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