megaraid_sas_fusion.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. /*
  2. * Linux MegaRAID driver for SAS based RAID controllers
  3. *
  4. * Copyright (c) 2009-2012 LSI Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * FILE: megaraid_sas_fusion.h
  21. *
  22. * Authors: LSI Corporation
  23. * Manoj Jose
  24. * Sumant Patro
  25. *
  26. * Send feedback to: <megaraidlinux@lsi.com>
  27. *
  28. * Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
  29. * ATTN: Linuxraid
  30. */
  31. #ifndef _MEGARAID_SAS_FUSION_H_
  32. #define _MEGARAID_SAS_FUSION_H_
  33. /* Fusion defines */
  34. #define MEGASAS_MAX_SZ_CHAIN_FRAME 1024
  35. #define MFI_FUSION_ENABLE_INTERRUPT_MASK (0x00000009)
  36. #define MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE 256
  37. #define MEGASAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST 0xF0
  38. #define MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST 0xF1
  39. #define MEGASAS_LOAD_BALANCE_FLAG 0x1
  40. #define MEGASAS_DCMD_MBOX_PEND_FLAG 0x1
  41. #define HOST_DIAG_WRITE_ENABLE 0x80
  42. #define HOST_DIAG_RESET_ADAPTER 0x4
  43. #define MEGASAS_FUSION_MAX_RESET_TRIES 3
  44. #define MAX_MSIX_QUEUES_FUSION 128
  45. /* Invader defines */
  46. #define MPI2_TYPE_CUDA 0x2
  47. #define MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH 0x4000
  48. #define MR_RL_FLAGS_GRANT_DESTINATION_CPU0 0x00
  49. #define MR_RL_FLAGS_GRANT_DESTINATION_CPU1 0x10
  50. #define MR_RL_FLAGS_GRANT_DESTINATION_CUDA 0x80
  51. #define MR_RL_FLAGS_SEQ_NUM_ENABLE 0x8
  52. /* T10 PI defines */
  53. #define MR_PROT_INFO_TYPE_CONTROLLER 0x8
  54. #define MEGASAS_SCSI_VARIABLE_LENGTH_CMD 0x7f
  55. #define MEGASAS_SCSI_SERVICE_ACTION_READ32 0x9
  56. #define MEGASAS_SCSI_SERVICE_ACTION_WRITE32 0xB
  57. #define MEGASAS_SCSI_ADDL_CDB_LEN 0x18
  58. #define MEGASAS_RD_WR_PROTECT_CHECK_ALL 0x20
  59. #define MEGASAS_RD_WR_PROTECT_CHECK_NONE 0x60
  60. #define MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET (0x0000030C)
  61. #define MPI2_REPLY_POST_HOST_INDEX_OFFSET (0x0000006C)
  62. /*
  63. * Raid context flags
  64. */
  65. #define MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT 0x4
  66. #define MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_MASK 0x30
  67. enum MR_RAID_FLAGS_IO_SUB_TYPE {
  68. MR_RAID_FLAGS_IO_SUB_TYPE_NONE = 0,
  69. MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD = 1,
  70. };
  71. /*
  72. * Request descriptor types
  73. */
  74. #define MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO 0x7
  75. #define MEGASAS_REQ_DESCRIPT_FLAGS_MFA 0x1
  76. #define MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK 0x2
  77. #define MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT 1
  78. #define MEGASAS_FP_CMD_LEN 16
  79. #define MEGASAS_FUSION_IN_RESET 0
  80. /*
  81. * Raid Context structure which describes MegaRAID specific IO Parameters
  82. * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
  83. */
  84. struct RAID_CONTEXT {
  85. #if defined(__BIG_ENDIAN_BITFIELD)
  86. u8 nseg:4;
  87. u8 Type:4;
  88. #else
  89. u8 Type:4;
  90. u8 nseg:4;
  91. #endif
  92. u8 resvd0;
  93. u16 timeoutValue;
  94. u8 regLockFlags;
  95. u8 resvd1;
  96. u16 VirtualDiskTgtId;
  97. u64 regLockRowLBA;
  98. u32 regLockLength;
  99. u16 nextLMId;
  100. u8 exStatus;
  101. u8 status;
  102. u8 RAIDFlags;
  103. u8 numSGE;
  104. u16 configSeqNum;
  105. u8 spanArm;
  106. u8 resvd2[3];
  107. };
  108. #define RAID_CTX_SPANARM_ARM_SHIFT (0)
  109. #define RAID_CTX_SPANARM_ARM_MASK (0x1f)
  110. #define RAID_CTX_SPANARM_SPAN_SHIFT (5)
  111. #define RAID_CTX_SPANARM_SPAN_MASK (0xE0)
  112. /*
  113. * define region lock types
  114. */
  115. enum REGION_TYPE {
  116. REGION_TYPE_UNUSED = 0,
  117. REGION_TYPE_SHARED_READ = 1,
  118. REGION_TYPE_SHARED_WRITE = 2,
  119. REGION_TYPE_EXCLUSIVE = 3,
  120. };
  121. /* MPI2 defines */
  122. #define MPI2_FUNCTION_IOC_INIT (0x02) /* IOC Init */
  123. #define MPI2_WHOINIT_HOST_DRIVER (0x04)
  124. #define MPI2_VERSION_MAJOR (0x02)
  125. #define MPI2_VERSION_MINOR (0x00)
  126. #define MPI2_VERSION_MAJOR_MASK (0xFF00)
  127. #define MPI2_VERSION_MAJOR_SHIFT (8)
  128. #define MPI2_VERSION_MINOR_MASK (0x00FF)
  129. #define MPI2_VERSION_MINOR_SHIFT (0)
  130. #define MPI2_VERSION ((MPI2_VERSION_MAJOR << MPI2_VERSION_MAJOR_SHIFT) | \
  131. MPI2_VERSION_MINOR)
  132. #define MPI2_HEADER_VERSION_UNIT (0x10)
  133. #define MPI2_HEADER_VERSION_DEV (0x00)
  134. #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00)
  135. #define MPI2_HEADER_VERSION_UNIT_SHIFT (8)
  136. #define MPI2_HEADER_VERSION_DEV_MASK (0x00FF)
  137. #define MPI2_HEADER_VERSION_DEV_SHIFT (0)
  138. #define MPI2_HEADER_VERSION ((MPI2_HEADER_VERSION_UNIT << 8) | \
  139. MPI2_HEADER_VERSION_DEV)
  140. #define MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR (0x03)
  141. #define MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG (0x8000)
  142. #define MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG (0x0400)
  143. #define MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP (0x0003)
  144. #define MPI2_SCSIIO_EEDPFLAGS_CHECK_APPTAG (0x0200)
  145. #define MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD (0x0100)
  146. #define MPI2_SCSIIO_EEDPFLAGS_INSERT_OP (0x0004)
  147. #define MPI2_FUNCTION_SCSI_IO_REQUEST (0x00) /* SCSI IO */
  148. #define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY (0x06)
  149. #define MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO (0x00)
  150. #define MPI2_SGE_FLAGS_64_BIT_ADDRESSING (0x02)
  151. #define MPI2_SCSIIO_CONTROL_WRITE (0x01000000)
  152. #define MPI2_SCSIIO_CONTROL_READ (0x02000000)
  153. #define MPI2_REQ_DESCRIPT_FLAGS_TYPE_MASK (0x0E)
  154. #define MPI2_RPY_DESCRIPT_FLAGS_UNUSED (0x0F)
  155. #define MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS (0x00)
  156. #define MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK (0x0F)
  157. #define MPI2_WRSEQ_FLUSH_KEY_VALUE (0x0)
  158. #define MPI2_WRITE_SEQUENCE_OFFSET (0x00000004)
  159. #define MPI2_WRSEQ_1ST_KEY_VALUE (0xF)
  160. #define MPI2_WRSEQ_2ND_KEY_VALUE (0x4)
  161. #define MPI2_WRSEQ_3RD_KEY_VALUE (0xB)
  162. #define MPI2_WRSEQ_4TH_KEY_VALUE (0x2)
  163. #define MPI2_WRSEQ_5TH_KEY_VALUE (0x7)
  164. #define MPI2_WRSEQ_6TH_KEY_VALUE (0xD)
  165. struct MPI25_IEEE_SGE_CHAIN64 {
  166. u64 Address;
  167. u32 Length;
  168. u16 Reserved1;
  169. u8 NextChainOffset;
  170. u8 Flags;
  171. };
  172. struct MPI2_SGE_SIMPLE_UNION {
  173. u32 FlagsLength;
  174. union {
  175. u32 Address32;
  176. u64 Address64;
  177. } u;
  178. };
  179. struct MPI2_SCSI_IO_CDB_EEDP32 {
  180. u8 CDB[20]; /* 0x00 */
  181. u32 PrimaryReferenceTag; /* 0x14 */
  182. u16 PrimaryApplicationTag; /* 0x18 */
  183. u16 PrimaryApplicationTagMask; /* 0x1A */
  184. u32 TransferLength; /* 0x1C */
  185. };
  186. struct MPI2_SGE_CHAIN_UNION {
  187. u16 Length;
  188. u8 NextChainOffset;
  189. u8 Flags;
  190. union {
  191. u32 Address32;
  192. u64 Address64;
  193. } u;
  194. };
  195. struct MPI2_IEEE_SGE_SIMPLE32 {
  196. u32 Address;
  197. u32 FlagsLength;
  198. };
  199. struct MPI2_IEEE_SGE_CHAIN32 {
  200. u32 Address;
  201. u32 FlagsLength;
  202. };
  203. struct MPI2_IEEE_SGE_SIMPLE64 {
  204. u64 Address;
  205. u32 Length;
  206. u16 Reserved1;
  207. u8 Reserved2;
  208. u8 Flags;
  209. };
  210. struct MPI2_IEEE_SGE_CHAIN64 {
  211. u64 Address;
  212. u32 Length;
  213. u16 Reserved1;
  214. u8 Reserved2;
  215. u8 Flags;
  216. };
  217. union MPI2_IEEE_SGE_SIMPLE_UNION {
  218. struct MPI2_IEEE_SGE_SIMPLE32 Simple32;
  219. struct MPI2_IEEE_SGE_SIMPLE64 Simple64;
  220. };
  221. union MPI2_IEEE_SGE_CHAIN_UNION {
  222. struct MPI2_IEEE_SGE_CHAIN32 Chain32;
  223. struct MPI2_IEEE_SGE_CHAIN64 Chain64;
  224. };
  225. union MPI2_SGE_IO_UNION {
  226. struct MPI2_SGE_SIMPLE_UNION MpiSimple;
  227. struct MPI2_SGE_CHAIN_UNION MpiChain;
  228. union MPI2_IEEE_SGE_SIMPLE_UNION IeeeSimple;
  229. union MPI2_IEEE_SGE_CHAIN_UNION IeeeChain;
  230. };
  231. union MPI2_SCSI_IO_CDB_UNION {
  232. u8 CDB32[32];
  233. struct MPI2_SCSI_IO_CDB_EEDP32 EEDP32;
  234. struct MPI2_SGE_SIMPLE_UNION SGE;
  235. };
  236. /*
  237. * RAID SCSI IO Request Message
  238. * Total SGE count will be one less than _MPI2_SCSI_IO_REQUEST
  239. */
  240. struct MPI2_RAID_SCSI_IO_REQUEST {
  241. u16 DevHandle; /* 0x00 */
  242. u8 ChainOffset; /* 0x02 */
  243. u8 Function; /* 0x03 */
  244. u16 Reserved1; /* 0x04 */
  245. u8 Reserved2; /* 0x06 */
  246. u8 MsgFlags; /* 0x07 */
  247. u8 VP_ID; /* 0x08 */
  248. u8 VF_ID; /* 0x09 */
  249. u16 Reserved3; /* 0x0A */
  250. u32 SenseBufferLowAddress; /* 0x0C */
  251. u16 SGLFlags; /* 0x10 */
  252. u8 SenseBufferLength; /* 0x12 */
  253. u8 Reserved4; /* 0x13 */
  254. u8 SGLOffset0; /* 0x14 */
  255. u8 SGLOffset1; /* 0x15 */
  256. u8 SGLOffset2; /* 0x16 */
  257. u8 SGLOffset3; /* 0x17 */
  258. u32 SkipCount; /* 0x18 */
  259. u32 DataLength; /* 0x1C */
  260. u32 BidirectionalDataLength; /* 0x20 */
  261. u16 IoFlags; /* 0x24 */
  262. u16 EEDPFlags; /* 0x26 */
  263. u32 EEDPBlockSize; /* 0x28 */
  264. u32 SecondaryReferenceTag; /* 0x2C */
  265. u16 SecondaryApplicationTag; /* 0x30 */
  266. u16 ApplicationTagTranslationMask; /* 0x32 */
  267. u8 LUN[8]; /* 0x34 */
  268. u32 Control; /* 0x3C */
  269. union MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */
  270. struct RAID_CONTEXT RaidContext; /* 0x60 */
  271. union MPI2_SGE_IO_UNION SGL; /* 0x80 */
  272. };
  273. /*
  274. * MPT RAID MFA IO Descriptor.
  275. */
  276. struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
  277. #if defined(__BIG_ENDIAN_BITFIELD)
  278. u32 MessageAddress1:24; /* bits 31:8*/
  279. u32 RequestFlags:8;
  280. #else
  281. u32 RequestFlags:8;
  282. u32 MessageAddress1:24; /* bits 31:8*/
  283. #endif
  284. u32 MessageAddress2; /* bits 61:32 */
  285. };
  286. /* Default Request Descriptor */
  287. struct MPI2_DEFAULT_REQUEST_DESCRIPTOR {
  288. u8 RequestFlags; /* 0x00 */
  289. u8 MSIxIndex; /* 0x01 */
  290. u16 SMID; /* 0x02 */
  291. u16 LMID; /* 0x04 */
  292. u16 DescriptorTypeDependent; /* 0x06 */
  293. };
  294. /* High Priority Request Descriptor */
  295. struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR {
  296. u8 RequestFlags; /* 0x00 */
  297. u8 MSIxIndex; /* 0x01 */
  298. u16 SMID; /* 0x02 */
  299. u16 LMID; /* 0x04 */
  300. u16 Reserved1; /* 0x06 */
  301. };
  302. /* SCSI IO Request Descriptor */
  303. struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR {
  304. u8 RequestFlags; /* 0x00 */
  305. u8 MSIxIndex; /* 0x01 */
  306. u16 SMID; /* 0x02 */
  307. u16 LMID; /* 0x04 */
  308. u16 DevHandle; /* 0x06 */
  309. };
  310. /* SCSI Target Request Descriptor */
  311. struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR {
  312. u8 RequestFlags; /* 0x00 */
  313. u8 MSIxIndex; /* 0x01 */
  314. u16 SMID; /* 0x02 */
  315. u16 LMID; /* 0x04 */
  316. u16 IoIndex; /* 0x06 */
  317. };
  318. /* RAID Accelerator Request Descriptor */
  319. struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {
  320. u8 RequestFlags; /* 0x00 */
  321. u8 MSIxIndex; /* 0x01 */
  322. u16 SMID; /* 0x02 */
  323. u16 LMID; /* 0x04 */
  324. u16 Reserved; /* 0x06 */
  325. };
  326. /* union of Request Descriptors */
  327. union MEGASAS_REQUEST_DESCRIPTOR_UNION {
  328. struct MPI2_DEFAULT_REQUEST_DESCRIPTOR Default;
  329. struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR HighPriority;
  330. struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR SCSIIO;
  331. struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR SCSITarget;
  332. struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR RAIDAccelerator;
  333. struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR MFAIo;
  334. union {
  335. struct {
  336. u32 low;
  337. u32 high;
  338. } u;
  339. u64 Words;
  340. };
  341. };
  342. /* Default Reply Descriptor */
  343. struct MPI2_DEFAULT_REPLY_DESCRIPTOR {
  344. u8 ReplyFlags; /* 0x00 */
  345. u8 MSIxIndex; /* 0x01 */
  346. u16 DescriptorTypeDependent1; /* 0x02 */
  347. u32 DescriptorTypeDependent2; /* 0x04 */
  348. };
  349. /* Address Reply Descriptor */
  350. struct MPI2_ADDRESS_REPLY_DESCRIPTOR {
  351. u8 ReplyFlags; /* 0x00 */
  352. u8 MSIxIndex; /* 0x01 */
  353. u16 SMID; /* 0x02 */
  354. u32 ReplyFrameAddress; /* 0x04 */
  355. };
  356. /* SCSI IO Success Reply Descriptor */
  357. struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR {
  358. u8 ReplyFlags; /* 0x00 */
  359. u8 MSIxIndex; /* 0x01 */
  360. u16 SMID; /* 0x02 */
  361. u16 TaskTag; /* 0x04 */
  362. u16 Reserved1; /* 0x06 */
  363. };
  364. /* TargetAssist Success Reply Descriptor */
  365. struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR {
  366. u8 ReplyFlags; /* 0x00 */
  367. u8 MSIxIndex; /* 0x01 */
  368. u16 SMID; /* 0x02 */
  369. u8 SequenceNumber; /* 0x04 */
  370. u8 Reserved1; /* 0x05 */
  371. u16 IoIndex; /* 0x06 */
  372. };
  373. /* Target Command Buffer Reply Descriptor */
  374. struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR {
  375. u8 ReplyFlags; /* 0x00 */
  376. u8 MSIxIndex; /* 0x01 */
  377. u8 VP_ID; /* 0x02 */
  378. u8 Flags; /* 0x03 */
  379. u16 InitiatorDevHandle; /* 0x04 */
  380. u16 IoIndex; /* 0x06 */
  381. };
  382. /* RAID Accelerator Success Reply Descriptor */
  383. struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {
  384. u8 ReplyFlags; /* 0x00 */
  385. u8 MSIxIndex; /* 0x01 */
  386. u16 SMID; /* 0x02 */
  387. u32 Reserved; /* 0x04 */
  388. };
  389. /* union of Reply Descriptors */
  390. union MPI2_REPLY_DESCRIPTORS_UNION {
  391. struct MPI2_DEFAULT_REPLY_DESCRIPTOR Default;
  392. struct MPI2_ADDRESS_REPLY_DESCRIPTOR AddressReply;
  393. struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR SCSIIOSuccess;
  394. struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR TargetAssistSuccess;
  395. struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer;
  396. struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR
  397. RAIDAcceleratorSuccess;
  398. u64 Words;
  399. };
  400. /* IOCInit Request message */
  401. struct MPI2_IOC_INIT_REQUEST {
  402. u8 WhoInit; /* 0x00 */
  403. u8 Reserved1; /* 0x01 */
  404. u8 ChainOffset; /* 0x02 */
  405. u8 Function; /* 0x03 */
  406. u16 Reserved2; /* 0x04 */
  407. u8 Reserved3; /* 0x06 */
  408. u8 MsgFlags; /* 0x07 */
  409. u8 VP_ID; /* 0x08 */
  410. u8 VF_ID; /* 0x09 */
  411. u16 Reserved4; /* 0x0A */
  412. u16 MsgVersion; /* 0x0C */
  413. u16 HeaderVersion; /* 0x0E */
  414. u32 Reserved5; /* 0x10 */
  415. u16 Reserved6; /* 0x14 */
  416. u8 Reserved7; /* 0x16 */
  417. u8 HostMSIxVectors; /* 0x17 */
  418. u16 Reserved8; /* 0x18 */
  419. u16 SystemRequestFrameSize; /* 0x1A */
  420. u16 ReplyDescriptorPostQueueDepth; /* 0x1C */
  421. u16 ReplyFreeQueueDepth; /* 0x1E */
  422. u32 SenseBufferAddressHigh; /* 0x20 */
  423. u32 SystemReplyAddressHigh; /* 0x24 */
  424. u64 SystemRequestFrameBaseAddress; /* 0x28 */
  425. u64 ReplyDescriptorPostQueueAddress;/* 0x30 */
  426. u64 ReplyFreeQueueAddress; /* 0x38 */
  427. u64 TimeStamp; /* 0x40 */
  428. };
  429. /* mrpriv defines */
  430. #define MR_PD_INVALID 0xFFFF
  431. #define MAX_SPAN_DEPTH 8
  432. #define MAX_QUAD_DEPTH MAX_SPAN_DEPTH
  433. #define MAX_RAIDMAP_SPAN_DEPTH (MAX_SPAN_DEPTH)
  434. #define MAX_ROW_SIZE 32
  435. #define MAX_RAIDMAP_ROW_SIZE (MAX_ROW_SIZE)
  436. #define MAX_LOGICAL_DRIVES 64
  437. #define MAX_RAIDMAP_LOGICAL_DRIVES (MAX_LOGICAL_DRIVES)
  438. #define MAX_RAIDMAP_VIEWS (MAX_LOGICAL_DRIVES)
  439. #define MAX_ARRAYS 128
  440. #define MAX_RAIDMAP_ARRAYS (MAX_ARRAYS)
  441. #define MAX_PHYSICAL_DEVICES 256
  442. #define MAX_RAIDMAP_PHYSICAL_DEVICES (MAX_PHYSICAL_DEVICES)
  443. #define MR_DCMD_LD_MAP_GET_INFO 0x0300e101
  444. struct MR_DEV_HANDLE_INFO {
  445. u16 curDevHdl;
  446. u8 validHandles;
  447. u8 reserved;
  448. u16 devHandle[2];
  449. };
  450. struct MR_ARRAY_INFO {
  451. u16 pd[MAX_RAIDMAP_ROW_SIZE];
  452. };
  453. struct MR_QUAD_ELEMENT {
  454. u64 logStart;
  455. u64 logEnd;
  456. u64 offsetInSpan;
  457. u32 diff;
  458. u32 reserved1;
  459. };
  460. struct MR_SPAN_INFO {
  461. u32 noElements;
  462. u32 reserved1;
  463. struct MR_QUAD_ELEMENT quad[MAX_RAIDMAP_SPAN_DEPTH];
  464. };
  465. struct MR_LD_SPAN {
  466. u64 startBlk;
  467. u64 numBlks;
  468. u16 arrayRef;
  469. u8 spanRowSize;
  470. u8 spanRowDataSize;
  471. u8 reserved[4];
  472. };
  473. struct MR_SPAN_BLOCK_INFO {
  474. u64 num_rows;
  475. struct MR_LD_SPAN span;
  476. struct MR_SPAN_INFO block_span_info;
  477. };
  478. struct MR_LD_RAID {
  479. struct {
  480. #if defined(__BIG_ENDIAN_BITFIELD)
  481. u32 reserved4:7;
  482. u32 fpNonRWCapable:1;
  483. u32 fpReadAcrossStripe:1;
  484. u32 fpWriteAcrossStripe:1;
  485. u32 fpReadCapable:1;
  486. u32 fpWriteCapable:1;
  487. u32 encryptionType:8;
  488. u32 pdPiMode:4;
  489. u32 ldPiMode:4;
  490. u32 reserved5:3;
  491. u32 fpCapable:1;
  492. #else
  493. u32 fpCapable:1;
  494. u32 reserved5:3;
  495. u32 ldPiMode:4;
  496. u32 pdPiMode:4;
  497. u32 encryptionType:8;
  498. u32 fpWriteCapable:1;
  499. u32 fpReadCapable:1;
  500. u32 fpWriteAcrossStripe:1;
  501. u32 fpReadAcrossStripe:1;
  502. u32 fpNonRWCapable:1;
  503. u32 reserved4:7;
  504. #endif
  505. } capability;
  506. u32 reserved6;
  507. u64 size;
  508. u8 spanDepth;
  509. u8 level;
  510. u8 stripeShift;
  511. u8 rowSize;
  512. u8 rowDataSize;
  513. u8 writeMode;
  514. u8 PRL;
  515. u8 SRL;
  516. u16 targetId;
  517. u8 ldState;
  518. u8 regTypeReqOnWrite;
  519. u8 modFactor;
  520. u8 regTypeReqOnRead;
  521. u16 seqNum;
  522. struct {
  523. u32 ldSyncRequired:1;
  524. u32 reserved:31;
  525. } flags;
  526. u8 LUN[8]; /* 0x24 8 byte LUN field used for SCSI IO's */
  527. u8 fpIoTimeoutForLd;/*0x2C timeout value used by driver in FP IO*/
  528. u8 reserved3[0x80-0x2D]; /* 0x2D */
  529. };
  530. struct MR_LD_SPAN_MAP {
  531. struct MR_LD_RAID ldRaid;
  532. u8 dataArmMap[MAX_RAIDMAP_ROW_SIZE];
  533. struct MR_SPAN_BLOCK_INFO spanBlock[MAX_RAIDMAP_SPAN_DEPTH];
  534. };
  535. struct MR_FW_RAID_MAP {
  536. u32 totalSize;
  537. union {
  538. struct {
  539. u32 maxLd;
  540. u32 maxSpanDepth;
  541. u32 maxRowSize;
  542. u32 maxPdCount;
  543. u32 maxArrays;
  544. } validationInfo;
  545. u32 version[5];
  546. u32 reserved1[5];
  547. };
  548. u32 ldCount;
  549. u32 Reserved1;
  550. u8 ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+
  551. MAX_RAIDMAP_VIEWS];
  552. u8 fpPdIoTimeoutSec;
  553. u8 reserved2[7];
  554. struct MR_ARRAY_INFO arMapInfo[MAX_RAIDMAP_ARRAYS];
  555. struct MR_DEV_HANDLE_INFO devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
  556. struct MR_LD_SPAN_MAP ldSpanMap[1];
  557. };
  558. struct IO_REQUEST_INFO {
  559. u64 ldStartBlock;
  560. u32 numBlocks;
  561. u16 ldTgtId;
  562. u8 isRead;
  563. u16 devHandle;
  564. u64 pdBlock;
  565. u8 fpOkForIo;
  566. u8 IoforUnevenSpan;
  567. u8 start_span;
  568. u8 reserved;
  569. u64 start_row;
  570. };
  571. struct MR_LD_TARGET_SYNC {
  572. u8 targetId;
  573. u8 reserved;
  574. u16 seqNum;
  575. };
  576. #define IEEE_SGE_FLAGS_ADDR_MASK (0x03)
  577. #define IEEE_SGE_FLAGS_SYSTEM_ADDR (0x00)
  578. #define IEEE_SGE_FLAGS_IOCDDR_ADDR (0x01)
  579. #define IEEE_SGE_FLAGS_IOCPLB_ADDR (0x02)
  580. #define IEEE_SGE_FLAGS_IOCPLBNTA_ADDR (0x03)
  581. #define IEEE_SGE_FLAGS_CHAIN_ELEMENT (0x80)
  582. #define IEEE_SGE_FLAGS_END_OF_LIST (0x40)
  583. struct megasas_register_set;
  584. struct megasas_instance;
  585. union desc_word {
  586. u64 word;
  587. struct {
  588. u32 low;
  589. u32 high;
  590. } u;
  591. };
  592. struct megasas_cmd_fusion {
  593. struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
  594. dma_addr_t io_request_phys_addr;
  595. union MPI2_SGE_IO_UNION *sg_frame;
  596. dma_addr_t sg_frame_phys_addr;
  597. u8 *sense;
  598. dma_addr_t sense_phys_addr;
  599. struct list_head list;
  600. struct scsi_cmnd *scmd;
  601. struct megasas_instance *instance;
  602. u8 retry_for_fw_reset;
  603. union MEGASAS_REQUEST_DESCRIPTOR_UNION *request_desc;
  604. /*
  605. * Context for a MFI frame.
  606. * Used to get the mfi cmd from list when a MFI cmd is completed
  607. */
  608. u32 sync_cmd_idx;
  609. u32 index;
  610. u8 flags;
  611. };
  612. struct LD_LOAD_BALANCE_INFO {
  613. u8 loadBalanceFlag;
  614. u8 reserved1;
  615. u16 raid1DevHandle[2];
  616. atomic_t scsi_pending_cmds[2];
  617. u64 last_accessed_block[2];
  618. };
  619. /* SPAN_SET is info caclulated from span info from Raid map per LD */
  620. typedef struct _LD_SPAN_SET {
  621. u64 log_start_lba;
  622. u64 log_end_lba;
  623. u64 span_row_start;
  624. u64 span_row_end;
  625. u64 data_strip_start;
  626. u64 data_strip_end;
  627. u64 data_row_start;
  628. u64 data_row_end;
  629. u8 strip_offset[MAX_SPAN_DEPTH];
  630. u32 span_row_data_width;
  631. u32 diff;
  632. u32 reserved[2];
  633. } LD_SPAN_SET, *PLD_SPAN_SET;
  634. typedef struct LOG_BLOCK_SPAN_INFO {
  635. LD_SPAN_SET span_set[MAX_SPAN_DEPTH];
  636. } LD_SPAN_INFO, *PLD_SPAN_INFO;
  637. struct MR_FW_RAID_MAP_ALL {
  638. struct MR_FW_RAID_MAP raidMap;
  639. struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES - 1];
  640. } __attribute__ ((packed));
  641. struct fusion_context {
  642. struct megasas_cmd_fusion **cmd_list;
  643. struct list_head cmd_pool;
  644. spinlock_t cmd_pool_lock;
  645. dma_addr_t req_frames_desc_phys;
  646. u8 *req_frames_desc;
  647. struct dma_pool *io_request_frames_pool;
  648. dma_addr_t io_request_frames_phys;
  649. u8 *io_request_frames;
  650. struct dma_pool *sg_dma_pool;
  651. struct dma_pool *sense_dma_pool;
  652. dma_addr_t reply_frames_desc_phys;
  653. union MPI2_REPLY_DESCRIPTORS_UNION *reply_frames_desc;
  654. struct dma_pool *reply_frames_desc_pool;
  655. u16 last_reply_idx[MAX_MSIX_QUEUES_FUSION];
  656. u32 reply_q_depth;
  657. u32 request_alloc_sz;
  658. u32 reply_alloc_sz;
  659. u32 io_frames_alloc_sz;
  660. u16 max_sge_in_main_msg;
  661. u16 max_sge_in_chain;
  662. u8 chain_offset_io_request;
  663. u8 chain_offset_mfi_pthru;
  664. struct MR_FW_RAID_MAP_ALL *ld_map[2];
  665. dma_addr_t ld_map_phys[2];
  666. u32 map_sz;
  667. u8 fast_path_io;
  668. struct LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES];
  669. LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES];
  670. };
  671. union desc_value {
  672. u64 word;
  673. struct {
  674. u32 low;
  675. u32 high;
  676. } u;
  677. };
  678. #endif /* _MEGARAID_SAS_FUSION_H_ */