cciss_cmd.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
  104. /* service action to differentiate a 16 byte read capacity from
  105. other commands that use the 0x9e SCSI op code */
  106. #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
  107. typedef struct _ReadCapdata_struct_16
  108. {
  109. BYTE total_size[8]; /* Total size in blocks */
  110. BYTE block_size[4]; /* Size of blocks in bytes */
  111. BYTE prot_en:1; /* protection enable bit */
  112. BYTE rto_en:1; /* reference tag own enable bit */
  113. BYTE reserved:6; /* reserved bits */
  114. BYTE reserved2[18]; /* reserved bytes per spec */
  115. } ReadCapdata_struct_16;
  116. /* Define the supported read/write commands for cciss based controllers */
  117. #define CCISS_READ_10 0x28 /* Read(10) */
  118. #define CCISS_WRITE_10 0x2a /* Write(10) */
  119. #define CCISS_READ_16 0x88 /* Read(16) */
  120. #define CCISS_WRITE_16 0x8a /* Write(16) */
  121. /* Define the CDB lengths supported by cciss based controllers */
  122. #define CDB_LEN10 10
  123. #define CDB_LEN16 16
  124. // BMIC commands
  125. #define BMIC_READ 0x26
  126. #define BMIC_WRITE 0x27
  127. #define BMIC_CACHE_FLUSH 0xc2
  128. #define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS
  129. //Command List Structure
  130. typedef union _SCSI3Addr_struct {
  131. struct {
  132. BYTE Dev;
  133. BYTE Bus:6;
  134. BYTE Mode:2; // b00
  135. } PeripDev;
  136. struct {
  137. BYTE DevLSB;
  138. BYTE DevMSB:6;
  139. BYTE Mode:2; // b01
  140. } LogDev;
  141. struct {
  142. BYTE Dev:5;
  143. BYTE Bus:3;
  144. BYTE Targ:6;
  145. BYTE Mode:2; // b10
  146. } LogUnit;
  147. } SCSI3Addr_struct;
  148. typedef struct _PhysDevAddr_struct {
  149. DWORD TargetId:24;
  150. DWORD Bus:6;
  151. DWORD Mode:2;
  152. SCSI3Addr_struct Target[2]; //2 level target device addr
  153. } PhysDevAddr_struct;
  154. typedef struct _LogDevAddr_struct {
  155. DWORD VolId:30;
  156. DWORD Mode:2;
  157. BYTE reserved[4];
  158. } LogDevAddr_struct;
  159. typedef union _LUNAddr_struct {
  160. BYTE LunAddrBytes[8];
  161. SCSI3Addr_struct SCSI3Lun[4];
  162. PhysDevAddr_struct PhysDev;
  163. LogDevAddr_struct LogDev;
  164. } LUNAddr_struct;
  165. typedef struct _CommandListHeader_struct {
  166. BYTE ReplyQueue;
  167. BYTE SGList;
  168. HWORD SGTotal;
  169. QWORD Tag;
  170. LUNAddr_struct LUN;
  171. } CommandListHeader_struct;
  172. typedef struct _RequestBlock_struct {
  173. BYTE CDBLen;
  174. struct {
  175. BYTE Type:3;
  176. BYTE Attribute:3;
  177. BYTE Direction:2;
  178. } Type;
  179. HWORD Timeout;
  180. BYTE CDB[16];
  181. } RequestBlock_struct;
  182. typedef struct _ErrDescriptor_struct {
  183. QWORD Addr;
  184. DWORD Len;
  185. } ErrDescriptor_struct;
  186. typedef struct _SGDescriptor_struct {
  187. QWORD Addr;
  188. DWORD Len;
  189. DWORD Ext;
  190. } SGDescriptor_struct;
  191. typedef union _MoreErrInfo_struct{
  192. struct {
  193. BYTE Reserved[3];
  194. BYTE Type;
  195. DWORD ErrorInfo;
  196. }Common_Info;
  197. struct{
  198. BYTE Reserved[2];
  199. BYTE offense_size;//size of offending entry
  200. BYTE offense_num; //byte # of offense 0-base
  201. DWORD offense_value;
  202. }Invalid_Cmd;
  203. }MoreErrInfo_struct;
  204. typedef struct _ErrorInfo_struct {
  205. BYTE ScsiStatus;
  206. BYTE SenseLen;
  207. HWORD CommandStatus;
  208. DWORD ResidualCnt;
  209. MoreErrInfo_struct MoreErrInfo;
  210. BYTE SenseInfo[SENSEINFOBYTES];
  211. } ErrorInfo_struct;
  212. /* Command types */
  213. #define CMD_RWREQ 0x00
  214. #define CMD_IOCTL_PEND 0x01
  215. #define CMD_SCSI 0x03
  216. #define CMD_MSG_DONE 0x04
  217. #define CMD_MSG_TIMEOUT 0x05
  218. /* This structure needs to be divisible by 8 for new
  219. * indexing method.
  220. */
  221. #define PADSIZE (sizeof(long) - 4)
  222. typedef struct _CommandList_struct {
  223. CommandListHeader_struct Header;
  224. RequestBlock_struct Request;
  225. ErrDescriptor_struct ErrDesc;
  226. SGDescriptor_struct SG[MAXSGENTRIES];
  227. /* information associated with the command */
  228. __u32 busaddr; /* physical address of this record */
  229. ErrorInfo_struct * err_info; /* pointer to the allocated mem */
  230. int ctlr;
  231. int cmd_type;
  232. long cmdindex;
  233. struct _CommandList_struct *prev;
  234. struct _CommandList_struct *next;
  235. struct request * rq;
  236. struct completion *waiting;
  237. int retry_count;
  238. void * scsi_cmd;
  239. char pad[PADSIZE];
  240. } CommandList_struct;
  241. //Configuration Table Structure
  242. typedef struct _HostWrite_struct {
  243. DWORD TransportRequest;
  244. DWORD Reserved;
  245. DWORD CoalIntDelay;
  246. DWORD CoalIntCount;
  247. } HostWrite_struct;
  248. typedef struct _CfgTable_struct {
  249. BYTE Signature[4];
  250. DWORD SpecValence;
  251. DWORD TransportSupport;
  252. DWORD TransportActive;
  253. HostWrite_struct HostWrite;
  254. DWORD CmdsOutMax;
  255. DWORD BusTypes;
  256. DWORD Reserved;
  257. BYTE ServerName[16];
  258. DWORD HeartBeat;
  259. DWORD SCSI_Prefetch;
  260. } CfgTable_struct;
  261. #pragma pack()
  262. #endif // CCISS_CMD_H