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