Whamcloud - gitweb
first part of 2.6.26 support (lnet/libcfs part)
[fs/lustre-release.git] / lnet / klnds / viblnd / viblnd_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 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lnet/klnds/viblnd/viblnd_modparams.c
37  *
38  * Author: Eric Barton <eric@bartonsoftware.com>
39  */
40
41 #include "viblnd.h"
42
43 static int service_number = 0x11b9a2;
44 CFS_MODULE_PARM(service_number, "i", int, 0444,
45                 "IB service number");
46
47 static int min_reconnect_interval = 1;
48 CFS_MODULE_PARM(min_reconnect_interval, "i", int, 0644,
49                 "minimum connection retry interval (seconds)");
50
51 static int max_reconnect_interval = 60;
52 CFS_MODULE_PARM(max_reconnect_interval, "i", int, 0644,
53                 "maximum connection retry interval (seconds)");
54
55 static int concurrent_peers = 1152;
56 CFS_MODULE_PARM(concurrent_peers, "i", int, 0444,
57                 "maximum number of peers that may connect");
58
59 static int cksum = 0;
60 CFS_MODULE_PARM(cksum, "i", int, 0644,
61                 "set non-zero to enable message (not RDMA) checksums");
62
63 static int timeout = 50;
64 CFS_MODULE_PARM(timeout, "i", int, 0644,
65                 "timeout (seconds)");
66
67 static int ntx = 256;
68 CFS_MODULE_PARM(ntx, "i", int, 0444,
69                 "# of message descriptors");
70
71 static int credits = 128;
72 CFS_MODULE_PARM(credits, "i", int, 0444,
73                 "# concurrent sends");
74
75 static int peer_credits = 8;
76 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
77                 "# concurrent sends to 1 peer");
78
79 static int arp_retries = 3;
80 CFS_MODULE_PARM(arp_retries, "i", int, 0644,
81                 "# of times to retry ARP");
82
83 static char *hca_basename = "InfiniHost";
84 CFS_MODULE_PARM(hca_basename, "s", charp, 0444,
85                 "HCA base name");
86
87 static char *ipif_basename = "ipoib";
88 CFS_MODULE_PARM(ipif_basename, "s", charp, 0444,
89                 "IPoIB interface base name");
90
91 static int local_ack_timeout = 0x12;
92 CFS_MODULE_PARM(local_ack_timeout, "i", int, 0644,
93                 "ACK timeout for low-level 'sends'");
94
95 static int retry_cnt = 7;
96 CFS_MODULE_PARM(retry_cnt, "i", int, 0644,
97                 "Retransmissions when no ACK received");
98
99 static int rnr_cnt = 6;
100 CFS_MODULE_PARM(rnr_cnt, "i", int, 0644,
101                 "RNR retransmissions");
102
103 static int rnr_nak_timer = 0x10;
104 CFS_MODULE_PARM(rnr_nak_timer, "i", int, 0644,
105                 "RNR retransmission interval");
106
107 static int keepalive = 100;
108 CFS_MODULE_PARM(keepalive, "i", int, 0644,
109                 "Idle time in seconds before sending a keepalive");
110
111 static int concurrent_sends = IBNAL_RX_MSGS;
112 CFS_MODULE_PARM(concurrent_sends, "i", int, 0644,
113                 "send work-queue sizing");
114
115 #if IBNAL_USE_FMR
116 static int fmr_remaps = 1000;
117 CFS_MODULE_PARM(fmr_remaps, "i", int, 0444,
118                 "FMR mappings allowed before unmap");
119 #endif
120
121 kib_tunables_t kibnal_tunables = {
122         .kib_service_number         = &service_number,
123         .kib_min_reconnect_interval = &min_reconnect_interval,
124         .kib_max_reconnect_interval = &max_reconnect_interval,
125         .kib_concurrent_peers       = &concurrent_peers,
126         .kib_cksum                  = &cksum,
127         .kib_timeout                = &timeout,
128         .kib_ntx                    = &ntx,
129         .kib_credits                = &credits,
130         .kib_peercredits            = &peer_credits,
131         .kib_arp_retries            = &arp_retries,
132         .kib_hca_basename           = &hca_basename,
133         .kib_ipif_basename          = &ipif_basename,
134         .kib_local_ack_timeout      = &local_ack_timeout,
135         .kib_retry_cnt              = &retry_cnt,
136         .kib_rnr_cnt                = &rnr_cnt,
137         .kib_rnr_nak_timer          = &rnr_nak_timer,
138         .kib_keepalive              = &keepalive,
139         .kib_concurrent_sends       = &concurrent_sends,
140 #if IBNAL_USE_FMR
141         .kib_fmr_remaps             = &fmr_remaps,
142 #endif
143 };
144
145 #ifndef HAVE_SYSCTL_UNNUMBERED
146
147 enum {
148         VIBLND_SERVICE = 1,
149         VIBLND_RECONNECT_MIN,
150         VIBLND_RECONNECT_MAX,
151         VIBLND_CONCURRENT_PEERS,
152         VIBLND_CHKSUM,
153         VIBLND_TIMEOUT,
154         VIBLND_NTX,
155         VIBLND_CREDITS,
156         VIBLND_PEER_CREDITS,
157         VIBLND_ARP_RETRIES,
158         VIBLND_HCA_BASENAME,
159         VIBLND_IPIF_BASENAME,
160         VIBLND_LOCAL_ACK_TIMEOUT,
161         VIBLND_RETRY_CNT,
162         VIBLND_RNR_CNT,
163         VIBLND_RNR_NAK_TIMER,
164         VIBLND_KEEPALIVE,
165         VIBLND_CONCURRENT_SENDS,
166         VIBLND_FMR_REMAPS
167 };        
168 #else
169
170 #define VIBLND_SERVICE          CTL_UNNUMBERED
171 #define VIBLND_RECONNECT_MIN    CTL_UNNUMBERED
172 #define VIBLND_RECONNECT_MAX    CTL_UNNUMBERED
173 #define VIBLND_CONCURRENT_PEERS CTL_UNNUMBERED
174 #define VIBLND_CHKSUM           CTL_UNNUMBERED
175 #define VIBLND_TIMEOUT          CTL_UNNUMBERED
176 #define VIBLND_NTX              CTL_UNNUMBERED
177 #define VIBLND_CREDITS          CTL_UNNUMBERED
178 #define VIBLND_PEER_CREDITS     CTL_UNNUMBERED
179 #define VIBLND_ARP_RETRIES      CTL_UNNUMBERED
180 #define VIBLND_HCA_BASENAME     CTL_UNNUMBERED
181 #define VIBLND_IPIF_BASENAME    CTL_UNNUMBERED
182 #define VIBLND_LOCAL_ACK_TIMEOUT CTL_UNNUMBERED
183 #define VIBLND_RETRY_CNT        CTL_UNNUMBERED
184 #define VIBLND_RNR_CNT          CTL_UNNUMBERED
185 #define VIBLND_RNR_NAK_TIMER    CTL_UNNUMBERED
186 #define VIBLND_KEEPALIVE        CTL_UNNUMBERED
187 #define VIBLND_CONCURRENT_SENDS CTL_UNNUMBERED
188 #define VIBLND_FMR_REMAPS       CTL_UNNUMBERED
189
190 #endif
191
192 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
193
194 static char hca_basename_space[32];
195 static char ipif_basename_space[32];
196
197 static cfs_sysctl_table_t kibnal_ctl_table[] = {
198         {
199                 .ctl_name = VIBLND_SERVICE,
200                 .procname = "service_number",
201                 .data     = &service_number,
202                 .maxlen   = sizeof(int),
203                 .mode     = 0444,
204                 .proc_handler = &proc_dointvec
205         },
206         {
207                 .ctl_name = VIBLND_RECONNECT_MIN,
208                 .procname = "min_reconnect_interval",
209                 .data     = &min_reconnect_interval,
210                 .maxlen   = sizeof(int),
211                 .mode     = 0644,
212                 .proc_handler = &proc_dointvec
213         },
214         {
215                 .ctl_name = VIBLND_RECONNECT_MAX,
216                 .procname = "max_reconnect_interval",
217                 .data     = &max_reconnect_interval,
218                 .maxlen   = sizeof(int),
219                 .mode     = 0644,
220                 .proc_handler = &proc_dointvec
221         },
222         {
223                 .ctl_name = VIBLND_CONCURRENT_PEERS,
224                 .procname = "concurrent_peers",
225                 .data     = &concurrent_peers,
226                 .maxlen   = sizeof(int),
227                 .mode     = 0444,
228                 .proc_handler = &proc_dointvec
229         },
230         {
231                 .ctl_name = VIBLND_CHKSUM,
232                 .procname = "cksum",
233                 .data     = &cksum,
234                 .maxlen   = sizeof(int),
235                 .mode     = 0644,
236                 .proc_handler = &proc_dointvec
237         },
238         {
239                 .ctl_name = VIBLND_TIMEOUT,
240                 .procname = "timeout",
241                 .data     = &timeout,
242                 .maxlen   = sizeof(int),
243                 .mode     = 0644,
244                 .proc_handler = &proc_dointvec
245         },
246         {
247                 .ctl_name = VIBLND_NTX,
248                 .procname = "ntx",
249                 .data     = &ntx,
250                 .maxlen   = sizeof(int),
251                 .mode     = 0444,
252                 .proc_handler = &proc_dointvec
253         },
254         {
255                 .ctl_name = VIBLND_CREDITS,
256                 .procname = "credits",
257                 .data     = &credits,
258                 .maxlen   = sizeof(int),
259                 .mode     = 0444,
260                 .proc_handler = &proc_dointvec
261         },
262         {
263                 .ctl_name = VIBLND_PEER_CREDITS,
264                 .procname = "peer_credits",
265                 .data     = &peer_credits,
266                 .maxlen   = sizeof(int),
267                 .mode     = 0444,
268                 .proc_handler = &proc_dointvec
269         },
270         {
271                 .ctl_name = VIBLND_ARP_RETRIES,
272                 .procname = "arp_retries",
273                 .data     = &arp_retries,
274                 .maxlen   = sizeof(int),
275                 .mode     = 0644,
276                 .proc_handler = &proc_dointvec
277         },
278         {
279                 .ctl_name = VIBLND_HCA_BASENAME,
280                 .procname = "hca_basename",
281                 .data     = hca_basename_space,
282                 .maxlen   = sizeof(hca_basename_space),
283                 .mode     = 0444,
284                 .proc_handler = &proc_dostring
285         },
286         {
287                 .ctl_name = VIBLND_IPIF_BASENAME,
288                 .procname = "ipif_basename",
289                 .data     = ipif_basename_space,
290                 .maxlen   = sizeof(ipif_basename_space),
291                 .mode     = 0444,
292                 .proc_handler = &proc_dostring
293         },
294         {
295                 .ctl_name = VIBLND_LOCAL_ACK_TIMEOUT,
296                 .procname = "local_ack_timeout",
297                 .data     = &local_ack_timeout,
298                 .maxlen   = sizeof(int),
299                 .mode     = 0644,
300                 .proc_handler = &proc_dointvec
301         },
302         {
303                 .ctl_name = VIBLND_RETRY_CNT,
304                 .procname = "retry_cnt",
305                 .data     = &retry_cnt,
306                 .maxlen   = sizeof(int),
307                 .mode     = 0644,
308                 .proc_handler = &proc_dointvec
309         },
310         {
311                 .ctl_name = VIBLND_RNR_CNT,
312                 .procname = "rnr_cnt",
313                 .data     = &rnr_cnt,
314                 .maxlen   = sizeof(int),
315                 .mode     = 0644,
316                 .proc_handler = &proc_dointvec
317         },
318         {
319                 .ctl_name = VIBLND_RNR_NAK_TIMER,
320                 .procname = "rnr_nak_timer",
321                 .data     = &rnr_nak_timer,
322                 .maxlen   = sizeof(int),
323                 .mode     = 0644,
324                 .proc_handler = &proc_dointvec
325         },
326         {
327                 .ctl_name = VIBLND_KEEPALIVE,
328                 .procname = "keepalive",
329                 .data     = &keepalive,
330                 .maxlen   = sizeof(int),
331                 .mode     = 0644,
332                 .proc_handler = &proc_dointvec
333         },
334         {
335                 .ctl_name = VIBLND_CONCURRENT_SENDS,
336                 .procname = "concurrent_sends",
337                 .data     = &concurrent_sends,
338                 .maxlen   = sizeof(int),
339                 .mode     = 0444,
340                 .proc_handler = &proc_dointvec
341         },
342 #if IBNAL_USE_FMR
343         {
344                 .ctl_name = VIBLND_FMR_REMAPS,
345                 .procname = "fmr_remaps",
346                 .data     = &fmr_remaps,
347                 .maxlen   = sizeof(int),
348                 .mode     = 0444,
349                 .proc_handler = &proc_dointvec
350         },
351 #endif
352         {0}
353 };
354
355 static cfs_sysctl_table_t kibnal_top_ctl_table[] = {
356         {
357                 .ctl_name = CTL_VIBLND,
358                 .procname = "vibnal",
359                 .data     = NULL,
360                 .maxlen   = 0,
361                 .mode     = 0555,
362                 .child    = kibnal_ctl_table
363         },
364         {0}
365 };
366
367 void
368 kibnal_initstrtunable(char *space, char *str, int size)
369 {
370         strncpy(space, str, size);
371         space[size-1] = 0;
372 }
373
374 int
375 kibnal_tunables_init ()
376 {
377         kibnal_initstrtunable(hca_basename_space, hca_basename,
378                               sizeof(hca_basename_space));
379         kibnal_initstrtunable(ipif_basename_space, ipif_basename,
380                               sizeof(ipif_basename_space));
381
382         kibnal_tunables.kib_sysctl =
383                 cfs_register_sysctl_table(kibnal_top_ctl_table, 0);
384
385         if (kibnal_tunables.kib_sysctl == NULL)
386                 CWARN("Can't setup /proc tunables\n");
387
388         if (*kibnal_tunables.kib_concurrent_sends > IBNAL_RX_MSGS)
389                 *kibnal_tunables.kib_concurrent_sends = IBNAL_RX_MSGS;
390         if (*kibnal_tunables.kib_concurrent_sends < IBNAL_MSG_QUEUE_SIZE)
391                 *kibnal_tunables.kib_concurrent_sends = IBNAL_MSG_QUEUE_SIZE;
392
393         return 0;
394 }
395
396 void
397 kibnal_tunables_fini ()
398 {
399         if (kibnal_tunables.kib_sysctl != NULL)
400                 cfs_unregister_sysctl_table(kibnal_tunables.kib_sysctl);
401 }
402
403 #else
404
405 int
406 kibnal_tunables_init ()
407 {
408         return 0;
409 }
410
411 void
412 kibnal_tunables_fini ()
413 {
414 }
415
416 #endif