megaraid_sas_fusion.h 22 KB

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