xref: /illumos-gate/usr/src/uts/common/sys/emul64.h (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
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 /*
31  * This file defines the commands and structures for three emul64 ioctls,
32  * that may be useful in speeding up tests involving large devices.  The
33  * ioctls are documented at
34  * http://lvm.central.sun.com/projects/lagavulin/emul64_design.html#ioctl.
35  * Briefly, there are three ioctls:
36  *
37  *	EMUL64_WRITE_OFF - ignore all write operations to a specified block
38  *		range.
39  *	EMUL64_WRITE_ON - enable writes to a specified block range.
40  *	EMUL64_ZERO_RANGE - zero all blocks in the specified range.
41  *
42  * The emul64_range structure is used to specify a block range for these
43  * ioctls.
44  */
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include <sys/inttypes.h>
51 #include <sys/types.h>
52 #include <sys/scsi/scsi.h>
53 
54 /*
55  * emul64 ioctl commands:
56  */
57 
58 #define	EMUL64IOC	('e' << 8)
59 
60 #define	EMUL64_WRITE_OFF	(EMUL64IOC|37)
61 #define	EMUL64_WRITE_ON		(EMUL64IOC|38)
62 #define	EMUL64_ZERO_RANGE	(EMUL64IOC|39)
63 #define	EMUL64_ERROR_INJECT	(EMUL64IOC|40)
64 
65 struct emul64_range {
66 	diskaddr_t	emul64_sb;	/* starting block # of range */
67 	uint64_t	emul64_blkcnt;	/* # of blocks in range */
68 };
69 
70 typedef struct emul64_range emul64_range_t;
71 
72 /*
73  * Structure to use when specifying an ioctl for a range of blocks on a
74  * specific target.
75  */
76 struct emul64_tgt_range {
77 	emul64_range_t	emul64_blkrange; /* blocks affected by ioctl */
78 	ushort_t	emul64_target;	/* target number of disk */
79 	ushort_t	emul64_lun;	/* lun of disk */
80 };
81 
82 typedef struct emul64_tgt_range emul64_tgt_range_t;
83 
84 /*
85  * Structure to use for specifying error injection sense data
86  */
87 #define	ERR_INJ_DISABLE		0
88 #define	ERR_INJ_ENABLE		1
89 #define	ERR_INJ_ENABLE_NODATA	2
90 
91 struct emul64_error_inj_data {
92 	ushort_t	eccd_target;
93 	ushort_t	eccd_lun;
94 	ushort_t	eccd_inj_state; /* ERR_INJ_DISABLE, ... */
95 	ushort_t	eccd_sns_dlen; /* Number of bytes of sense data */
96 	struct scsi_status eccd_scsi_status;
97 	uchar_t		eccd_pkt_reason;
98 	uint_t		eccd_pkt_state;
99 };
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* _SYS_SCSI_ADAPTERS_EMUL64_H */
106