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