hpsa_cmd.h 10 KB

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