xref: /illumos-gate/usr/src/uts/common/sys/scsi/generic/inquiry.h (revision 524e558aae3e99de2bdab73592f925ea489fbe07)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_GENERIC_INQUIRY_H
27 #define	_SYS_SCSI_GENERIC_INQUIRY_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * SCSI Inquiry Data
37  *
38  * Format of data returned as a result of an INQUIRY command.
39  *
40  */
41 
42 #if defined(_BIT_FIELDS_LTOH)
43 struct scsi_inquiry {
44 
45 	/*
46 	 * byte 0
47 	 *
48 	 * Bits 7-5 are the Peripheral Device Qualifier
49 	 * Bits 4-0 are the Peripheral Device Type
50 	 *
51 	 */
52 
53 	uchar_t	inq_dtype;
54 
55 	/* byte 1 */
56 	uchar_t	inq_qual	: 7,	/* device type qualifier	*/
57 		inq_rmb		: 1;	/* removable media		*/
58 
59 	/* byte 2 */
60 	uchar_t	inq_ansi	: 3,	/* ANSI version 		*/
61 		inq_ecma	: 3,	/* ECMA version 		*/
62 		inq_iso		: 2;	/* ISO version 			*/
63 
64 	/* byte 3 */
65 	uchar_t	inq_rdf		: 4,	/* response data format 	*/
66 				: 1,	/* reserved 			*/
67 		inq_normaca	: 1,	/* setting NACA bit supported */
68 		inq_trmiop	: 1,	/* TERMINATE I/O PROC msg 	*/
69 		inq_aenc	: 1;	/* async event notification cap. */
70 
71 	/* bytes 4-7 */
72 
73 	uchar_t	inq_len;		/* additional length 		*/
74 
75 	uchar_t			: 8;	/* reserved 			*/
76 
77 	uchar_t	inq_addr16	: 1,	/* supports 16 bit wide SCSI addr */
78 		inq_addr32	: 1,	/* supports 32 bit wide SCSI addr */
79 		inq_ackqreqq	: 1,	/* data tranfer on Q cable */
80 		inq_mchngr	: 1,	/* embedded/attached to medium chngr */
81 		inq_dualp	: 1,	/* dual port device */
82 		inq_port	: 1,	/* port receiving inquiry cmd */
83 				: 2;	/* reserved 			*/
84 
85 	uchar_t	inq_sftre	: 1,	/* supports Soft Reset option 	*/
86 		inq_cmdque	: 1,	/* supports command queueing 	*/
87 		inq_trandis	: 1,	/* supports transfer disable messages */
88 		inq_linked	: 1,	/* supports linked commands 	*/
89 		inq_sync	: 1,	/* supports synchronous data xfers */
90 		inq_wbus16	: 1,	/* supports 16 bit wide data xfers */
91 		inq_wbus32	: 1,	/* supports 32 bit wide data xfers */
92 		inq_reladdr	: 1;	/* supports relative addressing */
93 
94 	/* bytes 8-35 */
95 
96 	char	inq_vid[8];		/* vendor ID 			*/
97 	char	inq_pid[16];		/* product ID 			*/
98 	char	inq_revision[4];	/* revision level 		*/
99 
100 	/*
101 	 * Bytes 36-47 are reserved:
102 	 *	For Sun qualified hard disk drives the inq_serial field contains
103 	 *		two bytes of mfg date year code (ascii)
104 	 *		two bytes of mfg date week code (ascii)
105 	 *		six bytes of mfg serial number (ascii)
106 	 *		two bytes unused
107 	 */
108 	char	inq_serial[12];
109 
110 	/*
111 	 * Bytes 48-95 are reserved.
112 	 * 96 to 'n' are vendor-specific parameter bytes
113 	 */
114 };
115 
116 #elif defined(_BIT_FIELDS_HTOL)
117 
118 struct scsi_inquiry {
119 
120 	/*
121 	 * byte 0
122 	 *
123 	 * Bits 7-5 are the Peripheral Device Qualifier
124 	 * Bits 4-0 are the Peripheral Device Type
125 	 *
126 	 */
127 
128 	uchar_t	inq_dtype;
129 
130 	/* byte 1 */
131 	uchar_t	inq_rmb		: 1,	/* removable media */
132 		inq_qual	: 7;	/* device type qualifier */
133 
134 	/* byte 2 */
135 	uchar_t	inq_iso		: 2,	/* ISO version */
136 		inq_ecma	: 3,	/* ECMA version */
137 		inq_ansi	: 3;	/* ANSI version */
138 
139 	/* byte 3 */
140 	uchar_t	inq_aenc	: 1,	/* async event notification cap. */
141 		inq_trmiop	: 1,	/* supports TERMINATE I/O PROC msg */
142 		inq_normaca	: 1,	/* setting NACA bit supported */
143 				: 1,	/* reserved */
144 		inq_rdf		: 4;	/* response data format */
145 
146 	/* bytes 4-7 */
147 
148 	uchar_t	inq_len;		/* additional length */
149 
150 	uchar_t			: 8;	/* reserved */
151 
152 	uchar_t			: 2,	/* reserved 			*/
153 		inq_port	: 1,	/* port receiving inquiry cmd */
154 		inq_dualp	: 1,	/* dual port device */
155 		inq_mchngr	: 1,	/* embedded/attached to medium chngr */
156 		inq_ackqreqq	: 1,	/* data tranfer on Q cable */
157 		inq_addr32	: 1,	/* supports 32 bit wide SCSI addr */
158 		inq_addr16	: 1;	/* supports 16 bit wide SCSI addr */
159 
160 	uchar_t	inq_reladdr	: 1,	/* supports relative addressing */
161 		inq_wbus32	: 1,	/* supports 32 bit wide data xfers */
162 		inq_wbus16	: 1,	/* supports 16 bit wide data xfers */
163 		inq_sync	: 1,	/* supports synchronous data xfers */
164 		inq_linked	: 1,	/* supports linked commands */
165 		inq_trandis	: 1,	/* supports transfer disable messages */
166 		inq_cmdque	: 1,	/* supports command queueing */
167 		inq_sftre	: 1;	/* supports Soft Reset option */
168 
169 	/* bytes 8-35 */
170 
171 	char	inq_vid[8];		/* vendor ID */
172 
173 	char	inq_pid[16];		/* product ID */
174 
175 	char	inq_revision[4];	/* revision level */
176 
177 	/*
178 	 * Bytes 36-47 are reserved:
179 	 *	For Sun qualified hard disk drives the inq_serial field contains
180 	 *		two bytes of mfg date year code (ascii)
181 	 *		two bytes of mfg date week code (ascii)
182 	 *		six bytes of mfg serial number (ascii)
183 	 *		two bytes unused
184 	 */
185 	char	inq_serial[12];
186 
187 	/*
188 	 * Bytes 48-95 are reserved.
189 	 * 96 to 'n' are vendor-specific parameter bytes
190 	 */
191 };
192 #else
193 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
194 #endif	/* _BIT_FIELDS_LTOH */
195 
196 /*
197  * Defined Peripheral Device Types
198  */
199 
200 #define	DTYPE_DIRECT		0x00
201 #define	DTYPE_SEQUENTIAL	0x01
202 #define	DTYPE_PRINTER		0x02
203 #define	DTYPE_PROCESSOR		0x03
204 #define	DTYPE_WORM		0x04
205 #define	DTYPE_RODIRECT		0x05
206 #define	DTYPE_SCANNER		0x06	/* obsolete */
207 #define	DTYPE_OPTICAL		0x07
208 #define	DTYPE_CHANGER		0x08
209 #define	DTYPE_COMM		0x09	/* obsolete */
210 #define	DTYPE_ARRAY_CTRL	0x0C
211 #define	DTYPE_ESI		0x0D
212 #define	DTYPE_RBC		0x0E
213 #define	DTYPE_OCRW		0x0F
214 #define	DTYPE_BCC		0x10
215 #define	DTYPE_OSD		0x11
216 #define	DTYPE_ADC		0x12
217 /*
218  * Device types 0x13-0x1D are reserved in spc-3 (r23)
219  */
220 
221 #define	DTYPE_WELLKNOWN		0x1E
222 #define	DTYPE_UNKNOWN		0x1F
223 
224 #define	DTYPE_MASK		0x1F
225 
226 /*
227  * The peripheral qualifier tells us more about a particular device.
228  * (DPQ == DEVICE PERIPHERAL QUALIFIER).
229  */
230 
231 #define	DPQ_POSSIBLE	0x00
232 				/*
233 				 * The specified peripheral device type is
234 				 * currently connected to this logical unit.
235 				 * If the target cannot detrermine whether
236 				 * or not a physical device is currently
237 				 * connected, it shall also return this
238 				 * qualifier.
239 				 */
240 
241 #define	DPQ_SUPPORTED	0x20
242 				/*
243 				 * The target is capable of supporting the
244 				 * specified peripheral device type on this
245 				 * logical unit, however the the physical
246 				 * device is not currently connected to this
247 				 * logical unit.
248 				 */
249 
250 #define	DPQ_NEVER	0x60
251 				/*
252 				 * The target is not capable of supporting a
253 				 * physical device on this logical unit. For
254 				 * this peripheral qualifier, the peripheral
255 				 * device type will be set to DTYPE_UNKNOWN
256 				 * in order to provide compatibility with
257 				 * previous versions of SCSI.
258 				 */
259 
260 #define	DPQ_VUNIQ	0x80
261 				/*
262 				 * If this bit is set, this is a vendor
263 				 * unique qualifier.
264 				 */
265 /*
266  * To maintain compatibility with previous versions
267  * of inquiry data formats, if a device peripheral
268  * qualifier states that the target is not capable
269  * of supporting a physical device on this logical unit,
270  * then the qualifier DPQ_NEVER is set, *AND* the
271  * actual device type must be set to DTYPE_UNKNOWN.
272  *
273  * This may make for some problems with older drivers
274  * that blindly check the entire first byte, where they
275  * should be checking for only the least 5 bits to see
276  * whether the correct type is at the specified nexus.
277  */
278 
279 #define	DTYPE_NOTPRESENT	(DPQ_NEVER | DTYPE_UNKNOWN)
280 
281 /*
282  * Defined Response Data Formats
283  *
284  * RDF_LEVEL0 means that this structure complies with SCSI-1 spec.
285  *
286  * RDF_CCS means that this structure complies with CCS pseudo-spec.
287  *
288  * RDF_SCSI2 means that the structure complies with the SCSI-2/3 spec.
289  */
290 
291 #define	RDF_LEVEL0		0x00
292 #define	RDF_CCS			0x01
293 #define	RDF_SCSI2		0x02
294 
295 #ifdef	__cplusplus
296 }
297 #endif
298 
299 /*
300  * Include in implementation specifuc
301  * (non-generic) inquiry definitions.
302  */
303 
304 #include <sys/scsi/impl/inquiry.h>
305 
306 #endif	/* _SYS_SCSI_GENERIC_INQUIRY_H */
307