hpsa_cmd.h 9.3 KB

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