hpsa_cmd.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. /*
  2. * Disk Array driver for HP Smart Array SAS controllers
  3. * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  12. * NON INFRINGEMENT. See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * Questions/Comments/Bugfixes to iss_storagedev@hp.com
  19. *
  20. */
  21. #ifndef HPSA_CMD_H
  22. #define HPSA_CMD_H
  23. /* general boundary defintions */
  24. #define SENSEINFOBYTES 32 /* may vary between hbas */
  25. #define MAXSGENTRIES 32
  26. #define HPSA_SG_CHAIN 0x80000000
  27. #define MAXREPLYQS 256
  28. /* Command Status value */
  29. #define CMD_SUCCESS 0x0000
  30. #define CMD_TARGET_STATUS 0x0001
  31. #define CMD_DATA_UNDERRUN 0x0002
  32. #define CMD_DATA_OVERRUN 0x0003
  33. #define CMD_INVALID 0x0004
  34. #define CMD_PROTOCOL_ERR 0x0005
  35. #define CMD_HARDWARE_ERR 0x0006
  36. #define CMD_CONNECTION_LOST 0x0007
  37. #define CMD_ABORTED 0x0008
  38. #define CMD_ABORT_FAILED 0x0009
  39. #define CMD_UNSOLICITED_ABORT 0x000A
  40. #define CMD_TIMEOUT 0x000B
  41. #define CMD_UNABORTABLE 0x000C
  42. /* Unit Attentions ASC's as defined for the MSA2012sa */
  43. #define POWER_OR_RESET 0x29
  44. #define STATE_CHANGED 0x2a
  45. #define UNIT_ATTENTION_CLEARED 0x2f
  46. #define LUN_FAILED 0x3e
  47. #define REPORT_LUNS_CHANGED 0x3f
  48. /* Unit Attentions ASCQ's as defined for the MSA2012sa */
  49. /* These ASCQ's defined for ASC = POWER_OR_RESET */
  50. #define POWER_ON_RESET 0x00
  51. #define POWER_ON_REBOOT 0x01
  52. #define SCSI_BUS_RESET 0x02
  53. #define MSA_TARGET_RESET 0x03
  54. #define CONTROLLER_FAILOVER 0x04
  55. #define TRANSCEIVER_SE 0x05
  56. #define TRANSCEIVER_LVD 0x06
  57. /* These ASCQ's defined for ASC = STATE_CHANGED */
  58. #define RESERVATION_PREEMPTED 0x03
  59. #define ASYM_ACCESS_CHANGED 0x06
  60. #define LUN_CAPACITY_CHANGED 0x09
  61. /* transfer direction */
  62. #define XFER_NONE 0x00
  63. #define XFER_WRITE 0x01
  64. #define XFER_READ 0x02
  65. #define XFER_RSVD 0x03
  66. /* task attribute */
  67. #define ATTR_UNTAGGED 0x00
  68. #define ATTR_SIMPLE 0x04
  69. #define ATTR_HEADOFQUEUE 0x05
  70. #define ATTR_ORDERED 0x06
  71. #define ATTR_ACA 0x07
  72. /* cdb type */
  73. #define TYPE_CMD 0x00
  74. #define TYPE_MSG 0x01
  75. /* config space register offsets */
  76. #define CFG_VENDORID 0x00
  77. #define CFG_DEVICEID 0x02
  78. #define CFG_I2OBAR 0x10
  79. #define CFG_MEM1BAR 0x14
  80. /* i2o space register offsets */
  81. #define I2O_IBDB_SET 0x20
  82. #define I2O_IBDB_CLEAR 0x70
  83. #define I2O_INT_STATUS 0x30
  84. #define I2O_INT_MASK 0x34
  85. #define I2O_IBPOST_Q 0x40
  86. #define I2O_OBPOST_Q 0x44
  87. #define I2O_DMA1_CFG 0x214
  88. /* Configuration Table */
  89. #define CFGTBL_ChangeReq 0x00000001l
  90. #define CFGTBL_AccCmds 0x00000001l
  91. #define DOORBELL_CTLR_RESET 0x00000004l
  92. #define CFGTBL_Trans_Simple 0x00000002l
  93. #define CFGTBL_Trans_Performant 0x00000004l
  94. #define CFGTBL_BusType_Ultra2 0x00000001l
  95. #define CFGTBL_BusType_Ultra3 0x00000002l
  96. #define CFGTBL_BusType_Fibre1G 0x00000100l
  97. #define CFGTBL_BusType_Fibre2G 0x00000200l
  98. struct vals32 {
  99. u32 lower;
  100. u32 upper;
  101. };
  102. union u64bit {
  103. struct vals32 val32;
  104. u64 val;
  105. };
  106. /* FIXME this is a per controller value (barf!) */
  107. #define HPSA_MAX_TARGETS_PER_CTLR 16
  108. #define HPSA_MAX_LUN 256
  109. #define HPSA_MAX_PHYS_LUN 1024
  110. /* SCSI-3 Commands */
  111. #pragma pack(1)
  112. #define HPSA_INQUIRY 0x12
  113. struct InquiryData {
  114. u8 data_byte[36];
  115. };
  116. #define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
  117. #define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
  118. struct ReportLUNdata {
  119. u8 LUNListLength[4];
  120. u32 reserved;
  121. u8 LUN[HPSA_MAX_LUN][8];
  122. };
  123. struct ReportExtendedLUNdata {
  124. u8 LUNListLength[4];
  125. u8 extended_response_flag;
  126. u8 reserved[3];
  127. u8 LUN[HPSA_MAX_LUN][24];
  128. };
  129. struct SenseSubsystem_info {
  130. u8 reserved[36];
  131. u8 portname[8];
  132. u8 reserved1[1108];
  133. };
  134. /* BMIC commands */
  135. #define BMIC_READ 0x26
  136. #define BMIC_WRITE 0x27
  137. #define BMIC_CACHE_FLUSH 0xc2
  138. #define HPSA_CACHE_FLUSH 0x01 /* C2 was already being used by HPSA */
  139. /* Command List Structure */
  140. union SCSI3Addr {
  141. struct {
  142. u8 Dev;
  143. u8 Bus:6;
  144. u8 Mode:2; /* b00 */
  145. } PeripDev;
  146. struct {
  147. u8 DevLSB;
  148. u8 DevMSB:6;
  149. u8 Mode:2; /* b01 */
  150. } LogDev;
  151. struct {
  152. u8 Dev:5;
  153. u8 Bus:3;
  154. u8 Targ:6;
  155. u8 Mode:2; /* b10 */
  156. } LogUnit;
  157. };
  158. struct PhysDevAddr {
  159. u32 TargetId:24;
  160. u32 Bus:6;
  161. u32 Mode:2;
  162. /* 2 level target device addr */
  163. union SCSI3Addr Target[2];
  164. };
  165. struct LogDevAddr {
  166. u32 VolId:30;
  167. u32 Mode:2;
  168. u8 reserved[4];
  169. };
  170. union LUNAddr {
  171. u8 LunAddrBytes[8];
  172. union SCSI3Addr SCSI3Lun[4];
  173. struct PhysDevAddr PhysDev;
  174. struct LogDevAddr LogDev;
  175. };
  176. struct CommandListHeader {
  177. u8 ReplyQueue;
  178. u8 SGList;
  179. u16 SGTotal;
  180. struct vals32 Tag;
  181. union LUNAddr LUN;
  182. };
  183. struct RequestBlock {
  184. u8 CDBLen;
  185. struct {
  186. u8 Type:3;
  187. u8 Attribute:3;
  188. u8 Direction:2;
  189. } Type;
  190. u16 Timeout;
  191. u8 CDB[16];
  192. };
  193. struct ErrDescriptor {
  194. struct vals32 Addr;
  195. u32 Len;
  196. };
  197. struct SGDescriptor {
  198. struct vals32 Addr;
  199. u32 Len;
  200. u32 Ext;
  201. };
  202. union MoreErrInfo {
  203. struct {
  204. u8 Reserved[3];
  205. u8 Type;
  206. u32 ErrorInfo;
  207. } Common_Info;
  208. struct {
  209. u8 Reserved[2];
  210. u8 offense_size; /* size of offending entry */
  211. u8 offense_num; /* byte # of offense 0-base */
  212. u32 offense_value;
  213. } Invalid_Cmd;
  214. };
  215. struct ErrorInfo {
  216. u8 ScsiStatus;
  217. u8 SenseLen;
  218. u16 CommandStatus;
  219. u32 ResidualCnt;
  220. union MoreErrInfo MoreErrInfo;
  221. u8 SenseInfo[SENSEINFOBYTES];
  222. };
  223. /* Command types */
  224. #define CMD_IOCTL_PEND 0x01
  225. #define CMD_SCSI 0x03
  226. /* This structure needs to be divisible by 32 for new
  227. * indexing method and performant mode.
  228. */
  229. #define PAD32 32
  230. #define PAD64DIFF 0
  231. #define USEEXTRA ((sizeof(void *) - 4)/4)
  232. #define PADSIZE (PAD32 + PAD64DIFF * USEEXTRA)
  233. #define DIRECT_LOOKUP_SHIFT 5
  234. #define DIRECT_LOOKUP_BIT 0x10
  235. #define HPSA_ERROR_BIT 0x02
  236. struct ctlr_info; /* defined in hpsa.h */
  237. /* The size of this structure needs to be divisible by 32
  238. * on all architectures because low 5 bits of the addresses
  239. * are used as follows:
  240. *
  241. * bit 0: to device, used to indicate "performant mode" command
  242. * from device, indidcates error status.
  243. * bit 1-3: to device, indicates block fetch table entry for
  244. * reducing DMA in fetching commands from host memory.
  245. * bit 4: used to indicate whether tag is "direct lookup" (index),
  246. * or a bus address.
  247. */
  248. struct CommandList {
  249. struct CommandListHeader Header;
  250. struct RequestBlock Request;
  251. struct ErrDescriptor ErrDesc;
  252. struct SGDescriptor SG[MAXSGENTRIES];
  253. /* information associated with the command */
  254. u32 busaddr; /* physical addr of this record */
  255. struct ErrorInfo *err_info; /* pointer to the allocated mem */
  256. struct ctlr_info *h;
  257. int cmd_type;
  258. long cmdindex;
  259. struct hlist_node list;
  260. struct request *rq;
  261. struct completion *waiting;
  262. void *scsi_cmd;
  263. /* on 64 bit architectures, to get this to be 32-byte-aligned
  264. * it so happens we need PAD_64 bytes of padding, on 32 bit systems,
  265. * we need PAD_32 bytes of padding (see below). This does that.
  266. * If it happens that 64 bit and 32 bit systems need different
  267. * padding, PAD_32 and PAD_64 can be set independently, and.
  268. * the code below will do the right thing.
  269. */
  270. #define IS_32_BIT ((8 - sizeof(long))/4)
  271. #define IS_64_BIT (!IS_32_BIT)
  272. #define PAD_32 (4)
  273. #define PAD_64 (4)
  274. #define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
  275. u8 pad[COMMANDLIST_PAD];
  276. };
  277. /* Configuration Table Structure */
  278. struct HostWrite {
  279. u32 TransportRequest;
  280. u32 Reserved;
  281. u32 CoalIntDelay;
  282. u32 CoalIntCount;
  283. };
  284. #define SIMPLE_MODE 0x02
  285. #define PERFORMANT_MODE 0x04
  286. #define MEMQ_MODE 0x08
  287. struct CfgTable {
  288. u8 Signature[4];
  289. u32 SpecValence;
  290. u32 TransportSupport;
  291. u32 TransportActive;
  292. struct HostWrite HostWrite;
  293. u32 CmdsOutMax;
  294. u32 BusTypes;
  295. u32 TransMethodOffset;
  296. u8 ServerName[16];
  297. u32 HeartBeat;
  298. u32 SCSI_Prefetch;
  299. u32 MaxScatterGatherElements;
  300. u32 MaxLogicalUnits;
  301. u32 MaxPhysicalDevices;
  302. u32 MaxPhysicalDrivesPerLogicalUnit;
  303. u32 MaxPerformantModeCommands;
  304. u8 reserved[0x78 - 0x58];
  305. u32 misc_fw_support; /* offset 0x78 */
  306. #define MISC_FW_DOORBELL_RESET (0x02)
  307. };
  308. #define NUM_BLOCKFETCH_ENTRIES 8
  309. struct TransTable_struct {
  310. u32 BlockFetch[NUM_BLOCKFETCH_ENTRIES];
  311. u32 RepQSize;
  312. u32 RepQCount;
  313. u32 RepQCtrAddrLow32;
  314. u32 RepQCtrAddrHigh32;
  315. u32 RepQAddr0Low32;
  316. u32 RepQAddr0High32;
  317. };
  318. struct hpsa_pci_info {
  319. unsigned char bus;
  320. unsigned char dev_fn;
  321. unsigned short domain;
  322. u32 board_id;
  323. };
  324. #pragma pack()
  325. #endif /* HPSA_CMD_H */