Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * This header file contains public constants and structures used by
  4 * both the SCSI initiator and the SCSI target code.
  5 *
  6 * For documentation on the OPCODES, MESSAGES, and SENSE values,
  7 * please consult the SCSI standard.
  8 */
  9
 10#ifndef _SCSI_PROTO_H_
 11#define _SCSI_PROTO_H_
 12
 
 13#include <linux/types.h>
 14
 15/*
 16 *      SCSI opcodes
 17 */
 18
 19#define TEST_UNIT_READY       0x00
 20#define REZERO_UNIT           0x01
 21#define REQUEST_SENSE         0x03
 22#define FORMAT_UNIT           0x04
 23#define READ_BLOCK_LIMITS     0x05
 24#define REASSIGN_BLOCKS       0x07
 25#define INITIALIZE_ELEMENT_STATUS 0x07
 26#define READ_6                0x08
 27#define WRITE_6               0x0a
 28#define SEEK_6                0x0b
 29#define READ_REVERSE          0x0f
 30#define WRITE_FILEMARKS       0x10
 31#define SPACE                 0x11
 32#define INQUIRY               0x12
 33#define RECOVER_BUFFERED_DATA 0x14
 34#define MODE_SELECT           0x15
 35#define RESERVE               0x16
 36#define RELEASE               0x17
 37#define COPY                  0x18
 38#define ERASE                 0x19
 39#define MODE_SENSE            0x1a
 40#define START_STOP            0x1b
 41#define RECEIVE_DIAGNOSTIC    0x1c
 42#define SEND_DIAGNOSTIC       0x1d
 43#define ALLOW_MEDIUM_REMOVAL  0x1e
 44
 45#define READ_FORMAT_CAPACITIES 0x23
 46#define SET_WINDOW            0x24
 47#define READ_CAPACITY         0x25
 48#define READ_10               0x28
 49#define WRITE_10              0x2a
 50#define SEEK_10               0x2b
 51#define POSITION_TO_ELEMENT   0x2b
 52#define WRITE_VERIFY          0x2e
 53#define VERIFY                0x2f
 54#define SEARCH_HIGH           0x30
 55#define SEARCH_EQUAL          0x31
 56#define SEARCH_LOW            0x32
 57#define SET_LIMITS            0x33
 58#define PRE_FETCH             0x34
 59#define READ_POSITION         0x34
 60#define SYNCHRONIZE_CACHE     0x35
 61#define LOCK_UNLOCK_CACHE     0x36
 62#define READ_DEFECT_DATA      0x37
 63#define MEDIUM_SCAN           0x38
 64#define COMPARE               0x39
 65#define COPY_VERIFY           0x3a
 66#define WRITE_BUFFER          0x3b
 67#define READ_BUFFER           0x3c
 68#define UPDATE_BLOCK          0x3d
 69#define READ_LONG             0x3e
 70#define WRITE_LONG            0x3f
 71#define CHANGE_DEFINITION     0x40
 72#define WRITE_SAME            0x41
 73#define UNMAP		      0x42
 74#define READ_TOC              0x43
 75#define READ_HEADER           0x44
 76#define GET_EVENT_STATUS_NOTIFICATION 0x4a
 77#define LOG_SELECT            0x4c
 78#define LOG_SENSE             0x4d
 79#define XDWRITEREAD_10        0x53
 80#define MODE_SELECT_10        0x55
 81#define RESERVE_10            0x56
 82#define RELEASE_10            0x57
 83#define MODE_SENSE_10         0x5a
 84#define PERSISTENT_RESERVE_IN 0x5e
 85#define PERSISTENT_RESERVE_OUT 0x5f
 86#define VARIABLE_LENGTH_CMD   0x7f
 87#define REPORT_LUNS           0xa0
 88#define SECURITY_PROTOCOL_IN  0xa2
 89#define MAINTENANCE_IN        0xa3
 90#define MAINTENANCE_OUT       0xa4
 91#define MOVE_MEDIUM           0xa5
 92#define EXCHANGE_MEDIUM       0xa6
 93#define READ_12               0xa8
 94#define SERVICE_ACTION_OUT_12 0xa9
 95#define WRITE_12              0xaa
 96#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
 97#define SERVICE_ACTION_IN_12  0xab
 98#define WRITE_VERIFY_12       0xae
 99#define VERIFY_12	      0xaf
