Whamcloud - gitweb
LU-17676 build: configure should prefer to ask if
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnetst.h
1 // SPDX-License-Identifier: GPL-2.0
2
3 /* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4  * Use is subject to license terms.
5  *
6  * Copyright (c) 2012, 2016, Intel Corporation.
7  */
8
9 /* This file is part of Lustre, http://www.lustre.org/
10  *
11  * Author: Liang Zhen <liangzhen@clusterfs.com>
12  */
13
14 #ifndef __UAPI_LNET_ST_H__
15 #define __UAPI_LNET_ST_H__
16
17 #include <linux/types.h>
18 #include <linux/lnet/lnet-types.h>
19 #include <linux/time.h>
20
21 #define LST_FEAT_NONE           (0)
22 #define LST_FEAT_BULK_LEN       (1 << 0)        /* enable variable page size */
23
24 #define LST_FEATS_EMPTY         (LST_FEAT_NONE)
25 #define LST_FEATS_MASK          (LST_FEAT_NONE | LST_FEAT_BULK_LEN)
26
27 #define LST_NAME_SIZE           32              /* max name buffer length */
28
29 #define LSTIO_DEBUG             0xC00           /* debug */
30 #define LSTIO_SESSION_NEW       0xC01           /* create session */
31 #define LSTIO_SESSION_END       0xC02           /* end session */
32 #define LSTIO_SESSION_INFO      0xC03           /* query session */
33 #define LSTIO_GROUP_ADD         0xC10           /* add group */
34 #define LSTIO_GROUP_LIST        0xC11           /* list all groups in session */
35 #define LSTIO_GROUP_INFO        0xC12           /* query defailt infomation of specified group */
36 #define LSTIO_GROUP_DEL         0xC13           /* delete group */
37 #define LSTIO_NODES_ADD         0xC14           /* add nodes to specified group */
38 #define LSTIO_GROUP_UPDATE      0xC15           /* update group */
39 #define LSTIO_BATCH_ADD         0xC20           /* add batch */
40 #define LSTIO_BATCH_START       0xC21           /* start batch */
41 #define LSTIO_BATCH_STOP        0xC22           /* stop batch */
42 #define LSTIO_BATCH_DEL         0xC23           /* delete batch */
43 #define LSTIO_BATCH_LIST        0xC24           /* show all batches in the session */
44 #define LSTIO_BATCH_INFO        0xC25           /* show defail of specified batch */
45 #define LSTIO_TEST_ADD          0xC26           /* add test (to batch) */
46 #define LSTIO_BATCH_QUERY       0xC27           /* query batch status */
47 #define LSTIO_STAT_QUERY        0xC30           /* get stats */
48
49 /*
50  * sparse kernel source annotations
51  */
52 #ifndef __user
53 #define __user
54 #endif
55
56 struct lst_sid {
57         lnet_nid_t      ses_nid;        /* nid of console node */
58         __s64           ses_stamp;      /* time stamp in milliseconds */
59 };                                      /*** session id */
60
61 struct lst_bid {
62         __u64           bat_id;         /* unique id in session */
63 };
64
65 /* Status of test node */
66 #define LST_NODE_ACTIVE         0x1     /* node in this session */
67 #define LST_NODE_BUSY           0x2     /* node is taken by other session */
68 #define LST_NODE_DOWN           0x4     /* node is down */
69 #define LST_NODE_UNKNOWN        0x8     /* node not in session */
70
71 struct lstcon_node_ent {
72         struct lnet_process_id  nde_id;         /* id of node */
73         int                     nde_state;      /* state of node */
74 };                                              /*** node entry, for list_group command */
75
76 struct lstcon_ndlist_ent {
77         int     nle_nnode;      /* # of nodes */
78         int     nle_nactive;    /* # of active nodes */
79         int     nle_nbusy;      /* # of busy nodes */
80         int     nle_ndown;      /* # of down nodes */
81         int     nle_nunknown;   /* # of unknown nodes */
82 };                              /*** node_list entry, for list_batch command */
83
84 struct lstcon_test_ent {
85         int     tse_type;       /* test type */
86         int     tse_loop;       /* loop count */
87         int     tse_concur;     /* concurrency of test */
88 };                              /*** test summary entry, for list_batch command */
89
90 struct lstcon_batch_ent {
91         int     bae_state;      /* batch status */
92         int     bae_timeout;    /* batch timeout */
93         int     bae_ntest;      /* # of tests in the batch */
94 };                              /*** batch summary entry, for list_batch command */
95
96 struct lstcon_test_batch_ent {
97         struct lstcon_ndlist_ent        tbe_cli_nle;    /* client (group) node_list entry */
98         struct lstcon_ndlist_ent        tbe_srv_nle;    /* server (group) node_list entry */
99         union {
100                 struct lstcon_test_ent  tbe_test;       /* test entry */
101                 struct lstcon_batch_ent tbe_batch;      /* batch entry */
102         } u;
103 };                                                      /*** test/batch verbose information entry,
104                                                          *** for list_batch command */
105
106 /* This will go away once we move to netlink */
107 #if !defined(__KERNEL__) && !defined(__LIBCFS_UTIL_LIST_H__)
108 struct list_head {
109         struct list_head *next, *prev;
110 };
111 #endif
112
113 struct lstcon_rpc_ent {
114         struct list_head        rpe_link;               /* link chain */
115         struct lnet_process_id  rpe_peer;               /* peer's id */
116         /* This has not been used since Lustre 2.2 so its safe to use.
117          * Update to allow future use of timespec64
118          */
119         struct {
120                 __s64           tv_sec;
121                 __s64           tv_nsec;
122         } rpe_stamp;                                    /* time stamp of RPC */
123         int                     rpe_state;              /* peer's state */
124         int                     rpe_rpc_errno;          /* RPC errno */
125
126         struct lst_sid          rpe_sid;                /* peer's session id */
127         int                     rpe_fwk_errno;          /* framework errno */
128         int                     rpe_priv[4];            /* private data */
129         char                    rpe_payload[0];         /* private reply payload */
130 };
131
132 struct lstcon_trans_stat {
133         int     trs_rpc_stat[4];        /* RPCs stat (0: total, 1: failed, 2: finished, 4: reserved */
134         int     trs_rpc_errno;          /* RPC errno */
135         int     trs_fwk_stat[8];        /* framework stat */
136         int     trs_fwk_errno;          /* errno of the first remote error */
137         void   *trs_fwk_private;        /* private framework stat */
138 };
139
140 static inline int
141 lstcon_rpc_stat_total(struct lstcon_trans_stat *stat, int inc)
142 {
143         return inc ? ++stat->trs_rpc_stat[0] : stat->trs_rpc_stat[0];
144 }
145
146 static inline int
147 lstcon_rpc_stat_success(struct lstcon_trans_stat *stat, int inc)
148 {
149         return inc ? ++stat->trs_rpc_stat[1] : stat->trs_rpc_stat[1];
150 }
151
152 static inline int
153 lstcon_rpc_stat_failure(struct lstcon_trans_stat *stat, int inc)
154 {
155         return inc ? ++stat->trs_rpc_stat[2] : stat->trs_rpc_stat[2];
156 }
157
158 static inline int
159 lstcon_sesop_stat_success(struct lstcon_trans_stat *stat, int inc)
160 {
161         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
162 }
163
164 static inline int
165 lstcon_sesop_stat_failure(struct lstcon_trans_stat *stat, int inc)
166 {
167         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
168 }
169
170 static inline int
171 lstcon_sesqry_stat_active(struct lstcon_trans_stat *stat, int inc)
172 {
173         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
174 }
175
176 static inline int
177 lstcon_sesqry_stat_busy(struct lstcon_trans_stat *stat, int inc)
178 {
179         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
180 }
181
182 static inline int
183 lstcon_sesqry_stat_unknown(struct lstcon_trans_stat *stat, int inc)
184 {
185         return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2];
186 }
187
188 static inline int
189 lstcon_tsbop_stat_success(struct lstcon_trans_stat *stat, int inc)
190 {
191         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
192 }
193
194 static inline int
195 lstcon_tsbop_stat_failure(struct lstcon_trans_stat *stat, int inc)
196 {
197         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
198 }
199
200 static inline int
201 lstcon_tsbqry_stat_idle(struct lstcon_trans_stat *stat, int inc)
202 {
203         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
204 }
205
206 static inline int
207 lstcon_tsbqry_stat_run(struct lstcon_trans_stat *stat, int inc)
208 {
209         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
210 }
211
212 static inline int
213 lstcon_tsbqry_stat_failure(struct lstcon_trans_stat *stat, int inc)
214 {
215         return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2];
216 }
217
218 static inline int
219 lstcon_statqry_stat_success(struct lstcon_trans_stat *stat, int inc)
220 {
221         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
222 }
223
224 static inline int
225 lstcon_statqry_stat_failure(struct lstcon_trans_stat *stat, int inc)
226 {
227         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
228 }
229
230 /* create a session */
231 struct lstio_session_new_args {
232         int                     lstio_ses_key;          /* IN: local key */
233         int                     lstio_ses_timeout;      /* IN: session timeout */
234         int                     lstio_ses_force;        /* IN: force create ? */
235         /** IN: session features */
236         unsigned                lstio_ses_feats;
237         struct lst_sid __user  *lstio_ses_idp;          /* OUT: session id */
238         int                     lstio_ses_nmlen;        /* IN: name length */
239         char __user            *lstio_ses_namep;        /* IN: session name */
240 };
241
242 /* query current session */
243 struct lstio_session_info_args {
244         struct lst_sid __user   *lstio_ses_idp;         /* OUT: session id */
245         int __user              *lstio_ses_keyp;        /* OUT: local key */
246         /** OUT: session features */
247         unsigned __user         *lstio_ses_featp;
248         struct lstcon_ndlist_ent __user *lstio_ses_ndinfo; /* OUT: */
249         int                      lstio_ses_nmlen;       /* IN: name length */
250         char __user             *lstio_ses_namep;       /* OUT: session name */
251 };
252
253 /* delete a session */
254 struct lstio_session_end_args {
255         int                     lstio_ses_key;          /* IN: session key */
256 };
257
258 #define LST_OPC_SESSION         1
259 #define LST_OPC_GROUP           2
260 #define LST_OPC_NODES           3
261 #define LST_OPC_BATCHCLI        4
262 #define LST_OPC_BATCHSRV        5
263
264 struct lstio_debug_args {
265         int                     lstio_dbg_key;          /* IN: session key */
266         int                     lstio_dbg_type;         /* IN: debug sessin|batch|group|nodes list */
267         int                     lstio_dbg_flags;        /* IN: reserved debug flags */
268         int                     lstio_dbg_timeout;      /* IN: timeout of debug */
269
270         int                     lstio_dbg_nmlen;        /* IN: len of name */
271         char __user            *lstio_dbg_namep;        /* IN: name of group|batch */
272         int                     lstio_dbg_count;        /* IN: # of test nodes to debug */
273         struct lnet_process_id __user *lstio_dbg_idsp;  /* IN: id of test nodes */
274         /* OUT: list head of result buffer */
275         struct list_head __user *lstio_dbg_resultp;
276 };
277
278 struct lstio_group_add_args {
279         int                     lstio_grp_key;          /* IN: session key */
280         int                     lstio_grp_nmlen;        /* IN: name length */
281         char __user            *lstio_grp_namep;        /* IN: group name */
282 };
283
284 struct lstio_group_del_args {
285         int                     lstio_grp_key;          /* IN: session key */
286         int                     lstio_grp_nmlen;        /* IN: name length */
287         char __user            *lstio_grp_namep;        /* IN: group name */
288 };
289
290 #define LST_GROUP_CLEAN         1                       /* remove inactive nodes in the group */
291 #define LST_GROUP_REFRESH       2                       /* refresh inactive nodes in the group */
292 #define LST_GROUP_RMND          3                       /* delete nodes from the group */
293
294 struct lstio_group_update_args {
295         int                     lstio_grp_key;          /* IN: session key */
296         int                     lstio_grp_opc;          /* IN: OPC */
297         int                     lstio_grp_args;         /* IN: arguments */
298         int                     lstio_grp_nmlen;        /* IN: name length */
299         char __user            *lstio_grp_namep;        /* IN: group name */
300         int                     lstio_grp_count;        /* IN: # of nodes id */
301         struct lnet_process_id __user *lstio_grp_idsp;  /* IN: array of nodes */
302         /* OUT: list head of result buffer */
303         struct list_head __user *lstio_grp_resultp;
304 };
305
306 struct lstio_group_nodes_args {
307         int                      lstio_grp_key;         /* IN: session key */
308         int                      lstio_grp_nmlen;       /* IN: name length */
309         char __user             *lstio_grp_namep;       /* IN: group name */
310         int                      lstio_grp_count;       /* IN: # of nodes */
311         /** OUT: session features */
312         unsigned __user         *lstio_grp_featp;
313         struct lnet_process_id __user *lstio_grp_idsp;  /* IN: nodes */
314         /* OUT: list head of result buffer */
315         struct list_head __user *lstio_grp_resultp;
316 };
317
318 struct lstio_group_list_args {
319         int                     lstio_grp_key;          /* IN: session key */
320         int                     lstio_grp_idx;          /* IN: group idx */
321         int                     lstio_grp_nmlen;        /* IN: name len */
322         char __user            *lstio_grp_namep;        /* OUT: name */
323 };
324
325 struct lstio_group_info_args {
326         int                     lstio_grp_key;          /* IN: session key */
327         int                     lstio_grp_nmlen;        /* IN: name len */
328         char __user            *lstio_grp_namep;        /* IN: name */
329         struct lstcon_ndlist_ent __user *lstio_grp_entp;/* OUT: description of group */
330
331         int __user             *lstio_grp_idxp;         /* IN/OUT: node index */
332         int __user             *lstio_grp_ndentp;       /* IN/OUT: # of nodent */
333         struct lstcon_node_ent __user *lstio_grp_dentsp;/* OUT: nodent array */
334 };
335
336 #define LST_DEFAULT_BATCH       "batch"                 /* default batch name */
337
338 struct lstio_batch_add_args {
339         int                     lstio_bat_key;          /* IN: session key */
340         int                     lstio_bat_nmlen;        /* IN: name length */
341         char __user            *lstio_bat_namep;        /* IN: batch name */
342 };
343
344 struct lstio_batch_del_args {
345         int                     lstio_bat_key;          /* IN: session key */
346         int                     lstio_bat_nmlen;        /* IN: name length */
347         char __user            *lstio_bat_namep;        /* IN: batch name */
348 };
349
350 struct lstio_batch_run_args {
351         /* IN: session key */
352         int                      lstio_bat_key;
353         /* IN: timeout for the batch */
354         int                      lstio_bat_timeout;
355         /* IN: name length */
356         int                      lstio_bat_nmlen;
357         /* IN: batch name */
358         char __user             *lstio_bat_namep;
359         /* OUT: list head of result buffer */
360         struct list_head __user *lstio_bat_resultp;
361 };
362
363 struct lstio_batch_stop_args {
364         /* IN: session key */
365         int                      lstio_bat_key;
366         /* IN: abort unfinished test RPC */
367         int                      lstio_bat_force;
368         /* IN: name length */
369         int                      lstio_bat_nmlen;
370         /* IN: batch name */
371         char __user             *lstio_bat_namep;
372         /* OUT: list head of result buffer */
373         struct list_head __user *lstio_bat_resultp;
374 };
375
376 struct lstio_batch_query_args {
377         /* IN: session key */
378         int                     lstio_bat_key;
379         /* IN: test index */
380         int                     lstio_bat_testidx;
381         /* IN: is test client? */
382         int                     lstio_bat_client;
383         /* IN: timeout for waiting */
384         int                     lstio_bat_timeout;
385         /* IN: name length */
386         int                     lstio_bat_nmlen;
387         /* IN: batch name */
388         char __user             *lstio_bat_namep;
389         /* OUT: list head of result buffer */
390         struct list_head __user *lstio_bat_resultp;
391 };
392
393 struct lstio_batch_list_args {
394         int                     lstio_bat_key;          /* IN: session key */
395         int                     lstio_bat_idx;          /* IN: index */
396         int                     lstio_bat_nmlen;        /* IN: name length */
397         char __user            *lstio_bat_namep;        /* IN: batch name */
398 };
399
400 struct lstio_batch_info_args {
401         int                     lstio_bat_key;          /* IN: session key */
402         int                     lstio_bat_nmlen;        /* IN: name length */
403         char __user            *lstio_bat_namep;        /* IN: name */
404         int                     lstio_bat_server;       /* IN: query server or not */
405         int                     lstio_bat_testidx;      /* IN: test index */
406         struct lstcon_test_batch_ent __user *lstio_bat_entp;/* OUT: batch ent */
407
408         int __user             *lstio_bat_idxp;         /* IN/OUT: index of node */
409         int __user             *lstio_bat_ndentp;       /* IN/OUT: # of nodent */
410         struct lstcon_node_ent __user *lstio_bat_dentsp;/* array of nodent */
411 };
412
413 /* add stat in session */
414 struct lstio_stat_args {
415         /* IN: session key */
416         int                     lstio_sta_key;
417         /* IN: timeout for stat requst */
418         int                     lstio_sta_timeout;
419         /* IN: group name length */
420         int                     lstio_sta_nmlen;
421         /* IN: group name */
422         char __user            *lstio_sta_namep;
423         /* IN: # of pid */
424         int                     lstio_sta_count;
425         /* IN: pid */
426         struct lnet_process_id __user *lstio_sta_idsp;
427         /* OUT: list head of result buffer */
428         struct list_head __user *lstio_sta_resultp;
429 };
430
431 enum lst_test_type {
432         LST_TEST_BULK   = 1,
433         LST_TEST_PING   = 2
434 };
435
436 /* create a test in a batch */
437 #define LST_MAX_CONCUR          1024                    /* Max concurrency of test */
438
439 struct lstio_test_args {
440         int                     lstio_tes_key;          /* IN: session key */
441         int                     lstio_tes_bat_nmlen;    /* IN: batch name len */
442         char __user            *lstio_tes_bat_name;     /* IN: batch name */
443         int                     lstio_tes_type;         /* IN: test type */
444         int                     lstio_tes_oneside;      /* IN: one sided test */
445         int                     lstio_tes_loop;         /* IN: loop count */
446         int                     lstio_tes_concur;       /* IN: concurrency */
447
448         int                     lstio_tes_dist;         /* IN: node distribution in destination groups */
449         int                     lstio_tes_span;         /* IN: node span in destination groups */
450         int                     lstio_tes_sgrp_nmlen;   /* IN: source group name length */
451         char __user            *lstio_tes_sgrp_name;    /* IN: group name */
452         int                     lstio_tes_dgrp_nmlen;   /* IN: destination group name length */
453         char __user            *lstio_tes_dgrp_name;    /* IN: group name */
454
455         /* IN: param buffer len */
456         int                      lstio_tes_param_len;
457         /* IN: parameter for specified test:
458                lstio_bulk_param_t,
459                lstio_ping_param_t,
460                ... more */
461         void __user             *lstio_tes_param;
462         /* OUT: private returned value */
463         int __user              *lstio_tes_retp;
464         /* OUT: list head of result buffer */
465         struct list_head __user *lstio_tes_resultp;
466 };
467
468 enum lst_brw_type {
469         LST_BRW_READ    = 1,
470         LST_BRW_WRITE   = 2
471 };
472
473 enum lst_brw_flags {
474         LST_BRW_CHECK_NONE   = 1,
475         LST_BRW_CHECK_SIMPLE = 2,
476         LST_BRW_CHECK_FULL   = 3
477 };
478
479 struct lst_test_bulk_param {
480         int blk_opc;            /* bulk operation code */
481         int blk_size;           /* size (bytes) */
482         int blk_time;           /* time of running the test*/
483         int blk_flags;          /* reserved flags */
484         int blk_cli_off;        /* bulk offset on client */
485         int blk_srv_off;        /* reserved: bulk offset on server */
486 };
487
488 struct lst_test_ping_param {
489         int png_size;           /* size of ping message */
490         int png_time;           /* time */
491         int png_loop;           /* loop */
492         int png_flags;          /* reserved flags */
493 };
494
495 /* Both struct srpc_counters and struct sfw_counters are sent over the wire */
496 struct srpc_counters {
497         __u32 errors;
498         __u32 rpcs_sent;
499         __u32 rpcs_rcvd;
500         __u32 rpcs_dropped;
501         __u32 rpcs_expired;
502         __u64 bulk_get;
503         __u64 bulk_put;
504 } __attribute__((packed));
505
506 struct sfw_counters {
507         /** milliseconds since current session started */
508         __u32 running_ms;
509         __u32 active_batches;
510         __u32 zombie_sessions;
511         __u32 brw_errors;
512         __u32 ping_errors;
513 } __attribute__((packed));
514
515 #define LNET_SELFTEST_GENL_NAME         "lnet_selftest"
516 #define LNET_SELFTEST_GENL_VERSION      0x1
517
518 /* enum lnet_selftest_commands        - Supported core LNet Selftest Netlink
519  *                                      commands
520  *
521  * @LNET_SELFTEST_CMD_UNSPEC:           unspecified command to catch errors
522  * @LNET_SELFTEST_CMD_SESSIONS:         command to manage sessions
523  * @LNET_SELFTEST_CMD_GROUPS:           command to manage selftest groups
524  */
525 enum lnet_selftest_commands {
526         LNET_SELFTEST_CMD_UNSPEC        = 0,
527
528         LNET_SELFTEST_CMD_SESSIONS      = 1,
529         LNET_SELFTEST_CMD_GROUPS        = 2,
530
531         __LNET_SELFTEST_CMD_MAX_PLUS_ONE,
532 };
533
534 #define LNET_SELFTEST_CMD_MAX (__LNET_SELFTEST_CMD_MAX_PLUS_ONE - 1)
535
536 #endif