megaraid_sas_fusion.h 26 KB

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