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