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