Whamcloud - gitweb
LU-812 kernel: remove smp_lock.h
[fs/lustre-release.git] / lnet / klnds / mxlnd / mxlnd_modparams.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, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (C) 2006 Myricom, Inc.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lnet/klnds/mxlnd/mxlnd.c
37  *
38  * Author: Eric Barton <eric@bartonsoftware.com>
39  * Author: Scott Atchley <atchley at myri.com>
40  */
41
42 #include "mxlnd.h"
43
44 static int n_waitd = MXLND_N_SCHED;
45 CFS_MODULE_PARM(n_waitd, "i", int, 0444,
46                 "# of completion daemons");
47
48 /* this was used to allocate global rxs which are no londer used */
49 static int max_peers = MXLND_MAX_PEERS;
50 CFS_MODULE_PARM(max_peers, "i", int, 0444,
51                 "Unused - was maximum number of peers that may connect");
52
53 static int cksum = MXLND_CKSUM;
54 CFS_MODULE_PARM(cksum, "i", int, 0644,
55                 "set non-zero to enable message (not data payload) checksums");
56
57 static int ntx = MXLND_NTX;
58 CFS_MODULE_PARM(ntx, "i", int, 0444,
59                 "# of total tx message descriptors");
60
61 /* this duplicates ntx */
62 static int credits = MXLND_NTX;
63 CFS_MODULE_PARM(credits, "i", int, 0444,
64                 "Unused - was # concurrent sends to all peers");
65
66 static int peercredits = MXLND_MSG_QUEUE_DEPTH;
67 CFS_MODULE_PARM(peercredits, "i", int, 0444,
68                 "# concurrent sends to one peer");
69
70 static int board = MXLND_MX_BOARD;
71 CFS_MODULE_PARM(board, "i", int, 0444,
72                 "index value of the Myrinet board (NIC)");
73
74 static int ep_id = MXLND_MX_EP_ID;
75 CFS_MODULE_PARM(ep_id, "i", int, 0444, "MX endpoint ID");
76
77 static char *ipif_name = "myri0";
78 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
79                 "IPoMX interface name");
80
81 static int polling = MXLND_POLLING;
82 CFS_MODULE_PARM(polling, "i", int, 0444,
83                 "Use 0 to block (wait). A value > 0 will poll that many times before blocking");
84
85 static char *hosts = NULL;
86 CFS_MODULE_PARM(hosts, "s", charp, 0444,
87                 "Unused - was IP-to-hostname resolution file");
88
89 kmx_tunables_t kmxlnd_tunables = {
90         .kmx_n_waitd            = &n_waitd,
91         .kmx_max_peers          = &max_peers,
92         .kmx_cksum              = &cksum,
93         .kmx_ntx                = &ntx,
94         .kmx_credits            = &credits,
95         .kmx_peercredits        = &peercredits,
96         .kmx_board              = &board,
97         .kmx_ep_id              = &ep_id,
98         .kmx_default_ipif       = &ipif_name,
99         .kmx_polling            = &polling
100 };
101
102 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
103
104 static char ipif_basename_space[32];
105
106 #ifndef HAVE_SYSCTL_UNNUMBERED
107
108 enum {
109         MXLND_N_WAITD   = 1,
110         MXLND_MAX_PEERS,
111         MXLND_CKSUM,
112         MXLND_NNTX,
113         MXLND_CREDITS,
114         MXLND_BOARD,
115         MXLND_EP_ID,
116         MXLND_IPIF_BASENAME,
117         MXLND_POLLING
118 };
119 #else
120
121 #define MXLND_N_WAITD           CTL_UNNUMBERED
122 #define MXLND_MAX_PEERS         CTL_UNNUMBERED
123 #define MXLND_CKSUM             CTL_UNNUMBERED
124 #define MXLND_NNTX              CTL_UNNUMBERED
125 #define MXLND_CREDITS           CTL_UNNUMBERED
126 #define MXLND_BOARD             CTL_UNNUMBERED
127 #define MXLND_EP_ID             CTL_UNNUMBERED
128 #define MXLND_IPIF_BASENAME     CTL_UNNUMBERED
129 #define MXLND_POLLING           CTL_UNNUMBERED
130
131 #endif
132
133 static cfs_sysctl_table_t kmxlnd_ctl_table[] = {
134         {
135                 .ctl_name = 1,
136                 .procname = "n_waitd",
137                 .data     = &n_waitd,
138                 .maxlen   = sizeof(int),
139                 .mode     = 0444,
140                 .proc_handler = &proc_dointvec
141         },
142         {
143                 .ctl_name = 2,
144                 .procname = "max_peers",
145                 .data     = &max_peers,
146                 .maxlen   = sizeof(int),
147                 .mode     = 0444,
148                 .proc_handler = &proc_dointvec
149         },
150         {
151                 .ctl_name = 3,
152                 .procname = "cksum",
153                 .data     = &cksum,
154                 .maxlen   = sizeof(int),
155                 .mode     = 0644,
156                 .proc_handler = &proc_dointvec
157         },
158         {
159                 .ctl_name = 4,
160                 .procname = "ntx",
161                 .data     = &ntx,
162                 .maxlen   = sizeof(int),
163                 .mode     = 0444,
164                 .proc_handler = &proc_dointvec
165         },
166         {
167                 .ctl_name = 5,
168                 .procname = "credits",
169                 .data     = &credits,
170                 .maxlen   = sizeof(int),
171                 .mode     = 0444,
172                 .proc_handler = &proc_dointvec
173         },
174         {
175                 .ctl_name = 6,
176                 .procname = "peercredits",
177                 .data     = &peercredits,
178                 .maxlen   = sizeof(int),
179                 .mode     = 0444,
180                 .proc_handler = &proc_dointvec
181         },
182         {
183                 .ctl_name = 7,
184                 .procname = "board",
185                 .data     = &board,
186                 .maxlen   = sizeof(int),
187                 .mode     = 0444,
188                 .proc_handler = &proc_dointvec
189         },
190         {
191                 .ctl_name = 8,
192                 .procname = "ep_id",
193                 .data     = &ep_id,
194                 .maxlen   = sizeof(int),
195                 .mode     = 0444,
196                 .proc_handler = &proc_dointvec
197         },
198         {
199                 .ctl_name = 9,
200                 .procname = "ipif_name",
201                 .data     = ipif_basename_space,
202                 .maxlen   = sizeof(ipif_basename_space),
203                 .mode     = 0444,
204                 .proc_handler = &proc_dostring
205         },
206         {
207                 .ctl_name = 10,
208                 .procname = "polling",
209                 .data     = &polling,
210                 .maxlen   = sizeof(int),
211                 .mode     = 0444,
212                 .proc_handler = &proc_dointvec
213         },
214         {0}
215 };
216
217 static cfs_sysctl_table_t kmxlnd_top_ctl_table[] = {
218         {
219                 .ctl_name = 208,
220                 .procname = "mxlnd",
221                 .data     = NULL,
222                 .maxlen   = 0,
223                 .mode     = 0555,
224                 .child    = kmxlnd_ctl_table
225         },
226         {0}
227 };
228
229 void
230 kmxlnd_initstrtunable(char *space, char *str, int size)
231 {
232         strncpy(space, str, size);
233         space[size-1] = 0;
234 }
235
236 void
237 kmxlnd_sysctl_init (void)
238 {
239         kmxlnd_initstrtunable(ipif_basename_space, ipif_name,
240                               sizeof(ipif_basename_space));
241
242         kmxlnd_tunables.kib_sysctl =
243                 cfs_register_sysctl_table(kmxlnd_top_ctl_table, 0);
244
245         if (kmxlnd_tunables.kib_sysctl == NULL)
246                 CWARN("Can't setup /proc tunables\n");
247 }
248
249 void
250 kmxlnd_sysctl_fini (void)
251 {
252         if (kmxlnd_tunables.kib_sysctl != NULL)
253                 cfs_unregister_sysctl_table(kmxlnd_tunables.kib_sysctl);
254 }
255
256 #else
257
258 void
259 kmxlnd_sysctl_init (void)
260 {
261 }
262
263 void
264 kmxlnd_sysctl_fini (void)
265 {
266 }
267
268 #endif
269
270 int
271 kmxlnd_tunables_init (void)
272 {
273         kmxlnd_sysctl_init();
274         return 0;
275 }
276
277 void
278 kmxlnd_tunables_fini (void)
279 {
280         kmxlnd_sysctl_fini();
281 }