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, Intel Corporation.
26 * James Simmons <jsimmons@infradead.org>
30 #include <libcfs/util/ioctl.h>
31 #include "liblnetconfig.h"
35 lustre_ko2iblnd_show_net(struct cYAML *lndparams,
36 struct lnet_ioctl_config_lnd_tunables *tunables)
38 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg;
40 lnd_cfg = &tunables->lt_tun_u.lt_o2ib;
42 if (cYAML_create_number(lndparams, "peercredits_hiw",
43 lnd_cfg->lnd_peercredits_hiw) == NULL)
46 if (cYAML_create_number(lndparams, "map_on_demand",
47 lnd_cfg->lnd_map_on_demand) == NULL)
50 if (cYAML_create_number(lndparams, "concurrent_sends",
51 lnd_cfg->lnd_concurrent_sends) == NULL)
54 if (cYAML_create_number(lndparams, "fmr_pool_size",
55 lnd_cfg->lnd_fmr_pool_size) == NULL)
58 if (cYAML_create_number(lndparams, "fmr_flush_trigger",
59 lnd_cfg->lnd_fmr_flush_trigger) == NULL)
62 if (cYAML_create_number(lndparams, "fmr_cache",
63 lnd_cfg->lnd_fmr_cache) == NULL)
69 lustre_interface_show_net(struct cYAML *interfaces, unsigned int index,
70 bool detail, struct lnet_ioctl_config_data *data,
71 struct lnet_ioctl_net_config *net_config)
73 char ni_index[2]; /* LNET_MAX_INTERFACES is only 16 */
75 if (strlen(net_config->ni_interfaces[index]) == 0)
78 snprintf(ni_index, sizeof(ni_index), "%d", index);
79 if (cYAML_create_string(interfaces, ni_index,
80 net_config->ni_interfaces[index]) == NULL)
84 __u32 net = LNET_NETTYP(LNET_NIDNET(data->cfg_nid));
85 struct lnet_ioctl_config_lnd_tunables *lnd_cfg;
86 struct cYAML *lndparams;
88 if (data->cfg_config_u.cfg_net.net_interface_count == 0 ||
92 lndparams = cYAML_create_object(interfaces, "lnd tunables");
93 if (lndparams == NULL)
96 lnd_cfg = (struct lnet_ioctl_config_lnd_tunables *)net_config->cfg_bulk;
97 if (lustre_ko2iblnd_show_net(lndparams, lnd_cfg) < 0)
104 lustre_ko2iblnd_parse_net(struct cYAML *lndparams,
105 struct lnet_ioctl_config_lnd_tunables *lnd_cfg)
107 struct cYAML *map_on_demand = NULL, *concurrent_sends = NULL;
108 struct cYAML *fmr_pool_size = NULL, *fmr_cache = NULL;
109 struct cYAML *fmr_flush_trigger = NULL;
111 map_on_demand = cYAML_get_object_item(lndparams, "map_on_demand");
112 lnd_cfg->lt_tun_u.lt_o2ib.lnd_map_on_demand =
113 (map_on_demand) ? map_on_demand->cy_valueint : 0;
115 concurrent_sends = cYAML_get_object_item(lndparams, "concurrent_sends");
116 lnd_cfg->lt_tun_u.lt_o2ib.lnd_concurrent_sends =
117 (concurrent_sends) ? concurrent_sends->cy_valueint : 0;
119 fmr_pool_size = cYAML_get_object_item(lndparams, "fmr_pool_size");
120 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_pool_size =
121 (fmr_pool_size) ? fmr_pool_size->cy_valueint : 0;
123 fmr_flush_trigger = cYAML_get_object_item(lndparams,
124 "fmr_flush_trigger");
125 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_flush_trigger =
126 (fmr_flush_trigger) ? fmr_flush_trigger->cy_valueint : 0;
128 fmr_cache = cYAML_get_object_item(lndparams, "fmr_cache");
129 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_cache =
130 (fmr_cache) ? fmr_cache->cy_valueint : 0;
134 lustre_interface_parse(struct cYAML *lndparams, const char *dev_name,
135 struct lnet_ioctl_config_lnd_tunables *lnd_cfg)
137 if (dev_name != NULL && strstr(dev_name, "ib"))
138 lustre_ko2iblnd_parse_net(lndparams, lnd_cfg);