Whamcloud - gitweb
LU-9121 lnet: Add a selection policy
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.h
1 /*
2  * LGPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
10  *
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.
15  *
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/>.
18  *
19  * LGPL HEADER END
20  *
21  * Copyright (c) 2014, 2017, Intel Corporation.
22  *
23  * Author:
24  *   Amir Shehata <amir.shehata@intel.com>
25  */
26
27 #ifndef LIB_LNET_CONFIG_API_H
28 #define LIB_LNET_CONFIG_API_H
29
30 #include <net/if.h>
31 #include <libcfs/util/string.h>
32 #include <linux/lnet/lnet-dlc.h>
33 #include <linux/lnet/nidstr.h>
34
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
45 #define LUSTRE_CFG_RC_MARSHAL_FAIL              -10
46
47 #define CONFIG_CMD              "configure"
48 #define UNCONFIG_CMD            "unconfigure"
49 #define ADD_CMD                 "add"
50 #define DEL_CMD                 "del"
51 #define SHOW_CMD                "show"
52 #define DBG_CMD                 "dbg"
53 #define MANAGE_CMD              "manage"
54
55 #define MAX_NUM_IPS             128
56
57 #define modparam_path "/sys/module/lnet/parameters/"
58 #define o2ib_modparam_path "/sys/module/ko2iblnd/parameters/"
59 #define gni_nid_path "/proc/cray_xt/"
60
61 enum lnetctl_cmd {
62         LNETCTL_CONFIG_CMD      = 1,
63         LNETCTL_UNCONFIG_CMD    = 2,
64         LNETCTL_ADD_CMD         = 3,
65         LNETCTL_DEL_CMD         = 4,
66         LNETCTL_SHOW_CMD        = 5,
67         LNETCTL_DBG_CMD         = 6,
68         LNETCTL_MANAGE_CMD      = 7,
69         LNETCTL_LAST_CMD
70 };
71
72 /*
73  * Max number of nids we'll configure for a single peer via a single DLC
74  * operation
75  */
76 #define LNET_MAX_NIDS_PER_PEER 128
77
78 struct lnet_dlc_network_descr {
79         struct list_head network_on_rule;
80         __u32 nw_id;
81         struct list_head nw_intflist;
82 };
83
84 struct lnet_dlc_intf_descr {
85         struct list_head intf_on_network;
86         char intf_name[IFNAMSIZ];
87         struct cfs_expr_list *cpt_expr;
88 };
89
90 /* This UDSP structures need to match the kernel space structures
91  * in order for the marshall and unmarshall functions to be the same.
92  */
93
94 /* Net is described as a
95  *  1. net type
96  *  2. num range
97  */
98 struct lnet_ud_net_descr {
99         __u32 udn_net_type;
100         struct list_head udn_net_num_range;
101 };
102
103 /* each NID range is defined as
104  *  1. net descriptor
105  *  2. address range descriptor
106  */
107 struct lnet_ud_nid_descr {
108         struct lnet_ud_net_descr ud_net_id;
109         struct list_head ud_addr_range;
110 };
111
112 /* a UDSP rule can have up to three user defined NID descriptors
113  *      - src: defines the local NID range for the rule
114  *      - dst: defines the peer NID range for the rule
115  *      - rte: defines the router NID range for the rule
116  *
117  * An action union defines the action to take when the rule
118  * is matched
119  */
120 struct lnet_udsp {
121         struct list_head udsp_on_list;
122         __u32 udsp_idx;
123         struct lnet_ud_nid_descr udsp_src;
124         struct lnet_ud_nid_descr udsp_dst;
125         struct lnet_ud_nid_descr udsp_rte;
126         enum lnet_udsp_action_type udsp_action_type;
127         union {
128                 __u32 udsp_priority;
129         } udsp_action;
130 };
131
132 /* This union is passed from lnetctl to fill the action union in udsp
133  * structure
134  * TODO: The idea here is if we add extra actions, ex: drop, it can be
135  * added to the union
136  */
137 union lnet_udsp_action {
138         int udsp_priority;
139 };
140
141 /* forward declaration of the cYAML structure. */
142 struct cYAML;
143
144 /*
145  * lustre_lnet_config_lib_init()
146  *   Initialize the Library to enable communication with the LNET kernel
147  *   module.  Returns the device ID or -EINVAL if there is an error
148  */
149 int lustre_lnet_config_lib_init();
150
151 /*
152  * lustre_lnet_config_lib_uninit
153  *      Uninitialize the DLC Library
154  */
155 void lustre_lnet_config_lib_uninit();
156
157 /*
158  * lustre_lnet_config_ni_system
159  *   Initialize/Uninitialize the lnet NI system.
160  *
161  *   up - whehter to init or uninit the system
162  *   load_ni_from_mod - load NI from mod params.
163  *   seq_no - sequence number of the request
164  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
165  *            caller
166  */
167 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
168                                  int seq_no, struct cYAML **err_rc);
169
170 /*
171  * lustre_lnet_config_route
172  *   Send down an IOCTL to the kernel to configure the route
173  *
174  *   nw - network
175  *   gw - gateway
176  *   hops - number of hops passed down by the user
177  *   prio - priority of the route
178  *   sen - health sensitivity value for the gateway
179  *   seq_no - sequence number of the request
180  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
181  */
182 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
183                              int sen, int seq_no, struct cYAML **err_rc);
184
185 /*
186  * lustre_lnet_del_route
187  *   Send down an IOCTL to the kernel to delete a route
188  *
189  *   nw - network
190  *   gw - gateway
191  *   seq_no - sequence number of the request
192  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
193  */
194 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
195                           struct cYAML **err_rc);
196
197 /*
198  * lustre_lnet_show_route
199  *   Send down an IOCTL to the kernel to show routes
200  *   This function will get one route at a time and filter according to
201  *   provided parameters. If no routes are available then it will dump all
202  *   routes that are in the system.
203  *
204  *   nw - network.  Optional.  Used to filter output
205  *   gw - gateway. Optional. Used to filter ouptut
206  *   hops - number of hops passed down by the user
207  *          Optional.  Used to filter output.
208  *   prio - priority of the route.  Optional.  Used to filter output.
209  *   detail - flag to indicate whether detail output is required
210  *   seq_no - sequence number of the request
211  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
212  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
213  *   backup - true to output only what's necessary for reconfiguring
214  *            a node.
215  */
216 int lustre_lnet_show_route(char *nw, char *gw,
217                            int hops, int prio, int detail,
218                            int seq_no, struct cYAML **show_rc,
219                            struct cYAML **err_rc, bool backup);
220
221 /*
222  * lustre_lnet_config_ni
223  *   Send down an IOCTL to configure a network interface. It implicitly
224  *   creates a network if one doesn't exist..
225  *
226  *   nw_descr - network and interface descriptor
227  *   global_cpts - globally defined CPTs
228  *   ip2net - this parameter allows configuring multiple networks.
229  *      it takes precedence over the net and intf parameters
230  *   tunables - LND tunables
231  *   seq_no - sequence number of the request
232  *   lnd_tunables - lnet specific tunable parameters
233  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
234  */
235 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
236                           struct cfs_expr_list *global_cpts,
237                           char *ip2net,
238                           struct lnet_ioctl_config_lnd_tunables *tunables,
239                           int seq_no, struct cYAML **err_rc);
240
241 /*
242  * lustre_lnet_del_ni
243  *   Send down an IOCTL to delete a network interface. It implicitly
244  *   deletes a network if it becomes empty of nis
245  *
246  *   nw  - network and interface list
247  *   seq_no - sequence number of the request
248  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
249  */
250 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
251                        int seq_no, struct cYAML **err_rc);
252
253 /*
254  * lustre_lnet_show_net
255  *   Send down an IOCTL to show networks.
256  *   This function will use the nw paramter to filter the output.  If it's
257  *   not provided then all networks are listed.
258  *
259  *   nw - network to show.  Optional.  Used to filter output.
260  *   detail - flag to indicate if we require detail output.
261  *   seq_no - sequence number of the request
262  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
263  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
264  *   backup - true to output only what's necessary for reconfiguring
265  *            a node.
266  */
267 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
268                          struct cYAML **show_rc, struct cYAML **err_rc,
269                          bool backup);
270
271 /*
272  * lustre_lnet_enable_routing
273  *   Send down an IOCTL to enable or diable routing
274  *
275  *   enable - 1 to enable routing, 0 to disable routing
276  *   seq_no - sequence number of the request
277  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
278  */
279 int lustre_lnet_enable_routing(int enable, int seq_no,
280                                struct cYAML **err_rc);
281
282 /*
283  * lustre_lnet_config_numa_range
284  *   Set the NUMA range which impacts the NIs to be selected
285  *   during sending. If the NUMA range is large the NUMA
286  *   distance between the message memory and the NI becomes
287  *   less significant. The NUMA range is a relative number
288  *   with no other meaning besides allowing a wider breadth
289  *   for picking an NI to send from.
290  *
291  *   range - numa range value.
292  *   seq_no - sequence number of the request
293  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
294  *   caller
295  */
296 int lustre_lnet_config_numa_range(int range, int seq_no,
297                                   struct cYAML **err_rc);
298
299 /*
300  * lustre_lnet_show_num_range
301  *   Get the currently set NUMA range
302  *
303  *   seq_no - sequence number of the request
304  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
305  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
306  *   caller
307  */
308 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
309                                 struct cYAML **err_rc);
310
311 /*
312  * lustre_lnet_config_ni_healthv
313  *   set the health value of the NI. -1 resets the value to maximum.
314  *
315  *   value: health value to set.
316  *   all: true to set all local NIs to that value.
317  *   ni_nid: NI NID to set its health value. all parameter always takes
318  *   precedence
319  *   seq_no - sequence number of the request
320  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
321  *   caller
322  */
323 int lustre_lnet_config_ni_healthv(int value, bool all, char *ni_nid,
324                                   int seq_no, struct cYAML **err_rc);
325
326 /*
327  * lustre_lnet_config_peer_ni_healthv
328  *   set the health value of the peer NI. -1 resets the value to maximum.
329  *
330  *   value: health value to set.
331  *   all: true to set all local NIs to that value.
332  *   pni_nid: Peer NI NID to set its health value. all parameter always takes
333  *   precedence
334  *   seq_no - sequence number of the request
335  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
336  *   caller
337  */
338 int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid,
339                                        int seq_no, struct cYAML **err_rc);
340
341 /*
342  * lustre_lnet_config_recov_intrv
343  *   set the recovery interval in seconds. That's the interval to ping an
344  *   unhealthy interface.
345  *
346  *   intrv - recovery interval value to configure
347  *   seq_no - sequence number of the request
348  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
349  *   caller
350  */
351 int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc);
352
353 /*
354  * lustre_lnet_show_recov_intrv
355  *    show the recovery interval set in the system
356  *
357  *   seq_no - sequence number of the request
358  *   show_rc - [OUT] struct cYAML tree containing health sensitivity info
359  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
360  *   caller
361  */
362 int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc,
363                                  struct cYAML **err_rc);
364
365 /*
366  * lustre_lnet_config_rtr_sensitivity
367  *   sets the router sensitivity percentage. If the percentage health
368  *   of a router interface drops below that it's considered failed
369  *
370  *   sen - sensitivity value to configure
371  *   seq_no - sequence number of the request
372  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
373  *   caller
374  */
375 int lustre_lnet_config_rtr_sensitivity(int sen, int seq_no, struct cYAML **err_rc);
376
377 /*
378  * lustre_lnet_config_hsensitivity
379  *   sets the health sensitivity; the value by which to decrement the
380  *   health value of a local or peer NI. If 0 then health is turned off
381  *
382  *   sen - sensitivity value to configure
383  *   seq_no - sequence number of the request
384  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
385  *   caller
386  */
387 int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc);
388
389 /*
390  * lustre_lnet_show_hsensitivity
391  *    show the health sensitivity in the system
392  *
393  *   seq_no - sequence number of the request
394  *   show_rc - [OUT] struct cYAML tree containing health sensitivity info
395  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
396  *   caller
397  */
398 int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc,
399                                   struct cYAML **err_rc);
400
401 /*
402  * lustre_lnet_show_rtr_sensitivity
403  *    show the router sensitivity percentage in the system
404  *
405  *   seq_no - sequence number of the request
406  *   show_rc - [OUT] struct cYAML tree containing health sensitivity info
407  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
408  *   caller
409  */
410 int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc,
411                                      struct cYAML **err_rc);
412
413 /*
414  * lustre_lnet_config_transaction_to
415  *   sets the timeout after which a message expires or a timeout event is
416  *   propagated for an expired response.
417  *
418  *   timeout - timeout value to configure
419  *   seq_no - sequence number of the request
420  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
421  *   caller
422  */
423 int lustre_lnet_config_transaction_to(int timeout, int seq_no, struct cYAML **err_rc);
424
425 /*
426  * lustre_lnet_show_transaction_to
427  *    show the transaction timeout in the system
428  *
429  *   seq_no - sequence number of the request
430  *   show_rc - [OUT] struct cYAML tree containing transaction timeout info
431  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
432  *   caller
433  */
434 int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc,
435                                     struct cYAML **err_rc);
436
437 /*
438  * lustre_lnet_config_retry_count
439  *   sets the maximum number of retries to resend a message
440  *
441  *   count - maximum value to configure
442  *   seq_no - sequence number of the request
443  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
444  *   caller
445  */
446 int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc);
447
448 /*
449  * lustre_lnet_show_retry_count
450  *    show current maximum number of retries in the system
451  *
452  *   seq_no - sequence number of the request
453  *   show_rc - [OUT] struct cYAML tree containing retry count info
454  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
455  *   caller
456  */
457 int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc,
458                                  struct cYAML **err_rc);
459
460 int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc,
461                                  struct cYAML **err_rc);
462
463 int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc,
464                                      struct cYAML **err_rc);
465
466 int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc,
467                                     struct cYAML **err_rc);
468 int lustre_lnet_config_response_tracking(int count, int seq_no,
469                                          struct cYAML **err_rc);
470 int lustre_lnet_show_response_tracking(int seq_no, struct cYAML **show_rc,
471                                        struct cYAML **err_rc);
472 int lustre_lnet_config_recovery_limit(int val, int seq_no,
473                                       struct cYAML **err_rc);
474 int lustre_lnet_show_recovery_limit(int seq_no, struct cYAML **show_rc,
475                                     struct cYAML **err_rc);
476
477 /*
478  * lustre_lnet_config_max_intf
479  *   Sets the maximum number of interfaces per node. this tunable is
480  *   primarily useful for sanity checks prior to allocating memory.
481  *
482  *   max - maximum value to configure
483  *   seq_no - sequence number of the request
484  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
485  *   caller
486  */
487 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
488
489 /*
490  * lustre_lnet_show_max_intf
491  *    show current maximum interface setting
492  *
493  *   seq_no - sequence number of the request
494  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
495  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
496  *   caller
497  */
498 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
499                               struct cYAML **err_rc);
500
501 /*
502  * lustre_lnet_calc_service_id
503  *    Calculate the lustre service id to be used for qos
504  */
505 int lustre_lnet_calc_service_id(__u64 *service_id);
506
507 /*
508  * lustre_lnet_config_discovery
509  *   Enable or disable peer discovery. Peer discovery is enabled by default.
510  *
511  *   enable - non-0 enables, 0 disables
512  *   seq_no - sequence number of the request
513  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
514  *   caller
515  */
516 int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc);
517
518 /*
519  * lustre_lnet_show_discovery
520  *    show current peer discovery setting
521  *
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
525  *   caller
526  */
527 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
528                                struct cYAML **err_rc);
529
530 /*
531  * lustre_lnet_config_drop_asym_route
532  *   Drop or accept asymmetrical route messages. Accept by default.
533  *
534  *   drop - non-0 drops, 0 accepts
535  *   seq_no - sequence number of the request
536  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
537  *   caller
538  */
539 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
540                                        struct cYAML **err_rc);
541
542 /*
543  * lustre_lnet_show_drop_asym_route
544  *    show current drop asym route setting
545  *
546  *   seq_no - sequence number of the request
547  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
548  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
549  *   caller
550  */
551 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
552                                      struct cYAML **err_rc);
553
554 /*
555  * lustre_lnet_config_buffers
556  *   Send down an IOCTL to configure routing buffer sizes.  A value of 0 means
557  *   default that particular buffer to default size. A value of -1 means
558  *   leave the value of the buffer un changed.
559  *
560  *   tiny - tiny buffers
561  *   small - small buffers
562  *   large - large buffers.
563  *   seq_no - sequence number of the request
564  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
565  */
566 int lustre_lnet_config_buffers(int tiny, int small, int large,
567                                int seq_no, struct cYAML **err_rc);
568
569 /*
570  * lustre_lnet_show_routing
571  *   Send down an IOCTL to dump buffers and routing status
572  *   This function is used to dump buffers for all CPU partitions.
573  *
574  *   seq_no - sequence number of the request
575  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
576  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
577  *   backup - true to output only what's necessary for reconfiguring
578  *            a node.
579  */
580 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
581                              struct cYAML **err_rc, bool backup);
582
583 /*
584  * lustre_lnet_show_stats
585  *   Shows internal LNET statistics.  This is useful to display the
586  *   current LNET activity, such as number of messages route, etc
587  *
588  *     seq_no - sequence number of the command
589  *     show_rc - YAML structure of the resultant show
590  *     err_rc - YAML strucutre of the resultant return code.
591  */
592 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
593                            struct cYAML **err_rc);
594
595 /*
596  * lustre_lnet_modify_peer
597  *  Handle a peer config or delete operation.
598  *
599  *  Config Operation:
600  *  Add a peer NID to a peer with primary NID pnid. 
601  *  If the provided primary NID is unique, then a new peer is
602  *  created with this primary NID, and the NIDs in the NID list are added as
603  *  secondary NIDs to this new peer.
604  *  If any of the NIDs in the NID list are not unique then the operation
605  *  fails. Some peer NIDs might have already been added. It's the responsibility
606  *  of the caller of this API to remove the added NIDs if so desired.
607  *
608  *  Delete Operation:
609  *  Delete the NIDs given in the NID list from the peer with the primary NID
610  *  pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails,
611  *  and no change happens to the system.
612  *  The operation is aborted on the first NID that fails to be deleted.
613  *
614  *      prim_nid - The desired primary NID of a new peer, or the primary NID of
615  *                 an existing peer.
616  *      nids - a comma separated string of nids
617  *      is_mr - Specifies whether this peer is MR capable.
618  *      cmd - CONFIG or DELETE
619  *      seq_no - sequence number of the command
620  *      err_rc - YAML structure of the resultant return code
621  */
622 int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr,
623                             int cmd, int seq_no, struct cYAML **err_rc);
624
625 /*
626  * lustre_lnet_show_peer
627  *   Show the peer identified by nid, knid. If knid is NULL all
628  *   peers in the system are shown.
629  *
630  *     knid - A NID of the peer
631  *     detail - display detailed information
632  *     seq_no - sequence number of the command
633  *     show_rc - YAML structure of the resultant show
634  *     err_rc - YAML strucutre of the resultant return code.
635  *     backup - true to output only what's necessary for reconfiguring
636  *              a node.
637  *
638  */
639 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
640                           struct cYAML **show_rc, struct cYAML **err_rc,
641                           bool backup);
642
643 /*
644  * lustre_lnet_list_peer
645  *   List the known peers.
646  *
647  *     seq_no - sequence number of the command
648  *     show_rc - YAML structure of the resultant show
649  *     err_rc - YAML strucutre of the resultant return code.
650  *
651  */
652 int lustre_lnet_list_peer(int seq_no,
653                           struct cYAML **show_rc, struct cYAML **err_rc);
654
655 /* lustre_lnet_ping_nid
656  *   Ping the nid list, pnids.
657  *
658  *    pnids - NID list to ping.
659  *    timeout - timeout(seconds) for ping.
660  *    seq_no - sequence number of the command.
661  *    show_rc - YAML structure of the resultant show.
662  *    err_rc - YAML strucutre of the resultant return code.
663  *
664  */
665 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
666                         struct cYAML **show_rc, struct cYAML **err_rc);
667
668 /* lustre_lnet_discover_nid
669  *   Discover the nid list, pnids.
670  *
671  *    pnids - NID list to discover.
672  *    force - force discovery.
673  *    seq_no - sequence number of the command.
674  *    show_rc - YAML structure of the resultant show.
675  *    err_rc - YAML strucutre of the resultant return code.
676  *
677  */
678 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
679                              struct cYAML **show_rc, struct cYAML **err_rc);
680
681 /*
682  * lustre_yaml_config
683  *   Parses the provided YAML file and then calls the specific APIs
684  *   to configure the entities identified in the file
685  *
686  *   f - YAML file
687  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
688  */
689 int lustre_yaml_config(char *f, struct cYAML **err_rc);
690
691 /*
692  * lustre_yaml_del
693  *   Parses the provided YAML file and then calls the specific APIs
694  *   to delete the entities identified in the file
695  *
696  *   f - YAML file
697  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
698  */
699 int lustre_yaml_del(char *f, struct cYAML **err_rc);
700
701 /*
702  * lustre_yaml_show
703  *   Parses the provided YAML file and then calls the specific APIs
704  *   to show the entities identified in the file
705  *
706  *   f - YAML file
707  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
708  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
709  */
710 int lustre_yaml_show(char *f, struct cYAML **show_rc,
711                      struct cYAML **err_rc);
712
713 /*
714  * lustre_yaml_exec
715  *   Parses the provided YAML file and then calls the specific APIs
716  *   to execute the entities identified in the file
717  *
718  *   f - YAML file
719  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
720  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
721  */
722 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
723                      struct cYAML **err_rc);
724
725 /*
726  * lustre_lnet_init_nw_descr
727  *      initialize the network descriptor structure for use
728  */
729 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
730
731 /*
732  * lustre_lnet_parse_interfaces
733  *      prase an interface string and populate descriptor structures
734  *              intf_str - interface string of the format
735  *                      <intf>[<expr>], <intf>[<expr>],..
736  *              nw_descr - network descriptor to populate
737  *              init - True to initialize nw_descr
738  */
739 int lustre_lnet_parse_interfaces(char *intf_str,
740                                  struct lnet_dlc_network_descr *nw_descr);
741
742 /*
743  * lustre_lnet_parse_nidstr
744  *     This is a small wrapper around cfs_parse_nidlist.
745  *         nidstr - A string parseable by cfs_parse_nidlist
746  *         lnet_nidlist - An array of lnet_nid_t to hold the nids specified
747  *                        by the nidstring.
748  *         max_nids - Size of the lnet_nidlist array, and the maximum number of
749  *                    nids that can be expressed by the nidstring. If the
750  *                    nidstring expands to a larger number of nids than max_nids
751  *                    then an error is returned.
752  *         err_str - char pointer where we store an informative error
753  *                   message when an error is encountered
754  *     Returns:
755  *         The number (> 0) of lnet_nid_t stored in the supplied array, or
756  *         LUSTRE_CFG_RC_BAD_PARAM if:
757  *           - nidstr is NULL
758  *           - nidstr contains an asterisk. This character is not allowed
759  *             because it would cause the size of the expanded nidlist to exceed
760  *             the maximum number of nids that is supported by expected callers
761  *             of this function.
762  *           - cfs_parse_nidlist fails to parse the nidstring
763  *           - The nidlist populated by cfs_parse_nidlist is empty
764  *           - The nidstring expands to a larger number of nids than max_nids
765  *           - The nidstring expands to zero nids
766  *         LUSTRE_CFG_RC_OUT_OF_MEM if:
767  *           - cfs_expand_nidlist can return ENOMEM. We return out of mem in
768  *             this case.
769  */
770 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
771                              int max_nids, char *err_str);
772
773 /* lustre_lnet_add_udsp
774  *      Add a selection policy.
775  *      src - source NID descriptor
776  *      dst - destination NID descriptor
777  *      rte - router NID descriptor
778  *      type - action type
779  *      action - union of the action
780  *      idx - the index to delete
781  *      seq_no - sequence number of the request
782  *      err_rc - [OUT] struct cYAML tree describing the error. Freed by
783  *               caller
784  */
785 int lustre_lnet_add_udsp(char *src, char *dst, char *rte, char *type,
786                          union lnet_udsp_action *action, int idx,
787                          int seq_no, struct cYAML **err_rc);
788
789 #endif /* LIB_LNET_CONFIG_API_H */