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