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