Home | History | Annotate | Download | only in impl
      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 2008 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef	_SPC3_TYPES_H
     28 #define	_SPC3_TYPES_H
     29 
     30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31 
     32 #ifdef	__cplusplus
     33 extern "C" {
     34 #endif
     35 
     36 #include <sys/types.h>
     37 #include <sys/cdio.h>
     38 #include <sys/sysmacros.h>
     39 #include <sys/scsi/generic/commands.h>
     40 #include <sys/scsi/impl/commands.h>
     41 
     42 typedef enum spc3_cmd {
     43 	SPC3_CMD_TEST_UNIT_READY = SCMD_TEST_UNIT_READY,
     44 	SPC3_CMD_REZERO_UNIT = SCMD_REZERO_UNIT,
     45 	SPC3_CMD_REWIND = SCMD_REWIND,
     46 	SPC3_CMD_VENDOR_2 = 2,
     47 	SPC3_CMD_REQUEST_SENSE = SCMD_REQUEST_SENSE,
     48 	SPC3_CMD_FORMAT_UNIT = SCMD_FORMAT,
     49 	SPC3_CMD_FORMAT_MEDIUM = SCMD_FORMAT,
     50 	SPC3_CMD_FORMAT = SCMD_FORMAT,
     51 	SPC3_CMD_READ_BLOCK_LIMITS = SCMD_READ_BLKLIM,
     52 	SPC3_CMD_VENDOR_6 = 6,
     53 	SPC3_CMD_REASSIGN_BLOCKS = SCMD_REASSIGN_BLOCK,
     54 	SPC3_CMD_INITIALIZE_ELEMENT_STATUS = SCMD_REASSIGN_BLOCK,
     55 	SPC3_CMD_READ = SCMD_READ,
     56 	SPC3_CMD_READ6 = SCMD_READ,
     57 	SPC3_CMD_RECEIVE = SCMD_RECEIVE,
     58 	SPC3_CMD_GET_MESSAGE = SCMD_READ,
     59 	SPC3_CMD_VENDOR_9 = 9,
     60 	SPC3_CMD_WRITE = SCMD_WRITE,
     61 	SPC3_CMD_WRITE6 = SCMD_WRITE,
     62 	SPC3_CMD_SEND = SCMD_SEND,
     63 	SPC3_CMD_SEND6 = SCMD_SEND,
     64 	SPC3_CMD_SEND_MESSAGE = SCMD_SEND,
     65 	SPC3_CMD_PRINT = SCMD_PRINT,
     66 	SPC3_CMD_SEEK = SCMD_SEEK,
     67 	SPC3_CMD_SEEK6 = SCMD_SEEK,
     68 	SPC3_CMD_SET_CAPACITY = SCMD_SEEK,
     69 	SPC3_CMD_SLEW_AND_PRINT = SCMD_SLEW_PRINT,
     70 	SPC3_CMD_VENDOR_C = 0xc,
     71 	SPC3_CMD_VENDOR_D = 0xd,
     72 	SPC3_CMD_VENDOR_E = 0xe,
     73 	SPC3_CMD_READ_REVERSE = SCMD_READ_REVERSE,
     74 	SPC3_CMD_READ_REVERSE6 = SCMD_READ_REVERSE,
     75 	SPC3_CMD_WRITE_FILEMARKS = SCMD_WRITE_FILE_MARK,
     76 	SPC3_CMD_WRITE_FILEMARKS6 = SCMD_WRITE_FILE_MARK,
     77 	SPC3_CMD_SYNCHRONIZE_BUFFER = SCMD_FLUSH_PRINT_BUF,
     78 	SPC3_CMD_SPACE = SCMD_SPACE,
     79 	SPC3_CMD_SPACE6 = SCMD_SPACE,
     80 	SPC3_CMD_INQUIRY = SCMD_INQUIRY,
     81 	SPC3_CMD_VERIFY = SCMD_VERIFY_G0,
     82 	SPC3_CMD_VERIFY6 = SCMD_VERIFY_G0,
     83 	SPC3_CMD_RECOVER_BUFFERED_DATA = SCMD_RECOVER_BUF,
     84 	SPC3_CMD_MODE_SELECT = SCMD_MODE_SELECT,
     85 	SPC3_CMD_MODE_SELECT6 = SCMD_MODE_SELECT,
     86 	SPC3_CMD_RESERVE = SCMD_RESERVE,
     87 	SPC3_CMD_RESERVE6 = SCMD_RESERVE,
     88 	SPC3_CMD_RESERVE_ELEMENT = SCMD_RESERVE,
     89 	SPC3_CMD_RESERVE_ELEMENT6 = SCMD_RESERVE,
     90 	SPC3_CMD_RELEASE = SCMD_RELEASE,
     91 	SPC3_CMD_RELEASE6 = SCMD_RELEASE,
     92 	SPC3_CMD_RELEASE_ELEMENT = SCMD_RELEASE,
     93 	SPC3_CMD_RELEASE_ELEMENT6 = SCMD_RELEASE,
     94 	SPC3_CMD_COPY = SCMD_COPY,
     95 	SPC3_CMD_ERASE = SCMD_ERASE,
     96 	SPC3_CMD_ERASE6 = SCMD_ERASE,
     97 	SPC3_CMD_MODE_SENSE = SCMD_MODE_SENSE,
     98 	SPC3_CMD_MODE_SENSE6 = SCMD_MODE_SENSE,
     99 	SPC3_CMD_START_STOP_UNIT = SCMD_START_STOP,
    100 	SPC3_CMD_LOAD_UNLOAD = SCMD_LOAD,
    101 	SPC3_CMD_SCAN = SCMD_START_STOP,
    102 	SPC3_CMD_STOP_PRINT = SCMD_STOP_PRINT,
    103 	SPC3_CMD_RECEIVE_DIAGNOSTIC_RESULTS = SCMD_GDIAG,
    104 	SPC3_CMD_SEND_DIAGNOSTIC = SCMD_SDIAG,
    105 	SPC3_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL = SCMD_DOORLOCK,
    106 	SPC3_CMD_VENDOR_20 = 0x20,
    107 	SPC3_CMD_VENDOR_21 = 0x21,
    108 	SPC3_CMD_VENDOR_22 = 0x22,
    109 	SPC3_CMD_VENDOR_23 = 0x23,
    110 	SPC3_CMD_SET_WINDOW = 0x24,
    111 	SPC3_CMD_READ_CAPACITY = SCMD_READ_CAPACITY,
    112 	SPC3_CMD_READ_CAPACITY10 = SCMD_READ_CAPACITY,
    113 	SPC3_CMD_READ_CARD_CAPACITY = SCMD_READ_CAPACITY,
    114 	SPC3_CMD_GET_WINDOW = SCMD_READ_CAPACITY,
    115 	SPC3_CMD_VENDOR_26 = 0x26,
    116 	SPC3_CMD_VENDOR_27 = 0x27,
    117 	SPC3_CMD_READ10 = SCMD_READ_G1,
    118 	SPC3_CMD_GET_MESSAGE10 = SCMD_READ_G1,
    119 	SPC3_CMD_READ_GENERATION = 0x29,
    120 	SPC3_CMD_WRITE10 = SCMD_WRITE_G1,
    121 	SPC3_CMD_SEND10 = SCMD_WRITE_G1,
    122 	SPC3_CMD_SEND_MESSAGE10 = SCMD_WRITE_G1,
    123 	SPC3_CMD_SEEK10 = SCMD_SEEK_G1,
    124 	SPC3_CMD_LOCATE = SCMD_LOCATE,
    125 	SPC3_CMD_LOCATE10 = SCMD_LOCATE,
    126 	SPC3_CMD_POSITION_TO_ELEMENT = SCMD_SEEK_G1,
    127 	SPC3_CMD_ERASE10 = 0x2c,
    128 	SPC3_CMD_READ_UPDATED_BLOCK = 0x2d,
    129 	SPC3_CMD_WRITE_AND_VERIFY = SCMD_WRITE_VERIFY,
    130 	SPC3_CMD_WRITE_AND_VERIFY10 = SCMD_WRITE_VERIFY,
    131 	SPC3_CMD_VERIFY10 = SCMD_VERIFY,
    132 	SPC3_CMD_SEARCH_DATA_HIGH = SCMD_SEARCH_HIGH,
    133 	SPC3_CMD_SEARCH_DATA_HIGH10 = SCMD_SEARCH_HIGH,
    134 	SPC3_CMD_SEARCH_DATA_EQUAL = SCMD_SEARCH_EQUAL,
    135 	SPC3_CMD_SEARCH_DATA_EQUAL10 = SCMD_SEARCH_EQUAL,
    136 	SPC3_CMD_OBJECT_POSITION = SCMD_SEARCH_EQUAL,
    137 	SPC3_CMD_SEARCH_DATA_LOW = SCMD_SEARCH_LOW,
    138 	SPC3_CMD_SEARCH_DATA_LOW10 = SCMD_SEARCH_LOW,
    139 	SPC3_CMD_SET_LIMITS = SCMD_SET_LIMITS,
    140 	SPC3_CMD_SET_LIMITS10 = SCMD_SET_LIMITS,
    141 	SPC3_CMD_PREFETCH = SCMD_READ_POSITION,
    142 	SPC3_CMD_PREFETCH10 = SCMD_READ_POSITION,
    143 	SPC3_CMD_READ_POSITION = SCMD_READ_POSITION,
    144 	SPC3_CMD_GET_DATA_BUFFER_STATUS = SCMD_READ_POSITION,
    145 	SPC3_CMD_SYNCHRONIZE_CACHE = SCMD_SYNCHRONIZE_CACHE,
    146 	SPC3_CMD_SYNCHRONIZE_CACHE10 = SCMD_SYNCHRONIZE_CACHE,
    147 	SPC3_CMD_LOCK_UNLOCK_CACHE = 0x36,
    148 	SPC3_CMD_READ_DEFECT_DATA = SCMD_READ_DEFECT_LIST,
    149 	SPC3_CMD_READ_DEFECT_DATA10 = SCMD_READ_DEFECT_LIST,
    150 	SPC3_CMD_INITIALIZE_ELEMENT_STATUS_WITH_RANGE = SCMD_READ_DEFECT_LIST,
    151 	SPC3_CMD_MEDIUM_SCAN = 0x38,
    152 	SPC3_CMD_COMPARE = SCMD_COMPARE,
    153 	SPC3_CMD_COPY_AND_VERIFY = SCMD_COPY_VERIFY,
    154 	SPC3_CMD_WRITE_BUFFER = SCMD_WRITE_BUFFER,
    155 	SPC3_CMD_READ_BUFFER = SCMD_READ_BUFFER,
    156 	SPC3_CMD_UPDATE_BLOCK = 0x3d,
    157 	SPC3_CMD_READ_LONG = SCMD_READ_LONG,
    158 	SPC3_CMD_READ_LONG10 = SCMD_READ_LONG,
    159 	SPC3_CMD_WRITE_LONG = SCMD_WRITE_LONG,
    160 	SPC3_CMD_WRITE_LONG10 = SCMD_WRITE_LONG,
    161 	SPC3_CMD_CHANGE_DEFINITION = 0x40,
    162 	SPC3_CMD_WRITE_SAME = 0x41,
    163 	SPC3_CMD_WRITE_SAME10 = 0x41,
    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.16 READ MEDIA SERIAL NUMBER
    817  */
    818 typedef struct spc3_read_media_serial_number_cdb {
    819 	uint8_t rmsnc_opcode;
    820 	DECL_BITFIELD2(
    821 	    rmsnc_service_action	:5,
    822 	    _reserved1			:3);
    823 	uint8_t _reserved2[4];
    824 	uint32_t rmsnc_allocation_length;
    825 	uint8_t _reserved3;
    826 	spc3_control_t rmsnc_control;
    827 } spc3_read_media_serial_number_cdb_t;
    828 
    829 typedef struct spc3_read_media_serial_number_data {
    830 	uint32_t msnd_length;
    831 	uint8_t msnd_serial_number[1];	/* Flexible */
    832 } spc3_read_media_serial_number_data_t;
    833 
    834 /*
    835  * SPC-3 6.18 RECEIVE DIAGNOSTIC RESULTS
    836  */
    837 typedef struct spc3_receive_diagnostic_results_cdb {
    838 	uint8_t rdrc_opcode;
    839 	DECL_BITFIELD2(
    840 	    rdrc_pcv	:1,
    841 	    _reserved1	:7);
    842 	uint8_t rdrc_page_code;
    843 	uint16_t rdrc_allocation_length;
    844 	spc3_control_t rdrc_control;
    845 } spc3_receive_diagnostic_results_cdb_t;
    846 
    847 /*
    848  * SPC-3 Diagnostic page format (Table 194, 7.1.1)
    849  */
    850 typedef struct spc3_diag_page_impl {
    851 	uint8_t sdpi_page_code;
    852 	uint8_t sdpi_specific;
    853 	uint16_t sdpi_page_length;
    854 	uint8_t sdpi_data[1];
    855 } spc3_diag_page_impl_t;
    856 
    857 /*
    858  * SPC-3 Supported diagnostic pages (Table 196, 7.1.2)
    859  */
    860 typedef struct spc3_supported_diag_page_impl {
    861 	uint8_t ssdpi_page_code;
    862 	uint8_t _reserved1;
    863 	uint16_t ssdpi_page_length;
    864 	uint8_t ssdpi_page_list[1];
    865 } spc3_supported_diag_page_impl_t;
    866 
    867 /*
    868  * SPC-3 6.21 REPORT LUNS
    869  */
    870 typedef enum spc3_report_luns_select_report {
    871 	SPC3_RL_SR_ADDRESSING = 0,
    872 	SPC3_RL_SR_WELLKNOWN = 1,
    873 	SPC3_RL_SR_ALL = 2
    874 } spc3_report_luns_select_report_t;
    875 
    876 typedef struct spc3_report_luns_cdb {
    877 	uint8_t rlc_opcode;
    878 	uint8_t _reserved1;
    879 	uint8_t rlc_select_report;
    880 	uint8_t _reserved2[3];
    881 	uint32_t rlc_allocation_length;
    882 	uint8_t _reserved3;
    883 	spc3_control_t rlc_control;
    884 } spc3_report_luns_cdb_t;
    885 
    886 typedef struct spc3_report_luns_data {
    887 	uint32_t rld_lun_list_length;
    888 	uint8_t _reserved1[4];
    889 	uint64_t rld_luns[1];	/* Flexible */
    890 } spc3_report_luns_data_t;
    891 
    892 /*
    893  * SPC-3 6.27 REQUEST SENSE
    894  */
    895 typedef struct spc3_request_sense_cdb {
    896 	uint8_t rsc_opcode;
    897 	DECL_BITFIELD2(
    898 	    rsc_desc	:1,
    899 	    _reserved1	:7);
    900 	uint8_t _reserved2[2];
    901 	uint8_t rsc_allocation_length;
    902 	spc3_control_t rsc_control;
    903 } spc3_request_sense_cdb_t;
    904 
    905 /*
    906  * SPC-3 6.28 SEND DIAGNOSTIC
    907  */
    908 typedef struct spc3_send_diagnostic_cdb {
    909 	uint8_t sdc_opcode;
    910 	DECL_BITFIELD6(
    911 	    sdc_unit_off_l	:1,
    912 	    sdc_dev_off_l	:1,
    913 	    sdc_self_test	:1,
    914 	    _reserved1		:1,
    915 	    sdc_pf		:1,
    916 	    sdc_selftest_code	:3);
    917 	uint8_t _reserved2;
    918 	uint16_t sdc_parameter_list_length;
    919 	spc3_control_t sdc_control;
    920 } spc3_send_diagnostic_cdb_t;
    921 
    922 /*
    923  * SPC-3 6.33 TEST UNIT READY
    924  */
    925 typedef struct spc3_test_unit_ready_cdb {
    926 	uint8_t tur_opcode;
    927 	uint8_t _reserved1[4];
    928 	spc3_control_t tur_control;
    929 } spc3_test_unit_ready_cdb_t;
    930 
    931 /*
    932  * SPC-3 6.36 WRITE BUFFER
    933  */
    934 typedef struct spc3_write_buffer_cdb {
    935 	uint8_t wbc_opcode;
    936 	DECL_BITFIELD2(
    937 	    wbc_mode		:5,
    938 	    _reserved		:3);
    939 	uint8_t wbc_bufferid;
    940 	uint8_t wbc_buffer_offset[3];
    941 	uint8_t wbc_parameter_list_len[3];
    942 	spc3_control_t wbc_control;
    943 } spc3_write_buffer_cdb_t;
    944 
    945 typedef enum spc3_write_buffer_mode {
    946 	SPC3_WB_MODE_COMB_HDR_DATA = 0x00,
    947 	SPC3_WB_MODE_VENDOR_SPECIFIC = 0x01,
    948 	SPC3_WB_MODE_DATA = 0x02,
    949 	SPC3_WB_MODE_DL_UCODE = 0x04,
    950 	SPC3_WB_MODE_DL_UCODE_SAVE = 0x05,
    951 	SPC3_WB_MODE_DL_UCODE_OFFS = 0x06,
    952 	SPC3_WB_MODE_DL_UCODE_OFFS_SAVE = 0x07,
    953 	SPC3_WB_MODE_ECHO_BUF = 0x0a,
    954 	SPC3_WB_MODE_DL_UCODE_OFFS_DEFER = 0x0e,
    955 	SPC3_WB_MODE_ACTIVATE_DEFERRED_UCODE = 0x0f,
    956 	SPC3_WB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a,
    957 	SPC3_WB_MODE_DISABLE_EXPANDER = 0x1b,
    958 	SPC3_WB_MODE_DL_APP_LOG = 0x1c
    959 } spc3_write_buffer_mode_t;
    960 
    961 typedef struct spc3_write_buffer_log {
    962 	uint8_t wbl_vendor[8];
    963 	uint16_t wbl_error_type;
    964 	uint16_t _reserved1;
    965 	uint8_t wbl_timestamp[6];
    966 	uint16_t _reserved2;
    967 	DECL_BITFIELD2(
    968 	    _reserved3		:4,
    969 	    wbl_codeset		:4);
    970 	uint8_t wbl_error_location_fmt;
    971 	uint16_t wbl_error_location_len;
    972 	uint16_t wbl_client_error_history_len;
    973 	uint32_t wbl_data[1];
    974 } spc3_write_buffer_log_t;
    975 
    976 typedef enum sp3_write_buffer_error_type {
    977 	SPC3_WB_ERROR_NONE = 0x0000,
    978 	SPC3_WB_ERROR_UNKNOWN = 0x0001,
    979 	SPC3_WB_ERROR_DATA_CORRUPT = 0x0002,
    980 	SPC3_WB_ERROR_PERMANENT = 0x0003,
    981 	SPC3_WB_ERROR_SERVICETARGET_FAILURE = 0x0004
    982 } spc3_write_buffer_error_type_t;
    983 
    984 typedef enum spc3_write_buffer_codeset {
    985 	SPC3_WB_CODESET_RESERVED = 0x00,
    986 	SPC3_WB_CODESET_BIN = 0x01,
    987 	SPC3_WB_CODESET_ASCII = 0x02,
    988 	SPC3_WB_CODESET_UTF8 = 0x03
    989 } spc3_write_buffer_codeset_t;
    990 
    991 typedef enum spc_3_write_buffer_error_location {
    992 	SPC3_WB_ERROR_LOCATION_FMT_NONE = 0x00,
    993 	SPC3_WB_ERROR_LOCATION_FMT_LBA = 0x01
    994 } spc3_write_buffer_error_location_t;
    995 
    996 /*
    997  * SPC-4 7.5.1 Protocol values
    998  */
    999 typedef enum spc4_protocol_id {
   1000 	SPC4_PROTO_FIBRE_CHANNEL = 0,
   1001 	SPC4_PROTO_PARALLEL_SCSI = 1,
   1002 	SPC4_PROTO_SSA = 2,
   1003 	SPC4_PROTO_IEEE1394 = 3,
   1004 	SPC4_PROTO_RDMA = 4,
   1005 	SPC4_PROTO_ISCSI = 5,
   1006 	SPC4_PROTO_SAS = 6,
   1007 	SPC4_PROTO_ADT = 7,
   1008 	SPC4_PROTO_ATA = 8,
   1009 	SPC4_PROTO_NONE = 0xf
   1010 } spc4_protocol_id_t;
   1011 
   1012 /*
   1013  * SPC-3 NAA identifier format (Table 305, 7.6.3.6.1)
   1014  */
   1015 typedef struct spc3_naa_id_impl {
   1016 	DECL_BITFIELD2(
   1017 	    snii_priv_msn	:4,
   1018 	    snii_naa	:4);
   1019 	uint8_t snii_priv[1];
   1020 } spc3_naa_id_impl_t;
   1021 
   1022 /*
   1023  * SPC-3 NAA IEEE Extended Identifier field format (Table 307, 7.6.3.6.2)
   1024  */
   1025 typedef struct spc3_naa_ieee_ext_id_impl {
   1026 	DECL_BITFIELD2(
   1027 	    snieii_vendor_id_a_msn	:4,
   1028 	    snieii_naa			:4);
   1029 	uint8_t snieii_vendor_id_a_lsb;
   1030 	uint8_t snieii_company_id[3];
   1031 	uint8_t snieii_vendor_id_b[3];
   1032 } spc3_naa_ieee_ext_id_impl_t;
   1033 
   1034 #define	NAA_IEEE_EXT_VENDOR_A(idp)	\
   1035 	SCSI_MK12_4_8((idp)->snieii_vendor_id_a_msn,	\
   1036 	    (idp)->snieii_vendor_id_a_lsb)
   1037 #define	NAA_IEEE_EXT_COMPANY_ID(idp)	SCSI_READ24((idp)->snieii_company_id)
   1038 #define	NAA_IEEE_EXT_VENDOR_B(idp)	SCSI_READ24((idp)->snieii_vendor_id_b)
   1039 
   1040 /*
   1041  * Ibid, Table 308
   1042  */
   1043 typedef struct spc3_naa_ieee_reg_id_impl {
   1044 	DECL_BITFIELD2(
   1045 	    snirii_company_id_msn	:4,
   1046 	    snirii_naa			:4);
   1047 	uint16_t snirii_company_id_mid;
   1048 	DECL_BITFIELD2(
   1049 	    snirii_vendor_id_msn	:4,
   1050 	    snirii_company_id_lsn	:4);
   1051 	uint32_t snirii_vendor_id_low;
   1052 } spc3_naa_ieee_reg_id_impl_t;
   1053 
   1054 #define	NAA_IEEE_REG_COMPANY_ID(idp)	\
   1055 	SCSI_MK24_4_16_4((idp)->snirii_company_id_msn,	\
   1056 	    SCSI_READ16(&(idp)->snirii_company_id_mid),	\
   1057 	    (idp)->snirii_company_id_lsn)
   1058 #define	NAA_IEEE_REG_VENDOR_ID(idp)	\
   1059 	SCSI_MK36_4_32((idp)->snirii_vendor_id_msn,	\
   1060 	    SCSI_READ32(&(idp)->snirii_vendor_id_low))
   1061 
   1062 /*
   1063  * Ibid, Table 309
   1064  */
   1065 typedef struct spc3_naa_ieee_reg_ext_id_impl {
   1066 	DECL_BITFIELD2(
   1067 	    snireii_company_id_msn	:4,
   1068 	    snireii_naa		:4);
   1069 	uint16_t snireii_company_id_mid;
   1070 	DECL_BITFIELD2(
   1071 	    snireii_vendor_id_msn	:4,
   1072 	    snireii_company_id_lsn	:4);
   1073 	uint32_t snireii_vendor_id_low;
   1074 	uint64_t snireii_vendor_id_ext;
   1075 } spc3_naa_ieee_reg_ext_id_impl_t;
   1076 
   1077 #define	NAA_IEEE_REG_EXT_COMPANY_ID(idp)	\
   1078 	SCSI_MK20_4_16_4((idp)->snireii_company_id_msn,	\
   1079 	    SCSI_READ16(&(idp)->snireii_company_id_mid),	\
   1080 	    (idp)->snireii_company_id_lsn)
   1081 #define	NAA_IEEE_REG_EXT_VENDOR_ID(idp)	\
   1082 	SCSI_MK36_4_32((idp)->snireii_vendor_id_msn,	\
   1083 	    SCSI_READ32(&(idp)->snireii_vendor_id_low))
   1084 
   1085 typedef union spc3_naa_id_8_impl {
   1086 	struct {
   1087 		DECL_BITFIELD2(
   1088 		    _reserved1	:4,
   1089 		    sni8i_naa	:4);
   1090 	} sni8i_hdr;
   1091 	spc3_naa_ieee_ext_id_impl_t sni8i_ext_id;
   1092 	spc3_naa_ieee_reg_id_impl_t sni8i_reg_id;
   1093 } spc3_naa_id_8_impl_t;
   1094 
   1095 #define	sni8i_naa	sni8i_hdr.sni8i_naa
   1096 
   1097 typedef enum naa_id {
   1098 	NAA_IEEE_EXT = 0x2,
   1099 	NAA_LOCAL = 0x3,
   1100 	NAA_IEEE_REG = 0x5,
   1101 	NAA_IEEE_REG_EXT = 0x6
   1102 } naa_id_t;
   1103 
   1104 #pragma pack()
   1105 
   1106 #ifdef	__cplusplus
   1107 }
   1108 #endif
   1109 
   1110 #endif	/* _SPC3_TYPES_H */
   1111