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