blob: 35a51397b36478828e2649cac833249f0b38b2bb [file] [log] [blame]
adam radford9c915a82010-12-21 13:34:31 -08001/*
2 * Linux MegaRAID driver for SAS based RAID controllers
3 *
adam radfordae590572012-10-01 19:27:34 -07004 * Copyright (c) 2009-2012 LSI Corporation.
adam radford9c915a82010-12-21 13:34:31 -08005 *
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
32#ifndef _MEGARAID_SAS_FUSION_H_
33#define _MEGARAID_SAS_FUSION_H_
34
35/* Fusion defines */
36#define MEGASAS_MAX_SZ_CHAIN_FRAME 1024
37#define MFI_FUSION_ENABLE_INTERRUPT_MASK (0x00000009)
38#define MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE 256
39#define MEGASAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST 0xF0
40#define MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST 0xF1
41#define MEGASAS_LOAD_BALANCE_FLAG 0x1
42#define MEGASAS_DCMD_MBOX_PEND_FLAG 0x1
43#define HOST_DIAG_WRITE_ENABLE 0x80
44#define HOST_DIAG_RESET_ADAPTER 0x4
45#define MEGASAS_FUSION_MAX_RESET_TRIES 3
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +053046#define MAX_MSIX_QUEUES_FUSION 128
adam radford9c915a82010-12-21 13:34:31 -080047
adam radford36807e62011-10-08 18:15:06 -070048/* Invader defines */
49#define MPI2_TYPE_CUDA 0x2
50#define MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH 0x4000
51#define MR_RL_FLAGS_GRANT_DESTINATION_CPU0 0x00
52#define MR_RL_FLAGS_GRANT_DESTINATION_CPU1 0x10
53#define MR_RL_FLAGS_GRANT_DESTINATION_CUDA 0x80
54#define MR_RL_FLAGS_SEQ_NUM_ENABLE 0x8
55
adam radford9c915a82010-12-21 13:34:31 -080056/* T10 PI defines */
57#define MR_PROT_INFO_TYPE_CONTROLLER 0x8
58#define MEGASAS_SCSI_VARIABLE_LENGTH_CMD 0x7f
59#define MEGASAS_SCSI_SERVICE_ACTION_READ32 0x9
60#define MEGASAS_SCSI_SERVICE_ACTION_WRITE32 0xB
61#define MEGASAS_SCSI_ADDL_CDB_LEN 0x18
62#define MEGASAS_RD_WR_PROTECT_CHECK_ALL 0x20
63#define MEGASAS_RD_WR_PROTECT_CHECK_NONE 0x60
adam radford9c915a82010-12-21 13:34:31 -080064
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +053065#define MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET (0x0000030C)
66#define MPI2_REPLY_POST_HOST_INDEX_OFFSET (0x0000006C)
67
adam radford9c915a82010-12-21 13:34:31 -080068/*
69 * Raid context flags
70 */
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
74enum 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/*
80 * Request descriptor types
81 */
82#define MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO 0x7
83#define MEGASAS_REQ_DESCRIPT_FLAGS_MFA 0x1
adam radford36807e62011-10-08 18:15:06 -070084#define MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK 0x2
adam radford9c915a82010-12-21 13:34:31 -080085#define MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT 1
86
87#define MEGASAS_FP_CMD_LEN 16
88#define MEGASAS_FUSION_IN_RESET 0
89
90/*
Matthias Schid3948ff82013-06-26 16:25:53 +020091 * Raid Context structure which describes MegaRAID specific IO Parameters
adam radford9c915a82010-12-21 13:34:31 -080092 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
93 */
94
95struct RAID_CONTEXT {
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +053096#if defined(__BIG_ENDIAN_BITFIELD)
97 u8 nseg:4;
98 u8 Type:4;
99#else
adam radford36807e62011-10-08 18:15:06 -0700100 u8 Type:4;
101 u8 nseg:4;
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +0530102#endif
adam radford36807e62011-10-08 18:15:06 -0700103 u8 resvd0;
adam radford9c915a82010-12-21 13:34:31 -0800104 u16 timeoutValue;
105 u8 regLockFlags;
106 u8 resvd1;
107 u16 VirtualDiskTgtId;
108 u64 regLockRowLBA;
109 u32 regLockLength;
110 u16 nextLMId;
111 u8 exStatus;
112 u8 status;
113 u8 RAIDFlags;
114 u8 numSGE;
115 u16 configSeqNum;
116 u8 spanArm;
117 u8 resvd2[3];
118};
119
120#define RAID_CTX_SPANARM_ARM_SHIFT (0)
121#define RAID_CTX_SPANARM_ARM_MASK (0x1f)
122
123#define RAID_CTX_SPANARM_SPAN_SHIFT (5)
124#define RAID_CTX_SPANARM_SPAN_MASK (0xE0)
125
126/*
127 * define region lock types
128 */
129enum REGION_TYPE {
130 REGION_TYPE_UNUSED = 0,
131 REGION_TYPE_SHARED_READ = 1,
132 REGION_TYPE_SHARED_WRITE = 2,
133 REGION_TYPE_EXCLUSIVE = 3,
134};
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
181struct MPI25_IEEE_SGE_CHAIN64 {
182 u64 Address;
183 u32 Length;
184 u16 Reserved1;
185 u8 NextChainOffset;
186 u8 Flags;
187};
188
189struct MPI2_SGE_SIMPLE_UNION {
190 u32 FlagsLength;
191 union {
192 u32 Address32;
193 u64 Address64;
194 } u;
195};
196
197struct MPI2_SCSI_IO_CDB_EEDP32 {
198 u8 CDB[20]; /* 0x00 */
199 u32 PrimaryReferenceTag; /* 0x14 */
200 u16 PrimaryApplicationTag; /* 0x18 */
201 u16 PrimaryApplicationTagMask; /* 0x1A */
202 u32 TransferLength; /* 0x1C */
203};
204
205struct MPI2_SGE_CHAIN_UNION {
206 u16 Length;
207 u8 NextChainOffset;
208 u8 Flags;
209 union {
210 u32 Address32;
211 u64 Address64;
212 } u;
213};
214
215struct MPI2_IEEE_SGE_SIMPLE32 {
216 u32 Address;
217 u32 FlagsLength;
218};
219
220struct MPI2_IEEE_SGE_CHAIN32 {
221 u32 Address;
222 u32 FlagsLength;
223};
224
225struct MPI2_IEEE_SGE_SIMPLE64 {
226 u64 Address;
227 u32 Length;
228 u16 Reserved1;
229 u8 Reserved2;
230 u8 Flags;
231};
232
233struct MPI2_IEEE_SGE_CHAIN64 {
234 u64 Address;
235 u32 Length;
236 u16 Reserved1;
237 u8 Reserved2;
238 u8 Flags;
239};
240
241union MPI2_IEEE_SGE_SIMPLE_UNION {
242 struct MPI2_IEEE_SGE_SIMPLE32 Simple32;
243 struct MPI2_IEEE_SGE_SIMPLE64 Simple64;
244};
245
246union MPI2_IEEE_SGE_CHAIN_UNION {
247 struct MPI2_IEEE_SGE_CHAIN32 Chain32;
248 struct MPI2_IEEE_SGE_CHAIN64 Chain64;
249};
250
251union MPI2_SGE_IO_UNION {
252 struct MPI2_SGE_SIMPLE_UNION MpiSimple;
253 struct MPI2_SGE_CHAIN_UNION MpiChain;
254 union MPI2_IEEE_SGE_SIMPLE_UNION IeeeSimple;
255 union MPI2_IEEE_SGE_CHAIN_UNION IeeeChain;
256};
257
258union MPI2_SCSI_IO_CDB_UNION {
259 u8 CDB32[32];
260 struct MPI2_SCSI_IO_CDB_EEDP32 EEDP32;
261 struct MPI2_SGE_SIMPLE_UNION SGE;
262};
263
264/*
265 * RAID SCSI IO Request Message
266 * Total SGE count will be one less than _MPI2_SCSI_IO_REQUEST
267 */
268struct MPI2_RAID_SCSI_IO_REQUEST {
269 u16 DevHandle; /* 0x00 */
270 u8 ChainOffset; /* 0x02 */
271 u8 Function; /* 0x03 */
272 u16 Reserved1; /* 0x04 */
273 u8 Reserved2; /* 0x06 */
274 u8 MsgFlags; /* 0x07 */
275 u8 VP_ID; /* 0x08 */
276 u8 VF_ID; /* 0x09 */
277 u16 Reserved3; /* 0x0A */
278 u32 SenseBufferLowAddress; /* 0x0C */
279 u16 SGLFlags; /* 0x10 */
280 u8 SenseBufferLength; /* 0x12 */
281 u8 Reserved4; /* 0x13 */
282 u8 SGLOffset0; /* 0x14 */
283 u8 SGLOffset1; /* 0x15 */
284 u8 SGLOffset2; /* 0x16 */
285 u8 SGLOffset3; /* 0x17 */
286 u32 SkipCount; /* 0x18 */
287 u32 DataLength; /* 0x1C */
288 u32 BidirectionalDataLength; /* 0x20 */
289 u16 IoFlags; /* 0x24 */
290 u16 EEDPFlags; /* 0x26 */
291 u32 EEDPBlockSize; /* 0x28 */
292 u32 SecondaryReferenceTag; /* 0x2C */
293 u16 SecondaryApplicationTag; /* 0x30 */
294 u16 ApplicationTagTranslationMask; /* 0x32 */
295 u8 LUN[8]; /* 0x34 */
296 u32 Control; /* 0x3C */
297 union MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */
298 struct RAID_CONTEXT RaidContext; /* 0x60 */
299 union MPI2_SGE_IO_UNION SGL; /* 0x80 */
300};
301
302/*
303 * MPT RAID MFA IO Descriptor.
304 */
305struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +0530306#if defined(__BIG_ENDIAN_BITFIELD)
307 u32 MessageAddress1:24; /* bits 31:8*/
308 u32 RequestFlags:8;
309#else
adam radford9c915a82010-12-21 13:34:31 -0800310 u32 RequestFlags:8;
311 u32 MessageAddress1:24; /* bits 31:8*/
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +0530312#endif
adam radford9c915a82010-12-21 13:34:31 -0800313 u32 MessageAddress2; /* bits 61:32 */
314};
315
316/* Default Request Descriptor */
317struct MPI2_DEFAULT_REQUEST_DESCRIPTOR {
318 u8 RequestFlags; /* 0x00 */
319 u8 MSIxIndex; /* 0x01 */
320 u16 SMID; /* 0x02 */
321 u16 LMID; /* 0x04 */
322 u16 DescriptorTypeDependent; /* 0x06 */
323};
324
325/* High Priority Request Descriptor */
326struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR {
327 u8 RequestFlags; /* 0x00 */
328 u8 MSIxIndex; /* 0x01 */
329 u16 SMID; /* 0x02 */
330 u16 LMID; /* 0x04 */
331 u16 Reserved1; /* 0x06 */
332};
333
334/* SCSI IO Request Descriptor */
335struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR {
336 u8 RequestFlags; /* 0x00 */
337 u8 MSIxIndex; /* 0x01 */
338 u16 SMID; /* 0x02 */
339 u16 LMID; /* 0x04 */
340 u16 DevHandle; /* 0x06 */
341};
342
343/* SCSI Target Request Descriptor */
344struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR {
345 u8 RequestFlags; /* 0x00 */
346 u8 MSIxIndex; /* 0x01 */
347 u16 SMID; /* 0x02 */
348 u16 LMID; /* 0x04 */
349 u16 IoIndex; /* 0x06 */
350};
351
352/* RAID Accelerator Request Descriptor */
353struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {
354 u8 RequestFlags; /* 0x00 */
355 u8 MSIxIndex; /* 0x01 */
356 u16 SMID; /* 0x02 */
357 u16 LMID; /* 0x04 */
358 u16 Reserved; /* 0x06 */
359};
360
361/* union of Request Descriptors */
362union MEGASAS_REQUEST_DESCRIPTOR_UNION {
363 struct MPI2_DEFAULT_REQUEST_DESCRIPTOR Default;
364 struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR HighPriority;
365 struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR SCSIIO;
366 struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR SCSITarget;
367 struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR RAIDAccelerator;
368 struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR MFAIo;
369 union {
370 struct {
371 u32 low;
372 u32 high;
373 } u;
374 u64 Words;
375 };
376};
377
378/* Default Reply Descriptor */
379struct MPI2_DEFAULT_REPLY_DESCRIPTOR {
380 u8 ReplyFlags; /* 0x00 */
381 u8 MSIxIndex; /* 0x01 */
382 u16 DescriptorTypeDependent1; /* 0x02 */
383 u32 DescriptorTypeDependent2; /* 0x04 */
384};
385
386/* Address Reply Descriptor */
387struct MPI2_ADDRESS_REPLY_DESCRIPTOR {
388 u8 ReplyFlags; /* 0x00 */
389 u8 MSIxIndex; /* 0x01 */
390 u16 SMID; /* 0x02 */
391 u32 ReplyFrameAddress; /* 0x04 */
392};
393
394/* SCSI IO Success Reply Descriptor */
395struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR {
396 u8 ReplyFlags; /* 0x00 */
397 u8 MSIxIndex; /* 0x01 */
398 u16 SMID; /* 0x02 */
399 u16 TaskTag; /* 0x04 */
400 u16 Reserved1; /* 0x06 */
401};
402
403/* TargetAssist Success Reply Descriptor */
404struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR {
405 u8 ReplyFlags; /* 0x00 */
406 u8 MSIxIndex; /* 0x01 */
407 u16 SMID; /* 0x02 */
408 u8 SequenceNumber; /* 0x04 */
409 u8 Reserved1; /* 0x05 */
410 u16 IoIndex; /* 0x06 */
411};
412
413/* Target Command Buffer Reply Descriptor */
414struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR {
415 u8 ReplyFlags; /* 0x00 */
416 u8 MSIxIndex; /* 0x01 */
417 u8 VP_ID; /* 0x02 */
418 u8 Flags; /* 0x03 */
419 u16 InitiatorDevHandle; /* 0x04 */
420 u16 IoIndex; /* 0x06 */
421};
422
423/* RAID Accelerator Success Reply Descriptor */
424struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {
425 u8 ReplyFlags; /* 0x00 */
426 u8 MSIxIndex; /* 0x01 */
427 u16 SMID; /* 0x02 */
428 u32 Reserved; /* 0x04 */
429};
430
431/* union of Reply Descriptors */
432union MPI2_REPLY_DESCRIPTORS_UNION {
433 struct MPI2_DEFAULT_REPLY_DESCRIPTOR Default;
434 struct MPI2_ADDRESS_REPLY_DESCRIPTOR AddressReply;
435 struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR SCSIIOSuccess;
436 struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR TargetAssistSuccess;
437 struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer;
438 struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR
439 RAIDAcceleratorSuccess;
440 u64 Words;
441};
442
443/* IOCInit Request message */
444struct MPI2_IOC_INIT_REQUEST {
445 u8 WhoInit; /* 0x00 */
446 u8 Reserved1; /* 0x01 */
447 u8 ChainOffset; /* 0x02 */
448 u8 Function; /* 0x03 */
449 u16 Reserved2; /* 0x04 */
450 u8 Reserved3; /* 0x06 */
451 u8 MsgFlags; /* 0x07 */
452 u8 VP_ID; /* 0x08 */
453 u8 VF_ID; /* 0x09 */
454 u16 Reserved4; /* 0x0A */
455 u16 MsgVersion; /* 0x0C */
456 u16 HeaderVersion; /* 0x0E */
457 u32 Reserved5; /* 0x10 */
458 u16 Reserved6; /* 0x14 */
459 u8 Reserved7; /* 0x16 */
460 u8 HostMSIxVectors; /* 0x17 */
461 u16 Reserved8; /* 0x18 */
462 u16 SystemRequestFrameSize; /* 0x1A */
463 u16 ReplyDescriptorPostQueueDepth; /* 0x1C */
464 u16 ReplyFreeQueueDepth; /* 0x1E */
465 u32 SenseBufferAddressHigh; /* 0x20 */
466 u32 SystemReplyAddressHigh; /* 0x24 */
467 u64 SystemRequestFrameBaseAddress; /* 0x28 */
468 u64 ReplyDescriptorPostQueueAddress;/* 0x30 */
469 u64 ReplyFreeQueueAddress; /* 0x38 */
470 u64 TimeStamp; /* 0x40 */
471};
472
473/* mrpriv defines */
474#define MR_PD_INVALID 0xFFFF
475#define MAX_SPAN_DEPTH 8
Sumit.Saxena@lsi.combc93d422013-05-22 12:35:04 +0530476#define MAX_QUAD_DEPTH MAX_SPAN_DEPTH
adam radford9c915a82010-12-21 13:34:31 -0800477#define MAX_RAIDMAP_SPAN_DEPTH (MAX_SPAN_DEPTH)
478#define MAX_ROW_SIZE 32
479#define MAX_RAIDMAP_ROW_SIZE (MAX_ROW_SIZE)
480#define MAX_LOGICAL_DRIVES 64
481#define MAX_RAIDMAP_LOGICAL_DRIVES (MAX_LOGICAL_DRIVES)
482#define MAX_RAIDMAP_VIEWS (MAX_LOGICAL_DRIVES)
483#define MAX_ARRAYS 128
484#define MAX_RAIDMAP_ARRAYS (MAX_ARRAYS)
485#define MAX_PHYSICAL_DEVICES 256
486#define MAX_RAIDMAP_PHYSICAL_DEVICES (MAX_PHYSICAL_DEVICES)
487#define MR_DCMD_LD_MAP_GET_INFO 0x0300e101
488
489struct MR_DEV_HANDLE_INFO {
490 u16 curDevHdl;
491 u8 validHandles;
492 u8 reserved;
493 u16 devHandle[2];
494};
495
496struct MR_ARRAY_INFO {
497 u16 pd[MAX_RAIDMAP_ROW_SIZE];
498};
499
500struct MR_QUAD_ELEMENT {
501 u64 logStart;
502 u64 logEnd;
503 u64 offsetInSpan;
504 u32 diff;
505 u32 reserved1;
506};
507
508struct MR_SPAN_INFO {
509 u32 noElements;
510 u32 reserved1;
511 struct MR_QUAD_ELEMENT quad[MAX_RAIDMAP_SPAN_DEPTH];
512};
513
514struct MR_LD_SPAN {
515 u64 startBlk;
516 u64 numBlks;
517 u16 arrayRef;
Sumit.Saxena@lsi.combc93d422013-05-22 12:35:04 +0530518 u8 spanRowSize;
519 u8 spanRowDataSize;
520 u8 reserved[4];
adam radford9c915a82010-12-21 13:34:31 -0800521};
522
523struct MR_SPAN_BLOCK_INFO {
524 u64 num_rows;
525 struct MR_LD_SPAN span;
526 struct MR_SPAN_INFO block_span_info;
527};
528
529struct MR_LD_RAID {
530 struct {
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +0530531#if defined(__BIG_ENDIAN_BITFIELD)
532 u32 reserved4:7;
533 u32 fpNonRWCapable:1;
534 u32 fpReadAcrossStripe:1;
535 u32 fpWriteAcrossStripe:1;
536 u32 fpReadCapable:1;
537 u32 fpWriteCapable:1;
538 u32 encryptionType:8;
539 u32 pdPiMode:4;
540 u32 ldPiMode:4;
541 u32 reserved5:3;
542 u32 fpCapable:1;
543#else
adam radford9c915a82010-12-21 13:34:31 -0800544 u32 fpCapable:1;
545 u32 reserved5:3;
546 u32 ldPiMode:4;
547 u32 pdPiMode:4;
548 u32 encryptionType:8;
549 u32 fpWriteCapable:1;
550 u32 fpReadCapable:1;
551 u32 fpWriteAcrossStripe:1;
552 u32 fpReadAcrossStripe:1;
adam radford21c9e162013-09-06 15:27:14 -0700553 u32 fpNonRWCapable:1;
554 u32 reserved4:7;
Sumit.Saxena@lsi.com94cd65d2013-09-06 15:50:52 +0530555#endif
adam radford9c915a82010-12-21 13:34:31 -0800556 } capability;
557 u32 reserved6;
558 u64 size;
559 u8 spanDepth;
560 u8 level;
561 u8 stripeShift;
562 u8 rowSize;
563 u8 rowDataSize;
564 u8 writeMode;
565 u8 PRL;
566 u8 SRL;
567 u16 targetId;
568 u8 ldState;
569 u8 regTypeReqOnWrite;
570 u8 modFactor;
adam radford36807e62011-10-08 18:15:06 -0700571 u8 regTypeReqOnRead;
adam radford9c915a82010-12-21 13:34:31 -0800572 u16 seqNum;
573
574 struct {
575 u32 ldSyncRequired:1;
576 u32 reserved:31;
577 } flags;
578
adam radford21c9e162013-09-06 15:27:14 -0700579 u8 LUN[8]; /* 0x24 8 byte LUN field used for SCSI IO's */
580 u8 fpIoTimeoutForLd;/*0x2C timeout value used by driver in FP IO*/
581 u8 reserved3[0x80-0x2D]; /* 0x2D */
adam radford9c915a82010-12-21 13:34:31 -0800582};
583
584struct MR_LD_SPAN_MAP {
585 struct MR_LD_RAID ldRaid;
586 u8 dataArmMap[MAX_RAIDMAP_ROW_SIZE];
587 struct MR_SPAN_BLOCK_INFO spanBlock[MAX_RAIDMAP_SPAN_DEPTH];
588};
589
590struct MR_FW_RAID_MAP {
591 u32 totalSize;
592 union {
593 struct {
594 u32 maxLd;
595 u32 maxSpanDepth;
596 u32 maxRowSize;
597 u32 maxPdCount;
598 u32 maxArrays;
599 } validationInfo;
600 u32 version[5];
601 u32 reserved1[5];
602 };
603
604 u32 ldCount;
605 u32 Reserved1;
606 u8 ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+
607 MAX_RAIDMAP_VIEWS];
608 u8 fpPdIoTimeoutSec;
609 u8 reserved2[7];
610 struct MR_ARRAY_INFO arMapInfo[MAX_RAIDMAP_ARRAYS];
611 struct MR_DEV_HANDLE_INFO devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
612 struct MR_LD_SPAN_MAP ldSpanMap[1];
613};
614
615struct IO_REQUEST_INFO {
616 u64 ldStartBlock;
617 u32 numBlocks;
618 u16 ldTgtId;
619 u8 isRead;
620 u16 devHandle;
621 u64 pdBlock;
622 u8 fpOkForIo;
Sumit.Saxena@lsi.combc93d422013-05-22 12:35:04 +0530623 u8 IoforUnevenSpan;
624 u8 start_span;
625 u8 reserved;
626 u64 start_row;
adam radford9c915a82010-12-21 13:34:31 -0800627};
628
629struct MR_LD_TARGET_SYNC {
630 u8 targetId;
631 u8 reserved;
632 u16 seqNum;
633};
634
635#define IEEE_SGE_FLAGS_ADDR_MASK (0x03)
636#define IEEE_SGE_FLAGS_SYSTEM_ADDR (0x00)
637#define IEEE_SGE_FLAGS_IOCDDR_ADDR (0x01)
638#define IEEE_SGE_FLAGS_IOCPLB_ADDR (0x02)
639#define IEEE_SGE_FLAGS_IOCPLBNTA_ADDR (0x03)
640#define IEEE_SGE_FLAGS_CHAIN_ELEMENT (0x80)
641#define IEEE_SGE_FLAGS_END_OF_LIST (0x40)
642
643struct megasas_register_set;
644struct megasas_instance;
645
646union desc_word {
647 u64 word;
648 struct {
649 u32 low;
650 u32 high;
651 } u;
652};
653
654struct megasas_cmd_fusion {
655 struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
656 dma_addr_t io_request_phys_addr;
657
658 union MPI2_SGE_IO_UNION *sg_frame;
659 dma_addr_t sg_frame_phys_addr;
660
661 u8 *sense;
662 dma_addr_t sense_phys_addr;
663
664 struct list_head list;
665 struct scsi_cmnd *scmd;
666 struct megasas_instance *instance;
667
668 u8 retry_for_fw_reset;
669 union MEGASAS_REQUEST_DESCRIPTOR_UNION *request_desc;
670
671 /*
672 * Context for a MFI frame.
673 * Used to get the mfi cmd from list when a MFI cmd is completed
674 */
675 u32 sync_cmd_idx;
676 u32 index;
677 u8 flags;
678};
679
680struct LD_LOAD_BALANCE_INFO {
681 u8 loadBalanceFlag;
682 u8 reserved1;
683 u16 raid1DevHandle[2];
684 atomic_t scsi_pending_cmds[2];
685 u64 last_accessed_block[2];
686};
687
Sumit.Saxena@lsi.combc93d422013-05-22 12:35:04 +0530688/* SPAN_SET is info caclulated from span info from Raid map per LD */
689typedef struct _LD_SPAN_SET {
690 u64 log_start_lba;
691 u64 log_end_lba;
692 u64 span_row_start;
693 u64 span_row_end;
694 u64 data_strip_start;
695 u64 data_strip_end;
696 u64 data_row_start;
697 u64 data_row_end;
698 u8 strip_offset[MAX_SPAN_DEPTH];
699 u32 span_row_data_width;
700 u32 diff;
701 u32 reserved[2];
702} LD_SPAN_SET, *PLD_SPAN_SET;
703
704typedef struct LOG_BLOCK_SPAN_INFO {
705 LD_SPAN_SET span_set[MAX_SPAN_DEPTH];
706} LD_SPAN_INFO, *PLD_SPAN_INFO;
707
adam radford9c915a82010-12-21 13:34:31 -0800708struct MR_FW_RAID_MAP_ALL {
709 struct MR_FW_RAID_MAP raidMap;
710 struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES - 1];
711} __attribute__ ((packed));
712
713struct fusion_context {
714 struct megasas_cmd_fusion **cmd_list;
715 struct list_head cmd_pool;
716
717 spinlock_t cmd_pool_lock;
718
719 dma_addr_t req_frames_desc_phys;
720 u8 *req_frames_desc;
721
722 struct dma_pool *io_request_frames_pool;
723 dma_addr_t io_request_frames_phys;
724 u8 *io_request_frames;
725
726 struct dma_pool *sg_dma_pool;
727 struct dma_pool *sense_dma_pool;
728
729 dma_addr_t reply_frames_desc_phys;
730 union MPI2_REPLY_DESCRIPTORS_UNION *reply_frames_desc;
731 struct dma_pool *reply_frames_desc_pool;
732
adam radfordc8e858f2011-10-08 18:15:13 -0700733 u16 last_reply_idx[MAX_MSIX_QUEUES_FUSION];
adam radford9c915a82010-12-21 13:34:31 -0800734
735 u32 reply_q_depth;
736 u32 request_alloc_sz;
737 u32 reply_alloc_sz;
738 u32 io_frames_alloc_sz;
739
740 u16 max_sge_in_main_msg;
741 u16 max_sge_in_chain;
742
743 u8 chain_offset_io_request;
744 u8 chain_offset_mfi_pthru;
745
746 struct MR_FW_RAID_MAP_ALL *ld_map[2];
747 dma_addr_t ld_map_phys[2];
748
749 u32 map_sz;
750 u8 fast_path_io;
751 struct LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES];
Sumit.Saxena@lsi.combc93d422013-05-22 12:35:04 +0530752 LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES];
adam radford9c915a82010-12-21 13:34:31 -0800753};
754
755union desc_value {
756 u64 word;
757 struct {
758 u32 low;
759 u32 high;
760 } u;
761};
762
763#endif /* _MEGARAID_SAS_FUSION_H_ */