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
33 #include <sys/socket.h>
35 #include <netlink/netlink.h>
36 #include <netlink/genl/genl.h>
37 #include <netlink/genl/ctrl.h>
39 #include <libcfs/util/ioctl.h>
40 #include <libcfs/util/string.h>
41 #include <linux/lnet/lnet-dlc.h>
42 #include <linux/lnet/nidstr.h>
44 #define LUSTRE_CFG_RC_NO_ERR 0
45 #define LUSTRE_CFG_RC_BAD_PARAM -1
46 #define LUSTRE_CFG_RC_MISSING_PARAM -2
47 #define LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM -3
48 #define LUSTRE_CFG_RC_OUT_OF_MEM -4
49 #define LUSTRE_CFG_RC_GENERIC_ERR -5
50 #define LUSTRE_CFG_RC_NO_MATCH -6
51 #define LUSTRE_CFG_RC_MATCH -7
52 #define LUSTRE_CFG_RC_SKIP -8
53 #define LUSTRE_CFG_RC_LAST_ELEM -9
54 #define LUSTRE_CFG_RC_MARSHAL_FAIL -10
56 #define CONFIG_CMD "configure"
57 #define UNCONFIG_CMD "unconfigure"
60 #define SHOW_CMD "show"
62 #define MANAGE_CMD "manage"
64 #define MAX_NUM_IPS 128
65 #define INT_STRING_LEN 23
67 #define modparam_path "/sys/module/lnet/parameters/"
68 #define o2ib_modparam_path "/sys/module/ko2iblnd/parameters/"
69 #define gni_nid_path "/proc/cray_xt/"
72 LNETCTL_CONFIG_CMD = 1,
73 LNETCTL_UNCONFIG_CMD = 2,
78 LNETCTL_MANAGE_CMD = 7,
83 * Max number of nids we'll configure for a single peer via a single DLC
86 #define LNET_MAX_NIDS_PER_PEER 128
88 struct lnet_dlc_network_descr {
89 struct list_head network_on_rule;
91 struct list_head nw_intflist;
94 struct lnet_dlc_intf_descr {
95 struct list_head intf_on_network;
96 char intf_name[IFNAMSIZ];
97 struct cfs_expr_list *cpt_expr;
100 /* This UDSP structures need to match the kernel space structures
101 * in order for the marshall and unmarshall functions to be the same.
104 /* Net is described as a
108 struct lnet_ud_net_descr {
110 struct list_head udn_net_num_range;
113 /* each NID range is defined as
115 * 2. address range descriptor
117 struct lnet_ud_nid_descr {
118 struct lnet_ud_net_descr ud_net_id;
119 struct list_head ud_addr_range;
122 /* a UDSP rule can have up to three user defined NID descriptors
123 * - src: defines the local NID range for the rule
124 * - dst: defines the peer NID range for the rule
125 * - rte: defines the router NID range for the rule
127 * An action union defines the action to take when the rule
131 struct list_head udsp_on_list;
133 struct lnet_ud_nid_descr udsp_src;
134 struct lnet_ud_nid_descr udsp_dst;
135 struct lnet_ud_nid_descr udsp_rte;
136 enum lnet_udsp_action_type udsp_action_type;
142 /* This union is passed from lnetctl to fill the action union in udsp
144 * TODO: The idea here is if we add extra actions, ex: drop, it can be
147 union lnet_udsp_action {
151 /* forward declaration of the cYAML structure. */
155 * lustre_lnet_config_lib_init()
156 * Initialize the Library to enable communication with the LNET kernel
157 * module. Returns the device ID or -EINVAL if there is an error
159 int lustre_lnet_config_lib_init();
162 * lustre_lnet_config_lib_uninit
163 * Uninitialize the DLC Library
165 void lustre_lnet_config_lib_uninit();
168 * lustre_lnet_config_ni_system
169 * Initialize/Uninitialize the lnet NI system.
171 * up - whehter to init or uninit the system
172 * load_ni_from_mod - load NI from mod params.
173 * seq_no - sequence number of the request
174 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
177 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
178 int seq_no, struct cYAML **err_rc);
181 * lustre_lnet_config_route
182 * Send down an IOCTL to the kernel to configure the route
186 * hops - number of hops passed down by the user
187 * prio - priority of the route
188 * sen - health sensitivity value for the gateway
189 * seq_no - sequence number of the request
190 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
192 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
193 int sen, int seq_no, struct cYAML **err_rc);
196 * lustre_lnet_del_route
197 * Send down an IOCTL to the kernel to delete a route
201 * seq_no - sequence number of the request
202 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
204 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
205 struct cYAML **err_rc);
208 * lustre_lnet_show_route
209 * Send down an IOCTL to the kernel to show routes
210 * This function will get one route at a time and filter according to
211 * provided parameters. If no routes are available then it will dump all
212 * routes that are in the system.
214 * nw - network. Optional. Used to filter output
215 * gw - gateway. Optional. Used to filter ouptut
216 * hops - number of hops passed down by the user
217 * Optional. Used to filter output.
218 * prio - priority of the route. Optional. Used to filter output.
219 * detail - flag to indicate whether detail output is required
220 * seq_no - sequence number of the request
221 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
222 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
223 * backup - true to output only what's necessary for reconfiguring
226 int lustre_lnet_show_route(char *nw, char *gw,
227 int hops, int prio, int detail,
228 int seq_no, struct cYAML **show_rc,
229 struct cYAML **err_rc, bool backup);
232 * lustre_lnet_config_ni
233 * Send down an IOCTL to configure a network interface. It implicitly
234 * creates a network if one doesn't exist..
236 * nw_descr - network and interface descriptor
237 * global_cpts - globally defined CPTs
238 * ip2net - this parameter allows configuring multiple networks.
239 * it takes precedence over the net and intf parameters
240 * tunables - LND tunables
241 * seq_no - sequence number of the request
242 * lnd_tunables - lnet specific tunable parameters
243 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
245 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
246 struct cfs_expr_list *global_cpts,
248 struct lnet_ioctl_config_lnd_tunables *tunables,
249 int seq_no, struct cYAML **err_rc);
253 * Send down an IOCTL to delete a network interface. It implicitly
254 * deletes a network if it becomes empty of nis
256 * nw - network and interface list
257 * seq_no - sequence number of the request
258 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
260 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
261 int seq_no, struct cYAML **err_rc);
264 * lustre_lnet_show_net
265 * Send down an IOCTL to show networks.
266 * This function will use the nw paramter to filter the output. If it's
267 * not provided then all networks are listed.
269 * nw - network to show. Optional. Used to filter output.
270 * detail - flag to indicate if we require detail output.
271 * seq_no - sequence number of the request
272 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
273 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
274 * backup - true to output only what's necessary for reconfiguring
277 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
278 struct cYAML **show_rc, struct cYAML **err_rc,
282 * lustre_lnet_enable_routing
283 * Send down an IOCTL to enable or diable routing
285 * enable - 1 to enable routing, 0 to disable routing
286 * seq_no - sequence number of the request
287 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
289 int lustre_lnet_enable_routing(int enable, int seq_no,
290 struct cYAML **err_rc);
293 * lustre_lnet_config_numa_range
294 * Set the NUMA range which impacts the NIs to be selected
295 * during sending. If the NUMA range is large the NUMA
296 * distance between the message memory and the NI becomes
297 * less significant. The NUMA range is a relative number
298 * with no other meaning besides allowing a wider breadth
299 * for picking an NI to send from.
301 * range - numa range value.
302 * seq_no - sequence number of the request
303 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
306 int lustre_lnet_config_numa_range(int range, int seq_no,
307 struct cYAML **err_rc);
310 * lustre_lnet_show_num_range
311 * Get the currently set NUMA range
313 * seq_no - sequence number of the request
314 * show_rc - [OUT] struct cYAML tree containing NUMA range info
315 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
318 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
319 struct cYAML **err_rc);
322 * lustre_lnet_config_ni_healthv
323 * set the health value of the NI. -1 resets the value to maximum.
325 * value: health value to set.
326 * all: true to set all local NIs to that value.
327 * ni_nid: NI NID to set its health value. all parameter always takes
329 * seq_no - sequence number of the request
330 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
333 int lustre_lnet_config_ni_healthv(int value, bool all, char *ni_nid,
334 int seq_no, struct cYAML **err_rc);
337 /* lustre_lnet_config_ni_conns_per_peer
338 * set the conns_per_peer value of the NI. Valid range is specific to
341 * value: conns_per_peer value to set.
342 * all: true to set all local NIs to that value.
343 * ni_nid: NI NID to set its conns_per_peer value. 'all' parameter always
345 * seq_no - sequence number of the request
346 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
349 int lustre_lnet_config_ni_conns_per_peer(int value, bool all, char *ni_nid,
350 int seq_no, struct cYAML **err_rc);
353 * lustre_lnet_config_peer_ni_healthv
354 * set the health value of the peer NI. -1 resets the value to maximum.
356 * value: health value to set.
357 * all: true to set all local NIs to that value.
358 * pni_nid: Peer NI NID to set its health value. all parameter always takes
360 * seq_no - sequence number of the request
361 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
364 int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid,
365 int seq_no, struct cYAML **err_rc);
368 * lustre_lnet_config_recov_intrv
369 * set the recovery interval in seconds. That's the interval to ping an
370 * unhealthy interface.
372 * intrv - recovery interval value to configure
373 * seq_no - sequence number of the request
374 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
377 int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc);
380 * lustre_lnet_show_recov_intrv
381 * show the recovery interval set in the system
383 * seq_no - sequence number of the request
384 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
385 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
388 int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc,
389 struct cYAML **err_rc);
392 * lustre_lnet_config_rtr_sensitivity
393 * sets the router sensitivity percentage. If the percentage health
394 * of a router interface drops below that it's considered failed
396 * sen - sensitivity value to configure
397 * seq_no - sequence number of the request
398 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
401 int lustre_lnet_config_rtr_sensitivity(int sen, int seq_no, struct cYAML **err_rc);
404 * lustre_lnet_config_hsensitivity
405 * sets the health sensitivity; the value by which to decrement the
406 * health value of a local or peer NI. If 0 then health is turned off
408 * sen - sensitivity value to configure
409 * seq_no - sequence number of the request
410 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
413 int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc);
416 * lustre_lnet_show_hsensitivity
417 * show the health sensitivity in the system
419 * seq_no - sequence number of the request
420 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
421 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
424 int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc,
425 struct cYAML **err_rc);
428 * lustre_lnet_show_rtr_sensitivity
429 * show the router sensitivity percentage in the system
431 * seq_no - sequence number of the request
432 * show_rc - [OUT] struct cYAML tree containing health sensitivity info
433 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
436 int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc,
437 struct cYAML **err_rc);
440 * lustre_lnet_config_transaction_to
441 * sets the timeout after which a message expires or a timeout event is
442 * propagated for an expired response.
444 * timeout - timeout value to configure
445 * seq_no - sequence number of the request
446 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
449 int lustre_lnet_config_transaction_to(int timeout, int seq_no, struct cYAML **err_rc);
452 * lustre_lnet_show_transaction_to
453 * show the transaction timeout in the system
455 * seq_no - sequence number of the request
456 * show_rc - [OUT] struct cYAML tree containing transaction timeout info
457 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
460 int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc,
461 struct cYAML **err_rc);
464 * lustre_lnet_config_retry_count
465 * sets the maximum number of retries to resend a message
467 * count - maximum value to configure
468 * seq_no - sequence number of the request
469 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
472 int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc);
475 * lustre_lnet_show_retry_count
476 * show current maximum number of retries in the system
478 * seq_no - sequence number of the request
479 * show_rc - [OUT] struct cYAML tree containing retry count info
480 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
483 int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc,
484 struct cYAML **err_rc);
486 int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc,
487 struct cYAML **err_rc);
489 int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc,
490 struct cYAML **err_rc);
492 int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
493 struct cYAML **err_rc);
494 int lustre_lnet_config_response_tracking(int count, int seq_no,
495 struct cYAML **err_rc);
496 int lustre_lnet_show_response_tracking(int seq_no, struct cYAML **show_rc,
497 struct cYAML **err_rc);
498 int lustre_lnet_config_recovery_limit(int val, int seq_no,
499 struct cYAML **err_rc);
500 int lustre_lnet_show_recovery_limit(int seq_no, struct cYAML **show_rc,
501 struct cYAML **err_rc);
502 int lustre_lnet_show_max_recovery_ping_interval(int seq_no,
503 struct cYAML **show_rc,
504 struct cYAML **err_rc);
507 * lustre_lnet_config_max_intf
508 * Sets the maximum number of interfaces per node. this tunable is
509 * primarily useful for sanity checks prior to allocating memory.
511 * max - maximum value to configure
512 * seq_no - sequence number of the request
513 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
516 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
519 * lustre_lnet_show_max_intf
520 * show current maximum interface setting
522 * seq_no - sequence number of the request
523 * show_rc - [OUT] struct cYAML tree containing NUMA range info
524 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
527 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
528 struct cYAML **err_rc);
531 * lustre_lnet_calc_service_id
532 * Calculate the lustre service id to be used for qos
534 int lustre_lnet_calc_service_id(__u64 *service_id);
537 * lustre_lnet_setup_mrrouting
538 * configure linux routing tables for tcp interfaces
540 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
543 int lustre_lnet_setup_mrrouting(struct cYAML **err_rc);
546 * lustre_lnet_calc_cpt_of_nid
547 * Return the cpt number of the NID provided
549 int lustre_lnet_calc_cpt_of_nid(char *nidc, long int ncpts);
552 * lustre_lnet_config_discovery
553 * Enable or disable peer discovery. Peer discovery is enabled by default.
555 * enable - non-0 enables, 0 disables
556 * seq_no - sequence number of the request
557 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
560 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
563 * lustre_lnet_show_discovery
564 * show current peer discovery setting
566 * seq_no - sequence number of the request
567 * show_rc - [OUT] struct cYAML tree containing NUMA range info
568 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
571 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
572 struct cYAML **err_rc);
575 * lustre_lnet_config_drop_asym_route
576 * Drop or accept asymmetrical route messages. Accept by default.
578 * drop - non-0 drops, 0 accepts
579 * seq_no - sequence number of the request
580 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
583 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
584 struct cYAML **err_rc);
587 * lustre_lnet_show_drop_asym_route
588 * show current drop asym route setting
590 * seq_no - sequence number of the request
591 * show_rc - [OUT] struct cYAML tree containing NUMA range info
592 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
595 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
596 struct cYAML **err_rc);
599 * lustre_lnet_config_buffers
600 * Send down an IOCTL to configure routing buffer sizes. A value of 0 means
601 * default that particular buffer to default size. A value of -1 means
602 * leave the value of the buffer un changed.
604 * tiny - tiny buffers
605 * small - small buffers
606 * large - large buffers.
607 * seq_no - sequence number of the request
608 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
610 int lustre_lnet_config_buffers(int tiny, int small, int large,
611 int seq_no, struct cYAML **err_rc);
614 * lustre_lnet_config_max_recovery_ping_interval
615 * Set the maximum recovery ping interval.
617 * interval - interval value in seconds
618 * seq_no - sequence number of the request
619 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
621 int lustre_lnet_config_max_recovery_ping_interval(int interval, int seq_no,
622 struct cYAML **err_rc);
625 * lustre_lnet_show_routing
626 * Send down an IOCTL to dump buffers and routing status
627 * This function is used to dump buffers for all CPU partitions.
629 * seq_no - sequence number of the request
630 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
631 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
632 * backup - true to output only what's necessary for reconfiguring
635 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
636 struct cYAML **err_rc, bool backup);
639 * lustre_lnet_show_stats
640 * Shows internal LNET statistics. This is useful to display the
641 * current LNET activity, such as number of messages route, etc
643 * seq_no - sequence number of the command
644 * show_rc - YAML structure of the resultant show
645 * err_rc - YAML strucutre of the resultant return code.
647 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
648 struct cYAML **err_rc);
651 * lustre_lnet_reset_stats
652 * Resets internal LNET statistics.
654 * err_rc - YAML strucutre of the resultant return code.
656 int lustre_lnet_reset_stats(int seq_no, struct cYAML **err_rc);
659 * lustre_lnet_modify_peer
660 * Handle a peer config or delete operation.
663 * Add a peer NID to a peer with primary NID pnid.
664 * If the provided primary NID is unique, then a new peer is
665 * created with this primary NID, and the NIDs in the NID list are added as
666 * secondary NIDs to this new peer.
667 * If any of the NIDs in the NID list are not unique then the operation
668 * fails. Some peer NIDs might have already been added. It's the responsibility
669 * of the caller of this API to remove the added NIDs if so desired.
672 * Delete the NIDs given in the NID list from the peer with the primary NID
673 * pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails,
674 * and no change happens to the system.
675 * The operation is aborted on the first NID that fails to be deleted.
677 * prim_nid - The desired primary NID of a new peer, or the primary NID of
679 * nids - a comma separated string of nids
680 * is_mr - Specifies whether this peer is MR capable.
681 * cmd - CONFIG or DELETE
682 * force - whether force-deleting a peer with locked primary nid
683 * seq_no - sequence number of the command
684 * err_rc - YAML structure of the resultant return code
686 int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr, int cmd,
687 int force, int seq_no, struct cYAML **err_rc);
690 * lustre_lnet_show_peer
691 * Show the peer identified by nid, knid. If knid is NULL all
692 * peers in the system are shown.
694 * knid - A NID of the peer
695 * detail - display detailed information
696 * seq_no - sequence number of the command
697 * show_rc - YAML structure of the resultant show
698 * err_rc - YAML strucutre of the resultant return code.
699 * backup - true to output only what's necessary for reconfiguring
703 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
704 struct cYAML **show_rc, struct cYAML **err_rc,
708 * lustre_lnet_list_peer
709 * List the known peers.
711 * seq_no - sequence number of the command
712 * show_rc - YAML structure of the resultant show
713 * err_rc - YAML strucutre of the resultant return code.
716 int lustre_lnet_list_peer(int seq_no,
717 struct cYAML **show_rc, struct cYAML **err_rc);
719 /* lustre_lnet_ping_nid
720 * Ping the nid list, pnids.
722 * pnids - NID list to ping.
723 * src_nidstr - source NID
724 * timeout - timeout(seconds) for ping.
725 * seq_no - sequence number of the command.
726 * show_rc - YAML structure of the resultant show.
727 * err_rc - YAML strucutre of the resultant return code.
730 int lustre_lnet_ping_nid(char *pnid, char *src_nidstr, int timeout, int seq_no,
731 struct cYAML **show_rc, struct cYAML **err_rc);
733 /* lustre_lnet_discover_nid
734 * Discover the nid list, pnids.
736 * pnids - NID list to discover.
737 * force - force discovery.
738 * seq_no - sequence number of the command.
739 * show_rc - YAML structure of the resultant show.
740 * err_rc - YAML strucutre of the resultant return code.
743 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
744 struct cYAML **show_rc, struct cYAML **err_rc);
748 * Parses the provided YAML file and then calls the specific APIs
749 * to configure the entities identified in the file
752 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
754 int lustre_yaml_config(char *f, struct cYAML **err_rc);
758 * Parses the provided YAML file and then calls the specific APIs
759 * to delete the entities identified in the file
762 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
764 int lustre_yaml_del(char *f, struct cYAML **err_rc);
768 * Parses the provided YAML file and then calls the specific APIs
769 * to show the entities identified in the file
772 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
773 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
775 int lustre_yaml_show(char *f, struct cYAML **show_rc,
776 struct cYAML **err_rc);
780 * Parses the provided YAML file and then calls the specific APIs
781 * to execute the entities identified in the file
784 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
785 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
787 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
788 struct cYAML **err_rc);
791 * yaml_emitter_set_output_netlink
793 * Special handling to integrate LNet handling into libyaml.
794 * This function sets up the ability to take the data stored in @emitter
795 * and formats into a netlink packet to send to the kernel.
797 * emitter - YAML emitter containing what the user specified
798 * nl - Netlink socket to be used by libyaml
799 * family - Netlink family
800 * version - notify kernel what version user land supports
801 * cmd - Netlink command to execute
802 * flags - Netlink flags
804 int yaml_emitter_set_output_netlink(yaml_emitter_t *emitter, struct nl_sock *nl,
805 char *family, int version, int cmd,
809 * yaml_parser_set_input_netlink
811 * Special handling to LNet handling into libyaml.
812 * This function sets up the ability to receive the Netlink data
813 * from the Linux kernel. That data is formated into a YAML document.
815 * parser - YAML parser that is used to present the data received
816 * from the kernel in Netlink format.
817 * nl - should be the Netlink socket receiving data from
819 * stream - Handle the case of continuous data coming in.
821 int yaml_parser_set_input_netlink(yaml_parser_t *parser, struct nl_sock *nl,
825 * yaml_parser_get_reader_proto_version
827 * This function retrieves the Neltink version the kernel module
830 * parser - YAML parser being used for Netlink communication.
832 int yaml_parser_get_reader_proto_version(yaml_parser_t *parser);
835 * yaml_parser_get_reader_error
837 * By default libyaml reports a generic write error. We need a way
838 * to report better parser errors so we can track down problems.
840 * parser - YAML parser that has reported an error.
842 const char *yaml_parser_get_reader_error(yaml_parser_t *parser);
845 * yaml_parser_log_error
847 * Helper function to report the parser error to @log.
849 * parser - YAML parser that has reported an error.
850 * log - file descriptor to write the error message out to.
851 * errmsg - Special extra string to append to error message.
853 void yaml_parser_log_error(yaml_parser_t *parser, FILE *log,
857 * yaml_emitter_log_error
859 * Helper function to report the emitter error to @log.
861 * emitter - YAML emitter that has reported an error.
862 * log - file descriptor to write the error message out to.
864 void yaml_emitter_log_error(yaml_emitter_t *emitter, FILE *log);
868 * lustre_lnet_init_nw_descr
869 * initialize the network descriptor structure for use
871 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
874 * lustre_lnet_parse_interfaces
875 * prase an interface string and populate descriptor structures
876 * intf_str - interface string of the format
877 * <intf>[<expr>], <intf>[<expr>],..
878 * nw_descr - network descriptor to populate
879 * init - True to initialize nw_descr
881 int lustre_lnet_parse_interfaces(char *intf_str,
882 struct lnet_dlc_network_descr *nw_descr);
885 * lustre_lnet_parse_nidstr
886 * This is a small wrapper around cfs_parse_nidlist.
887 * nidstr - A string parseable by cfs_parse_nidlist
888 * lnet_nidlist - An array of lnet_nid_t to hold the nids specified
890 * max_nids - Size of the lnet_nidlist array, and the maximum number of
891 * nids that can be expressed by the nidstring. If the
892 * nidstring expands to a larger number of nids than max_nids
893 * then an error is returned.
894 * err_str - char pointer where we store an informative error
895 * message when an error is encountered
897 * The number (> 0) of lnet_nid_t stored in the supplied array, or
898 * LUSTRE_CFG_RC_BAD_PARAM if:
900 * - nidstr contains an asterisk. This character is not allowed
901 * because it would cause the size of the expanded nidlist to exceed
902 * the maximum number of nids that is supported by expected callers
904 * - cfs_parse_nidlist fails to parse the nidstring
905 * - The nidlist populated by cfs_parse_nidlist is empty
906 * - The nidstring expands to a larger number of nids than max_nids
907 * - The nidstring expands to zero nids
908 * LUSTRE_CFG_RC_OUT_OF_MEM if:
909 * - cfs_expand_nidlist can return ENOMEM. We return out of mem in
912 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
913 int max_nids, char *err_str);
915 /* lustre_lnet_add_udsp
916 * Add a selection policy.
917 * src - source NID descriptor
918 * dst - destination NID descriptor
919 * rte - router NID descriptor
921 * action - union of the action
922 * idx - the index to delete
923 * seq_no - sequence number of the request
924 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
927 int lustre_lnet_add_udsp(char *src, char *dst, char *rte, char *type,
928 union lnet_udsp_action *action, int idx,
929 int seq_no, struct cYAML **err_rc);
931 /* lustre_lnet_del_udsp
932 * Delete a net selection policy.
933 * idx - the index to delete
934 * seq_no - sequence number of the request
935 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
938 int lustre_lnet_del_udsp(unsigned int idx, int seq_no, struct cYAML **err_rc);
940 /* lustre_lnet_show_udsp
941 * show selection policy.
942 * idx - the index to show. -1 to show all policies
943 * seq_no - sequence number of the request
944 * err_rc - [IN/OUT] struct cYAML tree containing udsp info
945 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
948 int lustre_lnet_show_udsp(int idx, int seq_no, struct cYAML **show_rc,
949 struct cYAML **err_rc);
951 /* lustre_lnet_show_peer_debug_info
952 * dump peer debug info
953 * peer_nid - nid of the peer to show
954 * seq_no - sequence number of the request
955 * err_rc - [OUT] struct cYAML tree describing the error. Freed by
958 int lustre_lnet_show_peer_debug_info(char *peer_nid, int seq_no,
959 struct cYAML **err_rc);
961 #endif /* LIB_LNET_CONFIG_API_H */