scsi_proto.h 9.5 KB

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