cciss_cmd.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. //Configuration Table
  52. #define CFGTBL_ChangeReq 0x00000001l
  53. #define CFGTBL_AccCmds 0x00000001l
  54. #define CFGTBL_Trans_Simple 0x00000002l
  55. #define CFGTBL_BusType_Ultra2 0x00000001l
  56. #define CFGTBL_BusType_Ultra3 0x00000002l
  57. #define CFGTBL_BusType_Fibre1G 0x00000100l
  58. #define CFGTBL_BusType_Fibre2G 0x00000200l
  59. typedef struct _vals32
  60. {
  61. __u32 lower;
  62. __u32 upper;
  63. } vals32;
  64. typedef union _u64bit
  65. {
  66. vals32 val32;
  67. __u64 val;
  68. } u64bit;
  69. // Type defs used in the following structs
  70. #define BYTE __u8
  71. #define WORD __u16
  72. #define HWORD __u16
  73. #define DWORD __u32
  74. #define QWORD vals32
  75. //###########################################################################
  76. //STRUCTURES
  77. //###########################################################################
  78. #define CISS_MAX_LUN 16
  79. #define CISS_MAX_PHYS_LUN 1024
  80. // SCSI-3 Cmmands
  81. #pragma pack(1)
  82. #define CISS_INQUIRY 0x12
  83. //Date returned
  84. typedef struct _InquiryData_struct
  85. {
  86. BYTE data_byte[36];
  87. } InquiryData_struct;
  88. #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
  89. #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
  90. // Data returned
  91. typedef struct _ReportLUNdata_struct
  92. {
  93. BYTE LUNListLength[4];
  94. DWORD reserved;
  95. BYTE LUN[CISS_MAX_LUN][8];
  96. } ReportLunData_struct;
  97. #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
  98. typedef struct _ReadCapdata_struct
  99. {
  100. BYTE total_size[4]; // Total size in blocks
  101. BYTE block_size[4]; // Size of blocks in bytes
  102. } ReadCapdata_struct;
  103. // 12 byte commands not implemented in firmware yet.
  104. // #define CCISS_READ 0xa8 // Read(12)
  105. // #define CCISS_WRITE 0xaa // Write(12)
  106. #define CCISS_READ 0x28 // Read(10)
  107. #define CCISS_WRITE 0x2a // Write(10)
  108. // BMIC commands
  109. #define BMIC_READ 0x26
  110. #define BMIC_WRITE 0x27
  111. #define BMIC_CACHE_FLUSH 0xc2
  112. #define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS
  113. //Command List Structure
  114. typedef union _SCSI3Addr_struct {
  115. struct {
  116. BYTE Dev;
  117. BYTE Bus:6;
  118. BYTE Mode:2; // b00
  119. } PeripDev;
  120. struct {
  121. BYTE DevLSB;
  122. BYTE DevMSB:6;
  123. BYTE Mode:2; // b01
  124. } LogDev;
  125. struct {
  126. BYTE Dev:5;
  127. BYTE Bus:3;
  128. BYTE Targ:6;
  129. BYTE Mode:2; // b10
  130. } LogUnit;
  131. } SCSI3Addr_struct;
  132. typedef struct _PhysDevAddr_struct {
  133. DWORD TargetId:24;
  134. DWORD Bus:6;
  135. DWORD Mode:2;
  136. SCSI3Addr_struct Target[2]; //2 level target device addr
  137. } PhysDevAddr_struct;
  138. typedef struct _LogDevAddr_struct {
  139. DWORD VolId:30;
  140. DWORD Mode:2;
  141. BYTE reserved[4];
  142. } LogDevAddr_struct;
  143. typedef union _LUNAddr_struct {
  144. BYTE LunAddrBytes[8];
  145. SCSI3Addr_struct SCSI3Lun[4];
  146. PhysDevAddr_struct PhysDev;
  147. LogDevAddr_struct LogDev;
  148. } LUNAddr_struct;
  149. typedef struct _CommandListHeader_struct {
  150. BYTE ReplyQueue;
  151. BYTE SGList;
  152. HWORD SGTotal;
  153. QWORD Tag;
  154. LUNAddr_struct LUN;
  155. } CommandListHeader_struct;
  156. typedef struct _RequestBlock_struct {
  157. BYTE CDBLen;
  158. struct {
  159. BYTE Type:3;
  160. BYTE Attribute:3;
  161. BYTE Direction:2;
  162. } Type;
  163. HWORD Timeout;
  164. BYTE CDB[16];
  165. } RequestBlock_struct;
  166. typedef struct _ErrDescriptor_struct {
  167. QWORD Addr;
  168. DWORD Len;
  169. } ErrDescriptor_struct;
  170. typedef struct _SGDescriptor_struct {
  171. QWORD Addr;
  172. DWORD Len;
  173. DWORD Ext;
  174. } SGDescriptor_struct;
  175. typedef union _MoreErrInfo_struct{
  176. struct {
  177. BYTE Reserved[3];
  178. BYTE Type;
  179. DWORD ErrorInfo;
  180. }Common_Info;
  181. struct{
  182. BYTE Reserved[2];
  183. BYTE offense_size;//size of offending entry
  184. BYTE offense_num; //byte # of offense 0-base
  185. DWORD offense_value;
  186. }Invalid_Cmd;
  187. }MoreErrInfo_struct;
  188. typedef struct _ErrorInfo_struct {
  189. BYTE ScsiStatus;
  190. BYTE SenseLen;
  191. HWORD CommandStatus;
  192. DWORD ResidualCnt;
  193. MoreErrInfo_struct MoreErrInfo;
  194. BYTE SenseInfo[SENSEINFOBYTES];
  195. } ErrorInfo_struct;
  196. /* Command types */
  197. #define CMD_RWREQ 0x00
  198. #define CMD_IOCTL_PEND 0x01
  199. #define CMD_SCSI 0x03
  200. #define CMD_MSG_DONE 0x04
  201. #define CMD_MSG_TIMEOUT 0x05
  202. typedef struct _CommandList_struct {
  203. CommandListHeader_struct Header;
  204. RequestBlock_struct Request;
  205. ErrDescriptor_struct ErrDesc;
  206. SGDescriptor_struct SG[MAXSGENTRIES];
  207. /* information associated with the command */
  208. __u32 busaddr; /* physical address of this record */
  209. ErrorInfo_struct * err_info; /* pointer to the allocated mem */
  210. int ctlr;
  211. int cmd_type;
  212. struct _CommandList_struct *prev;
  213. struct _CommandList_struct *next;
  214. struct request * rq;
  215. struct completion *waiting;
  216. int retry_count;
  217. #ifdef CONFIG_CISS_SCSI_TAPE
  218. void * scsi_cmd;
  219. #endif
  220. } CommandList_struct;
  221. //Configuration Table Structure
  222. typedef struct _HostWrite_struct {
  223. DWORD TransportRequest;
  224. DWORD Reserved;
  225. DWORD CoalIntDelay;
  226. DWORD CoalIntCount;
  227. } HostWrite_struct;
  228. typedef struct _CfgTable_struct {
  229. BYTE Signature[4];
  230. DWORD SpecValence;
  231. DWORD TransportSupport;
  232. DWORD TransportActive;
  233. HostWrite_struct HostWrite;
  234. DWORD CmdsOutMax;
  235. DWORD BusTypes;
  236. DWORD Reserved;
  237. BYTE ServerName[16];
  238. DWORD HeartBeat;
  239. DWORD SCSI_Prefetch;
  240. } CfgTable_struct;
  241. #pragma pack()
  242. #endif // CCISS_CMD_H