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 <libcfs/util/string.h>
31 #include <linux/lnet/lnet-dlc.h>
32 #include <linux/lnet/nidstr.h>
34 #define LUSTRE_CFG_RC_NO_ERR 0
35 #define LUSTRE_CFG_RC_BAD_PARAM -1
36 #define LUSTRE_CFG_RC_MISSING_PARAM -2
37 #define LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM -3
38 #define LUSTRE_CFG_RC_OUT_OF_MEM -4
39 #define LUSTRE_CFG_RC_GENERIC_ERR -5
40 #define LUSTRE_CFG_RC_NO_MATCH -6
41 #define LUSTRE_CFG_RC_MATCH -7
43 struct lnet_dlc_network_descr {
44 struct list_head network_on_rule;
46 struct list_head nw_intflist;
49 struct lnet_dlc_intf_descr {
50 struct list_head intf_on_network;
51 char intf_name[LNET_MAX_STR_LEN];
52 struct cfs_expr_list *cpt_expr;
55 /* forward declaration of the cYAML structure. */
59 * lustre_lnet_config_lib_init()
60 * Initialize the Library to enable communication with the LNET kernel
61 * module. Returns the device ID or -EINVAL if there is an error
63 int lustre_lnet_config_lib_init();
66 * lustre_lnet_config_lib_uninit
67 * Uninitialize the DLC Library
69 void lustre_lnet_config_lib_uninit();
72 * lustre_lnet_config_ni_system
73 * Initialize/Uninitialize the lnet NI system.
75 * up - whehter to init or uninit the system
76 * load_ni_from_mod - load NI from mod params.
77 * seq_no - sequence number of the request
78 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
81 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
82 int seq_no, struct cYAML **err_rc);
85 * lustre_lnet_config_route
86 * Send down an IOCTL to the kernel to configure the route
90 * hops - number of hops passed down by the user
91 * prio - priority of the route
92 * seq_no - sequence number of the request
93 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
95 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
96 int seq_no, struct cYAML **err_rc);
99 * lustre_lnet_del_route
100 * Send down an IOCTL to the kernel to delete a route
104 * seq_no - sequence number of the request
105 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
107 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
108 struct cYAML **err_rc);
111 * lustre_lnet_show_route
112 * Send down an IOCTL to the kernel to show routes
113 * This function will get one route at a time and filter according to
114 * provided parameters. If no routes are available then it will dump all
115 * routes that are in the system.
117 * nw - network. Optional. Used to filter output
118 * gw - gateway. Optional. Used to filter ouptut
119 * hops - number of hops passed down by the user
120 * Optional. Used to filter output.
121 * prio - priority of the route. Optional. Used to filter output.
122 * detail - flag to indicate whether detail output is required
123 * seq_no - sequence number of the request
124 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
125 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
127 int lustre_lnet_show_route(char *nw, char *gw,
128 int hops, int prio, int detail,
129 int seq_no, struct cYAML **show_rc,
130 struct cYAML **err_rc);
133 * lustre_lnet_config_ni
134 * Send down an IOCTL to configure a network interface. It implicitly
135 * creates a network if one doesn't exist..
137 * nw_descr - network and interface descriptor
138 * global_cpts - globally defined CPTs
139 * ip2net - this parameter allows configuring multiple networks.
140 * it takes precedence over the net and intf parameters
141 * tunables - LND tunables
142 * seq_no - sequence number of the request
143 * lnd_tunables - lnet specific tunable parameters
144 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
146 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
147 struct cfs_expr_list *global_cpts,
149 struct lnet_ioctl_config_lnd_tunables *tunables,
150 int seq_no, struct cYAML **err_rc);
154 * Send down an IOCTL to delete a network interface. It implicitly
155 * deletes a network if it becomes empty of nis
157 * nw - network and interface list
158 * seq_no - sequence number of the request
159 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
161 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
162 int seq_no, struct cYAML **err_rc);
165 * lustre_lnet_show_net
166 * Send down an IOCTL to show networks.
167 * This function will use the nw paramter to filter the output. If it's
168 * not provided then all networks are listed.
170 * nw - network to show. Optional. Used to filter output.
171 * detail - flag to indicate if we require detail output.
172 * seq_no - sequence number of the request
173 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
174 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
176 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
177 struct cYAML **show_rc, struct cYAML **err_rc);
180 * lustre_lnet_enable_routing
181 * Send down an IOCTL to enable or diable routing
183 * enable - 1 to enable routing, 0 to disable routing
184 * seq_no - sequence number of the request
185 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
187 int lustre_lnet_enable_routing(int enable, int seq_no,
188 struct cYAML **err_rc);
191 * lustre_lnet_config_numa_range
192 * Set the NUMA range which impacts the NIs to be selected
193 * during sending. If the NUMA range is large the NUMA
194 * distance between the message memory and the NI becomes
195 * less significant. The NUMA range is a relative number
196 * with no other meaning besides allowing a wider breadth
197 * for picking an NI to send from.
199 * range - numa range value.
200 * seq_no - sequence number of the request
201 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
204 int lustre_lnet_config_numa_range(int range, int seq_no,
205 struct cYAML **err_rc);
208 * lustre_lnet_show_num_range
209 * Get the currently set NUMA range
211 * seq_no - sequence number of the request
212 * show_rc - [OUT] struct cYAML tree containing NUMA range info
213 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
216 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
217 struct cYAML **err_rc);
220 * lustre_lnet_config_max_intf
221 * Sets the maximum number of interfaces per node. this tunable is
222 * primarily useful for sanity checks prior to allocating memory.
224 * max - maximum value to configure
225 * seq_no - sequence number of the request
226 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
229 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
232 * lustre_lnet_show_max_intf
233 * show current maximum interface setting
235 * seq_no - sequence number of the request
236 * show_rc - [OUT] struct cYAML tree containing NUMA range info
237 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
240 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
241 struct cYAML **err_rc);
244 * lustre_lnet_config_discovery
245 * Enable or disable peer discovery. Peer discovery is enabled by default.
247 * enable - non-0 enables, 0 disables
248 * seq_no - sequence number of the request
249 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
252 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
255 * lustre_lnet_show_discovery
256 * show current peer discovery setting
258 * seq_no - sequence number of the request
259 * show_rc - [OUT] struct cYAML tree containing NUMA range info
260 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
263 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
264 struct cYAML **err_rc);
267 * lustre_lnet_config_buffers
268 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
269 * default that particular buffer to default size. A value of -1 means
270 * leave the value of the buffer un changed.
272 * tiny - tiny buffers
273 * small - small buffers
274 * large - large buffers.
275 * seq_no - sequence number of the request
276 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
278 int lustre_lnet_config_buffers(int tiny, int small, int large,
279 int seq_no, struct cYAML **err_rc);
282 * lustre_lnet_show_routing
283 * Send down an IOCTL to dump buffers and routing status
284 * This function is used to dump buffers for all CPU partitions.
286 * seq_no - sequence number of the request
287 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
288 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
290 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
291 struct cYAML **err_rc);
294 * lustre_lnet_show_stats
295 * Shows internal LNET statistics. This is useful to display the
296 * current LNET activity, such as number of messages route, etc
298 * seq_no - sequence number of the command
299 * show_rc - YAML structure of the resultant show
300 * err_rc - YAML strucutre of the resultant return code.
302 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
303 struct cYAML **err_rc);
306 * lustre_lnet_config_peer_nid
307 * Add a peer nid to a peer with primary nid pnid. If no pnid is given
308 * then the first nid in the nid list becomes the primary nid for
309 * a newly created peer.
310 * Otherwise if pnid is provided and it's unique then a new peer is
311 * created with pnid as the primary NID and the nids in the nid list as
313 * If any of the peers nids provided in with exception to the pnid is
314 * not unique the operation fails. Some peer nids might have already
315 * been added. It's the role of the caller of this API to remove the
316 * added NIDs if they wish.
318 * pnid - Primary NID of the peer
319 * nid - list of nids to add
320 * num_nids - number of nids in the nid array
321 * mr - true if this peer is MR capable.
322 * seq_no - sequence number of the command
323 * err_rc - YAML strucutre of the resultant return code.
325 int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
326 bool mr, int seq_no, struct cYAML **err_rc);
329 * lustre_lnet_del_peer_nid
330 * Delete the nids given in the nid list from the peer with primary NID
331 * pnid. If pnid is NULL or it doesn't identify a peer the operation
332 * fails and no change happens to the system.
333 * The operation is aborted on the first NID that fails to be deleted.
335 * pnid - Primary NID of the peer
336 * nid - list of nids to add
337 * num_nids - number of nids in the nid array
338 * seq_no - sequence number of the command
339 * err_rc - YAML strucutre of the resultant return code.
341 int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids,
342 int seq_no, struct cYAML **err_rc);
345 * lustre_lnet_show_peer
346 * Show the peer identified by nid, knid. If knid is NULL all
347 * peers in the system are shown.
349 * knid - A NID of the peer
350 * detail - display detailed information
351 * seq_no - sequence number of the command
352 * show_rc - YAML structure of the resultant show
353 * err_rc - YAML strucutre of the resultant return code.
356 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
357 struct cYAML **show_rc, struct cYAML **err_rc);
360 * lustre_lnet_list_peer
361 * List the known peers.
363 * seq_no - sequence number of the command
364 * show_rc - YAML structure of the resultant show
365 * err_rc - YAML strucutre of the resultant return code.
368 int lustre_lnet_list_peer(int seq_no,
369 struct cYAML **show_rc, struct cYAML **err_rc);
371 /* lustre_lnet_ping_nid
372 * Ping the nid list, pnids.
374 * pnids - NID list to ping.
375 * timeout - timeout(seconds) for ping.
376 * seq_no - sequence number of the command.
377 * show_rc - YAML structure of the resultant show.
378 * err_rc - YAML strucutre of the resultant return code.
381 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
382 struct cYAML **show_rc, struct cYAML **err_rc);
384 /* lustre_lnet_discover_nid
385 * Discover the nid list, pnids.
387 * pnids - NID list to discover.
388 * force - force discovery.
389 * seq_no - sequence number of the command.
390 * show_rc - YAML structure of the resultant show.
391 * err_rc - YAML strucutre of the resultant return code.
394 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
395 struct cYAML **show_rc, struct cYAML **err_rc);
399 * Parses the provided YAML file and then calls the specific APIs
400 * to configure the entities identified in the file
403 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
405 int lustre_yaml_config(char *f, struct cYAML **err_rc);
409 * Parses the provided YAML file and then calls the specific APIs
410 * to delete the entities identified in the file
413 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
415 int lustre_yaml_del(char *f, struct cYAML **err_rc);
419 * Parses the provided YAML file and then calls the specific APIs
420 * to show the entities identified in the file
423 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
424 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
426 int lustre_yaml_show(char *f, struct cYAML **show_rc,
427 struct cYAML **err_rc);
431 * Parses the provided YAML file and then calls the specific APIs
432 * to execute the entities identified in the file
435 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
436 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
438 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
439 struct cYAML **err_rc);
442 * lustre_lnet_init_nw_descr
443 * initialize the network descriptor structure for use
445 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
448 * lustre_lnet_parse_interfaces
449 * prase an interface string and populate descriptor structures
450 * intf_str - interface string of the format
451 * <intf>[<expr>], <intf>[<expr>],..
452 * nw_descr - network descriptor to populate
453 * init - True to initialize nw_descr
455 int lustre_lnet_parse_interfaces(char *intf_str,
456 struct lnet_dlc_network_descr *nw_descr);
459 * lustre_lnet_parse_nids
460 * Parse a set of nids into a locally allocated array and return the
461 * pointer of the array to the caller. The caller is responsible for
462 * freeing the array. If an initial array is provided then copy over
463 * the contents of that array into the new array and append to it the
465 * The nids can be of the form "nid [,nid, nid, nid]"
466 * nids: nids string to be parsed
467 * array: initial array of content
468 * size: num of elements in the array
469 * out_array: [OUT] new allocated array.
470 * Returns size of array
471 * sets the out_array to NULL on failure.
473 int lustre_lnet_parse_nids(char *nids, char **array, int size,
476 #endif /* LIB_LNET_CONFIG_API_H */