Whamcloud - gitweb
fe9ce5d6094d4a473c0eeb1aa3dc278d90890a84
[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 int lustre_lnet_config_recovery_limit(int val, int seq_no,
407                                       struct cYAML **err_rc);
408 int lustre_lnet_show_recovery_limit(int seq_no, struct cYAML **show_rc,
409                                     struct cYAML **err_rc);
410
411 /*
412  * lustre_lnet_config_max_intf
413  *   Sets the maximum number of interfaces per node. this tunable is
414  *   primarily useful for sanity checks prior to allocating memory.
415  *
416  *   max - maximum value to configure
417  *   seq_no - sequence number of the request
418  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
419  *   caller
420  */
421 int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc);
422
423 /*
424  * lustre_lnet_show_max_intf
425  *    show current maximum interface setting
426  *
427  *   seq_no - sequence number of the request
428  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
429  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
430  *   caller
431  */
432 int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc,
433                               struct cYAML **err_rc);
434
435 /*
436  * lustre_lnet_calc_service_id
437  *    Calculate the lustre service id to be used for qos
438  */
439 int lustre_lnet_calc_service_id(__u64 *service_id);
440
441 /*
442  * lustre_lnet_config_discovery
443  *   Enable or disable peer discovery. Peer discovery is enabled by default.
444  *
445  *   enable - non-0 enables, 0 disables
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_discovery(int enable, int seq_no, struct cYAML **err_rc);
451
452 /*
453  * lustre_lnet_show_discovery
454  *    show current peer discovery setting
455  *
456  *   seq_no - sequence number of the request
457  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
458  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
459  *   caller
460  */
461 int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc,
462                                struct cYAML **err_rc);
463
464 /*
465  * lustre_lnet_config_drop_asym_route
466  *   Drop or accept asymmetrical route messages. Accept by default.
467  *
468  *   drop - non-0 drops, 0 accepts
469  *   seq_no - sequence number of the request
470  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
471  *   caller
472  */
473 int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
474                                        struct cYAML **err_rc);
475
476 /*
477  * lustre_lnet_show_drop_asym_route
478  *    show current drop asym route setting
479  *
480  *   seq_no - sequence number of the request
481  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
482  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
483  *   caller
484  */
485 int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
486                                      struct cYAML **err_rc);
487
488 /*
489  * lustre_lnet_config_buffers
490  *   Send down an IOCTL to configure routing buffer sizes.  A value of 0 means
491  *   default that particular buffer to default size. A value of -1 means
492  *   leave the value of the buffer un changed.
493  *
494  *   tiny - tiny buffers
495  *   small - small buffers
496  *   large - large buffers.
497  *   seq_no - sequence number of the request
498  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
499  */
500 int lustre_lnet_config_buffers(int tiny, int small, int large,
501                                int seq_no, struct cYAML **err_rc);
502
503 /*
504  * lustre_lnet_show_routing
505  *   Send down an IOCTL to dump buffers and routing status
506  *   This function is used to dump buffers for all CPU partitions.
507  *
508  *   seq_no - sequence number of the request
509  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
510  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
511  *   backup - true to output only what's necessary for reconfiguring
512  *            a node.
513  */
514 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
515                              struct cYAML **err_rc, bool backup);
516
517 /*
518  * lustre_lnet_show_stats
519  *   Shows internal LNET statistics.  This is useful to display the
520  *   current LNET activity, such as number of messages route, etc
521  *
522  *     seq_no - sequence number of the command
523  *     show_rc - YAML structure of the resultant show
524  *     err_rc - YAML strucutre of the resultant return code.
525  */
526 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
527                            struct cYAML **err_rc);
528
529 /*
530  * lustre_lnet_modify_peer
531  *  Handle a peer config or delete operation.
532  *
533  *  Config Operation:
534  *  Add a peer NID to a peer with primary NID pnid. 
535  *  If the provided primary NID is unique, then a new peer is
536  *  created with this primary NID, and the NIDs in the NID list are added as
537  *  secondary NIDs to this new peer.
538  *  If any of the NIDs in the NID list are not unique then the operation
539  *  fails. Some peer NIDs might have already been added. It's the responsibility
540  *  of the caller of this API to remove the added NIDs if so desired.
541  *
542  *  Delete Operation:
543  *  Delete the NIDs given in the NID list from the peer with the primary NID
544  *  pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails,
545  *  and no change happens to the system.
546  *  The operation is aborted on the first NID that fails to be deleted.
547  *
548  *      prim_nid - The desired primary NID of a new peer, or the primary NID of
549  *                 an existing peer.
550  *      nids - a comma separated string of nids
551  *      is_mr - Specifies whether this peer is MR capable.
552  *      cmd - CONFIG or DELETE
553  *      seq_no - sequence number of the command
554  *      err_rc - YAML structure of the resultant return code
555  */
556 int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr,
557                             int cmd, int seq_no, struct cYAML **err_rc);
558
559 /*
560  * lustre_lnet_show_peer
561  *   Show the peer identified by nid, knid. If knid is NULL all
562  *   peers in the system are shown.
563  *
564  *     knid - A NID of the peer
565  *     detail - display detailed information
566  *     seq_no - sequence number of the command
567  *     show_rc - YAML structure of the resultant show
568  *     err_rc - YAML strucutre of the resultant return code.
569  *     backup - true to output only what's necessary for reconfiguring
570  *              a node.
571  *
572  */
573 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
574                           struct cYAML **show_rc, struct cYAML **err_rc,
575                           bool backup);
576
577 /*
578  * lustre_lnet_list_peer
579  *   List the known peers.
580  *
581  *     seq_no - sequence number of the command
582  *     show_rc - YAML structure of the resultant show
583  *     err_rc - YAML strucutre of the resultant return code.
584  *
585  */
586 int lustre_lnet_list_peer(int seq_no,
587                           struct cYAML **show_rc, struct cYAML **err_rc);
588
589 /* lustre_lnet_ping_nid
590  *   Ping the nid list, pnids.
591  *
592  *    pnids - NID list to ping.
593  *    timeout - timeout(seconds) for ping.
594  *    seq_no - sequence number of the command.
595  *    show_rc - YAML structure of the resultant show.
596  *    err_rc - YAML strucutre of the resultant return code.
597  *
598  */
599 int lustre_lnet_ping_nid(char *pnid, int timeout, int seq_no,
600                         struct cYAML **show_rc, struct cYAML **err_rc);
601
602 /* lustre_lnet_discover_nid
603  *   Discover the nid list, pnids.
604  *
605  *    pnids - NID list to discover.
606  *    force - force discovery.
607  *    seq_no - sequence number of the command.
608  *    show_rc - YAML structure of the resultant show.
609  *    err_rc - YAML strucutre of the resultant return code.
610  *
611  */
612 int lustre_lnet_discover_nid(char *pnid, int force, int seq_no,
613                              struct cYAML **show_rc, struct cYAML **err_rc);
614
615 /*
616  * lustre_yaml_config
617  *   Parses the provided YAML file and then calls the specific APIs
618  *   to configure 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_config(char *f, struct cYAML **err_rc);
624
625 /*
626  * lustre_yaml_del
627  *   Parses the provided YAML file and then calls the specific APIs
628  *   to delete the entities identified in the file
629  *
630  *   f - YAML file
631  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
632  */
633 int lustre_yaml_del(char *f, struct cYAML **err_rc);
634
635 /*
636  * lustre_yaml_show
637  *   Parses the provided YAML file and then calls the specific APIs
638  *   to show the entities identified in the file
639  *
640  *   f - YAML file
641  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
642  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
643  */
644 int lustre_yaml_show(char *f, struct cYAML **show_rc,
645                      struct cYAML **err_rc);
646
647 /*
648  * lustre_yaml_exec
649  *   Parses the provided YAML file and then calls the specific APIs
650  *   to execute the entities identified in the file
651  *
652  *   f - YAML file
653  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
654  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
655  */
656 int lustre_yaml_exec(char *f, struct cYAML **show_rc,
657                      struct cYAML **err_rc);
658
659 /*
660  * lustre_lnet_init_nw_descr
661  *      initialize the network descriptor structure for use
662  */
663 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
664
665 /*
666  * lustre_lnet_parse_interfaces
667  *      prase an interface string and populate descriptor structures
668  *              intf_str - interface string of the format
669  *                      <intf>[<expr>], <intf>[<expr>],..
670  *              nw_descr - network descriptor to populate
671  *              init - True to initialize nw_descr
672  */
673 int lustre_lnet_parse_interfaces(char *intf_str,
674                                  struct lnet_dlc_network_descr *nw_descr);
675
676 /*
677  * lustre_lnet_parse_nidstr
678  *     This is a small wrapper around cfs_parse_nidlist.
679  *         nidstr - A string parseable by cfs_parse_nidlist
680  *         lnet_nidlist - An array of lnet_nid_t to hold the nids specified
681  *                        by the nidstring.
682  *         max_nids - Size of the lnet_nidlist array, and the maximum number of
683  *                    nids that can be expressed by the nidstring. If the
684  *                    nidstring expands to a larger number of nids than max_nids
685  *                    then an error is returned.
686  *         err_str - char pointer where we store an informative error
687  *                   message when an error is encountered
688  *     Returns:
689  *         The number (> 0) of lnet_nid_t stored in the supplied array, or
690  *         LUSTRE_CFG_RC_BAD_PARAM if:
691  *           - nidstr is NULL
692  *           - nidstr contains an asterisk. This character is not allowed
693  *             because it would cause the size of the expanded nidlist to exceed
694  *             the maximum number of nids that is supported by expected callers
695  *             of this function.
696  *           - cfs_parse_nidlist fails to parse the nidstring
697  *           - The nidlist populated by cfs_parse_nidlist is empty
698  *           - The nidstring expands to a larger number of nids than max_nids
699  *           - The nidstring expands to zero nids
700  *         LUSTRE_CFG_RC_OUT_OF_MEM if:
701  *           - cfs_expand_nidlist can return ENOMEM. We return out of mem in
702  *             this case.
703  */
704 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
705                              int max_nids, char *err_str);
706
707 #endif /* LIB_LNET_CONFIG_API_H */