Whamcloud - gitweb
87dec6823be56c677414a11d826091542dc64308
[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                 set_bit(0, &cptab->ctb_nodemask);
62                 cptab->ctb_nparts  = ncpt;
63         }
64
65         return cptab;
66 }
67 EXPORT_SYMBOL(cfs_cpt_table_alloc);
68
69 void
70 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
71 {
72         LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
73
74         LIBCFS_FREE(cptab, sizeof(*cptab));
75 }
76 EXPORT_SYMBOL(cfs_cpt_table_free);
77
78 int
79 cfs_cpt_number(struct cfs_cpt_table *cptab)
80 {
81         return 1;
82 }
83 EXPORT_SYMBOL(cfs_cpt_number);
84
85 int
86 cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
87 {
88         return 1;
89 }
90 EXPORT_SYMBOL(cfs_cpt_weight);
91
92 int
93 cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
94 {
95         return 1;
96 }
97 EXPORT_SYMBOL(cfs_cpt_online);
98
99 nodemask_t *
100 cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
101 {
102         return &cptab->ctb_nodemask;
103 }
104 EXPORT_SYMBOL(cfs_cpt_cpumask);
105
106 int
107 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
108 {
109         return 1;
110 }
111 EXPORT_SYMBOL(cfs_cpt_set_cpu);
112
113 void
114 cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
115 {
116 }
117 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
118
119 int
120 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
121 {
122         return 1;
123 }
124 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
125
126 void
127 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
128 {
129 }
130 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
131
132 int
133 cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
134 {
135         return 1;
136 }
137 EXPORT_SYMBOL(cfs_cpt_set_node);
138
139 void
140 cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
141 {
142 }
143 EXPORT_SYMBOL(cfs_cpt_unset_node);
144
145 int
146 cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
147 {
148         return 1;
149 }
150 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
151
152 void
153 cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
154 {
155 }
156 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
157
158 void
159 cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
160 {
161 }
162 EXPORT_SYMBOL(cfs_cpt_clear);
163
164 int
165 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
166 {
167         return 0;
168 }
169 EXPORT_SYMBOL(cfs_cpt_spread_node);
170
171 int
172 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
173 {
174         return 0;
175 }
176 EXPORT_SYMBOL(cfs_cpt_current);
177
178 int
179 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
180 {
181         return 0;
182 }
183 EXPORT_SYMBOL(cfs_cpt_of_cpu);
184
185 int
186 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
187 {
188         return 0;
189 }
190 EXPORT_SYMBOL(cfs_cpt_bind);
191
192 void
193 cfs_cpu_fini(void)
194 {
195         if (cfs_cpt_table != NULL) {
196                 cfs_cpt_table_free(cfs_cpt_table);
197                 cfs_cpt_table = NULL;
198         }
199 }
200
201 int
202 cfs_cpu_init(void)
203 {
204         cfs_cpt_table = cfs_cpt_table_alloc(1);
205
206         return cfs_cpt_table != NULL ? 0 : -1;
207 }
208
209 #endif /* HAVE_LIBCFS_CPT */