cciss_cmd.h 7.9 KB

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