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