Whamcloud - gitweb
LU-16461 kfilnd: Modify peer credits and RX buffers
[fs/lustre-release.git] / lnet / klnds / kfilnd / kfilnd_modparams.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright 2022 Hewlett Packard Enterprise Development LP
24  */
25 /*
26  * This file is part of Lustre, http://www.lustre.org/
27  */
28 /*
29  * kfilnd module parameters
30  */
31
32 #include "kfilnd.h"
33
34 unsigned int cksum;
35 module_param(cksum, uint, 0444);
36 MODULE_PARM_DESC(cksum, "Enable checksums for non-zero messages (not RDMA)");
37
38 /* Scale factor for TX context queue depth. The factor is applied to the number
39  * of credits to determine queue depth.
40  */
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");
45
46 /* Scale factor for TX and RX completion queue depth. The factor is applied to
47  * the number of credits to determine queue depth.
48  */
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");
53
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");
58
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");
62
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");
67
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");
72
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");
76
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");
81
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).");
86
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");
91
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");
96
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");
100
101 int kfilnd_tunables_setup(struct lnet_ni *ni)
102 {
103         struct lnet_ioctl_config_lnd_cmn_tunables *net_tunables;
104         struct lnet_ioctl_config_kfilnd_tunables *kfilnd_tunables;
105
106         net_tunables = &ni->ni_net->net_tunables;
107         kfilnd_tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_kfi;
108
109         if (!ni->ni_net->net_tunables_set) {
110                 net_tunables->lct_max_tx_credits = credits;
111                 net_tunables->lct_peer_tx_credits = peer_credits;
112                 net_tunables->lct_peer_rtr_credits = peer_buffer_credits;
113                 net_tunables->lct_peer_timeout = peer_timeout;
114
115                 if (net_tunables->lct_peer_tx_credits >
116                     net_tunables->lct_max_tx_credits)
117                         net_tunables->lct_peer_tx_credits =
118                                 net_tunables->lct_max_tx_credits;
119         }
120
121         kfilnd_tunables->lnd_version = KFILND_MSG_VERSION;
122         if (!ni->ni_lnd_tunables_set) {
123                 kfilnd_tunables->lnd_prov_major_version = prov_major_version;
124                 kfilnd_tunables->lnd_prov_minor_version = prov_minor_version;
125
126                 /* Treat zero as uninitialized. */
127                 if (ni->ni_lnd_tunables.lnd_tun_u.lnd_kfi.lnd_auth_key == 0)
128                         ni->ni_lnd_tunables.lnd_tun_u.lnd_kfi.lnd_auth_key =
129                                 auth_key;
130         }
131
132         if (net_tunables->lct_max_tx_credits > KFILND_EP_KEY_MAX) {
133                 CERROR("Credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
134                 return -EINVAL;
135         }
136
137         if (net_tunables->lct_peer_tx_credits > KFILND_EP_KEY_MAX) {
138                 CERROR("Peer credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
139                 return -EINVAL;
140         }
141
142         return 0;
143 }
144
145 int kfilnd_tunables_init(void)
146 {
147         if (tx_scale_factor < 1) {
148                 CERROR("TX context scale factor less than 1");
149                 return -EINVAL;
150         }
151
152         if (rx_cq_scale_factor < 1) {
153                 CERROR("RX CQ scale factor less than 1");
154                 return -EINVAL;
155         }
156
157         if (tx_cq_scale_factor < 1) {
158                 CERROR("TX CQ scale factor less than 1");
159                 return -EINVAL;
160         }
161
162         if (immediate_rx_buf_count < 2) {
163                 CERROR("Immediate multi-receive buffer count less than 2");
164                 return -EINVAL;
165         }
166
167         if (auth_key < 1) {
168                 CERROR("Authorization key cannot be less than 1");
169                 return -EINVAL;
170         }
171
172         if (credits > KFILND_EP_KEY_MAX) {
173                 CERROR("Credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
174                 return -EINVAL;
175         }
176
177         if (peer_credits > KFILND_EP_KEY_MAX) {
178                 CERROR("Peer credits cannot exceed %lu\n", KFILND_EP_KEY_MAX);
179                 return -EINVAL;
180         }
181
182         return 0;
183 }