Whamcloud - gitweb
Revert "b20288 fix a deadlock in kiblnd_check_conns i=isaac i=maxim"
[fs/lustre-release.git] / lnet / klnds / iiblnd / iiblnd_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 (c) 2007, 2010, Oracle and/or its affiliates. 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/iiblnd/iiblnd_modparams.c
37  *
38  * Author: Eric Barton <eric@bartonsoftware.com>
39  */
40
41 #include "iiblnd.h"
42
43 static char *ipif_basename = "ib";
44 CFS_MODULE_PARM(ipif_basename, "s", charp, 0444,
45                 "IPoIB interface base name");
46
47 static char *service_name = "iiblnd";
48 CFS_MODULE_PARM(service_name, "s", charp, 0444,
49                 "IB service name");
50
51 static int service_number = 0x11b9a2;
52 CFS_MODULE_PARM(service_number, "i", int, 0444,
53                 "IB service number");
54
55 static int min_reconnect_interval = 1;
56 CFS_MODULE_PARM(min_reconnect_interval, "i", int, 0644,
57                 "minimum connection retry interval (seconds)");
58
59 static int max_reconnect_interval = 60;
60 CFS_MODULE_PARM(max_reconnect_interval, "i", int, 0644,
61                 "maximum connection retry interval (seconds)");
62
63 static int concurrent_peers = 1152;
64 CFS_MODULE_PARM(concurrent_peers, "i", int, 0444,
65                 "maximum number of peers that may connect");
66
67 static int cksum = 0;
68 CFS_MODULE_PARM(cksum, "i", int, 0644,
69                 "set non-zero to enable message (not RDMA) checksums");
70
71 static int timeout = 50;
72 CFS_MODULE_PARM(timeout, "i", int, 0644,
73                 "timeout (seconds)");
74
75 static int ntx = 256;
76 CFS_MODULE_PARM(ntx, "i", int, 0444,
77                 "# of message descriptors");
78
79 static int credits = 128;
80 CFS_MODULE_PARM(credits, "i", int, 0444,
81                 "# concurrent sends");
82
83 static int peer_credits = 8;
84 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
85                 "# concurrent sends to 1 peer");
86
87 static int sd_retries = 8;
88 CFS_MODULE_PARM(sd_retries, "i", int, 0444,
89                 "# times to retry SD queries");
90
91 static int keepalive = 100;
92 CFS_MODULE_PARM(keepalive, "i", int, 0644,
93                 "Idle time in seconds before sending a keepalive");
94
95 static int concurrent_sends = IBNAL_RX_MSGS;
96 CFS_MODULE_PARM(concurrent_sends, "i", int, 0644,
97                 "Send work queue sizing");
98
99 kib_tunables_t kibnal_tunables = {
100         .kib_ipif_basename          = &ipif_basename,
101         .kib_service_name           = &service_name,
102         .kib_service_number         = &service_number,
103         .kib_min_reconnect_interval = &min_reconnect_interval,
104         .kib_max_reconnect_interval = &max_reconnect_interval,
105         .kib_concurrent_peers       = &concurrent_peers,
106         .kib_cksum                  = &cksum,
107         .kib_timeout                = &timeout,
108         .kib_keepalive              = &keepalive,
109         .kib_ntx                    = &ntx,
110         .kib_credits                = &credits,
111         .kib_peercredits            = &peer_credits,
112         .kib_sd_retries             = &sd_retries,
113         .kib_concurrent_sends       = &concurrent_sends,
114 };
115
116 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
117
118 /* NB max_size specified for proc_dostring entries only needs to be big enough
119  * not to truncate the printout; it only needs to be the actual size of the
120  * string buffer if we allow writes (and we don't) */
121
122 #ifdef HAVE_SYSCTL_UNNUMBERED
123
124 enum {
125         IIBLND_IPIF_BASENAME = 1,
126         IIBLND_SERVICE_NAME,
127         IIBLND_SERVICE_NUMBER,
128         IIBLND_RECONNECT_MIN,
129         IIBLND_RECONNECT_MAX,
130         IIBLND_CONCURRENT_PEERS,
131         IIBLND_CKSUM,
132         IIBLND_TIMEOUT,
133         IIBLND_NTX,
134         IIBLND_CREDITS,
135         IIBLND_PEER_CREDITS,
136         IIBLND_SD_RETRIES,
137         IIBLND_KEEPALIVE,
138         IIBLND_CONCURRENT_SENDS
139 };
140
141 #else
142
143 #define IIBLND_IPIF_BASENAME    CTL_UNNUMBERED
144 #define IIBLND_SERVICE_NAME     CTL_UNNUMBERED
145 #define IIBLND_SERVICE_NUMBER   CTL_UNNUMBERED
146 #define IIBLND_RECONNECT_MIN    CTL_UNNUMBERED
147 #define IIBLND_RECONNECT_MAX    CTL_UNNUMBERED
148 #define IIBLND_CONCURRENT_PEERS CTL_UNNUMBERED
149 #define IIBLND_CKSUM            CTL_UNNUMBERED
150 #define IIBLND_TIMEOUT          CTL_UNNUMBERED
151 #define IIBLND_NTX              CTL_UNNUMBERED
152 #define IIBLND_CREDITS          CTL_UNNUMBERED
153 #define IIBLND_PEER_CREDITS     CTL_UNNUMBERED
154 #define IIBLND_SD_RETRIES       CTL_UNNUMBERED
155 #define IIBLND_KEEPALIVE        CTL_UNNUMBERED
156 #define IIBLND_CONCURRENT_SENDS CTL_UNNUMBERED
157
158 #endif
159
160 static cfs_sysctl_table_t kibnal_ctl_table[] = {
161         {
162                 .ctl_name = IBBLND_IPIF_BASENAME,
163                 .procname = "ipif_basename",
164                 .data     = &ipif_basename,
165                 .maxlen   = 1024,
166                 .mode     = 0444,
167                 .proc_handler = &proc_dostring
168         },
169         {
170                 .ctl_name = IIBLND_SERVICE_NAME,
171                 .procname = "service_name",
172                 .data     = &service_name,
173                 .maxlen   = 1024,
174                 .mode     = 0444,
175                 .proc_handler = &proc_dostring
176         },
177         {
178                 .ctl_name = IIBLND_SERVICE_NUMBER,
179                 .procname = "service_number",
180                 .data     = &service_number,
181                 .maxlen   = sizeof(int),
182                 .mode     = 0444,
183                 .proc_handler = &proc_dointvec
184         },
185         {
186                 .ctl_name = IIBLND_RECONNECT_MIN,
187                 .procname = "min_reconnect_interval",
188                 .data     = &min_reconnect_interval,
189                 .maxlen   = sizeof(int),
190                 .mode     = 0644,
191                 .proc_handler = &proc_dointvec
192         },
193         {
194                 .ctl_name = IIBLND_RECONNECT_MAX,
195                 .procname = "max_reconnect_interval",
196                 .data     = &max_reconnect_interval,
197                 .maxlen   = sizeof(int),
198                 .mode     = 0644,
199                 .proc_handler = &proc_dointvec
200         },
201         {
202                 .ctl_name = IIBLND_CONCURRENT_PEERS,
203                 .procname = "concurrent_peers",
204                 .data     = &concurrent_peers,
205                 .maxlen   = sizeof(int),
206                 .mode     = 0444,
207                 .proc_handler = &proc_dointvec
208         },
209         {
210                 .ctl_name = IIBLND_CKSUM,
211                 .procname = "cksum",
212                 .data     = &cksum,
213                 .maxlen   = sizeof(int),
214                 .mode     = 0644,
215                 .proc_handler = &proc_dointvec
216         },
217         {
218                 .ctl_name = IIBLND_TIMEOUT,
219                 .procname = "timeout",
220                 .data     = &timeout,
221                 .maxlen   = sizeof(int),
222                 .mode     = 0644,
223                 .proc_handler = &proc_dointvec
224         },
225         {
226                 .ctl_name = IIBLND_NTX,
227                 .procname = "ntx",
228                 .data     = &ntx,
229                 .maxlen   = sizeof(int),
230                 .mode     = 0444,
231                 .proc_handler = &proc_dointvec
232         },
233         {
234                 .ctl_name = IIBLND_CREDITS,
235                 .procname = "credits",
236                 .data     = &credits,
237                 .maxlen   = sizeof(int),
238                 .mode     = 0444,
239                 .proc_handler = &proc_dointvec
240         },
241         {
242                 .ctl_name = IIBLND_PEER_CREDITS,
243                 .procname = "peer_credits",
244                 .data     = &peer_credits,
245                 .maxlen   = sizeof(int),
246                 .mode     = 0444,
247                 .proc_handler = &proc_dointvec
248         },
249         {
250                 .ctl_name = IIBLND_SD_RETRIES,
251                 .procname = "sd_retries",
252                 .data     = &sd_retries,
253                 .maxlen   = sizeof(int),
254                 .mode     = 0444,
255                 .proc_handler = &proc_dointvec
256         },
257         {
258                 .ctl_name = IIBLND_KEEPALIVE,
259                 .procname = "keepalive",
260                 .data     = &keepalive,
261                 .maxlen   = sizeof(int),
262                 .mode     = 0644,
263                 .proc_handler = &proc_dointvec
264         },
265         {
266                 .ctl_name = IIBLND_CONCURRENT_SENDS,
267                 .procname = "concurrent_sends",
268                 .data     = &concurrent_sends,
269                 .maxlen   = sizeof(int),
270                 .mode     = 0444,
271                 .proc_handler = &proc_dointvec
272         },
273         {0}
274 };
275
276 static cfs_sysctl_table_t kibnal_top_ctl_table[] = {
277         {
278                 .ctl_name = CTL_IIBLND,
279                 .procname = "iibnal",
280                 .data     = NULL,
281                 .maxlen   = 0,
282                 .mode     = 0555,
283                 .child    = kibnal_ctl_table
284         },
285         {0}
286 };
287
288 int
289 kibnal_tunables_init ()
290 {
291         kibnal_tunables.kib_sysctl =
292                 cfs_register_sysctl_table(kibnal_top_ctl_table, 0);
293
294         if (kibnal_tunables.kib_sysctl == NULL)
295                 CWARN("Can't setup /proc tunables\n");
296
297         if (*kibnal_tunables.kib_concurrent_sends > IBNAL_RX_MSGS)
298                 *kibnal_tunables.kib_concurrent_sends = IBNAL_RX_MSGS;
299         if (*kibnal_tunables.kib_concurrent_sends < IBNAL_MSG_QUEUE_SIZE)
300                 *kibnal_tunables.kib_concurrent_sends = IBNAL_MSG_QUEUE_SIZE;
301
302         return 0;
303 }
304
305 void
306 kibnal_tunables_fini ()
307 {
308         if (kibnal_tunables.kib_sysctl != NULL)
309                 cfs_unregister_sysctl_table(kibnal_tunables.kib_sysctl);
310 }
311
312 #else
313
314 int
315 kibnal_tunables_init ()
316 {
317         return 0;
318 }
319
320 void
321 kibnal_tunables_fini ()
322 {
323 }
324
325 #endif