megaraid_sas_fusion.h 26 KB

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