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