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
38 #define LUSTRE_CFG_RC_NO_MATCH -6
39 #define LUSTRE_CFG_RC_MATCH -7
41 #include <lnet/lnet.h>
42 #include <libcfs/util/string.h>
44 struct lnet_dlc_network_descr {
45 struct list_head network_on_rule;
47 struct list_head nw_intflist;
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;
56 /* forward declaration of the cYAML structure. */
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
64 int lustre_lnet_config_lib_init();
67 * lustre_lnet_config_lib_uninit
68 * Uninitialize the DLC Library
70 void lustre_lnet_config_lib_uninit();
73 * lustre_lnet_config_ni_system
74 * Initialize/Uninitialize the lnet NI system.
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
82 int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod,
83 int seq_no, struct cYAML **err_rc);
86 * lustre_lnet_config_route
87 * Send down an IOCTL to the kernel to configure the route
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
96 int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio,
97 int seq_no, struct cYAML **err_rc);
100 * lustre_lnet_del_route
101 * Send down an IOCTL to the kernel to delete a route
105 * seq_no - sequence number of the request
106 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
108 int lustre_lnet_del_route(char *nw, char *gw, int seq_no,
109 struct cYAML **err_rc);
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.
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
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);
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..
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
147 int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
148 struct cfs_expr_list *global_cpts,
150 struct lnet_ioctl_config_lnd_tunables *tunables,
151 int seq_no, struct cYAML **err_rc);
155 * Send down an IOCTL to delete a network interface. It implicitly
156 * deletes a network if it becomes empty of nis
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
162 int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw,
163 int seq_no, struct cYAML **err_rc);
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.
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
177 int lustre_lnet_show_net(char *nw, int detail, int seq_no,
178 struct cYAML **show_rc, struct cYAML **err_rc);
181 * lustre_lnet_enable_routing
182 * Send down an IOCTL to enable or diable routing
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
188 int lustre_lnet_enable_routing(int enable, int seq_no,
189 struct cYAML **err_rc);
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.
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
205 int lustre_lnet_config_numa_range(int range, int seq_no,
206 struct cYAML **err_rc);
209 * lustre_lnet_show_num_range
210 * Get the currently set NUMA range
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
217 int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
218 struct cYAML **err_rc);
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.
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
232 int lustre_lnet_config_buffers(int tiny, int small, int large,
233 int seq_no, struct cYAML **err_rc);
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.
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
244 int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
245 struct cYAML **err_rc);
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
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.
256 int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc,
257 struct cYAML **err_rc);
260 * lustre_lnet_config_peer_nid
261 * Add a peer nid to a peer with primary nid pnid. If no pnid is given
262 * then the first nid in the nid list becomes the primary nid for
263 * a newly created peer.
264 * Otherwise if pnid is provided and it's unique then a new peer is
265 * created with pnid as the primary NID and the nids in the nid list as
267 * If any of the peers nids provided in with exception to the pnid 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.
272 * pnid - Primary NID of the peer
273 * nid - list of nids to add
274 * num_nids - number of nids in the nid array
275 * mr - true if this peer is MR capable.
276 * seq_no - sequence number of the command
277 * err_rc - YAML strucutre of the resultant return code.
279 int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
280 bool mr, int seq_no, struct cYAML **err_rc);
283 * lustre_lnet_del_peer_nid
284 * Delete the nids given in the nid list from the peer with primary NID
285 * pnid. If pnid is NULL or it doesn't identify a peer the operation
286 * fails and no change happens to the system.
287 * The operation is aborted on the first NID that fails to be deleted.
289 * pnid - Primary NID of the peer
290 * nid - list of nids to add
291 * num_nids - number of nids in the nid array
292 * seq_no - sequence number of the command
293 * err_rc - YAML strucutre of the resultant return code.
295 int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids,
296 int seq_no, struct cYAML **err_rc);
299 * lustre_lnet_show_peer
300 * Show the peer identified by nid, knid. If knid is NULL all
301 * peers in the system are shown.
303 * knid - A NID of the peer
304 * detail - display detailed information
305 * seq_no - sequence number of the command
306 * show_rc - YAML structure of the resultant show
307 * err_rc - YAML strucutre of the resultant return code.
310 int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
311 struct cYAML **show_rc, struct cYAML **err_rc);
315 * Parses the provided YAML file and then calls the specific APIs
316 * to configure the entities identified in the file
319 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
321 int lustre_yaml_config(char *f, struct cYAML **err_rc);
325 * Parses the provided YAML file and then calls the specific APIs
326 * to delete the entities identified in the file
329 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
331 int lustre_yaml_del(char *f, struct cYAML **err_rc);
335 * Parses the provided YAML file and then calls the specific APIs
336 * to show the entities identified in the file
339 * show_rc - [OUT] The show output in YAML. Must be freed by caller.
340 * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
342 int lustre_yaml_show(char *f, struct cYAML **show_rc,
343 struct cYAML **err_rc);
346 * lustre_lnet_init_nw_descr
347 * initialize the network descriptor structure for use
349 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr);
352 * lustre_lnet_parse_interfaces
353 * prase an interface string and populate descriptor structures
354 * intf_str - interface string of the format
355 * <intf>[<expr>], <intf>[<expr>],..
356 * nw_descr - network descriptor to populate
357 * init - True to initialize nw_descr
359 int lustre_lnet_parse_interfaces(char *intf_str,
360 struct lnet_dlc_network_descr *nw_descr);
363 * lustre_lnet_parse_nids
364 * Parse a set of nids into a locally allocated array and return the
365 * pointer of the array to the caller. The caller is responsible for
366 * freeing the array. If an initial array is provided then copy over
367 * the contents of that array into the new array and append to it the
369 * The nids can be of the form "nid [,nid, nid, nid]"
370 * nids: nids string to be parsed
371 * array: initial array of content
372 * size: num of elements in the array
373 * out_array: [OUT] new allocated array.
374 * Returns size of array
375 * sets the out_array to NULL on failure.
377 int lustre_lnet_parse_nids(char *nids, char **array, int size,
380 #endif /* LIB_LNET_CONFIG_API_H */