scsi_all.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /* $OpenBSD: scsi_all.h,v 1.55 2015/06/07 19:13:27 krw Exp $ */
  2. /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */
  3. /*
  4. * SCSI general interface description
  5. */
  6. /*
  7. * Largely written by Julian Elischer (julian@tfs.com)
  8. * for TRW Financial Systems.
  9. *
  10. * TRW Financial Systems, in accordance with their agreement with Carnegie
  11. * Mellon University, makes this software available to CMU to distribute
  12. * or use in any manner that they see fit as long as this message is kept with
  13. * the software. For this reason TFS also grants any other persons or
  14. * organisations permission to use or modify this software.
  15. *
  16. * TFS supplies this software to be publicly redistributed
  17. * on the understanding that TFS is not responsible for the correct
  18. * functioning of this software in any circumstances.
  19. *
  20. * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  21. */
  22. #ifndef _SCSI_SCSI_ALL_H
  23. #define _SCSI_SCSI_ALL_H 1
  24. /*
  25. * SCSI command format
  26. */
  27. /*
  28. * Define some bits that are in ALL (or a lot of) scsi commands
  29. */
  30. #define SCSI_CTL_LINK 0x01
  31. #define SCSI_CTL_FLAG 0x02
  32. #define SCSI_CTL_VENDOR 0xC0
  33. /*
  34. * Some old SCSI devices need the LUN to be set in the top 3 bits of the
  35. * second byte of the CDB.
  36. */
  37. #define SCSI_CMD_LUN_MASK 0xe0
  38. #define SCSI_CMD_LUN_SHIFT 5
  39. struct scsi_generic {
  40. u_int8_t opcode;
  41. u_int8_t bytes[15];
  42. };
  43. struct scsi_test_unit_ready {
  44. u_int8_t opcode;
  45. u_int8_t byte2;
  46. u_int8_t unused[3];
  47. u_int8_t control;
  48. };
  49. struct scsi_send_diag {
  50. u_int8_t opcode;
  51. u_int8_t byte2;
  52. #define SSD_UOL 0x01
  53. #define SSD_DOL 0x02
  54. #define SSD_SELFTEST 0x04
  55. #define SSD_PF 0x10
  56. u_int8_t unused[1];
  57. u_int8_t paramlen[2];
  58. u_int8_t control;
  59. };
  60. struct scsi_sense {
  61. u_int8_t opcode;
  62. u_int8_t byte2;
  63. u_int8_t unused[2];
  64. u_int8_t length;
  65. u_int8_t control;
  66. };
  67. struct scsi_inquiry {
  68. u_int8_t opcode;
  69. u_int8_t flags;
  70. #define SI_EVPD 0x01
  71. u_int8_t pagecode;
  72. #define SI_PG_SUPPORTED 0x00
  73. #define SI_PG_SERIAL 0x80
  74. #define SI_PG_DEVID 0x83
  75. #define SI_PG_ATA 0x89
  76. u_int8_t length[2];
  77. u_int8_t control;
  78. };
  79. struct scsi_mode_sense {
  80. u_int8_t opcode;
  81. u_int8_t byte2;
  82. #define SMS_DBD 0x08 /* Disable Block Descriptors */
  83. u_int8_t page;
  84. #define SMS_PAGE_CODE 0x3F
  85. #define SMS_PAGE_CTRL 0xC0
  86. #define SMS_PAGE_CTRL_CURRENT 0x00
  87. #define SMS_PAGE_CTRL_CHANGEABLE 0x40
  88. #define SMS_PAGE_CTRL_DEFAULT 0x80
  89. #define SMS_PAGE_CTRL_SAVED 0xC0
  90. u_int8_t unused;
  91. u_int8_t length;
  92. u_int8_t control;
  93. };
  94. struct scsi_mode_sense_big {
  95. u_int8_t opcode;
  96. u_int8_t byte2; /* same bits as small version */
  97. #define SMS_LLBAA 0x10 /* plus: Long LBA Accepted */
  98. u_int8_t page; /* same bits as small version */
  99. u_int8_t unused[4];
  100. u_int8_t length[2];
  101. u_int8_t control;
  102. };
  103. struct scsi_mode_select {
  104. u_int8_t opcode;
  105. u_int8_t byte2;
  106. #define SMS_SP 0x01
  107. #define SMS_PF 0x10
  108. u_int8_t unused[2];
  109. u_int8_t length;
  110. u_int8_t control;
  111. };
  112. struct scsi_mode_select_big {
  113. u_int8_t opcode;
  114. u_int8_t byte2; /* same bits as small version */
  115. u_int8_t unused[5];
  116. u_int8_t length[2];
  117. u_int8_t control;
  118. };
  119. struct scsi_reserve {
  120. u_int8_t opcode;
  121. u_int8_t byte2;
  122. u_int8_t unused[2];
  123. u_int8_t length;
  124. u_int8_t control;
  125. };
  126. struct scsi_release {
  127. u_int8_t opcode;
  128. u_int8_t byte2;
  129. u_int8_t unused[2];
  130. u_int8_t length;
  131. u_int8_t control;
  132. };
  133. struct scsi_prevent {
  134. u_int8_t opcode;
  135. u_int8_t byte2;
  136. u_int8_t unused[2];
  137. u_int8_t how;
  138. u_int8_t control;
  139. };
  140. #define PR_PREVENT 0x01
  141. #define PR_ALLOW 0x00
  142. struct scsi_report_luns {
  143. u_int8_t opcode;
  144. u_int8_t unused;
  145. u_int8_t selectreport;
  146. #define REPORT_NORMAL 0x00
  147. #define REPORT_WELLKNOWN 0x01
  148. #define REPORT_ALL 0x02
  149. u_int8_t unused2[3];
  150. u_int8_t length[4];
  151. u_int8_t unused4;
  152. u_int8_t control;
  153. };
  154. /*
  155. * Opcodes
  156. */
  157. #define TEST_UNIT_READY 0x00
  158. #define REQUEST_SENSE 0x03
  159. #define INQUIRY 0x12
  160. #define MODE_SELECT 0x15
  161. #define RESERVE 0x16
  162. #define RELEASE 0x17
  163. #define MODE_SENSE 0x1a
  164. #define START_STOP 0x1b
  165. #define RECEIVE_DIAGNOSTIC 0x1c
  166. #define SEND_DIAGNOSTIC 0x1d
  167. #define PREVENT_ALLOW 0x1e
  168. #define POSITION_TO_ELEMENT 0x2b
  169. #define WRITE_BUFFER 0x3b
  170. #define READ_BUFFER 0x3c
  171. #define CHANGE_DEFINITION 0x40
  172. #define MODE_SELECT_BIG 0x55
  173. #define MODE_SENSE_BIG 0x5a
  174. #define REPORT_LUNS 0xa0
  175. /*
  176. * Sort of an extra one, for SCSI_RESET.
  177. */
  178. #define GENRETRY 1
  179. /*
  180. * sense data format
  181. */
  182. #define T_DIRECT 0
  183. #define T_SEQUENTIAL 1
  184. #define T_PRINTER 2
  185. #define T_PROCESSOR 3
  186. #define T_WORM 4
  187. #define T_CDROM 5
  188. #define T_SCANNER 6
  189. #define T_OPTICAL 7
  190. #define T_RDIRECT 14
  191. #define T_NODEVICE 0x1F
  192. #define T_CHANGER 8
  193. #define T_COMM 9
  194. #define T_ENCLOSURE 13
  195. #define T_REMOV 1
  196. #define T_FIXED 0
  197. struct scsi_inquiry_data {
  198. u_int8_t device;
  199. #define SID_TYPE 0x1F
  200. #define SID_QUAL 0xE0
  201. #define SID_QUAL_LU_OK 0x00
  202. #define SID_QUAL_LU_OFFLINE 0x20
  203. #define SID_QUAL_RSVD 0x40
  204. #define SID_QUAL_BAD_LU 0x60
  205. u_int8_t dev_qual2;
  206. #define SID_QUAL2 0x7F
  207. #define SID_REMOVABLE 0x80
  208. u_int8_t version;
  209. #define SID_ANSII 0x07
  210. #define SID_ECMA 0x38
  211. #define SID_ISO 0xC0
  212. u_int8_t response_format;
  213. u_int8_t additional_length;
  214. #define SID_INQUIRY_HDR 5 /* Bytes up to & including additional_length */
  215. #define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */
  216. u_int8_t unused[2];
  217. u_int8_t flags;
  218. #define SID_SftRe 0x01
  219. #define SID_CmdQue 0x02
  220. #define SID_Linked 0x08
  221. #define SID_Sync 0x10
  222. #define SID_WBus16 0x20
  223. #define SID_WBus32 0x40
  224. #define SID_RelAdr 0x80
  225. char vendor[8];
  226. char product[16];
  227. char revision[4];
  228. u_int8_t extra[20];
  229. u_int8_t flags2;
  230. #define SID_IUS 0x01
  231. #define SID_QAS 0x02
  232. #define SID_CLOCKING 0x0c /* 0 == ST only, 1 == DT only, 3 == both */
  233. u_int8_t reserved;
  234. };
  235. struct scsi_vpd_hdr {
  236. u_int8_t device;
  237. u_int8_t page_code;
  238. u_int8_t page_length[2];
  239. };
  240. struct scsi_vpd_serial {
  241. struct scsi_vpd_hdr hdr;
  242. char serial[32];
  243. };
  244. #define VPD_PROTO_ID_FC 0x0 /* Fibre Channel */
  245. #define VPD_PROTO_ID_SPI 0x1 /* Parallel SCSI */
  246. #define VPD_PROTO_ID_SSA 0x2
  247. #define VPD_PROTO_ID_IEEE1394 0x3
  248. #define VPD_PROTO_ID_SRP 0x4 /* SCSI RDMA Protocol */
  249. #define VPD_PROTO_ID_ISCSI 0x5 /* Internet SCSI (iSCSI) */
  250. #define VPD_PROTO_ID_SAS 0x6 /* Serial Attached SCSI */
  251. #define VPD_PROTO_ID_ADT 0x7 /* Automation/Drive Interface Transport */
  252. #define VPD_PROTO_ID_ATA 0x7 /* ATA/ATAPI */
  253. #define VPD_PROTO_ID_NONE 0xf
  254. struct scsi_vpd_devid_hdr {
  255. u_int8_t pi_code;
  256. #define VPD_DEVID_PI(_f) (((_f) >> 4) & 0x0f)
  257. #define VPD_DEVID_CODE(_f) (((_f) >> 0) & 0x0f)
  258. #define VPD_DEVID_CODE_BINARY 0x1
  259. #define VPD_DEVID_CODE_ASCII 0x2
  260. #define VPD_DEVID_CODE_UTF8 0x3
  261. u_int8_t flags;
  262. #define VPD_DEVID_PIV 0x80
  263. #define VPD_DEVID_ASSOC(_f) ((_f) & 0x30)
  264. #define VPD_DEVID_ASSOC_LU 0x00
  265. #define VPD_DEVID_ASSOC_PORT 0x10
  266. #define VPD_DEVID_ASSOC_TARG 0x20
  267. #define VPD_DEVID_TYPE(_f) ((_f) & 0x0f)
  268. #define VPD_DEVID_TYPE_VENDOR 0x0
  269. #define VPD_DEVID_TYPE_T10 0x1
  270. #define VPD_DEVID_TYPE_EUI64 0x2
  271. #define VPD_DEVID_TYPE_NAA 0x3
  272. #define VPD_DEVID_TYPE_RELATIVE 0x4
  273. #define VPD_DEVID_TYPE_PORT 0x5
  274. #define VPD_DEVID_TYPE_LU 0x6
  275. #define VPD_DEVID_TYPE_MD5 0x7
  276. #define VPD_DEVID_TYPE_NAME 0x8
  277. u_int8_t reserved;
  278. u_int8_t len;
  279. };
  280. struct scsi_vpd_ata {
  281. struct scsi_vpd_hdr hdr;
  282. u_int8_t _reserved1[4];
  283. u_int8_t sat_vendor[8];
  284. u_int8_t sat_product[16];
  285. u_int8_t sat_revision[4];
  286. u_int8_t device_signature[20];
  287. u_int8_t command_code;
  288. #define VPD_ATA_COMMAND_CODE_ATA 0xec
  289. #define VPD_ATA_COMMAND_CODE_ATAPI 0xa1
  290. u_int8_t _reserved2[3];
  291. u_int8_t identify[512];
  292. };
  293. struct scsi_sense_data_unextended {
  294. /* 1*/ u_int8_t error_code;
  295. /* 4*/ u_int8_t block[3];
  296. };
  297. struct scsi_sense_data {
  298. /* 1*/ u_int8_t error_code;
  299. #define SSD_ERRCODE_CURRENT 0x70
  300. #define SSD_ERRCODE_DEFERRED 0x71
  301. #define SSD_ERRCODE 0x7F
  302. #define SSD_ERRCODE_VALID 0x80
  303. /* 2*/ u_int8_t segment;
  304. /* 3*/ u_int8_t flags;
  305. #define SSD_KEY 0x0F
  306. #define SSD_ILI 0x20
  307. #define SSD_EOM 0x40
  308. #define SSD_FILEMARK 0x80
  309. /* 7*/ u_int8_t info[4];
  310. /* 8*/ u_int8_t extra_len;
  311. /*12*/ u_int8_t cmd_spec_info[4];
  312. /*13*/ u_int8_t add_sense_code;
  313. /*14*/ u_int8_t add_sense_code_qual;
  314. /*15*/ u_int8_t fru;
  315. /*16*/ u_int8_t sense_key_spec_1;
  316. #define SSD_SCS_VALID 0x80
  317. #define SSD_SCS_CDB_ERROR 0x40
  318. #define SSD_SCS_SEGMENT_DESC 0x20
  319. #define SSD_SCS_VALID_BIT_INDEX 0x08
  320. #define SSD_SCS_BIT_INDEX 0x07
  321. /*17*/ u_int8_t sense_key_spec_2;
  322. /*18*/ u_int8_t sense_key_spec_3;
  323. };
  324. #define SKEY_NO_SENSE 0x00
  325. #define SKEY_RECOVERED_ERROR 0x01
  326. #define SKEY_NOT_READY 0x02
  327. #define SKEY_MEDIUM_ERROR 0x03
  328. #define SKEY_HARDWARE_ERROR 0x04
  329. #define SKEY_ILLEGAL_REQUEST 0x05
  330. #define SKEY_UNIT_ATTENTION 0x06
  331. #define SKEY_WRITE_PROTECT 0x07
  332. #define SKEY_BLANK_CHECK 0x08
  333. #define SKEY_VENDOR_UNIQUE 0x09
  334. #define SKEY_COPY_ABORTED 0x0A
  335. #define SKEY_ABORTED_COMMAND 0x0B
  336. #define SKEY_EQUAL 0x0C
  337. #define SKEY_VOLUME_OVERFLOW 0x0D
  338. #define SKEY_MISCOMPARE 0x0E
  339. #define SKEY_RESERVED 0x0F
  340. /* Additional sense code info */
  341. #define ASC_ASCQ(ssd) ((ssd->add_sense_code << 8) | ssd->add_sense_code_qual)
  342. #define SENSE_FILEMARK_DETECTED 0x0001
  343. #define SENSE_END_OF_MEDIUM_DETECTED 0x0002
  344. #define SENSE_SETMARK_DETECTED 0x0003
  345. #define SENSE_BEGINNING_OF_MEDIUM_DETECTED 0x0004
  346. #define SENSE_END_OF_DATA_DETECTED 0x0005
  347. #define SENSE_NOT_READY_BECOMING_READY 0x0401
  348. #define SENSE_NOT_READY_INIT_REQUIRED 0x0402
  349. #define SENSE_NOT_READY_FORMAT 0x0404
  350. #define SENSE_NOT_READY_REBUILD 0x0405
  351. #define SENSE_NOT_READY_RECALC 0x0406
  352. #define SENSE_NOT_READY_INPROGRESS 0x0407
  353. #define SENSE_NOT_READY_LONGWRITE 0x0408
  354. #define SENSE_NOT_READY_SELFTEST 0x0409
  355. #define SENSE_POWER_RESET_OR_BUS 0x2900
  356. #define SENSE_POWER_ON 0x2901
  357. #define SENSE_BUS_RESET 0x2902
  358. #define SENSE_BUS_DEVICE_RESET 0x2903
  359. #define SENSE_DEVICE_INTERNAL_RESET 0x2904
  360. #define SENSE_TSC_CHANGE_SE 0x2905
  361. #define SENSE_TSC_CHANGE_LVD 0x2906
  362. #define SENSE_IT_NEXUS_LOSS 0x2907
  363. #define SENSE_BAD_MEDIUM 0x3000
  364. #define SENSE_NR_MEDIUM_UNKNOWN_FORMAT 0x3001
  365. #define SENSE_NR_MEDIUM_INCOMPATIBLE_FORMAT 0x3002
  366. #define SENSE_NW_MEDIUM_UNKNOWN_FORMAT 0x3004
  367. #define SENSE_NW_MEDIUM_INCOMPATIBLE_FORMAT 0x3005
  368. #define SENSE_NF_MEDIUM_INCOMPATIBLE_FORMAT 0x3006
  369. #define SENSE_NW_MEDIUM_AC_MISMATCH 0x3008
  370. #define SENSE_NOMEDIUM 0x3A00
  371. #define SENSE_NOMEDIUM_TCLOSED 0x3A01
  372. #define SENSE_NOMEDIUM_TOPEN 0x3A02
  373. #define SENSE_NOMEDIUM_LOADABLE 0x3A03
  374. #define SENSE_NOMEDIUM_AUXMEM 0x3A04
  375. #define SENSE_CARTRIDGE_FAULT 0x5200
  376. #define SENSE_MEDIUM_REMOVAL_PREVENTED 0x5302
  377. struct scsi_blk_desc {
  378. u_int8_t density;
  379. u_int8_t nblocks[3];
  380. u_int8_t reserved;
  381. u_int8_t blklen[3];
  382. };
  383. struct scsi_direct_blk_desc {
  384. u_int8_t nblocks[4];
  385. u_int8_t density;
  386. u_int8_t blklen[3];
  387. };
  388. struct scsi_blk_desc_big {
  389. u_int8_t nblocks[8];
  390. u_int8_t density;
  391. u_int8_t reserved[3];
  392. u_int8_t blklen[4];
  393. };
  394. struct scsi_mode_header {
  395. u_int8_t data_length; /* Sense data length */
  396. u_int8_t medium_type;
  397. u_int8_t dev_spec;
  398. u_int8_t blk_desc_len;
  399. };
  400. struct scsi_mode_header_big {
  401. u_int8_t data_length[2]; /* Sense data length */
  402. u_int8_t medium_type;
  403. u_int8_t dev_spec;
  404. u_int8_t reserved;
  405. #define LONGLBA 0x01
  406. u_int8_t reserved2;
  407. u_int8_t blk_desc_len[2];
  408. };
  409. /* Both disks and tapes use dev_spec to report READONLY status. */
  410. #define SMH_DSP_WRITE_PROT 0x80
  411. union scsi_mode_sense_buf {
  412. struct scsi_mode_header hdr;
  413. struct scsi_mode_header_big hdr_big;
  414. u_char buf[254]; /* 255 & 256 bytes breaks some devices. */
  415. /* ahci doesn't like 255, various don't like */
  416. /* 256 because length must fit in 8 bits. */
  417. } __packed; /* Ensure sizeof() is 254! */
  418. struct scsi_report_luns_data {
  419. u_int8_t length[4]; /* length of LUN inventory, in bytes */
  420. u_int8_t reserved[4]; /* unused */
  421. /*
  422. * LUN inventory- we only support the type zero form for now.
  423. */
  424. #define RPL_LUNDATA_SIZE 8 /* Bytes per lun */
  425. struct {
  426. u_int8_t lundata[RPL_LUNDATA_SIZE];
  427. } luns[256]; /* scsi_link->luns is u_int8_t. */
  428. };
  429. #define RPL_LUNDATA_T0LUN 1 /* Type 0 LUN is in lundata[1] */
  430. /*
  431. * ATA PASS-THROUGH as per SAT2
  432. */
  433. #define ATA_PASSTHRU_12 0xa1
  434. #define ATA_PASSTHRU_16 0x85
  435. #define ATA_PASSTHRU_PROTO_MASK 0x1e
  436. #define ATA_PASSTHRU_PROTO_HW_RESET 0x00
  437. #define ATA_PASSTHRU_PROTO_SW_RESET 0x02
  438. #define ATA_PASSTHRU_PROTO_NON_DATA 0x06
  439. #define ATA_PASSTHRU_PROTO_PIO_DATAIN 0x08
  440. #define ATA_PASSTHRU_PROTO_PIO_DATAOUT 0x0a
  441. #define ATA_PASSTHRU_PROTO_DMA 0x0c
  442. #define ATA_PASSTHRU_PROTO_DMA_QUEUED 0x0e
  443. #define ATA_PASSTHRU_PROTO_EXEC_DIAG 0x10
  444. #define ATA_PASSTHRU_PROTO_NON_DATA_RST 0x12
  445. #define ATA_PASSTHRU_PROTO_UDMA_DATAIN 0x14
  446. #define ATA_PASSTHRU_PROTO_UDMA_DATAOUT 0x16
  447. #define ATA_PASSTHRU_PROTO_FPDMA 0x18
  448. #define ATA_PASSTHRU_PROTO_RESPONSE 0x1e
  449. #define ATA_PASSTHRU_T_DIR_MASK 0x08
  450. #define ATA_PASSTHRU_T_DIR_READ 0x08
  451. #define ATA_PASSTHRU_T_DIR_WRITE 0x00
  452. #define ATA_PASSTHRU_T_LEN_MASK 0x03
  453. #define ATA_PASSTHRU_T_LEN_NONE 0x00
  454. #define ATA_PASSTHRU_T_LEN_FEATURES 0x01
  455. #define ATA_PASSTHRU_T_LEN_SECTOR_COUNT 0x02
  456. #define ATA_PASSTHRU_T_LEN_TPSIU 0x03
  457. struct scsi_ata_passthru_12 {
  458. u_int8_t opcode;
  459. u_int8_t count_proto;
  460. u_int8_t flags;
  461. u_int8_t features;
  462. u_int8_t sector_count;
  463. u_int8_t lba_low;
  464. u_int8_t lba_mid;
  465. u_int8_t lba_high;
  466. u_int8_t device;
  467. u_int8_t command;
  468. u_int8_t _reserved;
  469. u_int8_t control;
  470. };
  471. struct scsi_ata_passthru_16 {
  472. u_int8_t opcode;
  473. u_int8_t count_proto;
  474. u_int8_t flags;
  475. u_int8_t features[2];
  476. u_int8_t sector_count[2];
  477. u_int8_t lba_low[2];
  478. u_int8_t lba_mid[2];
  479. u_int8_t lba_high[2];
  480. u_int8_t device;
  481. u_int8_t command;
  482. u_int8_t control;
  483. };
  484. /*
  485. * SPI status information unit. See section 14.3.5 of SPI-3.
  486. */
  487. struct scsi_status_iu_header {
  488. /* 2*/ u_int8_t reserved[2];
  489. /* 3*/ u_int8_t flags;
  490. #define SIU_SNSVALID 0x2
  491. #define SIU_RSPVALID 0x1
  492. /* 4*/ u_int8_t status;
  493. /* 8*/ u_int8_t sense_length[4];
  494. /*12*/ u_int8_t pkt_failures_length[4];
  495. u_int8_t data[1]; /* <pkt failure list><sense data> OR <sense_data> */
  496. };
  497. #define SIU_PKTFAIL_CODE(siu) ((siu)->data[3])
  498. #define SIU_PFC_NONE 0x00
  499. #define SIU_PFC_CIU_FIELDS_INVALID 0x02
  500. #define SIU_PFC_TMF_NOT_SUPPORTED 0x04
  501. #define SIU_PFC_TMF_FAILED 0x05
  502. #define SIU_PFC_INVALID_TYPE_CODE 0x06
  503. #define SIU_PFC_ILLEGAL_REQUEST 0x07
  504. #define SIU_SENSE_LENGTH(siu) (_4btol((siu)->sense_length))
  505. #define SIU_SENSE_DATA(siu) (((siu)->flags & SIU_RSPVALID) ? \
  506. &(siu)->data[_4btol((siu)->pkt_failures_length)] : &(siu)->data[0])
  507. /*
  508. * Values for 'Task Management Flags' field of SPI command information unit.
  509. * See section 14.3.1 of SPI-3.
  510. */
  511. #define SIU_TASKMGMT_NONE 0x00
  512. #define SIU_TASKMGMT_ABORT_TASK 0x01
  513. #define SIU_TASKMGMT_ABORT_TASK_SET 0x02
  514. #define SIU_TASKMGMT_CLEAR_TASK_SET 0x04
  515. #define SIU_TASKMGMT_LUN_RESET 0x08
  516. #define SIU_TASKMGMT_TARGET_RESET 0x20
  517. #define SIU_TASKMGMT_CLEAR_ACA 0x40
  518. /*
  519. * Status Byte
  520. */
  521. #define SCSI_OK 0x00
  522. #define SCSI_CHECK 0x02
  523. #define SCSI_COND_MET 0x04
  524. #define SCSI_BUSY 0x08
  525. #define SCSI_INTERM 0x10
  526. #define SCSI_INTERM_COND_MET 0x14
  527. #define SCSI_RESV_CONFLICT 0x18
  528. #define SCSI_TERMINATED 0x22
  529. #define SCSI_QUEUE_FULL 0x28 /* Old (Pre SCSI-3) name */
  530. #define SCSI_TASKSET_FULL 0x28 /* New (SCSI-3) name */
  531. #define SCSI_ACA_ACTIVE 0x30
  532. #endif /* _SCSI_SCSI_ALL_H */