1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
6 * SCSI specification definition
7 * refer http://www.t10.org/drafts.htm#SPC_Family for SPC-3 and SBC-3
15 enum scsi_group_code {
16 SCSI_6BYTE_CMD = 0x00,
17 SCSI_10BYTE_CMD = 0x20,
18 SCSI_10BYTE_CMD2 = 0x40,
19 SCSI_16BYTE_CMD = 0x80,
20 SCSI_12BYTE_CMD = 0xa0,
23 #define SCSI_GROUP_MASK 0xe0
24 #define SCSI_OPCODE_MASK 0x1f
27 SCSI_STATUS_GOOD = 0x00,
28 SCSI_STATUS_CHECK_CONDITION = 0x02,
29 SCSI_STATUS_CONDITION_MET = 0x04,
30 SCSI_STATUS_BUSY = 0x08,
31 SCSI_STATUS_INTERMEDIATE = 0x10,
32 SCSI_STATUS_INTERMEDIATE_CONDITION_MET = 0x14,
33 SCSI_STATUS_RESERVATION_CONFLICT = 0x18,
34 SCSI_STATUS_Obsolete = 0x22,
35 SCSI_STATUS_TASK_SET_FULL = 0x28,
36 SCSI_STATUS_ACA_ACTIVE = 0x30,
37 SCSI_STATUS_TASK_ABORTED = 0x40,
41 SCSI_SENSE_NO_SENSE = 0x00,
42 SCSI_SENSE_RECOVERED_ERROR = 0x01,
43 SCSI_SENSE_NOT_READY = 0x02,
44 SCSI_SENSE_MEDIUM_ERROR = 0x03,
45 SCSI_SENSE_HARDWARE_ERROR = 0x04,
46 SCSI_SENSE_ILLEGAL_REQUEST = 0x05,
47 SCSI_SENSE_UNIT_ATTENTION = 0x06,
48 SCSI_SENSE_DATA_PROTECT = 0x07,
49 SCSI_SENSE_BLANK_CHECK = 0x08,
50 SCSI_SENSE_VENDOR_SPECIFIC = 0x09,
51 SCSI_SENSE_COPY_ABORTED = 0x0a,
52 SCSI_SENSE_ABORTED_COMMAND = 0x0b,
53 SCSI_SENSE_VOLUME_OVERFLOW = 0x0d,
54 SCSI_SENSE_MISCOMPARE = 0x0e,
58 SCSI_ASC_NO_ADDITIONAL_SENSE = 0x00,
59 SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03,
60 SCSI_ASC_LOGICAL_UNIT_NOT_READY = 0x04,
61 SCSI_ASC_WARNING = 0x0b,
62 SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x10,
63 SCSI_ASC_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = 0x10,
64 SCSI_ASC_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = 0x10,
65 SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11,
66 SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION = 0x1d,
67 SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20,
68 SCSI_ASC_ACCESS_DENIED = 0x20,
69 SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE = 0x21,
70 SCSI_ASC_INVALID_FIELD_IN_CDB = 0x24,
71 SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25,
72 SCSI_ASC_WRITE_PROTECTED = 0x27,
73 SCSI_ASC_FORMAT_COMMAND_FAILED = 0x31,
74 SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x44,
78 SCSI_ASCQ_CAUSE_NOT_REPORTABLE = 0x00,
79 SCSI_ASCQ_BECOMING_READY = 0x01,
80 SCSI_ASCQ_FORMAT_COMMAND_FAILED = 0x01,
81 SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x01,
82 SCSI_ASCQ_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED = 0x02,
83 SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02,
84 SCSI_ASCQ_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED = 0x03,
85 SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08,
86 SCSI_ASCQ_INVALID_LU_IDENTIFIER = 0x09,
91 SPC_ACCESS_CONTROL_IN = 0x86,
92 SPC_ACCESS_CONTROL_OUT = 0x87,
93 SPC_EXTENDED_COPY = 0x83,
95 SPC_LOG_SELECT = 0x4c,
97 SPC_MODE_SELECT_6 = 0x15,
98 SPC_MODE_SELECT_10 = 0x55,
99 SPC_MODE_SENSE_6 = 0x1a,
100 SPC_MODE_SENSE_10 = 0x5a,
101 SPC_PERSISTENT_RESERVE_IN = 0x5e,
102 SPC_PERSISTENT_RESERVE_OUT = 0x5f,
103 SPC_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e,
104 SPC_READ_ATTRIBUTE = 0x8c,
105 SPC_READ_BUFFER = 0x3c,
106 SPC_RECEIVE_COPY_RESULTS = 0x84,
107 SPC_RECEIVE_DIAGNOSTIC_RESULTS = 0x1c,
108 SPC_REPORT_LUNS = 0xa0,
109 SPC_REQUEST_SENSE = 0x03,
110 SPC_SEND_DIAGNOSTIC = 0x1d,
111 SPC_TEST_UNIT_READY = 0x00,
112 SPC_WRITE_ATTRIBUTE = 0x8d,
113 SPC_WRITE_BUFFER = 0x3b,
115 SPC_SERVICE_ACTION_IN_12 = 0xab,
116 SPC_SERVICE_ACTION_OUT_12 = 0xa9,
117 SPC_SERVICE_ACTION_IN_16 = 0x9e,
118 SPC_SERVICE_ACTION_OUT_16 = 0x9f,
120 SPC_VARIABLE_LENGTH = 0x7f,
122 SPC_MO_CHANGE_ALIASES = 0x0b,
123 SPC_MO_SET_DEVICE_IDENTIFIER = 0x06,
124 SPC_MO_SET_PRIORITY = 0x0e,
125 SPC_MO_SET_TARGET_PORT_GROUPS = 0x0a,
126 SPC_MO_SET_TIMESTAMP = 0x0f,
127 SPC_MI_REPORT_ALIASES = 0x0b,
128 SPC_MI_REPORT_DEVICE_IDENTIFIER = 0x05,
129 SPC_MI_REPORT_PRIORITY = 0x0e,
130 SPC_MI_REPORT_SUPPORTED_OPERATION_CODES = 0x0c,
131 SPC_MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS = 0x0d,
132 SPC_MI_REPORT_TARGET_PORT_GROUPS = 0x0a,
133 SPC_MI_REPORT_TIMESTAMP = 0x0f,
135 /* SPC2 related (Obsolete) */
136 SPC2_RELEASE_6 = 0x17,
137 SPC2_RELEASE_10 = 0x57,
138 SPC2_RESERVE_6 = 0x16,
139 SPC2_RESERVE_10 = 0x56,
143 SCC_MAINTENANCE_IN = 0xa3,
144 SCC_MAINTENANCE_OUT = 0xa4,
148 SBC_COMPARE_AND_WRITE = 0x89,
149 SBC_FORMAT_UNIT = 0x04,
150 SBC_GET_LBA_STATUS = 0x0012009e,
151 SBC_ORWRITE_16 = 0x8b,
152 SBC_PRE_FETCH_10 = 0x34,
153 SBC_PRE_FETCH_16 = 0x90,
158 SBC_READ_ATTRIBUTE = 0x8c,
159 SBC_READ_BUFFER = 0x3c,
160 SBC_READ_CAPACITY_10 = 0x25,
161 SBC_READ_DEFECT_DATA_10 = 0x37,
162 SBC_READ_DEFECT_DATA_12 = 0xb7,
163 SBC_READ_LONG_10 = 0x3e,
164 SBC_REASSIGN_BLOCKS = 0x07,
166 SBC_START_STOP_UNIT = 0x1b,
167 SBC_SYNCHRONIZE_CACHE_10 = 0x35,
168 SBC_SYNCHRONIZE_CACHE_16 = 0x91,
170 SBC_VERIFY_10 = 0x2f,
171 SBC_VERIFY_12 = 0xaf,
172 SBC_VERIFY_16 = 0x8f,
177 SBC_WRITE_AND_VERIFY_10 = 0x2e,
178 SBC_WRITE_AND_VERIFY_12 = 0xae,
179 SBC_WRITE_AND_VERIFY_16 = 0x8e,
180 SBC_WRITE_LONG_10 = 0x3f,
181 SBC_WRITE_SAME_10 = 0x41,
182 SBC_WRITE_SAME_16 = 0x93,
183 SBC_XDREAD_10 = 0x52,
184 SBC_XDWRITE_10 = 0x50,
185 SBC_XDWRITEREAD_10 = 0x53,
186 SBC_XPWRITE_10 = 0x51,
188 SBC_SAI_READ_CAPACITY_16 = 0x10,
189 SBC_SAI_READ_LONG_16 = 0x11,
190 SBC_SAO_WRITE_LONG_16 = 0x11,
192 SBC_VL_READ_32 = 0x0009,
193 SBC_VL_VERIFY_32 = 0x000a,
194 SBC_VL_WRITE_32 = 0x000b,
195 SBC_VL_WRITE_AND_VERIFY_32 = 0x000c,
196 SBC_VL_WRITE_SAME_32 = 0x000d,
197 SBC_VL_XDREAD_32 = 0x0003,
198 SBC_VL_XDWRITE_32 = 0x0004,
199 SBC_VL_XDWRITEREAD_32 = 0x0007,
200 SBC_VL_XPWRITE_32 = 0x0006,
205 MMC_READ_DISC_STRUCTURE = 0xad,
209 MMC_CLOSE_TRACK_SESSION = 0x5b,
211 MMC_FORMAT_UNIT = 0x04,
212 MMC_GET_CONFIGURATION = 0x46,
213 MMC_GET_EVENT_STATUS_NOTIFICATION = 0x4a,
214 MMC_GET_PERFORMANCE = 0xac,
216 MMC_LOAD_UNLOAD_MEDIUM = 0xa6,
217 MMC_MECHANISM_STATUS = 0xbd,
218 MMC_MODE_SELECT_10 = 0x55,
219 MMC_MODE_SENSE_10 = 0x5a,
220 MMC_PAUSE_RESUME = 0x4b,
221 MMC_PLAY_AUDIO_10 = 0x45,
222 MMC_PLAY_AUDIO_12 = 0xa5,
223 MMC_PLAY_AUDIO_MSF = 0x47,
224 MMC_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e,
227 MMC_READ_BUFFER = 0x3c,
228 MMC_READ_BUFFER_CAPACITY = 0x5c,
229 MMC_READ_CAPACITY = 0x25,
231 MMC_READ_CD_MSF = 0xb9,
232 MMC_READ_DISC_INFORMATION = 0x51,
233 MMC_READ_DVD_STRUCTURE = 0xad,
234 MMC_READ_FORMAT_CAPACITIES = 0x23,
235 MMC_READ_SUB_CHANNEL = 0x42,
236 MMC_READ_TOC_PMA_ATIP = 0x43,
237 MMC_READ_TRACK_INFORMATION = 0x52,
238 MMC_REPAIR_TRACK = 0x58,
239 MMC_REPORT_KEY = 0xa4,
240 MMC_REQUEST_SENSE = 0x03,
241 MMC_RESERVE_TRACK = 0x53,
244 MMC_SEND_CUE_SHEET = 0x5d,
245 MMC_SEND_DVD_STRUCTURE = 0xbf,
247 MMC_SEND_OPC_INFORMATION = 0x54,
248 MMC_SET_CD_SPEED = 0xbb,
249 MMC_SET_READ_AHEAD = 0xa7,
250 MMC_SET_STREAMING = 0xb6,
251 MMC_START_STOP_UNIT = 0x1b,
252 MMC_STOP_PLAY_SCAN = 0x4e,
253 MMC_SYNCHRONIZE_CACHE = 0x35,
254 MMC_TEST_UNIT_READY = 0x00,
255 MMC_VERIFY_10 = 0x2f,
258 MMC_WRITE_AND_VERIFY_10 = 0x2e,
259 MMC_WRITE_BUFFER = 0x3b,
264 SSC_FORMAT_MEDIUM = 0x04,
265 SSC_LOAD_UNLOAD = 0x1b,
266 SSC_LOCATE_10 = 0x2b,
267 SSC_LOCATE_16 = 0x92,
268 SSC_MOVE_MEDIUM_ATTACHED = 0xa7,
270 SSC_READ_BLOCK_LIMITS = 0x05,
271 SSC_READ_ELEMENT_STATUS_ATTACHED = 0xb4,
272 SSC_READ_POSITION = 0x34,
273 SSC_READ_REVERSE_6 = 0x0f,
274 SSC_RECOVER_BUFFERED_DATA = 0x14,
275 SSC_REPORT_DENSITY_SUPPORT = 0x44,
277 SSC_SET_CAPACITY = 0x0b,
282 SSC_WRITE_FILEMARKS_6 = 0x10,
286 SPC_VPD_DEVICE_IDENTIFICATION = 0x83,
287 SPC_VPD_EXTENDED_INQUIRY_DATA = 0x86,
288 SPC_VPD_MANAGEMENT_NETWORK_ADDRESSES = 0x85,
289 SPC_VPD_MODE_PAGE_POLICY = 0x87,
290 SPC_VPD_SCSI_PORTS = 0x88,
291 SPC_VPD_SOFTWARE_INTERFACE_IDENTIFICATION = 0x84,
292 SPC_VPD_SUPPORTED_VPD_PAGES = 0x00,
293 SPC_VPD_UNIT_SERIAL_NUMBER = 0x80,
294 SPC_VPD_BLOCK_LIMITS = 0xb0,
295 SPC_VPD_BLOCK_DEV_CHARS = 0xb1,
296 SPC_VPD_BLOCK_THIN_PROVISION = 0xb2,
300 SPC_PERIPHERAL_DEVICE_TYPE_DISK = 0x00,
301 SPC_PERIPHERAL_DEVICE_TYPE_TAPE = 0x01,
302 SPC_PERIPHERAL_DEVICE_TYPE_DVD = 0x05,
303 SPC_PERIPHERAL_DEVICE_TYPE_CHANGER = 0x08,
305 SPC_VERSION_NONE = 0x00,
306 SPC_VERSION_SPC = 0x03,
307 SPC_VERSION_SPC2 = 0x04,
308 SPC_VERSION_SPC3 = 0x05,
309 SPC_VERSION_SPC4 = 0x06,
311 SPC_PROTOCOL_IDENTIFIER_FC = 0x00,
312 SPC_PROTOCOL_IDENTIFIER_PSCSI = 0x01,
313 SPC_PROTOCOL_IDENTIFIER_SSA = 0x02,
314 SPC_PROTOCOL_IDENTIFIER_IEEE1394 = 0x03,
315 SPC_PROTOCOL_IDENTIFIER_RDMA = 0x04,
316 SPC_PROTOCOL_IDENTIFIER_ISCSI = 0x05,
317 SPC_PROTOCOL_IDENTIFIER_SAS = 0x06,
318 SPC_PROTOCOL_IDENTIFIER_ADT = 0x07,
319 SPC_PROTOCOL_IDENTIFIER_ATA = 0x08,
321 SPC_VPD_CODE_SET_BINARY = 0x01,
322 SPC_VPD_CODE_SET_ASCII = 0x02,
323 SPC_VPD_CODE_SET_UTF8 = 0x03,
325 SPC_VPD_ASSOCIATION_LOGICAL_UNIT = 0x00,
326 SPC_VPD_ASSOCIATION_TARGET_PORT = 0x01,
327 SPC_VPD_ASSOCIATION_TARGET_DEVICE = 0x02,
329 SPC_VPD_IDENTIFIER_TYPE_VENDOR_SPECIFIC = 0x00,
330 SPC_VPD_IDENTIFIER_TYPE_T10_VENDOR_ID = 0x01,
331 SPC_VPD_IDENTIFIER_TYPE_EUI64 = 0x02,
332 SPC_VPD_IDENTIFIER_TYPE_NAA = 0x03,
333 SPC_VPD_IDENTIFIER_TYPE_RELATIVE_TARGET_PORT = 0x04,
334 SPC_VPD_IDENTIFIER_TYPE_TARGET_PORT_GROUP = 0x05,
335 SPC_VPD_IDENTIFIER_TYPE_LOGICAL_UNIT_GROUP = 0x06,
336 SPC_VPD_IDENTIFIER_TYPE_MD5_LOGICAL_UNIT = 0x07,
337 SPC_VPD_IDENTIFIER_TYPE_SCSI_NAME = 0x08,
340 struct scsi_cdb_inquiry {
348 struct scsi_cdb_inquiry_data {
357 uint8_t t10_vendor_id[8];
358 uint8_t product_id[16];
359 uint8_t product_rev[4];
366 struct scsi_vpd_page {
373 #define SCSI_VEXT_REF_CHK 0x01
374 #define SCSI_VEXT_APP_CHK 0x02
375 #define SCSI_VEXT_GRD_CHK 0x04
376 #define SCSI_VEXT_SIMPSUP 0x01
377 #define SCSI_VEXT_ORDSUP 0x02
378 #define SCSI_VEXT_HEADSUP 0x04
379 #define SCSI_VEXT_PRIOR_SUP 0x08
380 #define SCSI_VEXT_GROUP_SUP 0x10
381 #define SCSI_VEXT_UASK_SUP 0x20
382 #define SCSI_VEXT_V_SUP 0x01
383 #define SCSI_VEXT_NV_SUP 0x02
384 #define SCSI_VEXT_CRD_SUP 0x04
385 #define SCSI_VEXT_WU_SUP 0x08
387 struct scsi_vpd_ext_inquiry {
397 uint8_t reserved[54];
400 #define SPC_VPD_DESIG_PIV 0x80
402 /* designation descriptor */
403 struct scsi_desig_desc {
404 uint8_t code_set : 4;
405 uint8_t protocol_id : 4;
407 uint8_t association : 2;
408 uint8_t reserved0 : 1;
415 /* mode page policy descriptor */
416 struct scsi_mpage_policy_desc {
418 uint8_t sub_page_code;
423 /* target port descriptor */
424 struct scsi_tgt_port_desc {
429 uint8_t designator[];
432 /* SCSI port designation descriptor */
433 struct scsi_port_desc {
435 uint16_t rel_port_id;
437 uint16_t init_port_len;
438 uint16_t init_port_id;
440 uint16_t tgt_desc_len;
444 /* SCSI UNMAP block descriptor */
445 struct scsi_unmap_bdesc {
446 /* UNMAP LOGICAL BLOCK ADDRESS */
449 /* NUMBER OF LOGICAL BLOCKS */
450 uint32_t block_count;
456 #define SCSI_UNMAP_LBPU (1 << 7)
457 #define SCSI_UNMAP_LBPWS (1 << 6)
458 #define SCSI_UNMAP_LBPWS10 (1 << 5)
460 #define SCSI_UNMAP_FULL_PROVISIONING 0x00
461 #define SCSI_UNMAP_RESOURCE_PROVISIONING 0x01
462 #define SCSI_UNMAP_THIN_PROVISIONING 0x02
464 #endif /* _SCSI_SPEC_H */