scsi_proto.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 SERVICE_ACTION_BIDIRECTIONAL 0x9d
  114. #define SERVICE_ACTION_IN_16 0x9e
  115. #define SERVICE_ACTION_OUT_16 0x9f
  116. /* values for service action in */
  117. #define SAI_READ_CAPACITY_16 0x10
  118. #define SAI_GET_LBA_STATUS 0x12
  119. #define SAI_REPORT_REFERRALS 0x13
  120. /* values for VARIABLE_LENGTH_CMD service action codes
  121. * see spc4r17 Section D.3.5, table D.7 and D.8 */
  122. #define VLC_SA_RECEIVE_CREDENTIAL 0x1800
  123. /* values for maintenance in */
  124. #define MI_REPORT_IDENTIFYING_INFORMATION 0x05
  125. #define MI_REPORT_TARGET_PGS 0x0a
  126. #define MI_REPORT_ALIASES 0x0b
  127. #define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
  128. #define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
  129. #define MI_REPORT_PRIORITY 0x0e
  130. #define MI_REPORT_TIMESTAMP 0x0f
  131. #define MI_MANAGEMENT_PROTOCOL_IN 0x10
  132. /* value for MI_REPORT_TARGET_PGS ext header */
  133. #define MI_EXT_HDR_PARAM_FMT 0x20
  134. /* values for maintenance out */
  135. #define MO_SET_IDENTIFYING_INFORMATION 0x06
  136. #define MO_SET_TARGET_PGS 0x0a
  137. #define MO_CHANGE_ALIASES 0x0b
  138. #define MO_SET_PRIORITY 0x0e
  139. #define MO_SET_TIMESTAMP 0x0f
  140. #define MO_MANAGEMENT_PROTOCOL_OUT 0x10
  141. /* values for variable length command */
  142. #define XDREAD_32 0x03
  143. #define XDWRITE_32 0x04
  144. #define XPWRITE_32 0x06
  145. #define XDWRITEREAD_32 0x07
  146. #define READ_32 0x09
  147. #define VERIFY_32 0x0a
  148. #define WRITE_32 0x0b
  149. #define WRITE_SAME_32 0x0d
  150. /* Values for T10/04-262r7 */
  151. #define ATA_16 0x85 /* 16-byte pass-thru */
  152. #define ATA_12 0xa1 /* 12-byte pass-thru */
  153. /* Vendor specific CDBs start here */
  154. #define VENDOR_SPECIFIC_CDB 0xc0
  155. /*
  156. * SCSI command lengths
  157. */
  158. #define SCSI_MAX_VARLEN_CDB_SIZE 260
  159. /* defined in T10 SCSI Primary Commands-2 (SPC2) */
  160. struct scsi_varlen_cdb_hdr {
  161. __u8 opcode; /* opcode always == VARIABLE_LENGTH_CMD */
  162. __u8 control;
  163. __u8 misc[5];
  164. __u8 additional_cdb_length; /* total cdb length - 8 */
  165. __be16 service_action;
  166. /* service specific data follows */
  167. };
  168. /*
  169. * SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
  170. * T10/1561-D Revision 4 Draft dated 7th November 2002.
  171. */
  172. #define SAM_STAT_GOOD 0x00
  173. #define SAM_STAT_CHECK_CONDITION 0x02
  174. #define SAM_STAT_CONDITION_MET 0x04
  175. #define SAM_STAT_BUSY 0x08
  176. #define SAM_STAT_INTERMEDIATE 0x10
  177. #define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
  178. #define SAM_STAT_RESERVATION_CONFLICT 0x18
  179. #define SAM_STAT_COMMAND_TERMINATED 0x22 /* obsolete in SAM-3 */
  180. #define SAM_STAT_TASK_SET_FULL 0x28
  181. #define SAM_STAT_ACA_ACTIVE 0x30
  182. #define SAM_STAT_TASK_ABORTED 0x40
  183. /*
  184. * Status codes. These are deprecated as they are shifted 1 bit right
  185. * from those found in the SCSI standards. This causes confusion for
  186. * applications that are ported to several OSes. Prefer SAM Status codes
  187. * above.
  188. */
  189. #define GOOD 0x00
  190. #define CHECK_CONDITION 0x01
  191. #define CONDITION_GOOD 0x02
  192. #define BUSY 0x04
  193. #define INTERMEDIATE_GOOD 0x08
  194. #define INTERMEDIATE_C_GOOD 0x0a
  195. #define RESERVATION_CONFLICT 0x0c
  196. #define COMMAND_TERMINATED 0x11
  197. #define QUEUE_FULL 0x14
  198. #define ACA_ACTIVE 0x18
  199. #define TASK_ABORTED 0x20
  200. #define STATUS_MASK 0xfe
  201. /*
  202. * SENSE KEYS
  203. */
  204. #define NO_SENSE 0x00
  205. #define RECOVERED_ERROR 0x01
  206. #define NOT_READY 0x02
  207. #define MEDIUM_ERROR 0x03
  208. #define HARDWARE_ERROR 0x04
  209. #define ILLEGAL_REQUEST 0x05
  210. #define UNIT_ATTENTION 0x06
  211. #define DATA_PROTECT 0x07
  212. #define BLANK_CHECK 0x08
  213. #define COPY_ABORTED 0x0a
  214. #define ABORTED_COMMAND 0x0b
  215. #define VOLUME_OVERFLOW 0x0d
  216. #define MISCOMPARE 0x0e
  217. /*
  218. * DEVICE TYPES
  219. * Please keep them in 0x%02x format for $MODALIAS to work
  220. */
  221. #define TYPE_DISK 0x00
  222. #define TYPE_TAPE 0x01
  223. #define TYPE_PRINTER 0x02
  224. #define TYPE_PROCESSOR 0x03 /* HP scanners use this */
  225. #define TYPE_WORM 0x04 /* Treated as ROM by our system */
  226. #define TYPE_ROM 0x05
  227. #define TYPE_SCANNER 0x06
  228. #define TYPE_MOD 0x07 /* Magneto-optical disk -
  229. * - treated as TYPE_DISK */
  230. #define TYPE_MEDIUM_CHANGER 0x08
  231. #define TYPE_COMM 0x09 /* Communications device */
  232. #define TYPE_RAID 0x0c
  233. #define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */
  234. #define TYPE_RBC 0x0e
  235. #define TYPE_OSD 0x11
  236. #define TYPE_ZBC 0x14
  237. #define TYPE_WLUN 0x1e /* well-known logical unit */
  238. #define TYPE_NO_LUN 0x7f
  239. /* SCSI protocols; these are taken from SPC-3 section 7.5 */
  240. enum scsi_protocol {
  241. SCSI_PROTOCOL_FCP = 0, /* Fibre Channel */
  242. SCSI_PROTOCOL_SPI = 1, /* parallel SCSI */
  243. SCSI_PROTOCOL_SSA = 2, /* Serial Storage Architecture - Obsolete */
  244. SCSI_PROTOCOL_SBP = 3, /* firewire */
  245. SCSI_PROTOCOL_SRP = 4, /* Infiniband RDMA */
  246. SCSI_PROTOCOL_ISCSI = 5,
  247. SCSI_PROTOCOL_SAS = 6,
  248. SCSI_PROTOCOL_ADT = 7, /* Media Changers */
  249. SCSI_PROTOCOL_ATA = 8,
  250. SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
  251. };
  252. /*
  253. * ScsiLun: 8 byte LUN.
  254. */
  255. struct scsi_lun {
  256. __u8 scsi_lun[8];
  257. };
  258. #endif /* _SCSI_PROTO_H_ */