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 2009 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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /*
34 * SCSI Standard Inquiry Data:
35 *
36 * Format of data returned as a result of an INQUIRY command.
37 *
38 * NOTE: Fields marked 'DEPRECATED' are defined in older versions of t10 "SCSI
39 * Primary Command" spec, and are marked 'Obsolete' in newer versions.
40 */
41 #if defined(_BIT_FIELDS_LTOH)
42 struct scsi_inquiry {
43 /*
44 * byte 0
45 *
46 * Bits 7-5 are the Peripheral Device Qualifier
47 * Bits 4-0 are the Peripheral Device Type
48 */
49 uchar_t inq_dtype;
50
51 /* byte 1 */
52 uchar_t inq_qual : 7, /* device type qualifier */
53 inq_rmb : 1; /* removable media */
54
55 /* byte 2 */
56 uchar_t inq_ansi : 3, /* ANSI version */
57 inq_ecma : 3, /* ECMA version */
58 inq_iso : 2; /* ISO version */
59
60 /* byte 3 */
61 uchar_t inq_rdf : 4, /* response data format */
62 inq_hisup : 1, /* hierarchical addressing model */
63 inq_normaca : 1, /* setting NACA bit supported */
64 inq_trmiop : 1, /* DEPRECATED: terminate I/O proc */
65 inq_aenc : 1; /* DEPRECATED: async event notify */
66
67 /* bytes 4-7 */
68 uchar_t inq_len; /* additional length */
69
70 uchar_t inq_protect : 1, /* supports protection information */
71 inq_5_1 : 1,
72 inq_5_2 : 1,
73 inq_3pc : 1, /* third-party copy */
74 inq_tpgs : 2, /* impl/expl asymmetric lun access */
75 inq_acc : 1, /* access controls coordinator */
76 inq_sccs : 1; /* embedded storage array */
77
78 uchar_t inq_addr16 : 1, /* SPI: 16-bit wide SCSI addr */
79 inq_addr32 : 1, /* DEPRECATED: 32 bit wide address */
80 inq_ackqreqq : 1, /* DEPRECATED: data xfer on Q cable */
81 inq_mchngr : 1, /* DEPRECATED: embeded medium changer */
82 inq_dualp : 1, /* multi port device */
83 inq_port : 1, /* DEPRECATED: port rcv inquiry cmd */
84 inq_encserv : 1, /* embedded enclosure services */
85 inq_bque : 1; /* DEPRECATED: combined with cmdque */
86
87 uchar_t inq_sftre : 1, /* DEPRECATED: Soft Reset option */
88 inq_cmdque : 1, /* supports command queueing */
89 inq_trandis : 1, /* DEPRECATED: transfer disable msgs */
90 inq_linked : 1, /* DEPRECATED: linked commands */
91 inq_sync : 1, /* SPI: synchronous data xfers */
92 inq_wbus16 : 1, /* SPI: 16-bit wide data xfers */
93 inq_wbus32 : 1, /* DEPRECATED: 32 bit wide data xfers */
94 inq_reladdr : 1; /* DEPRECATED: relative addressing */
95
96 /* bytes 8-35 */
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-55 are reserved.
113 */
114 uchar_t __inq_48 : 8;
115 uchar_t __inq_49 : 8;
116 uchar_t __inq_50 : 8;
117 uchar_t __inq_51 : 8;
118 uchar_t __inq_52 : 8;
119 uchar_t __inq_53 : 8;
120 uchar_t __inq_54 : 8;
121 uchar_t __inq_55 : 8;
122
123 /*
124 * The meanings of byte 56 is specific to SPI-3. For protocols older
125 * or other than this these fields are reserved.
126 */
127 uchar_t inq_ius : 1, /* SPI3: information units */
128 inq_qas : 1, /* SPI3: quick arb sel */
129 inq_clk : 2, /* SPI3: clocking */
130 __inq_56_4 : 1, /* reserved */
131 __inq_56_5 : 1, /* reserved */
132 __inq_56_6 : 1, /* reserved */
133 __inq_56_7 : 1; /* reserved */
134
135 uchar_t __inq_57 : 8; /* reserved */
136
137 /*
138 * byte pairs 58-73 are version descriptors
139 * See: Table 51: dpANS SCSI Primary Commands - 2 (SPC-2) T10/1236
140 */
141 struct inq_vd {
142 uchar_t inq_vd_msb;
143 uchar_t inq_vd_lsb;
144 } inq_vd[8];
145
146 /*
147 * Bytes 74-95 are reserved.
148 * 96 to 'n' are vendor-specific parameter bytes.
149 *
150 * Pad structure to 132 bytes so that access to some vendor-specific
151 * data is possible via scsi_device(9S) sd_inq (for mpxio).
152 */
153 uchar_t __inq_74_127[132 - 74];
154 };
155
156 #elif defined(_BIT_FIELDS_HTOL)
157
158 struct scsi_inquiry {
159 /*
160 * byte 0
161 *
162 * Bits 7-5 are the Peripheral Device Qualifier
163 * Bits 4-0 are the Peripheral Device Type
164 */
165 uchar_t inq_dtype;
166
167 /* byte 1 */
168 uchar_t inq_rmb : 1, /* removable media */
169 inq_qual : 7; /* device type qualifier */
170
171 /* byte 2 */
172 uchar_t inq_iso : 2, /* ISO version */
173 inq_ecma : 3, /* ECMA version */
174 inq_ansi : 3; /* ANSI version */
175
176 /* byte 3 */
177 uchar_t inq_aenc : 1, /* DEPRECATED: async event notify */
178 inq_trmiop : 1, /* DEPRECATED: terminate I/O proc */
179 inq_normaca : 1, /* setting NACA bit supported */
180 inq_hisup : 1, /* hierarchical addressing model */
181 inq_rdf : 4; /* response data format */
182
183 /* bytes 4-7 */
184 uchar_t inq_len; /* additional length */
185
186 uchar_t inq_sccs : 1, /* embedded storage array */
187 inq_acc : 1, /* access controls coordinator */
188 inq_tpgs : 2, /* impl/expl asymmetric lun access */
189 inq_3pc : 1, /* third-party copy */
190 inq_5_2 : 1,
191 inq_5_1 : 1,
192 inq_protect : 1; /* supports protection information */
193
194 uchar_t inq_bque : 1, /* DEPRECATED: combined with cmdque */
195 inq_encserv : 1, /* embedded enclosure services */
196 inq_port : 1, /* DEPRECATED: port rcv inquiry cmd */
197 inq_dualp : 1, /* multi port device */
198 inq_mchngr : 1, /* DEPRECATED: embeded medium changer */
199 inq_ackqreqq : 1, /* DEPRECATED: data xfer on Q cable */
200 inq_addr32 : 1, /* DEPRECATED: 32 bit wide address */
201 inq_addr16 : 1; /* SPI: 16-bit wide SCSI addr */
202
203 uchar_t inq_reladdr : 1, /* DEPRECATED: relative addressing */
204 inq_wbus32 : 1, /* DEPRECATED: 32 bit wide data xfers */
205 inq_wbus16 : 1, /* SPI: 16-bit wide data xfers */
206 inq_sync : 1, /* SPI: synchronous data xfers */
207 inq_linked : 1, /* DEPRECATED: linked commands */
208 inq_trandis : 1, /* DEPRECATED: transfer disable msgs */
209 inq_cmdque : 1, /* supports command queueing */
210 inq_sftre : 1; /* DEPRECATED: Soft Reset option */
211
212 /* bytes 8-35 */
213 char inq_vid[8]; /* vendor ID */
214 char inq_pid[16]; /* product ID */
215 char inq_revision[4]; /* revision level */
216
217 /*
218 * Bytes 36-47 are reserved:
219 * For Sun qualified hard disk drives the inq_serial field contains
220 * two bytes of mfg date year code (ascii)
221 * two bytes of mfg date week code (ascii)
222 * six bytes of mfg serial number (ascii)
223 * two bytes unused
224 */
225 char inq_serial[12];
226
227 /*
228 * Bytes 48-55 are reserved.
229 */
230 uchar_t __inq_48 : 8;
231 uchar_t __inq_49 : 8;
232 uchar_t __inq_50 : 8;
233 uchar_t __inq_51 : 8;
234 uchar_t __inq_52 : 8;
235 uchar_t __inq_53 : 8;
236 uchar_t __inq_54 : 8;
237 uchar_t __inq_55 : 8;
238
239 /*
240 * The meanings of byte 56 is specific to SPI-3. For protocols older
241 * or other than this these fields are reserved.
242 */
243 uchar_t __inq_56_7 : 1, /* reserved */
244 __inq_56_6 : 1, /* reserved */
245 __inq_56_5 : 1, /* reserved */
246 __inq_56_4 : 1, /* reserved */
247 inq_clk : 2, /* SPI3: clocking */
248 inq_qas : 1, /* SPI3: quick arb sel */
249 inq_ius : 1; /* SPI3: information units */
250
251 uchar_t __inq_57 : 8; /* reserved */
252
253 /*
254 * byte pairs 58-73 are version descriptors
255 * See: Table 51: dpANS SCSI Primary Commands - 2 (SPC-2) T10/1236
256 */
257 struct inq_vd {
258 uchar_t inq_vd_msb;
259 uchar_t inq_vd_lsb;
260 } inq_vd[8];
261
262 /*
263 * Bytes 74-95 are reserved.
264 * 96 to 'n' are vendor-specific parameter bytes.
265 *
266 * Pad structure to 132 bytes so that access to some vendor-specific
267 * data is possible via scsi_device(9S) sd_inq (for mpxio).
268 */
269 uchar_t __inq_74_127[132 - 74];
270 };
271 #else
272 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
273 #endif /* _BIT_FIELDS_LTOH */
274
275 /*
276 * Defined Peripheral Device Types
277 */
278 #define DTYPE_DIRECT 0x00 /* magnetic disk */
279 #define DTYPE_SEQUENTIAL 0x01 /* magnetic tape */
280 #define DTYPE_PRINTER 0x02
281 #define DTYPE_PROCESSOR 0x03
282 #define DTYPE_WORM 0x04 /* some optical disks */
283 #define DTYPE_RODIRECT 0x05
284 #define DTYPE_SCANNER 0x06 /* obsolete */
285 #define DTYPE_OPTICAL 0x07
286 #define DTYPE_CHANGER 0x08 /* jukeboxes */
287 #define DTYPE_COMM 0x09 /* obsolete */
288 #define DTYPE_ARRAY_CTRL 0x0C
289 #define DTYPE_ESI 0x0D /* Enclosure services device */
290 #define DTYPE_RBC 0x0E /* Simplified direct-access device */
291 #define DTYPE_OCRW 0x0F /* Optical card reader/writer device */
292 #define DTYPE_BCC 0x10
293 #define DTYPE_OSD 0x11 /* Object-based Storage Device */
294 #define DTYPE_ADC 0x12
295 /*
296 * Device types 0x13-0x1D are reserved in spc-3 (r23)
297 */
298
299 #define DTYPE_WELLKNOWN 0x1E
300 #define DTYPE_UNKNOWN 0x1F
301 #define DTYPE_MASK 0x1F
302
303 /* ASCII mapping used by scsi_dname(9F) */
304 #define DTYPE_ASCII { \
305 "Direct Access", "Sequential Access", "Printer", "Processor", \
306 "Write-Once/Read-Many", "Read-Only Direct Access", "Scanner", \
307 "Optical", "Changer", "Communications", "Unknown-0A", \
308 "Unknown-0B", "Array Controller", "Enclosure-Services", \
309 "Simplified-Direct-Access", "Optical-Card", "Bridge", \
310 "Object-Storage", NULL}
311
312 /*
313 * The peripheral qualifier tells us more about a particular device.
314 * (DPQ == DEVICE PERIPHERAL QUALIFIER).
315 */
316 #define DPQ_MASK 0x60 /* DPQ bits */
317 #define DPQ_POSSIBLE 0x00
318 /*
319 * The specified peripheral device type is
320 * currently connected to this logical unit.
321 * If the target cannot determine whether
322 * or not a physical device is currently
323 * connected, it shall also return this
324 * qualifier.
325 */
326 #define DPQ_SUPPORTED 0x20
327 /*
328 * The target is capable of supporting the
329 * specified peripheral device type on this
330 * logical unit, however the physical device
331 * is not currently connected to this logical
332 * unit.
333 */
334 #define DPQ_NEVER 0x60
335 /*
336 * The target is not capable of supporting a
337 * physical device on this logical unit. For
338 * this peripheral qualifier, the peripheral
339 * device type will be set to DTYPE_UNKNOWN
340 * in order to provide compatibility with
341 * previous versions of SCSI.
342 */
343 #define DPQ_VUNIQ 0x80
344 /*
345 * If this bit is set, this is a vendor
346 * unique qualifier.
347 */
348
349 /*
350 * To maintain compatibility with previous versions
351 * of inquiry data formats, if a device peripheral
352 * qualifier states that the target is not capable
353 * of supporting a physical device on this logical unit,
354 * then the qualifier DPQ_NEVER is set, *AND* the
355 * actual device type must be set to DTYPE_UNKNOWN.
356 *
357 * This may make for some problems with older drivers
358 * that blindly check the entire first byte, where they
359 * should be checking for only the least 5 bits to see
360 * whether the correct type is at the specified nexus.
361 */
362 #define DTYPE_NOTPRESENT (DPQ_NEVER | DTYPE_UNKNOWN)
363
364 /*
365 * Defined Response Data Formats:
366 */
367 #define RDF_LEVEL0 0x00 /* no conformance claim (SCSI-1) */
368 #define RDF_CCS 0x01 /* Obsolete (pseudo-spec) */
369 #define RDF_SCSI2 0x02 /* Obsolete (SCSI-2/3 spec) */
370 #define RDF_SCSI_SPC 0x03 /* ANSI INCITS 301-1997 (SPC) */
371 #define RDF_SCSI_SPC2 0x04 /* ANSI INCITS 351-2001 (SPC-2) */
372 #define RDF_SCSI_SPC3 0x05 /* ANSI INCITS 408-2005 (SPC-3) */
373 #define RDF_SCSI_SPC4 0x06 /* t10 (SPC-4) */
374
375 /*
376 * Defined Target Port Group Select values:
377 */
378 #define TPGS_FAILOVER_NONE 0x0
379 #define TPGS_FAILOVER_IMPLICIT 0x1
380 #define TPGS_FAILOVER_EXPLICIT 0x2
381 #define TPGS_FAILOVER_BOTH 0x3
382
383 /*
384 * SPC-3 revision 21c, section 7.6.4.1
385 * Table 289 -- Device Identification VPD page
386 */
387 struct vpd_hdr {
388 #if defined(_BIT_FIELDS_LTOH)
389 uchar_t device_type : 4,
390 periph_qual : 4;
391 #elif defined(_BIT_FIELDS_HTOL)
392 uchar_t periph_qual : 4,
393 device_type : 4;
394 #else
395 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
396 #endif
397 uchar_t page_code,
398 page_len[2];
399 };
400
401 /*
402 * SPC-3 revision 21c, section 7.6.4.1
403 * Table 290 -- Identification descriptor
404 */
405 struct vpd_desc {
406 #if defined(_BIT_FIELDS_LTOH)
407 uchar_t code_set : 4,
408 proto_id : 4;
409 uchar_t id_type : 4,
410 association : 2,
411 : 1,
412 piv : 1;
413 #elif defined(_BIT_FIELDS_HTOL)
414 uchar_t proto_id : 4,
415 code_set : 4;
416 uchar_t piv : 1,
417 : 1,
418 association : 2,
419 id_type : 4;
420 #else
421 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
422 #endif
423 uchar_t resrv1;
424 uchar_t len;
425 /* ---- data follows ---- */
426 };
427
428 /*
429 * "pm-capable" integer property bit mask definitions
430 */
431 #define PM_CAPABLE_PM_MASK 0x0000ffff /* use lower 16 bits to */
432 /* indicate PM mode */
433 #define PM_CAPABLE_CCS RDF_CCS
434 #define PM_CAPABLE_SCSI2 RDF_SCSI2
435 #define PM_CAPABLE_SPC RDF_SCSI_SPC
436 #define PM_CAPABLE_SPC2 RDF_SCSI_SPC2
437 #define PM_CAPABLE_SPC3 RDF_SCSI_SPC3
438 #define PM_CAPABLE_SPC4 RDF_SCSI_SPC4
439 #define PM_CAPABLE_LOG_MASK 0xffff0000 /* use upper 16 bit to */
440 /* indicate log specifics */
441 #define PM_CAPABLE_LOG_SUPPORTED 0x10000 /* Log page 0xE might be */
442 /* supported */
443 #define PM_CAPABLE_SMART_LOG 0x20000 /* Log page 0xE reports SMART */
444 /* attributes instead of the */
445 /* default SCSI Log pages */
446 #ifdef __cplusplus
447 }
448 #endif
449
450 /*
451 * Include in implementation specifuc
452 * (non-generic) inquiry definitions.
453 */
454
455 #include <sys/scsi/impl/inquiry.h>
456
457 #endif /* _SYS_SCSI_GENERIC_INQUIRY_H */