Whamcloud - gitweb
LU-7734 lnet: handle non-MR peers
[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, 2016, 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 <lnet/lnet.h>
31
32 #define LUSTRE_CFG_RC_NO_ERR                     0
33 #define LUSTRE_CFG_RC_BAD_PARAM                 -1
34 #define LUSTRE_CFG_RC_MISSING_PARAM             -2
35 #define LUSTRE_CFG_RC_OUT_OF_RANGE_PARAM        -3
36 #define LUSTRE_CFG_RC_OUT_OF_MEM                -4
37 #define LUSTRE_CFG_RC_GENERIC_ERR               -5
38 #define LUSTRE_CFG_RC_NO_MATCH                  -6
39 #define LUSTRE_CFG_RC_MATCH                     -7
40
41 #include <lnet/lnet.h>
42 #include <libcfs/libcfs_string.h>
43
44 struct lnet_dlc_network_descr {
45         struct list_head network_on_rule;
46         __u32 nw_id;
47         struct list_head nw_intflist;
48 };
49
50 struct lnet_dlc_intf_descr {
51         struct list_head intf_on_network;
52         char intf_name[LNET_MAX_STR_LEN];
53         struct cfs_expr_list *cpt_expr;
54 };
55
56 /* forward declaration of the cYAML structure. */
57 struct cYAML;
58
59 /*
60  * lustre_lnet_config_lib_init()
61  *   Initialize the Library to enable communication with the LNET kernel
62  *   module.  Returns the device ID or -EINVAL if there is an error
63  */
64 int lustre_lnet_config_lib_init();
65
66 /*
67  * lustre_lnet_config_lib_uninit
68  *      Uninitialize the DLC Library
69  */
70 void lustre_lnet_config_lib_uninit();
71
72 /*
73  * lustre_lnet_config_ni_system
74  *   Initialize/Uninitialize the lnet NI system.
75  *
76  *   up - whehter to init or uninit the system
77  *   load_ni_from_mod - load NI from mod params.
78  *   seq_no - sequence number of the request
79  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
80  *            caller
81  */
82 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
83                                  int seq_no, struct cYAML **err_rc);
84
85 /*
86  * lustre_lnet_config_route
87  *   Send down an IOCTL to the kernel to configure the route
88  *
89  *   nw - network
90  *   gw - gateway
91  *   hops - number of hops passed down by the user
92  *   prio - priority of the route
93  *   seq_no - sequence number of the request
94  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
95  */
96 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
97                              int seq_no, struct cYAML **err_rc);
98
99 /*
100  * lustre_lnet_del_route
101  *   Send down an IOCTL to the kernel to delete a route
102  *
103  *   nw - network
104  *   gw - gateway
105  *   seq_no - sequence number of the request
106  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
107  */
108 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
109                           struct cYAML **err_rc);
110
111 /*
112  * lustre_lnet_show_route
113  *   Send down an IOCTL to the kernel to show routes
114  *   This function will get one route at a time and filter according to
115  *   provided parameters. If no routes are available then it will dump all
116  *   routes that are in the system.
117  *
118  *   nw - network.  Optional.  Used to filter output
119  *   gw - gateway. Optional. Used to filter ouptut
120  *   hops - number of hops passed down by the user
121  *          Optional.  Used to filter output.
122  *   prio - priority of the route.  Optional.  Used to filter output.
123  *   detail - flag to indicate whether detail output is required
124  *   seq_no - sequence number of the request
125  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
126  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
127  */
128 int lustre_lnet_show_route(char *nw, char *gw,
129                            int hops, int prio, int detail,
130                            int seq_no, struct cYAML **show_rc,
131                            struct cYAML **err_rc);
132
133 /*
134  * lustre_lnet_config_ni
135  *   Send down an IOCTL to configure a network interface. It implicitly
136  *   creates a network if one doesn't exist..
137  *
138  *   nw_descr - network and interface descriptor
139  *   global_cpts - globally defined CPTs
140  *   ip2net - this parameter allows configuring multiple networks.
141  *      it takes precedence over the net and intf parameters
142  *   tunables - LND tunables
143  *   seq_no - sequence number of the request
144  *   lnd_tunables - lnet specific tunable parameters
145  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
146  */
147 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
148                           struct cfs_expr_list *global_cpts,
149                           char *ip2net,
150                           struct lnet_ioctl_config_lnd_tunables *tunables,
151                           int seq_no, struct cYAML **err_rc);
152
153 /*
154  * lustre_lnet_del_ni
155  *   Send down an IOCTL to delete a network interface. It implicitly
156  *   deletes a network if it becomes empty of nis
157  *
158  *   nw  - network and interface list
159  *   seq_no - sequence number of the request
160  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
161  */
162 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
163                        int seq_no, struct cYAML **err_rc);
164
165 /*
166  * lustre_lnet_show_net
167  *   Send down an IOCTL to show networks.
168  *   This function will use the nw paramter to filter the output.  If it's
169  *   not provided then all networks are listed.
170  *
171  *   nw - network to show.  Optional.  Used to filter output.
172  *   detail - flag to indicate if we require detail output.
173  *   seq_no - sequence number of the request
174  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
175  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
176  */
177 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
178                          struct cYAML **show_rc, struct cYAML **err_rc);
179
180 /*
181  * lustre_lnet_enable_routing
182  *   Send down an IOCTL to enable or diable routing
183  *
184  *   enable - 1 to enable routing, 0 to disable routing
185  *   seq_no - sequence number of the request
186  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
187  */
188 int lustre_lnet_enable_routing(int enable, int seq_no,
189                                struct cYAML **err_rc);
190
191 /*
192  * lustre_lnet_config_numa_range
193  *   Set the NUMA range which impacts the NIs to be selected
194  *   during sending. If the NUMA range is large the NUMA
195  *   distance between the message memory and the NI becomes
196  *   less significant. The NUMA range is a relative number
197  *   with no other meaning besides allowing a wider breadth
198  *   for picking an NI to send from.
199  *
200  *   range - numa range value.
201  *   seq_no - sequence number of the request
202  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
203  *   caller
204  */
205 int lustre_lnet_config_numa_range(int range, int seq_no,
206                                   struct cYAML **err_rc);
207
208 /*
209  * lustre_lnet_show_num_range
210  *   Get the currently set NUMA range
211  *
212  *   seq_no - sequence number of the request
213  *   show_rc - [OUT] struct cYAML tree containing NUMA range info
214  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
215  *   caller
216  */
217 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
218                                 struct cYAML **err_rc);
219
220 /*
221  * lustre_lnet_config_buffers
222  *   Send down an IOCTL to configure routing buffer sizes.  A value of 0 means
223  *   default that particular buffer to default size. A value of -1 means
224  *   leave the value of the buffer un changed.
225  *
226  *   tiny - tiny buffers
227  *   small - small buffers
228  *   large - large buffers.
229  *   seq_no - sequence number of the request
230  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
231  */
232 int lustre_lnet_config_buffers(int tiny, int small, int large,
233                                int seq_no, struct cYAML **err_rc);
234
235 /*
236  * lustre_lnet_show_routing
237  *   Send down an IOCTL to dump buffers and routing status
238  *   This function is used to dump buffers for all CPU partitions.
239  *
240  *   seq_no - sequence number of the request
241  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
242  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
243  */
244 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
245                              struct cYAML **err_rc);
246
247 /*
248  * lustre_lnet_show_stats
249  *   Shows internal LNET statistics.  This is useful to display the
250  *   current LNET activity, such as number of messages route, etc
251  *
252  *     seq_no - sequence number of the command
253  *     show_rc - YAML structure of the resultant show
254  *     err_rc - YAML strucutre of the resultant return code.
255  */
256 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
257                            struct cYAML **err_rc);
258
259 /*
260  * lustre_lnet_config_peer_nid
261  *   Add a peer nid to an peer identified by knid. If no knid is given
262  *   then the first nid in the nid list becomes the primary nid for
263  *   a newly created peer.
264  *   Otherwise if knid is provided an it's unique then a new peer is
265  *   created with knid as the primary NID and the nids in the nid list as
266  *   secondary nids.
267  *   If any of the peers nids provided in with exception to the knid is
268  *   not unique the operation fails. Some peer nids might have already
269  *   been added. It's the role of the caller of this API to remove the
270  *   added NIDs if they wish.
271  *
272  *     knid - Key NID of the peer
273  *     nid - list of nids to add
274  *     mr - true if this peer is MR capable.
275  *     seq_no - sequence number of the command
276  *     err_rc - YAML strucutre of the resultant return code.
277  */
278 int lustre_lnet_config_peer_nid(char *knid, char **nid, bool mr, int seq_no,
279                                 struct cYAML **err_rc);
280
281 /*
282  * lustre_lnet_del_peer_nid
283  *  Delete the nids identified in the nid list from the peer identified by
284  *  knid. If knid is NULL or it doesn't identify a peer the operation
285  *  fails and no change happens to the system.
286  *  The operation is aborted on the first NID that fails to be deleted.
287  *
288  *     knid - Key NID of the peer
289  *     nid - list of nids to add
290  *     seq_no - sequence number of the command
291  *     err_rc - YAML strucutre of the resultant return code.
292  */
293 int lustre_lnet_del_peer_nid(char *knid, char **nid, int seq_no,
294                              struct cYAML **err_rc);
295
296 /*
297  * lustre_lnet_show_peer
298  *   Show the peer identified by knid. If knid is NULL all peers in the
299  *   system are shown.
300  *
301  *     knid - Key NID of the peer
302  *     seq_no - sequence number of the command
303  *     show_rc - YAML structure of the resultant show
304  *     err_rc - YAML strucutre of the resultant return code.
305  *
306  */
307 int lustre_lnet_show_peer(char *knid, int seq_no, struct cYAML **show_rc,
308                           struct cYAML **err_rc);
309
310 /*
311  * lustre_yaml_config
312  *   Parses the provided YAML file and then calls the specific APIs
313  *   to configure the entities identified in the file
314  *
315  *   f - YAML file
316  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
317  */
318 int lustre_yaml_config(char *f, struct cYAML **err_rc);
319
320 /*
321  * lustre_yaml_del
322  *   Parses the provided YAML file and then calls the specific APIs
323  *   to delete the entities identified in the file
324  *
325  *   f - YAML file
326  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
327  */
328 int lustre_yaml_del(char *f, struct cYAML **err_rc);
329
330 /*
331  * lustre_yaml_show
332  *   Parses the provided YAML file and then calls the specific APIs
333  *   to show the entities identified in the file
334  *
335  *   f - YAML file
336  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
337  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
338  */
339 int lustre_yaml_show(char *f, struct cYAML **show_rc,
340                      struct cYAML **err_rc);
341
342 /*
343  * lustre_lnet_init_nw_descr
344  *      initialize the network descriptor structure for use
345  */
346 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
347
348 /*
349  * lustre_lnet_parse_interfaces
350  *      prase an interface string and populate descriptor structures
351  *              intf_str - interface string of the format
352  *                      <intf>[<expr>], <intf>[<expr>],..
353  *              nw_descr - network descriptor to populate
354  *              init - True to initialize nw_descr
355  */
356 int lustre_lnet_parse_interfaces(char *intf_str,
357                                  struct lnet_dlc_network_descr *nw_descr);
358
359 /*
360  * lustre_lnet_send_dbg_task
361  *      send a debug task to be carried out in the kernel. This API will
362  *      not be exposed to the user through lnetctl utility. It can only be
363  *      executed by being called directly.
364  *              dbg_task: The task to be carried out
365  *              dbg_info: task specific information
366  */
367 int lustre_lnet_send_dbg_task(enum lnet_dbg_task dbg_task,
368                               struct lnet_dbg_task_info *dbg_info,
369                               struct cYAML **show_rc,
370                               struct cYAML **err_rc);
371
372 #endif /* LIB_LNET_CONFIG_API_H */