Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd_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/o2iblnd/o2iblnd_modparams.c
37  *
38  * Author: Eric Barton <eric@bartonsoftware.com>
39  */
40
41 #include "o2iblnd.h"
42
43 static int service = 987;
44 CFS_MODULE_PARM(service, "i", int, 0444,
45                 "service number (within RDMA_PS_TCP)");
46
47 static int cksum = 0;
48 CFS_MODULE_PARM(cksum, "i", int, 0644,
49                 "set non-zero to enable message (not RDMA) checksums");
50
51 static int timeout = 50;
52 CFS_MODULE_PARM(timeout, "i", int, 0644,
53                 "timeout (seconds)");
54
55 static int ntx = 256;
56 CFS_MODULE_PARM(ntx, "i", int, 0444,
57                 "# of message descriptors");
58
59 static int credits = 64;
60 CFS_MODULE_PARM(credits, "i", int, 0444,
61                 "# concurrent sends");
62
63 static int peer_credits = 8;
64 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
65                 "# concurrent sends to 1 peer");
66
67 static char *ipif_name = "ib0";
68 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
69                 "IPoIB interface name");
70
71 static int retry_count = 5;
72 CFS_MODULE_PARM(retry_count, "i", int, 0644,
73                 "Retransmissions when no ACK received");
74
75 static int rnr_retry_count = 6;
76 CFS_MODULE_PARM(rnr_retry_count, "i", int, 0644,
77                 "RNR retransmissions");
78
79 static int keepalive = 100;
80 CFS_MODULE_PARM(keepalive, "i", int, 0644,
81                 "Idle time in seconds before sending a keepalive");
82
83 static int ib_mtu = 0;
84 CFS_MODULE_PARM(ib_mtu, "i", int, 0444,
85                 "IB MTU 256/512/1024/2048/4096");
86
87 #if IBLND_MAP_ON_DEMAND
88 static int concurrent_sends = IBLND_RX_MSGS;
89 #else
90 static int concurrent_sends = IBLND_MSG_QUEUE_SIZE;
91 #endif
92 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
93                 "send work-queue sizing");
94
95 #if IBLND_MAP_ON_DEMAND
96 static int fmr_pool_size = 512;
97 CFS_MODULE_PARM(fmr_pool_size, "i", int, 0444,
98                 "size of the fmr pool (>= ntx)");
99
100 static int fmr_flush_trigger = 384;
101 CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
102                 "# dirty FMRs that triggers pool flush");
103
104 static int fmr_cache = 1;
105 CFS_MODULE_PARM(fmr_cache, "i", int, 0444,
106                 "non-zero to enable FMR caching");
107 #endif
108
109 kib_tunables_t kiblnd_tunables = {
110         .kib_service                = &service,
111         .kib_cksum                  = &cksum,
112         .kib_timeout                = &timeout,
113         .kib_keepalive              = &keepalive,
114         .kib_ntx                    = &ntx,
115         .kib_credits                = &credits,
116         .kib_peercredits            = &peer_credits,
117         .kib_default_ipif           = &ipif_name,
118         .kib_retry_count            = &retry_count,
119         .kib_rnr_retry_count        = &rnr_retry_count,
120         .kib_concurrent_sends       = &concurrent_sends,
121         .kib_ib_mtu                 = &ib_mtu,
122 #if IBLND_MAP_ON_DEMAND
123         .kib_fmr_pool_size          = &fmr_pool_size,
124         .kib_fmr_flush_trigger      = &fmr_flush_trigger,
125         .kib_fmr_cache              = &fmr_cache,
126 #endif
127 };
128
129 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
130
131 static char ipif_basename_space[32];
132
133 static cfs_sysctl_table_t kiblnd_ctl_table[] = {
134         {
135                 .ctl_name = 1,
136                 .procname = "service",
137                 .data     = &service,
138                 .maxlen   = sizeof(int),
139                 .mode     = 0444,
140                 .proc_handler = &proc_dointvec
141         },
142         {
143                 .ctl_name = 2,
144                 .procname = "cksum",
145                 .data     = &cksum,
146                 .maxlen   = sizeof(int),
147                 .mode     = 0644,
148                 .proc_handler = &proc_dointvec
149         },
150         {
151                 .ctl_name = 3,
152                 .procname = "timeout",
153                 .data     = &timeout,
154                 .maxlen   = sizeof(int),
155                 .mode     = 0644,
156                 .proc_handler = &proc_dointvec
157         },
158         {
159                 .ctl_name = 4,
160                 .procname = "ntx",
161                 .data     = &ntx,
162                 .maxlen   = sizeof(int),
163                 .mode     = 0444,
164                 .proc_handler = &proc_dointvec
165         },
166         {
167                 .ctl_name = 5,
168                 .procname = "credits",
169                 .data     = &credits,
170                 .maxlen   = sizeof(int),
171                 .mode     = 0444,
172                 .proc_handler = &proc_dointvec
173         },
174         {
175                 .ctl_name = 6,
176                 .procname = "peer_credits",
177                 .data     = &peer_credits,
178                 .maxlen   = sizeof(int),
179                 .mode     = 0444,
180                 .proc_handler = &proc_dointvec
181         },
182         {
183                 .ctl_name = 7,
184                 .procname = "ipif_name",
185                 .data     = ipif_basename_space,
186                 .maxlen   = sizeof(ipif_basename_space),
187                 .mode     = 0444,
188                 .proc_handler = &proc_dostring
189         },
190         {
191                 .ctl_name = 8,
192                 .procname = "retry_count",
193                 .data     = &retry_count,
194                 .maxlen   = sizeof(int),
195                 .mode     = 0644,
196                 .proc_handler = &proc_dointvec
197         },
198         {
199                 .ctl_name = 9,
200                 .procname = "rnr_retry_count",
201                 .data     = &rnr_retry_count,
202                 .maxlen   = sizeof(int),
203                 .mode     = 0644,
204                 .proc_handler = &proc_dointvec
205         },
206         {
207                 .ctl_name = 10,
208                 .procname = "keepalive",
209                 .data     = &keepalive,
210                 .maxlen   = sizeof(int),
211                 .mode     = 0644,
212                 .proc_handler = &proc_dointvec
213         },
214         {
215                 .ctl_name = 11,
216                 .procname = "concurrent_sends",
217                 .data     = &concurrent_sends,
218                 .maxlen   = sizeof(int),
219                 .mode     = 0444,
220                 .proc_handler = &proc_dointvec
221         },
222         {
223                 .ctl_name = 12,
224                 .procname = "ib_mtu",
225                 .data     = &ib_mtu,
226                 .maxlen   = sizeof(int),
227                 .mode     = 0444,
228                 .proc_handler = &proc_dointvec
229         },
230 #if IBLND_MAP_ON_DEMAND
231         {
232                 .ctl_name = 13,
233                 .procname = "fmr_pool_size",
234                 .data     = &fmr_pool_size,
235                 .maxlen   = sizeof(int),
236                 .mode     = 0444,
237                 .proc_handler = &proc_dointvec
238         },
239         {
240                 .ctl_name = 14,
241                 .procname = "fmr_flush_trigger",
242                 .data     = &fmr_flush_trigger,
243                 .maxlen   = sizeof(int),
244                 .mode     = 0444,
245                 .proc_handler = &proc_dointvec
246         },
247         {
248                 .ctl_name = 15,
249                 .procname = "fmr_cache",
250                 .data     = &fmr_cache,
251                 .maxlen   = sizeof(int),
252                 .mode     = 0444,
253                 .proc_handler = &proc_dointvec
254         },
255 #endif
256         {0}
257 };
258
259 static cfs_sysctl_table_t kiblnd_top_ctl_table[] = {
260         {
261                 .ctl_name = 203,
262                 .procname = "o2iblnd",
263                 .data     = NULL,
264                 .maxlen   = 0,
265                 .mode     = 0555,
266                 .child    = kiblnd_ctl_table
267         },
268         {0}
269 };
270
271 void
272 kiblnd_initstrtunable(char *space, char *str, int size)
273 {
274         strncpy(space, str, size);
275         space[size-1] = 0;
276 }
277
278 void
279 kiblnd_sysctl_init (void)
280 {
281         kiblnd_initstrtunable(ipif_basename_space, ipif_name,
282                               sizeof(ipif_basename_space));
283
284         kiblnd_tunables.kib_sysctl =
285                 cfs_register_sysctl_table(kiblnd_top_ctl_table, 0);
286
287         if (kiblnd_tunables.kib_sysctl == NULL)
288                 CWARN("Can't setup /proc tunables\n");
289 }
290
291 void
292 kiblnd_sysctl_fini (void)
293 {
294         if (kiblnd_tunables.kib_sysctl != NULL)
295                 cfs_unregister_sysctl_table(kiblnd_tunables.kib_sysctl);
296 }
297
298 #else
299
300 void
301 kiblnd_sysctl_init (void)
302 {
303 }
304
305 void
306 kiblnd_sysctl_fini (void)
307 {
308 }
309
310 #endif
311
312 int
313 kiblnd_tunables_init (void)
314 {
315         kiblnd_sysctl_init();
316
317         if (*kiblnd_tunables.kib_concurrent_sends > IBLND_RX_MSGS)
318                 *kiblnd_tunables.kib_concurrent_sends = IBLND_RX_MSGS;
319         if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE / 2)
320                 *kiblnd_tunables.kib_concurrent_sends = IBLND_MSG_QUEUE_SIZE / 2;
321
322         if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE) {
323                 CWARN("Concurrent sends %d is lower than message queue size: %d, "
324                       "performance may drop slightly.\n",
325                       *kiblnd_tunables.kib_concurrent_sends, IBLND_MSG_QUEUE_SIZE);
326         }
327
328         return 0;
329 }
330
331 void
332 kiblnd_tunables_fini (void)
333 {
334         kiblnd_sysctl_fini();
335 }