Whamcloud - gitweb
LU-7101 lnet: per NI map-on-demand value
[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, 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
39 /* forward declaration of the cYAML structure. */
40 struct cYAML;
41
42 /*
43  * lustre_lnet_config_lib_init()
44  *   Initialize the Library to enable communication with the LNET kernel
45  *   module.  Returns the device ID or -EINVAL if there is an error
46  */
47 int lustre_lnet_config_lib_init();
48
49 /*
50  * lustre_lnet_config_ni_system
51  *   Initialize/Uninitialize the lnet NI system.
52  *
53  *   up - whehter to init or uninit the system
54  *   load_ni_from_mod - load NI from mod params.
55  *   seq_no - sequence number of the request
56  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by
57  *            caller
58  */
59 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
60                                  int seq_no, struct cYAML **err_rc);
61
62 /*
63  * lustre_lnet_config_route
64  *   Send down an IOCTL to the kernel to configure the route
65  *
66  *   nw - network
67  *   gw - gateway
68  *   hops - number of hops passed down by the user
69  *   prio - priority of the route
70  *   seq_no - sequence number of the request
71  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
72  */
73 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
74                              int seq_no, struct cYAML **err_rc);
75
76 /*
77  * lustre_lnet_del_route
78  *   Send down an IOCTL to the kernel to delete a route
79  *
80  *   nw - network
81  *   gw - gateway
82  *   seq_no - sequence number of the request
83  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
84  */
85 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
86                           struct cYAML **err_rc);
87
88 /*
89  * lustre_lnet_show_route
90  *   Send down an IOCTL to the kernel to show routes
91  *   This function will get one route at a time and filter according to
92  *   provided parameters. If no routes are available then it will dump all
93  *   routes that are in the system.
94  *
95  *   nw - network.  Optional.  Used to filter output
96  *   gw - gateway. Optional. Used to filter ouptut
97  *   hops - number of hops passed down by the user
98  *          Optional.  Used to filter output.
99  *   prio - priority of the route.  Optional.  Used to filter output.
100  *   detail - flag to indicate whether detail output is required
101  *   seq_no - sequence number of the request
102  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
103  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
104  */
105 int lustre_lnet_show_route(char *nw, char *gw,
106                            int hops, int prio, int detail,
107                            int seq_no, struct cYAML **show_rc,
108                            struct cYAML **err_rc);
109
110 /*
111  * lustre_lnet_config_net
112  *   Send down an IOCTL to configure a network.
113  *
114  *   net - the network name
115  *   intf - the interface of the network of the form net_name(intf)
116  *   ip2net - this parameter allows configuring multiple networks.
117  *      it takes precedence over the net and intf parameters
118  *   peer_to - peer timeout
119  *   peer_cr - peer credit
120  *   peer_buf_cr - peer buffer credits
121  *       - the above are LND tunable parameters and are optional
122  *   credits - network interface credits
123  *   smp - cpu affinity
124  *   seq_no - sequence number of the request
125  *   lnd_tunables - lnet specific tunable parameters
126  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
127  */
128 int lustre_lnet_config_net(char *net, char *intf, char *ip2net,
129                            int peer_to, int peer_cr, int peer_buf_cr,
130                            int credits, char *smp, int seq_no,
131                            struct lnet_ioctl_config_lnd_tunables *lnd_tunables,
132                            struct cYAML **err_rc);
133
134 /*
135  * lustre_lnet_del_net
136  *   Send down an IOCTL to delete a network.
137  *
138  *   nw - network to delete.
139  *   seq_no - sequence number of the request
140  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
141  */
142 int lustre_lnet_del_net(char *nw, int seq_no,
143                         struct cYAML **err_rc);
144
145 /*
146  * lustre_lnet_show_net
147  *   Send down an IOCTL to show networks.
148  *   This function will use the nw paramter to filter the output.  If it's
149  *   not provided then all networks are listed.
150  *
151  *   nw - network to show.  Optional.  Used to filter output.
152  *   detail - flag to indicate if we require detail output.
153  *   seq_no - sequence number of the request
154  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
155  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
156  */
157 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
158                          struct cYAML **show_rc, struct cYAML **err_rc);
159
160 /*
161  * lustre_lnet_enable_routing
162  *   Send down an IOCTL to enable or diable routing
163  *
164  *   enable - 1 to enable routing, 0 to disable routing
165  *   seq_no - sequence number of the request
166  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
167  */
168 int lustre_lnet_enable_routing(int enable, int seq_no,
169                                struct cYAML **err_rc);
170
171 /*
172  * lustre_lnet_config_buffers
173  *   Send down an IOCTL to configure routing buffer sizes.  A value of 0 means
174  *   default that particular buffer to default size. A value of -1 means
175  *   leave the value of the buffer un changed.
176  *
177  *   tiny - tiny buffers
178  *   small - small buffers
179  *   large - large buffers.
180  *   seq_no - sequence number of the request
181  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
182  */
183 int lustre_lnet_config_buffers(int tiny, int small, int large,
184                                int seq_no, struct cYAML **err_rc);
185
186 /*
187  * lustre_lnet_show_routing
188  *   Send down an IOCTL to dump buffers and routing status
189  *   This function is used to dump buffers for all CPU partitions.
190  *
191  *   seq_no - sequence number of the request
192  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
193  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
194  */
195 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
196                              struct cYAML **err_rc);
197
198 /*
199  * lustre_lnet_show_peer_credits
200  *   Shows credit details on the peers in the system
201  *
202  *     seq_no - sequence number of the command
203  *     show_rc - YAML structure of the resultant show
204  *     err_rc - YAML strucutre of the resultant return code.
205  */
206 int lustre_lnet_show_peer_credits(int seq_no, struct cYAML **show_rc,
207                                   struct cYAML **err_rc);
208
209 /*
210  * lustre_lnet_show_stats
211  *   Shows internal LNET statistics.  This is useful to display the
212  *   current LNET activity, such as number of messages route, etc
213  *
214  *     seq_no - sequence number of the command
215  *     show_rc - YAML structure of the resultant show
216  *     err_rc - YAML strucutre of the resultant return code.
217  */
218 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
219                            struct cYAML **err_rc);
220
221 /*
222  * lustre_yaml_config
223  *   Parses the provided YAML file and then calls the specific APIs
224  *   to configure the entities identified in the file
225  *
226  *   f - YAML file
227  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
228  */
229 int lustre_yaml_config(char *f, struct cYAML **err_rc);
230
231 /*
232  * lustre_yaml_del
233  *   Parses the provided YAML file and then calls the specific APIs
234  *   to delete the entities identified in the file
235  *
236  *   f - YAML file
237  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
238  */
239 int lustre_yaml_del(char *f, struct cYAML **err_rc);
240
241 /*
242  * lustre_yaml_show
243  *   Parses the provided YAML file and then calls the specific APIs
244  *   to show the entities identified in the file
245  *
246  *   f - YAML file
247  *   show_rc - [OUT] The show output in YAML.  Must be freed by caller.
248  *   err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
249  */
250 int lustre_yaml_show(char *f, struct cYAML **show_rc,
251                      struct cYAML **err_rc);
252
253 #endif /* LIB_LNET_CONFIG_API_H */