Whamcloud - gitweb
LU-1730 obdclass: fix cfs_lockdep_set_class() typos
[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) 2011, 2012, Whamcloud, Inc.
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 #ifndef EXPORT_SYMTAB
37 # define EXPORT_SYMTAB
38 #endif
39 #define DEBUG_SUBSYSTEM S_LNET
40
41 #include <libcfs/libcfs.h>
42
43 /** Global cpu partition table */
44 struct cfs_cpt_table   *cfs_cpt_table __read_mostly = NULL;
45 EXPORT_SYMBOL(cfs_cpt_table);
46
47 #ifndef HAVE_LIBCFS_CPT
48
49 #define CFS_CPU_VERSION_MAGIC           0xbabecafe
50
51 struct cfs_cpt_table *
52 cfs_cpt_table_alloc(unsigned int ncpt)
53 {
54         struct cfs_cpt_table *cptab;
55
56         if (ncpt != 1) {
57                 CERROR("Can't support cpu partition number %d\n", ncpt);
58                 return NULL;
59         }
60
61         LIBCFS_ALLOC(cptab, sizeof(*cptab));
62         if (cptab != NULL) {
63                 cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
64                 cptab->ctb_nparts  = ncpt;
65         }
66
67         return cptab;
68 }
69 EXPORT_SYMBOL(cfs_cpt_table_alloc);
70
71 void
72 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
73 {
74         LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
75
76         LIBCFS_FREE(cptab, sizeof(*cptab));
77 }
78 EXPORT_SYMBOL(cfs_cpt_table_free);
79
80 int
81 cfs_cpt_number(struct cfs_cpt_table *cptab)
82 {
83         return 1;
84 }
85 EXPORT_SYMBOL(cfs_cpt_number);
86
87 int
88 cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
89 {
90         return 1;
91 }
92 EXPORT_SYMBOL(cfs_cpt_number);
93
94 int
95 cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
96 {
97         return 1;
98 }
99 EXPORT_SYMBOL(cfs_cpt_online);
100
101 int
102 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
103 {
104         return 1;
105 }
106 EXPORT_SYMBOL(cfs_cpt_set_cpu);
107
108 void
109 cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
110 {
111 }
112 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
113
114 int
115 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
116 {
117         return 1;
118 }
119 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
120
121 void
122 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
123 {
124 }
125 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
126
127 int
128 cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
129 {
130         return 1;
131 }
132 EXPORT_SYMBOL(cfs_cpt_set_node);
133
134 void
135 cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
136 {
137 }
138 EXPORT_SYMBOL(cfs_cpt_unset_node);
139
140 int
141 cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
142 {
143         return 1;
144 }
145 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
146
147 void
148 cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
149 {
150 }
151 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
152
153 void
154 cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
155 {
156 }
157 EXPORT_SYMBOL(cfs_cpt_clear);
158
159 int
160 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
161 {
162         return 0;
163 }
164 EXPORT_SYMBOL(cfs_cpt_spread_node);
165
166 int
167 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
168 {
169         return 0;
170 }
171 EXPORT_SYMBOL(cfs_cpt_current);
172
173 int
174 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
175 {
176         return 0;
177 }
178 EXPORT_SYMBOL(cfs_cpt_from_cpu);
179
180 int
181 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
182 {
183         return 0;
184 }
185 EXPORT_SYMBOL(cfs_cpt_bind);
186
187 void
188 cfs_cpu_fini(void)
189 {
190         if (cfs_cpt_table != NULL) {
191                 cfs_cpt_table_free(cfs_cpt_table);
192                 cfs_cpt_table = NULL;
193         }
194 }
195
196 int
197 cfs_cpu_init(void)
198 {
199         cfs_cpt_table = cfs_cpt_table_alloc(1);
200
201         return cfs_cpt_table != NULL ? 0 : -1;
202 }
203
204 #endif /* HAVE_LIBCFS_CPT */