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, 2017, Intel Corporation.
24 * Amir Shehata <amir.shehata@intel.com>
27 #ifndef LIB_LNET_CONFIG_API_H
28 #define LIB_LNET_CONFIG_API_H
31 #include <libcfs/util/string.h>
32 #include <linux/lnet/lnet-dlc.h>
33 #include <linux/lnet/nidstr.h>
35 #define LUSTRE_CFG_RC_NO_ERR 0
36 #define LUSTRE_CFG_RC_BAD_PARAM -1
37 #define LUSTRE_CFG_RC_MISSING_PARAM -2
38 #define LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM -3
39 #define LUSTRE_CFG_RC_OUT_OF_MEM -4
40 #define LUSTRE_CFG_RC_GENERIC_ERR -5
41 #define LUSTRE_CFG_RC_NO_MATCH -6
42 #define LUSTRE_CFG_RC_MATCH -7
43 #define LUSTRE_CFG_RC_SKIP -8
44 #define LUSTRE_CFG_RC_LAST_ELEM -9
46 struct lnet_dlc_network_descr {
47 struct list_head network_on_rule;
49 struct list_head nw_intflist;
52 struct lnet_dlc_intf_descr {
53 struct list_head intf_on_network;
54 char intf_name[IFNAMSIZ];
55 struct cfs_expr_list *cpt_expr;
58 /* forward declaration of the cYAML structure. */
62 * lustre_lnet_config_lib_init()
63 * Initialize the Library to enable communication with the LNET kernel
64 * module. Returns the device ID or -EINVAL if there is an error
66 int lustre_lnet_config_lib_init();
69 * lustre_lnet_config_lib_uninit
70 * Uninitialize the DLC Library
72 void lustre_lnet_config_lib_uninit();
75 * lustre_lnet_config_ni_system
76 * Initialize/Uninitialize the lnet NI system.
78 * up - whehter to init or uninit the system
79 * load_ni_from_mod - load NI from mod params.
80 * seq_no - sequence number of the request
81 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
84 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
85 int seq_no, struct cYAML **err_rc);
88 * lustre_lnet_config_route
89 * Send down an IOCTL to the kernel to configure the route
93 * hops - number of hops passed down by the user
94 * prio - priority of the route
95 * sen - health sensitivity value for the gateway
96 * seq_no - sequence number of the request
97 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
99 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
100 int sen, int seq_no, struct cYAML **err_rc);
103 * lustre_lnet_del_route
104 * Send down an IOCTL to the kernel to delete a route
108 * seq_no - sequence number of the request
109 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
111 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
112 struct cYAML **err_rc);
115 * lustre_lnet_show_route
116 * Send down an IOCTL to the kernel to show routes
117 * This function will get one route at a time and filter according to
118 * provided parameters. If no routes are available then it will dump all
119 * routes that are in the system.
121 * nw - network. Optional. Used to filter output
122 * gw - gateway. Optional. Used to filter ouptut
123 * hops - number of hops passed down by the user
124 * Optional. Used to filter output.
125 * prio - priority of the route. Optional. Used to filter output.
126 * detail - flag to indicate whether detail output is required
127 * seq_no - sequence number of the request
128 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
129 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
130 * backup - true to output only what's necessary for reconfiguring
133 int lustre_lnet_show_route(char *nw, char *gw,
134 int hops, int prio, int detail,
135 int seq_no, struct cYAML **show_rc,
136 struct cYAML **err_rc, bool backup);
139 * lustre_lnet_config_ni
140 * Send down an IOCTL to configure a network interface. It implicitly
141 * creates a network if one doesn't exist..
143 * nw_descr - network and interface descriptor
144 * global_cpts - globally defined CPTs
145 * ip2net - this parameter allows configuring multiple networks.
146 * it takes precedence over the net and intf parameters
147 * tunables - LND tunables
148 * seq_no - sequence number of the request
149 * lnd_tunables - lnet specific tunable parameters
150 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
152 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
153 struct cfs_expr_list *global_cpts,
155 struct lnet_ioctl_config_lnd_tunables *tunables,
156 int seq_no, struct cYAML **err_rc);
160 * Send down an IOCTL to delete a network interface. It implicitly
161 * deletes a network if it becomes empty of nis
163 * nw - network and interface list
164 * seq_no - sequence number of the request
165 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
167 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
168 int seq_no, struct cYAML **err_rc);
171 * lustre_lnet_show_net
172 * Send down an IOCTL to show networks.
173 * This function will use the nw paramter to filter the output. If it's
174 * not provided then all networks are listed.
176 * nw - network to show. Optional. Used to filter output.
177 * detail - flag to indicate if we require detail output.
178 * seq_no - sequence number of the request
179 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
180 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
181 * backup - true to output only what's necessary for reconfiguring
184 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
185 struct cYAML **show_rc, struct cYAML **err_rc,
189 * lustre_lnet_enable_routing
190 * Send down an IOCTL to enable or diable routing
192 * enable - 1 to enable routing, 0 to disable routing
193 * seq_no - sequence number of the request
194 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
196 int lustre_lnet_enable_routing(int enable, int seq_no,
197 struct cYAML **err_rc);
200 * lustre_lnet_config_numa_range
201 * Set the NUMA range which impacts the NIs to be selected
202 * during sending. If the NUMA range is large the NUMA
203 * distance between the message memory and the NI becomes
204 * less significant. The NUMA range is a relative number
205 * with no other meaning besides allowing a wider breadth
206 * for picking an NI to send from.
208 * range - numa range value.
209 * seq_no - sequence number of the request
210 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
213 int lustre_lnet_config_numa_range(int range, int seq_no,
214 struct cYAML **err_rc);
217 * lustre_lnet_show_num_range
218 * Get the currently set NUMA range
220 * seq_no - sequence number of the request
221 * show_rc - [OUT] struct cYAML tree containing NUMA range info
222 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
225 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
226 struct cYAML **err_rc);
229 * lustre_lnet_config_ni_healthv
230 * set the health value of the NI. -1 resets the value to maximum.
232 * value: health value to set.
233 * all: true to set all local NIs to that value.
234 * ni_nid: NI NID to set its health value. all parameter always takes
236 * seq_no - sequence number of the request
237 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
240 int lustre_lnet_config_ni_healthv(int value, bool all, char *ni_nid,
241 int seq_no, struct cYAML **err_rc);
244 * lustre_lnet_config_peer_ni_healthv
245 * set the health value of the peer NI. -1 resets the value to maximum.
247 * value: health value to set.
248 * all: true to set all local NIs to that value.
249 * pni_nid: Peer NI NID to set its health value. all parameter always takes
251 * seq_no - sequence number of the request
252 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
255 int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid,
256 int seq_no, struct cYAML **err_rc);
259 * lustre_lnet_config_recov_intrv
260 * set the recovery interval in seconds. That's the interval to ping an
261 * unhealthy interface.
263 * intrv - recovery interval value to configure
264 * seq_no - sequence number of the request
265 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
268 int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc);
271 * lustre_lnet_show_recov_intrv
272 * show the recovery interval set in the system
274 * seq_no - sequence number of the request
275 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
276 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
279 int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc,
280 struct cYAML **err_rc);
283 * lustre_lnet_config_rtr_sensitivity
284 * sets the router sensitivity percentage. If the percentage health
285 * of a router interface drops below that it's considered failed
287 * sen - sensitivity value to configure
288 * seq_no - sequence number of the request
289 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
292 int lustre_lnet_config_rtr_sensitivity(int sen, int seq_no, struct cYAML **err_rc);
295 * lustre_lnet_config_hsensitivity
296 * sets the health sensitivity; the value by which to decrement the
297 * health value of a local or peer NI. If 0 then health is turned off
299 * sen - sensitivity value to configure
300 * seq_no - sequence number of the request
301 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
304 int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc);
307 * lustre_lnet_show_hsensitivity
308 * show the health sensitivity in the system
310 * seq_no - sequence number of the request
311 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
312 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
315 int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc,
316 struct cYAML **err_rc);
319 * lustre_lnet_show_rtr_sensitivity
320 * show the router sensitivity percentage in the system
322 * seq_no - sequence number of the request
323 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
324 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
327 int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc,
328 struct cYAML **err_rc);
331 * lustre_lnet_config_transaction_to
332 * sets the timeout after which a message expires or a timeout event is
333 * propagated for an expired response.
335 * timeout - timeout value to configure
336 * seq_no - sequence number of the request
337 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
340 int lustre_lnet_config_transaction_to(int timeout, int seq_no, struct cYAML **err_rc);
343 * lustre_lnet_show_transaction_to
344 * show the transaction timeout in the system
346 * seq_no - sequence number of the request
347 * show_rc - [OUT] struct cYAML tree containing transaction timeout info
348 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
351 int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc,
352 struct cYAML **err_rc);
355 * lustre_lnet_config_retry_count
356 * sets the maximum number of retries to resend a message
358 * count - maximum value to configure
359 * seq_no - sequence number of the request
360 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
363 int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc);
366 * lustre_lnet_show_retry_count
367 * show current maximum number of retries in the system
369 * seq_no - sequence number of the request
370 * show_rc - [OUT] struct cYAML tree containing retry count info
371 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
374 int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc,
375 struct cYAML **err_rc);
377 int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc,
378 struct cYAML **err_rc);
380 int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
381 struct cYAML **err_rc);
384 * lustre_lnet_config_max_intf
385 * Sets the maximum number of interfaces per node. this tunable is
386 * primarily useful for sanity checks prior to allocating memory.
388 * max - maximum value to configure
389 * seq_no - sequence number of the request
390 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
393 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
396 * lustre_lnet_show_max_intf
397 * show current maximum interface setting
399 * seq_no - sequence number of the request
400 * show_rc - [OUT] struct cYAML tree containing NUMA range info
401 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
404 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
405 struct cYAML **err_rc);
408 * lustre_lnet_config_discovery
409 * Enable or disable peer discovery. Peer discovery is enabled by default.
411 * enable - non-0 enables, 0 disables
412 * seq_no - sequence number of the request
413 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
416 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
419 * lustre_lnet_show_discovery
420 * show current peer discovery setting
422 * seq_no - sequence number of the request
423 * show_rc - [OUT] struct cYAML tree containing NUMA range info
424 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
427 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
428 struct cYAML **err_rc);
431 * lustre_lnet_config_drop_asym_route
432 * Drop or accept asymmetrical route messages. Accept by default.
434 * drop - non-0 drops, 0 accepts
435 * seq_no - sequence number of the request
436 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
439 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
440 struct cYAML **err_rc);
443 * lustre_lnet_show_drop_asym_route
444 * show current drop asym route setting
446 * seq_no - sequence number of the request
447 * show_rc - [OUT] struct cYAML tree containing NUMA range info
448 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
451 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
452 struct cYAML **err_rc);
455 * lustre_lnet_config_buffers
456 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
457 * default that particular buffer to default size. A value of -1 means
458 * leave the value of the buffer un changed.
460 * tiny - tiny buffers
461 * small - small buffers
462 * large - large buffers.
463 * seq_no - sequence number of the request
464 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
466 int lustre_lnet_config_buffers(int tiny, int small, int large,
467 int seq_no, struct cYAML **err_rc);
470 * lustre_lnet_show_routing
471 * Send down an IOCTL to dump buffers and routing status
472 * This function is used to dump buffers for all CPU partitions.
474 * seq_no - sequence number of the request
475 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
476 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
477 * backup - true to output only what's necessary for reconfiguring
480 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
481 struct cYAML **err_rc, bool backup);
484 * lustre_lnet_show_stats
485 * Shows internal LNET statistics. This is useful to display the
486 * current LNET activity, such as number of messages route, etc
488 * seq_no - sequence number of the command
489 * show_rc - YAML structure of the resultant show
490 * err_rc - YAML strucutre of the resultant return code.
492 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
493 struct cYAML **err_rc);
496 * lustre_lnet_config_peer_nid
497 * Add a peer nid to a peer with primary nid pnid. If no pnid is given
498 * then the first nid in the nid list becomes the primary nid for
499 * a newly created peer.
500 * Otherwise if pnid is provided and it's unique then a new peer is
501 * created with pnid as the primary NID and the nids in the nid list as
503 * If any of the peers nids provided in with exception to the pnid is
504 * not unique the operation fails. Some peer nids might have already
505 * been added. It's the role of the caller of this API to remove the
506 * added NIDs if they wish.
508 * pnid - Primary NID of the peer
509 * nid - list of nids to add
510 * num_nids - number of nids in the nid array
511 * mr - true if this peer is MR capable.
512 * ip2nets - true if a list of nid expressions are given to configure
514 * seq_no - sequence number of the command
515 * err_rc - YAML strucutre of the resultant return code.
517 int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
518 bool mr, bool ip2nets, int seq_no,
519 struct cYAML **err_rc);
522 * lustre_lnet_del_peer_nid
523 * Delete the nids given in the nid list from the peer with primary NID
524 * pnid. If pnid is NULL or it doesn't identify a peer the operation
525 * fails and no change happens to the system.
526 * The operation is aborted on the first NID that fails to be deleted.
528 * pnid - Primary NID of the peer
529 * nid - list of nids to add
530 * num_nids - number of nids in the nid array
531 * ip2nets - used to specify a range of nids
532 * seq_no - sequence number of the command
533 * err_rc - YAML strucutre of the resultant return code.
535 int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids,
536 bool ip2nets, int seq_no, struct cYAML **err_rc);
539 * lustre_lnet_show_peer
540 * Show the peer identified by nid, knid. If knid is NULL all
541 * peers in the system are shown.
543 * knid - A NID of the peer
544 * detail - display detailed information
545 * seq_no - sequence number of the command
546 * show_rc - YAML structure of the resultant show
547 * err_rc - YAML strucutre of the resultant return code.
548 * backup - true to output only what's necessary for reconfiguring
552 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
553 struct cYAML **show_rc, struct cYAML **err_rc,
557 * lustre_lnet_list_peer
558 * List the known peers.
560 * seq_no - sequence number of the command
561 * show_rc - YAML structure of the resultant show
562 * err_rc - YAML strucutre of the resultant return code.
565 int lustre_lnet_list_peer(int seq_no,
566 struct cYAML **show_rc, struct cYAML **err_rc);
568 /* lustre_lnet_ping_nid
569 * Ping the nid list, pnids.
571 * pnids - NID list to ping.
572 * timeout - timeout(seconds) for ping.
573 * seq_no - sequence number of the command.
574 * show_rc - YAML structure of the resultant show.
575 * err_rc - YAML strucutre of the resultant return code.
578 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
579 struct cYAML **show_rc, struct cYAML **err_rc);
581 /* lustre_lnet_discover_nid
582 * Discover the nid list, pnids.
584 * pnids - NID list to discover.
585 * force - force discovery.
586 * seq_no - sequence number of the command.
587 * show_rc - YAML structure of the resultant show.
588 * err_rc - YAML strucutre of the resultant return code.
591 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
592 struct cYAML **show_rc, struct cYAML **err_rc);
596 * Parses the provided YAML file and then calls the specific APIs
597 * to configure the entities identified in the file
600 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
602 int lustre_yaml_config(char *f, struct cYAML **err_rc);
606 * Parses the provided YAML file and then calls the specific APIs
607 * to delete the entities identified in the file
610 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
612 int lustre_yaml_del(char *f, struct cYAML **err_rc);
616 * Parses the provided YAML file and then calls the specific APIs
617 * to show the entities identified in the file
620 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
621 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
623 int lustre_yaml_show(char *f, struct cYAML **show_rc,
624 struct cYAML **err_rc);
628 * Parses the provided YAML file and then calls the specific APIs
629 * to execute the entities identified in the file
632 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
633 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
635 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
636 struct cYAML **err_rc);
639 * lustre_lnet_init_nw_descr
640 * initialize the network descriptor structure for use
642 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
645 * lustre_lnet_parse_interfaces
646 * prase an interface string and populate descriptor structures
647 * intf_str - interface string of the format
648 * <intf>[<expr>], <intf>[<expr>],..
649 * nw_descr - network descriptor to populate
650 * init - True to initialize nw_descr
652 int lustre_lnet_parse_interfaces(char *intf_str,
653 struct lnet_dlc_network_descr *nw_descr);
656 * lustre_lnet_parse_nids
657 * Parse a set of nids into a locally allocated array and return the
658 * pointer of the array to the caller. The caller is responsible for
659 * freeing the array. If an initial array is provided then copy over
660 * the contents of that array into the new array and append to it the
662 * The nids can be of the form "nid [,nid, nid, nid]"
663 * nids: nids string to be parsed
664 * array: initial array of content
665 * size: num of elements in the array
666 * out_array: [OUT] new allocated array.
667 * Returns size of array
668 * sets the out_array to NULL on failure.
670 int lustre_lnet_parse_nids(char *nids, char **array, int size,
673 #endif /* LIB_LNET_CONFIG_API_H */