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.
30 * Copyright (c) 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lnet/klnds/o2iblnd/o2iblnd_modparams.c
38 * Author: Eric Barton <eric@bartonsoftware.com>
43 static int service = 987;
44 CFS_MODULE_PARM(service, "i", int, 0444,
45 "service number (within RDMA_PS_TCP)");
48 CFS_MODULE_PARM(cksum, "i", int, 0644,
49 "set non-zero to enable message (not RDMA) checksums");
51 static int timeout = 50;
52 CFS_MODULE_PARM(timeout, "i", int, 0644,
55 /* Number of threads in each scheduler pool which is percpt,
56 * we will estimate reasonable value based on CPUs if it's set to zero. */
58 CFS_MODULE_PARM(nscheds, "i", int, 0444,
59 "number of threads in each scheduler pool");
61 /* NB: this value is shared by all CPTs, it can grow at runtime */
63 CFS_MODULE_PARM(ntx, "i", int, 0444,
64 "# of message descriptors allocated for each pool");
66 /* NB: this value is shared by all CPTs */
67 static int credits = 256;
68 CFS_MODULE_PARM(credits, "i", int, 0444,
69 "# concurrent sends");
71 static int peer_credits = 8;
72 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
73 "# concurrent sends to 1 peer");
75 static int peer_credits_hiw = 0;
76 CFS_MODULE_PARM(peer_credits_hiw, "i", int, 0444,
77 "when eagerly to return credits");
79 static int peer_buffer_credits = 0;
80 CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
81 "# per-peer router buffer credits");
83 static int peer_timeout = 180;
84 CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
85 "Seconds without aliveness news to declare peer dead (<=0 to disable)");
87 static char *ipif_name = "ib0";
88 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
89 "IPoIB interface name");
91 static int retry_count = 5;
92 CFS_MODULE_PARM(retry_count, "i", int, 0644,
93 "Retransmissions when no ACK received");
95 static int rnr_retry_count = 6;
96 CFS_MODULE_PARM(rnr_retry_count, "i", int, 0644,
97 "RNR retransmissions");
99 static int keepalive = 100;
100 CFS_MODULE_PARM(keepalive, "i", int, 0644,
101 "Idle time in seconds before sending a keepalive");
103 static int ib_mtu = 0;
104 CFS_MODULE_PARM(ib_mtu, "i", int, 0444,
105 "IB MTU 256/512/1024/2048/4096");
107 static int concurrent_sends = 0;
108 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
109 "send work-queue sizing");
111 static int map_on_demand = 0;
112 CFS_MODULE_PARM(map_on_demand, "i", int, 0444,
115 /* NB: this value is shared by all CPTs, it can grow at runtime */
116 static int fmr_pool_size = 512;
117 CFS_MODULE_PARM(fmr_pool_size, "i", int, 0444,
118 "size of fmr pool on each CPT (>= ntx / 4)");
120 /* NB: this value is shared by all CPTs, it can grow at runtime */
121 static int fmr_flush_trigger = 384;
122 CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
123 "# dirty FMRs that triggers pool flush");
125 static int fmr_cache = 1;
126 CFS_MODULE_PARM(fmr_cache, "i", int, 0444,
127 "non-zero to enable FMR caching");
130 * 0: disable failover
131 * 1: enable failover if necessary
132 * 2: force to failover (for debug)
134 static int dev_failover = 0;
135 CFS_MODULE_PARM(dev_failover, "i", int, 0444,
136 "HCA failover for bonding (0 off, 1 on, other values reserved)");
138 static int require_privileged_port = 0;
139 CFS_MODULE_PARM(require_privileged_port, "i", int, 0644,
140 "require privileged port when accepting connection");
142 static int use_privileged_port = 1;
143 CFS_MODULE_PARM(use_privileged_port, "i", int, 0644,
144 "use privileged port when initiating connection");
146 kib_tunables_t kiblnd_tunables = {
147 .kib_dev_failover = &dev_failover,
148 .kib_service = &service,
150 .kib_timeout = &timeout,
151 .kib_keepalive = &keepalive,
153 .kib_default_ipif = &ipif_name,
154 .kib_retry_count = &retry_count,
155 .kib_rnr_retry_count = &rnr_retry_count,
156 .kib_ib_mtu = &ib_mtu,
157 .kib_require_priv_port = &require_privileged_port,
158 .kib_use_priv_port = &use_privileged_port,
159 .kib_nscheds = &nscheds
162 static struct lnet_ioctl_config_o2iblnd_tunables default_tunables;
164 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
166 static char ipif_basename_space[32];
168 static struct ctl_table kiblnd_ctl_table[] = {
171 .procname = "service",
173 .maxlen = sizeof(int),
175 .proc_handler = &proc_dointvec
181 .maxlen = sizeof(int),
183 .proc_handler = &proc_dointvec
187 .procname = "timeout",
189 .maxlen = sizeof(int),
191 .proc_handler = &proc_dointvec
197 .maxlen = sizeof(int),
199 .proc_handler = &proc_dointvec
203 .procname = "credits",
205 .maxlen = sizeof(int),
207 .proc_handler = &proc_dointvec
211 .procname = "peer_credits",
212 .data = &peer_credits,
213 .maxlen = sizeof(int),
215 .proc_handler = &proc_dointvec
219 .procname = "peer_credits_hiw",
220 .data = &peer_credits_hiw,
221 .maxlen = sizeof(int),
223 .proc_handler = &proc_dointvec
227 .procname = "peer_buffer_credits",
228 .data = &peer_buffer_credits,
229 .maxlen = sizeof(int),
231 .proc_handler = &proc_dointvec
235 .procname = "peer_timeout",
236 .data = &peer_timeout,
237 .maxlen = sizeof(int),
239 .proc_handler = &proc_dointvec
243 .procname = "ipif_name",
244 .data = ipif_basename_space,
245 .maxlen = sizeof(ipif_basename_space),
247 .proc_handler = &proc_dostring
251 .procname = "retry_count",
252 .data = &retry_count,
253 .maxlen = sizeof(int),
255 .proc_handler = &proc_dointvec
259 .procname = "rnr_retry_count",
260 .data = &rnr_retry_count,
261 .maxlen = sizeof(int),
263 .proc_handler = &proc_dointvec
267 .procname = "keepalive",
269 .maxlen = sizeof(int),
271 .proc_handler = &proc_dointvec
275 .procname = "concurrent_sends",
276 .data = &concurrent_sends,
277 .maxlen = sizeof(int),
279 .proc_handler = &proc_dointvec
283 .procname = "ib_mtu",
285 .maxlen = sizeof(int),
287 .proc_handler = &proc_dointvec
291 .procname = "map_on_demand",
292 .data = &map_on_demand,
293 .maxlen = sizeof(int),
295 .proc_handler = &proc_dointvec
299 .procname = "fmr_pool_size",
300 .data = &fmr_pool_size,
301 .maxlen = sizeof(int),
303 .proc_handler = &proc_dointvec
307 .procname = "fmr_flush_trigger",
308 .data = &fmr_flush_trigger,
309 .maxlen = sizeof(int),
311 .proc_handler = &proc_dointvec
315 .procname = "fmr_cache",
317 .maxlen = sizeof(int),
319 .proc_handler = &proc_dointvec
323 .procname = "dev_failover",
324 .data = &dev_failover,
325 .maxlen = sizeof(int),
327 .proc_handler = &proc_dointvec
332 static struct ctl_table kiblnd_top_ctl_table[] = {
335 .procname = "o2iblnd",
339 .child = kiblnd_ctl_table
345 kiblnd_initstrtunable(char *space, char *str, int size)
347 strncpy(space, str, size);
352 kiblnd_sysctl_init (void)
354 kiblnd_initstrtunable(ipif_basename_space, ipif_name,
355 sizeof(ipif_basename_space));
357 kiblnd_tunables.kib_sysctl =
358 register_sysctl_table(kiblnd_top_ctl_table);
360 if (kiblnd_tunables.kib_sysctl == NULL)
361 CWARN("Can't setup /proc tunables\n");
365 kiblnd_sysctl_fini (void)
367 if (kiblnd_tunables.kib_sysctl != NULL)
368 unregister_sysctl_table(kiblnd_tunables.kib_sysctl);
374 kiblnd_sysctl_init (void)
379 kiblnd_sysctl_fini (void)
384 /* # messages/RDMAs in-flight */
386 kiblnd_msg_queue_size(int version, lnet_ni_t *ni)
388 if (version == IBLND_MSG_VERSION_1)
389 return IBLND_MSG_QUEUE_SIZE_V1;
391 return ni->ni_peertxcredits;
397 kiblnd_tunables_setup(lnet_ni_t *ni)
399 struct lnet_ioctl_config_o2iblnd_tunables *tunables;
402 * if there was no tunables specified, setup the tunables to be
405 if (!ni->ni_lnd_tunables) {
406 LIBCFS_ALLOC(ni->ni_lnd_tunables,
407 sizeof(*ni->ni_lnd_tunables));
408 if (!ni->ni_lnd_tunables)
411 memcpy(&ni->ni_lnd_tunables->lt_tun_u.lt_o2ib,
412 &default_tunables, sizeof(*tunables));
414 tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
416 /* Current API version */
417 tunables->lnd_version = 0;
419 if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
420 CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
421 *kiblnd_tunables.kib_ib_mtu);
425 if (!ni->ni_peertimeout)
426 ni->ni_peertimeout = peer_timeout;
428 if (!ni->ni_maxtxcredits)
429 ni->ni_maxtxcredits = credits;
431 if (!ni->ni_peertxcredits)
432 ni->ni_peertxcredits = peer_credits;
434 if (!ni->ni_peerrtrcredits)
435 ni->ni_peerrtrcredits = peer_buffer_credits;
437 if (ni->ni_peertxcredits < IBLND_CREDITS_DEFAULT)
438 ni->ni_peertxcredits = IBLND_CREDITS_DEFAULT;
440 if (ni->ni_peertxcredits > IBLND_CREDITS_MAX)
441 ni->ni_peertxcredits = IBLND_CREDITS_MAX;
443 if (ni->ni_peertxcredits > credits)
444 ni->ni_peertxcredits = credits;
446 if (!tunables->lnd_peercredits_hiw)
447 tunables->lnd_peercredits_hiw = peer_credits_hiw;
449 if (tunables->lnd_peercredits_hiw < ni->ni_peertxcredits / 2)
450 tunables->lnd_peercredits_hiw = ni->ni_peertxcredits / 2;
452 if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits)
453 tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1;
455 if (tunables->lnd_map_on_demand < 0 ||
456 tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) {
457 /* disable map-on-demand */
458 tunables->lnd_map_on_demand = 0;
461 if (tunables->lnd_map_on_demand == 1) {
462 /* don't make sense to create map if only one fragment */
463 tunables->lnd_map_on_demand = 2;
466 if (tunables->lnd_concurrent_sends == 0) {
467 if (tunables->lnd_map_on_demand > 0 &&
468 tunables->lnd_map_on_demand <= IBLND_MAX_RDMA_FRAGS / 8) {
469 tunables->lnd_concurrent_sends =
470 ni->ni_peertxcredits * 2;
472 tunables->lnd_concurrent_sends = ni->ni_peertxcredits;
476 if (tunables->lnd_concurrent_sends > ni->ni_peertxcredits * 2)
477 tunables->lnd_concurrent_sends = ni->ni_peertxcredits * 2;
479 if (tunables->lnd_concurrent_sends < ni->ni_peertxcredits / 2)
480 tunables->lnd_concurrent_sends = ni->ni_peertxcredits / 2;
482 if (tunables->lnd_concurrent_sends < ni->ni_peertxcredits) {
483 CWARN("Concurrent sends %d is lower than message "
484 "queue size: %d, performance may drop slightly.\n",
485 tunables->lnd_concurrent_sends, ni->ni_peertxcredits);
488 if (!tunables->lnd_fmr_pool_size)
489 tunables->lnd_fmr_pool_size = fmr_pool_size;
490 if (!tunables->lnd_fmr_flush_trigger)
491 tunables->lnd_fmr_flush_trigger = fmr_flush_trigger;
492 if (!tunables->lnd_fmr_cache)
493 tunables->lnd_fmr_cache = fmr_cache;
499 kiblnd_tunables_init(void)
501 default_tunables.lnd_version = 0;
502 default_tunables.lnd_peercredits_hiw = peer_credits_hiw,
503 default_tunables.lnd_map_on_demand = map_on_demand;
504 default_tunables.lnd_concurrent_sends = concurrent_sends;
505 default_tunables.lnd_fmr_pool_size = fmr_pool_size;
506 default_tunables.lnd_fmr_flush_trigger = fmr_flush_trigger;
507 default_tunables.lnd_fmr_cache = fmr_cache;
509 kiblnd_sysctl_init();
514 kiblnd_tunables_fini(void)
516 kiblnd_sysctl_fini();