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);
406 int lustre_lnet_config_recovery_limit(int val, int seq_no,
407 struct cYAML **err_rc);
408 int lustre_lnet_show_recovery_limit(int seq_no, struct cYAML **show_rc,
409 struct cYAML **err_rc);
412 * lustre_lnet_config_max_intf
413 * Sets the maximum number of interfaces per node. this tunable is
414 * primarily useful for sanity checks prior to allocating memory.
416 * max - maximum value to configure
417 * seq_no - sequence number of the request
418 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
421 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
424 * lustre_lnet_show_max_intf
425 * show current maximum interface setting
427 * seq_no - sequence number of the request
428 * show_rc - [OUT] struct cYAML tree containing NUMA range info
429 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
432 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
433 struct cYAML **err_rc);
436 * lustre_lnet_calc_service_id
437 * Calculate the lustre service id to be used for qos
439 int lustre_lnet_calc_service_id(__u64 *service_id);
442 * lustre_lnet_config_discovery
443 * Enable or disable peer discovery. Peer discovery is enabled by default.
445 * enable - non-0 enables, 0 disables
446 * seq_no - sequence number of the request
447 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
450 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
453 * lustre_lnet_show_discovery
454 * show current peer discovery setting
456 * seq_no - sequence number of the request
457 * show_rc - [OUT] struct cYAML tree containing NUMA range info
458 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
461 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
462 struct cYAML **err_rc);
465 * lustre_lnet_config_drop_asym_route
466 * Drop or accept asymmetrical route messages. Accept by default.
468 * drop - non-0 drops, 0 accepts
469 * seq_no - sequence number of the request
470 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
473 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
474 struct cYAML **err_rc);
477 * lustre_lnet_show_drop_asym_route
478 * show current drop asym route setting
480 * seq_no - sequence number of the request
481 * show_rc - [OUT] struct cYAML tree containing NUMA range info
482 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
485 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
486 struct cYAML **err_rc);
489 * lustre_lnet_config_buffers
490 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
491 * default that particular buffer to default size. A value of -1 means
492 * leave the value of the buffer un changed.
494 * tiny - tiny buffers
495 * small - small buffers
496 * large - large buffers.
497 * seq_no - sequence number of the request
498 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
500 int lustre_lnet_config_buffers(int tiny, int small, int large,
501 int seq_no, struct cYAML **err_rc);
504 * lustre_lnet_show_routing
505 * Send down an IOCTL to dump buffers and routing status
506 * This function is used to dump buffers for all CPU partitions.
508 * seq_no - sequence number of the request
509 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
510 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
511 * backup - true to output only what's necessary for reconfiguring
514 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
515 struct cYAML **err_rc, bool backup);
518 * lustre_lnet_show_stats
519 * Shows internal LNET statistics. This is useful to display the
520 * current LNET activity, such as number of messages route, etc
522 * seq_no - sequence number of the command
523 * show_rc - YAML structure of the resultant show
524 * err_rc - YAML strucutre of the resultant return code.
526 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
527 struct cYAML **err_rc);
530 * lustre_lnet_modify_peer
531 * Handle a peer config or delete operation.
534 * Add a peer NID to a peer with primary NID pnid.
535 * If the provided primary NID is unique, then a new peer is
536 * created with this primary NID, and the NIDs in the NID list are added as
537 * secondary NIDs to this new peer.
538 * If any of the NIDs in the NID list are not unique then the operation
539 * fails. Some peer NIDs might have already been added. It's the responsibility
540 * of the caller of this API to remove the added NIDs if so desired.
543 * Delete the NIDs given in the NID list from the peer with the primary NID
544 * pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails,
545 * and no change happens to the system.
546 * The operation is aborted on the first NID that fails to be deleted.
548 * prim_nid - The desired primary NID of a new peer, or the primary NID of
550 * nids - a comma separated string of nids
551 * is_mr - Specifies whether this peer is MR capable.
552 * cmd - CONFIG or DELETE
553 * seq_no - sequence number of the command
554 * err_rc - YAML structure of the resultant return code
556 int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr,
557 int cmd, int seq_no, struct cYAML **err_rc);
560 * lustre_lnet_show_peer
561 * Show the peer identified by nid, knid. If knid is NULL all
562 * peers in the system are shown.
564 * knid - A NID of the peer
565 * detail - display detailed information
566 * seq_no - sequence number of the command
567 * show_rc - YAML structure of the resultant show
568 * err_rc - YAML strucutre of the resultant return code.
569 * backup - true to output only what's necessary for reconfiguring
573 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
574 struct cYAML **show_rc, struct cYAML **err_rc,
578 * lustre_lnet_list_peer
579 * List the known peers.
581 * seq_no - sequence number of the command
582 * show_rc - YAML structure of the resultant show
583 * err_rc - YAML strucutre of the resultant return code.
586 int lustre_lnet_list_peer(int seq_no,
587 struct cYAML **show_rc, struct cYAML **err_rc);
589 /* lustre_lnet_ping_nid
590 * Ping the nid list, pnids.
592 * pnids - NID list to ping.
593 * timeout - timeout(seconds) for ping.
594 * seq_no - sequence number of the command.
595 * show_rc - YAML structure of the resultant show.
596 * err_rc - YAML strucutre of the resultant return code.
599 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
600 struct cYAML **show_rc, struct cYAML **err_rc);
602 /* lustre_lnet_discover_nid
603 * Discover the nid list, pnids.
605 * pnids - NID list to discover.
606 * force - force discovery.
607 * seq_no - sequence number of the command.
608 * show_rc - YAML structure of the resultant show.
609 * err_rc - YAML strucutre of the resultant return code.
612 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
613 struct cYAML **show_rc, struct cYAML **err_rc);
617 * Parses the provided YAML file and then calls the specific APIs
618 * to configure the entities identified in the file
621 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
623 int lustre_yaml_config(char *f, struct cYAML **err_rc);
627 * Parses the provided YAML file and then calls the specific APIs
628 * to delete the entities identified in the file
631 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
633 int lustre_yaml_del(char *f, struct cYAML **err_rc);
637 * Parses the provided YAML file and then calls the specific APIs
638 * to show the entities identified in the file
641 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
642 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
644 int lustre_yaml_show(char *f, struct cYAML **show_rc,
645 struct cYAML **err_rc);
649 * Parses the provided YAML file and then calls the specific APIs
650 * to execute the entities identified in the file
653 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
654 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
656 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
657 struct cYAML **err_rc);
660 * lustre_lnet_init_nw_descr
661 * initialize the network descriptor structure for use
663 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
666 * lustre_lnet_parse_interfaces
667 * prase an interface string and populate descriptor structures
668 * intf_str - interface string of the format
669 * <intf>[<expr>], <intf>[<expr>],..
670 * nw_descr - network descriptor to populate
671 * init - True to initialize nw_descr
673 int lustre_lnet_parse_interfaces(char *intf_str,
674 struct lnet_dlc_network_descr *nw_descr);
677 * lustre_lnet_parse_nidstr
678 * This is a small wrapper around cfs_parse_nidlist.
679 * nidstr - A string parseable by cfs_parse_nidlist
680 * lnet_nidlist - An array of lnet_nid_t to hold the nids specified
682 * max_nids - Size of the lnet_nidlist array, and the maximum number of
683 * nids that can be expressed by the nidstring. If the
684 * nidstring expands to a larger number of nids than max_nids
685 * then an error is returned.
686 * err_str - char pointer where we store an informative error
687 * message when an error is encountered
689 * The number (> 0) of lnet_nid_t stored in the supplied array, or
690 * LUSTRE_CFG_RC_BAD_PARAM if:
692 * - nidstr contains an asterisk. This character is not allowed
693 * because it would cause the size of the expanded nidlist to exceed
694 * the maximum number of nids that is supported by expected callers
696 * - cfs_parse_nidlist fails to parse the nidstring
697 * - The nidlist populated by cfs_parse_nidlist is empty
698 * - The nidstring expands to a larger number of nids than max_nids
699 * - The nidstring expands to zero nids
700 * LUSTRE_CFG_RC_OUT_OF_MEM if:
701 * - cfs_expand_nidlist can return ENOMEM. We return out of mem in
704 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
705 int max_nids, char *err_str);
707 #endif /* LIB_LNET_CONFIG_API_H */