Whamcloud - gitweb
b=16098
[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 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
146
147 static char hca_basename_space[32];
148 static char ipif_basename_space[32];
149
150 static cfs_sysctl_table_t kibnal_ctl_table[] = {
151         {
152                 .ctl_name = 1,
153                 .procname = "service_number",
154                 .data     = &service_number,
155                 .maxlen   = sizeof(int),
156                 .mode     = 0444,
157                 .proc_handler = &proc_dointvec
158         },
159         {
160                 .ctl_name = 2,
161                 .procname = "min_reconnect_interval",
162                 .data     = &min_reconnect_interval,
163                 .maxlen   = sizeof(int),
164                 .mode     = 0644,
165                 .proc_handler = &proc_dointvec
166         },
167         {
168                 .ctl_name = 3,
169                 .procname = "max_reconnect_interval",
170                 .data     = &max_reconnect_interval,
171                 .maxlen   = sizeof(int),
172                 .mode     = 0644,
173                 .proc_handler = &proc_dointvec
174         },
175         {
176                 .ctl_name = 4,
177                 .procname = "concurrent_peers",
178                 .data     = &concurrent_peers,
179                 .maxlen   = sizeof(int),
180                 .mode     = 0444,
181                 .proc_handler = &proc_dointvec
182         },
183         {
184                 .ctl_name = 5,
185                 .procname = "cksum",
186                 .data     = &cksum,
187                 .maxlen   = sizeof(int),
188                 .mode     = 0644,
189                 .proc_handler = &proc_dointvec
190         },
191         {
192                 .ctl_name = 6,
193                 .procname = "timeout",
194                 .data     = &timeout,
195                 .maxlen   = sizeof(int),
196                 .mode     = 0644,
197                 .proc_handler = &proc_dointvec
198         },
199         {
200                 .ctl_name = 7,
201                 .procname = "ntx",
202                 .data     = &ntx,
203                 .maxlen   = sizeof(int),
204                 .mode     = 0444,
205                 .proc_handler = &proc_dointvec
206         },
207         {
208                 .ctl_name = 8,
209                 .procname = "credits",
210                 .data     = &credits,
211                 .maxlen   = sizeof(int),
212                 .mode     = 0444,
213                 .proc_handler = &proc_dointvec
214         },
215         {
216                 .ctl_name = 9,
217                 .procname = "peer_credits",
218                 .data     = &peer_credits,
219                 .maxlen   = sizeof(int),
220                 .mode     = 0444,
221                 .proc_handler = &proc_dointvec
222         },
223         {
224                 .ctl_name = 10,
225                 .procname = "arp_retries",
226                 .data     = &arp_retries,
227                 .maxlen   = sizeof(int),
228                 .mode     = 0644,
229                 .proc_handler = &proc_dointvec
230         },
231         {
232                 .ctl_name = 11,
233                 .procname = "hca_basename",
234                 .data     = hca_basename_space,
235                 .maxlen   = sizeof(hca_basename_space),
236                 .mode     = 0444,
237                 .proc_handler = &proc_dostring
238         },
239         {
240                 .ctl_name = 12,
241                 .procname = "ipif_basename",
242                 .data     = ipif_basename_space,
243                 .maxlen   = sizeof(ipif_basename_space),
244                 .mode     = 0444,
245                 .proc_handler = &proc_dostring
246         },
247         {
248                 .ctl_name = 13,
249                 .procname = "local_ack_timeout",
250                 .data     = &local_ack_timeout,
251                 .maxlen   = sizeof(int),
252                 .mode     = 0644,
253                 .proc_handler = &proc_dointvec
254         },
255         {
256                 .ctl_name = 14,
257                 .procname = "retry_cnt",
258                 .data     = &retry_cnt,
259                 .maxlen   = sizeof(int),
260                 .mode     = 0644,
261                 .proc_handler = &proc_dointvec
262         },
263         {
264                 .ctl_name = 15,
265                 .procname = "rnr_cnt",
266                 .data     = &rnr_cnt,
267                 .maxlen   = sizeof(int),
268                 .mode     = 0644,
269                 .proc_handler = &proc_dointvec
270         },
271         {
272                 .ctl_name = 16,
273                 .procname = "rnr_nak_timer",
274                 .data     = &rnr_nak_timer,
275                 .maxlen   = sizeof(int),
276                 .mode     = 0644,
277                 .proc_handler = &proc_dointvec
278         },
279         {
280                 .ctl_name = 17,
281                 .procname = "keepalive",
282                 .data     = &keepalive,
283                 .maxlen   = sizeof(int),
284                 .mode     = 0644,
285                 .proc_handler = &proc_dointvec
286         },
287         {
288                 .ctl_name = 18,
289                 .procname = "concurrent_sends",
290                 .data     = &concurrent_sends,
291                 .maxlen   = sizeof(int),
292                 .mode     = 0444,
293                 .proc_handler = &proc_dointvec
294         },
295 #if IBNAL_USE_FMR
296         {
297                 .ctl_name = 19,
298                 .procname = "fmr_remaps",
299                 .data     = &fmr_remaps,
300                 .maxlen   = sizeof(int),
301                 .mode     = 0444,
302                 .proc_handler = &proc_dointvec
303         },
304 #endif
305         {0}
306 };
307
308 static cfs_sysctl_table_t kibnal_top_ctl_table[] = {
309         {
310                 .ctl_name = 203,
311                 .procname = "vibnal",
312                 .data     = NULL,
313                 .maxlen   = 0,
314                 .mode     = 0555,
315                 .child    = kibnal_ctl_table
316         },
317         {0}
318 };
319
320 void
321 kibnal_initstrtunable(char *space, char *str, int size)
322 {
323         strncpy(space, str, size);
324         space[size-1] = 0;
325 }
326
327 int
328 kibnal_tunables_init ()
329 {
330         kibnal_initstrtunable(hca_basename_space, hca_basename,
331                               sizeof(hca_basename_space));
332         kibnal_initstrtunable(ipif_basename_space, ipif_basename,
333                               sizeof(ipif_basename_space));
334
335         kibnal_tunables.kib_sysctl =
336                 cfs_register_sysctl_table(kibnal_top_ctl_table, 0);
337
338         if (kibnal_tunables.kib_sysctl == NULL)
339                 CWARN("Can't setup /proc tunables\n");
340
341         if (*kibnal_tunables.kib_concurrent_sends > IBNAL_RX_MSGS)
342                 *kibnal_tunables.kib_concurrent_sends = IBNAL_RX_MSGS;
343         if (*kibnal_tunables.kib_concurrent_sends < IBNAL_MSG_QUEUE_SIZE)
344                 *kibnal_tunables.kib_concurrent_sends = IBNAL_MSG_QUEUE_SIZE;
345
346         return 0;
347 }
348
349 void
350 kibnal_tunables_fini ()
351 {
352         if (kibnal_tunables.kib_sysctl != NULL)
353                 cfs_unregister_sysctl_table(kibnal_tunables.kib_sysctl);
354 }
355
356 #else
357
358 int
359 kibnal_tunables_init ()
360 {
361         return 0;
362 }
363
364 void
365 kibnal_tunables_fini ()
366 {
367 }
368
369 #endif