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