1 // SPDX-License-Identifier: LGPL-2.0
4 * Copyright (c) 2015, James Simmons
6 * Copyright (c) 2016, 2017, Intel Corporation.
10 * This file is part of Lustre, http://www.lustre.org/
12 * Author: James Simmons <jsimmons@infradead.org>
19 #include <libcfs/util/ioctl.h>
21 #include "liblnetconfig.h"
24 lustre_o2iblnd_show_tun(struct cYAML *lndparams,
25 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg)
27 if (cYAML_create_number(lndparams, "peercredits_hiw",
28 lnd_cfg->lnd_peercredits_hiw) == NULL)
29 return LUSTRE_CFG_RC_OUT_OF_MEM;
31 if (cYAML_create_number(lndparams, "map_on_demand",
32 lnd_cfg->lnd_map_on_demand) == NULL)
33 return LUSTRE_CFG_RC_OUT_OF_MEM;
35 if (cYAML_create_number(lndparams, "concurrent_sends",
36 lnd_cfg->lnd_concurrent_sends) == NULL)
37 return LUSTRE_CFG_RC_OUT_OF_MEM;
39 if (cYAML_create_number(lndparams, "fmr_pool_size",
40 lnd_cfg->lnd_fmr_pool_size) == NULL)
41 return LUSTRE_CFG_RC_OUT_OF_MEM;
43 if (cYAML_create_number(lndparams, "fmr_flush_trigger",
44 lnd_cfg->lnd_fmr_flush_trigger) == NULL)
45 return LUSTRE_CFG_RC_OUT_OF_MEM;
47 if (cYAML_create_number(lndparams, "fmr_cache",
48 lnd_cfg->lnd_fmr_cache) == NULL)
49 return LUSTRE_CFG_RC_OUT_OF_MEM;
51 if (cYAML_create_number(lndparams, "ntx",
52 lnd_cfg->lnd_ntx) == NULL)
53 return LUSTRE_CFG_RC_OUT_OF_MEM;
55 if (cYAML_create_number(lndparams, "conns_per_peer",
56 lnd_cfg->lnd_conns_per_peer) == NULL)
57 return LUSTRE_CFG_RC_OUT_OF_MEM;
59 if (cYAML_create_number(lndparams, "timeout",
60 lnd_cfg->lnd_timeout) == NULL)
61 return LUSTRE_CFG_RC_OUT_OF_MEM;
63 if (cYAML_create_number(lndparams, "tos",
64 lnd_cfg->lnd_tos) == NULL)
65 return LUSTRE_CFG_RC_OUT_OF_MEM;
67 return LUSTRE_CFG_RC_NO_ERR;
72 lustre_socklnd_show_tun(struct cYAML *lndparams,
73 struct lnet_ioctl_config_socklnd_tunables *lnd_cfg)
75 if (cYAML_create_number(lndparams, "conns_per_peer",
76 lnd_cfg->lnd_conns_per_peer) == NULL)
77 return LUSTRE_CFG_RC_OUT_OF_MEM;
79 if (cYAML_create_number(lndparams, "timeout",
80 lnd_cfg->lnd_timeout) == NULL)
81 return LUSTRE_CFG_RC_OUT_OF_MEM;
83 if (cYAML_create_number(lndparams, "tos",
84 lnd_cfg->lnd_tos) == NULL)
85 return LUSTRE_CFG_RC_OUT_OF_MEM;
87 return LUSTRE_CFG_RC_NO_ERR;
92 lustre_kfilnd_show_tun(struct cYAML *lndparams,
93 struct lnet_ioctl_config_kfilnd_tunables *lnd_cfg,
96 if (cYAML_create_number(lndparams, "prov_major_version",
97 lnd_cfg->lnd_prov_major_version) == NULL)
98 return LUSTRE_CFG_RC_OUT_OF_MEM;
100 if (cYAML_create_number(lndparams, "prov_minor_version",
101 lnd_cfg->lnd_prov_minor_version) == NULL)
102 return LUSTRE_CFG_RC_OUT_OF_MEM;
104 if (cYAML_create_number(lndparams, "auth_key",
105 lnd_cfg->lnd_auth_key) == NULL)
106 return LUSTRE_CFG_RC_OUT_OF_MEM;
108 if (cYAML_create_string(lndparams, "traffic_class",
109 lnd_cfg->lnd_traffic_class_str) == NULL)
110 return LUSTRE_CFG_RC_OUT_OF_MEM;
113 cYAML_create_number(lndparams, "traffic_class_num",
114 lnd_cfg->lnd_traffic_class) == NULL)
115 return LUSTRE_CFG_RC_OUT_OF_MEM;
117 return LUSTRE_CFG_RC_NO_ERR;
122 lustre_gnilnd_show_tun(struct cYAML *lndparams,
123 struct lnet_ioctl_config_gnilnd_tunables *lnd_cfg)
125 if (cYAML_create_number(lndparams, "timeout",
126 lnd_cfg->lnd_timeout) == NULL)
127 return LUSTRE_CFG_RC_OUT_OF_MEM;
129 return LUSTRE_CFG_RC_NO_ERR;
133 lustre_net_show_tunables(struct cYAML *tunables,
134 struct lnet_ioctl_config_lnd_cmn_tunables *cmn)
136 if (cYAML_create_number(tunables, "peer_timeout",
137 cmn->lct_peer_timeout)
141 if (cYAML_create_number(tunables, "peer_credits",
142 cmn->lct_peer_tx_credits)
146 if (cYAML_create_number(tunables,
147 "peer_buffer_credits",
148 cmn->lct_peer_rtr_credits)
152 if (cYAML_create_number(tunables, "credits",
153 cmn->lct_max_tx_credits)
157 return LUSTRE_CFG_RC_NO_ERR;
160 return LUSTRE_CFG_RC_OUT_OF_MEM;
164 lustre_ni_show_tunables(struct cYAML *lnd_tunables,
166 struct lnet_lnd_tunables *lnd,
169 int rc = LUSTRE_CFG_RC_NO_MATCH;
171 if (net_type == O2IBLND)
172 rc = lustre_o2iblnd_show_tun(lnd_tunables,
173 &lnd->lnd_tun_u.lnd_o2ib);
174 else if (net_type == SOCKLND)
175 rc = lustre_socklnd_show_tun(lnd_tunables,
176 &lnd->lnd_tun_u.lnd_sock);
178 else if (net_type == KFILND)
179 rc = lustre_kfilnd_show_tun(lnd_tunables,
180 &lnd->lnd_tun_u.lnd_kfi,
183 else if (net_type == GNILND)
184 rc = lustre_gnilnd_show_tun(lnd_tunables,
185 &lnd->lnd_tun_u.lnd_gni);
190 yaml_extract_o2ib_tun(struct cYAML *tree,
191 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg)
193 struct cYAML *map_on_demand = NULL, *concurrent_sends = NULL;
194 struct cYAML *fmr_pool_size = NULL, *fmr_cache = NULL;
195 struct cYAML *fmr_flush_trigger = NULL, *lndparams = NULL;
196 struct cYAML *conns_per_peer = NULL, *ntx = NULL;
197 struct cYAML *tos = NULL;
199 lndparams = cYAML_get_object_item(tree, "lnd tunables");
203 map_on_demand = cYAML_get_object_item(lndparams, "map_on_demand");
204 lnd_cfg->lnd_map_on_demand =
205 (map_on_demand) ? map_on_demand->cy_valueint : UINT_MAX;
207 concurrent_sends = cYAML_get_object_item(lndparams, "concurrent_sends");
208 lnd_cfg->lnd_concurrent_sends =
209 (concurrent_sends) ? concurrent_sends->cy_valueint : 0;
211 fmr_pool_size = cYAML_get_object_item(lndparams, "fmr_pool_size");
212 lnd_cfg->lnd_fmr_pool_size =
213 (fmr_pool_size) ? fmr_pool_size->cy_valueint : 0;
215 fmr_flush_trigger = cYAML_get_object_item(lndparams,
216 "fmr_flush_trigger");
217 lnd_cfg->lnd_fmr_flush_trigger =
218 (fmr_flush_trigger) ? fmr_flush_trigger->cy_valueint : 0;
220 fmr_cache = cYAML_get_object_item(lndparams, "fmr_cache");
221 lnd_cfg->lnd_fmr_cache =
222 (fmr_cache) ? fmr_cache->cy_valueint : 0;
224 ntx = cYAML_get_object_item(lndparams, "ntx");
225 lnd_cfg->lnd_ntx = (ntx) ? ntx->cy_valueint : 0;
227 conns_per_peer = cYAML_get_object_item(lndparams, "conns_per_peer");
228 lnd_cfg->lnd_conns_per_peer =
229 (conns_per_peer) ? conns_per_peer->cy_valueint : 1;
231 tos = cYAML_get_object_item(lndparams, "tos");
233 (tos) ? tos->cy_valueint : -1;
238 yaml_extract_kfi_tun(struct cYAML *tree,
239 struct lnet_ioctl_config_kfilnd_tunables *lnd_cfg)
241 struct cYAML *prov_major_version = NULL;
242 struct cYAML *prov_minor_version = NULL;
243 struct cYAML *auth_key = NULL;
244 struct cYAML *traffic_class = NULL;
245 struct cYAML *lndparams = NULL;
247 lndparams = cYAML_get_object_item(tree, "lnd tunables");
252 cYAML_get_object_item(lndparams, "prov_major_version");
253 lnd_cfg->lnd_prov_major_version =
254 (prov_major_version) ? prov_major_version->cy_valueint : 0;
257 cYAML_get_object_item(lndparams, "prov_minor_version");
258 lnd_cfg->lnd_prov_minor_version =
259 (prov_minor_version) ? prov_minor_version->cy_valueint : 0;
261 auth_key = cYAML_get_object_item(lndparams, "auth_key");
262 lnd_cfg->lnd_auth_key =
263 (auth_key) ? auth_key->cy_valueint : 0;
265 traffic_class = cYAML_get_object_item(lndparams, "traffic_class");
266 if (traffic_class && traffic_class->cy_valuestring &&
267 strlen(traffic_class->cy_valuestring) < LNET_MAX_STR_LEN)
268 strcpy(&lnd_cfg->lnd_traffic_class_str[0],
269 traffic_class->cy_valuestring);
274 yaml_extract_sock_tun(struct cYAML *tree,
275 struct lnet_ioctl_config_socklnd_tunables *lnd_cfg)
277 struct cYAML *conns_per_peer = NULL;
278 struct cYAML *tos = NULL;
279 struct cYAML *lndparams = NULL;
281 lndparams = cYAML_get_object_item(tree, "lnd tunables");
285 conns_per_peer = cYAML_get_object_item(lndparams, "conns_per_peer");
286 lnd_cfg->lnd_conns_per_peer =
287 (conns_per_peer) ? conns_per_peer->cy_valueint : 1;
289 tos = cYAML_get_object_item(lndparams, "tos");
291 (tos) ? tos->cy_valueint : -1;
295 lustre_yaml_extract_lnd_tunables(struct cYAML *tree,
297 struct lnet_lnd_tunables *tun)
299 if (net_type == O2IBLND)
300 yaml_extract_o2ib_tun(tree,
301 &tun->lnd_tun_u.lnd_o2ib);
302 else if (net_type == SOCKLND)
303 yaml_extract_sock_tun(tree,
304 &tun->lnd_tun_u.lnd_sock);
306 else if (net_type == KFILND)
307 yaml_extract_kfi_tun(tree,
308 &tun->lnd_tun_u.lnd_kfi);