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