hpsa_cmd.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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 DOORBELL_CTLR_RESET2 0x00000020l
  93. #define CFGTBL_Trans_Simple 0x00000002l
  94. #define CFGTBL_Trans_Performant 0x00000004l
  95. #define CFGTBL_Trans_use_short_tags 0x20000000l
  96. #define CFGTBL_BusType_Ultra2 0x00000001l
  97. #define CFGTBL_BusType_Ultra3 0x00000002l
  98. #define CFGTBL_BusType_Fibre1G 0x00000100l
  99. #define CFGTBL_BusType_Fibre2G 0x00000200l
  100. struct vals32 {
  101. u32 lower;
  102. u32 upper;
  103. };
  104. union u64bit {
  105. struct vals32 val32;
  106. u64 val;
  107. };
  108. /* FIXME this is a per controller value (barf!) */
  109. #define HPSA_MAX_TARGETS_PER_CTLR 16
  110. #define HPSA_MAX_LUN 256
  111. #define HPSA_MAX_PHYS_LUN 1024
  112. /* SCSI-3 Commands */
  113. #pragma pack(1)
  114. #define HPSA_INQUIRY 0x12
  115. struct InquiryData {
  116. u8 data_byte[36];
  117. };
  118. #define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
  119. #define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
  120. struct ReportLUNdata {
  121. u8 LUNListLength[4];
  122. u32 reserved;
  123. u8 LUN[HPSA_MAX_LUN][8];
  124. };
  125. struct ReportExtendedLUNdata {
  126. u8 LUNListLength[4];
  127. u8 extended_response_flag;
  128. u8 reserved[3];
  129. u8 LUN[HPSA_MAX_LUN][24];
  130. };
  131. struct SenseSubsystem_info {
  132. u8 reserved[36];
  133. u8 portname[8];
  134. u8 reserved1[1108];
  135. };
  136. /* BMIC commands */
  137. #define BMIC_READ 0x26
  138. #define BMIC_WRITE 0x27
  139. #define BMIC_CACHE_FLUSH 0xc2
  140. #define HPSA_CACHE_FLUSH 0x01 /* C2 was already being used by HPSA */
  141. /* Command List Structure */
  142. union SCSI3Addr {
  143. struct {
  144. u8 Dev;
  145. u8 Bus:6;
  146. u8 Mode:2; /* b00 */
  147. } PeripDev;
  148. struct {
  149. u8 DevLSB;
  150. u8 DevMSB:6;
  151. u8 Mode:2; /* b01 */
  152. } LogDev;
  153. struct {
  154. u8 Dev:5;
  155. u8 Bus:3;
  156. u8 Targ:6;
  157. u8 Mode:2; /* b10 */
  158. } LogUnit;
  159. };
  160. struct PhysDevAddr {
  161. u32 TargetId:24;
  162. u32 Bus:6;
  163. u32 Mode:2;
  164. /* 2 level target device addr */
  165. union SCSI3Addr Target[2];
  166. };
  167. struct LogDevAddr {
  168. u32 VolId:30;
  169. u32 Mode:2;
  170. u8 reserved[4];
  171. };
  172. union LUNAddr {
  173. u8 LunAddrBytes[8];
  174. union SCSI3Addr SCSI3Lun[4];
  175. struct PhysDevAddr PhysDev;
  176. struct LogDevAddr LogDev;
  177. };
  178. struct CommandListHeader {
  179. u8 ReplyQueue;
  180. u8 SGList;
  181. u16 SGTotal;
  182. struct vals32 Tag;
  183. union LUNAddr LUN;
  184. };
  185. struct RequestBlock {
  186. u8 CDBLen;
  187. struct {
  188. u8 Type:3;
  189. u8 Attribute:3;
  190. u8 Direction:2;
  191. } Type;
  192. u16 Timeout;
  193. u8 CDB[16];
  194. };
  195. struct ErrDescriptor {
  196. struct vals32 Addr;
  197. u32 Len;
  198. };
  199. struct SGDescriptor {
  200. struct vals32 Addr;
  201. u32 Len;
  202. u32 Ext;
  203. };
  204. union MoreErrInfo {
  205. struct {
  206. u8 Reserved[3];
  207. u8 Type;
  208. u32 ErrorInfo;
  209. } Common_Info;
  210. struct {
  211. u8 Reserved[2];
  212. u8 offense_size; /* size of offending entry */
  213. u8 offense_num; /* byte # of offense 0-base */
  214. u32 offense_value;
  215. } Invalid_Cmd;
  216. };
  217. struct ErrorInfo {
  218. u8 ScsiStatus;
  219. u8 SenseLen;
  220. u16 CommandStatus;
  221. u32 ResidualCnt;
  222. union MoreErrInfo MoreErrInfo;
  223. u8 SenseInfo[SENSEINFOBYTES];
  224. };
  225. /* Command types */
  226. #define CMD_IOCTL_PEND 0x01
  227. #define CMD_SCSI 0x03
  228. #define DIRECT_LOOKUP_SHIFT 5
  229. #define DIRECT_LOOKUP_BIT 0x10
  230. #define DIRECT_LOOKUP_MASK (~((1 << DIRECT_LOOKUP_SHIFT) - 1))
  231. #define HPSA_ERROR_BIT 0x02
  232. struct ctlr_info; /* defined in hpsa.h */
  233. /* The size of this structure needs to be divisible by 32
  234. * on all architectures because low 5 bits of the addresses
  235. * are used as follows:
  236. *
  237. * bit 0: to device, used to indicate "performant mode" command
  238. * from device, indidcates error status.
  239. * bit 1-3: to device, indicates block fetch table entry for
  240. * reducing DMA in fetching commands from host memory.
  241. * bit 4: used to indicate whether tag is "direct lookup" (index),
  242. * or a bus address.
  243. */
  244. struct CommandList {
  245. struct CommandListHeader Header;
  246. struct RequestBlock Request;
  247. struct ErrDescriptor ErrDesc;
  248. struct SGDescriptor SG[MAXSGENTRIES];
  249. /* information associated with the command */
  250. u32 busaddr; /* physical addr of this record */
  251. struct ErrorInfo *err_info; /* pointer to the allocated mem */
  252. struct ctlr_info *h;
  253. int cmd_type;
  254. long cmdindex;
  255. struct list_head list;
  256. struct request *rq;
  257. struct completion *waiting;
  258. void *scsi_cmd;
  259. /* on 64 bit architectures, to get this to be 32-byte-aligned
  260. * it so happens we need PAD_64 bytes of padding, on 32 bit systems,
  261. * we need PAD_32 bytes of padding (see below). This does that.
  262. * If it happens that 64 bit and 32 bit systems need different
  263. * padding, PAD_32 and PAD_64 can be set independently, and.
  264. * the code below will do the right thing.
  265. */
  266. #define IS_32_BIT ((8 - sizeof(long))/4)
  267. #define IS_64_BIT (!IS_32_BIT)
  268. #define PAD_32 (4)
  269. #define PAD_64 (4)
  270. #define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
  271. u8 pad[COMMANDLIST_PAD];
  272. };
  273. /* Configuration Table Structure */
  274. struct HostWrite {
  275. u32 TransportRequest;
  276. u32 Reserved;
  277. u32 CoalIntDelay;
  278. u32 CoalIntCount;
  279. };
  280. #define SIMPLE_MODE 0x02
  281. #define PERFORMANT_MODE 0x04
  282. #define MEMQ_MODE 0x08
  283. struct CfgTable {
  284. u8 Signature[4];
  285. u32 SpecValence;
  286. u32 TransportSupport;
  287. u32 TransportActive;
  288. struct HostWrite HostWrite;
  289. u32 CmdsOutMax;
  290. u32 BusTypes;
  291. u32 TransMethodOffset;
  292. u8 ServerName[16];
  293. u32 HeartBeat;
  294. u32 SCSI_Prefetch;
  295. u32 MaxScatterGatherElements;
  296. u32 MaxLogicalUnits;
  297. u32 MaxPhysicalDevices;
  298. u32 MaxPhysicalDrivesPerLogicalUnit;
  299. u32 MaxPerformantModeCommands;
  300. u8 reserved[0x78 - 0x58];
  301. u32 misc_fw_support; /* offset 0x78 */
  302. #define MISC_FW_DOORBELL_RESET (0x02)
  303. #define MISC_FW_DOORBELL_RESET2 (0x010)
  304. u8 driver_version[32];
  305. };
  306. #define NUM_BLOCKFETCH_ENTRIES 8
  307. struct TransTable_struct {
  308. u32 BlockFetch[NUM_BLOCKFETCH_ENTRIES];
  309. u32 RepQSize;
  310. u32 RepQCount;
  311. u32 RepQCtrAddrLow32;
  312. u32 RepQCtrAddrHigh32;
  313. u32 RepQAddr0Low32;
  314. u32 RepQAddr0High32;
  315. };
  316. struct hpsa_pci_info {
  317. unsigned char bus;
  318. unsigned char dev_fn;
  319. unsigned short domain;
  320. u32 board_id;
  321. };
  322. #pragma pack()
  323. #endif /* HPSA_CMD_H */