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