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