xref: /titanic_44/usr/src/uts/common/sys/emul64.h (revision 20c1c3551cb3b3117591ae38463d16aada597c48)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_SCSI_ADAPTERS_EMUL64_H
28 #define	_SYS_SCSI_ADAPTERS_EMUL64_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file defines the commands and structures for three emul64 ioctls,
34  * that may be useful in speeding up tests involving large devices.  The
35  * ioctls are documented at
36  * http://lvm.central.sun.com/projects/lagavulin/emul64_design.html#ioctl.
37  * Briefly, there are three ioctls:
38  *
39  *	EMUL64_WRITE_OFF - ignore all write operations to a specified block
40  *		range.
41  *	EMUL64_WRITE_ON - enable writes to a specified block range.
42  *	EMUL64_ZERO_RANGE - zero all blocks in the specified range.
43  *
44  * The emul64_range structure is used to specify a block range for these
45  * ioctls.
46  */
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #include <sys/inttypes.h>
53 #include <sys/types.h>
54 #include <sys/scsi/scsi.h>
55 
56 /*
57  * emul64 ioctl commands:
58  */
59 
60 #define	EMUL64IOC	('e' << 8)
61 
62 #define	EMUL64_WRITE_OFF	(EMUL64IOC|37)
63 #define	EMUL64_WRITE_ON		(EMUL64IOC|38)
64 #define	EMUL64_ZERO_RANGE	(EMUL64IOC|39)
65 #define	EMUL64_ERROR_INJECT	(EMUL64IOC|40)
66 
67 struct emul64_range {
68 	diskaddr_t	emul64_sb;	/* starting block # of range */
69 	uint64_t	emul64_blkcnt;	/* # of blocks in range */
70 };
71 
72 typedef struct emul64_range emul64_range_t;
73 
74 /*
75  * Structure to use when specifying an ioctl for a range of blocks on a
76  * specific target.
77  */
78 struct emul64_tgt_range {
79 	emul64_range_t	emul64_blkrange; /* blocks affected by ioctl */
80 	ushort_t	emul64_target;	/* target number of disk */
81 	ushort_t	emul64_lun;	/* lun of disk */
82 };
83 
84 typedef struct emul64_tgt_range emul64_tgt_range_t;
85 
86 /*
87  * Structure to use for specifying error injection sense data
88  */
89 #define	ERR_INJ_DISABLE		0
90 #define	ERR_INJ_ENABLE		1
91 #define	ERR_INJ_ENABLE_NODATA	2
92 
93 struct emul64_error_inj_data {
94 	ushort_t	eccd_target;
95 	ushort_t	eccd_lun;
96 	ushort_t	eccd_inj_state; /* ERR_INJ_DISABLE, ... */
97 	ushort_t	eccd_sns_dlen; /* Number of bytes of sense data */
98 	struct scsi_status eccd_scsi_status;
99 	uchar_t		eccd_pkt_reason;
100 	uint_t		eccd_pkt_state;
101 };
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* _SYS_SCSI_ADAPTERS_EMUL64_H */
108