Whamcloud - gitweb
705b3c062b5483557c0509b7a3d3e9b67c0120df
[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 [sun.com URL with a
20  * copy of GPLv2].
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/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 static cfs_sysctl_table_t kibnal_ctl_table[] = {
123         {
124                 .ctl_name = 1,
125                 .procname = "ipif_basename",
126                 .data     = &ipif_basename,
127                 .maxlen   = 1024,
128                 .mode     = 0444,
129                 .proc_handler = &proc_dostring
130         },
131         {
132                 .ctl_name = 2,
133                 .procname = "service_name",
134                 .data     = &service_name,
135                 .maxlen   = 1024,
136                 .mode     = 0444,
137                 .proc_handler = &proc_dostring
138         },
139         {
140                 .ctl_name = 3,
141                 .procname = "service_number",
142                 .data     = &service_number,
143                 .maxlen   = sizeof(int),
144                 .mode     = 0444,
145                 .proc_handler = &proc_dointvec
146         },
147         {
148                 .ctl_name = 4,
149                 .procname = "min_reconnect_interval",
150                 .data     = &min_reconnect_interval,
151                 .maxlen   = sizeof(int),
152                 .mode     = 0644,
153                 .proc_handler = &proc_dointvec
154         },
155         {
156                 .ctl_name = 5,
157                 .procname = "max_reconnect_interval",
158                 .data     = &max_reconnect_interval,
159                 .maxlen   = sizeof(int),
160                 .mode     = 0644,
161                 .proc_handler = &proc_dointvec
162         },
163         {
164                 .ctl_name = 6,
165                 .procname = "concurrent_peers",
166                 .data     = &concurrent_peers,
167                 .maxlen   = sizeof(int),
168                 .mode     = 0444,
169                 .proc_handler = &proc_dointvec
170         },
171         {
172                 .ctl_name = 7,
173                 .procname = "cksum",
174                 .data     = &cksum,
175                 .maxlen   = sizeof(int),
176                 .mode     = 0644,
177                 .proc_handler = &proc_dointvec
178         },
179         {
180                 .ctl_name = 8,
181                 .procname = "timeout",
182                 .data     = &timeout,
183                 .maxlen   = sizeof(int),
184                 .mode     = 0644,
185                 .proc_handler = &proc_dointvec
186         },
187         {
188                 .ctl_name = 9,
189                 .procname = "ntx",
190                 .data     = &ntx,
191                 .maxlen   = sizeof(int),
192                 .mode     = 0444,
193                 .proc_handler = &proc_dointvec
194         },
195         {
196                 .ctl_name = 10,
197                 .procname = "credits",
198                 .data     = &credits,
199                 .maxlen   = sizeof(int),
200                 .mode     = 0444,
201                 .proc_handler = &proc_dointvec
202         },
203         {
204                 .ctl_name = 11,
205                 .procname = "peer_credits",
206                 .data     = &peer_credits,
207                 .maxlen   = sizeof(int),
208                 .mode     = 0444,
209                 .proc_handler = &proc_dointvec
210         },
211         {
212                 .ctl_name = 12,
213                 .procname = "sd_retries",
214                 .data     = &sd_retries,
215                 .maxlen   = sizeof(int),
216                 .mode     = 0444,
217                 .proc_handler = &proc_dointvec
218         },
219         {
220                 .ctl_name = 13,
221                 .procname = "keepalive",
222                 .data     = &keepalive,
223                 .maxlen   = sizeof(int),
224                 .mode     = 0644,
225                 .proc_handler = &proc_dointvec
226         },
227         {
228                 .ctl_name = 14,
229                 .procname = "concurrent_sends",
230                 .data     = &concurrent_sends,
231                 .maxlen   = sizeof(int),
232                 .mode     = 0444,
233                 .proc_handler = &proc_dointvec
234         },
235         {0}
236 };
237
238 static cfs_sysctl_table_t kibnal_top_ctl_table[] = {
239         {
240                 .ctl_name = 203,
241                 .procname = "iibnal",
242                 .data     = NULL,
243                 .maxlen   = 0,
244                 .mode     = 0555,
245                 .child    = kibnal_ctl_table
246         },
247         {0}
248 };
249
250 int
251 kibnal_tunables_init ()
252 {
253         kibnal_tunables.kib_sysctl =
254                 cfs_register_sysctl_table(kibnal_top_ctl_table, 0);
255
256         if (kibnal_tunables.kib_sysctl == NULL)
257                 CWARN("Can't setup /proc tunables\n");
258
259         if (*kibnal_tunables.kib_concurrent_sends > IBNAL_RX_MSGS)
260                 *kibnal_tunables.kib_concurrent_sends = IBNAL_RX_MSGS;
261         if (*kibnal_tunables.kib_concurrent_sends < IBNAL_MSG_QUEUE_SIZE)
262                 *kibnal_tunables.kib_concurrent_sends = IBNAL_MSG_QUEUE_SIZE;
263
264         return 0;
265 }
266
267 void
268 kibnal_tunables_fini ()
269 {
270         if (kibnal_tunables.kib_sysctl != NULL)
271                 cfs_unregister_sysctl_table(kibnal_tunables.kib_sysctl);
272 }
273
274 #else
275
276 int
277 kibnal_tunables_init ()
278 {
279         return 0;
280 }
281
282 void
283 kibnal_tunables_fini ()
284 {
285 }
286
287 #endif