cciss_cmd.h 8.8 KB

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