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