4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/klnds/o2iblnd/o2iblnd_modparams.c
36 * Author: Eric Barton <eric@bartonsoftware.com>
41 static int service = 987;
42 CFS_MODULE_PARM(service, "i", int, 0444,
43 "service number (within RDMA_PS_TCP)");
46 CFS_MODULE_PARM(cksum, "i", int, 0644,
47 "set non-zero to enable message (not RDMA) checksums");
49 static int timeout = 50;
50 CFS_MODULE_PARM(timeout, "i", int, 0644,
53 /* Number of threads in each scheduler pool which is percpt,
54 * we will estimate reasonable value based on CPUs if it's set to zero. */
56 CFS_MODULE_PARM(nscheds, "i", int, 0444,
57 "number of threads in each scheduler pool");
59 /* NB: this value is shared by all CPTs, it can grow at runtime */
61 CFS_MODULE_PARM(ntx, "i", int, 0444,
62 "# of message descriptors allocated for each pool");
64 /* NB: this value is shared by all CPTs */
65 static int credits = 256;
66 CFS_MODULE_PARM(credits, "i", int, 0444,
67 "# concurrent sends");
69 static int peer_credits = 8;
70 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
71 "# concurrent sends to 1 peer");
73 static int peer_credits_hiw = 0;
74 CFS_MODULE_PARM(peer_credits_hiw, "i", int, 0444,
75 "when eagerly to return credits");
77 static int peer_buffer_credits = 0;
78 CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
79 "# per-peer router buffer credits");
81 static int peer_timeout = 180;
82 CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
83 "Seconds without aliveness news to declare peer dead (<=0 to disable)");
85 static char *ipif_name = "ib0";
86 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
87 "IPoIB interface name");
89 static int retry_count = 5;
90 CFS_MODULE_PARM(retry_count, "i", int, 0644,
91 "Retransmissions when no ACK received");
93 static int rnr_retry_count = 6;
94 CFS_MODULE_PARM(rnr_retry_count, "i", int, 0644,
95 "RNR retransmissions");
97 static int keepalive = 100;
98 CFS_MODULE_PARM(keepalive, "i", int, 0644,
99 "Idle time in seconds before sending a keepalive");
101 static int ib_mtu = 0;
102 CFS_MODULE_PARM(ib_mtu, "i", int, 0444,
103 "IB MTU 256/512/1024/2048/4096");
105 static int concurrent_sends = 0;
106 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
107 "send work-queue sizing");
109 static int map_on_demand = 0;
110 CFS_MODULE_PARM(map_on_demand, "i", int, 0444,
113 /* NB: this value is shared by all CPTs, it can grow at runtime */
114 static int fmr_pool_size = 512;
115 CFS_MODULE_PARM(fmr_pool_size, "i", int, 0444,
116 "size of fmr pool on each CPT (>= ntx / 4)");
118 /* NB: this value is shared by all CPTs, it can grow at runtime */
119 static int fmr_flush_trigger = 384;
120 CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
121 "# dirty FMRs that triggers pool flush");
123 static int fmr_cache = 1;
124 CFS_MODULE_PARM(fmr_cache, "i", int, 0444,
125 "non-zero to enable FMR caching");
127 /* NB: this value is shared by all CPTs, it can grow at runtime */
128 static int pmr_pool_size = 512;
129 CFS_MODULE_PARM(pmr_pool_size, "i", int, 0444,
130 "size of MR cache pmr pool on each CPT");
133 * 0: disable failover
134 * 1: enable failover if necessary
135 * 2: force to failover (for debug)
137 static int dev_failover = 0;
138 CFS_MODULE_PARM(dev_failover, "i", int, 0444,
139 "HCA failover for bonding (0 off, 1 on, other values reserved)");
142 static int require_privileged_port = 0;
143 CFS_MODULE_PARM(require_privileged_port, "i", int, 0644,
144 "require privileged port when accepting connection");
146 static int use_privileged_port = 1;
147 CFS_MODULE_PARM(use_privileged_port, "i", int, 0644,
148 "use privileged port when initiating connection");
150 kib_tunables_t kiblnd_tunables = {
151 .kib_dev_failover = &dev_failover,
152 .kib_service = &service,
154 .kib_timeout = &timeout,
155 .kib_keepalive = &keepalive,
157 .kib_credits = &credits,
158 .kib_peertxcredits = &peer_credits,
159 .kib_peercredits_hiw = &peer_credits_hiw,
160 .kib_peerrtrcredits = &peer_buffer_credits,
161 .kib_peertimeout = &peer_timeout,
162 .kib_default_ipif = &ipif_name,
163 .kib_retry_count = &retry_count,
164 .kib_rnr_retry_count = &rnr_retry_count,
165 .kib_concurrent_sends = &concurrent_sends,
166 .kib_ib_mtu = &ib_mtu,
167 .kib_map_on_demand = &map_on_demand,
168 .kib_fmr_pool_size = &fmr_pool_size,
169 .kib_fmr_flush_trigger = &fmr_flush_trigger,
170 .kib_fmr_cache = &fmr_cache,
171 .kib_pmr_pool_size = &pmr_pool_size,
172 .kib_require_priv_port = &require_privileged_port,
173 .kib_use_priv_port = &use_privileged_port,
174 .kib_nscheds = &nscheds
177 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
179 static char ipif_basename_space[32];
181 #ifndef HAVE_SYSCTL_UNNUMBERED
189 O2IBLND_PEER_TXCREDITS,
190 O2IBLND_PEER_CREDITS_HIW,
191 O2IBLND_PEER_RTRCREDITS,
192 O2IBLND_PEER_TIMEOUT,
193 O2IBLND_IPIF_BASENAME,
195 O2IBLND_RNR_RETRY_COUNT,
197 O2IBLND_CONCURRENT_SENDS,
199 O2IBLND_MAP_ON_DEMAND,
200 O2IBLND_FMR_POOL_SIZE,
201 O2IBLND_FMR_FLUSH_TRIGGER,
203 O2IBLND_PMR_POOL_SIZE,
208 #define O2IBLND_SERVICE CTL_UNNUMBERED
209 #define O2IBLND_CKSUM CTL_UNNUMBERED
210 #define O2IBLND_TIMEOUT CTL_UNNUMBERED
211 #define O2IBLND_NTX CTL_UNNUMBERED
212 #define O2IBLND_CREDITS CTL_UNNUMBERED
213 #define O2IBLND_PEER_TXCREDITS CTL_UNNUMBERED
214 #define O2IBLND_PEER_CREDITS_HIW CTL_UNNUMBERED
215 #define O2IBLND_PEER_RTRCREDITS CTL_UNNUMBERED
216 #define O2IBLND_PEER_TIMEOUT CTL_UNNUMBERED
217 #define O2IBLND_IPIF_BASENAME CTL_UNNUMBERED
218 #define O2IBLND_RETRY_COUNT CTL_UNNUMBERED
219 #define O2IBLND_RNR_RETRY_COUNT CTL_UNNUMBERED
220 #define O2IBLND_KEEPALIVE CTL_UNNUMBERED
221 #define O2IBLND_CONCURRENT_SENDS CTL_UNNUMBERED
222 #define O2IBLND_IB_MTU CTL_UNNUMBERED
223 #define O2IBLND_MAP_ON_DEMAND CTL_UNNUMBERED
224 #define O2IBLND_FMR_POOL_SIZE CTL_UNNUMBERED
225 #define O2IBLND_FMR_FLUSH_TRIGGER CTL_UNNUMBERED
226 #define O2IBLND_FMR_CACHE CTL_UNNUMBERED
227 #define O2IBLND_PMR_POOL_SIZE CTL_UNNUMBERED
228 #define O2IBLND_DEV_FAILOVER CTL_UNNUMBERED
232 static cfs_sysctl_table_t kiblnd_ctl_table[] = {
234 .ctl_name = O2IBLND_SERVICE,
235 .procname = "service",
237 .maxlen = sizeof(int),
239 .proc_handler = &proc_dointvec
242 .ctl_name = O2IBLND_CKSUM,
245 .maxlen = sizeof(int),
247 .proc_handler = &proc_dointvec
250 .ctl_name = O2IBLND_TIMEOUT,
251 .procname = "timeout",
253 .maxlen = sizeof(int),
255 .proc_handler = &proc_dointvec
258 .ctl_name = O2IBLND_NTX,
261 .maxlen = sizeof(int),
263 .proc_handler = &proc_dointvec
266 .ctl_name = O2IBLND_CREDITS,
267 .procname = "credits",
269 .maxlen = sizeof(int),
271 .proc_handler = &proc_dointvec
274 .ctl_name = O2IBLND_PEER_TXCREDITS,
275 .procname = "peer_credits",
276 .data = &peer_credits,
277 .maxlen = sizeof(int),
279 .proc_handler = &proc_dointvec
282 .ctl_name = O2IBLND_PEER_CREDITS_HIW,
283 .procname = "peer_credits_hiw",
284 .data = &peer_credits_hiw,
285 .maxlen = sizeof(int),
287 .proc_handler = &proc_dointvec
290 .ctl_name = O2IBLND_PEER_RTRCREDITS,
291 .procname = "peer_buffer_credits",
292 .data = &peer_buffer_credits,
293 .maxlen = sizeof(int),
295 .proc_handler = &proc_dointvec
298 .ctl_name = O2IBLND_PEER_TIMEOUT,
299 .procname = "peer_timeout",
300 .data = &peer_timeout,
301 .maxlen = sizeof(int),
303 .proc_handler = &proc_dointvec
306 .ctl_name = O2IBLND_IPIF_BASENAME,
307 .procname = "ipif_name",
308 .data = ipif_basename_space,
309 .maxlen = sizeof(ipif_basename_space),
311 .proc_handler = &proc_dostring
314 .ctl_name = O2IBLND_RETRY_COUNT,
315 .procname = "retry_count",
316 .data = &retry_count,
317 .maxlen = sizeof(int),
319 .proc_handler = &proc_dointvec
322 .ctl_name = O2IBLND_RNR_RETRY_COUNT,
323 .procname = "rnr_retry_count",
324 .data = &rnr_retry_count,
325 .maxlen = sizeof(int),
327 .proc_handler = &proc_dointvec
330 .ctl_name = O2IBLND_KEEPALIVE,
331 .procname = "keepalive",
333 .maxlen = sizeof(int),
335 .proc_handler = &proc_dointvec
338 .ctl_name = O2IBLND_CONCURRENT_SENDS,
339 .procname = "concurrent_sends",
340 .data = &concurrent_sends,
341 .maxlen = sizeof(int),
343 .proc_handler = &proc_dointvec
346 .ctl_name = O2IBLND_IB_MTU,
347 .procname = "ib_mtu",
349 .maxlen = sizeof(int),
351 .proc_handler = &proc_dointvec
354 .ctl_name = O2IBLND_MAP_ON_DEMAND,
355 .procname = "map_on_demand",
356 .data = &map_on_demand,
357 .maxlen = sizeof(int),
359 .proc_handler = &proc_dointvec
363 .ctl_name = O2IBLND_FMR_POOL_SIZE,
364 .procname = "fmr_pool_size",
365 .data = &fmr_pool_size,
366 .maxlen = sizeof(int),
368 .proc_handler = &proc_dointvec
371 .ctl_name = O2IBLND_FMR_FLUSH_TRIGGER,
372 .procname = "fmr_flush_trigger",
373 .data = &fmr_flush_trigger,
374 .maxlen = sizeof(int),
376 .proc_handler = &proc_dointvec
379 .ctl_name = O2IBLND_FMR_CACHE,
380 .procname = "fmr_cache",
382 .maxlen = sizeof(int),
384 .proc_handler = &proc_dointvec
387 .ctl_name = O2IBLND_PMR_POOL_SIZE,
388 .procname = "pmr_pool_size",
389 .data = &pmr_pool_size,
390 .maxlen = sizeof(int),
392 .proc_handler = &proc_dointvec
395 .ctl_name = O2IBLND_DEV_FAILOVER,
396 .procname = "dev_failover",
397 .data = &dev_failover,
398 .maxlen = sizeof(int),
400 .proc_handler = &proc_dointvec
405 static cfs_sysctl_table_t kiblnd_top_ctl_table[] = {
407 .ctl_name = CTL_O2IBLND,
408 .procname = "o2iblnd",
412 .child = kiblnd_ctl_table
418 kiblnd_initstrtunable(char *space, char *str, int size)
420 strncpy(space, str, size);
425 kiblnd_sysctl_init (void)
427 kiblnd_initstrtunable(ipif_basename_space, ipif_name,
428 sizeof(ipif_basename_space));
430 kiblnd_tunables.kib_sysctl =
431 cfs_register_sysctl_table(kiblnd_top_ctl_table, 0);
433 if (kiblnd_tunables.kib_sysctl == NULL)
434 CWARN("Can't setup /proc tunables\n");
438 kiblnd_sysctl_fini (void)
440 if (kiblnd_tunables.kib_sysctl != NULL)
441 cfs_unregister_sysctl_table(kiblnd_tunables.kib_sysctl);
447 kiblnd_sysctl_init (void)
452 kiblnd_sysctl_fini (void)
459 kiblnd_tunables_init (void)
461 if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
462 CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
463 *kiblnd_tunables.kib_ib_mtu);
467 if (*kiblnd_tunables.kib_peertxcredits < IBLND_CREDITS_DEFAULT)
468 *kiblnd_tunables.kib_peertxcredits = IBLND_CREDITS_DEFAULT;
470 if (*kiblnd_tunables.kib_peertxcredits > IBLND_CREDITS_MAX)
471 *kiblnd_tunables.kib_peertxcredits = IBLND_CREDITS_MAX;
473 if (*kiblnd_tunables.kib_peertxcredits > *kiblnd_tunables.kib_credits)
474 *kiblnd_tunables.kib_peertxcredits = *kiblnd_tunables.kib_credits;
476 if (*kiblnd_tunables.kib_peercredits_hiw < *kiblnd_tunables.kib_peertxcredits / 2)
477 *kiblnd_tunables.kib_peercredits_hiw = *kiblnd_tunables.kib_peertxcredits / 2;
479 if (*kiblnd_tunables.kib_peercredits_hiw >= *kiblnd_tunables.kib_peertxcredits)
480 *kiblnd_tunables.kib_peercredits_hiw = *kiblnd_tunables.kib_peertxcredits - 1;
482 if (*kiblnd_tunables.kib_map_on_demand < 0 ||
483 *kiblnd_tunables.kib_map_on_demand > IBLND_MAX_RDMA_FRAGS)
484 *kiblnd_tunables.kib_map_on_demand = 0; /* disable map-on-demand */
486 if (*kiblnd_tunables.kib_map_on_demand == 1)
487 *kiblnd_tunables.kib_map_on_demand = 2; /* don't make sense to create map if only one fragment */
489 if (*kiblnd_tunables.kib_concurrent_sends == 0) {
490 if (*kiblnd_tunables.kib_map_on_demand > 0 &&
491 *kiblnd_tunables.kib_map_on_demand <= IBLND_MAX_RDMA_FRAGS / 8)
492 *kiblnd_tunables.kib_concurrent_sends = (*kiblnd_tunables.kib_peertxcredits) * 2;
494 *kiblnd_tunables.kib_concurrent_sends = (*kiblnd_tunables.kib_peertxcredits);
497 if (*kiblnd_tunables.kib_concurrent_sends > *kiblnd_tunables.kib_peertxcredits * 2)
498 *kiblnd_tunables.kib_concurrent_sends = *kiblnd_tunables.kib_peertxcredits * 2;
500 if (*kiblnd_tunables.kib_concurrent_sends < *kiblnd_tunables.kib_peertxcredits / 2)
501 *kiblnd_tunables.kib_concurrent_sends = *kiblnd_tunables.kib_peertxcredits / 2;
503 if (*kiblnd_tunables.kib_concurrent_sends < *kiblnd_tunables.kib_peertxcredits) {
504 CWARN("Concurrent sends %d is lower than message queue size: %d, "
505 "performance may drop slightly.\n",
506 *kiblnd_tunables.kib_concurrent_sends, *kiblnd_tunables.kib_peertxcredits);
509 kiblnd_sysctl_init();
514 kiblnd_tunables_fini (void)
516 kiblnd_sysctl_fini();