xref: /titanic_50/usr/src/uts/common/sys/scsi/impl/uscsi.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Defines for user SCSI commands					*
29  */
30 
31 #ifndef _SYS_SCSI_IMPL_USCSI_H
32 #define	_SYS_SCSI_IMPL_USCSI_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * definition for user-scsi command structure
42  */
43 struct uscsi_cmd {
44 	int		uscsi_flags;	/* read, write, etc. see below */
45 	short		uscsi_status;	/* resulting status  */
46 	short		uscsi_timeout;	/* Command Timeout */
47 	caddr_t		uscsi_cdb;	/* cdb to send to target */
48 	caddr_t		uscsi_bufaddr;	/* i/o source/destination */
49 	size_t		uscsi_buflen;	/* size of i/o to take place */
50 	size_t		uscsi_resid;	/* resid from i/o operation */
51 	uchar_t		uscsi_cdblen;	/* # of valid cdb bytes */
52 	uchar_t		uscsi_rqlen;	/* size of uscsi_rqbuf */
53 	uchar_t		uscsi_rqstatus;	/* status of request sense cmd */
54 	uchar_t		uscsi_rqresid;	/* resid of request sense cmd */
55 	caddr_t		uscsi_rqbuf;	/* request sense buffer */
56 	void		*uscsi_reserved_5;	/* Reserved for Future Use */
57 };
58 
59 #if defined(_SYSCALL32)
60 struct uscsi_cmd32 {
61 	int		uscsi_flags;	/* read, write, etc. see below */
62 	short		uscsi_status;	/* resulting status  */
63 	short		uscsi_timeout;	/* Command Timeout */
64 	caddr32_t	uscsi_cdb;	/* cdb to send to target */
65 	caddr32_t	uscsi_bufaddr;	/* i/o source/destination */
66 	size32_t	uscsi_buflen;	/* size of i/o to take place */
67 	size32_t	uscsi_resid;	/* resid from i/o operation */
68 	uchar_t		uscsi_cdblen;	/* # of valid cdb bytes */
69 	uchar_t		uscsi_rqlen;	/* size of uscsi_rqbuf */
70 	uchar_t		uscsi_rqstatus;	/* status of request sense cmd */
71 	uchar_t		uscsi_rqresid;	/* resid of request sense cmd */
72 	caddr32_t	uscsi_rqbuf;	/* request sense buffer */
73 	caddr32_t	uscsi_reserved_5;	/* Reserved for Future Use */
74 };
75 
76 #define	uscsi_cmd32touscsi_cmd(u32, ucmd)				\
77 	ucmd->uscsi_flags	= u32->uscsi_flags;			\
78 	ucmd->uscsi_status	= u32->uscsi_status;			\
79 	ucmd->uscsi_timeout	= u32->uscsi_timeout;			\
80 	ucmd->uscsi_cdb		= (caddr_t)(uintptr_t)u32->uscsi_cdb;	\
81 	ucmd->uscsi_bufaddr	= (caddr_t)(uintptr_t)u32->uscsi_bufaddr; \
82 	ucmd->uscsi_buflen	= (size_t)u32->uscsi_buflen;		\
83 	ucmd->uscsi_resid	= (size_t)u32->uscsi_resid;		\
84 	ucmd->uscsi_cdblen	= u32->uscsi_cdblen;			\
85 	ucmd->uscsi_rqlen	= u32->uscsi_rqlen;			\
86 	ucmd->uscsi_rqstatus	= u32->uscsi_rqstatus;			\
87 	ucmd->uscsi_rqresid	= u32->uscsi_rqresid;			\
88 	ucmd->uscsi_rqbuf	= (caddr_t)(uintptr_t)u32->uscsi_rqbuf;	\
89 	ucmd->uscsi_reserved_5	= (void *)(uintptr_t)u32->uscsi_reserved_5;
90 
91 
92 #define	uscsi_cmdtouscsi_cmd32(ucmd, u32)				\
93 	u32->uscsi_flags	= ucmd->uscsi_flags;			\
94 	u32->uscsi_status	= ucmd->uscsi_status;			\
95 	u32->uscsi_timeout	= ucmd->uscsi_timeout;			\
96 	u32->uscsi_cdb		= (caddr32_t)(uintptr_t)ucmd->uscsi_cdb;  \
97 	u32->uscsi_bufaddr	= (caddr32_t)(uintptr_t)ucmd->uscsi_bufaddr; \
98 	u32->uscsi_buflen	= (size32_t)ucmd->uscsi_buflen;		\
99 	u32->uscsi_resid	= (size32_t)ucmd->uscsi_resid;		\
100 	u32->uscsi_cdblen	= ucmd->uscsi_cdblen;			\
101 	u32->uscsi_rqlen	= ucmd->uscsi_rqlen;			\
102 	u32->uscsi_rqstatus	= ucmd->uscsi_rqstatus;			\
103 	u32->uscsi_rqresid	= ucmd->uscsi_rqresid;			\
104 	u32->uscsi_rqbuf	= (caddr32_t)(uintptr_t)ucmd->uscsi_rqbuf; \
105 	u32->uscsi_reserved_5	= (caddr32_t)(uintptr_t)ucmd->uscsi_reserved_5;
106 
107 #endif /* _SYSCALL32 */
108 
109 
110 /*
111  * flags for uscsi_flags field
112  */
113 /*
114  * generic flags
115  */
116 #define	USCSI_WRITE	0x00000	/* send data to device */
117 #define	USCSI_SILENT	0x00001	/* no error messages */
118 #define	USCSI_DIAGNOSE	0x00002	/* fail if any error occurs */
119 #define	USCSI_ISOLATE	0x00004	/* isolate from normal commands */
120 #define	USCSI_READ	0x00008	/* get data from device */
121 #define	USCSI_RESET	0x04000	/* Reset target */
122 #define	USCSI_RESET_ALL	0x08000	/* Reset all targets */
123 #define	USCSI_RQENABLE	0x10000	/* Enable Request Sense extensions */
124 #define	USCSI_RENEGOT	0x20000	/* renegotiate wide/sync on next I/O */
125 
126 /*
127  * suitable for parallel SCSI bus only
128  */
129 #define	USCSI_ASYNC	0x01000	/* Set bus to asynchronous mode */
130 #define	USCSI_SYNC	0x02000	/* Return bus to sync mode if possible */
131 
132 /*
133  * the following flags should not be used at user level but may
134  * be used by a scsi target driver for internal commands
135  */
136 /*
137  * generic flags
138  */
139 #define	USCSI_NOINTR	0x00040	/* No interrupts, NEVER to use this flag */
140 #define	USCSI_NOTAG	0x00100	/* Disable tagged queueing */
141 #define	USCSI_OTAG	0x00200	/* ORDERED QUEUE tagged cmd */
142 #define	USCSI_HTAG	0x00400	/* HEAD OF QUEUE tagged cmd */
143 #define	USCSI_HEAD	0x00800	/* Head of HA queue */
144 
145 /*
146  * suitable for parallel SCSI bus only
147  */
148 #define	USCSI_NOPARITY	0x00010	/* run command without parity */
149 #define	USCSI_NODISCON	0x00020	/* run command without disconnects */
150 
151 
152 #define	USCSI_RESERVED	0xfffc0000	/* Reserved Bits, must be zero */
153 
154 struct uscsi_rqs {
155 	int		rqs_flags;	/* see below */
156 	ushort_t	rqs_buflen;	/* maximum number or bytes to return */
157 	ushort_t	rqs_resid;	/* untransferred length of RQS data */
158 	caddr_t		rqs_bufaddr;	/* request sense buffer */
159 };
160 
161 #if defined(_SYSCALL32)
162 struct uscsi_rqs32	{
163 	int		rqs_flags;	/* see below */
164 	ushort_t	rqs_buflen;	/* maximum number or bytes to return */
165 	ushort_t	rqs_resid;	/* untransferred length of RQS data */
166 	caddr32_t	rqs_bufaddr;	/* request sense buffer */
167 };
168 #endif /* _SYSCALL32 */
169 
170 
171 /*
172  * uscsi_rqs flags
173  */
174 
175 #define	RQS_OVR		0x01	/* RQS data has been overwritten */
176 #define	RQS_VALID	0x02	/* RQS data is valid */
177 
178 /*
179  * User SCSI io control command
180  */
181 #define	USCSIIOC	(0x04 << 8)
182 #define	USCSICMD	(USCSIIOC|201) 	/* user scsi command */
183 #define	USCSIGETRQS	(USCSIIOC|202) 	/* retrieve SCSI sense data */
184 
185 #ifdef	__cplusplus
186 }
187 #endif
188 
189 #endif	/* _SYS_SCSI_IMPL_USCSI_H */
190