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