hpsa_cmd.h 9.5 KB

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