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