Whamcloud - gitweb
f31c8dc2e51cad3e27c6d1b9e8fc939a6ea01c82
[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  * Copyright (C) 2004 Cluster File Systems, Inc.
5  *   Author: Eric Barton <eric@bartonsoftware.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org.
8  *
9  *   Lustre is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Lustre is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Lustre; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include "viblnd.h"
25
26 static int service_number = 0x11b9a2;
27 CFS_MODULE_PARM(service_number, "i", int, 0444,
28                 "IB service number");
29
30 static int min_reconnect_interval = 1;
31 CFS_MODULE_PARM(min_reconnect_interval, "i", int, 0644,
32                 "minimum connection retry interval (seconds)");
33
34 static int max_reconnect_interval = 60;
35 CFS_MODULE_PARM(max_reconnect_interval, "i", int, 0644,
36                 "maximum connection retry interval (seconds)");
37
38 static int concurrent_peers = 1152;
39 CFS_MODULE_PARM(concurrent_peers, "i", int, 0444,
40                 "maximum number of peers that may connect");
41
42 static int cksum = 0;
43 CFS_MODULE_PARM(cksum, "i", int, 0644,
44                 "set non-zero to enable message (not RDMA) checksums");
45
46 static int timeout = 50;
47 CFS_MODULE_PARM(timeout, "i", int, 0644,
48                 "timeout (seconds)");
49
50 static int ntx = 256;
51 CFS_MODULE_PARM(ntx, "i", int, 0444,
52                 "# of message descriptors");
53
54 static int credits = 128;
55 CFS_MODULE_PARM(credits, "i", int, 0444,
56                 "# concurrent sends");
57
58 static int peer_credits = 8;
59 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
60                 "# concurrent sends to 1 peer");
61
62 static int arp_retries = 3;
63 CFS_MODULE_PARM(arp_retries, "i", int, 0644,
64                 "# of times to retry ARP");
65
66 static char *hca_basename = "InfiniHost";
67 CFS_MODULE_PARM(hca_basename, "s", charp, 0444,
68                 "HCA base name");
69
70 static char *ipif_basename = "ipoib";
71 CFS_MODULE_PARM(ipif_basename, "s", charp, 0444,
72                 "IPoIB interface base name");
73
74 static int local_ack_timeout = 0x12;
75 CFS_MODULE_PARM(local_ack_timeout, "i", int, 0644,
76                 "ACK timeout for low-level 'sends'");
77
78 static int retry_cnt = 7;
79 CFS_MODULE_PARM(retry_cnt, "i", int, 0644,
80                 "Retransmissions when no ACK received");
81
82 static int rnr_cnt = 6;
83 CFS_MODULE_PARM(rnr_cnt, "i", int, 0644,
84                 "RNR retransmissions");
85
86 static int rnr_nak_timer = 0x10;
87 CFS_MODULE_PARM(rnr_nak_timer, "i", int, 0644,
88                 "RNR retransmission interval");
89
90 static int keepalive = 100;
91 CFS_MODULE_PARM(keepalive, "i", int, 0644,
92                 "Idle time in seconds before sending a keepalive");
93
94 static int concurrent_sends = IBNAL_RX_MSGS;
95 CFS_MODULE_PARM(concurrent_sends, "i", int, 0644,
96                 "send work-queue sizing");
97
98 #if IBNAL_USE_FMR
99 static int fmr_remaps = 1000;
100 CFS_MODULE_PARM(fmr_remaps, "i", int, 0444,
101                 "FMR mappings allowed before unmap");
102 #endif
103
104 kib_tunables_t kibnal_tunables = {
105         .kib_service_number         = &service_number,
106         .kib_min_reconnect_interval = &min_reconnect_interval,
107         .kib_max_reconnect_interval = &max_reconnect_interval,
108         .kib_concurrent_peers       = &concurrent_peers,
109         .kib_cksum                  = &cksum,
110         .kib_timeout                = &timeout,
111         .kib_ntx                    = &ntx,
112         .kib_credits                = &credits,
113         .kib_peercredits            = &peer_credits,
114         .kib_arp_retries            = &arp_retries,
115         .kib_hca_basename           = &hca_basename,
116         .kib_ipif_basename          = &ipif_basename,
117         .kib_local_ack_timeout      = &local_ack_timeout,
118         .kib_retry_cnt              = &retry_cnt,
119         .kib_rnr_cnt                = &rnr_cnt,
120         .kib_rnr_nak_timer          = &rnr_nak_timer,
121         .kib_keepalive              = &keepalive,
122         .kib_concurrent_sends       = &concurrent_sends,
123 #if IBNAL_USE_FMR
124         .kib_fmr_remaps             = &fmr_remaps,
125 #endif
126 };
127
128 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
129
130 static char hca_basename_space[32];
131 static char ipif_basename_space[32];
132
133 static cfs_sysctl_table_t kibnal_ctl_table[] = {
134         {
135                 .ctl_name = 1,
136                 .procname = "service_number",
137                 .data     = &service_number,
138                 .maxlen   = sizeof(int),
139                 .mode     = 0444,
140                 .proc_handler = &proc_dointvec
141         },
142         {
143                 .ctl_name = 2,
144                 .procname = "min_reconnect_interval",
145                 .data     = &min_reconnect_interval,
146                 .maxlen   = sizeof(int),
147                 .mode     = 0644,
148                 .proc_handler = &proc_dointvec
149         },
150         {
151                 .ctl_name = 3,
152                 .procname = "max_reconnect_interval",
153                 .data     = &max_reconnect_interval,
154                 .maxlen   = sizeof(int),
155                 .mode     = 0644,
156                 .proc_handler = &proc_dointvec
157         },
158         {
159                 .ctl_name = 4,
160                 .procname = "concurrent_peers",
161                 .data     = &concurrent_peers,
162                 .maxlen   = sizeof(int),
163                 .mode     = 0444,
164                 .proc_handler = &proc_dointvec
165         },
166         {
167                 .ctl_name = 5,
168                 .procname = "cksum",
169                 .data     = &cksum,
170                 .maxlen   = sizeof(int),
171                 .mode     = 0644,
172                 .proc_handler = &proc_dointvec
173         },
174         {
175                 .ctl_name = 6,
176                 .procname = "timeout",
177                 .data     = &timeout,
178                 .maxlen   = sizeof(int),
179                 .mode     = 0644,
180                 .proc_handler = &proc_dointvec
181         },
182         {
183                 .ctl_name = 7,
184                 .procname = "ntx",
185                 .data     = &ntx,
186                 .maxlen   = sizeof(int),
187                 .mode     = 0444,
188                 .proc_handler = &proc_dointvec
189         },
190         {
191                 .ctl_name = 8,
192                 .procname = "credits",
193                 .data     = &credits,
194                 .maxlen   = sizeof(int),
195                 .mode     = 0444,
196                 .proc_handler = &proc_dointvec
197         },
198         {
199                 .ctl_name = 9,
200                 .procname = "peer_credits",
201                 .data     = &peer_credits,
202                 .maxlen   = sizeof(int),
203                 .mode     = 0444,
204                 .proc_handler = &proc_dointvec
205         },
206         {
207                 .ctl_name = 10,
208                 .procname = "arp_retries",
209                 .data     = &arp_retries,
210                 .maxlen   = sizeof(int),
211                 .mode     = 0644,
212                 .proc_handler = &proc_dointvec
213         },
214         {
215                 .ctl_name = 11,
216                 .procname = "hca_basename",
217                 .data     = hca_basename_space,
218                 .maxlen   = sizeof(hca_basename_space),
219                 .mode     = 0444,
220                 .proc_handler = &proc_dostring
221         },
222         {
223                 .ctl_name = 12,
224                 .procname = "ipif_basename",
225                 .data     = ipif_basename_space,
226                 .maxlen   = sizeof(ipif_basename_space),
227                 .mode     = 0444,
228                 .proc_handler = &proc_dostring
229         },
230         {
231                 .ctl_name = 13,
232                 .procname = "local_ack_timeout",
233                 .data     = &local_ack_timeout,
234                 .maxlen   = sizeof(int),
235                 .mode     = 0644,
236                 .proc_handler = &proc_dointvec
237         },
238         {
239                 .ctl_name = 14,
240                 .procname = "retry_cnt",
241                 .data     = &retry_cnt,
242                 .maxlen   = sizeof(int),
243                 .mode     = 0644,
244                 .proc_handler = &proc_dointvec
245         },
246         {
247                 .ctl_name = 15,
248                 .procname = "rnr_cnt",
249                 .data     = &rnr_cnt,
250                 .maxlen   = sizeof(int),
251                 .mode     = 0644,
252                 .proc_handler = &proc_dointvec
253         },
254         {
255                 .ctl_name = 16,
256                 .procname = "rnr_nak_timer",
257                 .data     = &rnr_nak_timer,
258                 .maxlen   = sizeof(int),
259                 .mode     = 0644,
260                 .proc_handler = &proc_dointvec
261         },
262         {
263                 .ctl_name = 17,
264                 .procname = "keepalive",
265                 .data     = &keepalive,
266                 .maxlen   = sizeof(int),
267                 .mode     = 0644,
268                 .proc_handler = &proc_dointvec
269         },
270         {
271                 .ctl_name = 18,
272                 .procname = "concurrent_sends",
273                 .data     = &concurrent_sends,
274                 .maxlen   = sizeof(int),
275                 .mode     = 0644,
276                 .proc_handler = &proc_dointvec
277         },
278 #if IBNAL_USE_FMR
279         {
280                 .ctl_name = 19,
281                 .procname = "fmr_remaps",
282                 .data     = &fmr_remaps,
283                 .maxlen   = sizeof(int),
284                 .mode     = 0444,
285                 .proc_handler = &proc_dointvec
286         },
287 #endif
288         {0}
289 };
290
291 static cfs_sysctl_table_t kibnal_top_ctl_table[] = {
292         {
293                 .ctl_name = 203,
294                 .procname = "vibnal",
295                 .data     = NULL,
296                 .maxlen   = 0,
297                 .mode     = 0555,
298                 .child    = kibnal_ctl_table
299         },
300         {0}
301 };
302
303 void
304 kibnal_initstrtunable(char *space, char *str, int size)
305 {
306         strncpy(space, str, size);
307         space[size-1] = 0;
308 }
309
310 int
311 kibnal_tunables_init ()
312 {
313         kibnal_initstrtunable(hca_basename_space, hca_basename,
314                               sizeof(hca_basename_space));
315         kibnal_initstrtunable(ipif_basename_space, ipif_basename,
316                               sizeof(ipif_basename_space));
317
318         kibnal_tunables.kib_sysctl =
319                 cfs_register_sysctl_table(kibnal_top_ctl_table, 0);
320
321         if (kibnal_tunables.kib_sysctl == NULL)
322                 CWARN("Can't setup /proc tunables\n");
323
324         if (*kibnal_tunables.kib_concurrent_sends > IBNAL_RX_MSGS)
325                 *kibnal_tunables.kib_concurrent_sends = IBNAL_RX_MSGS;
326         if (*kibnal_tunables.kib_concurrent_sends < IBNAL_MSG_QUEUE_SIZE)
327                 *kibnal_tunables.kib_concurrent_sends = IBNAL_MSG_QUEUE_SIZE;
328
329         return 0;
330 }
331
332 void
333 kibnal_tunables_fini ()
334 {
335         if (kibnal_tunables.kib_sysctl != NULL)
336                 cfs_unregister_sysctl_table(kibnal_tunables.kib_sysctl);
337 }
338
339 #else
340
341 int
342 kibnal_tunables_init ()
343 {
344         return 0;
345 }
346
347 void
348 kibnal_tunables_fini ()
349 {
350 }
351
352 #endif