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