Whamcloud - gitweb
LU-8648 all: remove all Sun license and URL references
[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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2014, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  *
32  * lnet/include/lnet/lnetst.h
33  *
34  * Author: Liang Zhen <liangzhen@clusterfs.com>
35  */
36
37 #ifndef __LNET_ST_H__
38 #define __LNET_ST_H__
39
40 #define LST_FEAT_NONE           (0)
41 #define LST_FEAT_BULK_LEN       (1 << 0)        /* enable variable page size */
42
43 #define LST_FEATS_EMPTY         (LST_FEAT_NONE)
44 #define LST_FEATS_MASK          (LST_FEAT_NONE | LST_FEAT_BULK_LEN)
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         struct list_head        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         /** IN: session features */
237         unsigned                lstio_ses_feats;
238         lst_sid_t __user       *lstio_ses_idp;          /* OUT: session id */
239         int                     lstio_ses_nmlen;        /* IN: name length */
240         char __user            *lstio_ses_namep;        /* IN: session name */
241 } lstio_session_new_args_t;
242
243 /* query current session */
244 typedef struct {
245         lst_sid_t __user       *lstio_ses_idp;          /* OUT: session id */
246         int __user             *lstio_ses_keyp;         /* OUT: local key */
247         /** OUT: session features */
248         unsigned __user        *lstio_ses_featp;
249         lstcon_ndlist_ent_t __user *lstio_ses_ndinfo;   /* OUT: */
250         int                     lstio_ses_nmlen;        /* IN: name length */
251         char __user            *lstio_ses_namep;        /* OUT: session name */
252 } lstio_session_info_args_t;
253
254 /* delete a session */
255 typedef struct {
256         int                     lstio_ses_key;          /* IN: session key */
257 } lstio_session_end_args_t;
258
259 #define LST_OPC_SESSION         1
260 #define LST_OPC_GROUP           2
261 #define LST_OPC_NODES           3
262 #define LST_OPC_BATCHCLI        4
263 #define LST_OPC_BATCHSRV        5
264
265 typedef struct {
266         int                     lstio_dbg_key;          /* IN: session key */
267         int                     lstio_dbg_type;         /* IN: debug sessin|batch|group|nodes list */
268         int                     lstio_dbg_flags;        /* IN: reserved debug flags */
269         int                     lstio_dbg_timeout;      /* IN: timeout of debug */
270
271         int                     lstio_dbg_nmlen;        /* IN: len of name */
272         char __user            *lstio_dbg_namep;        /* IN: name of group|batch */
273         int                     lstio_dbg_count;        /* IN: # of test nodes to debug */
274         lnet_process_id_t __user *lstio_dbg_idsp;       /* IN: id of test nodes */
275         /* OUT: list head of result buffer */
276         struct list_head __user *lstio_dbg_resultp;
277 } lstio_debug_args_t;
278
279 typedef struct {
280         int                     lstio_grp_key;          /* IN: session key */
281         int                     lstio_grp_nmlen;        /* IN: name length */
282         char __user            *lstio_grp_namep;        /* IN: group name */
283 } lstio_group_add_args_t;
284
285 typedef struct {
286         int                     lstio_grp_key;          /* IN: session key */
287         int                     lstio_grp_nmlen;        /* IN: name length */
288         char __user            *lstio_grp_namep;        /* IN: group name */
289 } lstio_group_del_args_t;
290
291 #define LST_GROUP_CLEAN         1                       /* remove inactive nodes in the group */
292 #define LST_GROUP_REFRESH       2                       /* refresh inactive nodes in the group */
293 #define LST_GROUP_RMND          3                       /* delete nodes from the group */
294
295 typedef struct {
296         int                     lstio_grp_key;          /* IN: session key */
297         int                     lstio_grp_opc;          /* IN: OPC */
298         int                     lstio_grp_args;         /* IN: arguments */
299         int                     lstio_grp_nmlen;        /* IN: name length */
300         char __user            *lstio_grp_namep;        /* IN: group name */
301         int                     lstio_grp_count;        /* IN: # of nodes id */
302         lnet_process_id_t __user *lstio_grp_idsp;       /* IN: array of nodes */
303         /* OUT: list head of result buffer */
304         struct list_head __user *lstio_grp_resultp;
305 } lstio_group_update_args_t;
306
307 typedef struct {
308         int                      lstio_grp_key;         /* IN: session key */
309         int                      lstio_grp_nmlen;       /* IN: name length */
310         char __user             *lstio_grp_namep;       /* IN: group name */
311         int                      lstio_grp_count;       /* IN: # of nodes */
312         /** OUT: session features */
313         unsigned __user         *lstio_grp_featp;
314         lnet_process_id_t __user *lstio_grp_idsp;       /* IN: nodes */
315         /* OUT: list head of result buffer */
316         struct list_head __user *lstio_grp_resultp;
317 } lstio_group_nodes_args_t;
318
319 typedef struct {
320         int                     lstio_grp_key;          /* IN: session key */
321         int                     lstio_grp_idx;          /* IN: group idx */
322         int                     lstio_grp_nmlen;        /* IN: name len */
323         char __user            *lstio_grp_namep;        /* OUT: name */
324 } lstio_group_list_args_t;
325
326 typedef struct {
327         int                     lstio_grp_key;          /* IN: session key */
328         int                     lstio_grp_nmlen;        /* IN: name len */
329         char __user            *lstio_grp_namep;        /* IN: name */
330         lstcon_ndlist_ent_t __user *lstio_grp_entp;         /* OUT: description of group */
331
332         int __user             *lstio_grp_idxp;         /* IN/OUT: node index */
333         int __user             *lstio_grp_ndentp;       /* IN/OUT: # of nodent */
334         lstcon_node_ent_t __user *lstio_grp_dentsp;     /* OUT: nodent array */
335 } lstio_group_info_args_t;
336
337 #define LST_DEFAULT_BATCH       "batch"                 /* default batch name */
338
339 typedef struct {
340         int                     lstio_bat_key;          /* IN: session key */
341         int                     lstio_bat_nmlen;        /* IN: name length */
342         char __user            *lstio_bat_namep;        /* IN: batch name */
343 } lstio_batch_add_args_t;
344
345 typedef struct {
346         int                     lstio_bat_key;          /* IN: session key */
347         int                     lstio_bat_nmlen;        /* IN: name length */
348         char __user            *lstio_bat_namep;        /* IN: batch name */
349 } lstio_batch_del_args_t;
350
351 typedef struct {
352         /* IN: session key */
353         int                      lstio_bat_key;
354         /* IN: timeout for the batch */
355         int                      lstio_bat_timeout;
356         /* IN: name length */
357         int                      lstio_bat_nmlen;
358         /* IN: batch name */
359         char __user             *lstio_bat_namep;
360         /* OUT: list head of result buffer */
361         struct list_head __user *lstio_bat_resultp;
362 } lstio_batch_run_args_t;
363
364 typedef struct {
365         /* IN: session key */
366         int                      lstio_bat_key;
367         /* IN: abort unfinished test RPC */
368         int                      lstio_bat_force;
369         /* IN: name length */
370         int                      lstio_bat_nmlen;
371         /* IN: batch name */
372         char __user             *lstio_bat_namep;
373         /* OUT: list head of result buffer */
374         struct list_head __user *lstio_bat_resultp;
375 } lstio_batch_stop_args_t;
376
377 typedef struct {
378         /* IN: session key */
379         int                     lstio_bat_key;
380         /* IN: test index */
381         int                     lstio_bat_testidx;
382         /* IN: is test client? */
383         int                     lstio_bat_client;
384         /* IN: timeout for waiting */
385         int                     lstio_bat_timeout;
386         /* IN: name length */
387         int                     lstio_bat_nmlen;
388         /* IN: batch name */
389         char __user             *lstio_bat_namep;
390         /* OUT: list head of result buffer */
391         struct list_head __user *lstio_bat_resultp;
392 } lstio_batch_query_args_t;
393
394 typedef struct {
395         int                     lstio_bat_key;          /* IN: session key */
396         int                     lstio_bat_idx;          /* IN: index */
397         int                     lstio_bat_nmlen;        /* IN: name length */
398         char __user            *lstio_bat_namep;        /* IN: batch name */
399 } lstio_batch_list_args_t;
400
401 typedef struct {
402         int                     lstio_bat_key;          /* IN: session key */
403         int                     lstio_bat_nmlen;        /* IN: name length */
404         char __user            *lstio_bat_namep;        /* IN: name */
405         int                     lstio_bat_server;       /* IN: query server or not */
406         int                     lstio_bat_testidx;      /* IN: test index */
407         lstcon_test_batch_ent_t __user *lstio_bat_entp; /* OUT: batch ent */
408
409         int __user             *lstio_bat_idxp;         /* IN/OUT: index of node */
410         int __user             *lstio_bat_ndentp;       /* IN/OUT: # of nodent */
411         lstcon_node_ent_t __user *lstio_bat_dentsp;     /* array of nodent */
412 } lstio_batch_info_args_t;
413
414 /* add stat in session */
415 typedef struct {
416         /* IN: session key */
417         int                     lstio_sta_key;
418         /* IN: timeout for stat requst */
419         int                     lstio_sta_timeout;
420         /* IN: group name length */
421         int                     lstio_sta_nmlen;
422         /* IN: group name */
423         char __user            *lstio_sta_namep;
424         /* IN: # of pid */
425         int                     lstio_sta_count;
426         /* IN: pid */
427         lnet_process_id_t __user *lstio_sta_idsp;
428         /* OUT: list head of result buffer */
429         struct list_head __user *lstio_sta_resultp;
430 } lstio_stat_args_t;
431
432 typedef enum {
433         LST_TEST_BULK   = 1,
434         LST_TEST_PING   = 2
435 } lst_test_type_t;
436
437 /* create a test in a batch */
438 #define LST_MAX_CONCUR          1024                    /* Max concurrency of test */
439
440 typedef struct {
441         int                     lstio_tes_key;          /* IN: session key */
442         int                     lstio_tes_bat_nmlen;    /* IN: batch name len */
443         char __user            *lstio_tes_bat_name;     /* IN: batch name */
444         int                     lstio_tes_type;         /* IN: test type */
445         int                     lstio_tes_oneside;      /* IN: one sided test */
446         int                     lstio_tes_loop;         /* IN: loop count */
447         int                     lstio_tes_concur;       /* IN: concurrency */
448
449         int                     lstio_tes_dist;         /* IN: node distribution in destination groups */
450         int                     lstio_tes_span;         /* IN: node span in destination groups */
451         int                     lstio_tes_sgrp_nmlen;   /* IN: source group name length */
452         char __user            *lstio_tes_sgrp_name;    /* IN: group name */
453         int                     lstio_tes_dgrp_nmlen;   /* IN: destination group name length */
454         char __user            *lstio_tes_dgrp_name;    /* IN: group name */
455
456         /* IN: param buffer len */
457         int                      lstio_tes_param_len;
458         /* IN: parameter for specified test:
459                lstio_bulk_param_t,
460                lstio_ping_param_t,
461                ... more */
462         void __user             *lstio_tes_param;
463         /* OUT: private returned value */
464         int __user              *lstio_tes_retp;
465         /* OUT: list head of result buffer */
466         struct list_head __user *lstio_tes_resultp;
467 } lstio_test_args_t;
468
469 typedef enum {
470         LST_BRW_READ    = 1,
471         LST_BRW_WRITE   = 2
472 } lst_brw_type_t;
473
474 typedef enum {
475         LST_BRW_CHECK_NONE   = 1,
476         LST_BRW_CHECK_SIMPLE = 2,
477         LST_BRW_CHECK_FULL   = 3
478 } lst_brw_flags_t;
479
480 typedef struct {
481         int                     blk_opc;                /* bulk operation code */
482         int                     blk_size;               /* size (bytes) */
483         int                     blk_time;               /* time of running the test*/
484         int                     blk_flags;              /* reserved flags */
485         int                     blk_cli_off;            /* bulk offset on client */
486         int                     blk_srv_off;            /* reserved: bulk offset on server */
487 } lst_test_bulk_param_t;
488
489 typedef struct {
490         int                     png_size;               /* size of ping message */
491         int                     png_time;               /* time */
492         int                     png_loop;               /* loop */
493         int                     png_flags;              /* reserved flags */
494 } lst_test_ping_param_t;
495
496 typedef struct {
497         __u32 errors;
498         __u32 rpcs_sent;
499         __u32 rpcs_rcvd;
500         __u32 rpcs_dropped;
501         __u32 rpcs_expired;
502         __u64 bulk_get;
503         __u64 bulk_put;
504 } WIRE_ATTR srpc_counters_t;
505
506 typedef struct {
507         /** milliseconds since current session started */
508         __u32 running_ms;
509         __u32 active_batches;
510         __u32 zombie_sessions;
511         __u32 brw_errors;
512         __u32 ping_errors;
513 } WIRE_ATTR sfw_counters_t;
514
515 #endif