100#define SEARCH_HIGH_12        0xb0
101#define SEARCH_EQUAL_12       0xb1
102#define SEARCH_LOW_12         0xb2
103#define SECURITY_PROTOCOL_OUT 0xb5
104#define READ_ELEMENT_STATUS   0xb8
105#define SEND_VOLUME_TAG       0xb6
106#define WRITE_LONG_2          0xea
107#define EXTENDED_COPY         0x83
108#define RECEIVE_COPY_RESULTS  0x84
109#define ACCESS_CONTROL_IN     0x86
110#define ACCESS_CONTROL_OUT    0x87
111#define READ_16               0x88
112#define COMPARE_AND_WRITE     0x89
113#define WRITE_16              0x8a
114#define READ_ATTRIBUTE        0x8c
115#define WRITE_ATTRIBUTE	      0x8d
116#define WRITE_VERIFY_16	      0x8e
117#define VERIFY_16	      0x8f
118#define SYNCHRONIZE_CACHE_16  0x91
119#define WRITE_SAME_16	      0x93
120#define ZBC_OUT		      0x94
121#define ZBC_IN		      0x95
122#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
123#define SERVICE_ACTION_IN_16  0x9e
124#define SERVICE_ACTION_OUT_16 0x9f
125/* values for service action in */
126#define	SAI_READ_CAPACITY_16  0x10
127#define SAI_GET_LBA_STATUS    0x12
128#define SAI_REPORT_REFERRALS  0x13
 
129/* values for maintenance in */
130#define MI_REPORT_IDENTIFYING_INFORMATION 0x05
131#define MI_REPORT_TARGET_PGS  0x0a
132#define MI_REPORT_ALIASES     0x0b
133#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
134#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
135#define MI_REPORT_PRIORITY    0x0e
136#define MI_REPORT_TIMESTAMP   0x0f
137#define MI_MANAGEMENT_PROTOCOL_IN 0x10
138/* value for MI_REPORT_TARGET_PGS ext header */
139#define MI_EXT_HDR_PARAM_FMT  0x20
140/* values for maintenance out */
141#define MO_SET_IDENTIFYING_INFORMATION 0x06
142#define MO_SET_TARGET_PGS     0x0a
143#define MO_CHANGE_ALIASES     0x0b
144#define MO_SET_PRIORITY       0x0e
145#define MO_SET_TIMESTAMP      0x0f
146#define MO_MANAGEMENT_PROTOCOL_OUT 0x10
147/* values for ZBC_IN */
148#define ZI_REPORT_ZONES	      0x00
149/* values for ZBC_OUT */
150#define ZO_CLOSE_ZONE	      0x01
151#define ZO_FINISH_ZONE	      0x02
152#define ZO_OPEN_ZONE	      0x03
153#define ZO_RESET_WRITE_POINTER 0x04
 
 
 
 
 
