4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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.
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/>.
21 * Copyright (c) 2014, 2016, Intel Corporation.
24 * Amir Shehata <amir.shehata@intel.com>
27 #ifndef LIB_LNET_CONFIG_API_H
28 #define LIB_LNET_CONFIG_API_H
30 #include <lnet/lnet.h>
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
39 /* forward declaration of the cYAML structure. */
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
47 int lustre_lnet_config_lib_init();
50 * lustre_lnet_config_ni_system
51 * Initialize/Uninitialize the lnet NI system.
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
59 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
60 int seq_no, struct cYAML **err_rc);
63 * lustre_lnet_config_route
64 * Send down an IOCTL to the kernel to configure the route
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
73 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
74 int seq_no, struct cYAML **err_rc);
77 * lustre_lnet_del_route
78 * Send down an IOCTL to the kernel to delete a route
82 * seq_no - sequence number of the request
83 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
85 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
86 struct cYAML **err_rc);
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.
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
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);
111 * lustre_lnet_config_net
112 * Send down an IOCTL to configure a network.
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
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
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);
135 * lustre_lnet_del_net
136 * Send down an IOCTL to delete a network.
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
142 int lustre_lnet_del_net(char *nw, int seq_no,
143 struct cYAML **err_rc);
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.
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
157 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
158 struct cYAML **show_rc, struct cYAML **err_rc);
161 * lustre_lnet_enable_routing
162 * Send down an IOCTL to enable or diable routing
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
168 int lustre_lnet_enable_routing(int enable, int seq_no,
169 struct cYAML **err_rc);
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.
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
183 int lustre_lnet_config_buffers(int tiny, int small, int large,
184 int seq_no, struct cYAML **err_rc);
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.
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
195 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
196 struct cYAML **err_rc);
199 * lustre_lnet_show_stats
200 * Shows internal LNET statistics. This is useful to display the
201 * current LNET activity, such as number of messages route, etc
203 * seq_no - sequence number of the command
204 * show_rc - YAML structure of the resultant show
205 * err_rc - YAML strucutre of the resultant return code.
207 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
208 struct cYAML **err_rc);
211 * lustre_lnet_config_peer_nid
212 * Add a peer nid to an peer identified by knid. If no knid is given
213 * then the first nid in the nid list becomes the primary nid for
214 * a newly created peer.
215 * Otherwise if knid is provided an it's unique then a new peer is
216 * created with knid as the primary NID and the nids in the nid list as
218 * If any of the peers nids provided in with exception to the knid is
219 * not unique the operation fails. Some peer nids might have already
220 * been added. It's the role of the caller of this API to remove the
221 * added NIDs if they wish.
223 * knid - Key NID of the peer
224 * nid - list of nids to add
225 * seq_no - sequence number of the command
226 * err_rc - YAML strucutre of the resultant return code.
228 int lustre_lnet_config_peer_nid(char *knid, char **nid, int seq_no,
229 struct cYAML **err_rc);
232 * lustre_lnet_del_peer_nid
233 * Delete the nids identified in the nid list from the peer identified by
234 * knid. If knid is NULL or it doesn't identify a peer the operation
235 * fails and no change happens to the system.
236 * The operation is aborted on the first NID that fails to be deleted.
238 * knid - Key NID of the peer
239 * nid - list of nids to add
240 * seq_no - sequence number of the command
241 * err_rc - YAML strucutre of the resultant return code.
243 int lustre_lnet_del_peer_nid(char *knid, char **nid, int seq_no,
244 struct cYAML **err_rc);
247 * lustre_lnet_show_peer
248 * Show the peer identified by knid. If knid is NULL all peers in the
251 * knid - Key NID of the peer
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.
257 int lustre_lnet_show_peer(char *knid, int seq_no, struct cYAML **show_rc,
258 struct cYAML **err_rc);
262 * Parses the provided YAML file and then calls the specific APIs
263 * to configure the entities identified in the file
266 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
268 int lustre_yaml_config(char *f, struct cYAML **err_rc);
272 * Parses the provided YAML file and then calls the specific APIs
273 * to delete the entities identified in the file
276 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
278 int lustre_yaml_del(char *f, struct cYAML **err_rc);
282 * Parses the provided YAML file and then calls the specific APIs
283 * to show the entities identified in the file
286 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
287 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
289 int lustre_yaml_show(char *f, struct cYAML **show_rc,
290 struct cYAML **err_rc);
292 #endif /* LIB_LNET_CONFIG_API_H */