cciss_cmd.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. #ifndef CCISS_CMD_H
  2. #define CCISS_CMD_H
  3. //###########################################################################
  4. //DEFINES
  5. //###########################################################################
  6. #define CISS_VERSION "1.00"
  7. //general boundary defintions
  8. #define SENSEINFOBYTES 32//note that this value may vary between host implementations
  9. #define MAXSGENTRIES 31
  10. #define MAXREPLYQS 256
  11. //Command Status value
  12. #define CMD_SUCCESS 0x0000
  13. #define CMD_TARGET_STATUS 0x0001
  14. #define CMD_DATA_UNDERRUN 0x0002
  15. #define CMD_DATA_OVERRUN 0x0003
  16. #define CMD_INVALID 0x0004
  17. #define CMD_PROTOCOL_ERR 0x0005
  18. #define CMD_HARDWARE_ERR 0x0006
  19. #define CMD_CONNECTION_LOST 0x0007
  20. #define CMD_ABORTED 0x0008
  21. #define CMD_ABORT_FAILED 0x0009
  22. #define CMD_UNSOLICITED_ABORT 0x000A
  23. #define CMD_TIMEOUT 0x000B
  24. #define CMD_UNABORTABLE 0x000C
  25. /* Unit Attentions ASC's as defined for the MSA2012sa */
  26. #define POWER_OR_RESET 0x29
  27. #define STATE_CHANGED 0x2a
  28. #define UNIT_ATTENTION_CLEARED 0x2f
  29. #define LUN_FAILED 0x3e
  30. #define REPORT_LUNS_CHANGED 0x3f
  31. /* Unit Attentions ASCQ's as defined for the MSA2012sa */
  32. /* These ASCQ's defined for ASC = POWER_OR_RESET */
  33. #define POWER_ON_RESET 0x00
  34. #define POWER_ON_REBOOT 0x01
  35. #define SCSI_BUS_RESET 0x02
  36. #define MSA_TARGET_RESET 0x03
  37. #define CONTROLLER_FAILOVER 0x04
  38. #define TRANSCEIVER_SE 0x05
  39. #define TRANSCEIVER_LVD 0x06
  40. /* These ASCQ's defined for ASC = STATE_CHANGED */
  41. #define RESERVATION_PREEMPTED 0x03
  42. #define ASYM_ACCESS_CHANGED 0x06
  43. #define LUN_CAPACITY_CHANGED 0x09
  44. //transfer direction
  45. #define XFER_NONE 0x00
  46. #define XFER_WRITE 0x01
  47. #define XFER_READ 0x02
  48. #define XFER_RSVD 0x03
  49. //task attribute
  50. #define ATTR_UNTAGGED 0x00
  51. #define ATTR_SIMPLE 0x04
  52. #define ATTR_HEADOFQUEUE 0x05
  53. #define ATTR_ORDERED 0x06
  54. #define ATTR_ACA 0x07
  55. //cdb type
  56. #define TYPE_CMD 0x00
  57. #define TYPE_MSG 0x01
  58. //config space register offsets
  59. #define CFG_VENDORID 0x00
  60. #define CFG_DEVICEID 0x02
  61. #define CFG_I2OBAR 0x10
  62. #define CFG_MEM1BAR 0x14
  63. //i2o space register offsets
  64. #define I2O_IBDB_SET 0x20
  65. #define I2O_IBDB_CLEAR 0x70
  66. #define I2O_INT_STATUS 0x30
  67. #define I2O_INT_MASK 0x34
  68. #define I2O_IBPOST_Q 0x40
  69. #define I2O_OBPOST_Q 0x44
  70. #define I2O_DMA1_CFG 0x214
  71. //Configuration Table
  72. #define CFGTBL_ChangeReq 0x00000001l
  73. #define CFGTBL_AccCmds 0x00000001l
  74. #define CFGTBL_Trans_Simple 0x00000002l
  75. #define CFGTBL_BusType_Ultra2 0x00000001l
  76. #define CFGTBL_BusType_Ultra3 0x00000002l
  77. #define CFGTBL_BusType_Fibre1G 0x00000100l
  78. #define CFGTBL_BusType_Fibre2G 0x00000200l
  79. typedef struct _vals32
  80. {
  81. __u32 lower;
  82. __u32 upper;
  83. } vals32;
  84. typedef union _u64bit
  85. {
  86. vals32 val32;
  87. __u64 val;
  88. } u64bit;
  89. // Type defs used in the following structs
  90. #define BYTE __u8
  91. #define WORD __u16
  92. #define HWORD __u16
  93. #define DWORD __u32
  94. #define QWORD vals32
  95. //###########################################################################
  96. //STRUCTURES
  97. //###########################################################################
  98. #define CISS_MAX_LUN 1024
  99. #define CISS_MAX_PHYS_LUN 1024
  100. // SCSI-3 Cmmands
  101. #pragma pack(1)
  102. #define CISS_INQUIRY 0x12
  103. //Date returned
  104. typedef struct _InquiryData_struct
  105. {
  106. BYTE data_byte[36];
  107. } InquiryData_struct;
  108. #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
  109. #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
  110. // Data returned
  111. typedef struct _ReportLUNdata_struct
  112. {
  113. BYTE LUNListLength[4];
  114. DWORD reserved;
  115. BYTE LUN[CISS_MAX_LUN][8];
  116. } ReportLunData_struct;
  117. #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
  118. typedef struct _ReadCapdata_struct
  119. {
  120. BYTE total_size[4]; // Total size in blocks
  121. BYTE block_size[4]; // Size of blocks in bytes
  122. } ReadCapdata_struct;
  123. #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
  124. /* service action to differentiate a 16 byte read capacity from
  125. other commands that use the 0x9e SCSI op code */
  126. #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
  127. typedef struct _ReadCapdata_struct_16
  128. {
  129. BYTE total_size[8]; /* Total size in blocks */
  130. BYTE block_size[4]; /* Size of blocks in bytes */
  131. BYTE prot_en:1; /* protection enable bit */
  132. BYTE rto_en:1; /* reference tag own enable bit */
  133. BYTE reserved:6; /* reserved bits */
  134. BYTE reserved2[18]; /* reserved bytes per spec */
  135. } ReadCapdata_struct_16;
  136. /* Define the supported read/write commands for cciss based controllers */
  137. #define CCISS_READ_10 0x28 /* Read(10) */
  138. #define CCISS_WRITE_10 0x2a /* Write(10) */
  139. #define CCISS_READ_16 0x88 /* Read(16) */
  140. #define CCISS_WRITE_16 0x8a /* Write(16) */
  141. /* Define the CDB lengths supported by cciss based controllers */
  142. #define CDB_LEN10 10
  143. #define CDB_LEN16 16
  144. // BMIC commands
  145. #define BMIC_READ 0x26
  146. #define BMIC_WRITE 0x27
  147. #define BMIC_CACHE_FLUSH 0xc2
  148. #define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS
  149. //Command List Structure
  150. typedef union _SCSI3Addr_struct {
  151. struct {
  152. BYTE Dev;
  153. BYTE Bus:6;
  154. BYTE Mode:2; // b00
  155. } PeripDev;
  156. struct {
  157. BYTE DevLSB;
  158. BYTE DevMSB:6;
  159. BYTE Mode:2; // b01
  160. } LogDev;
  161. struct {
  162. BYTE Dev:5;
  163. BYTE Bus:3;
  164. BYTE Targ:6;
  165. BYTE Mode:2; // b10
  166. } LogUnit;
  167. } SCSI3Addr_struct;
  168. typedef struct _PhysDevAddr_struct {
  169. DWORD TargetId:24;
  170. DWORD Bus:6;
  171. DWORD Mode:2;
  172. SCSI3Addr_struct Target[2]; //2 level target device addr
  173. } PhysDevAddr_struct;
  174. typedef struct _LogDevAddr_struct {
  175. DWORD VolId:30;
  176. DWORD Mode:2;
  177. BYTE reserved[4];
  178. } LogDevAddr_struct;
  179. typedef union _LUNAddr_struct {
  180. BYTE LunAddrBytes[8];
  181. SCSI3Addr_struct SCSI3Lun[4];
  182. PhysDevAddr_struct PhysDev;
  183. LogDevAddr_struct LogDev;
  184. } LUNAddr_struct;
  185. typedef struct _CommandListHeader_struct {
  186. BYTE ReplyQueue;
  187. BYTE SGList;
  188. HWORD SGTotal;
  189. QWORD Tag;
  190. LUNAddr_struct LUN;
  191. } CommandListHeader_struct;
  192. typedef struct _RequestBlock_struct {
  193. BYTE CDBLen;
  194. struct {
  195. BYTE Type:3;
  196. BYTE Attribute:3;
  197. BYTE Direction:2;
  198. } Type;
  199. HWORD Timeout;
  200. BYTE CDB[16];
  201. } RequestBlock_struct;
  202. typedef struct _ErrDescriptor_struct {
  203. QWORD Addr;
  204. DWORD Len;
  205. } ErrDescriptor_struct;
  206. typedef struct _SGDescriptor_struct {
  207. QWORD Addr;
  208. DWORD Len;
  209. DWORD Ext;
  210. } SGDescriptor_struct;
  211. typedef union _MoreErrInfo_struct{
  212. struct {
  213. BYTE Reserved[3];
  214. BYTE Type;
  215. DWORD ErrorInfo;
  216. }Common_Info;
  217. struct{
  218. BYTE Reserved[2];
  219. BYTE offense_size;//size of offending entry
  220. BYTE offense_num; //byte # of offense 0-base
  221. DWORD offense_value;
  222. }Invalid_Cmd;
  223. }MoreErrInfo_struct;
  224. typedef struct _ErrorInfo_struct {
  225. BYTE ScsiStatus;
  226. BYTE SenseLen;
  227. HWORD CommandStatus;
  228. DWORD ResidualCnt;
  229. MoreErrInfo_struct MoreErrInfo;
  230. BYTE SenseInfo[SENSEINFOBYTES];
  231. } ErrorInfo_struct;
  232. /* Command types */
  233. #define CMD_RWREQ 0x00
  234. #define CMD_IOCTL_PEND 0x01
  235. #define CMD_SCSI 0x03
  236. #define CMD_MSG_DONE 0x04
  237. #define CMD_MSG_TIMEOUT 0x05
  238. /* This structure needs to be divisible by 8 for new
  239. * indexing method.
  240. */
  241. #define PADSIZE (sizeof(long) - 4)
  242. typedef struct _CommandList_struct {
  243. CommandListHeader_struct Header;
  244. RequestBlock_struct Request;
  245. ErrDescriptor_struct ErrDesc;
  246. SGDescriptor_struct SG[MAXSGENTRIES];
  247. /* information associated with the command */
  248. __u32 busaddr; /* physical address of this record */
  249. ErrorInfo_struct * err_info; /* pointer to the allocated mem */
  250. int ctlr;
  251. int cmd_type;
  252. long cmdindex;
  253. struct hlist_node list;
  254. struct request * rq;
  255. struct completion *waiting;
  256. int retry_count;
  257. void * scsi_cmd;
  258. char pad[PADSIZE];
  259. } CommandList_struct;
  260. //Configuration Table Structure
  261. typedef struct _HostWrite_struct {
  262. DWORD TransportRequest;
  263. DWORD Reserved;
  264. DWORD CoalIntDelay;
  265. DWORD CoalIntCount;
  266. } HostWrite_struct;
  267. typedef struct _CfgTable_struct {
  268. BYTE Signature[4];
  269. DWORD SpecValence;
  270. DWORD TransportSupport;
  271. DWORD TransportActive;
  272. HostWrite_struct HostWrite;
  273. DWORD CmdsOutMax;
  274. DWORD BusTypes;
  275. DWORD Reserved;
  276. BYTE ServerName[16];
  277. DWORD HeartBeat;
  278. DWORD SCSI_Prefetch;
  279. } CfgTable_struct;
  280. #pragma pack()
  281. #endif // CCISS_CMD_H