154/* values for variable length command */
155#define XDREAD_32	      0x03
156#define XDWRITE_32	      0x04
157#define XPWRITE_32	      0x06
158#define XDWRITEREAD_32	      0x07
159#define READ_32		      0x09
160#define VERIFY_32	      0x0a
161#define WRITE_32	      0x0b
162#define WRITE_VERIFY_32	      0x0c
163#define WRITE_SAME_32	      0x0d
164#define ATA_32		      0x1ff0
165
166/* Values for T10/04-262r7 */
167#define	ATA_16		      0x85	/* 16-byte pass-thru */
168#define	ATA_12		      0xa1	/* 12-byte pass-thru */
169
170/* Vendor specific CDBs start here */
171#define VENDOR_SPECIFIC_CDB 0xc0
172
173/*
174 *	SCSI command lengths
175 */
176
177#define SCSI_MAX_VARLEN_CDB_SIZE 260
178
179/* defined in T10 SCSI Primary Commands-2 (SPC2) */
180struct scsi_varlen_cdb_hdr {
181	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */
182	__u8 control;
183	__u8 misc[5];
184	__u8 additional_cdb_length;         /* total cdb length - 8 */
185	__be16 service_action;
186	/* service specific data follows */
187};
188
189/*
190 *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
191 *  T10/1561-D Revision 4 Draft dated 7th November 2002.
192 */
193enum sam_status {
194	SAM_STAT_GOOD				= 0x00,
195	SAM_STAT_CHECK_CONDITION		= 0x02,
196	SAM_STAT_CONDITION_MET			= 0x04,
197	SAM_STAT_BUSY				= 0x08,
198	SAM_STAT_INTERMEDIATE			= 0x10,
199	SAM_STAT_INTERMEDIATE_CONDITION_MET	= 0x14,
200	SAM_STAT_RESERVATION_CONFLICT		= 0x18,
201	SAM_STAT_COMMAND_TERMINATED		= 0x22,	/* obsolete in SAM-3 */
202	SAM_STAT_TASK_SET_FULL			= 0x28,
203	SAM_STAT_ACA_ACTIVE			= 0x30,
204	SAM_STAT_TASK_ABORTED			= 0x40,
205};
206
207#define STATUS_MASK         0xfe
208
209/*
210 *  SENSE KEYS
211 */
212#define NO_SENSE            0x00
213#define RECOVERED_ERROR     0x01
214#define NOT_READY           0x02
215#define MEDIUM_ERROR        0x03
216#define HARDWARE_ERROR      0x04
217#define ILLEGAL_REQUEST     0x05
218#define UNIT_ATTENTION      0x06
219#define DATA_PROTECT        0x07
220#define BLANK_CHECK         0x08
221#define VENDOR_SPECIFIC     0x09
222#define COPY_ABORTED        0x0a
223#define ABORTED_COMMAND     0x0b
224#define VOLUME_OVERFLOW     0x0d
225#define MISCOMPARE          0x0e
226#define COMPLETED	    0x0f
227
228/*
229 *  DEVICE TYPES
230 *  Please keep them in 0x%02x format for $MODALIAS to work
231 */
232
233#define TYPE_DISK           0x00
234#define TYPE_TAPE           0x01
235#define TYPE_PRINTER        0x02
236#define TYPE_PROCESSOR      0x03    /* HP scanners use this */
237#define TYPE_WORM           0x04    /* Treated as ROM by our system */
238#define TYPE_ROM            0x05
239#define TYPE_SCANNER        0x06
240#define TYPE_MOD            0x07    /* Magneto-optical disk -
241				     * - treated as TYPE_DISK */
242#define TYPE_MEDIUM_CHANGER 0x08
243#define TYPE_COMM           0x09    /* Communications device */
244#define TYPE_RAID           0x0c
245#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
246#define TYPE_RBC	    0x0e
247#define TYPE_OSD            0x11
248#define TYPE_ZBC            0x14
249#define TYPE_WLUN           0x1e    /* well-known logical unit */
250#define TYPE_NO_LUN         0x7f
251
252/* SCSI protocols; these are taken from SPC-3 section 7.5 */
253enum scsi_protocol {
254	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
255	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
256	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */
257	SCSI_PROTOCOL_SBP = 3,	/* firewire */
258	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */
259	SCSI_PROTOCOL_ISCSI = 5,
260	SCSI_PROTOCOL_SAS = 6,
261	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
262	SCSI_PROTOCOL_ATA = 8,
263	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
264};
265
266/*
267 * ScsiLun: 8 byte LUN.
268 */
269struct scsi_lun {
270	__u8 scsi_lun[8];
271};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
273/* SPC asymmetric access states */
274#define SCSI_ACCESS_STATE_OPTIMAL     0x00
275#define SCSI_ACCESS_STATE_ACTIVE      0x01
276#define SCSI_ACCESS_STATE_STANDBY     0x02
277#define SCSI_ACCESS_STATE_UNAVAILABLE 0x03
278#define SCSI_ACCESS_STATE_LBA         0x04
279#define SCSI_ACCESS_STATE_OFFLINE     0x0e
280#define SCSI_ACCESS_STATE_TRANSITIONING 0x0f
281
282/* Values for REPORT TARGET GROUP STATES */
283#define SCSI_ACCESS_STATE_MASK        0x0f
284#define SCSI_ACCESS_STATE_PREFERRED   0x80
285
286/* Reporting options for REPORT ZONES */
287enum zbc_zone_reporting_options {
288	ZBC_ZONE_REPORTING_OPTION_ALL		= 0x00,
289	ZBC_ZONE_REPORTING_OPTION_EMPTY		= 0x01,
290	ZBC_ZONE_REPORTING_OPTION_IMPLICIT_OPEN	= 0x02,
291	ZBC_ZONE_REPORTING_OPTION_EXPLICIT_OPEN	= 0x03,
292	ZBC_ZONE_REPORTING_OPTION_CLOSED	= 0x04,
293	ZBC_ZONE_REPORTING_OPTION_FULL		= 0x05,
294	ZBC_ZONE_REPORTING_OPTION_READONLY	= 0x06,
295	ZBC_ZONE_REPORTING_OPTION_OFFLINE	= 0x07,
296	/* 0x08 to 0x0f are reserved */
297	ZBC_ZONE_REPORTING_OPTION_NEED_RESET_WP	= 0x10,
298	ZBC_ZONE_REPORTING_OPTION_NON_SEQWRITE	= 0x11,
299	/* 0x12 to 0x3e are reserved */
300	ZBC_ZONE_REPORTING_OPTION_NON_WP	= 0x3f,
301};
302
303#define ZBC_REPORT_ZONE_PARTIAL 0x80
304
305/* Zone types of REPORT ZONES zone descriptors */
306enum zbc_zone_type {
307	ZBC_ZONE_TYPE_CONV		= 0x1,
308	ZBC_ZONE_TYPE_SEQWRITE_REQ	= 0x2,
309	ZBC_ZONE_TYPE_SEQWRITE_PREF	= 0x3,
310	ZBC_ZONE_TYPE_SEQ_OR_BEFORE_REQ	= 0x4,
311	ZBC_ZONE_TYPE_GAP		= 0x5,
312	/* 0x6 to 0xf are reserved */
313};
314
315/* Zone conditions of REPORT ZONES zone descriptors */
316enum zbc_zone_cond {
317	ZBC_ZONE_COND_NO_WP		= 0x0,
318	ZBC_ZONE_COND_EMPTY		= 0x1,
319	ZBC_ZONE_COND_IMP_OPEN		= 0x2,
320	ZBC_ZONE_COND_EXP_OPEN		= 0x3,
321	ZBC_ZONE_COND_CLOSED		= 0x4,
322	/* 0x5 to 0xc are reserved */
323	ZBC_ZONE_COND_READONLY		= 0xd,
324	ZBC_ZONE_COND_FULL		= 0xe,
325	ZBC_ZONE_COND_OFFLINE		= 0xf,
326};
327
328enum zbc_zone_alignment_method {
329	ZBC_CONSTANT_ZONE_LENGTH	= 0x1,
330	ZBC_CONSTANT_ZONE_START_OFFSET	= 0x8,
331};
332
333/* Version descriptor values for INQUIRY */
334enum scsi_version_descriptor {
335	SCSI_VERSION_DESCRIPTOR_FCP4	= 0x0a40,
336	SCSI_VERSION_DESCRIPTOR_ISCSI	= 0x0960,
337	SCSI_VERSION_DESCRIPTOR_SAM5	= 0x00a0,
338	SCSI_VERSION_DESCRIPTOR_SAS3	= 0x0c60,
339	SCSI_VERSION_DESCRIPTOR_SBC3	= 0x04c0,
340	SCSI_VERSION_DESCRIPTOR_SBP3	= 0x0980,
341	SCSI_VERSION_DESCRIPTOR_SPC4	= 0x0460,
342	SCSI_VERSION_DESCRIPTOR_SRP	= 0x0940
343};
344
345enum scsi_support_opcode {
346	SCSI_SUPPORT_NO_INFO		= 0,
347	SCSI_SUPPORT_NOT_SUPPORTED	= 1,
348	SCSI_SUPPORT_FULL		= 3,
349	SCSI_SUPPORT_VENDOR		= 5,
350};
351
352#define SCSI_CONTROL_MASK 0
353#define SCSI_GROUP_NUMBER_MASK 0
354
355#endif /* _SCSI_PROTO_H_ */
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * This header file contains public constants and structures used by
  4 * both the SCSI initiator and the SCSI target code.
  5 *
  6 * For documentation on the OPCODES, MESSAGES, and SENSE values,
  7 * please consult the SCSI standard.
  8 */
  9
 10#ifndef _SCSI_PROTO_H_
 11#define _SCSI_PROTO_H_
 12
 13#include <linux/build_bug.h>
 14#include <linux/types.h>
 15
 16/*
 17 *      SCSI opcodes
 18 */
 19
 20#define TEST_UNIT_READY       0x00
 21#define REZERO_UNIT           0x01
 22#define REQUEST_SENSE         0x03
 23#define FORMAT_UNIT           0x04
 24#define READ_BLOCK_LIMITS     0x05
 25#define REASSIGN_BLOCKS       0x07
 26#define INITIALIZE_ELEMENT_STATUS 0x07
 27#define READ_6                0x08
 28#define WRITE_6               0x0a
 29#define SEEK_6                0x0b
 30#define READ_REVERSE          0x0f
 31#define WRITE_FILEMARKS       0x10
 32#define SPACE                 0x11
 33#define INQUIRY               0x12
 34#define RECOVER_BUFFERED_DATA 0x14
 35#define MODE_SELECT           0x15
 36#define RESERVE               0x16
 37#define RELEASE               0x17
 38#define COPY                  0x18
 39#define ERASE                 0x19
 40#define MODE_SENSE            0x1a
 41#define START_STOP            0x1b
 42#define RECEIVE_DIAGNOSTIC    0x1c
 43#define SEND_DIAGNOSTIC       0x1d
 44#define ALLOW_MEDIUM_REMOVAL  0x1e
 45
 46#define READ_FORMAT_CAPACITIES 0x23
 47#define SET_WINDOW            0x24
 48#define READ_CAPACITY         0x25
 49#define READ_10               0x28
 50#define WRITE_10              0x2a
 51#define SEEK_10               0x2b
 52#define POSITION_TO_ELEMENT   0x2b
 53#define WRITE_VERIFY          0x2e
 54#define VERIFY                0x2f
 55#define SEARCH_HIGH           0x30
 56#define SEARCH_EQUAL          0x31
 57#define SEARCH_LOW            0x32
 58#define SET_LIMITS            0x33
 59#define PRE_FETCH             0x34
 60#define READ_POSITION         0x34
 61#define SYNCHRONIZE_CACHE     0x35
 62#define LOCK_UNLOCK_CACHE     0x36
 63#define READ_DEFECT_DATA      0x37
 64#define MEDIUM_SCAN           0x38
 65#define COMPARE               0x39
 66#define COPY_VERIFY           0x3a
 67#define WRITE_BUFFER          0x3b
 68#define READ_BUFFER           0x3c
 69#define UPDATE_BLOCK          0x3d
 70#define READ_LONG             0x3e
 71#define WRITE_LONG            0x3f
 72#define CHANGE_DEFINITION     0x40
 73#define WRITE_SAME            0x41
 74#define UNMAP		      0x42
 75#define READ_TOC              0x43
 76#define READ_HEADER           0x44
 77#define GET_EVENT_STATUS_NOTIFICATION 0x4a
 78#define LOG_SELECT            0x4c
 79#define LOG_SENSE             0x4d
 80#define XDWRITEREAD_10        0x53
 81#define MODE_SELECT_10        0x55
 82#define RESERVE_10            0x56
 83#define RELEASE_10            0x57
 84#define MODE_SENSE_10         0x5a
 85#define PERSISTENT_RESERVE_IN 0x5e
 86#define PERSISTENT_RESERVE_OUT 0x5f
 87#define VARIABLE_LENGTH_CMD   0x7f
 88#define REPORT_LUNS           0xa0
 89#define SECURITY_PROTOCOL_IN  0xa2
 90#define MAINTENANCE_IN        0xa3
 91#define MAINTENANCE_OUT       0xa4
 92#define MOVE_MEDIUM           0xa5
 93#define EXCHANGE_MEDIUM       0xa6
 94#define READ_12               0xa8
 95#define SERVICE_ACTION_OUT_12 0xa9
 96#define WRITE_12              0xaa
 97#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
 98#define SERVICE_ACTION_IN_12  0xab
 99#define WRITE_VERIFY_12       0xae
