xref: /titanic_51/usr/src/uts/common/sys/scsi/impl/spc3_types.h (revision 9241eba2ee6b19f556bc3779eef7f62da5efffe5)
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 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2016 Joyent, Inc.
25  */
26 
27 #ifndef	_SPC3_TYPES_H
28 #define	_SPC3_TYPES_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 #include <sys/cdio.h>
36 #include <sys/sysmacros.h>
37 #include <sys/scsi/generic/commands.h>
38 #include <sys/scsi/impl/commands.h>
39 
40 typedef enum spc3_cmd {
41 	SPC3_CMD_TEST_UNIT_READY = SCMD_TEST_UNIT_READY,
42 	SPC3_CMD_REZERO_UNIT = SCMD_REZERO_UNIT,
43 	SPC3_CMD_REWIND = SCMD_REWIND,
44 	SPC3_CMD_VENDOR_2 = 2,
45 	SPC3_CMD_REQUEST_SENSE = SCMD_REQUEST_SENSE,
46 	SPC3_CMD_FORMAT_UNIT = SCMD_FORMAT,
47 	SPC3_CMD_FORMAT_MEDIUM = SCMD_FORMAT,
48 	SPC3_CMD_FORMAT = SCMD_FORMAT,
49 	SPC3_CMD_READ_BLOCK_LIMITS = SCMD_READ_BLKLIM,
50 	SPC3_CMD_VENDOR_6 = 6,
51 	SPC3_CMD_REASSIGN_BLOCKS = SCMD_REASSIGN_BLOCK,
52 	SPC3_CMD_INITIALIZE_ELEMENT_STATUS = SCMD_REASSIGN_BLOCK,
53 	SPC3_CMD_READ = SCMD_READ,
54 	SPC3_CMD_READ6 = SCMD_READ,
55 	SPC3_CMD_RECEIVE = SCMD_RECEIVE,
56 	SPC3_CMD_GET_MESSAGE = SCMD_READ,
57 	SPC3_CMD_VENDOR_9 = 9,
58 	SPC3_CMD_WRITE = SCMD_WRITE,
59 	SPC3_CMD_WRITE6 = SCMD_WRITE,
60 	SPC3_CMD_SEND = SCMD_SEND,
61 	SPC3_CMD_SEND6 = SCMD_SEND,
62 	SPC3_CMD_SEND_MESSAGE = SCMD_SEND,
63 	SPC3_CMD_PRINT = SCMD_PRINT,
64 	SPC3_CMD_SEEK = SCMD_SEEK,
65 	SPC3_CMD_SEEK6 = SCMD_SEEK,
66 	SPC3_CMD_SET_CAPACITY = SCMD_SEEK,
67 	SPC3_CMD_SLEW_AND_PRINT = SCMD_SLEW_PRINT,
68 	SPC3_CMD_VENDOR_C = 0xc,
69 	SPC3_CMD_VENDOR_D = 0xd,
70 	SPC3_CMD_VENDOR_E = 0xe,
71 	SPC3_CMD_READ_REVERSE = SCMD_READ_REVERSE,
72 	SPC3_CMD_READ_REVERSE6 = SCMD_READ_REVERSE,
73 	SPC3_CMD_WRITE_FILEMARKS = SCMD_WRITE_FILE_MARK,
74 	SPC3_CMD_WRITE_FILEMARKS6 = SCMD_WRITE_FILE_MARK,
75 	SPC3_CMD_SYNCHRONIZE_BUFFER = SCMD_FLUSH_PRINT_BUF,
76 	SPC3_CMD_SPACE = SCMD_SPACE,
77 	SPC3_CMD_SPACE6 = SCMD_SPACE,
78 	SPC3_CMD_INQUIRY = SCMD_INQUIRY,
79 	SPC3_CMD_VERIFY = SCMD_VERIFY_G0,
80 	SPC3_CMD_VERIFY6 = SCMD_VERIFY_G0,
81 	SPC3_CMD_RECOVER_BUFFERED_DATA = SCMD_RECOVER_BUF,
82 	SPC3_CMD_MODE_SELECT = SCMD_MODE_SELECT,
83 	SPC3_CMD_MODE_SELECT6 = SCMD_MODE_SELECT,
84 	SPC3_CMD_RESERVE = SCMD_RESERVE,
85 	SPC3_CMD_RESERVE6 = SCMD_RESERVE,
86 	SPC3_CMD_RESERVE_ELEMENT = SCMD_RESERVE,
87 	SPC3_CMD_RESERVE_ELEMENT6 = SCMD_RESERVE,
88 	SPC3_CMD_RELEASE = SCMD_RELEASE,
89 	SPC3_CMD_RELEASE6 = SCMD_RELEASE,
90 	SPC3_CMD_RELEASE_ELEMENT = SCMD_RELEASE,
91 	SPC3_CMD_RELEASE_ELEMENT6 = SCMD_RELEASE,
92 	SPC3_CMD_COPY = SCMD_COPY,
93 	SPC3_CMD_ERASE = SCMD_ERASE,
94 	SPC3_CMD_ERASE6 = SCMD_ERASE,
95 	SPC3_CMD_MODE_SENSE = SCMD_MODE_SENSE,
96 	SPC3_CMD_MODE_SENSE6 = SCMD_MODE_SENSE,
97 	SPC3_CMD_START_STOP_UNIT = SCMD_START_STOP,
98 	SPC3_CMD_LOAD_UNLOAD = SCMD_LOAD,
99 	SPC3_CMD_SCAN = SCMD_START_STOP,
100 	SPC3_CMD_STOP_PRINT = SCMD_STOP_PRINT,
101 	SPC3_CMD_RECEIVE_DIAGNOSTIC_RESULTS = SCMD_GDIAG,
102 	SPC3_CMD_SEND_DIAGNOSTIC = SCMD_SDIAG,
103 	SPC3_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = SCMD_DOORLOCK,
104 	SPC3_CMD_VENDOR_20 = 0x20,
105 	SPC3_CMD_VENDOR_21 = 0x21,
106 	SPC3_CMD_VENDOR_22 = 0x22,
107 	SPC3_CMD_VENDOR_23 = 0x23,
108 	SPC3_CMD_SET_WINDOW = 0x24,
109 	SPC3_CMD_READ_CAPACITY = SCMD_READ_CAPACITY,
110 	SPC3_CMD_READ_CAPACITY10 = SCMD_READ_CAPACITY,
111 	SPC3_CMD_READ_CARD_CAPACITY = SCMD_READ_CAPACITY,
112 	SPC3_CMD_GET_WINDOW = SCMD_READ_CAPACITY,
113 	SPC3_CMD_VENDOR_26 = 0x26,
114 	SPC3_CMD_VENDOR_27 = 0x27,
115 	SPC3_CMD_READ10 = SCMD_READ_G1,
116 	SPC3_CMD_GET_MESSAGE10 = SCMD_READ_G1,
117 	SPC3_CMD_READ_GENERATION = 0x29,
118 	SPC3_CMD_WRITE10 = SCMD_WRITE_G1,
119 	SPC3_CMD_SEND10 = SCMD_WRITE_G1,
120 	SPC3_CMD_SEND_MESSAGE10 = SCMD_WRITE_G1,
121 	SPC3_CMD_SEEK10 = SCMD_SEEK_G1,
122 	SPC3_CMD_LOCATE = SCMD_LOCATE,
123 	SPC3_CMD_LOCATE10 = SCMD_LOCATE,
124 	SPC3_CMD_POSITION_TO_ELEMENT = SCMD_SEEK_G1,
125 	SPC3_CMD_ERASE10 = 0x2c,
126 	SPC3_CMD_READ_UPDATED_BLOCK = 0x2d,
127 	SPC3_CMD_WRITE_AND_VERIFY = SCMD_WRITE_VERIFY,
128 	SPC3_CMD_WRITE_AND_VERIFY10 = SCMD_WRITE_VERIFY,
129 	SPC3_CMD_VERIFY10 = SCMD_VERIFY,
130 	SPC3_CMD_SEARCH_DATA_HIGH = SCMD_SEARCH_HIGH,
131 	SPC3_CMD_SEARCH_DATA_HIGH10 = SCMD_SEARCH_HIGH,
132 	SPC3_CMD_SEARCH_DATA_EQUAL = SCMD_SEARCH_EQUAL,
133 	SPC3_CMD_SEARCH_DATA_EQUAL10 = SCMD_SEARCH_EQUAL,
134 	SPC3_CMD_OBJECT_POSITION = SCMD_SEARCH_EQUAL,
135 	SPC3_CMD_SEARCH_DATA_LOW = SCMD_SEARCH_LOW,
136 	SPC3_CMD_SEARCH_DATA_LOW10 = SCMD_SEARCH_LOW,
137 	SPC3_CMD_SET_LIMITS = SCMD_SET_LIMITS,
138 	SPC3_CMD_SET_LIMITS10 = SCMD_SET_LIMITS,
139 	SPC3_CMD_PREFETCH = SCMD_READ_POSITION,
140 	SPC3_CMD_PREFETCH10 = SCMD_READ_POSITION,
141 	SPC3_CMD_READ_POSITION = SCMD_READ_POSITION,
142 	SPC3_CMD_GET_DATA_BUFFER_STATUS = SCMD_READ_POSITION,
143 	SPC3_CMD_SYNCHRONIZE_CACHE = SCMD_SYNCHRONIZE_CACHE,
144 	SPC3_CMD_SYNCHRONIZE_CACHE10 = SCMD_SYNCHRONIZE_CACHE,
145 	SPC3_CMD_LOCK_UNLOCK_CACHE = 0x36,
146 	SPC3_CMD_READ_DEFECT_DATA = SCMD_READ_DEFECT_LIST,
147 	SPC3_CMD_READ_DEFECT_DATA10 = SCMD_READ_DEFECT_LIST,
148 	SPC3_CMD_INITIALIZE_ELEMENT_STATUS_WITH_RANGE = SCMD_READ_DEFECT_LIST,
149 	SPC3_CMD_MEDIUM_SCAN = 0x38,
150 	SPC3_CMD_COMPARE = SCMD_COMPARE,
151 	SPC3_CMD_COPY_AND_VERIFY = SCMD_COPY_VERIFY,
152 	SPC3_CMD_WRITE_BUFFER = SCMD_WRITE_BUFFER,
153 	SPC3_CMD_READ_BUFFER = SCMD_READ_BUFFER,
154 	SPC3_CMD_UPDATE_BLOCK = 0x3d,
155 	SPC3_CMD_READ_LONG = SCMD_READ_LONG,
156 	SPC3_CMD_READ_LONG10 = SCMD_READ_LONG,
157 	SPC3_CMD_WRITE_LONG = SCMD_WRITE_LONG,
158 	SPC3_CMD_WRITE_LONG10 = SCMD_WRITE_LONG,
159 	SPC3_CMD_CHANGE_DEFINITION = 0x40,
160 	SPC3_CMD_WRITE_SAME = 0x41,
161 	SPC3_CMD_WRITE_SAME10 = 0x41,
162 	SPC3_CMD_UNMAP = 0x42,
163 	SPC3_CMD_UNMAP10 = 0x42,
164 	SPC3_CMD_READ_SUBCHANNEL = SCMD_READ_SUBCHANNEL,
165 	SPC3_CMD_READ_TOC = SCMD_READ_TOC,
166 	SPC3_CMD_REPORT_DENSITY_SUPPORT = SCMD_REPORT_DENSITIES,
167 	SPC3_CMD_READ_HEADER = SCMD_READ_HEADER,
168 	SPC3_CMD_PLAY_AUDIO = SCMD_PLAYAUDIO10,
169 	SPC3_CMD_PLAY_AUDIO10 = SCMD_PLAYAUDIO10,
170 	SPC3_CMD_GET_CONFIGURATION = SCMD_GET_CONFIGURATION,
171 	SPC3_CMD_PLAY_AUDIO_MSF = SCMD_PLAYAUDIO_MSF,
172 	/* Not defined by SPC-3 */
173 	SPC3_CMD_PLAY_AUDIO_TI = SCMD_PLAYAUDIO_TI,
174 	SPC3_CMD_PLAY_TRACK_REL = SCMD_PLAYTRACK_REL10,
175 	SPC3_CMD_PLAY_TRACK_REL10 = SCMD_PLAYTRACK_REL10,
176 	SPC3_CMD_GET_EVENT_STATUS_NOTIFICATION = 0x4a,
177 	SPC3_CMD_PAUSE_RESUME = SCMD_PAUSE_RESUME,
178 	SPC3_CMD_LOG_SELECT = SCMD_LOG_SELECT_G1,
179 	SPC3_CMD_LOG_SENSE = SCMD_LOG_SENSE_G1,
180 	SPC3_CMD_STOP_PLAY_SCAN = 0x4e,
181 	SPC3_CMD_XDWRITE = 0x50,
182 	SPC3_CMD_XDWRITE10 = 0x50,
183 	SPC3_CMD_XPWRITE = 0x51,
184 	SPC3_CMD_XPWRITE10 = 0x51,
185 	SPC3_CMD_READ_DISC_INFORMATION = 0x51,
186 	SPC3_CMD_XDREAD = 0x52,
187 	SPC3_CMD_XDREAD10 = 0x52,
188 	SPC3_CMD_READ_TRACK_INFORMATION = 0x52,
189 	SPC3_CMD_RESERVE_TRACK = 0x53,
190 	SPC3_CMD_SEND_OPC_INFORMATION = 0x54,
191 	SPC3_CMD_MODE_SELECT10 = SCMD_MODE_SELECT_G1,
192 	SPC3_CMD_RESERVE10 = SCMD_RESERVE_G1,
193 	SPC3_CMD_RESERVE_ELEMENT10 = SCMD_RESERVE_G1,
194 	SPC3_CMD_RELEASE10 = SCMD_RELEASE_G1,
195 	SPC3_CMD_RELEASE_ELEMENT10 = SCMD_RELEASE_G1,
196 	SPC3_CMD_REPAIR_TRACK = 0x58,
197 	SPC3_CMD_MODE_SENSE10 = SCMD_MODE_SENSE_G1,
198 	SPC3_CMD_CLOSE_TRACK_SESSION = 0x5b,
199 	SPC3_CMD_READ_BUFFER_CAPACITY = 0x5c,
200 	SPC3_CMD_SEND_CUE_SHEET = 0x5d,
201 	SPC3_CMD_PERSISTENT_RESERVE_IN = SCMD_PERSISTENT_RESERVE_IN,
202 	SPC3_CMD_PERSISTENT_RESERVE_OUT = SCMD_PERSISTENT_RESERVE_OUT,
203 	SPC3_CMD_VARIABLE_LENGTH = SCMD_VAR_LEN,
204 	SPC3_CMD_XDWRITE_EXTENDED = SCMD_WRITE_FILE_MARK_G4,
205 	SPC3_CMD_XDWRITE_EXTENDED16 = SCMD_WRITE_FILE_MARK_G4,
206 	SPC3_CMD_WRITE_FILEMARKS16 = SCMD_WRITE_FILE_MARK_G4,
207 	SPC3_CMD_REBUILD = SCMD_READ_REVERSE_G4,
208 	SPC3_CMD_REBUILD16 = SCMD_READ_REVERSE_G4,
209 	SPC3_CMD_READ_REVERSE16 = SCMD_READ_REVERSE_G4,
210 	SPC3_CMD_REGENERATE = 0x82,
211 	SPC3_CMD_REGENERATE16 = 0x82,
212 	SPC3_CMD_EXTENDED_COPY = SCMD_EXTENDED_COPY,
213 	SPC3_CMD_RECEIVE_COPY_RESULTS = 0x84,
214 	SPC3_CMD_ATA_COMMAND_PASS_THROUGH = 0x85,
215 	SPC3_CMD_ATA_COMMAND_PASS_THROUGH16 = 0x85,
216 	SPC3_CMD_ACCESS_CONTROL_IN = 0x86,
217 	SPC3_CMD_ACCESS_CONTROL_OUT = 0x87,
218 	SPC3_CMD_READ16 = SCMD_READ_G4,
219 	SPC3_CMD_WRITE16 = SCMD_WRITE_G4,
220 	SPC3_CMD_READ_ATTRIBUTE = SCMD_READ_ATTRIBUTE,
221 	SPC3_CMD_WRITE_ATTRIBUTE = SCMD_WRITE_ATTRIBUTE,
222 	SPC3_CMD_WRITE_AND_VERIFY16 = 0x8e,
223 	SPC3_CMD_VERIFY16 = SCMD_VERIFY_G4,
224 	SPC3_CMD_PREFETCH16 = 0x90,
225 	SPC3_CMD_SYNCHRONIZE_CACHE16 = SCMD_SPACE_G4,
226 	SPC3_CMD_SPACE16 = SCMD_SPACE_G4,
227 	SPC3_CMD_LOCK_UNLOCK_CACHE16 = 0x92,
228 	SPC3_CMD_LOCATE16 = 0x92,
229 	SPC3_CMD_WRITE_SAME16 = 0x93,
230 	SPC3_CMD_ERASE16 = 0x93,
231 	SPC3_CMD_SERVICE_ACTION_IN = SCMD_SVC_ACTION_IN_G4,
232 	SPC3_CMD_SERVICE_ACTION_IN16 = SCMD_SVC_ACTION_IN_G4,
233 	SPC3_CMD_SERVICE_ACTION_OUT = SCMD_SVC_ACTION_OUT_G4,
234 	SPC3_CMD_SERVICE_ACTION_OUT16 = SCMD_SVC_ACTION_OUT_G4,
235 	SPC3_CMD_REPORT_LUNS = SCMD_REPORT_LUNS,
236 	SPC3_CMD_BLANK = 0xa1,
237 	SPC3_CMD_ATA_COMMAND_PASS_THROUGH12 = 0xa1,
238 	SPC3_CMD_SECURITY_PROTO_IN = SCMD_SECURITY_PROTO_IN,
239 	SPC3_CMD_MAINTENANCE_IN = SCMD_MAINTENANCE_IN,
240 	SPC3_CMD_SEND_KEY = SCMD_MAINTENANCE_IN,
241 	SPC3_CMD_MAINTENANCE_OUT = SCMD_MAINTENANCE_OUT,
242 	SPC3_CMD_REPORT_KEY = SCMD_MAINTENANCE_OUT,
243 	SPC3_CMD_MOVE_MEDIUM = SCMD_PLAYAUDIO12,
244 	SPC3_CMD_PLAY_AUDIO12 = SCMD_PLAYAUDIO12,
245 	SPC3_CMD_EXCHANGE_MEDIUM = 0xa6,
246 	SPC3_CMD_LOAD_UNLOAD_CD = 0xa6,
247 	SPC3_CMD_MOVE_MEDIUM_ATTACHED = 0xa7,
248 	SPC3_CMD_SET_READ_AHEAD = 0xa7,
249 	SPC3_CMD_READ12 = SCMD_READ_G5,
250 	SPC3_CMD_GET_MESSAGE12 = SCMD_READ_G5,
251 	SPC3_CMD_SERVICE_ACTION_OUT12 = SCMD_SVC_ACTION_OUT_G5,
252 	SPC3_CMD_PLAY_TRACK_REL12 = SCMD_PLAYTRACK_REL12,
253 	SPC3_CMD_WRITE12 = SCMD_WRITE_G5,
254 	SPC3_CMD_SEND_MESSAGE12 = SCMD_WRITE_G5,
255 	SPC3_CMD_SERVICE_ACTION_IN12 = SCMD_SVC_ACTION_IN_G5,
256 	SPC3_CMD_ERASE12 = SCMD_GET_PERFORMANCE,
257 	SPC3_CMD_GET_PERFORMANCE = SCMD_GET_PERFORMANCE,
258 	SPC3_CMD_READ_DVD_STRUCTURE = 0xad,
259 	SPC3_CMD_WRITE_AND_VERIFY12 = 0xae,
260 	SPC3_CMD_VERIFY12 = SCMD_VERIFY_G5,
261 	SPC3_CMD_SEARCH_DATA_HIGH12 = 0xb0,
262 	SPC3_CMD_SEARCH_DATA_EQUAL12 = 0xb1,
263 	SPC3_CMD_SEARCH_DATA_LOW12 = 0xb2,
264 	SPC3_CMD_SET_LIMITS12 = 0xb3,
265 	SPC3_CMD_READ_ELEMENT_STATUS_ATTACHED = 0xb4,
266 	SPC3_CMD_REQUEST_VOLUME_ELEMENT_ADDRESS = 0xb5,
267 	SPC3_CMD_SEND_VOLUME_TAG = 0xb6,
268 	SPC3_CMD_SET_STREAMING = 0xb6,
269 	SPC3_CMD_READ_DEFECT_DATA12 = 0xb7,
270 	SPC3_CMD_READ_ELEMENT_STATUS = 0xb8,
271 	SPC3_CMD_READ_CD_MSF = 0xb9,
272 	SPC3_CMD_REDUNDANCY_GROUP_IN = 0xba,
273 	SPC3_CMD_SCAN12 = 0xba,
274 	SPC3_CMD_REDUNDANCY_GROUP_OUT = SCMD_SET_CDROM_SPEED,
275 	SPC3_CMD_SET_CD_SPEED = SCMD_SET_CDROM_SPEED,
276 	SPC3_CMD_SPARE_IN = 0xbc,
277 	SPC3_CMD_SPARE_OUT = 0xbd,
278 	SPC3_CMD_MECHANISM_STATUS = 0xbd,
279 	SPC3_CMD_VOLUME_SET_IN = SCMD_READ_CD,
280 	SPC3_CMD_READ_CD = SCMD_READ_CD,
281 	SPC3_CMD_VOLUME_SET_OUT = 0xbf,
282 	SPC3_CMD_SEND_DVD_STRUCTURE = 0xbf
283 } spc3_cmd_t;
284 
285 typedef enum spc3_dev_type {
286 	SPC3_DEVTYPE_DIRECT = 0x00,
287 	SPC3_DEVTYPE_SEQUENTIAL = 0x01,
288 	SPC3_DEVTYPE_PRINTER = 0x02,
289 	SPC3_DEVTYPE_PROCESSOR = 0x03,
290 	SPC3_DEVTYPE_WORM = 0x04,
291 	SPC3_DEVTYPE_MMC = 0x05,
292 	SPC3_DEVTYPE_SCANNER = 0x06,
293 	SPC3_DEVTYPE_OPTICAL = 0x07,
294 	SPC3_DEVTYPE_CHANGER = 0x08,
295 	SPC3_DEVTYPE_COMM = 0x09,
296 	SPC3_DEVTYPE_ARRAY_CONTROLLER = 0x0c,
297 	SPC3_DEVTYPE_SES = 0x0d,
298 	SPC3_DEVTYPE_RBC = 0xe,
299 	SPC3_DEVTYPE_OCRW = 0xf,
300 	SPC3_DEVTYPE_BCC = 0x10,
301 	SPC3_DEVTYPE_OSD = 0x11,
302 	SPC3_DEVTYPE_ADC = 0x12
303 } spc3_dev_type_t;
304 
305 /*
306  * SAM-4 5.3.1, Table 25
307  */
308 typedef enum sam4_status {
309 	SAM4_STATUS_GOOD = 0x0,
310 	SAM4_STATUS_CHECK_CONDITION = 0x2,
311 	SAM4_STATUS_CONDITION_MET = 0x4,
312 	SAM4_STATUS_BUSY = 0x8,
313 	SAM4_STATUS_RESERVATION_CONFLICT = 0x18,
314 	SAM4_STATUS_TASK_SET_FULL = 0x28,
315 	SAM4_STATUS_ACA_ACTIVE = 0x30,
316 	SAM4_STATUS_TASK_ABORTED = 0x40
317 } sam4_status_t;
318 
319 #pragma pack(1)
320 
321 typedef union spc3_control {
322 	struct {
323 		DECL_BITFIELD5(
324 		    c_link	:1,
325 		    c_flag	:1,
326 		    c_naca	:1,
327 		    _reserved1	:3,
328 		    c_vs_6	:2);
329 	} c_bits;
330 	uint8_t c_byte;
331 } spc3_control_t;
332 
333 /*
334  * SPC-3 6.2.1 CHANGE ALIASES
335  */
336 typedef struct spc3_change_aliases_cdb {
337 	uint8_t cac_opcode;
338 	DECL_BITFIELD2(
339 	    cac_service_action	:5,
340 	    _reserved1		:3);
341 	uint8_t _reserved2[4];
342 	uint32_t cac_parameter_list_length;
343 	uint8_t _reserved3;
344 	spc3_control_t cac_control;
345 } spc3_change_aliases_cdb_t;
346 
347 typedef struct spc3_alias_entry {
348 	uint64_t ae_alias_value;
349 	uint8_t ae_protocol_identifier;
350 	uint8_t _reserved1[2];
351 	uint8_t ae_format_code;
352 	uint8_t _reserved2[2];
353 	uint16_t ae_designation_length;
354 	uint8_t ae_designation[1];	/* Flexible */
355 } spc3_alias_entry_t;
356 
357 typedef struct spc3_change_aliases_param_list {
358 	uint32_t capl_parameter_data_length;
359 	uint8_t _reserved1[4];
360 	spc3_alias_entry_t capl_alias_entries[1];	/* Flexible */
361 } spc3_change_aliases_param_list_t;
362 
363 /*
364  * SPC-3 6.4.1 INQUIRY
365  */
366 typedef struct spc3_inquiry_cdb {
367 	uint8_t ic_opcode;
368 	DECL_BITFIELD2(
369 	    ic_evpd	:1,
370 	    _reserved1	:7);
371 	uint8_t ic_page_code;
372 	uint16_t ic_allocation_length;
373 	spc3_control_t ic_control;
374 } spc3_inquiry_cdb_t;
375 
376 typedef struct spc3_inquiry_data {
377 	DECL_BITFIELD2(
378 	    id_peripheral_device_type	:5,
379 	    id_peripheral_qualifier	:3);
380 	DECL_BITFIELD2(
381 	    _reserved1	:7,
382 	    id_rmb	:1);
383 	uint8_t id_version;
384 	DECL_BITFIELD4(
385 	    id_response_data_format	:4,
386 	    id_hisup			:1,
387 	    id_naca			:1,
388 	    _reserved2			:2);
389 	uint8_t additional_length;
390 	DECL_BITFIELD6(
391 	    id_protect	:1,
392 	    _reserved3	:2,
393 	    id_3pc	:1,
394 	    id_tpgs	:2,
395 	    id_acc	:1,
396 	    id_sccs	:1);
397 	DECL_BITFIELD7(
398 	    id_addr16	:1,
399 	    _reserved4	:2,
400 	    id_mchanger	:1,
401 	    id_multip	:1,
402 	    id_vs_6_5	:1,
403 	    id_enc_serv	:1,
404 	    id_b_que	:1);
405 	DECL_BITFIELD7(
406 	    id_vs_7_0	:1,
407 	    id_cmd_que	:1,
408 	    _reserved5	:1,
409 	    id_linked	:1,
410 	    id_sync	:1,
411 	    id_wbus16	:1,
412 	    _reserved6	:2);
413 	char id_vendor_id[8];
414 	char id_product_id[16];
415 	char id_product_revision[4];
416 	uint8_t id_vs_36[20];
417 	DECL_BITFIELD4(
418 	    id_ius	:1,
419 	    id_qas	:1,
420 	    id_clocking	:2,
421 	    _reserved7	:4);
422 	uint8_t _reserved8;
423 	uint16_t id_version_descriptors[8];
424 	uint8_t _reserved9[22];
425 	uint8_t id_vs_96[1];	/* Flexible */
426 } spc3_inquiry_data_t;
427 
428 /*
429  * SPC-3 6.5 LOG SELECT
430  */
431 typedef enum spc3_log_page_control {
432 	SPC3_LOG_PC_CUR_THRESHOLD = 0,
433 	SPC3_LOG_PC_CUR_CUMULATIVE = 1,
434 	SPC3_LOG_PC_DEF_THRESHOLD = 2,
435 	SPC3_LOG_PC_DEF_CUMULATIVE = 3
436 } spc3_log_page_control_t;
437 
438 typedef struct spc3_log_select_cdb {
439 	uint8_t lsc_opcode;
440 	DECL_BITFIELD3(
441 	    lsc_sp	:1,
442 	    lsc_pcr	:1,
443 	    _reserved1	:6);
444 	DECL_BITFIELD2(
445 	    _reserved2	:6,
446 	    lsc_pc	:2);
447 	uint8_t _reserved3[4];
448 	uint16_t lsc_parameter_list_length;
449 	spc3_control_t lsc_control;
450 } spc3_log_select_cdb_t;
451 
452 /*
453  * SPC-3 6.6 LOG SENSE
454  */
455 typedef struct spc3_log_sense_cdb {
456 	uint8_t lsc_opcode;
457 	DECL_BITFIELD3(
458 	    lsc_sp	:1,
459 	    lsc_ppc	:1,
460 	    _reserved1	:6);
461 	DECL_BITFIELD2(
462 	    lsc_page_code	:6,
463 	    lsc_pc		:2);
464 	uint8_t _reserved2[2];
465 	uint16_t lsc_parameter_ptr;
466 	uint16_t lsc_allocation_length;
467 	spc3_control_t lsc_control;
468 } spc3_log_sense_cdb_t;
469 
470 typedef enum spc3_mode_page_control {
471 	SPC3_MODE_PC_CURRENT = 0,
472 	SPC3_MODE_PC_CHANGEABLE = 1,
473 	SPC3_MODE_PC_DEFAULT = 2,
474 	SPC3_MODE_PC_SAVED = 3
475 } spc3_mode_page_control_t;
476 
477 typedef struct spc3_mode_param_header6 {
478 	uint8_t mph_mode_data_length;
479 	uint8_t mph_medium_type;
480 	uint8_t mph_device_param;
481 	uint8_t mph_block_descriptor_length;
482 } spc3_mode_param_header6_t;
483 
484 typedef spc3_mode_param_header6_t spc3_mode_param_header_t;
485 
486 typedef struct spc3_mode_param_header10 {
487 	uint16_t mph_mode_data_length;
488 	uint8_t mph_medium_type;
489 	uint8_t mph_device_param;
490 	DECL_BITFIELD2(
491 	    mph_longlba	:1,
492 	    _reserved1	:7);
493 	uint8_t _reserved2;
494 	uint16_t mph_block_descriptor_length;
495 } spc3_mode_param_header10_t;
496 
497 typedef struct spc3_mode_param_block_descriptor {
498 	uint8_t mpbd_density_code;
499 	uint8_t mpbd_nblocks[3];
500 	uint8_t _reserved1;
501 	uint8_t mpbd_block_length[3];
502 } spc3_mode_param_block_descriptor_t;
503 
504 typedef struct spc3_mode_page_0 {
505 	DECL_BITFIELD3(
506 	    mp0_page_code	:6,
507 	    mp0_spf		:1,
508 	    mp0_ps		:1);
509 	uint8_t mp0_page_length;
510 	uint8_t mp0_mode_parameters[1];	/* Flexible */
511 } spc3_mode_page_0_t;
512 
513 typedef struct spc3_mode_subpage {
514 	DECL_BITFIELD3(
515 	    ms_page_code	:6,
516 	    ms_spf		:1,
517 	    ms_ps		:1);
518 	uint8_t ms_subpage_code;
519 	uint16_t ms_page_length;
520 	uint8_t ms_mode_parameters[1];	/* Flexible */
521 } spc3_mode_subpage_t;
522 
523 /*
524  * SPC-3 7.4.6 Table 246 - TST field
525  */
526 typedef enum spc3_mode_task_set {
527 	SPC3_MODE_TST_ONE = 0,
528 	SPC3_MODE_TST_SEPARATE = 1
529 } spc3_mode_task_set_t;
530 
531 /*
532  * SPC-3 7.4.6 Table 247 - Queue Algorithm Modifier field
533  */
534 typedef enum spc3_mode_queue_alg_mod {
535 	SPC3_MODE_QAM_RESTRICTED = 0,
536 	SPC3_MODE_QAM_UNRESTRICTED = 1
537 } spc3_mode_queue_alg_mod_t;
538 
539 /*
540  * SPC-3 7.4.6 Table 245
541  */
542 typedef struct spc3_mode_params_control {
543 	DECL_BITFIELD6(
544 	    mpc_rlec		:1,
545 	    mpc_gltsd		:1,
546 	    mpc_d_sense		:1,
547 	    _reserved1		:1,
548 	    mpc_tmf_only	:1,
549 	    mpc_tst		:3);
550 	DECL_BITFIELD4(
551 	    _reserved2		:1,
552 	    mpc_q_err		:1,
553 	    _reserved3		:1,
554 	    mpc_queue_alg_mod	:4);
555 	DECL_BITFIELD5(
556 	    _reserved4		:3,
557 	    mpc_swp		:1,
558 	    mpc_ua_intlck_ctrl	:2,
559 	    mpc_rac		:1,
560 	    mpc_vs_4_7		:1);
561 	DECL_BITFIELD4(
562 	    mpc_autoload_mode	:3,
563 	    _reserved5		:3,
564 	    mpc_tas		:1,
565 	    mpc_ato		:1);
566 	uint8_t _reserved6[2];
567 	uint16_t mpc_busy_timeout_period;
568 	uint16_t mpc_ext_selftest_completion_time;
569 } spc3_mode_page_params_control_t;
570 
571 /*
572  * SPC-3 7.4.7 Control Extension mode page
573  */
574 typedef struct spc3_mode_params_control_ext {
575 	DECL_BITFIELD4(
576 	    mpce_ialuae	:1,
577 	    mpce_scsip	:1,
578 	    mpce_tcmos	:1,
579 	    _reserved1	:5);
580 	DECL_BITFIELD2(
581 	    mpce_initial_priority	:4,
582 	    _reserved2			:4);
583 	uint8_t _reserved3[26];
584 } spc3_mode_params_control_ext_t;
585 
586 /*
587  * SPC-3 7.4.8 Disconnect-Reconnect mode page
588  */
589 typedef struct spc3_mode_params_dc_rc {
590 	uint8_t mpdr_buffer_full_ratio;
591 	uint8_t mpdr_buffer_empty_ratio;
592 	uint16_t mpdr_bus_inactivity_limit;
593 	uint16_t mpdr_disconnect_time_limit;
594 	uint16_t mpdr_connect_time_limit;
595 	uint16_t mpdr_max_burst_size;
596 	DECL_BITFIELD4(
597 	    mpdr_dtdc			:3,
598 	    mpdr_di_mm			:1,
599 	    mpdr_fair_arbitration	:3,
600 	    mpdr_emdp			:1);
601 	uint8_t _reserved1;
602 	uint16_t mpdr_first_burst_size;
603 } spc3_mode_params_dc_rc_t;
604 
605 typedef enum spc3_mode_mrie {
606 	SPC3_MODE_MRIE_NONE = 0,
607 	SPC3_MODE_MRIE_ASYNC = 1,
608 	SPC3_MODE_MRIE_UNIT_ATTN = 2,
609 	SPC3_MODE_MRIE_COND_REC_ERR = 3,
610 	SPC3_MODE_MRIE_UNCOND_REC_ERR = 4,
611 	SPC3_MODE_MRIE_NO_SENSE = 5,
612 	SPC3_MODE_MRIE_REQUEST = 6
613 } spc3_mode_mrie_t;
614 
615 /*
616  * SPC-3 7.4.11 Informational Exceptions Control mode page
617  */
618 typedef struct spc3_mode_params_iec {
619 	DECL_BITFIELD8(
620 	    mpi_log_err	:1,
621 	    _reserved1	:1,
622 	    mpi_test	:1,
623 	    mpi_d_excpt	:1,
624 	    mpi_e_wasc	:1,
625 	    mpi_ebf	:1,
626 	    _reserved2	:1,
627 	    mpi_perf	:1);
628 	DECL_BITFIELD2(
629 	    mpi_mrie	:4,
630 	    _reserved3	:4);
631 	uint32_t mpi_interval_timer;
632 	uint32_t mpi_report_count;
633 } spc3_mode_params_iec_t;
634 
635 /*
636  * SPC-3 7.4.12 Power Condition mode page
637  */
638 typedef struct spc3_mode_params_pc {
639 	uint8_t _reserved1;
640 	DECL_BITFIELD3(
641 	    mpp_standby	:1,
642 	    mpp_idle	:1,
643 	    _reserved2	:6);
644 	uint32_t mpp_idle_condition_timer;
645 	uint32_t mpp_standby_condition_timer;
646 } spc3_mode_params_pc_t;
647 
648 /*
649  * SPC-3 6.7 MODE SELECT(6)
650  */
651 typedef struct spc3_mode_select6_cdb {
652 	uint8_t msc_opcode;
653 	DECL_BITFIELD4(
654 	    msc_sp	:1,
655 	    _reserved1	:3,
656 	    msc_pf	:1,
657 	    _reserved2	:3);
658 	uint8_t _reserved3[2];
659 	uint8_t msc_parameter_list_length;
660 	spc3_control_t msc_control;
661 } spc3_mode_select6_cdb_t;
662 
663 typedef spc3_mode_select6_cdb_t spc3_mode_select_cdb_t;
664 
665 /*
666  * SPC-3 6.8 MODE SELECT(10)
667  */
668 typedef struct spc3_mode_select10_cdb {
669 	uint8_t msc_opcode;
670 	DECL_BITFIELD4(
671 	    msc_sp	:1,
672 	    _reserved1	:3,
673 	    msc_pf	:1,
674 	    _reserved2	:3);
675 	uint8_t _reserved3[5];
676 	uint16_t msc_parameter_list_length;
677 	spc3_control_t msc_control;
678 } spc3_mode_select10_cdb_t;
679 
680 /*
681  * SPC-3 6.9 MODE SENSE(6)
682  */
683 typedef struct spc3_mode_sense6_cdb {
684 	uint8_t msc_opcode;
685 	DECL_BITFIELD3(
686 	    _reserved1	:3,
687 	    msc_dbd	:1,
688 	    _reserved2	:4);
689 	DECL_BITFIELD2(
690 	    msc_page_code	:6,
691 	    msc_pc		:2);
692 	uint8_t msc_subpage_code;
693 	uint8_t msc_allocation_length;
694 	spc3_control_t msc_control;
695 } spc3_mode_sense6_cdb_t;
696 
697 typedef spc3_mode_sense6_cdb_t spc3_mode_sense_cdb_t;
698 
699 /*
700  * SPC-3 6.10 MODE SENSE(10)
701  */
702 typedef struct spc3_mode_sense10_cdb {
703 	uint8_t msc_opcode;
704 	DECL_BITFIELD4(
705 	    _reserved1	:3,
706 	    msc_dbd	:1,
707 	    msc_llbaa	:1,
708 	    _reserved2	:3);
709 	DECL_BITFIELD2(
710 	    msc_page_code	:6,
711 	    msc_pc		:2);
712 	uint8_t msc_subpage_code;
713 	uint8_t _reserved3[3];
714 	uint16_t msc_allocation_length;
715 	spc3_control_t msc_control;
716 } spc3_mode_sense10_cdb_t;
717 
718 /*
719  * SPC-3 6.11 PERSISTENT RESERVE IN
720  */
721 typedef enum spc3_persistent_reserve_in_sac {
722 	SPC3_PRI_SAC_READ_KEYS = 0,
723 	SPC3_PRI_SAC_READ_RESERVATION = 1,
724 	SPC3_PRI_SAC_REPORT_CAPABILITIES = 2,
725 	SPC3_PRI_SAC_READ_FULL_STATUS = 3
726 } spc3_persistent_reserve_in_sac_t;
727 
728 typedef struct spc3_persistent_reserve_in_param_rk {
729 	uint32_t pripr_pr_generation;
730 	uint32_t pripr_additional_length;
731 	uint64_t pripr_keys[1];	/* Flexible */
732 } spc3_persistent_reserve_in_param_rk_t;
733 
734 typedef enum spc3_persistent_reserve_type {
735 	SPC3_PR_TYPE_WREXCL = 1,
736 	SPC3_PR_TYPE_EXCL = 3,
737 	SPC3_PR_WREXCL_REG_ONLY = 5,
738 	SPC3_PR_EXCL_REG_ONLY = 6,
739 	SPC3_PR_WREXCL_ALL_REG = 7,
740 	SPC3_PR_EXCL_ALL_REG = 8
741 } spc3_persistent_reserve_type_t;
742 
743 typedef struct spc3_persistent_reserve_in_param_rr {
744 	uint32_t pripr_pr_generation;
745 	uint32_t pripr_additional_length;
746 	uint64_t pripr_key;
747 	uint8_t _reserved1[4];
748 	uint8_t _reserved2;
749 	DECL_BITFIELD2(
750 	    pripr_type	:4,
751 	    pripr_scope	:4);
752 	uint8_t _reserved3[2];
753 } spc3_persistent_reserve_in_param_rr_t;
754 
755 typedef struct spc3_persistent_reserve_in_param_rc {
756 	uint16_t pripr_length;
757 	DECL_BITFIELD6(
758 	    pripr_ptpl_c	:1,
759 	    _reserved1		:1,
760 	    pripr_atp_c		:1,
761 	    pripr_sip_c		:1,
762 	    pripr_crh		:1,
763 	    _reserved2		:3);
764 	DECL_BITFIELD3(
765 	    pripr_ptpl_a	:1,
766 	    _reserved3		:6,
767 	    pripr_tmv		:1);
768 	DECL_BITFIELD8(
769 	    _reserved4		:1,
770 	    pripr_wr_ex		:1,
771 	    _reserved5		:1,
772 	    pripr_ex_ac		:1,
773 	    _reserved6		:1,
774 	    pripr_wr_ex_ro	:1,
775 	    pripr_ex_ac_ro	:1,
776 	    pripr_wr_ex_ar	:1);
777 	DECL_BITFIELD2(
778 	    pripr_ex_ac_ar	:1,
779 	    _reserved7		:7);
780 	uint8_t _reserved8[2];
781 } spc3_persistent_reserve_in_param_rc_t;
782 
783 typedef struct spc3_persistent_reserve_full_status {
784 	uint64_t prfs_key;
785 	uint8_t _reserved1[4];
786 	DECL_BITFIELD3(
787 	    prfs_r_holder	:1,
788 	    prfs_all_tg_pt	:1,
789 	    _reserved2		:6);
790 	DECL_BITFIELD2(
791 	    prfs_type		:4,
792 	    prfs_scope		:4);
793 	uint8_t _reserved3[4];
794 	uint16_t prfs_relative_target_port_identifier;
795 	uint32_t prfs_additional_descriptor_length;
796 	uint8_t prfs_transport_id[1];	/* Flexible */
797 } spc3_persistent_reserve_full_status_t;
798 
799 typedef struct spc3_persistent_reserve_in_param_rfs {
800 	uint32_t pripr_pr_generation;
801 	uint32_t pripr_additional_length;
802 	uint8_t pripr_status_descriptors[1];	/* Flexible */
803 } spc3_persistent_reserve_in_param_rfs_t;
804 
805 typedef struct spc3_persistent_reserve_in_cdb {
806 	uint8_t pric_opcode;
807 	DECL_BITFIELD2(
808 	    pric_service_action	:5,
809 	    _reserved1		:3);
810 	uint8_t _reserved2[5];
811 	uint16_t pric_allocation_length;
812 	spc3_control_t pric_control;
813 } spc3_persistent_reserve_in_cdb_t;
814 
815 /*
816  * SPC-3 6.15 READ BUFFER
817  */
818 typedef struct spc3_read_buffer_cdb {
819 	uint8_t rbc_opcode;
820 	DECL_BITFIELD2(
821 	    rbc_mode		:5,
822 	    _reserved		:3);
823 	uint8_t	rbc_bufferid;
824 	uint8_t rbc_buffer_offset[3];
825 	uint8_t rbc_allocation_len[3];
826 	spc3_control_t rbc_control;
827 } spc3_read_buffer_cdb_t;
828 
829 typedef enum spc3_read_buffer_mode {
830 	SPC3_RB_MODE_COMB_HDR_DATA = 0x00,
831 	SPC3_RB_MODE_VENDOR_SPECIFIC = 0x01,
832 	SPC3_RB_MODE_DATA = 0x02,
833 	SPC3_RB_MODE_DESCRIPTOR = 0x03,
834 	SPC3_RB_MODE_ECHO_BUF = 0x0a,
835 	SPC3_RB_MODE_ECHO_BUF_DESC = 0x0b,
836 	SPC3_RB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a
837 } spc3_read_buffer_mode_t;
838 
839 /*
840  * SPC-3 6.16 READ MEDIA SERIAL NUMBER
841  */
842 typedef struct spc3_read_media_serial_number_cdb {
843 	uint8_t rmsnc_opcode;
844 	DECL_BITFIELD2(
845 	    rmsnc_service_action	:5,
846 	    _reserved1			:3);
847 	uint8_t _reserved2[4];
848 	uint32_t rmsnc_allocation_length;
849 	uint8_t _reserved3;
850 	spc3_control_t rmsnc_control;
851 } spc3_read_media_serial_number_cdb_t;
852 
853 typedef struct spc3_read_media_serial_number_data {
854 	uint32_t msnd_length;
855 	uint8_t msnd_serial_number[1];	/* Flexible */
856 } spc3_read_media_serial_number_data_t;
857 
858 /*
859  * SPC-3 6.18 RECEIVE DIAGNOSTIC RESULTS
860  */
861 typedef struct spc3_receive_diagnostic_results_cdb {
862 	uint8_t rdrc_opcode;
863 	DECL_BITFIELD2(
864 	    rdrc_pcv	:1,
865 	    _reserved1	:7);
866 	uint8_t rdrc_page_code;
867 	uint16_t rdrc_allocation_length;
868 	spc3_control_t rdrc_control;
869 } spc3_receive_diagnostic_results_cdb_t;
870 
871 /*
872  * SPC-3 Diagnostic page format (Table 194, 7.1.1)
873  */
874 typedef struct spc3_diag_page_impl {
875 	uint8_t sdpi_page_code;
876 	uint8_t sdpi_specific;
877 	uint16_t sdpi_page_length;
878 	uint8_t sdpi_data[1];
879 } spc3_diag_page_impl_t;
880 
881 /*
882  * SPC-3 Supported diagnostic pages (Table 196, 7.1.2)
883  */
884 typedef struct spc3_supported_diag_page_impl {
885 	uint8_t ssdpi_page_code;
886 	uint8_t _reserved1;
887 	uint16_t ssdpi_page_length;
888 	uint8_t ssdpi_page_list[1];
889 } spc3_supported_diag_page_impl_t;
890 
891 /*
892  * SPC-3 6.21 REPORT LUNS
893  */
894 typedef enum spc3_report_luns_select_report {
895 	SPC3_RL_SR_ADDRESSING = 0,
896 	SPC3_RL_SR_WELLKNOWN = 1,
897 	SPC3_RL_SR_ALL = 2
898 } spc3_report_luns_select_report_t;
899 
900 typedef struct spc3_report_luns_cdb {
901 	uint8_t rlc_opcode;
902 	uint8_t _reserved1;
903 	uint8_t rlc_select_report;
904 	uint8_t _reserved2[3];
905 	uint32_t rlc_allocation_length;
906 	uint8_t _reserved3;
907 	spc3_control_t rlc_control;
908 } spc3_report_luns_cdb_t;
909 
910 typedef struct spc3_report_luns_data {
911 	uint32_t rld_lun_list_length;
912 	uint8_t _reserved1[4];
913 	uint64_t rld_luns[1];	/* Flexible */
914 } spc3_report_luns_data_t;
915 
916 /*
917  * SPC-3 6.27 REQUEST SENSE
918  */
919 typedef struct spc3_request_sense_cdb {
920 	uint8_t rsc_opcode;
921 	DECL_BITFIELD2(
922 	    rsc_desc	:1,
923 	    _reserved1	:7);
924 	uint8_t _reserved2[2];
925 	uint8_t rsc_allocation_length;
926 	spc3_control_t rsc_control;
927 } spc3_request_sense_cdb_t;
928 
929 /*
930  * SPC-3 6.28 SEND DIAGNOSTIC
931  */
932 typedef struct spc3_send_diagnostic_cdb {
933 	uint8_t sdc_opcode;
934 	DECL_BITFIELD6(
935 	    sdc_unit_off_l	:1,
936 	    sdc_dev_off_l	:1,
937 	    sdc_self_test	:1,
938 	    _reserved1		:1,
939 	    sdc_pf		:1,
940 	    sdc_selftest_code	:3);
941 	uint8_t _reserved2;
942 	uint16_t sdc_parameter_list_length;
943 	spc3_control_t sdc_control;
944 } spc3_send_diagnostic_cdb_t;
945 
946 /*
947  * SPC-3 6.33 TEST UNIT READY
948  */
949 typedef struct spc3_test_unit_ready_cdb {
950 	uint8_t tur_opcode;
951 	uint8_t _reserved1[4];
952 	spc3_control_t tur_control;
953 } spc3_test_unit_ready_cdb_t;
954 
955 /*
956  * SPC-3 6.36 WRITE BUFFER
957  */
958 typedef struct spc3_write_buffer_cdb {
959 	uint8_t wbc_opcode;
960 	DECL_BITFIELD2(
961 	    wbc_mode		:5,
962 	    _reserved		:3);
963 	uint8_t wbc_bufferid;
964 	uint8_t wbc_buffer_offset[3];
965 	uint8_t wbc_parameter_list_len[3];
966 	spc3_control_t wbc_control;
967 } spc3_write_buffer_cdb_t;
968 
969 typedef enum spc3_write_buffer_mode {
970 	SPC3_WB_MODE_COMB_HDR_DATA = 0x00,
971 	SPC3_WB_MODE_VENDOR_SPECIFIC = 0x01,
972 	SPC3_WB_MODE_DATA = 0x02,
973 	SPC3_WB_MODE_DL_UCODE = 0x04,
974 	SPC3_WB_MODE_DL_UCODE_SAVE = 0x05,
975 	SPC3_WB_MODE_DL_UCODE_OFFS = 0x06,
976 	SPC3_WB_MODE_DL_UCODE_OFFS_SAVE = 0x07,
977 	SPC3_WB_MODE_ECHO_BUF = 0x0a,
978 	SPC3_WB_MODE_DL_UCODE_OFFS_DEFER = 0x0e,
979 	SPC3_WB_MODE_ACTIVATE_DEFERRED_UCODE = 0x0f,
980 	SPC3_WB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a,
981 	SPC3_WB_MODE_DISABLE_EXPANDER = 0x1b,
982 	SPC3_WB_MODE_DL_APP_LOG = 0x1c
983 } spc3_write_buffer_mode_t;
984 
985 typedef struct spc3_write_buffer_log {
986 	uint8_t wbl_vendor[8];
987 	uint16_t wbl_error_type;
988 	uint16_t _reserved1;
989 	uint8_t wbl_timestamp[6];
990 	uint16_t _reserved2;
991 	DECL_BITFIELD2(
992 	    _reserved3		:4,
993 	    wbl_codeset		:4);
994 	uint8_t wbl_error_location_fmt;
995 	uint16_t wbl_error_location_len;
996 	uint16_t wbl_client_error_history_len;
997 	uint32_t wbl_data[1];
998 } spc3_write_buffer_log_t;
999 
1000 typedef enum sp3_write_buffer_error_type {
1001 	SPC3_WB_ERROR_NONE = 0x0000,
1002 	SPC3_WB_ERROR_UNKNOWN = 0x0001,
1003 	SPC3_WB_ERROR_DATA_CORRUPT = 0x0002,
1004 	SPC3_WB_ERROR_PERMANENT = 0x0003,
1005 	SPC3_WB_ERROR_SERVICETARGET_FAILURE = 0x0004
1006 } spc3_write_buffer_error_type_t;
1007 
1008 typedef enum spc3_write_buffer_codeset {
1009 	SPC3_WB_CODESET_RESERVED = 0x00,
1010 	SPC3_WB_CODESET_BIN = 0x01,
1011 	SPC3_WB_CODESET_ASCII = 0x02,
1012 	SPC3_WB_CODESET_UTF8 = 0x03
1013 } spc3_write_buffer_codeset_t;
1014 
1015 typedef enum spc_3_write_buffer_error_location {
1016 	SPC3_WB_ERROR_LOCATION_FMT_NONE = 0x00,
1017 	SPC3_WB_ERROR_LOCATION_FMT_LBA = 0x01
1018 } spc3_write_buffer_error_location_t;
1019 
1020 /*
1021  * SPC-4 7.5.1 Protocol values
1022  */
1023 typedef enum spc4_protocol_id {
1024 	SPC4_PROTO_FIBRE_CHANNEL = 0,
1025 	SPC4_PROTO_PARALLEL_SCSI = 1,
1026 	SPC4_PROTO_SSA = 2,
1027 	SPC4_PROTO_IEEE1394 = 3,
1028 	SPC4_PROTO_RDMA = 4,
1029 	SPC4_PROTO_ISCSI = 5,
1030 	SPC4_PROTO_SAS = 6,
1031 	SPC4_PROTO_ADT = 7,
1032 	SPC4_PROTO_ATA = 8,
1033 	SPC4_PROTO_NONE = 0xf
1034 } spc4_protocol_id_t;
1035 
1036 /*
1037  * SPC-3 NAA identifier format (Table 305, 7.6.3.6.1)
1038  */
1039 typedef struct spc3_naa_id_impl {
1040 	DECL_BITFIELD2(
1041 	    snii_priv_msn	:4,
1042 	    snii_naa	:4);
1043 	uint8_t snii_priv[1];
1044 } spc3_naa_id_impl_t;
1045 
1046 /*
1047  * SPC-3 NAA IEEE Extended Identifier field format (Table 307, 7.6.3.6.2)
1048  */
1049 typedef struct spc3_naa_ieee_ext_id_impl {
1050 	DECL_BITFIELD2(
1051 	    snieii_vendor_id_a_msn	:4,
1052 	    snieii_naa			:4);
1053 	uint8_t snieii_vendor_id_a_lsb;
1054 	uint8_t snieii_company_id[3];
1055 	uint8_t snieii_vendor_id_b[3];
1056 } spc3_naa_ieee_ext_id_impl_t;
1057 
1058 #define	NAA_IEEE_EXT_VENDOR_A(idp)	\
1059 	SCSI_MK12_4_8((idp)->snieii_vendor_id_a_msn,	\
1060 	    (idp)->snieii_vendor_id_a_lsb)
1061 #define	NAA_IEEE_EXT_COMPANY_ID(idp)	SCSI_READ24((idp)->snieii_company_id)
1062 #define	NAA_IEEE_EXT_VENDOR_B(idp)	SCSI_READ24((idp)->snieii_vendor_id_b)
1063 
1064 /*
1065  * Ibid, Table 308
1066  */
1067 typedef struct spc3_naa_ieee_reg_id_impl {
1068 	DECL_BITFIELD2(
1069 	    snirii_company_id_msn	:4,
1070 	    snirii_naa			:4);
1071 	uint16_t snirii_company_id_mid;
1072 	DECL_BITFIELD2(
1073 	    snirii_vendor_id_msn	:4,
1074 	    snirii_company_id_lsn	:4);
1075 	uint32_t snirii_vendor_id_low;
1076 } spc3_naa_ieee_reg_id_impl_t;
1077 
1078 #define	NAA_IEEE_REG_COMPANY_ID(idp)	\
1079 	SCSI_MK24_4_16_4((idp)->snirii_company_id_msn,	\
1080 	    SCSI_READ16(&(idp)->snirii_company_id_mid),	\
1081 	    (idp)->snirii_company_id_lsn)
1082 #define	NAA_IEEE_REG_VENDOR_ID(idp)	\
1083 	SCSI_MK36_4_32((idp)->snirii_vendor_id_msn,	\
1084 	    SCSI_READ32(&(idp)->snirii_vendor_id_low))
1085 
1086 /*
1087  * Ibid, Table 309
1088  */
1089 typedef struct spc3_naa_ieee_reg_ext_id_impl {
1090 	DECL_BITFIELD2(
1091 	    snireii_company_id_msn	:4,
1092 	    snireii_naa		:4);
1093 	uint16_t snireii_company_id_mid;
1094 	DECL_BITFIELD2(
1095 	    snireii_vendor_id_msn	:4,
1096 	    snireii_company_id_lsn	:4);
1097 	uint32_t snireii_vendor_id_low;
1098 	uint64_t snireii_vendor_id_ext;
1099 } spc3_naa_ieee_reg_ext_id_impl_t;
1100 
1101 #define	NAA_IEEE_REG_EXT_COMPANY_ID(idp)	\
1102 	SCSI_MK20_4_16_4((idp)->snireii_company_id_msn,	\
1103 	    SCSI_READ16(&(idp)->snireii_company_id_mid),	\
1104 	    (idp)->snireii_company_id_lsn)
1105 #define	NAA_IEEE_REG_EXT_VENDOR_ID(idp)	\
1106 	SCSI_MK36_4_32((idp)->snireii_vendor_id_msn,	\
1107 	    SCSI_READ32(&(idp)->snireii_vendor_id_low))
1108 
1109 typedef union spc3_naa_id_8_impl {
1110 	struct {
1111 		DECL_BITFIELD2(
1112 		    _reserved1	:4,
1113 		    sni8i_naa	:4);
1114 	} sni8i_hdr;
1115 	spc3_naa_ieee_ext_id_impl_t sni8i_ext_id;
1116 	spc3_naa_ieee_reg_id_impl_t sni8i_reg_id;
1117 } spc3_naa_id_8_impl_t;
1118 
1119 #define	sni8i_naa	sni8i_hdr.sni8i_naa
1120 
1121 typedef enum naa_id {
1122 	NAA_IEEE_EXT = 0x2,
1123 	NAA_LOCAL = 0x3,
1124 	NAA_IEEE_REG = 0x5,
1125 	NAA_IEEE_REG_EXT = 0x6
1126 } naa_id_t;
1127 
1128 #pragma pack()
1129 
1130 #ifdef	__cplusplus
1131 }
1132 #endif
1133 
1134 #endif	/* _SPC3_TYPES_H */
1135