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