Whamcloud - gitweb
LU-4372 gss: Compatibility cache_register_net 2.6.x/3.3 kernel
[fs/lustre-release.git] / libcfs / libcfs / libcfs_cpu.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25  * Copyright (c) 2012, 2013, Intel Corporation.
26  */
27 /*
28  * This file is part of Lustre, http://www.lustre.org/
29  * Lustre is a trademark of Sun Microsystems, Inc.
30  *
31  * Please see comments in libcfs/include/libcfs/libcfs_cpu.h for introduction
32  *
33  * Author: liang@whamcloud.com
34  */
35
36 #define DEBUG_SUBSYSTEM S_LNET
37
38 #include <libcfs/libcfs.h>
39
40 /** Global CPU partition table */
41 struct cfs_cpt_table   *cfs_cpt_table __read_mostly = NULL;
42 EXPORT_SYMBOL(cfs_cpt_table);
43
44 #ifndef HAVE_LIBCFS_CPT
45
46 #define CFS_CPU_VERSION_MAGIC           0xbabecafe
47
48 struct cfs_cpt_table *
49 cfs_cpt_table_alloc(unsigned int ncpt)
50 {
51         struct cfs_cpt_table *cptab;
52
53         if (ncpt != 1) {
54                 CERROR("Can't support cpu partition number %d\n", ncpt);
55                 return NULL;
56         }
57
58         LIBCFS_ALLOC(cptab, sizeof(*cptab));
59         if (cptab != NULL) {
60                 cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
61                 cptab->ctb_nparts  = ncpt;
62         }
63
64         return cptab;
65 }
66 EXPORT_SYMBOL(cfs_cpt_table_alloc);
67
68 void
69 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
70 {
71         LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
72
73         LIBCFS_FREE(cptab, sizeof(*cptab));
74 }
75 EXPORT_SYMBOL(cfs_cpt_table_free);
76
77 int
78 cfs_cpt_number(struct cfs_cpt_table *cptab)
79 {
80         return 1;
81 }
82 EXPORT_SYMBOL(cfs_cpt_number);
83
84 int
85 cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
86 {
87         return 1;
88 }
89 EXPORT_SYMBOL(cfs_cpt_weight);
90
91 int
92 cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
93 {
94         return 1;
95 }
96 EXPORT_SYMBOL(cfs_cpt_online);
97
98 int
99 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
100 {
101         return 1;
102 }
103 EXPORT_SYMBOL(cfs_cpt_set_cpu);
104
105 void
106 cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
107 {
108 }
109 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
110
111 int
112 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
113 {
114         return 1;
115 }
116 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
117
118 void
119 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
120 {
121 }
122 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
123
124 int
125 cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
126 {
127         return 1;
128 }
129 EXPORT_SYMBOL(cfs_cpt_set_node);
130
131 void
132 cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
133 {
134 }
135 EXPORT_SYMBOL(cfs_cpt_unset_node);
136
137 int
138 cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
139 {
140         return 1;
141 }
142 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
143
144 void
145 cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
146 {
147 }
148 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
149
150 void
151 cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
152 {
153 }
154 EXPORT_SYMBOL(cfs_cpt_clear);
155
156 int
157 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
158 {
159         return 0;
160 }
161 EXPORT_SYMBOL(cfs_cpt_spread_node);
162
163 int
164 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
165 {
166         return 0;
167 }
168 EXPORT_SYMBOL(cfs_cpt_current);
169
170 int
171 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
172 {
173         return 0;
174 }
175 EXPORT_SYMBOL(cfs_cpt_of_cpu);
176
177 int
178 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
179 {
180         return 0;
181 }
182 EXPORT_SYMBOL(cfs_cpt_bind);
183
184 void
185 cfs_cpu_fini(void)
186 {
187         if (cfs_cpt_table != NULL) {
188                 cfs_cpt_table_free(cfs_cpt_table);
189                 cfs_cpt_table = NULL;
190         }
191 }
192
193 int
194 cfs_cpu_init(void)
195 {
196         cfs_cpt_table = cfs_cpt_table_alloc(1);
197
198         return cfs_cpt_table != NULL ? 0 : -1;
199 }
200
201 #endif /* HAVE_LIBCFS_CPT */