xref: /titanic_51/usr/src/uts/common/sys/scsi/generic/inquiry.h (revision 98157a7002f4f2cf7978f3084ca5577f0a1d72b2)
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 		inq_hisup	: 1,	/* Hierarchial support		*/
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			: 4,	/* reserved 			*/
76 		inq_tpgs	: 1,	/* supports Target Port Group set */
77 				: 3;
78 	uchar_t	inq_addr16	: 1,	/* supports 16 bit wide SCSI addr */
79 		inq_addr32	: 1,	/* supports 32 bit wide SCSI addr */
80 		inq_ackqreqq	: 1,	/* data tranfer on Q cable */
81 		inq_mchngr	: 1,	/* embedded/attached to medium chngr */
82 		inq_dualp	: 1,	/* dual port device */
83 		inq_port	: 1,	/* port receiving inquiry cmd */
84 				: 2;	/* reserved 			*/
85 
86 	uchar_t	inq_sftre	: 1,	/* supports Soft Reset option 	*/
87 		inq_cmdque	: 1,	/* supports command queueing 	*/
88 		inq_trandis	: 1,	/* supports transfer disable messages */
89 		inq_linked	: 1,	/* supports linked commands 	*/
90 		inq_sync	: 1,	/* supports synchronous data xfers */
91 		inq_wbus16	: 1,	/* supports 16 bit wide data xfers */
92 		inq_wbus32	: 1,	/* supports 32 bit wide data xfers */
93 		inq_reladdr	: 1;	/* supports relative addressing */
94 
95 	/* bytes 8-35 */
96 
97 	char	inq_vid[8];		/* vendor ID 			*/
98 	char	inq_pid[16];		/* product ID 			*/
99 	char	inq_revision[4];	/* revision level 		*/
100 
101 	/*
102 	 * Bytes 36-47 are reserved:
103 	 *	For Sun qualified hard disk drives the inq_serial field contains
104 	 *		two bytes of mfg date year code (ascii)
105 	 *		two bytes of mfg date week code (ascii)
106 	 *		six bytes of mfg serial number (ascii)
107 	 *		two bytes unused
108 	 */
109 	char	inq_serial[12];
110 
111 	/*
112 	 * Bytes 48-95 are reserved.
113 	 * 96 to 'n' are vendor-specific parameter bytes
114 	 */
115 };
116 
117 #elif defined(_BIT_FIELDS_HTOL)
118 
119 struct scsi_inquiry {
120 
121 	/*
122 	 * byte 0
123 	 *
124 	 * Bits 7-5 are the Peripheral Device Qualifier
125 	 * Bits 4-0 are the Peripheral Device Type
126 	 *
127 	 */
128 
129 	uchar_t	inq_dtype;
130 
131 	/* byte 1 */
132 	uchar_t	inq_rmb		: 1,	/* removable media */
133 		inq_qual	: 7;	/* device type qualifier */
134 
135 	/* byte 2 */
136 	uchar_t	inq_iso		: 2,	/* ISO version */
137 		inq_ecma	: 3,	/* ECMA version */
138 		inq_ansi	: 3;	/* ANSI version */
139 
140 	/* byte 3 */
141 	uchar_t	inq_aenc	: 1,	/* async event notification cap. */
142 		inq_trmiop	: 1,	/* supports TERMINATE I/O PROC msg */
143 		inq_normaca	: 1,	/* setting NACA bit supported */
144 		inq_hisup	: 1,	/* hierachial support */
145 		inq_rdf		: 4;	/* response data format */
146 
147 	/* bytes 4-7 */
148 
149 	uchar_t	inq_len;		/* additional length */
150 
151 	uchar_t			: 3,	/* reserved */
152 		inq_tpgs	: 1,	/* supports Target Port Group Set */
153 				: 4;
154 
155 	uchar_t			: 2,	/* reserved 			*/
156 		inq_port	: 1,	/* port receiving inquiry cmd */
157 		inq_dualp	: 1,	/* dual port device */
158 		inq_mchngr	: 1,	/* embedded/attached to medium chngr */
159 		inq_ackqreqq	: 1,	/* data tranfer on Q cable */
160 		inq_addr32	: 1,	/* supports 32 bit wide SCSI addr */
161 		inq_addr16	: 1;	/* supports 16 bit wide SCSI addr */
162 
163 	uchar_t	inq_reladdr	: 1,	/* supports relative addressing */
164 		inq_wbus32	: 1,	/* supports 32 bit wide data xfers */
165 		inq_wbus16	: 1,	/* supports 16 bit wide data xfers */
166 		inq_sync	: 1,	/* supports synchronous data xfers */
167 		inq_linked	: 1,	/* supports linked commands */
168 		inq_trandis	: 1,	/* supports transfer disable messages */
169 		inq_cmdque	: 1,	/* supports command queueing */
170 		inq_sftre	: 1;	/* supports Soft Reset option */
171 
172 	/* bytes 8-35 */
173 
174 	char	inq_vid[8];		/* vendor ID */
175 
176 	char	inq_pid[16];		/* product ID */
177 
178 	char	inq_revision[4];	/* revision level */
179 
180 	/*
181 	 * Bytes 36-47 are reserved:
182 	 *	For Sun qualified hard disk drives the inq_serial field contains
183 	 *		two bytes of mfg date year code (ascii)
184 	 *		two bytes of mfg date week code (ascii)
185 	 *		six bytes of mfg serial number (ascii)
186 	 *		two bytes unused
187 	 */
188 	char	inq_serial[12];
189 
190 	/*
191 	 * Bytes 48-95 are reserved.
192 	 * 96 to 'n' are vendor-specific parameter bytes
193 	 */
194 };
195 #else
196 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
197 #endif	/* _BIT_FIELDS_LTOH */
198 
199 /*
200  * Defined Peripheral Device Types
201  */
202 
203 #define	DTYPE_DIRECT		0x00
204 #define	DTYPE_SEQUENTIAL	0x01
205 #define	DTYPE_PRINTER		0x02
206 #define	DTYPE_PROCESSOR		0x03
207 #define	DTYPE_WORM		0x04
208 #define	DTYPE_RODIRECT		0x05
209 #define	DTYPE_SCANNER		0x06	/* obsolete */
210 #define	DTYPE_OPTICAL		0x07
211 #define	DTYPE_CHANGER		0x08
212 #define	DTYPE_COMM		0x09	/* obsolete */
213 #define	DTYPE_ARRAY_CTRL	0x0C
214 #define	DTYPE_ESI		0x0D
215 #define	DTYPE_RBC		0x0E
216 #define	DTYPE_OCRW		0x0F
217 #define	DTYPE_BCC		0x10
218 #define	DTYPE_OSD		0x11
219 #define	DTYPE_ADC		0x12
220 /*
221  * Device types 0x13-0x1D are reserved in spc-3 (r23)
222  */
223 
224 #define	DTYPE_WELLKNOWN		0x1E
225 #define	DTYPE_UNKNOWN		0x1F
226 
227 #define	DTYPE_MASK		0x1F
228 
229 /*
230  * The peripheral qualifier tells us more about a particular device.
231  * (DPQ == DEVICE PERIPHERAL QUALIFIER).
232  */
233 
234 #define	DPQ_POSSIBLE	0x00
235 				/*
236 				 * The specified peripheral device type is
237 				 * currently connected to this logical unit.
238 				 * If the target cannot detrermine whether
239 				 * or not a physical device is currently
240 				 * connected, it shall also return this
241 				 * qualifier.
242 				 */
243 
244 #define	DPQ_SUPPORTED	0x20
245 				/*
246 				 * The target is capable of supporting the
247 				 * specified peripheral device type on this
248 				 * logical unit, however the the physical
249 				 * device is not currently connected to this
250 				 * logical unit.
251 				 */
252 
253 #define	DPQ_NEVER	0x60
254 				/*
255 				 * The target is not capable of supporting a
256 				 * physical device on this logical unit. For
257 				 * this peripheral qualifier, the peripheral
258 				 * device type will be set to DTYPE_UNKNOWN
259 				 * in order to provide compatibility with
260 				 * previous versions of SCSI.
261 				 */
262 
263 #define	DPQ_VUNIQ	0x80
264 				/*
265 				 * If this bit is set, this is a vendor
266 				 * unique qualifier.
267 				 */
268 /*
269  * To maintain compatibility with previous versions
270  * of inquiry data formats, if a device peripheral
271  * qualifier states that the target is not capable
272  * of supporting a physical device on this logical unit,
273  * then the qualifier DPQ_NEVER is set, *AND* the
274  * actual device type must be set to DTYPE_UNKNOWN.
275  *
276  * This may make for some problems with older drivers
277  * that blindly check the entire first byte, where they
278  * should be checking for only the least 5 bits to see
279  * whether the correct type is at the specified nexus.
280  */
281 
282 #define	DTYPE_NOTPRESENT	(DPQ_NEVER | DTYPE_UNKNOWN)
283 
284 /*
285  * Defined Response Data Formats
286  *
287  * RDF_LEVEL0 means that this structure complies with SCSI-1 spec.
288  *
289  * RDF_CCS means that this structure complies with CCS pseudo-spec.
290  *
291  * RDF_SCSI2 means that the structure complies with the SCSI-2/3 spec.
292  */
293 
294 #define	RDF_LEVEL0		0x00
295 #define	RDF_CCS			0x01
296 #define	RDF_SCSI2		0x02
297 
298 /*
299  * SPC-3 revision 21c, section 7.6.4.1
300  * Table 289 -- Device Identification VPD page
301  */
302 struct vpd_hdr {
303 #if defined(_BIT_FIELDS_LTOH)
304 	uchar_t	device_type	: 4,
305 		periph_qual	: 4;
306 #elif defined(_BIT_FIELDS_HTOL)
307 	uchar_t	periph_qual	: 4,
308 		device_type	: 4;
309 #else
310 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
311 #endif
312 	uchar_t	page_code,
313 		page_len[2];
314 };
315 
316 /*
317  * SPC-3 revision 21c, section 7.6.4.1
318  * Table 290 -- Identification descriptor
319  */
320 struct vpd_desc {
321 #if defined(_BIT_FIELDS_LTOH)
322 	uchar_t	code_set	: 4,
323 		proto_id	: 4;
324 	uchar_t id_type		: 4,
325 		association	: 2,
326 				: 1,
327 		piv		: 1;
328 #elif defined(_BIT_FIELDS_HTOL)
329 	uchar_t	proto_id	: 4,
330 		code_set	: 4;
331 	uchar_t piv		: 1,
332 				: 1,
333 		association	: 2,
334 		id_type		: 4;
335 #else
336 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
337 #endif
338 	uchar_t	resrv1;
339 	uchar_t	len;
340 	/* ---- data follows ---- */
341 };
342 
343 #ifdef	__cplusplus
344 }
345 #endif
346 
347 /*
348  * Include in implementation specifuc
349  * (non-generic) inquiry definitions.
350  */
351 
352 #include <sys/scsi/impl/inquiry.h>
353 
354 #endif	/* _SYS_SCSI_GENERIC_INQUIRY_H */
355