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