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