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
24 * James Simmons <jsimmons@infradead.org>
28 #include <libcfs/util/ioctl.h>
29 #include "liblnetconfig.h"
33 lustre_ko2iblnd_show_net(struct cYAML *lndparams,
34 struct lnet_ioctl_config_lnd_tunables *tunables)
36 struct lnet_ioctl_config_o2iblnd_tunables *lnd_cfg;
38 lnd_cfg = &tunables->lt_tun_u.lt_o2ib;
40 if (cYAML_create_number(lndparams, "peercredits_hiw",
41 lnd_cfg->lnd_peercredits_hiw) == NULL)
44 if (cYAML_create_number(lndparams, "map_on_demand",
45 lnd_cfg->lnd_map_on_demand) == NULL)
48 if (cYAML_create_number(lndparams, "concurrent_sends",
49 lnd_cfg->lnd_concurrent_sends) == NULL)
52 if (cYAML_create_number(lndparams, "fmr_pool_size",
53 lnd_cfg->lnd_fmr_pool_size) == NULL)
56 if (cYAML_create_number(lndparams, "fmr_flush_trigger",
57 lnd_cfg->lnd_fmr_flush_trigger) == NULL)
60 if (cYAML_create_number(lndparams, "fmr_cache",
61 lnd_cfg->lnd_fmr_cache) == NULL)
67 lustre_interface_show_net(struct cYAML *interfaces, unsigned int index,
68 bool detail, struct lnet_ioctl_config_data *data,
69 struct lnet_ioctl_net_config *net_config)
71 char ni_index[2]; /* LNET_MAX_INTERFACES is only 16 */
73 if (strlen(net_config->ni_interfaces[index]) == 0)
76 snprintf(ni_index, sizeof(ni_index), "%d", index);
77 if (cYAML_create_string(interfaces, ni_index,
78 net_config->ni_interfaces[index]) == NULL)
82 __u32 net = LNET_NETTYP(LNET_NIDNET(data->cfg_nid));
83 struct lnet_ioctl_config_lnd_tunables *lnd_cfg;
84 struct cYAML *lndparams;
86 if (data->cfg_config_u.cfg_net.net_interface_count == 0 ||
90 lndparams = cYAML_create_object(interfaces, "lnd tunables");
91 if (lndparams == NULL)
94 lnd_cfg = (struct lnet_ioctl_config_lnd_tunables *)net_config->cfg_bulk;
95 if (lustre_ko2iblnd_show_net(lndparams, lnd_cfg) < 0)
102 lustre_ko2iblnd_parse_net(struct cYAML *lndparams,
103 struct lnet_ioctl_config_lnd_tunables *lnd_cfg)
105 struct cYAML *map_on_demand = NULL, *concurrent_sends = NULL;
106 struct cYAML *fmr_pool_size = NULL, *fmr_cache = NULL;
107 struct cYAML *fmr_flush_trigger = NULL;
109 map_on_demand = cYAML_get_object_item(lndparams, "map_on_demand");
110 lnd_cfg->lt_tun_u.lt_o2ib.lnd_map_on_demand =
111 (map_on_demand) ? map_on_demand->cy_valueint : 0;
113 concurrent_sends = cYAML_get_object_item(lndparams, "concurrent_sends");
114 lnd_cfg->lt_tun_u.lt_o2ib.lnd_concurrent_sends =
115 (concurrent_sends) ? concurrent_sends->cy_valueint : 0;
117 fmr_pool_size = cYAML_get_object_item(lndparams, "fmr_pool_size");
118 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_pool_size =
119 (fmr_pool_size) ? fmr_pool_size->cy_valueint : 0;
121 fmr_flush_trigger = cYAML_get_object_item(lndparams,
122 "fmr_flush_trigger");
123 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_flush_trigger =
124 (fmr_flush_trigger) ? fmr_flush_trigger->cy_valueint : 0;
126 fmr_cache = cYAML_get_object_item(lndparams, "fmr_cache");
127 lnd_cfg->lt_tun_u.lt_o2ib.lnd_fmr_cache =
128 (fmr_cache) ? fmr_cache->cy_valueint : 0;
132 lustre_interface_parse(struct cYAML *lndparams, const char *dev_name,
133 struct lnet_ioctl_config_lnd_tunables *lnd_cfg)
135 if (dev_name != NULL && strstr(dev_name, "ib"))
136 lustre_ko2iblnd_parse_net(lndparams, lnd_cfg);