cciss_cmd.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. #ifndef CCISS_CMD_H
  2. #define CCISS_CMD_H
  3. #include <linux/cciss_defs.h>
  4. /* DEFINES */
  5. #define CISS_VERSION "1.00"
  6. /* general boundary definitions */
  7. #define MAXSGENTRIES 32
  8. #define CCISS_SG_CHAIN 0x80000000
  9. #define MAXREPLYQS 256
  10. /* Unit Attentions ASC's as defined for the MSA2012sa */
  11. #define POWER_OR_RESET 0x29
  12. #define STATE_CHANGED 0x2a
  13. #define UNIT_ATTENTION_CLEARED 0x2f
  14. #define LUN_FAILED 0x3e
  15. #define REPORT_LUNS_CHANGED 0x3f
  16. /* Unit Attentions ASCQ's as defined for the MSA2012sa */
  17. /* These ASCQ's defined for ASC = POWER_OR_RESET */
  18. #define POWER_ON_RESET 0x00
  19. #define POWER_ON_REBOOT 0x01
  20. #define SCSI_BUS_RESET 0x02
  21. #define MSA_TARGET_RESET 0x03
  22. #define CONTROLLER_FAILOVER 0x04
  23. #define TRANSCEIVER_SE 0x05
  24. #define TRANSCEIVER_LVD 0x06
  25. /* These ASCQ's defined for ASC = STATE_CHANGED */
  26. #define RESERVATION_PREEMPTED 0x03
  27. #define ASYM_ACCESS_CHANGED 0x06
  28. #define LUN_CAPACITY_CHANGED 0x09
  29. /* config space register offsets */
  30. #define CFG_VENDORID 0x00
  31. #define CFG_DEVICEID 0x02
  32. #define CFG_I2OBAR 0x10
  33. #define CFG_MEM1BAR 0x14
  34. /* i2o space register offsets */
  35. #define I2O_IBDB_SET 0x20
  36. #define I2O_IBDB_CLEAR 0x70
  37. #define I2O_INT_STATUS 0x30
  38. #define I2O_INT_MASK 0x34
  39. #define I2O_IBPOST_Q 0x40
  40. #define I2O_OBPOST_Q 0x44
  41. #define I2O_DMA1_CFG 0x214
  42. /* Configuration Table */
  43. #define CFGTBL_ChangeReq 0x00000001l
  44. #define CFGTBL_AccCmds 0x00000001l
  45. #define DOORBELL_CTLR_RESET 0x00000004l
  46. #define CFGTBL_Trans_Simple 0x00000002l
  47. #define CFGTBL_Trans_Performant 0x00000004l
  48. #define CFGTBL_Trans_use_short_tags 0x20000000l
  49. #define CFGTBL_BusType_Ultra2 0x00000001l
  50. #define CFGTBL_BusType_Ultra3 0x00000002l
  51. #define CFGTBL_BusType_Fibre1G 0x00000100l
  52. #define CFGTBL_BusType_Fibre2G 0x00000200l
  53. typedef struct _vals32
  54. {
  55. __u32 lower;
  56. __u32 upper;
  57. } vals32;
  58. typedef union _u64bit
  59. {
  60. vals32 val32;
  61. __u64 val;
  62. } u64bit;
  63. /* Type defs used in the following structs */
  64. #define QWORD vals32
  65. /* STRUCTURES */
  66. #define CISS_MAX_PHYS_LUN 1024
  67. /* SCSI-3 Cmmands */
  68. #pragma pack(1)
  69. #define CISS_INQUIRY 0x12
  70. /* Date returned */
  71. typedef struct _InquiryData_struct
  72. {
  73. BYTE data_byte[36];
  74. } InquiryData_struct;
  75. #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
  76. #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
  77. /* Data returned */
  78. typedef struct _ReportLUNdata_struct
  79. {
  80. BYTE LUNListLength[4];
  81. DWORD reserved;
  82. BYTE LUN[CISS_MAX_LUN][8];
  83. } ReportLunData_struct;
  84. #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
  85. typedef struct _ReadCapdata_struct
  86. {
  87. BYTE total_size[4]; /* Total size in blocks */
  88. BYTE block_size[4]; /* Size of blocks in bytes */
  89. } ReadCapdata_struct;
  90. #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
  91. /* service action to differentiate a 16 byte read capacity from
  92. other commands that use the 0x9e SCSI op code */
  93. #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
  94. typedef struct _ReadCapdata_struct_16
  95. {
  96. BYTE total_size[8]; /* Total size in blocks */
  97. BYTE block_size[4]; /* Size of blocks in bytes */
  98. BYTE prot_en:1; /* protection enable bit */
  99. BYTE rto_en:1; /* reference tag own enable bit */
  100. BYTE reserved:6; /* reserved bits */
  101. BYTE reserved2[18]; /* reserved bytes per spec */
  102. } ReadCapdata_struct_16;
  103. /* Define the supported read/write commands for cciss based controllers */
  104. #define CCISS_READ_10 0x28 /* Read(10) */
  105. #define CCISS_WRITE_10 0x2a /* Write(10) */
  106. #define CCISS_READ_16 0x88 /* Read(16) */
  107. #define CCISS_WRITE_16 0x8a /* Write(16) */
  108. /* Define the CDB lengths supported by cciss based controllers */
  109. #define CDB_LEN10 10
  110. #define CDB_LEN16 16
  111. /* BMIC commands */
  112. #define BMIC_READ 0x26
  113. #define BMIC_WRITE 0x27
  114. #define BMIC_CACHE_FLUSH 0xc2
  115. #define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */
  116. /* Command List Structure */
  117. #define CTLR_LUNID "\0\0\0\0\0\0\0\0"
  118. typedef struct _CommandListHeader_struct {
  119. BYTE ReplyQueue;
  120. BYTE SGList;
  121. HWORD SGTotal;
  122. QWORD Tag;
  123. LUNAddr_struct LUN;
  124. } CommandListHeader_struct;
  125. typedef struct _ErrDescriptor_struct {
  126. QWORD Addr;
  127. DWORD Len;
  128. } ErrDescriptor_struct;
  129. typedef struct _SGDescriptor_struct {
  130. QWORD Addr;
  131. DWORD Len;
  132. DWORD Ext;
  133. } SGDescriptor_struct;
  134. /* Command types */
  135. #define CMD_RWREQ 0x00
  136. #define CMD_IOCTL_PEND 0x01
  137. #define CMD_SCSI 0x03
  138. #define CMD_MSG_DONE 0x04
  139. #define CMD_MSG_TIMEOUT 0x05
  140. #define CMD_MSG_STALE 0xff
  141. /* This structure needs to be divisible by COMMANDLIST_ALIGNMENT
  142. * because low bits of the address are used to to indicate that
  143. * whether the tag contains an index or an address. PAD_32 and
  144. * PAD_64 can be adjusted independently as needed for 32-bit
  145. * and 64-bits systems.
  146. */
  147. #define COMMANDLIST_ALIGNMENT (32)
  148. #define IS_64_BIT ((sizeof(long) - 4)/4)
  149. #define IS_32_BIT (!IS_64_BIT)
  150. #define PAD_32 (0)
  151. #define PAD_64 (4)
  152. #define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
  153. #define DIRECT_LOOKUP_BIT 0x10
  154. #define DIRECT_LOOKUP_SHIFT 5
  155. typedef struct _CommandList_struct {
  156. CommandListHeader_struct Header;
  157. RequestBlock_struct Request;
  158. ErrDescriptor_struct ErrDesc;
  159. SGDescriptor_struct SG[MAXSGENTRIES];
  160. /* information associated with the command */
  161. __u32 busaddr; /* physical address of this record */
  162. ErrorInfo_struct * err_info; /* pointer to the allocated mem */
  163. int ctlr;
  164. int cmd_type;
  165. long cmdindex;
  166. struct list_head list;
  167. struct request * rq;
  168. struct completion *waiting;
  169. int retry_count;
  170. void * scsi_cmd;
  171. char pad[PADSIZE];
  172. } CommandList_struct;
  173. /* Configuration Table Structure */
  174. typedef struct _HostWrite_struct {
  175. DWORD TransportRequest;
  176. DWORD Reserved;
  177. DWORD CoalIntDelay;
  178. DWORD CoalIntCount;
  179. } HostWrite_struct;
  180. typedef struct _CfgTable_struct {
  181. BYTE Signature[4];
  182. DWORD SpecValence;
  183. #define SIMPLE_MODE 0x02
  184. #define PERFORMANT_MODE 0x04
  185. #define MEMQ_MODE 0x08
  186. DWORD TransportSupport;
  187. DWORD TransportActive;
  188. HostWrite_struct HostWrite;
  189. DWORD CmdsOutMax;
  190. DWORD BusTypes;
  191. DWORD TransMethodOffset;
  192. BYTE ServerName[16];
  193. DWORD HeartBeat;
  194. DWORD SCSI_Prefetch;
  195. DWORD MaxSGElements;
  196. DWORD MaxLogicalUnits;
  197. DWORD MaxPhysicalDrives;
  198. DWORD MaxPhysicalDrivesPerLogicalUnit;
  199. DWORD MaxPerformantModeCommands;
  200. u8 reserved[0x78 - 0x58];
  201. u32 misc_fw_support; /* offset 0x78 */
  202. #define MISC_FW_DOORBELL_RESET (0x02)
  203. } CfgTable_struct;
  204. struct TransTable_struct {
  205. u32 BlockFetch0;
  206. u32 BlockFetch1;
  207. u32 BlockFetch2;
  208. u32 BlockFetch3;
  209. u32 BlockFetch4;
  210. u32 BlockFetch5;
  211. u32 BlockFetch6;
  212. u32 BlockFetch7;
  213. u32 RepQSize;
  214. u32 RepQCount;
  215. u32 RepQCtrAddrLow32;
  216. u32 RepQCtrAddrHigh32;
  217. u32 RepQAddr0Low32;
  218. u32 RepQAddr0High32;
  219. };
  220. #pragma pack()
  221. #endif /* CCISS_CMD_H */