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