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 Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 * Copyright (c) 2015, James Simmons
23 * Copyright (c) 2016, 2017, Intel Corporation.
26 * James Simmons <jsimmons@infradead.org>
33 #include <libcfs/util/ioctl.h>
35 #include "liblnetconfig.h"
38 lustre_o2iblnd_show_tun(struct cYAML *lndparams,
39 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg)
41 if (cYAML_create_number(lndparams, "peercredits_hiw",
42 lnd_cfg->lnd_peercredits_hiw) == NULL)
43 return LUSTRE_CFG_RC_OUT_OF_MEM;
45 if (cYAML_create_number(lndparams, "map_on_demand",
46 lnd_cfg->lnd_map_on_demand) == NULL)
47 return LUSTRE_CFG_RC_OUT_OF_MEM;
49 if (cYAML_create_number(lndparams, "concurrent_sends",
50 lnd_cfg->lnd_concurrent_sends) == NULL)
51 return LUSTRE_CFG_RC_OUT_OF_MEM;
53 if (cYAML_create_number(lndparams, "fmr_pool_size",
54 lnd_cfg->lnd_fmr_pool_size) == NULL)
55 return LUSTRE_CFG_RC_OUT_OF_MEM;
57 if (cYAML_create_number(lndparams, "fmr_flush_trigger",
58 lnd_cfg->lnd_fmr_flush_trigger) == NULL)
59 return LUSTRE_CFG_RC_OUT_OF_MEM;
61 if (cYAML_create_number(lndparams, "fmr_cache",
62 lnd_cfg->lnd_fmr_cache) == NULL)
63 return LUSTRE_CFG_RC_OUT_OF_MEM;
65 if (cYAML_create_number(lndparams, "ntx",
66 lnd_cfg->lnd_ntx) == NULL)
67 return LUSTRE_CFG_RC_OUT_OF_MEM;
69 if (cYAML_create_number(lndparams, "conns_per_peer",
70 lnd_cfg->lnd_conns_per_peer) == NULL)
71 return LUSTRE_CFG_RC_OUT_OF_MEM;
73 return LUSTRE_CFG_RC_NO_ERR;
78 lustre_socklnd_show_tun(struct cYAML *lndparams,
79 struct lnet_ioctl_config_socklnd_tunables *lnd_cfg)
81 if (cYAML_create_number(lndparams, "conns_per_peer",
82 lnd_cfg->lnd_conns_per_peer) == NULL)
83 return LUSTRE_CFG_RC_OUT_OF_MEM;
85 return LUSTRE_CFG_RC_NO_ERR;
89 lustre_net_show_tunables(struct cYAML *tunables,
90 struct lnet_ioctl_config_lnd_cmn_tunables *cmn)
92 if (cYAML_create_number(tunables, "peer_timeout",
93 cmn->lct_peer_timeout)
97 if (cYAML_create_number(tunables, "peer_credits",
98 cmn->lct_peer_tx_credits)
102 if (cYAML_create_number(tunables,
103 "peer_buffer_credits",
104 cmn->lct_peer_rtr_credits)
108 if (cYAML_create_number(tunables, "credits",
109 cmn->lct_max_tx_credits)
113 return LUSTRE_CFG_RC_NO_ERR;
116 return LUSTRE_CFG_RC_OUT_OF_MEM;
120 lustre_ni_show_tunables(struct cYAML *lnd_tunables,
122 struct lnet_lnd_tunables *lnd)
124 int rc = LUSTRE_CFG_RC_NO_MATCH;
126 if (net_type == O2IBLND)
127 rc = lustre_o2iblnd_show_tun(lnd_tunables,
128 &lnd->lnd_tun_u.lnd_o2ib);
129 else if (net_type == SOCKLND)
130 rc = lustre_socklnd_show_tun(lnd_tunables,
131 &lnd->lnd_tun_u.lnd_sock);
137 yaml_extract_o2ib_tun(struct cYAML *tree,
138 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg)
140 struct cYAML *map_on_demand = NULL, *concurrent_sends = NULL;
141 struct cYAML *fmr_pool_size = NULL, *fmr_cache = NULL;
142 struct cYAML *fmr_flush_trigger = NULL, *lndparams = NULL;
143 struct cYAML *conns_per_peer = NULL, *ntx = NULL;
145 lndparams = cYAML_get_object_item(tree, "lnd tunables");
149 map_on_demand = cYAML_get_object_item(lndparams, "map_on_demand");
150 lnd_cfg->lnd_map_on_demand =
151 (map_on_demand) ? map_on_demand->cy_valueint : 0;
153 concurrent_sends = cYAML_get_object_item(lndparams, "concurrent_sends");
154 lnd_cfg->lnd_concurrent_sends =
155 (concurrent_sends) ? concurrent_sends->cy_valueint : 0;
157 fmr_pool_size = cYAML_get_object_item(lndparams, "fmr_pool_size");
158 lnd_cfg->lnd_fmr_pool_size =
159 (fmr_pool_size) ? fmr_pool_size->cy_valueint : 0;
161 fmr_flush_trigger = cYAML_get_object_item(lndparams,
162 "fmr_flush_trigger");
163 lnd_cfg->lnd_fmr_flush_trigger =
164 (fmr_flush_trigger) ? fmr_flush_trigger->cy_valueint : 0;
166 fmr_cache = cYAML_get_object_item(lndparams, "fmr_cache");
167 lnd_cfg->lnd_fmr_cache =
168 (fmr_cache) ? fmr_cache->cy_valueint : 0;
170 ntx = cYAML_get_object_item(lndparams, "ntx");
171 lnd_cfg->lnd_ntx = (ntx) ? ntx->cy_valueint : 0;
173 conns_per_peer = cYAML_get_object_item(lndparams, "conns_per_peer");
174 lnd_cfg->lnd_conns_per_peer =
175 (conns_per_peer) ? conns_per_peer->cy_valueint : 1;
181 yaml_extract_sock_tun(struct cYAML *tree,
182 struct lnet_ioctl_config_socklnd_tunables *lnd_cfg)
184 struct cYAML *conns_per_peer = NULL, *lndparams = NULL;
186 lndparams = cYAML_get_object_item(tree, "lnd tunables");
190 conns_per_peer = cYAML_get_object_item(lndparams, "conns_per_peer");
191 lnd_cfg->lnd_conns_per_peer =
192 (conns_per_peer) ? conns_per_peer->cy_valueint : 1;
196 lustre_yaml_extract_lnd_tunables(struct cYAML *tree,
198 struct lnet_lnd_tunables *tun)
200 if (net_type == O2IBLND)
201 yaml_extract_o2ib_tun(tree,
202 &tun->lnd_tun_u.lnd_o2ib);
203 else if (net_type == SOCKLND)
204 yaml_extract_sock_tun(tree,
205 &tun->lnd_tun_u.lnd_sock);