xref: /linux/include/scsi/scsi_proto.h (revision 2fe05e1139a555ae91f00a812cb9520e7d3022ab)
1 /*
2  * This header file contains public constants and structures used by
3  * both the SCSI initiator and the SCSI target code.
4  *
5  * For documentation on the OPCODES, MESSAGES, and SENSE values,
6  * please consult the SCSI standard.
7  */
8 
9 #ifndef _SCSI_PROTO_H_
10 #define _SCSI_PROTO_H_
11 
12 #include <linux/types.h>
13 
14 /*
15  *      SCSI opcodes
16  */
17 
18 #define TEST_UNIT_READY       0x00
19 #define REZERO_UNIT           0x01
20 #define REQUEST_SENSE         0x03
21 #define FORMAT_UNIT           0x04
22 #define READ_BLOCK_LIMITS     0x05
23 #define REASSIGN_BLOCKS       0x07
24 #define INITIALIZE_ELEMENT_STATUS 0x07
25 #define READ_6                0x08
26 #define WRITE_6               0x0a
27 #define SEEK_6                0x0b
28 #define READ_REVERSE          0x0f
29 #define WRITE_FILEMARKS       0x10
30 #define SPACE                 0x11
31 #define INQUIRY               0x12
32 #define RECOVER_BUFFERED_DATA 0x14
33 #define MODE_SELECT           0x15
34 #define RESERVE               0x16
35 #define RELEASE               0x17
36 #define COPY                  0x18
37 #define ERASE                 0x19
38 #define MODE_SENSE            0x1a
39 #define START_STOP            0x1b
40 #define RECEIVE_DIAGNOSTIC    0x1c
41 #define SEND_DIAGNOSTIC       0x1d
42 #define ALLOW_MEDIUM_REMOVAL  0x1e
43 
44 #define READ_FORMAT_CAPACITIES 0x23
45 #define SET_WINDOW            0x24
46 #define READ_CAPACITY         0x25
47 #define READ_10               0x28
48 #define WRITE_10              0x2a
49 #define SEEK_10               0x2b
50 #define POSITION_TO_ELEMENT   0x2b
51 #define WRITE_VERIFY          0x2e
52 #define VERIFY                0x2f
53 #define SEARCH_HIGH           0x30
54 #define SEARCH_EQUAL          0x31
55 #define SEARCH_LOW            0x32
56 #define SET_LIMITS            0x33
57 #define PRE_FETCH             0x34
58 #define READ_POSITION         0x34
59 #define SYNCHRONIZE_CACHE     0x35
60 #define LOCK_UNLOCK_CACHE     0x36
61 #define READ_DEFECT_DATA      0x37
62 #define MEDIUM_SCAN           0x38
63 #define COMPARE               0x39
64 #define COPY_VERIFY           0x3a
65 #define WRITE_BUFFER          0x3b
66 #define READ_BUFFER           0x3c
67 #define UPDATE_BLOCK          0x3d
68 #define READ_LONG             0x3e
69 #define WRITE_LONG            0x3f
70 #define CHANGE_DEFINITION     0x40
71 #define WRITE_SAME            0x41
72 #define UNMAP		      0x42
73 #define READ_TOC              0x43
74 #define READ_HEADER           0x44
75 #define GET_EVENT_STATUS_NOTIFICATION 0x4a
76 #define LOG_SELECT            0x4c
77 #define LOG_SENSE             0x4d
78 #define XDWRITEREAD_10        0x53
79 #define MODE_SELECT_10        0x55
80 #define RESERVE_10            0x56
81 #define RELEASE_10            0x57
82 #define MODE_SENSE_10         0x5a
83 #define PERSISTENT_RESERVE_IN 0x5e
84 #define PERSISTENT_RESERVE_OUT 0x5f
85 #define VARIABLE_LENGTH_CMD   0x7f
86 #define REPORT_LUNS           0xa0
87 #define SECURITY_PROTOCOL_IN  0xa2
88 #define MAINTENANCE_IN        0xa3
89 #define MAINTENANCE_OUT       0xa4
90 #define MOVE_MEDIUM           0xa5
91 #define EXCHANGE_MEDIUM       0xa6
92 #define READ_12               0xa8
93 #define SERVICE_ACTION_OUT_12 0xa9
94 #define WRITE_12              0xaa
95 #define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
96 #define SERVICE_ACTION_IN_12  0xab
97 #define WRITE_VERIFY_12       0xae
98 #define VERIFY_12	      0xaf
99 #define SEARCH_HIGH_12        0xb0
100 #define SEARCH_EQUAL_12       0xb1
101 #define SEARCH_LOW_12         0xb2
102 #define SECURITY_PROTOCOL_OUT 0xb5
103 #define READ_ELEMENT_STATUS   0xb8
104 #define SEND_VOLUME_TAG       0xb6
105 #define WRITE_LONG_2          0xea
106 #define EXTENDED_COPY         0x83
107 #define RECEIVE_COPY_RESULTS  0x84
108 #define ACCESS_CONTROL_IN     0x86
109 #define ACCESS_CONTROL_OUT    0x87
110 #define READ_16               0x88
111 #define COMPARE_AND_WRITE     0x89
112 #define WRITE_16              0x8a
113 #define READ_ATTRIBUTE        0x8c
114 #define WRITE_ATTRIBUTE	      0x8d
115 #define WRITE_VERIFY_16	      0x8e
116 #define VERIFY_16	      0x8f
117 #define SYNCHRONIZE_CACHE_16  0x91
118 #define WRITE_SAME_16	      0x93
119 #define ZBC_OUT		      0x94
120 #define ZBC_IN		      0x95
121 #define SERVICE_ACTION_BIDIRECTIONAL 0x9d
122 #define SERVICE_ACTION_IN_16  0x9e
123 #define SERVICE_ACTION_OUT_16 0x9f
124 /* values for service action in */
125 #define	SAI_READ_CAPACITY_16  0x10
126 #define SAI_GET_LBA_STATUS    0x12
127 #define SAI_REPORT_REFERRALS  0x13
128 /* values for maintenance in */
129 #define MI_REPORT_IDENTIFYING_INFORMATION 0x05
130 #define MI_REPORT_TARGET_PGS  0x0a
131 #define MI_REPORT_ALIASES     0x0b
132 #define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
133 #define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
134 #define MI_REPORT_PRIORITY    0x0e
135 #define MI_REPORT_TIMESTAMP   0x0f
136 #define MI_MANAGEMENT_PROTOCOL_IN 0x10
137 /* value for MI_REPORT_TARGET_PGS ext header */
138 #define MI_EXT_HDR_PARAM_FMT  0x20
139 /* values for maintenance out */
140 #define MO_SET_IDENTIFYING_INFORMATION 0x06
141 #define MO_SET_TARGET_PGS     0x0a
142 #define MO_CHANGE_ALIASES     0x0b
143 #define MO_SET_PRIORITY       0x0e
144 #define MO_SET_TIMESTAMP      0x0f
145 #define MO_MANAGEMENT_PROTOCOL_OUT 0x10
146 /* values for ZBC_IN */
147 #define ZI_REPORT_ZONES	      0x00
148 /* values for ZBC_OUT */
149 #define ZO_CLOSE_ZONE	      0x01
150 #define ZO_FINISH_ZONE	      0x02
151 #define ZO_OPEN_ZONE	      0x03
152 #define ZO_RESET_WRITE_POINTER 0x04
153 /* values for variable length command */
154 #define XDREAD_32	      0x03
155 #define XDWRITE_32	      0x04
156 #define XPWRITE_32	      0x06
157 #define XDWRITEREAD_32	      0x07
158 #define READ_32		      0x09
159 #define VERIFY_32	      0x0a
160 #define WRITE_32	      0x0b
161 #define WRITE_VERIFY_32	      0x0c
162 #define WRITE_SAME_32	      0x0d
163 #define ATA_32		      0x1ff0
164 
165 /* Values for T10/04-262r7 */
166 #define	ATA_16		      0x85	/* 16-byte pass-thru */
167 #define	ATA_12		      0xa1	/* 12-byte pass-thru */
168 
169 /* Vendor specific CDBs start here */
170 #define VENDOR_SPECIFIC_CDB 0xc0
171 
172 /*
173  *	SCSI command lengths
174  */
175 
176 #define SCSI_MAX_VARLEN_CDB_SIZE 260
177 
178 /* defined in T10 SCSI Primary Commands-2 (SPC2) */
179 struct scsi_varlen_cdb_hdr {
180 	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */
181 	__u8 control;
182 	__u8 misc[5];
183 	__u8 additional_cdb_length;         /* total cdb length - 8 */
184 	__be16 service_action;
185 	/* service specific data follows */
186 };
187 
188 /*
189  *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
190  *  T10/1561-D Revision 4 Draft dated 7th November 2002.
191  */
192 #define SAM_STAT_GOOD            0x00
193 #define SAM_STAT_CHECK_CONDITION 0x02
194 #define SAM_STAT_CONDITION_MET   0x04
195 #define SAM_STAT_BUSY            0x08
196 #define SAM_STAT_INTERMEDIATE    0x10
197 #define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
198 #define SAM_STAT_RESERVATION_CONFLICT 0x18
199 #define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
200 #define SAM_STAT_TASK_SET_FULL   0x28
201 #define SAM_STAT_ACA_ACTIVE      0x30
202 #define SAM_STAT_TASK_ABORTED    0x40
203 
204 /*
205  *  Status codes. These are deprecated as they are shifted 1 bit right
206  *  from those found in the SCSI standards. This causes confusion for
207  *  applications that are ported to several OSes. Prefer SAM Status codes
208  *  above.
209  */
210 
211 #define GOOD                 0x00
212 #define CHECK_CONDITION      0x01
213 #define CONDITION_GOOD       0x02
214 #define BUSY                 0x04
215 #define INTERMEDIATE_GOOD    0x08
216 #define INTERMEDIATE_C_GOOD  0x0a
217 #define RESERVATION_CONFLICT 0x0c
218 #define COMMAND_TERMINATED   0x11
219 #define QUEUE_FULL           0x14
220 #define ACA_ACTIVE           0x18
221 #define TASK_ABORTED         0x20
222 
223 #define STATUS_MASK          0xfe
224 
225 /*
226  *  SENSE KEYS
227  */
228 
229 #define NO_SENSE            0x00
230 #define RECOVERED_ERROR     0x01
231 #define NOT_READY           0x02
232 #define MEDIUM_ERROR        0x03
233 #define HARDWARE_ERROR      0x04
234 #define ILLEGAL_REQUEST     0x05
235 #define UNIT_ATTENTION      0x06
236 #define DATA_PROTECT        0x07
237 #define BLANK_CHECK         0x08
238 #define COPY_ABORTED        0x0a
239 #define ABORTED_COMMAND     0x0b
240 #define VOLUME_OVERFLOW     0x0d
241 #define MISCOMPARE          0x0e
242 
243 
244 /*
245  *  DEVICE TYPES
246  *  Please keep them in 0x%02x format for $MODALIAS to work
247  */
248 
249 #define TYPE_DISK           0x00
250 #define TYPE_TAPE           0x01
251 #define TYPE_PRINTER        0x02
252 #define TYPE_PROCESSOR      0x03    /* HP scanners use this */
253 #define TYPE_WORM           0x04    /* Treated as ROM by our system */
254 #define TYPE_ROM            0x05
255 #define TYPE_SCANNER        0x06
256 #define TYPE_MOD            0x07    /* Magneto-optical disk -
257 				     * - treated as TYPE_DISK */
258 #define TYPE_MEDIUM_CHANGER 0x08
259 #define TYPE_COMM           0x09    /* Communications device */
260 #define TYPE_RAID           0x0c
261 #define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
262 #define TYPE_RBC	    0x0e
263 #define TYPE_OSD            0x11
264 #define TYPE_ZBC            0x14
265 #define TYPE_WLUN           0x1e    /* well-known logical unit */
266 #define TYPE_NO_LUN         0x7f
267 
268 /* SCSI protocols; these are taken from SPC-3 section 7.5 */
269 enum scsi_protocol {
270 	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
271 	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
272 	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */
273 	SCSI_PROTOCOL_SBP = 3,	/* firewire */
274 	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */
275 	SCSI_PROTOCOL_ISCSI = 5,
276 	SCSI_PROTOCOL_SAS = 6,
277 	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
278 	SCSI_PROTOCOL_ATA = 8,
279 	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
280 };
281 
282 /*
283  * ScsiLun: 8 byte LUN.
284  */
285 struct scsi_lun {
286 	__u8 scsi_lun[8];
287 };
288 
289 /* SPC asymmetric access states */
290 #define SCSI_ACCESS_STATE_OPTIMAL     0x00
291 #define SCSI_ACCESS_STATE_ACTIVE      0x01
292 #define SCSI_ACCESS_STATE_STANDBY     0x02
293 #define SCSI_ACCESS_STATE_UNAVAILABLE 0x03
294 #define SCSI_ACCESS_STATE_LBA         0x04
295 #define SCSI_ACCESS_STATE_OFFLINE     0x0e
296 #define SCSI_ACCESS_STATE_TRANSITIONING 0x0f
297 
298 /* Values for REPORT TARGET GROUP STATES */
299 #define SCSI_ACCESS_STATE_MASK        0x0f
300 #define SCSI_ACCESS_STATE_PREFERRED   0x80
301 
302 /* Reporting options for REPORT ZONES */
303 enum zbc_zone_reporting_options {
304 	ZBC_ZONE_REPORTING_OPTION_ALL = 0,
305 	ZBC_ZONE_REPORTING_OPTION_EMPTY,
306 	ZBC_ZONE_REPORTING_OPTION_IMPLICIT_OPEN,
307 	ZBC_ZONE_REPORTING_OPTION_EXPLICIT_OPEN,
308 	ZBC_ZONE_REPORTING_OPTION_CLOSED,
309 	ZBC_ZONE_REPORTING_OPTION_FULL,
310 	ZBC_ZONE_REPORTING_OPTION_READONLY,
311 	ZBC_ZONE_REPORTING_OPTION_OFFLINE,
312 	ZBC_ZONE_REPORTING_OPTION_NEED_RESET_WP = 0x10,
313 	ZBC_ZONE_REPORTING_OPTION_NON_SEQWRITE,
314 	ZBC_ZONE_REPORTING_OPTION_NON_WP = 0x3f,
315 };
316 
317 #define ZBC_REPORT_ZONE_PARTIAL 0x80
318 
319 #endif /* _SCSI_PROTO_H_ */
320