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) 2014, 2016, Intel Corporation.
24 * Amir Shehata <amir.shehata@intel.com>
27 #ifndef LIB_LNET_CONFIG_API_H
28 #define LIB_LNET_CONFIG_API_H
30 #include <lnet/lnet.h>
32 #define LUSTRE_CFG_RC_NO_ERR 0
33 #define LUSTRE_CFG_RC_BAD_PARAM -1
34 #define LUSTRE_CFG_RC_MISSING_PARAM -2
35 #define LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM -3
36 #define LUSTRE_CFG_RC_OUT_OF_MEM -4
37 #define LUSTRE_CFG_RC_GENERIC_ERR -5
38 #define LUSTRE_CFG_RC_NO_MATCH -6
39 #define LUSTRE_CFG_RC_MATCH -7
41 #include <lnet/lnet.h>
42 #include <libcfs/libcfs_string.h>
44 struct lnet_dlc_network_descr {
45 struct list_head network_on_rule;
47 struct list_head nw_intflist;
50 struct lnet_dlc_intf_descr {
51 struct list_head intf_on_network;
52 char intf_name[LNET_MAX_STR_LEN];
53 struct cfs_expr_list *cpt_expr;
56 /* forward declaration of the cYAML structure. */
60 * lustre_lnet_config_lib_init()
61 * Initialize the Library to enable communication with the LNET kernel
62 * module. Returns the device ID or -EINVAL if there is an error
64 int lustre_lnet_config_lib_init();
67 * lustre_lnet_config_lib_uninit
68 * Uninitialize the DLC Library
70 void lustre_lnet_config_lib_uninit();
73 * lustre_lnet_config_ni_system
74 * Initialize/Uninitialize the lnet NI system.
76 * up - whehter to init or uninit the system
77 * load_ni_from_mod - load NI from mod params.
78 * seq_no - sequence number of the request
79 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
82 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
83 int seq_no, struct cYAML **err_rc);
86 * lustre_lnet_config_route
87 * Send down an IOCTL to the kernel to configure the route
91 * hops - number of hops passed down by the user
92 * prio - priority of the route
93 * seq_no - sequence number of the request
94 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
96 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
97 int seq_no, struct cYAML **err_rc);
100 * lustre_lnet_del_route
101 * Send down an IOCTL to the kernel to delete a route
105 * seq_no - sequence number of the request
106 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
108 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
109 struct cYAML **err_rc);
112 * lustre_lnet_show_route
113 * Send down an IOCTL to the kernel to show routes
114 * This function will get one route at a time and filter according to
115 * provided parameters. If no routes are available then it will dump all
116 * routes that are in the system.
118 * nw - network. Optional. Used to filter output
119 * gw - gateway. Optional. Used to filter ouptut
120 * hops - number of hops passed down by the user
121 * Optional. Used to filter output.
122 * prio - priority of the route. Optional. Used to filter output.
123 * detail - flag to indicate whether detail output is required
124 * seq_no - sequence number of the request
125 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
126 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
128 int lustre_lnet_show_route(char *nw, char *gw,
129 int hops, int prio, int detail,
130 int seq_no, struct cYAML **show_rc,
131 struct cYAML **err_rc);
134 * lustre_lnet_config_ni
135 * Send down an IOCTL to configure a network interface. It implicitly
136 * creates a network if one doesn't exist..
138 * nw_descr - network and interface descriptor
139 * global_cpts - globally defined CPTs
140 * ip2net - this parameter allows configuring multiple networks.
141 * it takes precedence over the net and intf parameters
142 * tunables - LND tunables
143 * seq_no - sequence number of the request
144 * lnd_tunables - lnet specific tunable parameters
145 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
147 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
148 struct cfs_expr_list *global_cpts,
150 struct lnet_ioctl_config_lnd_tunables *tunables,
151 int seq_no, struct cYAML **err_rc);
155 * Send down an IOCTL to delete a network interface. It implicitly
156 * deletes a network if it becomes empty of nis
158 * nw - network and interface list
159 * seq_no - sequence number of the request
160 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
162 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
163 int seq_no, struct cYAML **err_rc);
166 * lustre_lnet_show_net
167 * Send down an IOCTL to show networks.
168 * This function will use the nw paramter to filter the output. If it's
169 * not provided then all networks are listed.
171 * nw - network to show. Optional. Used to filter output.
172 * detail - flag to indicate if we require detail output.
173 * seq_no - sequence number of the request
174 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
175 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
177 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
178 struct cYAML **show_rc, struct cYAML **err_rc);
181 * lustre_lnet_enable_routing
182 * Send down an IOCTL to enable or diable routing
184 * enable - 1 to enable routing, 0 to disable routing
185 * seq_no - sequence number of the request
186 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
188 int lustre_lnet_enable_routing(int enable, int seq_no,
189 struct cYAML **err_rc);
192 * lustre_lnet_config_buffers
193 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
194 * default that particular buffer to default size. A value of -1 means
195 * leave the value of the buffer un changed.
197 * tiny - tiny buffers
198 * small - small buffers
199 * large - large buffers.
200 * seq_no - sequence number of the request
201 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
203 int lustre_lnet_config_buffers(int tiny, int small, int large,
204 int seq_no, struct cYAML **err_rc);
207 * lustre_lnet_show_routing
208 * Send down an IOCTL to dump buffers and routing status
209 * This function is used to dump buffers for all CPU partitions.
211 * seq_no - sequence number of the request
212 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
213 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
215 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
216 struct cYAML **err_rc);
219 * lustre_lnet_show_stats
220 * Shows internal LNET statistics. This is useful to display the
221 * current LNET activity, such as number of messages route, etc
223 * seq_no - sequence number of the command
224 * show_rc - YAML structure of the resultant show
225 * err_rc - YAML strucutre of the resultant return code.
227 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
228 struct cYAML **err_rc);
231 * lustre_lnet_config_peer_nid
232 * Add a peer nid to an peer identified by knid. If no knid is given
233 * then the first nid in the nid list becomes the primary nid for
234 * a newly created peer.
235 * Otherwise if knid is provided an it's unique then a new peer is
236 * created with knid as the primary NID and the nids in the nid list as
238 * If any of the peers nids provided in with exception to the knid is
239 * not unique the operation fails. Some peer nids might have already
240 * been added. It's the role of the caller of this API to remove the
241 * added NIDs if they wish.
243 * knid - Key NID of the peer
244 * nid - list of nids to add
245 * seq_no - sequence number of the command
246 * err_rc - YAML strucutre of the resultant return code.
248 int lustre_lnet_config_peer_nid(char *knid, char **nid, int seq_no,
249 struct cYAML **err_rc);
252 * lustre_lnet_del_peer_nid
253 * Delete the nids identified in the nid list from the peer identified by
254 * knid. If knid is NULL or it doesn't identify a peer the operation
255 * fails and no change happens to the system.
256 * The operation is aborted on the first NID that fails to be deleted.
258 * knid - Key NID of the peer
259 * nid - list of nids to add
260 * seq_no - sequence number of the command
261 * err_rc - YAML strucutre of the resultant return code.
263 int lustre_lnet_del_peer_nid(char *knid, char **nid, int seq_no,
264 struct cYAML **err_rc);
267 * lustre_lnet_show_peer
268 * Show the peer identified by knid. If knid is NULL all peers in the
271 * knid - Key NID of the peer
272 * seq_no - sequence number of the command
273 * show_rc - YAML structure of the resultant show
274 * err_rc - YAML strucutre of the resultant return code.
277 int lustre_lnet_show_peer(char *knid, int seq_no, struct cYAML **show_rc,
278 struct cYAML **err_rc);
282 * Parses the provided YAML file and then calls the specific APIs
283 * to configure the entities identified in the file
286 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
288 int lustre_yaml_config(char *f, struct cYAML **err_rc);
292 * Parses the provided YAML file and then calls the specific APIs
293 * to delete the entities identified in the file
296 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
298 int lustre_yaml_del(char *f, struct cYAML **err_rc);
302 * Parses the provided YAML file and then calls the specific APIs
303 * to show the entities identified in the file
306 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
307 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
309 int lustre_yaml_show(char *f, struct cYAML **show_rc,
310 struct cYAML **err_rc);
313 * lustre_lnet_init_nw_descr
314 * initialize the network descriptor structure for use
316 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
319 * lustre_lnet_parse_interfaces
320 * prase an interface string and populate descriptor structures
321 * intf_str - interface string of the format
322 * <intf>[<expr>], <intf>[<expr>],..
323 * nw_descr - network descriptor to populate
324 * init - True to initialize nw_descr
326 int lustre_lnet_parse_interfaces(char *intf_str,
327 struct lnet_dlc_network_descr *nw_descr);
330 * lustre_lnet_send_dbg_task
331 * send a debug task to be carried out in the kernel. This API will
332 * not be exposed to the user through lnetctl utility. It can only be
333 * executed by being called directly.
334 * dbg_task: The task to be carried out
335 * dbg_info: task specific information
337 int lustre_lnet_send_dbg_task(enum lnet_dbg_task dbg_task,
338 struct lnet_dbg_task_info *dbg_info,
339 struct cYAML **show_rc,
340 struct cYAML **err_rc);
342 #endif /* LIB_LNET_CONFIG_API_H */