100#define VERIFY_12	      0xaf
101#define SEARCH_HIGH_12        0xb0
102#define SEARCH_EQUAL_12       0xb1
103#define SEARCH_LOW_12         0xb2
104#define SECURITY_PROTOCOL_OUT 0xb5
105#define READ_ELEMENT_STATUS   0xb8
106#define SEND_VOLUME_TAG       0xb6
107#define WRITE_LONG_2          0xea
108#define EXTENDED_COPY         0x83
109#define RECEIVE_COPY_RESULTS  0x84
110#define ACCESS_CONTROL_IN     0x86
111#define ACCESS_CONTROL_OUT    0x87
112#define READ_16               0x88
113#define COMPARE_AND_WRITE     0x89
114#define WRITE_16              0x8a
115#define READ_ATTRIBUTE        0x8c
116#define WRITE_ATTRIBUTE	      0x8d
117#define WRITE_VERIFY_16	      0x8e
118#define VERIFY_16	      0x8f
119#define SYNCHRONIZE_CACHE_16  0x91
120#define WRITE_SAME_16	      0x93
121#define ZBC_OUT		      0x94
122#define ZBC_IN		      0x95
123#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
124#define SERVICE_ACTION_IN_16  0x9e
125#define SERVICE_ACTION_OUT_16 0x9f
126/* values for service action in */
127#define	SAI_READ_CAPACITY_16  0x10
128#define SAI_GET_LBA_STATUS    0x12
129#define SAI_REPORT_REFERRALS  0x13
130#define SAI_GET_STREAM_STATUS 0x16
131/* values for maintenance in */
132#define MI_REPORT_IDENTIFYING_INFORMATION 0x05
133#define MI_REPORT_TARGET_PGS  0x0a
134#define MI_REPORT_ALIASES     0x0b
135#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
136#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
137#define MI_REPORT_PRIORITY    0x0e
138#define MI_REPORT_TIMESTAMP   0x0f
139#define MI_MANAGEMENT_PROTOCOL_IN 0x10
140/* value for MI_REPORT_TARGET_PGS ext header */
141#define MI_EXT_HDR_PARAM_FMT  0x20
142/* values for maintenance out */
143#define MO_SET_IDENTIFYING_INFORMATION 0x06
144#define MO_SET_TARGET_PGS     0x0a
145#define MO_CHANGE_ALIASES     0x0b
146#define MO_SET_PRIORITY       0x0e
147#define MO_SET_TIMESTAMP      0x0f
148#define MO_MANAGEMENT_PROTOCOL_OUT 0x10
149/* values for ZBC_IN */
150#define ZI_REPORT_ZONES	      0x00
151/* values for ZBC_OUT */
152#define ZO_CLOSE_ZONE	      0x01
153#define ZO_FINISH_ZONE	      0x02
154#define ZO_OPEN_ZONE	      0x03
155#define ZO_RESET_WRITE_POINTER 0x04
156/* values for PR in service action */
157#define READ_KEYS             0x00
158#define READ_RESERVATION      0x01
159#define REPORT_CAPABILITES    0x02
160#define READ_FULL_STATUS      0x03
161/* values for variable length command */
162#define XDREAD_32	      0x03
163#define XDWRITE_32	      0x04
164#define XPWRITE_32	      0x06
165#define XDWRITEREAD_32	      0x07
166#define READ_32		      0x09
167#define VERIFY_32	      0x0a
168#define WRITE_32	      0x0b
169#define WRITE_VERIFY_32	      0x0c
170#define WRITE_SAME_32	      0x0d
171#define ATA_32		      0x1ff0
172
173/* Values for T10/04-262r7 */
174#define	ATA_16		      0x85	/* 16-byte pass-thru */
175#define	ATA_12		      0xa1	/* 12-byte pass-thru */
176
177/* Vendor specific CDBs start here */
178#define VENDOR_SPECIFIC_CDB 0xc0
179
180/*
181 *	SCSI command lengths
182 */
183
184#define SCSI_MAX_VARLEN_CDB_SIZE 260
185
186/* defined in T10 SCSI Primary Commands-2 (SPC2) */
187struct scsi_varlen_cdb_hdr {
188	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */
189	__u8 control;
190	__u8 misc[5];
191	__u8 additional_cdb_length;         /* total cdb length - 8 */
192	__be16 service_action;
193	/* service specific data follows */
194};
195
196/*
197 *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
198 *  T10/1561-D Revision 4 Draft dated 7th November 2002.
199 */
200enum sam_status {
201	SAM_STAT_GOOD				= 0x00,
202	SAM_STAT_CHECK_CONDITION		= 0x02,
203	SAM_STAT_CONDITION_MET			= 0x04,
204	SAM_STAT_BUSY				= 0x08,
205	SAM_STAT_INTERMEDIATE			= 0x10,
206	SAM_STAT_INTERMEDIATE_CONDITION_MET	= 0x14,
207	SAM_STAT_RESERVATION_CONFLICT		= 0x18,
208	SAM_STAT_COMMAND_TERMINATED		= 0x22,	/* obsolete in SAM-3 */
209	SAM_STAT_TASK_SET_FULL			= 0x28,
210	SAM_STAT_ACA_ACTIVE			= 0x30,
211	SAM_STAT_TASK_ABORTED			= 0x40,
212};
213
214#define STATUS_MASK         0xfe
215
216/*
217 *  SENSE KEYS
218 */
219#define NO_SENSE            0x00
220#define RECOVERED_ERROR     0x01
221#define NOT_READY           0x02
222#define MEDIUM_ERROR        0x03
223#define HARDWARE_ERROR      0x04
224#define ILLEGAL_REQUEST     0x05
225#define UNIT_ATTENTION      0x06
226#define DATA_PROTECT        0x07
227#define BLANK_CHECK         0x08
228#define VENDOR_SPECIFIC     0x09
229#define COPY_ABORTED        0x0a
230#define ABORTED_COMMAND     0x0b
231#define VOLUME_OVERFLOW     0x0d
232#define MISCOMPARE          0x0e
233#define COMPLETED	    0x0f
234
235/*
236 *  DEVICE TYPES
237 *  Please keep them in 0x%02x format for $MODALIAS to work
238 */
239
240#define TYPE_DISK           0x00
241#define TYPE_TAPE           0x01
242#define TYPE_PRINTER        0x02
243#define TYPE_PROCESSOR      0x03    /* HP scanners use this */
244#define TYPE_WORM           0x04    /* Treated as ROM by our system */
245#define TYPE_ROM            0x05
246#define TYPE_SCANNER        0x06
247#define TYPE_MOD            0x07    /* Magneto-optical disk -
248				     * - treated as TYPE_DISK */
249#define TYPE_MEDIUM_CHANGER 0x08
250#define TYPE_COMM           0x09    /* Communications device */
251#define TYPE_RAID           0x0c
252#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
253#define TYPE_RBC	    0x0e
254#define TYPE_OSD            0x11
255#define TYPE_ZBC            0x14
256#define TYPE_WLUN           0x1e    /* well-known logical unit */
257#define TYPE_NO_LUN         0x7f
258
259/* SCSI protocols; these are taken from SPC-3 section 7.5 */
260enum scsi_protocol {
261	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
262	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
263	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */
264	SCSI_PROTOCOL_SBP = 3,	/* firewire */
265	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */
266	SCSI_PROTOCOL_ISCSI = 5,
267	SCSI_PROTOCOL_SAS = 6,
268	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
269	SCSI_PROTOCOL_ATA = 8,
270	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
271};
272
273/*
274 * ScsiLun: 8 byte LUN.
275 */
276struct scsi_lun {
277	__u8 scsi_lun[8];
278};
279
280/* SBC-5 IO advice hints group descriptor */
281struct scsi_io_group_descriptor {
282#if defined(__BIG_ENDIAN)
283	u8 io_advice_hints_mode: 2;
284	u8 reserved1: 3;
285	u8 st_enble: 1;
286	u8 cs_enble: 1;
287	u8 ic_enable: 1;
288#elif defined(__LITTLE_ENDIAN)
289	u8 ic_enable: 1;
290	u8 cs_enble: 1;
291	u8 st_enble: 1;
292	u8 reserved1: 3;
293	u8 io_advice_hints_mode: 2;
294#else
295#error
296#endif
297	u8 reserved2[3];
298	/* Logical block markup descriptor */
299#if defined(__BIG_ENDIAN)
300	u8 acdlu: 1;
301	u8 reserved3: 1;
302	u8 rlbsr: 2;
303	u8 lbm_descriptor_type: 4;
304#elif defined(__LITTLE_ENDIAN)
305	u8 lbm_descriptor_type: 4;
306	u8 rlbsr: 2;
307	u8 reserved3: 1;
308	u8 acdlu: 1;
309#else
310#error
311#endif
312	u8 params[2];
313	u8 reserved4;
314	u8 reserved5[8];
315};
316
317static_assert(sizeof(struct scsi_io_group_descriptor) == 16);
318
319/* SCSI stream status descriptor */
320struct scsi_stream_status {
321#if defined(__BIG_ENDIAN)
322	u8 perm: 1;
323	u8 reserved1: 7;
324#elif defined(__LITTLE_ENDIAN)
325	u8 reserved1: 7;
326	u8 perm: 1;
327#else
328#error
329#endif
330	u8 reserved2;
331	__be16 stream_identifier;
332#if defined(__BIG_ENDIAN)
333	u8 reserved3: 2;
334	u8 rel_lifetime: 6;
335#elif defined(__LITTLE_ENDIAN)
336	u8 rel_lifetime: 6;
337	u8 reserved3: 2;
338#else
339#error
340#endif
341	u8 reserved4[3];
342};
343
344static_assert(sizeof(struct scsi_stream_status) == 8);
345
346/* GET STREAM STATUS parameter data */
347struct scsi_stream_status_header {
348	__be32 len;	/* length in bytes of stream_status[] array. */
349	u16 reserved;
350	__be16 number_of_open_streams;
351	DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
352};
353
354static_assert(sizeof(struct scsi_stream_status_header) == 8);
355
356/* SPC asymmetric access states */
357#define SCSI_ACCESS_STATE_OPTIMAL     0x00
358#define SCSI_ACCESS_STATE_ACTIVE      0x01
359#define SCSI_ACCESS_STATE_STANDBY     0x02
360#define SCSI_ACCESS_STATE_UNAVAILABLE 0x03
361#define SCSI_ACCESS_STATE_LBA         0x04
362#define SCSI_ACCESS_STATE_OFFLINE     0x0e
363#define SCSI_ACCESS_STATE_TRANSITIONING 0x0f
364
365/* Values for REPORT TARGET GROUP STATES */
366#define SCSI_ACCESS_STATE_MASK        0x0f
367#define SCSI_ACCESS_STATE_PREFERRED   0x80
368
369/* Reporting options for REPORT ZONES */
370enum zbc_zone_reporting_options {
371	ZBC_ZONE_REPORTING_OPTION_ALL		= 0x00,
372	ZBC_ZONE_REPORTING_OPTION_EMPTY		= 0x01,
373	ZBC_ZONE_REPORTING_OPTION_IMPLICIT_OPEN	= 0x02,
374	ZBC_ZONE_REPORTING_OPTION_EXPLICIT_OPEN	= 0x03,
375	ZBC_ZONE_REPORTING_OPTION_CLOSED	= 0x04,
376	ZBC_ZONE_REPORTING_OPTION_FULL		= 0x05,
377	ZBC_ZONE_REPORTING_OPTION_READONLY	= 0x06,
378	ZBC_ZONE_REPORTING_OPTION_OFFLINE	= 0x07,
379	/* 0x08 to 0x0f are reserved */
380	ZBC_ZONE_REPORTING_OPTION_NEED_RESET_WP	= 0x10,
381	ZBC_ZONE_REPORTING_OPTION_NON_SEQWRITE	= 0x11,
382	/* 0x12 to 0x3e are reserved */
383	ZBC_ZONE_REPORTING_OPTION_NON_WP	= 0x3f,
384};
385
386#define ZBC_REPORT_ZONE_PARTIAL 0x80
387
388/* Zone types of REPORT ZONES zone descriptors */
389enum zbc_zone_type {
390	ZBC_ZONE_TYPE_CONV		= 0x1,
391	ZBC_ZONE_TYPE_SEQWRITE_REQ	= 0x2,
392	ZBC_ZONE_TYPE_SEQWRITE_PREF	= 0x3,
393	ZBC_ZONE_TYPE_SEQ_OR_BEFORE_REQ	= 0x4,
394	ZBC_ZONE_TYPE_GAP		= 0x5,
395	/* 0x6 to 0xf are reserved */
396};
397
398/* Zone conditions of REPORT ZONES zone descriptors */
399enum zbc_zone_cond {
400	ZBC_ZONE_COND_NO_WP		= 0x0,
401	ZBC_ZONE_COND_EMPTY		= 0x1,
402	ZBC_ZONE_COND_IMP_OPEN		= 0x2,
403	ZBC_ZONE_COND_EXP_OPEN		= 0x3,
404	ZBC_ZONE_COND_CLOSED		= 0x4,
405	/* 0x5 to 0xc are reserved */
406	ZBC_ZONE_COND_READONLY		= 0xd,
407	ZBC_ZONE_COND_FULL		= 0xe,
408	ZBC_ZONE_COND_OFFLINE		= 0xf,
409};
410
411enum zbc_zone_alignment_method {
412	ZBC_CONSTANT_ZONE_LENGTH	= 0x1,
413	ZBC_CONSTANT_ZONE_START_OFFSET	= 0x8,
414};
415
416/* Version descriptor values for INQUIRY */
417enum scsi_version_descriptor {
418	SCSI_VERSION_DESCRIPTOR_FCP4	= 0x0a40,
419	SCSI_VERSION_DESCRIPTOR_ISCSI	= 0x0960,
420	SCSI_VERSION_DESCRIPTOR_SAM5	= 0x00a0,
421	SCSI_VERSION_DESCRIPTOR_SAS3	= 0x0c60,
422	SCSI_VERSION_DESCRIPTOR_SBC3	= 0x04c0,
423	SCSI_VERSION_DESCRIPTOR_SBP3	= 0x0980,
424	SCSI_VERSION_DESCRIPTOR_SPC4	= 0x0460,
425	SCSI_VERSION_DESCRIPTOR_SRP	= 0x0940
426};
427
428enum scsi_support_opcode {
429	SCSI_SUPPORT_NO_INFO		= 0,
430	SCSI_SUPPORT_NOT_SUPPORTED	= 1,
431	SCSI_SUPPORT_FULL		= 3,
432	SCSI_SUPPORT_VENDOR		= 5,
433};
434
435#define SCSI_CONTROL_MASK 0
436#define SCSI_GROUP_NUMBER_MASK 0
437
438#endif /* _SCSI_PROTO_H_ */