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