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
47 LNETCTL_CONFIG_CMD = 1,
48 LNETCTL_UNCONFIG_CMD = 2,
53 LNETCTL_MANAGE_CMD = 7,
58 * Max number of nids we'll configure for a single peer via a single DLC
61 #define LNET_MAX_NIDS_PER_PEER 128
63 struct lnet_dlc_network_descr {
64 struct list_head network_on_rule;
66 struct list_head nw_intflist;
69 struct lnet_dlc_intf_descr {
70 struct list_head intf_on_network;
71 char intf_name[IFNAMSIZ];
72 struct cfs_expr_list *cpt_expr;
75 /* forward declaration of the cYAML structure. */
79 * lustre_lnet_config_lib_init()
80 * Initialize the Library to enable communication with the LNET kernel
81 * module. Returns the device ID or -EINVAL if there is an error
83 int lustre_lnet_config_lib_init();
86 * lustre_lnet_config_lib_uninit
87 * Uninitialize the DLC Library
89 void lustre_lnet_config_lib_uninit();
92 * lustre_lnet_config_ni_system
93 * Initialize/Uninitialize the lnet NI system.
95 * up - whehter to init or uninit the system
96 * load_ni_from_mod - load NI from mod params.
97 * seq_no - sequence number of the request
98 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
101 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
102 int seq_no, struct cYAML **err_rc);
105 * lustre_lnet_config_route
106 * Send down an IOCTL to the kernel to configure the route
110 * hops - number of hops passed down by the user
111 * prio - priority of the route
112 * sen - health sensitivity value for the gateway
113 * seq_no - sequence number of the request
114 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
116 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
117 int sen, int seq_no, struct cYAML **err_rc);
120 * lustre_lnet_del_route
121 * Send down an IOCTL to the kernel to delete a route
125 * seq_no - sequence number of the request
126 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
128 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
129 struct cYAML **err_rc);
132 * lustre_lnet_show_route
133 * Send down an IOCTL to the kernel to show routes
134 * This function will get one route at a time and filter according to
135 * provided parameters. If no routes are available then it will dump all
136 * routes that are in the system.
138 * nw - network. Optional. Used to filter output
139 * gw - gateway. Optional. Used to filter ouptut
140 * hops - number of hops passed down by the user
141 * Optional. Used to filter output.
142 * prio - priority of the route. Optional. Used to filter output.
143 * detail - flag to indicate whether detail output is required
144 * seq_no - sequence number of the request
145 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
146 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
147 * backup - true to output only what's necessary for reconfiguring
150 int lustre_lnet_show_route(char *nw, char *gw,
151 int hops, int prio, int detail,
152 int seq_no, struct cYAML **show_rc,
153 struct cYAML **err_rc, bool backup);
156 * lustre_lnet_config_ni
157 * Send down an IOCTL to configure a network interface. It implicitly
158 * creates a network if one doesn't exist..
160 * nw_descr - network and interface descriptor
161 * global_cpts - globally defined CPTs
162 * ip2net - this parameter allows configuring multiple networks.
163 * it takes precedence over the net and intf parameters
164 * tunables - LND tunables
165 * seq_no - sequence number of the request
166 * lnd_tunables - lnet specific tunable parameters
167 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
169 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
170 struct cfs_expr_list *global_cpts,
172 struct lnet_ioctl_config_lnd_tunables *tunables,
173 int seq_no, struct cYAML **err_rc);
177 * Send down an IOCTL to delete a network interface. It implicitly
178 * deletes a network if it becomes empty of nis
180 * nw - network and interface list
181 * seq_no - sequence number of the request
182 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
184 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
185 int seq_no, struct cYAML **err_rc);
188 * lustre_lnet_show_net
189 * Send down an IOCTL to show networks.
190 * This function will use the nw paramter to filter the output. If it's
191 * not provided then all networks are listed.
193 * nw - network to show. Optional. Used to filter output.
194 * detail - flag to indicate if we require detail output.
195 * seq_no - sequence number of the request
196 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
197 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
198 * backup - true to output only what's necessary for reconfiguring
201 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
202 struct cYAML **show_rc, struct cYAML **err_rc,
206 * lustre_lnet_enable_routing
207 * Send down an IOCTL to enable or diable routing
209 * enable - 1 to enable routing, 0 to disable routing
210 * seq_no - sequence number of the request
211 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
213 int lustre_lnet_enable_routing(int enable, int seq_no,
214 struct cYAML **err_rc);
217 * lustre_lnet_config_numa_range
218 * Set the NUMA range which impacts the NIs to be selected
219 * during sending. If the NUMA range is large the NUMA
220 * distance between the message memory and the NI becomes
221 * less significant. The NUMA range is a relative number
222 * with no other meaning besides allowing a wider breadth
223 * for picking an NI to send from.
225 * range - numa range value.
226 * seq_no - sequence number of the request
227 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
230 int lustre_lnet_config_numa_range(int range, int seq_no,
231 struct cYAML **err_rc);
234 * lustre_lnet_show_num_range
235 * Get the currently set NUMA range
237 * seq_no - sequence number of the request
238 * show_rc - [OUT] struct cYAML tree containing NUMA range info
239 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
242 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
243 struct cYAML **err_rc);
246 * lustre_lnet_config_ni_healthv
247 * set the health value of the NI. -1 resets the value to maximum.
249 * value: health value to set.
250 * all: true to set all local NIs to that value.
251 * ni_nid: NI NID to set its health value. all parameter always takes
253 * seq_no - sequence number of the request
254 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
257 int lustre_lnet_config_ni_healthv(int value, bool all, char *ni_nid,
258 int seq_no, struct cYAML **err_rc);
261 * lustre_lnet_config_peer_ni_healthv
262 * set the health value of the peer NI. -1 resets the value to maximum.
264 * value: health value to set.
265 * all: true to set all local NIs to that value.
266 * pni_nid: Peer NI NID to set its health value. all parameter always takes
268 * seq_no - sequence number of the request
269 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
272 int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid,
273 int seq_no, struct cYAML **err_rc);
276 * lustre_lnet_config_recov_intrv
277 * set the recovery interval in seconds. That's the interval to ping an
278 * unhealthy interface.
280 * intrv - recovery interval value to configure
281 * seq_no - sequence number of the request
282 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
285 int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc);
288 * lustre_lnet_show_recov_intrv
289 * show the recovery interval set in the system
291 * seq_no - sequence number of the request
292 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
293 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
296 int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc,
297 struct cYAML **err_rc);
300 * lustre_lnet_config_rtr_sensitivity
301 * sets the router sensitivity percentage. If the percentage health
302 * of a router interface drops below that it's considered failed
304 * sen - sensitivity value to configure
305 * seq_no - sequence number of the request
306 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
309 int lustre_lnet_config_rtr_sensitivity(int sen, int seq_no, struct cYAML **err_rc);
312 * lustre_lnet_config_hsensitivity
313 * sets the health sensitivity; the value by which to decrement the
314 * health value of a local or peer NI. If 0 then health is turned off
316 * sen - sensitivity value to configure
317 * seq_no - sequence number of the request
318 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
321 int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc);
324 * lustre_lnet_show_hsensitivity
325 * show the health sensitivity in the system
327 * seq_no - sequence number of the request
328 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
329 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
332 int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc,
333 struct cYAML **err_rc);
336 * lustre_lnet_show_rtr_sensitivity
337 * show the router sensitivity percentage in the system
339 * seq_no - sequence number of the request
340 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
341 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
344 int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc,
345 struct cYAML **err_rc);
348 * lustre_lnet_config_transaction_to
349 * sets the timeout after which a message expires or a timeout event is
350 * propagated for an expired response.
352 * timeout - timeout value to configure
353 * seq_no - sequence number of the request
354 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
357 int lustre_lnet_config_transaction_to(int timeout, int seq_no, struct cYAML **err_rc);
360 * lustre_lnet_show_transaction_to
361 * show the transaction timeout in the system
363 * seq_no - sequence number of the request
364 * show_rc - [OUT] struct cYAML tree containing transaction timeout info
365 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
368 int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc,
369 struct cYAML **err_rc);
372 * lustre_lnet_config_retry_count
373 * sets the maximum number of retries to resend a message
375 * count - maximum value to configure
376 * seq_no - sequence number of the request
377 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
380 int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc);
383 * lustre_lnet_show_retry_count
384 * show current maximum number of retries in the system
386 * seq_no - sequence number of the request
387 * show_rc - [OUT] struct cYAML tree containing retry count info
388 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
391 int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc,
392 struct cYAML **err_rc);
394 int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc,
395 struct cYAML **err_rc);
397 int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc,
398 struct cYAML **err_rc);
400 int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
401 struct cYAML **err_rc);
402 int lustre_lnet_config_response_tracking(int count, int seq_no,
403 struct cYAML **err_rc);
404 int lustre_lnet_show_response_tracking(int seq_no, struct cYAML **show_rc,
405 struct cYAML **err_rc);
408 * lustre_lnet_config_max_intf
409 * Sets the maximum number of interfaces per node. this tunable is
410 * primarily useful for sanity checks prior to allocating memory.
412 * max - maximum value to configure
413 * seq_no - sequence number of the request
414 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
417 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
420 * lustre_lnet_show_max_intf
421 * show current maximum interface setting
423 * seq_no - sequence number of the request
424 * show_rc - [OUT] struct cYAML tree containing NUMA range info
425 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
428 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
429 struct cYAML **err_rc);
432 * lustre_lnet_calc_service_id
433 * Calculate the lustre service id to be used for qos
435 int lustre_lnet_calc_service_id(__u64 *service_id);
438 * lustre_lnet_config_discovery
439 * Enable or disable peer discovery. Peer discovery is enabled by default.
441 * enable - non-0 enables, 0 disables
442 * seq_no - sequence number of the request
443 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
446 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
449 * lustre_lnet_show_discovery
450 * show current peer discovery setting
452 * seq_no - sequence number of the request
453 * show_rc - [OUT] struct cYAML tree containing NUMA range info
454 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
457 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
458 struct cYAML **err_rc);
461 * lustre_lnet_config_drop_asym_route
462 * Drop or accept asymmetrical route messages. Accept by default.
464 * drop - non-0 drops, 0 accepts
465 * seq_no - sequence number of the request
466 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
469 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
470 struct cYAML **err_rc);
473 * lustre_lnet_show_drop_asym_route
474 * show current drop asym route setting
476 * seq_no - sequence number of the request
477 * show_rc - [OUT] struct cYAML tree containing NUMA range info
478 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
481 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
482 struct cYAML **err_rc);
485 * lustre_lnet_config_buffers
486 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
487 * default that particular buffer to default size. A value of -1 means
488 * leave the value of the buffer un changed.
490 * tiny - tiny buffers
491 * small - small buffers
492 * large - large buffers.
493 * seq_no - sequence number of the request
494 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
496 int lustre_lnet_config_buffers(int tiny, int small, int large,
497 int seq_no, struct cYAML **err_rc);
500 * lustre_lnet_show_routing
501 * Send down an IOCTL to dump buffers and routing status
502 * This function is used to dump buffers for all CPU partitions.
504 * seq_no - sequence number of the request
505 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
506 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
507 * backup - true to output only what's necessary for reconfiguring
510 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
511 struct cYAML **err_rc, bool backup);
514 * lustre_lnet_show_stats
515 * Shows internal LNET statistics. This is useful to display the
516 * current LNET activity, such as number of messages route, etc
518 * seq_no - sequence number of the command
519 * show_rc - YAML structure of the resultant show
520 * err_rc - YAML strucutre of the resultant return code.
522 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
523 struct cYAML **err_rc);
526 * lustre_lnet_modify_peer
527 * Handle a peer config or delete operation.
530 * Add a peer NID to a peer with primary NID pnid.
531 * If the provided primary NID is unique, then a new peer is
532 * created with this primary NID, and the NIDs in the NID list are added as
533 * secondary NIDs to this new peer.
534 * If any of the NIDs in the NID list are not unique then the operation
535 * fails. Some peer NIDs might have already been added. It's the responsibility
536 * of the caller of this API to remove the added NIDs if so desired.
539 * Delete the NIDs given in the NID list from the peer with the primary NID
540 * pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails,
541 * and no change happens to the system.
542 * The operation is aborted on the first NID that fails to be deleted.
544 * prim_nid - The desired primary NID of a new peer, or the primary NID of
546 * nids - a comma separated string of nids
547 * is_mr - Specifies whether this peer is MR capable.
548 * cmd - CONFIG or DELETE
549 * seq_no - sequence number of the command
550 * err_rc - YAML structure of the resultant return code
552 int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr,
553 int cmd, int seq_no, struct cYAML **err_rc);
556 * lustre_lnet_show_peer
557 * Show the peer identified by nid, knid. If knid is NULL all
558 * peers in the system are shown.
560 * knid - A NID of the peer
561 * detail - display detailed information
562 * seq_no - sequence number of the command
563 * show_rc - YAML structure of the resultant show
564 * err_rc - YAML strucutre of the resultant return code.
565 * backup - true to output only what's necessary for reconfiguring
569 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
570 struct cYAML **show_rc, struct cYAML **err_rc,
574 * lustre_lnet_list_peer
575 * List the known peers.
577 * seq_no - sequence number of the command
578 * show_rc - YAML structure of the resultant show
579 * err_rc - YAML strucutre of the resultant return code.
582 int lustre_lnet_list_peer(int seq_no,
583 struct cYAML **show_rc, struct cYAML **err_rc);
585 /* lustre_lnet_ping_nid
586 * Ping the nid list, pnids.
588 * pnids - NID list to ping.
589 * timeout - timeout(seconds) for ping.
590 * seq_no - sequence number of the command.
591 * show_rc - YAML structure of the resultant show.
592 * err_rc - YAML strucutre of the resultant return code.
595 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
596 struct cYAML **show_rc, struct cYAML **err_rc);
598 /* lustre_lnet_discover_nid
599 * Discover the nid list, pnids.
601 * pnids - NID list to discover.
602 * force - force discovery.
603 * seq_no - sequence number of the command.
604 * show_rc - YAML structure of the resultant show.
605 * err_rc - YAML strucutre of the resultant return code.
608 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
609 struct cYAML **show_rc, struct cYAML **err_rc);
613 * Parses the provided YAML file and then calls the specific APIs
614 * to configure the entities identified in the file
617 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
619 int lustre_yaml_config(char *f, struct cYAML **err_rc);
623 * Parses the provided YAML file and then calls the specific APIs
624 * to delete the entities identified in the file
627 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
629 int lustre_yaml_del(char *f, struct cYAML **err_rc);
633 * Parses the provided YAML file and then calls the specific APIs
634 * to show the entities identified in the file
637 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
638 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
640 int lustre_yaml_show(char *f, struct cYAML **show_rc,
641 struct cYAML **err_rc);
645 * Parses the provided YAML file and then calls the specific APIs
646 * to execute the entities identified in the file
649 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
650 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
652 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
653 struct cYAML **err_rc);
656 * lustre_lnet_init_nw_descr
657 * initialize the network descriptor structure for use
659 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
662 * lustre_lnet_parse_interfaces
663 * prase an interface string and populate descriptor structures
664 * intf_str - interface string of the format
665 * <intf>[<expr>], <intf>[<expr>],..
666 * nw_descr - network descriptor to populate
667 * init - True to initialize nw_descr
669 int lustre_lnet_parse_interfaces(char *intf_str,
670 struct lnet_dlc_network_descr *nw_descr);
673 * lustre_lnet_parse_nidstr
674 * This is a small wrapper around cfs_parse_nidlist.
675 * nidstr - A string parseable by cfs_parse_nidlist
676 * lnet_nidlist - An array of lnet_nid_t to hold the nids specified
678 * max_nids - Size of the lnet_nidlist array, and the maximum number of
679 * nids that can be expressed by the nidstring. If the
680 * nidstring expands to a larger number of nids than max_nids
681 * then an error is returned.
682 * err_str - char pointer where we store an informative error
683 * message when an error is encountered
685 * The number (> 0) of lnet_nid_t stored in the supplied array, or
686 * LUSTRE_CFG_RC_BAD_PARAM if:
688 * - nidstr contains an asterisk. This character is not allowed
689 * because it would cause the size of the expanded nidlist to exceed
690 * the maximum number of nids that is supported by expected callers
692 * - cfs_parse_nidlist fails to parse the nidstring
693 * - The nidlist populated by cfs_parse_nidlist is empty
694 * - The nidstring expands to a larger number of nids than max_nids
695 * - The nidstring expands to zero nids
696 * LUSTRE_CFG_RC_OUT_OF_MEM if:
697 * - cfs_expand_nidlist can return ENOMEM. We return out of mem in
700 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
701 int max_nids, char *err_str);
703 #endif /* LIB_LNET_CONFIG_API_H */