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.gnu.org/licenses/gpl-2.0.html
23 * Copyright 2022 Hewlett Packard Enterprise Development LP
26 * This file is part of Lustre, http://www.lustre.org/
29 * kfilnd module parameters
35 module_param(cksum, uint, 0444);
36 MODULE_PARM_DESC(cksum, "Enable checksums for non-zero messages (not RDMA)");
38 /* Scale factor for TX context queue depth. The factor is applied to the number
39 * of credits to determine queue depth.
41 unsigned int tx_scale_factor = 2;
42 module_param(tx_scale_factor, uint, 0444);
43 MODULE_PARM_DESC(tx_scale_factor,
44 "Factor applied to credits to determine TX context size");
46 /* Scale factor for TX and RX completion queue depth. The factor is applied to
47 * the number of credits to determine queue depth.
49 unsigned int rx_cq_scale_factor = 10;
50 module_param(rx_cq_scale_factor, uint, 0444);
51 MODULE_PARM_DESC(rx_cq_scale_factor,
52 "Factor applied to credits to determine RX CQ size");
54 unsigned int tx_cq_scale_factor = 10;
55 module_param(tx_cq_scale_factor, uint, 0444);
56 MODULE_PARM_DESC(tx_cq_scale_factor,
57 "Factor applied to credits to determine TX CQ size");
59 unsigned int eq_size = 1024;
60 module_param(eq_size, uint, 0444);
61 MODULE_PARM_DESC(eq_size, "Default event queue size used by all kfi LNet NIs");
63 unsigned int immediate_rx_buf_count = 8;
64 module_param(immediate_rx_buf_count, uint, 0444);
65 MODULE_PARM_DESC(immediate_rx_buf_count,
66 "Number of immediate multi-receive buffers posted per CPT");
68 /* Common LND network tunables. */
69 static int credits = 256;
70 module_param(credits, int, 0444);
71 MODULE_PARM_DESC(credits, "Number of concurrent sends on network");
73 static int peer_credits = 16;
74 module_param(peer_credits, int, 0444);
75 MODULE_PARM_DESC(peer_credits, "Number of concurrent sends to 1 peer");
77 static int peer_buffer_credits = -1;
78 module_param(peer_buffer_credits, int, 0444);
79 MODULE_PARM_DESC(peer_buffer_credits,
80 "Number of per-peer router buffer credits");
82 static int peer_timeout = -1;
83 module_param(peer_timeout, int, 0444);
84 MODULE_PARM_DESC(peer_timeout,
85 "Seconds without aliveness news to declare peer dead (less than or equal to 0 to disable).");
87 static unsigned int prov_major_version = 1;
88 module_param(prov_major_version, int, 0444);
89 MODULE_PARM_DESC(prov_major_version,
90 "Default kfabric provider major version kfilnd should use");
92 static unsigned int prov_minor_version;
93 module_param(prov_minor_version, int, 0444);
94 MODULE_PARM_DESC(prov_minor_version,
95 "Default kfabric provider minor version kfilnd should use");
97 static unsigned int auth_key = 255;
98 module_param(auth_key, uint, 0444);
99 MODULE_PARM_DESC(auth_key, "Default authorization key to be used for LNet NIs");
101 static char *traffic_class = "best_effort";
102 module_param(traffic_class, charp, 0444);
103 MODULE_PARM_DESC(traffic_class, "Traffic class - default is \"best_effort\"");
106 kfilnd_tcstr2num(char *tcstr)
108 if (!strcmp(tcstr, "best_effort"))
109 return KFI_TC_BEST_EFFORT;
110 if (!strcmp(tcstr, "low_latency"))
111 return KFI_TC_LOW_LATENCY;
112 if (!strcmp(tcstr, "dedicated_access"))
113 return KFI_TC_DEDICATED_ACCESS;
114 if (!strcmp(tcstr, "bulk_data"))
115 return KFI_TC_BULK_DATA;
116 if (!strcmp(tcstr, "scavenger"))
117 return KFI_TC_SCAVENGER;
118 if (!strcmp(tcstr, "network_ctrl"))
119 return KFI_TC_NETWORK_CTRL;
123 int kfilnd_tunables_setup(struct lnet_ni *ni)
125 struct lnet_ioctl_config_lnd_cmn_tunables *net_tunables;
126 struct lnet_ioctl_config_kfilnd_tunables *kfilnd_tunables;
128 net_tunables = &ni->ni_net->net_tunables;
129 kfilnd_tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_kfi;
131 if (net_tunables->lct_peer_timeout == -1)
132 net_tunables->lct_peer_timeout = peer_timeout;
134 if (net_tunables->lct_max_tx_credits == -1)
135 net_tunables->lct_max_tx_credits = credits;
137 if (net_tunables->lct_peer_tx_credits == -1)
138 net_tunables->lct_peer_tx_credits = peer_credits;
140 if (net_tunables->lct_peer_rtr_credits == -1)
141 net_tunables->lct_peer_rtr_credits = peer_buffer_credits;
143 if (net_tunables->lct_peer_tx_credits >
144 net_tunables->lct_max_tx_credits)
145 net_tunables->lct_peer_tx_credits =
146 net_tunables->lct_max_tx_credits;
148 kfilnd_tunables->lnd_version = KFILND_MSG_VERSION;
149 if (!ni->ni_lnd_tunables_set) {
150 kfilnd_tunables->lnd_prov_major_version = prov_major_version;
151 kfilnd_tunables->lnd_prov_minor_version = prov_minor_version;
152 kfilnd_tunables->lnd_auth_key = auth_key;
153 if (strlen(traffic_class) < LNET_MAX_STR_LEN)
154 strcpy(&kfilnd_tunables->lnd_traffic_class_str[0],
158 /* Treat kfilnd_tunables set to zero as uninitialized. */
159 if (kfilnd_tunables->lnd_prov_major_version == 0 &&
160 kfilnd_tunables->lnd_prov_major_version == 0) {
161 kfilnd_tunables->lnd_prov_major_version = prov_major_version;
162 kfilnd_tunables->lnd_prov_minor_version = prov_minor_version;
165 if (kfilnd_tunables->lnd_auth_key == 0)
166 kfilnd_tunables->lnd_auth_key = auth_key;
168 if (strlen(kfilnd_tunables->lnd_traffic_class_str) == 0 &&
169 strlen(traffic_class) < LNET_MAX_STR_LEN)
170 strcpy(&kfilnd_tunables->lnd_traffic_class_str[0],
173 kfilnd_tunables->lnd_traffic_class =
174 kfilnd_tcstr2num(kfilnd_tunables->lnd_traffic_class_str);
176 if (net_tunables->lct_max_tx_credits > KFILND_EP_KEY_MAX) {
177 CERROR("Credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
181 if (net_tunables->lct_peer_tx_credits > KFILND_EP_KEY_MAX) {
182 CERROR("Peer credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
186 if (kfilnd_tunables->lnd_prov_major_version > prov_major_version) {
187 CERROR("Provider major version greater than %d unsupported\n",
192 if (kfilnd_tunables->lnd_traffic_class == -1) {
193 CERROR("Invalid traffic_class \"%s\" - Valid values are: best_effort, low_latency, dedicated_access, bulk_data, scavenger, and network_ctrl\n",
194 kfilnd_tunables->lnd_traffic_class_str);
201 int kfilnd_tunables_init(void)
203 if (tx_scale_factor < 1) {
204 CERROR("TX context scale factor less than 1");
208 if (rx_cq_scale_factor < 1) {
209 CERROR("RX CQ scale factor less than 1");
213 if (tx_cq_scale_factor < 1) {
214 CERROR("TX CQ scale factor less than 1");
218 if (immediate_rx_buf_count < 2) {
219 CERROR("Immediate multi-receive buffer count less than 2");
224 CERROR("Authorization key cannot be less than 1");
228 if (credits > KFILND_EP_KEY_MAX) {
229 CERROR("Credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
233 if (peer_credits > KFILND_EP_KEY_MAX) {
234 CERROR("Peer credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
238 if (kfilnd_tcstr2num(traffic_class) == -1) {
239 CERROR("Invalid traffic_class \"%s\" - Valid values are: best_effort, low_latency, dedicated_access, bulk_data, scavenger, and network_ctrl\n",