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