Whamcloud - gitweb
LU-10003 lnet: migrate lnet setup and tear down to Netlink
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnet-dlc.h
1 /*
2  * LGPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but 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.
18  *
19  * LGPL HEADER END
20  *
21  */
22 /*
23  * Copyright (c) 2014, 2017, Intel Corporation.
24  */
25 /*
26  * Author: Amir Shehata <amir.shehata@intel.com>
27  */
28
29 #ifndef __UAPI_LNET_DLC_H_
30 #define __UAPI_LNET_DLC_H_
31
32 #include <linux/types.h>
33 #include <linux/lnet/libcfs_ioctl.h>
34 #include <linux/lnet/lnet-types.h>
35
36 #define MAX_NUM_SHOW_ENTRIES    32
37 #define LNET_MAX_STR_LEN        128
38 #define LNET_MAX_SHOW_NUM_CPT   128
39 #define LNET_MAX_SHOW_NUM_NID   128
40 #define LNET_UNDEFINED_HOPS     ((__u32) -1)
41
42 #define LNET_RT_ALIVE           (1 << 0)
43 #define LNET_RT_MULTI_HOP       (1 << 1)
44
45 /*
46  * sparse kernel source annotations
47  */
48 #ifndef __user
49 #define __user
50 #endif
51
52 #define LNET_GENL_NAME          "lnet"
53 #define LNET_GENL_VERSION       0x05
54
55 /* enum lnet_commands         - Supported core LNet Netlink commands
56  *
57  * @LNET_CMD_UNSPEC:            unspecified command to catch errors
58  *
59  * @LNET_CMD_CONFIGURE:         command to setup LNet stack
60  * @LNET_CMD_NETS:              command to manage the LNet networks
61  * @LNET_CMD_ROUTES:            command to manage LNet routes
62  * @LNET_CMD_PING:              command to send pings to LNet connections
63  * @LNET_CMD_CPT_OF_NID:        command to calculate the CPT of specified NIDs
64  */
65 enum lnet_commands {
66         LNET_CMD_UNSPEC         = 0,
67
68         LNET_CMD_CONFIGURE      = 1,
69         LNET_CMD_NETS           = 2,
70         LNET_CMD_PEERS          = 3,
71         LNET_CMD_ROUTES         = 4,
72         LNET_CMD_CONNS          = 5,
73         LNET_CMD_PING           = 6,
74         LNET_CMD_CPT_OF_NID     = 7,
75         LNET_CMD_PEER_DIST      = 8,
76
77         __LNET_CMD_MAX_PLUS_ONE
78 };
79
80 #define LNET_CMD_MAX (__LNET_CMD_MAX_PLUS_ONE - 1)
81
82 /*
83  * To allow for future enhancements to extend the tunables
84  * add a hdr to this structure, so that the version can be set
85  * and checked for backwards compatibility. Newer versions of LNet
86  * can still work with older versions of lnetctl. The restriction is
87  * that the structure can be added to and not removed from in order
88  * to not invalidate older lnetctl utilities. Moreover, the order of
89  * fields must remain the same, and new fields appended to the structure
90  *
91  * That said all existing LND tunables will be added in this structure
92  * to avoid future changes.
93  */
94 struct lnet_ioctl_config_lnd_cmn_tunables {
95         __u32 lct_version;
96         __s32 lct_peer_timeout;
97         __s32 lct_peer_tx_credits;
98         __s32 lct_peer_rtr_credits;
99         __s32 lct_max_tx_credits;
100 };
101
102 struct lnet_ioctl_config_o2iblnd_tunables {
103         __u32 lnd_version;
104         __u32 lnd_peercredits_hiw;
105         __u32 lnd_map_on_demand;
106         __u32 lnd_concurrent_sends;
107         __u32 lnd_fmr_pool_size;
108         __u32 lnd_fmr_flush_trigger;
109         __u32 lnd_fmr_cache;
110         __u16 lnd_conns_per_peer;
111         __u16 lnd_ntx;
112         __u32 lnd_timeout;
113 };
114
115 struct lnet_ioctl_config_kfilnd_tunables {
116         __u32 lnd_version;
117         __u32 lnd_prov_major_version;
118         __u32 lnd_prov_minor_version;
119         __u32 lnd_auth_key;
120         char lnd_traffic_class_str[LNET_MAX_STR_LEN];
121         __u32 lnd_traffic_class;
122 };
123
124 struct lnet_ioctl_config_socklnd_tunables {
125         __u32 lnd_version;
126         __u16 lnd_conns_per_peer;
127         __u16 lnd_pad;
128         __u32 lnd_timeout;
129 };
130
131 struct lnet_ioctl_config_gnilnd_tunables {
132         __u32 lnd_version;
133         __u32 lnd_timeout;
134 };
135
136 struct lnet_lnd_tunables {
137         union {
138                 struct lnet_ioctl_config_o2iblnd_tunables lnd_o2ib;
139                 struct lnet_ioctl_config_socklnd_tunables lnd_sock;
140                 struct lnet_ioctl_config_kfilnd_tunables lnd_kfi;
141                 struct lnet_ioctl_config_gnilnd_tunables lnd_gni;
142         } lnd_tun_u;
143 };
144
145 struct lnet_ioctl_config_lnd_tunables {
146         struct lnet_ioctl_config_lnd_cmn_tunables lt_cmn;
147         struct lnet_lnd_tunables lt_tun;
148 };
149
150 struct lnet_ioctl_net_config {
151         char ni_interface[LNET_MAX_STR_LEN];
152         __u32 ni_status;
153         __u32 ni_cpts[LNET_MAX_SHOW_NUM_CPT];
154         char cfg_bulk[0];
155 };
156
157 #define LNET_TINY_BUF_IDX       0
158 #define LNET_SMALL_BUF_IDX      1
159 #define LNET_LARGE_BUF_IDX      2
160
161 /* # different router buffer pools */
162 #define LNET_NRBPOOLS           (LNET_LARGE_BUF_IDX + 1)
163
164 struct lnet_ioctl_pool_cfg {
165         struct {
166                 __u32 pl_npages;
167                 __u32 pl_nbuffers;
168                 __u32 pl_credits;
169                 __u32 pl_mincredits;
170         } pl_pools[LNET_NRBPOOLS];
171         __u32 pl_routing;
172 };
173
174 struct lnet_ioctl_ping_data {
175         struct libcfs_ioctl_hdr ping_hdr;
176
177         __u32 op_param;
178         __u32 ping_count;
179         __u32 ping_flags;
180         __u32 mr_info;
181         struct lnet_process_id ping_id;
182         struct lnet_process_id __user *ping_buf;
183         lnet_nid_t ping_src;
184 };
185
186 struct lnet_ioctl_config_data {
187         struct libcfs_ioctl_hdr cfg_hdr;
188
189         __u32 cfg_net;
190         __u32 cfg_count;
191         __u64 cfg_nid;
192         __u32 cfg_ncpts;
193
194         union {
195                 struct {
196                         __u32 rtr_hop;
197                         __u32 rtr_priority;
198                         __u32 rtr_flags;
199                         __u32 rtr_sensitivity;
200                 } cfg_route;
201                 struct {
202                         char net_intf[LNET_MAX_STR_LEN];
203                         __s32 net_peer_timeout;
204                         __s32 net_peer_tx_credits;
205                         __s32 net_peer_rtr_credits;
206                         __s32 net_max_tx_credits;
207                         __u32 net_cksum_algo;
208                         __u32 net_interface_count;
209                 } cfg_net;
210                 struct {
211                         __u32 buf_enable;
212                         __s32 buf_tiny;
213                         __s32 buf_small;
214                         __s32 buf_large;
215                 } cfg_buffers;
216         } cfg_config_u;
217
218         char cfg_bulk[0];
219 };
220
221 struct lnet_ioctl_comm_count {
222         __u32 ico_get_count;
223         __u32 ico_put_count;
224         __u32 ico_reply_count;
225         __u32 ico_ack_count;
226         __u32 ico_hello_count;
227 };
228
229 struct lnet_ioctl_element_stats {
230         __u32 iel_send_count;
231         __u32 iel_recv_count;
232         __u32 iel_drop_count;
233 };
234
235 enum lnet_health_type {
236         LNET_HEALTH_TYPE_LOCAL_NI = 0,
237         LNET_HEALTH_TYPE_PEER_NI,
238 };
239
240 struct lnet_ioctl_local_ni_hstats {
241         struct libcfs_ioctl_hdr hlni_hdr;
242         lnet_nid_t hlni_nid;
243         __u32 hlni_local_interrupt;
244         __u32 hlni_local_dropped;
245         __u32 hlni_local_aborted;
246         __u32 hlni_local_no_route;
247         __u32 hlni_local_timeout;
248         __u32 hlni_local_error;
249         __s32 hlni_fatal_error;
250         __s32 hlni_health_value;
251         __u32 hlni_ping_count;
252         __u64 hlni_next_ping;
253 };
254
255 struct lnet_ioctl_peer_ni_hstats {
256         __u32 hlpni_remote_dropped;
257         __u32 hlpni_remote_timeout;
258         __u32 hlpni_remote_error;
259         __u32 hlpni_network_timeout;
260         __s32 hlpni_health_value;
261         __u32 hlpni_ping_count;
262         __u64 hlpni_next_ping;
263 };
264
265 struct lnet_ioctl_element_msg_stats {
266         struct libcfs_ioctl_hdr im_hdr;
267         __u32 im_idx;
268         struct lnet_ioctl_comm_count im_send_stats;
269         struct lnet_ioctl_comm_count im_recv_stats;
270         struct lnet_ioctl_comm_count im_drop_stats;
271 };
272
273 /*
274  * lnet_ioctl_config_ni
275  *  This structure describes an NI configuration. There are multiple components
276  *  when configuring an NI: Net, Interfaces, CPT list and LND tunables
277  *  A network is passed as a string to the DLC and translated using
278  *  libcfs_str2net()
279  *  An interface is the name of the system configured interface
280  *  (ex eth0, ib1)
281  *  CPT is the list of CPTS LND tunables are passed in the lic_bulk area
282  */
283 struct lnet_ioctl_config_ni {
284         struct libcfs_ioctl_hdr lic_cfg_hdr;
285         lnet_nid_t              lic_nid;
286         char                    lic_ni_intf[LNET_MAX_STR_LEN];
287         char                    lic_legacy_ip2nets[LNET_MAX_STR_LEN];
288         __u32                   lic_cpts[LNET_MAX_SHOW_NUM_CPT];
289         __u32                   lic_ncpts;
290         __u32                   lic_status;
291         __u32                   lic_idx;
292         __s32                   lic_dev_cpt;
293         char                    pad[4];
294         char                    lic_bulk[0];
295 };
296
297 struct lnet_peer_ni_credit_info {
298         char cr_aliveness[LNET_MAX_STR_LEN];
299         __u32 cr_refcount;
300         __s32 cr_ni_peer_tx_credits;
301         __s32 cr_peer_tx_credits;
302         __s32 cr_peer_min_tx_credits;
303         __u32 cr_peer_tx_qnob;
304         __s32 cr_peer_rtr_credits;
305         __s32 cr_peer_min_rtr_credits;
306         __u32 cr_ncpt;
307 };
308
309 struct lnet_ioctl_peer {
310         struct libcfs_ioctl_hdr pr_hdr;
311         __u32 pr_count;
312         __u32 pr_pad;
313         lnet_nid_t pr_nid;
314
315         union {
316                 struct lnet_peer_ni_credit_info  pr_peer_credits;
317         } pr_lnd_u;
318 };
319
320 struct lnet_ioctl_peer_cfg {
321         struct libcfs_ioctl_hdr prcfg_hdr;
322         lnet_nid_t prcfg_prim_nid;
323         lnet_nid_t prcfg_cfg_nid;
324         __u32 prcfg_count;      /* ADD_PEER_NI: used for 'lock_prim' option
325                                  * DEL_PEER_NI: used for 'force' option
326                                  */
327         __u32 prcfg_mr;
328         __u32 prcfg_state;
329         __u32 prcfg_size;
330         void __user *prcfg_bulk;
331 };
332
333 struct lnet_ioctl_reset_health_cfg {
334         struct libcfs_ioctl_hdr rh_hdr;
335         enum lnet_health_type rh_type:32;
336         __u16 rh_all:1;
337         __s16 rh_value;
338         lnet_nid_t rh_nid;
339 };
340
341 struct lnet_ioctl_reset_conns_per_peer_cfg {
342         struct libcfs_ioctl_hdr rcpp_hdr;
343         __u16 rcpp_all:1;
344         __s16 rcpp_value;
345         lnet_nid_t rcpp_nid;
346 };
347
348 struct lnet_ioctl_recovery_list {
349         struct libcfs_ioctl_hdr rlst_hdr;
350         enum lnet_health_type rlst_type:32;
351         __u32 rlst_num_nids;
352         lnet_nid_t rlst_nid_array[LNET_MAX_SHOW_NUM_NID];
353 };
354
355 struct lnet_ioctl_set_value {
356         struct libcfs_ioctl_hdr sv_hdr;
357         __u32 sv_value;
358 };
359
360 struct lnet_ioctl_lnet_stats {
361         struct libcfs_ioctl_hdr st_hdr;
362         struct lnet_counters st_cntrs;
363 };
364
365 /* An IP, numeric NID or a Net number is composed of 1 or more of these
366  * descriptor structures.
367  */
368 struct lnet_range_expr {
369         __u32 re_lo;
370         __u32 re_hi;
371         __u32 re_stride;
372 };
373
374 /* le_count identifies the number of lnet_range_expr in the bulk
375  * which follows
376  */
377 struct lnet_expressions {
378         __u32 le_count;
379 };
380
381 /* A net descriptor has the net type, IE: O2IBLND, SOCKLND, etc and an
382  * expression describing a net number range.
383  */
384 struct lnet_ioctl_udsp_net_descr {
385         __u32 ud_net_type;
386         struct lnet_expressions ud_net_num_expr;
387 };
388
389 /* The UDSP descriptor header contains the type of matching criteria, SRC,
390  * DST, RTE, etc and how many lnet_expressions compose the LNet portion of
391  * the LNet NID. For example an IP can be
392  * composed of 4 lnet_expressions , a gni can be composed of 1
393  */
394 struct lnet_ioctl_udsp_descr_hdr {
395         /* The literals SRC, DST and RTE are encoded
396          * here.
397          */
398         __u32 ud_descr_type;
399         __u32 ud_descr_count;
400 };
401
402 /* each matching expression in the UDSP is described with this.
403  * The bulk format is as follows:
404  *      1. 1x struct lnet_ioctl_udsp_net_descr
405  *              -> the net part of the NID
406  *      2. >=0 struct lnet_expressions
407  *              -> the address part of the NID
408  */
409 struct lnet_ioctl_udsp_descr {
410         struct lnet_ioctl_udsp_descr_hdr iud_src_hdr;
411         struct lnet_ioctl_udsp_net_descr iud_net;
412 };
413
414 /* The cumulative UDSP descriptor
415  * The bulk format is as follows:
416  *      1. >=1 struct lnet_ioctl_udsp_descr
417  *
418  * The size indicated in iou_hdr is the total size of the UDSP.
419  *
420  */
421 struct lnet_ioctl_udsp {
422         struct libcfs_ioctl_hdr iou_hdr;
423         __s32 iou_idx;
424         __u32 iou_action_type;
425         __u32 iou_bulk_size;
426         union {
427                 __u32 priority;
428         } iou_action;
429         void __user *iou_bulk;
430 };
431
432 /* structure used to request udsp instantiation information on the
433  * specified construct.
434  *   cud_nid: the NID of the local or remote NI to pull info on.
435  *   cud_nid_priority: NID prio of the requested NID.
436  *   cud_net_priority: net prio of network of the requested NID.
437  *   cud_pref_nid: array of preferred NIDs if it exists.
438  */
439 struct lnet_ioctl_construct_udsp_info {
440         struct libcfs_ioctl_hdr cud_hdr;
441         __u32 cud_peer:1;
442         lnet_nid_t cud_nid;
443         __u32 cud_nid_priority;
444         __u32 cud_net_priority;
445         lnet_nid_t cud_pref_nid[LNET_MAX_SHOW_NUM_NID];
446         lnet_nid_t cud_pref_rtr_nid[LNET_MAX_SHOW_NUM_NID];
447 };
448
449 #endif /* _LNET_DLC_H_ */