1c4a3e0a5SBagalkote, Sreenivas /*
2c4a3e0a5SBagalkote, Sreenivas  *  Linux MegaRAID driver for SAS based RAID controllers
3c4a3e0a5SBagalkote, Sreenivas  *
4e399065bSSumit.Saxena@avagotech.com  *  Copyright (c) 2003-2013  LSI Corporation
5365597cfSShivasharan S  *  Copyright (c) 2013-2016  Avago Technologies
6365597cfSShivasharan S  *  Copyright (c) 2016-2018  Broadcom Inc.
7c4a3e0a5SBagalkote, Sreenivas  *
8c4a3e0a5SBagalkote, Sreenivas  *  This program is free software; you can redistribute it and/or
9c4a3e0a5SBagalkote, Sreenivas  *  modify it under the terms of the GNU General Public License
103f1530c1Sadam radford  *  as published by the Free Software Foundation; either version 2
113f1530c1Sadam radford  *  of the License, or (at your option) any later version.
123f1530c1Sadam radford  *
133f1530c1Sadam radford  *  This program is distributed in the hope that it will be useful,
143f1530c1Sadam radford  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
153f1530c1Sadam radford  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
163f1530c1Sadam radford  *  GNU General Public License for more details.
173f1530c1Sadam radford  *
183f1530c1Sadam radford  *  You should have received a copy of the GNU General Public License
19e399065bSSumit.Saxena@avagotech.com  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20c4a3e0a5SBagalkote, Sreenivas  *
21c4a3e0a5SBagalkote, Sreenivas  *  FILE: megaraid_sas.h
223f1530c1Sadam radford  *
23365597cfSShivasharan S  *  Authors: Broadcom Inc.
24365597cfSShivasharan S  *           Kashyap Desai <kashyap.desai@broadcom.com>
25365597cfSShivasharan S  *           Sumit Saxena <sumit.saxena@broadcom.com>
263f1530c1Sadam radford  *
27365597cfSShivasharan S  *  Send feedback to: megaraidlinux.pdl@broadcom.com
28c4a3e0a5SBagalkote, Sreenivas  */
29c4a3e0a5SBagalkote, Sreenivas 
30c4a3e0a5SBagalkote, Sreenivas #ifndef LSI_MEGARAID_SAS_H
31c4a3e0a5SBagalkote, Sreenivas #define LSI_MEGARAID_SAS_H
32c4a3e0a5SBagalkote, Sreenivas 
33a69b74d3SRandy Dunlap /*
34c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS Driver meta data
35c4a3e0a5SBagalkote, Sreenivas  */
36c9ac8e24SShivasharan S #define MEGASAS_VERSION				"07.708.03.00-rc1"
37c9ac8e24SShivasharan S #define MEGASAS_RELDATE				"March 14, 2019"
380e98936cSSumant Patro 
390e98936cSSumant Patro /*
400e98936cSSumant Patro  * Device IDs
410e98936cSSumant Patro  */
420e98936cSSumant Patro #define	PCI_DEVICE_ID_LSI_SAS1078R		0x0060
43af7a5647Sbo yang #define	PCI_DEVICE_ID_LSI_SAS1078DE		0x007C
440e98936cSSumant Patro #define	PCI_DEVICE_ID_LSI_VERDE_ZCR		0x0413
456610a6b3SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS1078GEN2		0x0078
466610a6b3SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0079GEN2		0x0079
4787911122SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0073SKINNY		0x0073
4887911122SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0071SKINNY		0x0071
499c915a8cSadam radford #define	PCI_DEVICE_ID_LSI_FUSION		0x005b
50229fe47cSadam radford #define PCI_DEVICE_ID_LSI_PLASMA		0x002f
5136807e67Sadam radford #define PCI_DEVICE_ID_LSI_INVADER		0x005d
5221d3c710SSumit.Saxena@lsi.com #define PCI_DEVICE_ID_LSI_FURY			0x005f
5390c204bcSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_INTRUDER		0x00ce
5490c204bcSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_INTRUDER_24		0x00cf
557364d34bSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_CUTLASS_52		0x0052
567364d34bSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_CUTLASS_53		0x0053
5745f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_VENTURA		    0x0014
58754f1baeSShivasharan S #define PCI_DEVICE_ID_LSI_CRUSADER		    0x0015
5945f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_HARPOON		    0x0016
6045f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_TOMCAT		    0x0017
6145f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_VENTURA_4PORT		0x001B
6245f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_CRUSADER_4PORT	0x001C
63469f72ddSShivasharan S #define PCI_DEVICE_ID_LSI_AERO_10E1		0x10e1
64469f72ddSShivasharan S #define PCI_DEVICE_ID_LSI_AERO_10E2		0x10e2
65469f72ddSShivasharan S #define PCI_DEVICE_ID_LSI_AERO_10E5		0x10e5
66469f72ddSShivasharan S #define PCI_DEVICE_ID_LSI_AERO_10E6		0x10e6
67dd807699SChandrakanth Patil #define PCI_DEVICE_ID_LSI_AERO_10E0		0x10e0
68dd807699SChandrakanth Patil #define PCI_DEVICE_ID_LSI_AERO_10E3		0x10e3
69dd807699SChandrakanth Patil #define PCI_DEVICE_ID_LSI_AERO_10E4		0x10e4
70dd807699SChandrakanth Patil #define PCI_DEVICE_ID_LSI_AERO_10E7		0x10e7
710e98936cSSumant Patro 
72c4a3e0a5SBagalkote, Sreenivas /*
7339b72c3cSSumit.Saxena@lsi.com  * Intel HBA SSDIDs
7439b72c3cSSumit.Saxena@lsi.com  */
7539b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_SSDID		0x9360
7639b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_SSDID		0x9362
7739b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_SSDID		0x9380
7839b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_SSDID		0x9381
7939b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_SSDID		0x9341
8039b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_SSDID		0x9343
817364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_SSDID		0x352B
8239b72c3cSSumit.Saxena@lsi.com 
8339b72c3cSSumit.Saxena@lsi.com /*
8490c204bcSsumit.saxena@avagotech.com  * Intruder HBA SSDIDs
8590c204bcSsumit.saxena@avagotech.com  */
8690c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID1		0x9371
8790c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID2		0x9390
8890c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID3		0x9370
8990c204bcSsumit.saxena@avagotech.com 
9090c204bcSsumit.saxena@avagotech.com /*
9139b72c3cSSumit.Saxena@lsi.com  * Intel HBA branding
9239b72c3cSSumit.Saxena@lsi.com  */
9339b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_BRANDING	\
9439b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC080"
9539b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_BRANDING	\
9639b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC040"
9739b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_BRANDING	\
9839b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3SC008"
9939b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_BRANDING	\
10039b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3MC044"
10139b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_BRANDING	\
10239b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC080"
10339b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_BRANDING	\
10439b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC040"
1057364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_BRANDING	\
1067364d34bSsumit.saxena@avagotech.com 	"Intel(R) Integrated RAID Module RMS3BC160"
10739b72c3cSSumit.Saxena@lsi.com 
10839b72c3cSSumit.Saxena@lsi.com /*
109c4a3e0a5SBagalkote, Sreenivas  * =====================================
110c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS MFI firmware definitions
111c4a3e0a5SBagalkote, Sreenivas  * =====================================
112c4a3e0a5SBagalkote, Sreenivas  */
113c4a3e0a5SBagalkote, Sreenivas 
114c4a3e0a5SBagalkote, Sreenivas /*
115c4a3e0a5SBagalkote, Sreenivas  * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for
116c4a3e0a5SBagalkote, Sreenivas  * protocol between the software and firmware. Commands are issued using
117c4a3e0a5SBagalkote, Sreenivas  * "message frames"
118c4a3e0a5SBagalkote, Sreenivas  */
119c4a3e0a5SBagalkote, Sreenivas 
120a69b74d3SRandy Dunlap /*
121c4a3e0a5SBagalkote, Sreenivas  * FW posts its state in upper 4 bits of outbound_msg_0 register
122c4a3e0a5SBagalkote, Sreenivas  */
123c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_MASK				0xF0000000
124c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_UNDEFINED			0x00000000
125c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_BB_INIT			0x10000000
126c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT			0x40000000
127c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_WAIT_HANDSHAKE		0x60000000
128c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT_2			0x70000000
129c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_DEVICE_SCAN			0x80000000
130e3bbff9fSSumant Patro #define MFI_STATE_BOOT_MESSAGE_PENDING		0x90000000
131c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FLUSH_CACHE			0xA0000000
132c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_READY				0xB0000000
133c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_OPERATIONAL			0xC0000000
134c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FAULT				0xF0000000
135fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_FORCE_OCR			0x00000080
136fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_DMADONE			0x00000008
137fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_CRASH_DUMP_DONE		0x00000004
13839a98554Sbo yang #define MFI_RESET_REQUIRED			0x00000001
1397e70e733Sadam radford #define MFI_RESET_ADAPTER			0x00000002
140c4a3e0a5SBagalkote, Sreenivas #define MEGAMFI_FRAME_SIZE			64
141c4a3e0a5SBagalkote, Sreenivas 
142b6661342SShivasharan S #define MFI_STATE_FAULT_CODE			0x0FFF0000
143b6661342SShivasharan S #define MFI_STATE_FAULT_SUBCODE			0x0000FF00
144a69b74d3SRandy Dunlap /*
145c4a3e0a5SBagalkote, Sreenivas  * During FW init, clear pending cmds & reset state using inbound_msg_0
146c4a3e0a5SBagalkote, Sreenivas  *
147c4a3e0a5SBagalkote, Sreenivas  * ABORT	: Abort all pending cmds
148c4a3e0a5SBagalkote, Sreenivas  * READY	: Move from OPERATIONAL to READY state; discard queue info
149c4a3e0a5SBagalkote, Sreenivas  * MFIMODE	: Discard (possible) low MFA posted in 64-bit mode (??)
150c4a3e0a5SBagalkote, Sreenivas  * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
151e3bbff9fSSumant Patro  * HOTPLUG	: Resume from Hotplug
152e3bbff9fSSumant Patro  * MFI_STOP_ADP	: Send signal to FW to stop processing
153f0c21df6SShivasharan S  * MFI_ADP_TRIGGER_SNAP_DUMP: Inform firmware to initiate snap dump
154c4a3e0a5SBagalkote, Sreenivas  */
15539a98554Sbo yang #define WRITE_SEQUENCE_OFFSET		(0x0000000FC) /* I20 */
15639a98554Sbo yang #define HOST_DIAGNOSTIC_OFFSET		(0x000000F8)  /* I20 */
15739a98554Sbo yang #define DIAG_WRITE_ENABLE			(0x00000080)
15839a98554Sbo yang #define DIAG_RESET_ADAPTER			(0x00000004)
15939a98554Sbo yang 
16039a98554Sbo yang #define MFI_ADP_RESET				0x00000040
161e3bbff9fSSumant Patro #define MFI_INIT_ABORT				0x00000001
162c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_READY				0x00000002
163c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_MFIMODE			0x00000004
164c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_CLEAR_HANDSHAKE		0x00000008
165e3bbff9fSSumant Patro #define MFI_INIT_HOTPLUG			0x00000010
166e3bbff9fSSumant Patro #define MFI_STOP_ADP				0x00000020
167e3bbff9fSSumant Patro #define MFI_RESET_FLAGS				MFI_INIT_READY| \
168e3bbff9fSSumant Patro 						MFI_INIT_MFIMODE| \
169e3bbff9fSSumant Patro 						MFI_INIT_ABORT
170f0c21df6SShivasharan S #define MFI_ADP_TRIGGER_SNAP_DUMP		0x00000100
171179ac142SSumit Saxena #define MPI2_IOCINIT_MSGFLAG_RDPQ_ARRAY_MODE    (0x01)
172c4a3e0a5SBagalkote, Sreenivas 
173a69b74d3SRandy Dunlap /*
174c4a3e0a5SBagalkote, Sreenivas  * MFI frame flags
175c4a3e0a5SBagalkote, Sreenivas  */
176c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_POST_IN_REPLY_QUEUE		0x0000
177c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE	0x0001
178c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL32				0x0000
179c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL64				0x0002
180c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE32			0x0000
181c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE64			0x0004
182c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_NONE			0x0000
183c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_WRITE			0x0008
184c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_READ			0x0010
185c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_BOTH			0x0018
186f4c9a131SYang, Bo #define MFI_FRAME_IEEE                          0x0020
187c4a3e0a5SBagalkote, Sreenivas 
1884026e9aaSSumit.Saxena@avagotech.com /* Driver internal */
1894026e9aaSSumit.Saxena@avagotech.com #define DRV_DCMD_POLLED_MODE		0x1
1906d40afbcSSumit Saxena #define DRV_DCMD_SKIP_REFIRE		0x2
1914026e9aaSSumit.Saxena@avagotech.com 
192a69b74d3SRandy Dunlap /*
193c4a3e0a5SBagalkote, Sreenivas  * Definition for cmd_status
194c4a3e0a5SBagalkote, Sreenivas  */
195c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_STATUS_POLL_MODE		0xFF
196c4a3e0a5SBagalkote, Sreenivas 
197a69b74d3SRandy Dunlap /*
198c4a3e0a5SBagalkote, Sreenivas  * MFI command opcodes
199c4a3e0a5SBagalkote, Sreenivas  */
20082add4e1SShivasharan S enum MFI_CMD_OP {
20182add4e1SShivasharan S 	MFI_CMD_INIT		= 0x0,
20282add4e1SShivasharan S 	MFI_CMD_LD_READ		= 0x1,
20382add4e1SShivasharan S 	MFI_CMD_LD_WRITE	= 0x2,
20482add4e1SShivasharan S 	MFI_CMD_LD_SCSI_IO	= 0x3,
20582add4e1SShivasharan S 	MFI_CMD_PD_SCSI_IO	= 0x4,
20682add4e1SShivasharan S 	MFI_CMD_DCMD		= 0x5,
20782add4e1SShivasharan S 	MFI_CMD_ABORT		= 0x6,
20882add4e1SShivasharan S 	MFI_CMD_SMP		= 0x7,
20982add4e1SShivasharan S 	MFI_CMD_STP		= 0x8,
210f870bcbeSShivasharan S 	MFI_CMD_NVME		= 0x9,
21158136856SChandrakanth Patil 	MFI_CMD_TOOLBOX		= 0xa,
21282add4e1SShivasharan S 	MFI_CMD_OP_COUNT,
21382add4e1SShivasharan S 	MFI_CMD_INVALID		= 0xff
21482add4e1SShivasharan S };
215c4a3e0a5SBagalkote, Sreenivas 
216c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_GET_INFO			0x01010000
217bdc6fb8dSYang, Bo #define MR_DCMD_LD_GET_LIST			0x03010000
21821c9e160Sadam radford #define MR_DCMD_LD_LIST_QUERY			0x03010100
219c4a3e0a5SBagalkote, Sreenivas 
220c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_CACHE_FLUSH		0x01101000
221c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_CTRL_CACHE			0x01
222c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_DISK_CACHE			0x02
223c4a3e0a5SBagalkote, Sreenivas 
224c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_SHUTDOWN			0x01050000
22531ea7088Sbo yang #define MR_DCMD_HIBERNATE_SHUTDOWN		0x01060000
226c4a3e0a5SBagalkote, Sreenivas #define MR_ENABLE_DRIVE_SPINDOWN		0x01
227c4a3e0a5SBagalkote, Sreenivas 
228c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET_INFO		0x01040100
229c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET			0x01040300
230c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_WAIT			0x01040500
231c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_LD_GET_PROPERTIES		0x03030000
232c4a3e0a5SBagalkote, Sreenivas 
233c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER				0x08000000
234c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_ALL		0x08010100
235c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_LD		0x08010200
23681e403ceSYang, Bo #define MR_DCMD_PD_LIST_QUERY                   0x02010100
237c4a3e0a5SBagalkote, Sreenivas 
238fc62b3fcSSumit.Saxena@avagotech.com #define MR_DCMD_CTRL_SET_CRASH_DUMP_PARAMS	0x01190100
239fc62b3fcSSumit.Saxena@avagotech.com #define MR_DRIVER_SET_APP_CRASHDUMP_MODE	(0xF0010000 | 0x0600)
2402216c305SSumit Saxena #define MR_DCMD_PD_GET_INFO			0x02020000
241fc62b3fcSSumit.Saxena@avagotech.com 
242a69b74d3SRandy Dunlap /*
243bc93d425SSumit.Saxena@lsi.com  * Global functions
244bc93d425SSumit.Saxena@lsi.com  */
2455f19f7c8SShivasharan S extern u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id);
246bc93d425SSumit.Saxena@lsi.com 
247bc93d425SSumit.Saxena@lsi.com 
248bc93d425SSumit.Saxena@lsi.com /*
249c4a3e0a5SBagalkote, Sreenivas  * MFI command completion codes
250c4a3e0a5SBagalkote, Sreenivas  */
251c4a3e0a5SBagalkote, Sreenivas enum MFI_STAT {
252c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_OK = 0x00,
253c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_CMD = 0x01,
254c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_DCMD = 0x02,
255c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_PARAMETER = 0x03,
256c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
257c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
258c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
259c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_IN_USE = 0x07,
260c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_NOT_INITIALIZED = 0x08,
261c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
262c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
263c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
264c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
265c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
266c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
267c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_BUSY = 0x0f,
268c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ERROR = 0x10,
269c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_BAD = 0x11,
270c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
271c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_OPEN = 0x13,
272c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_STARTED = 0x14,
273c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLUSH_FAILED = 0x15,
274c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
275c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
276c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
277c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
278c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
279c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
280c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
281c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
282c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
283c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
284c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
285c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MFC_HW_ERROR = 0x21,
286c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NO_HW_PRESENT = 0x22,
287c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_FOUND = 0x23,
288c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_IN_ENCL = 0x24,
289c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
290c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_TYPE_WRONG = 0x26,
291c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PR_DISABLED = 0x27,
292c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ROW_INDEX_INVALID = 0x28,
293c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
294c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
295c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
296c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
297c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
298c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_IO_FAILED = 0x2e,
299c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
300c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SHUTDOWN_FAILED = 0x30,
301c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_TIME_NOT_SET = 0x31,
302c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_WRONG_STATE = 0x32,
303c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_OFFLINE = 0x33,
304c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
305c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
306c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
307c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
308c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
30936807e67Sadam radford 	MFI_STAT_CONFIG_SEQ_MISMATCH = 0x67,
310c4a3e0a5SBagalkote, Sreenivas 
311c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_STATUS = 0xFF
312c4a3e0a5SBagalkote, Sreenivas };
313c4a3e0a5SBagalkote, Sreenivas 
314714f5177Ssumit.saxena@avagotech.com enum mfi_evt_class {
315714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEBUG =		-2,
316714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_PROGRESS =	-1,
317714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_INFO =		0,
318714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_WARNING =		1,
319714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_CRITICAL =	2,
320714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_FATAL =		3,
321714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEAD =		4
322714f5177Ssumit.saxena@avagotech.com };
323714f5177Ssumit.saxena@avagotech.com 
324c4a3e0a5SBagalkote, Sreenivas /*
325fc62b3fcSSumit.Saxena@avagotech.com  * Crash dump related defines
326fc62b3fcSSumit.Saxena@avagotech.com  */
327fc62b3fcSSumit.Saxena@avagotech.com #define MAX_CRASH_DUMP_SIZE 512
328fc62b3fcSSumit.Saxena@avagotech.com #define CRASH_DMA_BUF_SIZE  (1024 * 1024)
329fc62b3fcSSumit.Saxena@avagotech.com 
330fc62b3fcSSumit.Saxena@avagotech.com enum MR_FW_CRASH_DUMP_STATE {
331fc62b3fcSSumit.Saxena@avagotech.com 	UNAVAILABLE = 0,
332fc62b3fcSSumit.Saxena@avagotech.com 	AVAILABLE = 1,
333fc62b3fcSSumit.Saxena@avagotech.com 	COPYING = 2,
334fc62b3fcSSumit.Saxena@avagotech.com 	COPIED = 3,
335fc62b3fcSSumit.Saxena@avagotech.com 	COPY_ERROR = 4,
336fc62b3fcSSumit.Saxena@avagotech.com };
337fc62b3fcSSumit.Saxena@avagotech.com 
338fc62b3fcSSumit.Saxena@avagotech.com enum _MR_CRASH_BUF_STATUS {
339fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_OFF = 0,
340fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_ON = 1,
341fc62b3fcSSumit.Saxena@avagotech.com };
342fc62b3fcSSumit.Saxena@avagotech.com 
343fc62b3fcSSumit.Saxena@avagotech.com /*
344c4a3e0a5SBagalkote, Sreenivas  * Number of mailbox bytes in DCMD message frame
345c4a3e0a5SBagalkote, Sreenivas  */
346c4a3e0a5SBagalkote, Sreenivas #define MFI_MBOX_SIZE				12
347c4a3e0a5SBagalkote, Sreenivas 
348c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_CLASS {
349c4a3e0a5SBagalkote, Sreenivas 
350c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEBUG = -2,
351c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_PROGRESS = -1,
352c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_INFO = 0,
353c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_WARNING = 1,
354c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_CRITICAL = 2,
355c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_FATAL = 3,
356c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEAD = 4,
357c4a3e0a5SBagalkote, Sreenivas 
358c4a3e0a5SBagalkote, Sreenivas };
359c4a3e0a5SBagalkote, Sreenivas 
360c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_LOCALE {
361c4a3e0a5SBagalkote, Sreenivas 
362c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_LD = 0x0001,
363c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_PD = 0x0002,
364c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ENCL = 0x0004,
365c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_BBU = 0x0008,
366c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_SAS = 0x0010,
367c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CTRL = 0x0020,
368c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CONFIG = 0x0040,
369c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CLUSTER = 0x0080,
370c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ALL = 0xffff,
371c4a3e0a5SBagalkote, Sreenivas 
372c4a3e0a5SBagalkote, Sreenivas };
373c4a3e0a5SBagalkote, Sreenivas 
374c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_ARGS {
375c4a3e0a5SBagalkote, Sreenivas 
376c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_NONE,
377c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_CDB_SENSE,
378c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD,
379c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_COUNT,
380c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA,
381c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_OWNER,
382c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA_PD_LBA,
383c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_PROG,
384c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STATE,
385c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STRIP,
386c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD,
387c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_ERR,
388c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA,
389c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA_LD,
390c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_PROG,
391c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_STATE,
392c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PCI,
393c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_RATE,
394c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_STR,
395c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_TIME,
396c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_ECC,
39781e403ceSYang, Bo 	MR_EVT_ARGS_LD_PROP,
39881e403ceSYang, Bo 	MR_EVT_ARGS_PD_SPARE,
39981e403ceSYang, Bo 	MR_EVT_ARGS_PD_INDEX,
40081e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_PASS,
40181e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_FAIL,
40281e403ceSYang, Bo 	MR_EVT_ARGS_PD_LBA_LBA,
40381e403ceSYang, Bo 	MR_EVT_ARGS_PORT_PHY,
40481e403ceSYang, Bo 	MR_EVT_ARGS_PD_MISSING,
40581e403ceSYang, Bo 	MR_EVT_ARGS_PD_ADDRESS,
40681e403ceSYang, Bo 	MR_EVT_ARGS_BITMAP,
40781e403ceSYang, Bo 	MR_EVT_ARGS_CONNECTOR,
40881e403ceSYang, Bo 	MR_EVT_ARGS_PD_PD,
40981e403ceSYang, Bo 	MR_EVT_ARGS_PD_FRU,
41081e403ceSYang, Bo 	MR_EVT_ARGS_PD_PATHINFO,
41181e403ceSYang, Bo 	MR_EVT_ARGS_PD_POWER_STATE,
41281e403ceSYang, Bo 	MR_EVT_ARGS_GENERIC,
413c4a3e0a5SBagalkote, Sreenivas };
414c4a3e0a5SBagalkote, Sreenivas 
415357ae967Ssumit.saxena@avagotech.com 
416357ae967Ssumit.saxena@avagotech.com #define SGE_BUFFER_SIZE	4096
4178f67c8c5SSumit Saxena #define MEGASAS_CLUSTER_ID_SIZE	16
418c4a3e0a5SBagalkote, Sreenivas /*
41981e403ceSYang, Bo  * define constants for device list query options
42081e403ceSYang, Bo  */
42181e403ceSYang, Bo enum MR_PD_QUERY_TYPE {
42281e403ceSYang, Bo 	MR_PD_QUERY_TYPE_ALL                = 0,
42381e403ceSYang, Bo 	MR_PD_QUERY_TYPE_STATE              = 1,
42481e403ceSYang, Bo 	MR_PD_QUERY_TYPE_POWER_STATE        = 2,
42581e403ceSYang, Bo 	MR_PD_QUERY_TYPE_MEDIA_TYPE         = 3,
42681e403ceSYang, Bo 	MR_PD_QUERY_TYPE_SPEED              = 4,
42781e403ceSYang, Bo 	MR_PD_QUERY_TYPE_EXPOSED_TO_HOST    = 5,
42881e403ceSYang, Bo };
42981e403ceSYang, Bo 
43021c9e160Sadam radford enum MR_LD_QUERY_TYPE {
43121c9e160Sadam radford 	MR_LD_QUERY_TYPE_ALL	         = 0,
43221c9e160Sadam radford 	MR_LD_QUERY_TYPE_EXPOSED_TO_HOST = 1,
43321c9e160Sadam radford 	MR_LD_QUERY_TYPE_USED_TGT_IDS    = 2,
43421c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_ACCESS  = 3,
43521c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_LOCALE  = 4,
43621c9e160Sadam radford };
43721c9e160Sadam radford 
43821c9e160Sadam radford 
4397e8a75f4SYang, Bo #define MR_EVT_CFG_CLEARED                              0x0004
4407e8a75f4SYang, Bo #define MR_EVT_LD_STATE_CHANGE                          0x0051
4417e8a75f4SYang, Bo #define MR_EVT_PD_INSERTED                              0x005b
4427e8a75f4SYang, Bo #define MR_EVT_PD_REMOVED                               0x0070
4437e8a75f4SYang, Bo #define MR_EVT_LD_CREATED                               0x008a
4447e8a75f4SYang, Bo #define MR_EVT_LD_DELETED                               0x008b
4457e8a75f4SYang, Bo #define MR_EVT_FOREIGN_CFG_IMPORTED                     0x00db
4467e8a75f4SYang, Bo #define MR_EVT_LD_OFFLINE                               0x00fc
4477e8a75f4SYang, Bo #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED             0x0152
448c4bd2654Ssumit.saxena@avagotech.com #define MR_EVT_CTRL_PROP_CHANGED			0x012f
4497e8a75f4SYang, Bo 
45081e403ceSYang, Bo enum MR_PD_STATE {
45181e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_GOOD   = 0x00,
45281e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_BAD    = 0x01,
45381e403ceSYang, Bo 	MR_PD_STATE_HOT_SPARE           = 0x02,
45481e403ceSYang, Bo 	MR_PD_STATE_OFFLINE             = 0x10,
45581e403ceSYang, Bo 	MR_PD_STATE_FAILED              = 0x11,
45681e403ceSYang, Bo 	MR_PD_STATE_REBUILD             = 0x14,
45781e403ceSYang, Bo 	MR_PD_STATE_ONLINE              = 0x18,
45881e403ceSYang, Bo 	MR_PD_STATE_COPYBACK            = 0x20,
45981e403ceSYang, Bo 	MR_PD_STATE_SYSTEM              = 0x40,
46081e403ceSYang, Bo  };
46181e403ceSYang, Bo 
4622216c305SSumit Saxena union MR_PD_REF {
4632216c305SSumit Saxena 	struct {
4642216c305SSumit Saxena 		u16	 deviceId;
4652216c305SSumit Saxena 		u16	 seqNum;
4662216c305SSumit Saxena 	} mrPdRef;
4672216c305SSumit Saxena 	u32	 ref;
4682216c305SSumit Saxena };
4692216c305SSumit Saxena 
4702216c305SSumit Saxena /*
4712216c305SSumit Saxena  * define the DDF Type bit structure
4722216c305SSumit Saxena  */
4732216c305SSumit Saxena union MR_PD_DDF_TYPE {
4742216c305SSumit Saxena 	 struct {
4752216c305SSumit Saxena 		union {
4762216c305SSumit Saxena 			struct {
4772216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
4782216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4792216c305SSumit Saxena 				 u16	 inVD:1;
4802216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4812216c305SSumit Saxena 				 u16	 isSpare:1;
4822216c305SSumit Saxena 				 u16	 isForeign:1;
4832216c305SSumit Saxena 				 u16	 reserved:7;
4842216c305SSumit Saxena 				 u16	 intf:4;
4852216c305SSumit Saxena #else
4862216c305SSumit Saxena 				 u16	 intf:4;
4872216c305SSumit Saxena 				 u16	 reserved:7;
4882216c305SSumit Saxena 				 u16	 isForeign:1;
4892216c305SSumit Saxena 				 u16	 isSpare:1;
4902216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4912216c305SSumit Saxena 				 u16	 inVD:1;
4922216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4932216c305SSumit Saxena #endif
4942216c305SSumit Saxena 			 } pdType;
4952216c305SSumit Saxena 			 u16	 type;
4962216c305SSumit Saxena 		 };
4972216c305SSumit Saxena 		 u16	 reserved;
4982216c305SSumit Saxena 	 } ddf;
4992216c305SSumit Saxena 	 struct {
5002216c305SSumit Saxena 		 u32	reserved;
5012216c305SSumit Saxena 	 } nonDisk;
5022216c305SSumit Saxena 	 u32	 type;
5032216c305SSumit Saxena } __packed;
5042216c305SSumit Saxena 
5052216c305SSumit Saxena /*
5062216c305SSumit Saxena  * defines the progress structure
5072216c305SSumit Saxena  */
5082216c305SSumit Saxena union MR_PROGRESS {
5092216c305SSumit Saxena 	struct  {
5102216c305SSumit Saxena 		u16 progress;
5112216c305SSumit Saxena 		union {
5122216c305SSumit Saxena 			u16 elapsedSecs;
5132216c305SSumit Saxena 			u16 elapsedSecsForLastPercent;
5142216c305SSumit Saxena 		};
5152216c305SSumit Saxena 	} mrProgress;
5162216c305SSumit Saxena 	u32 w;
5172216c305SSumit Saxena } __packed;
5182216c305SSumit Saxena 
5192216c305SSumit Saxena /*
5202216c305SSumit Saxena  * defines the physical drive progress structure
5212216c305SSumit Saxena  */
5222216c305SSumit Saxena struct MR_PD_PROGRESS {
5232216c305SSumit Saxena 	struct {
5242216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5252216c305SSumit Saxena 		u32     rbld:1;
5262216c305SSumit Saxena 		u32     patrol:1;
5272216c305SSumit Saxena 		u32     clear:1;
5282216c305SSumit Saxena 		u32     copyBack:1;
5292216c305SSumit Saxena 		u32     erase:1;
5302216c305SSumit Saxena 		u32     locate:1;
5312216c305SSumit Saxena 		u32     reserved:26;
5322216c305SSumit Saxena #else
5332216c305SSumit Saxena 		u32     reserved:26;
5342216c305SSumit Saxena 		u32     locate:1;
5352216c305SSumit Saxena 		u32     erase:1;
5362216c305SSumit Saxena 		u32     copyBack:1;
5372216c305SSumit Saxena 		u32     clear:1;
5382216c305SSumit Saxena 		u32     patrol:1;
5392216c305SSumit Saxena 		u32     rbld:1;
5402216c305SSumit Saxena #endif
5412216c305SSumit Saxena 	} active;
5422216c305SSumit Saxena 	union MR_PROGRESS     rbld;
5432216c305SSumit Saxena 	union MR_PROGRESS     patrol;
5442216c305SSumit Saxena 	union {
5452216c305SSumit Saxena 		union MR_PROGRESS     clear;
5462216c305SSumit Saxena 		union MR_PROGRESS     erase;
5472216c305SSumit Saxena 	};
5482216c305SSumit Saxena 
5492216c305SSumit Saxena 	struct {
5502216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5512216c305SSumit Saxena 		u32     rbld:1;
5522216c305SSumit Saxena 		u32     patrol:1;
5532216c305SSumit Saxena 		u32     clear:1;
5542216c305SSumit Saxena 		u32     copyBack:1;
5552216c305SSumit Saxena 		u32     erase:1;
5562216c305SSumit Saxena 		u32     reserved:27;
5572216c305SSumit Saxena #else
5582216c305SSumit Saxena 		u32     reserved:27;
5592216c305SSumit Saxena 		u32     erase:1;
5602216c305SSumit Saxena 		u32     copyBack:1;
5612216c305SSumit Saxena 		u32     clear:1;
5622216c305SSumit Saxena 		u32     patrol:1;
5632216c305SSumit Saxena 		u32     rbld:1;
5642216c305SSumit Saxena #endif
5652216c305SSumit Saxena 	} pause;
5662216c305SSumit Saxena 
5672216c305SSumit Saxena 	union MR_PROGRESS     reserved[3];
5682216c305SSumit Saxena } __packed;
5692216c305SSumit Saxena 
5702216c305SSumit Saxena struct  MR_PD_INFO {
5712216c305SSumit Saxena 	union MR_PD_REF	ref;
5722216c305SSumit Saxena 	u8 inquiryData[96];
5732216c305SSumit Saxena 	u8 vpdPage83[64];
5742216c305SSumit Saxena 	u8 notSupported;
5752216c305SSumit Saxena 	u8 scsiDevType;
5762216c305SSumit Saxena 
5772216c305SSumit Saxena 	union {
5782216c305SSumit Saxena 		u8 connectedPortBitmap;
5792216c305SSumit Saxena 		u8 connectedPortNumbers;
5802216c305SSumit Saxena 	};
5812216c305SSumit Saxena 
5822216c305SSumit Saxena 	u8 deviceSpeed;
5832216c305SSumit Saxena 	u32 mediaErrCount;
5842216c305SSumit Saxena 	u32 otherErrCount;
5852216c305SSumit Saxena 	u32 predFailCount;
5862216c305SSumit Saxena 	u32 lastPredFailEventSeqNum;
5872216c305SSumit Saxena 
5882216c305SSumit Saxena 	u16 fwState;
5892216c305SSumit Saxena 	u8 disabledForRemoval;
5902216c305SSumit Saxena 	u8 linkSpeed;
5912216c305SSumit Saxena 	union MR_PD_DDF_TYPE state;
5922216c305SSumit Saxena 
5932216c305SSumit Saxena 	struct {
5942216c305SSumit Saxena 		u8 count;
5952216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
5962216c305SSumit Saxena 		u8 isPathBroken:4;
5972216c305SSumit Saxena 		u8 reserved3:3;
5982216c305SSumit Saxena 		u8 widePortCapable:1;
5992216c305SSumit Saxena #else
6002216c305SSumit Saxena 		u8 widePortCapable:1;
6012216c305SSumit Saxena 		u8 reserved3:3;
6022216c305SSumit Saxena 		u8 isPathBroken:4;
6032216c305SSumit Saxena #endif
6042216c305SSumit Saxena 
6052216c305SSumit Saxena 		u8 connectorIndex[2];
6062216c305SSumit Saxena 		u8 reserved[4];
6072216c305SSumit Saxena 		u64 sasAddr[2];
6082216c305SSumit Saxena 		u8 reserved2[16];
6092216c305SSumit Saxena 	} pathInfo;
6102216c305SSumit Saxena 
6112216c305SSumit Saxena 	u64 rawSize;
6122216c305SSumit Saxena 	u64 nonCoercedSize;
6132216c305SSumit Saxena 	u64 coercedSize;
6142216c305SSumit Saxena 	u16 enclDeviceId;
6152216c305SSumit Saxena 	u8 enclIndex;
6162216c305SSumit Saxena 
6172216c305SSumit Saxena 	union {
6182216c305SSumit Saxena 		u8 slotNumber;
6192216c305SSumit Saxena 		u8 enclConnectorIndex;
6202216c305SSumit Saxena 	};
6212216c305SSumit Saxena 
6222216c305SSumit Saxena 	struct MR_PD_PROGRESS progInfo;
6232216c305SSumit Saxena 	u8 badBlockTableFull;
6242216c305SSumit Saxena 	u8 unusableInCurrentConfig;
6252216c305SSumit Saxena 	u8 vpdPage83Ext[64];
6262216c305SSumit Saxena 	u8 powerState;
6272216c305SSumit Saxena 	u8 enclPosition;
6282216c305SSumit Saxena 	u32 allowedOps;
6292216c305SSumit Saxena 	u16 copyBackPartnerId;
6302216c305SSumit Saxena 	u16 enclPartnerDeviceId;
6312216c305SSumit Saxena 	struct {
6322216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6332216c305SSumit Saxena 		u16 fdeCapable:1;
6342216c305SSumit Saxena 		u16 fdeEnabled:1;
6352216c305SSumit Saxena 		u16 secured:1;
6362216c305SSumit Saxena 		u16 locked:1;
6372216c305SSumit Saxena 		u16 foreign:1;
6382216c305SSumit Saxena 		u16 needsEKM:1;
6392216c305SSumit Saxena 		u16 reserved:10;
6402216c305SSumit Saxena #else
6412216c305SSumit Saxena 		u16 reserved:10;
6422216c305SSumit Saxena 		u16 needsEKM:1;
6432216c305SSumit Saxena 		u16 foreign:1;
6442216c305SSumit Saxena 		u16 locked:1;
6452216c305SSumit Saxena 		u16 secured:1;
6462216c305SSumit Saxena 		u16 fdeEnabled:1;
6472216c305SSumit Saxena 		u16 fdeCapable:1;
6482216c305SSumit Saxena #endif
6492216c305SSumit Saxena 	} security;
6502216c305SSumit Saxena 	u8 mediaType;
6512216c305SSumit Saxena 	u8 notCertified;
6522216c305SSumit Saxena 	u8 bridgeVendor[8];
6532216c305SSumit Saxena 	u8 bridgeProductIdentification[16];
6542216c305SSumit Saxena 	u8 bridgeProductRevisionLevel[4];
6552216c305SSumit Saxena 	u8 satBridgeExists;
6562216c305SSumit Saxena 
6572216c305SSumit Saxena 	u8 interfaceType;
6582216c305SSumit Saxena 	u8 temperature;
6592216c305SSumit Saxena 	u8 emulatedBlockSize;
6602216c305SSumit Saxena 	u16 userDataBlockSize;
6612216c305SSumit Saxena 	u16 reserved2;
6622216c305SSumit Saxena 
6632216c305SSumit Saxena 	struct {
6642216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6652216c305SSumit Saxena 		u32 piType:3;
6662216c305SSumit Saxena 		u32 piFormatted:1;
6672216c305SSumit Saxena 		u32 piEligible:1;
6682216c305SSumit Saxena 		u32 NCQ:1;
6692216c305SSumit Saxena 		u32 WCE:1;
6702216c305SSumit Saxena 		u32 commissionedSpare:1;
6712216c305SSumit Saxena 		u32 emergencySpare:1;
6722216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6732216c305SSumit Saxena 		u32 ineligibleForLd:1;
6742216c305SSumit Saxena 		u32 useSSEraseType:1;
6752216c305SSumit Saxena 		u32 wceUnchanged:1;
6762216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6772216c305SSumit Saxena 		u32 reserved:18;
6782216c305SSumit Saxena #else
6792216c305SSumit Saxena 		u32 reserved:18;
6802216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6812216c305SSumit Saxena 		u32 wceUnchanged:1;
6822216c305SSumit Saxena 		u32 useSSEraseType:1;
6832216c305SSumit Saxena 		u32 ineligibleForLd:1;
6842216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6852216c305SSumit Saxena 		u32 emergencySpare:1;
6862216c305SSumit Saxena 		u32 commissionedSpare:1;
6872216c305SSumit Saxena 		u32 WCE:1;
6882216c305SSumit Saxena 		u32 NCQ:1;
6892216c305SSumit Saxena 		u32 piEligible:1;
6902216c305SSumit Saxena 		u32 piFormatted:1;
6912216c305SSumit Saxena 		u32 piType:3;
6922216c305SSumit Saxena #endif
6932216c305SSumit Saxena 	} properties;
6942216c305SSumit Saxena 
6952216c305SSumit Saxena 	u64 shieldDiagCompletionTime;
6962216c305SSumit Saxena 	u8 shieldCounter;
6972216c305SSumit Saxena 
6982216c305SSumit Saxena 	u8 linkSpeedOther;
6992216c305SSumit Saxena 	u8 reserved4[2];
7002216c305SSumit Saxena 
7012216c305SSumit Saxena 	struct {
7022216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
7032216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
7042216c305SSumit Saxena 		u32 bbmErrCount:31;
7052216c305SSumit Saxena #else
7062216c305SSumit Saxena 		u32 bbmErrCount:31;
7072216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
7082216c305SSumit Saxena #endif
7092216c305SSumit Saxena 	} bbmErr;
7102216c305SSumit Saxena 
7112216c305SSumit Saxena 	u8 reserved1[512-428];
7122216c305SSumit Saxena } __packed;
71381e403ceSYang, Bo 
71481e403ceSYang, Bo /*
71596188a89SShivasharan S  * Definition of structure used to expose attributes of VD or JBOD
71696188a89SShivasharan S  * (this structure is to be filled by firmware when MR_DCMD_DRV_GET_TARGET_PROP
71796188a89SShivasharan S  * is fired by driver)
71896188a89SShivasharan S  */
71996188a89SShivasharan S struct MR_TARGET_PROPERTIES {
72096188a89SShivasharan S 	u32    max_io_size_kb;
72196188a89SShivasharan S 	u32    device_qdepth;
72296188a89SShivasharan S 	u32    sector_size;
723e9495e2dSShivasharan S 	u8     reset_tmo;
724e9495e2dSShivasharan S 	u8     reserved[499];
72596188a89SShivasharan S } __packed;
72696188a89SShivasharan S 
72796188a89SShivasharan S  /*
72881e403ceSYang, Bo  * defines the physical drive address structure
72981e403ceSYang, Bo  */
73081e403ceSYang, Bo struct MR_PD_ADDRESS {
7319ab9ed38SChristoph Hellwig 	__le16	deviceId;
73281e403ceSYang, Bo 	u16     enclDeviceId;
73381e403ceSYang, Bo 
73481e403ceSYang, Bo 	union {
73581e403ceSYang, Bo 		struct {
73681e403ceSYang, Bo 			u8  enclIndex;
73781e403ceSYang, Bo 			u8  slotNumber;
73881e403ceSYang, Bo 		} mrPdAddress;
73981e403ceSYang, Bo 		struct {
74081e403ceSYang, Bo 			u8  enclPosition;
74181e403ceSYang, Bo 			u8  enclConnectorIndex;
74281e403ceSYang, Bo 		} mrEnclAddress;
74381e403ceSYang, Bo 	};
74481e403ceSYang, Bo 	u8      scsiDevType;
74581e403ceSYang, Bo 	union {
74681e403ceSYang, Bo 		u8      connectedPortBitmap;
74781e403ceSYang, Bo 		u8      connectedPortNumbers;
74881e403ceSYang, Bo 	};
74981e403ceSYang, Bo 	u64     sasAddr[2];
75081e403ceSYang, Bo } __packed;
75181e403ceSYang, Bo 
75281e403ceSYang, Bo /*
75381e403ceSYang, Bo  * defines the physical drive list structure
75481e403ceSYang, Bo  */
75581e403ceSYang, Bo struct MR_PD_LIST {
7569ab9ed38SChristoph Hellwig 	__le32		size;
7579ab9ed38SChristoph Hellwig 	__le32		count;
75881e403ceSYang, Bo 	struct MR_PD_ADDRESS   addr[1];
75981e403ceSYang, Bo } __packed;
76081e403ceSYang, Bo 
76181e403ceSYang, Bo struct megasas_pd_list {
76281e403ceSYang, Bo 	u16             tid;
76381e403ceSYang, Bo 	u8             driveType;
76481e403ceSYang, Bo 	u8             driveState;
76581e403ceSYang, Bo } __packed;
76681e403ceSYang, Bo 
76781e403ceSYang, Bo  /*
768bdc6fb8dSYang, Bo  * defines the logical drive reference structure
769bdc6fb8dSYang, Bo  */
770bdc6fb8dSYang, Bo union  MR_LD_REF {
771bdc6fb8dSYang, Bo 	struct {
772bdc6fb8dSYang, Bo 		u8      targetId;
773bdc6fb8dSYang, Bo 		u8      reserved;
7749ab9ed38SChristoph Hellwig 		__le16     seqNum;
775bdc6fb8dSYang, Bo 	};
7769ab9ed38SChristoph Hellwig 	__le32     ref;
777bdc6fb8dSYang, Bo } __packed;
778bdc6fb8dSYang, Bo 
779bdc6fb8dSYang, Bo /*
780bdc6fb8dSYang, Bo  * defines the logical drive list structure
781bdc6fb8dSYang, Bo  */
782bdc6fb8dSYang, Bo struct MR_LD_LIST {
7839ab9ed38SChristoph Hellwig 	__le32     ldCount;
7849ab9ed38SChristoph Hellwig 	__le32     reserved;
785bdc6fb8dSYang, Bo 	struct {
786bdc6fb8dSYang, Bo 		union MR_LD_REF   ref;
787bdc6fb8dSYang, Bo 		u8          state;
788bdc6fb8dSYang, Bo 		u8          reserved[3];
7899ab9ed38SChristoph Hellwig 		__le64		size;
79051087a86SSumit.Saxena@avagotech.com 	} ldList[MAX_LOGICAL_DRIVES_EXT];
791bdc6fb8dSYang, Bo } __packed;
792bdc6fb8dSYang, Bo 
79321c9e160Sadam radford struct MR_LD_TARGETID_LIST {
7949ab9ed38SChristoph Hellwig 	__le32	size;
7959ab9ed38SChristoph Hellwig 	__le32	count;
79621c9e160Sadam radford 	u8	pad[3];
79751087a86SSumit.Saxena@avagotech.com 	u8	targetId[MAX_LOGICAL_DRIVES_EXT];
79821c9e160Sadam radford };
79921c9e160Sadam radford 
800f6fe5731SShivasharan S struct MR_HOST_DEVICE_LIST_ENTRY {
801f6fe5731SShivasharan S 	struct {
802f6fe5731SShivasharan S 		union {
803f6fe5731SShivasharan S 			struct {
804f6fe5731SShivasharan S #if defined(__BIG_ENDIAN_BITFIELD)
805f6fe5731SShivasharan S 				u8 reserved:7;
806f6fe5731SShivasharan S 				u8 is_sys_pd:1;
807f6fe5731SShivasharan S #else
808f6fe5731SShivasharan S 				u8 is_sys_pd:1;
809f6fe5731SShivasharan S 				u8 reserved:7;
810f6fe5731SShivasharan S #endif
811f6fe5731SShivasharan S 			} bits;
812f6fe5731SShivasharan S 			u8 byte;
813f6fe5731SShivasharan S 		} u;
814f6fe5731SShivasharan S 	} flags;
815f6fe5731SShivasharan S 	u8 scsi_type;
816f6fe5731SShivasharan S 	__le16 target_id;
817a3742d68SShivasharan S 	u8 reserved[4];
818f6fe5731SShivasharan S 	__le64 sas_addr[2];
819f6fe5731SShivasharan S } __packed;
820f6fe5731SShivasharan S 
821f6fe5731SShivasharan S struct MR_HOST_DEVICE_LIST {
822f6fe5731SShivasharan S 	__le32			size;
823f6fe5731SShivasharan S 	__le32			count;
824a3742d68SShivasharan S 	__le32			reserved[2];
825f6fe5731SShivasharan S 	struct MR_HOST_DEVICE_LIST_ENTRY	host_device_list[1];
826f6fe5731SShivasharan S } __packed;
827f6fe5731SShivasharan S 
828f6fe5731SShivasharan S #define HOST_DEVICE_LIST_SZ (sizeof(struct MR_HOST_DEVICE_LIST) +	       \
829f6fe5731SShivasharan S 			      (sizeof(struct MR_HOST_DEVICE_LIST_ENTRY) *      \
830f6fe5731SShivasharan S 			      (MEGASAS_MAX_PD + MAX_LOGICAL_DRIVES_EXT - 1)))
831f6fe5731SShivasharan S 
83221c9e160Sadam radford 
833bdc6fb8dSYang, Bo /*
834c4a3e0a5SBagalkote, Sreenivas  * SAS controller properties
835c4a3e0a5SBagalkote, Sreenivas  */
836c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_prop {
837c4a3e0a5SBagalkote, Sreenivas 
838c4a3e0a5SBagalkote, Sreenivas 	u16 seq_num;
839c4a3e0a5SBagalkote, Sreenivas 	u16 pred_fail_poll_interval;
840c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_count;
841c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_timeouts;
842c4a3e0a5SBagalkote, Sreenivas 	u8 rebuild_rate;
843c4a3e0a5SBagalkote, Sreenivas 	u8 patrol_read_rate;
844c4a3e0a5SBagalkote, Sreenivas 	u8 bgi_rate;
845c4a3e0a5SBagalkote, Sreenivas 	u8 cc_rate;
846c4a3e0a5SBagalkote, Sreenivas 	u8 recon_rate;
847c4a3e0a5SBagalkote, Sreenivas 	u8 cache_flush_interval;
848c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_drv_count;
849c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_delay;
850c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_enable;
851c4a3e0a5SBagalkote, Sreenivas 	u8 coercion_mode;
852c4a3e0a5SBagalkote, Sreenivas 	u8 alarm_enable;
853c4a3e0a5SBagalkote, Sreenivas 	u8 disable_auto_rebuild;
854c4a3e0a5SBagalkote, Sreenivas 	u8 disable_battery_warn;
855c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_size;
856c4a3e0a5SBagalkote, Sreenivas 	u16 ecc_bucket_leak_rate;
857c4a3e0a5SBagalkote, Sreenivas 	u8 restore_hotspare_on_insertion;
858c4a3e0a5SBagalkote, Sreenivas 	u8 expose_encl_devices;
85939a98554Sbo yang 	u8 maintainPdFailHistory;
86039a98554Sbo yang 	u8 disallowHostRequestReordering;
86139a98554Sbo yang 	u8 abortCCOnError;
86239a98554Sbo yang 	u8 loadBalanceMode;
86339a98554Sbo yang 	u8 disableAutoDetectBackplane;
864c4a3e0a5SBagalkote, Sreenivas 
86539a98554Sbo yang 	u8 snapVDSpace;
86639a98554Sbo yang 
86739a98554Sbo yang 	/*
86839a98554Sbo yang 	* Add properties that can be controlled by
86939a98554Sbo yang 	* a bit in the following structure.
87039a98554Sbo yang 	*/
87139a98554Sbo yang 	struct {
87294cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
87394cd65ddSSumit.Saxena@lsi.com 		u32     reserved:18;
87494cd65ddSSumit.Saxena@lsi.com 		u32     enableJBOD:1;
87594cd65ddSSumit.Saxena@lsi.com 		u32     disableSpinDownHS:1;
87694cd65ddSSumit.Saxena@lsi.com 		u32     allowBootWithPinnedCache:1;
87794cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlineCtrlReset:1;
87894cd65ddSSumit.Saxena@lsi.com 		u32     enableSecretKeyControl:1;
87994cd65ddSSumit.Saxena@lsi.com 		u32     autoEnhancedImport:1;
88094cd65ddSSumit.Saxena@lsi.com 		u32     enableSpinDownUnconfigured:1;
88194cd65ddSSumit.Saxena@lsi.com 		u32     SSDPatrolReadEnabled:1;
88294cd65ddSSumit.Saxena@lsi.com 		u32     SSDSMARTerEnabled:1;
88394cd65ddSSumit.Saxena@lsi.com 		u32     disableNCQ:1;
88494cd65ddSSumit.Saxena@lsi.com 		u32     useFdeOnly:1;
88594cd65ddSSumit.Saxena@lsi.com 		u32     prCorrectUnconfiguredAreas:1;
88694cd65ddSSumit.Saxena@lsi.com 		u32     SMARTerEnabled:1;
88794cd65ddSSumit.Saxena@lsi.com 		u32     copyBackDisabled:1;
88894cd65ddSSumit.Saxena@lsi.com #else
88939a98554Sbo yang 		u32     copyBackDisabled:1;
89039a98554Sbo yang 		u32     SMARTerEnabled:1;
89139a98554Sbo yang 		u32     prCorrectUnconfiguredAreas:1;
89239a98554Sbo yang 		u32     useFdeOnly:1;
89339a98554Sbo yang 		u32     disableNCQ:1;
89439a98554Sbo yang 		u32     SSDSMARTerEnabled:1;
89539a98554Sbo yang 		u32     SSDPatrolReadEnabled:1;
89639a98554Sbo yang 		u32     enableSpinDownUnconfigured:1;
89739a98554Sbo yang 		u32     autoEnhancedImport:1;
89839a98554Sbo yang 		u32     enableSecretKeyControl:1;
89939a98554Sbo yang 		u32     disableOnlineCtrlReset:1;
90039a98554Sbo yang 		u32     allowBootWithPinnedCache:1;
90139a98554Sbo yang 		u32     disableSpinDownHS:1;
90239a98554Sbo yang 		u32     enableJBOD:1;
90339a98554Sbo yang 		u32     reserved:18;
90494cd65ddSSumit.Saxena@lsi.com #endif
90539a98554Sbo yang 	} OnOffProperties;
906f0c21df6SShivasharan S 
907f0c21df6SShivasharan S 	union {
90839a98554Sbo yang 		u8 autoSnapVDSpace;
90939a98554Sbo yang 		u8 viewSpace;
910f0c21df6SShivasharan S 		struct {
911f0c21df6SShivasharan S #if   defined(__BIG_ENDIAN_BITFIELD)
912f6fe5731SShivasharan S 			u16 reserved3:9;
913f6fe5731SShivasharan S 			u16 enable_fw_dev_list:1;
914f6fe5731SShivasharan S 			u16 reserved2:1;
915f0c21df6SShivasharan S 			u16 enable_snap_dump:1;
916f0c21df6SShivasharan S 			u16 reserved1:4;
917f0c21df6SShivasharan S #else
918f0c21df6SShivasharan S 			u16 reserved1:4;
919f0c21df6SShivasharan S 			u16 enable_snap_dump:1;
920f6fe5731SShivasharan S 			u16 reserved2:1;
921f6fe5731SShivasharan S 			u16 enable_fw_dev_list:1;
922f6fe5731SShivasharan S 			u16 reserved3:9;
923f0c21df6SShivasharan S #endif
924f0c21df6SShivasharan S 		} on_off_properties2;
925f0c21df6SShivasharan S 	};
9269ab9ed38SChristoph Hellwig 	__le16 spinDownTime;
92739a98554Sbo yang 	u8  reserved[24];
92881e403ceSYang, Bo } __packed;
929c4a3e0a5SBagalkote, Sreenivas 
930c4a3e0a5SBagalkote, Sreenivas /*
931c4a3e0a5SBagalkote, Sreenivas  * SAS controller information
932c4a3e0a5SBagalkote, Sreenivas  */
933c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_info {
934c4a3e0a5SBagalkote, Sreenivas 
935c4a3e0a5SBagalkote, Sreenivas 	/*
936c4a3e0a5SBagalkote, Sreenivas 	 * PCI device information
937c4a3e0a5SBagalkote, Sreenivas 	 */
938c4a3e0a5SBagalkote, Sreenivas 	struct {
939c4a3e0a5SBagalkote, Sreenivas 
9409ab9ed38SChristoph Hellwig 		__le16 vendor_id;
9419ab9ed38SChristoph Hellwig 		__le16 device_id;
9429ab9ed38SChristoph Hellwig 		__le16 sub_vendor_id;
9439ab9ed38SChristoph Hellwig 		__le16 sub_device_id;
944c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[24];
945c4a3e0a5SBagalkote, Sreenivas 
946c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pci;
947c4a3e0a5SBagalkote, Sreenivas 
948c4a3e0a5SBagalkote, Sreenivas 	/*
949c4a3e0a5SBagalkote, Sreenivas 	 * Host interface information
950c4a3e0a5SBagalkote, Sreenivas 	 */
951c4a3e0a5SBagalkote, Sreenivas 	struct {
952c4a3e0a5SBagalkote, Sreenivas 
953c4a3e0a5SBagalkote, Sreenivas 		u8 PCIX:1;
954c4a3e0a5SBagalkote, Sreenivas 		u8 PCIE:1;
955c4a3e0a5SBagalkote, Sreenivas 		u8 iSCSI:1;
956c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
957229fe47cSadam radford 		u8 SRIOV:1;
958229fe47cSadam radford 		u8 reserved_0:3;
959c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
960c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
961c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
962c4a3e0a5SBagalkote, Sreenivas 
963c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) host_interface;
964c4a3e0a5SBagalkote, Sreenivas 
965c4a3e0a5SBagalkote, Sreenivas 	/*
966c4a3e0a5SBagalkote, Sreenivas 	 * Device (backend) interface information
967c4a3e0a5SBagalkote, Sreenivas 	 */
968c4a3e0a5SBagalkote, Sreenivas 	struct {
969c4a3e0a5SBagalkote, Sreenivas 
970c4a3e0a5SBagalkote, Sreenivas 		u8 SPI:1;
971c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
972c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_1_5G:1;
973c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_3G:1;
974c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_0:4;
975c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
976c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
977c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
978c4a3e0a5SBagalkote, Sreenivas 
979c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) device_interface;
980c4a3e0a5SBagalkote, Sreenivas 
981c4a3e0a5SBagalkote, Sreenivas 	/*
982c4a3e0a5SBagalkote, Sreenivas 	 * List of components residing in flash. All str are null terminated
983c4a3e0a5SBagalkote, Sreenivas 	 */
9849ab9ed38SChristoph Hellwig 	__le32 image_check_word;
9859ab9ed38SChristoph Hellwig 	__le32 image_component_count;
986c4a3e0a5SBagalkote, Sreenivas 
987c4a3e0a5SBagalkote, Sreenivas 	struct {
988c4a3e0a5SBagalkote, Sreenivas 
989c4a3e0a5SBagalkote, Sreenivas 		char name[8];
990c4a3e0a5SBagalkote, Sreenivas 		char version[32];
991c4a3e0a5SBagalkote, Sreenivas 		char build_date[16];
992c4a3e0a5SBagalkote, Sreenivas 		char built_time[16];
993c4a3e0a5SBagalkote, Sreenivas 
994c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) image_component[8];
995c4a3e0a5SBagalkote, Sreenivas 
996c4a3e0a5SBagalkote, Sreenivas 	/*
997c4a3e0a5SBagalkote, Sreenivas 	 * List of flash components that have been flashed on the card, but
998c4a3e0a5SBagalkote, Sreenivas 	 * are not in use, pending reset of the adapter. This list will be
999c4a3e0a5SBagalkote, Sreenivas 	 * empty if a flash operation has not occurred. All stings are null
1000c4a3e0a5SBagalkote, Sreenivas 	 * terminated
1001c4a3e0a5SBagalkote, Sreenivas 	 */
10029ab9ed38SChristoph Hellwig 	__le32 pending_image_component_count;
1003c4a3e0a5SBagalkote, Sreenivas 
1004c4a3e0a5SBagalkote, Sreenivas 	struct {
1005c4a3e0a5SBagalkote, Sreenivas 
1006c4a3e0a5SBagalkote, Sreenivas 		char name[8];
1007c4a3e0a5SBagalkote, Sreenivas 		char version[32];
1008c4a3e0a5SBagalkote, Sreenivas 		char build_date[16];
1009c4a3e0a5SBagalkote, Sreenivas 		char build_time[16];
1010c4a3e0a5SBagalkote, Sreenivas 
1011c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pending_image_component[8];
1012c4a3e0a5SBagalkote, Sreenivas 
1013c4a3e0a5SBagalkote, Sreenivas 	u8 max_arms;
1014c4a3e0a5SBagalkote, Sreenivas 	u8 max_spans;
1015c4a3e0a5SBagalkote, Sreenivas 	u8 max_arrays;
1016c4a3e0a5SBagalkote, Sreenivas 	u8 max_lds;
1017c4a3e0a5SBagalkote, Sreenivas 
1018c4a3e0a5SBagalkote, Sreenivas 	char product_name[80];
1019c4a3e0a5SBagalkote, Sreenivas 	char serial_no[32];
1020c4a3e0a5SBagalkote, Sreenivas 
1021c4a3e0a5SBagalkote, Sreenivas 	/*
1022c4a3e0a5SBagalkote, Sreenivas 	 * Other physical/controller/operation information. Indicates the
1023c4a3e0a5SBagalkote, Sreenivas 	 * presence of the hardware
1024c4a3e0a5SBagalkote, Sreenivas 	 */
1025c4a3e0a5SBagalkote, Sreenivas 	struct {
1026c4a3e0a5SBagalkote, Sreenivas 
1027c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
1028c4a3e0a5SBagalkote, Sreenivas 		u32 alarm:1;
1029c4a3e0a5SBagalkote, Sreenivas 		u32 nvram:1;
1030c4a3e0a5SBagalkote, Sreenivas 		u32 uart:1;
1031c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:28;
1032c4a3e0a5SBagalkote, Sreenivas 
1033c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) hw_present;
1034c4a3e0a5SBagalkote, Sreenivas 
10359ab9ed38SChristoph Hellwig 	__le32 current_fw_time;
1036c4a3e0a5SBagalkote, Sreenivas 
1037c4a3e0a5SBagalkote, Sreenivas 	/*
1038c4a3e0a5SBagalkote, Sreenivas 	 * Maximum data transfer sizes
1039c4a3e0a5SBagalkote, Sreenivas 	 */
10409ab9ed38SChristoph Hellwig 	__le16 max_concurrent_cmds;
10419ab9ed38SChristoph Hellwig 	__le16 max_sge_count;
10429ab9ed38SChristoph Hellwig 	__le32 max_request_size;
1043c4a3e0a5SBagalkote, Sreenivas 
1044c4a3e0a5SBagalkote, Sreenivas 	/*
1045c4a3e0a5SBagalkote, Sreenivas 	 * Logical and physical device counts
1046c4a3e0a5SBagalkote, Sreenivas 	 */
10479ab9ed38SChristoph Hellwig 	__le16 ld_present_count;
10489ab9ed38SChristoph Hellwig 	__le16 ld_degraded_count;
10499ab9ed38SChristoph Hellwig 	__le16 ld_offline_count;
1050c4a3e0a5SBagalkote, Sreenivas 
10519ab9ed38SChristoph Hellwig 	__le16 pd_present_count;
10529ab9ed38SChristoph Hellwig 	__le16 pd_disk_present_count;
10539ab9ed38SChristoph Hellwig 	__le16 pd_disk_pred_failure_count;
10549ab9ed38SChristoph Hellwig 	__le16 pd_disk_failed_count;
1055c4a3e0a5SBagalkote, Sreenivas 
1056c4a3e0a5SBagalkote, Sreenivas 	/*
1057c4a3e0a5SBagalkote, Sreenivas 	 * Memory size information
1058c4a3e0a5SBagalkote, Sreenivas 	 */
10599ab9ed38SChristoph Hellwig 	__le16 nvram_size;
10609ab9ed38SChristoph Hellwig 	__le16 memory_size;
10619ab9ed38SChristoph Hellwig 	__le16 flash_size;
1062c4a3e0a5SBagalkote, Sreenivas 
1063c4a3e0a5SBagalkote, Sreenivas 	/*
1064c4a3e0a5SBagalkote, Sreenivas 	 * Error counters
1065c4a3e0a5SBagalkote, Sreenivas 	 */
10669ab9ed38SChristoph Hellwig 	__le16 mem_correctable_error_count;
10679ab9ed38SChristoph Hellwig 	__le16 mem_uncorrectable_error_count;
1068c4a3e0a5SBagalkote, Sreenivas 
1069c4a3e0a5SBagalkote, Sreenivas 	/*
1070c4a3e0a5SBagalkote, Sreenivas 	 * Cluster information
1071c4a3e0a5SBagalkote, Sreenivas 	 */
1072c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_permitted;
1073c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_active;
1074c4a3e0a5SBagalkote, Sreenivas 
1075c4a3e0a5SBagalkote, Sreenivas 	/*
1076c4a3e0a5SBagalkote, Sreenivas 	 * Additional max data transfer sizes
1077c4a3e0a5SBagalkote, Sreenivas 	 */
10789ab9ed38SChristoph Hellwig 	__le16 max_strips_per_io;
1079c4a3e0a5SBagalkote, Sreenivas 
1080c4a3e0a5SBagalkote, Sreenivas 	/*
1081c4a3e0a5SBagalkote, Sreenivas 	 * Controller capabilities structures
1082c4a3e0a5SBagalkote, Sreenivas 	 */
1083c4a3e0a5SBagalkote, Sreenivas 	struct {
1084c4a3e0a5SBagalkote, Sreenivas 
1085c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_0:1;
1086c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1:1;
1087c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_5:1;
1088c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1E:1;
1089c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_6:1;
1090c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1091c4a3e0a5SBagalkote, Sreenivas 
1092c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) raid_levels;
1093c4a3e0a5SBagalkote, Sreenivas 
1094c4a3e0a5SBagalkote, Sreenivas 	struct {
1095c4a3e0a5SBagalkote, Sreenivas 
1096c4a3e0a5SBagalkote, Sreenivas 		u32 rbld_rate:1;
1097c4a3e0a5SBagalkote, Sreenivas 		u32 cc_rate:1;
1098c4a3e0a5SBagalkote, Sreenivas 		u32 bgi_rate:1;
1099c4a3e0a5SBagalkote, Sreenivas 		u32 recon_rate:1;
1100c4a3e0a5SBagalkote, Sreenivas 		u32 patrol_rate:1;
1101c4a3e0a5SBagalkote, Sreenivas 		u32 alarm_control:1;
1102c4a3e0a5SBagalkote, Sreenivas 		u32 cluster_supported:1;
1103c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
1104c4a3e0a5SBagalkote, Sreenivas 		u32 spanning_allowed:1;
1105c4a3e0a5SBagalkote, Sreenivas 		u32 dedicated_hotspares:1;
1106c4a3e0a5SBagalkote, Sreenivas 		u32 revertible_hotspares:1;
1107c4a3e0a5SBagalkote, Sreenivas 		u32 foreign_config_import:1;
1108c4a3e0a5SBagalkote, Sreenivas 		u32 self_diagnostic:1;
1109c4a3e0a5SBagalkote, Sreenivas 		u32 mixed_redundancy_arr:1;
1110c4a3e0a5SBagalkote, Sreenivas 		u32 global_hot_spares:1;
1111c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:17;
1112c4a3e0a5SBagalkote, Sreenivas 
1113c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) adapter_operations;
1114c4a3e0a5SBagalkote, Sreenivas 
1115c4a3e0a5SBagalkote, Sreenivas 	struct {
1116c4a3e0a5SBagalkote, Sreenivas 
1117c4a3e0a5SBagalkote, Sreenivas 		u32 read_policy:1;
1118c4a3e0a5SBagalkote, Sreenivas 		u32 write_policy:1;
1119c4a3e0a5SBagalkote, Sreenivas 		u32 io_policy:1;
1120c4a3e0a5SBagalkote, Sreenivas 		u32 access_policy:1;
1121c4a3e0a5SBagalkote, Sreenivas 		u32 disk_cache_policy:1;
1122c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1123c4a3e0a5SBagalkote, Sreenivas 
1124c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) ld_operations;
1125c4a3e0a5SBagalkote, Sreenivas 
1126c4a3e0a5SBagalkote, Sreenivas 	struct {
1127c4a3e0a5SBagalkote, Sreenivas 
1128c4a3e0a5SBagalkote, Sreenivas 		u8 min;
1129c4a3e0a5SBagalkote, Sreenivas 		u8 max;
1130c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[2];
1131c4a3e0a5SBagalkote, Sreenivas 
1132c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) stripe_sz_ops;
1133c4a3e0a5SBagalkote, Sreenivas 
1134c4a3e0a5SBagalkote, Sreenivas 	struct {
1135c4a3e0a5SBagalkote, Sreenivas 
1136c4a3e0a5SBagalkote, Sreenivas 		u32 force_online:1;
1137c4a3e0a5SBagalkote, Sreenivas 		u32 force_offline:1;
1138c4a3e0a5SBagalkote, Sreenivas 		u32 force_rebuild:1;
1139c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:29;
1140c4a3e0a5SBagalkote, Sreenivas 
1141c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_operations;
1142c4a3e0a5SBagalkote, Sreenivas 
1143c4a3e0a5SBagalkote, Sreenivas 	struct {
1144c4a3e0a5SBagalkote, Sreenivas 
1145c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sas:1;
1146c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sata:1;
1147c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_encl:1;
1148c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_ld:1;
1149c4a3e0a5SBagalkote, Sreenivas 		u32 allow_sata_in_cluster:1;
1150c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1151c4a3e0a5SBagalkote, Sreenivas 
1152c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_mix_support;
1153c4a3e0a5SBagalkote, Sreenivas 
1154c4a3e0a5SBagalkote, Sreenivas 	/*
1155c4a3e0a5SBagalkote, Sreenivas 	 * Define ECC single-bit-error bucket information
1156c4a3e0a5SBagalkote, Sreenivas 	 */
1157c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_count;
1158c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[11];
1159c4a3e0a5SBagalkote, Sreenivas 
1160c4a3e0a5SBagalkote, Sreenivas 	/*
1161c4a3e0a5SBagalkote, Sreenivas 	 * Include the controller properties (changeable items)
1162c4a3e0a5SBagalkote, Sreenivas 	 */
1163c4a3e0a5SBagalkote, Sreenivas 	struct megasas_ctrl_prop properties;
1164c4a3e0a5SBagalkote, Sreenivas 
1165c4a3e0a5SBagalkote, Sreenivas 	/*
1166c4a3e0a5SBagalkote, Sreenivas 	 * Define FW pkg version (set in envt v'bles on OEM basis)
1167c4a3e0a5SBagalkote, Sreenivas 	 */
1168c4a3e0a5SBagalkote, Sreenivas 	char package_version[0x60];
1169c4a3e0a5SBagalkote, Sreenivas 
1170c4a3e0a5SBagalkote, Sreenivas 
1171bc93d425SSumit.Saxena@lsi.com 	/*
1172bc93d425SSumit.Saxena@lsi.com 	* If adapterOperations.supportMoreThan8Phys is set,
1173bc93d425SSumit.Saxena@lsi.com 	* and deviceInterface.portCount is greater than 8,
1174bc93d425SSumit.Saxena@lsi.com 	* SAS Addrs for first 8 ports shall be populated in
1175bc93d425SSumit.Saxena@lsi.com 	* deviceInterface.portAddr, and the rest shall be
1176bc93d425SSumit.Saxena@lsi.com 	* populated in deviceInterfacePortAddr2.
1177bc93d425SSumit.Saxena@lsi.com 	*/
11789ab9ed38SChristoph Hellwig 	__le64	    deviceInterfacePortAddr2[8]; /*6a0h */
1179bc93d425SSumit.Saxena@lsi.com 	u8          reserved3[128];              /*6e0h */
1180bc93d425SSumit.Saxena@lsi.com 
1181bc93d425SSumit.Saxena@lsi.com 	struct {                                /*760h */
1182bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_0:4;
1183bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_0:12;
1184bc93d425SSumit.Saxena@lsi.com 
1185bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1:4;
1186bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1:12;
1187bc93d425SSumit.Saxena@lsi.com 
1188bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_5:4;
1189bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_5:12;
1190bc93d425SSumit.Saxena@lsi.com 
1191bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E:4;
1192bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E:12;
1193bc93d425SSumit.Saxena@lsi.com 
1194bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_6:4;
1195bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_6:12;
1196bc93d425SSumit.Saxena@lsi.com 
1197bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_10:4;
1198bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_10:12;
1199bc93d425SSumit.Saxena@lsi.com 
1200bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_50:4;
1201bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_50:12;
1202bc93d425SSumit.Saxena@lsi.com 
1203bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_60:4;
1204bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_60:12;
1205bc93d425SSumit.Saxena@lsi.com 
1206bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E_RLQ0:4;
1207bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E_RLQ0:12;
1208bc93d425SSumit.Saxena@lsi.com 
1209bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E0_RLQ0:4;
1210bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E0_RLQ0:12;
1211bc93d425SSumit.Saxena@lsi.com 
1212bc93d425SSumit.Saxena@lsi.com 		u16 reserved[6];
1213bc93d425SSumit.Saxena@lsi.com 	} pdsForRaidLevels;
1214bc93d425SSumit.Saxena@lsi.com 
12159ab9ed38SChristoph Hellwig 	__le16 maxPds;                          /*780h */
12169ab9ed38SChristoph Hellwig 	__le16 maxDedHSPs;                      /*782h */
12179ab9ed38SChristoph Hellwig 	__le16 maxGlobalHSP;                    /*784h */
12189ab9ed38SChristoph Hellwig 	__le16 ddfSize;                         /*786h */
1219bc93d425SSumit.Saxena@lsi.com 	u8  maxLdsPerArray;                     /*788h */
1220bc93d425SSumit.Saxena@lsi.com 	u8  partitionsInDDF;                    /*789h */
1221bc93d425SSumit.Saxena@lsi.com 	u8  lockKeyBinding;                     /*78ah */
1222bc93d425SSumit.Saxena@lsi.com 	u8  maxPITsPerLd;                       /*78bh */
1223bc93d425SSumit.Saxena@lsi.com 	u8  maxViewsPerLd;                      /*78ch */
1224bc93d425SSumit.Saxena@lsi.com 	u8  maxTargetId;                        /*78dh */
12259ab9ed38SChristoph Hellwig 	__le16 maxBvlVdSize;                    /*78eh */
1226bc93d425SSumit.Saxena@lsi.com 
12279ab9ed38SChristoph Hellwig 	__le16 maxConfigurableSSCSize;          /*790h */
12289ab9ed38SChristoph Hellwig 	__le16 currentSSCsize;                  /*792h */
1229bc93d425SSumit.Saxena@lsi.com 
1230bc93d425SSumit.Saxena@lsi.com 	char    expanderFwVersion[12];          /*794h */
1231bc93d425SSumit.Saxena@lsi.com 
12329ab9ed38SChristoph Hellwig 	__le16 PFKTrialTimeRemaining;           /*7A0h */
1233bc93d425SSumit.Saxena@lsi.com 
12349ab9ed38SChristoph Hellwig 	__le16 cacheMemorySize;                 /*7A2h */
1235bc93d425SSumit.Saxena@lsi.com 
1236bc93d425SSumit.Saxena@lsi.com 	struct {                                /*7A4h */
123794cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
1238229fe47cSadam radford 		u32     reserved:5;
1239229fe47cSadam radford 		u32	activePassive:2;
1240229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1241229fe47cSadam radford 		u32	mpio:1;
1242229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1243229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
124494cd65ddSSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
124594cd65ddSSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
124694cd65ddSSumit.Saxena@lsi.com 		u32     headlessMode:1;
124794cd65ddSSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
124894cd65ddSSumit.Saxena@lsi.com 		u32     supportResetNow:1;
124994cd65ddSSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
125094cd65ddSSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
125194cd65ddSSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
125294cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
125394cd65ddSSumit.Saxena@lsi.com 		u32     supportJBOD:1;
125494cd65ddSSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
125594cd65ddSSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
125694cd65ddSSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
125794cd65ddSSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
125894cd65ddSSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
125994cd65ddSSumit.Saxena@lsi.com 		u32     supportShieldState:1;
126094cd65ddSSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
126194cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
126294cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
126394cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
126494cd65ddSSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
126594cd65ddSSumit.Saxena@lsi.com #else
1266bc93d425SSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
1267bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
1268bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
1269bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
1270bc93d425SSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
1271bc93d425SSumit.Saxena@lsi.com 		u32     supportShieldState:1;
1272bc93d425SSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
1273bc93d425SSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
1274bc93d425SSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
1275bc93d425SSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
1276bc93d425SSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
1277bc93d425SSumit.Saxena@lsi.com 		u32     supportJBOD:1;
1278bc93d425SSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
1279bc93d425SSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
1280bc93d425SSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
1281bc93d425SSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
1282bc93d425SSumit.Saxena@lsi.com 
1283bc93d425SSumit.Saxena@lsi.com 		u32     supportResetNow:1;
1284bc93d425SSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
1285bc93d425SSumit.Saxena@lsi.com 		u32     headlessMode:1;
1286bc93d425SSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
1287bc93d425SSumit.Saxena@lsi.com 
1288bc93d425SSumit.Saxena@lsi.com 
1289bc93d425SSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
1290229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
1291229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1292229fe47cSadam radford 		u32	mpio:1;
1293229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1294229fe47cSadam radford 		u32	activePassive:2;
1295229fe47cSadam radford 		u32     reserved:5;
129694cd65ddSSumit.Saxena@lsi.com #endif
1297bc93d425SSumit.Saxena@lsi.com 	} adapterOperations2;
1298bc93d425SSumit.Saxena@lsi.com 
1299bc93d425SSumit.Saxena@lsi.com 	u8  driverVersion[32];                  /*7A8h */
1300bc93d425SSumit.Saxena@lsi.com 	u8  maxDAPdCountSpinup60;               /*7C8h */
1301bc93d425SSumit.Saxena@lsi.com 	u8  temperatureROC;                     /*7C9h */
1302bc93d425SSumit.Saxena@lsi.com 	u8  temperatureCtrl;                    /*7CAh */
1303bc93d425SSumit.Saxena@lsi.com 	u8  reserved4;                          /*7CBh */
13049ab9ed38SChristoph Hellwig 	__le16 maxConfigurablePds;              /*7CCh */
1305bc93d425SSumit.Saxena@lsi.com 
1306bc93d425SSumit.Saxena@lsi.com 
1307bc93d425SSumit.Saxena@lsi.com 	u8  reserved5[2];                       /*0x7CDh */
1308bc93d425SSumit.Saxena@lsi.com 
1309bc93d425SSumit.Saxena@lsi.com 	/*
1310bc93d425SSumit.Saxena@lsi.com 	* HA cluster information
1311bc93d425SSumit.Saxena@lsi.com 	*/
1312bc93d425SSumit.Saxena@lsi.com 	struct {
131351087a86SSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
13148f67c8c5SSumit Saxena 		u32     reserved:25;
13158f67c8c5SSumit Saxena 		u32     passive:1;
131651087a86SSumit.Saxena@avagotech.com 		u32     premiumFeatureMismatch:1;
131751087a86SSumit.Saxena@avagotech.com 		u32     ctrlPropIncompatible:1;
131851087a86SSumit.Saxena@avagotech.com 		u32     fwVersionMismatch:1;
131951087a86SSumit.Saxena@avagotech.com 		u32     hwIncompatible:1;
132051087a86SSumit.Saxena@avagotech.com 		u32     peerIsIncompatible:1;
132151087a86SSumit.Saxena@avagotech.com 		u32     peerIsPresent:1;
132251087a86SSumit.Saxena@avagotech.com #else
1323bc93d425SSumit.Saxena@lsi.com 		u32     peerIsPresent:1;
1324bc93d425SSumit.Saxena@lsi.com 		u32     peerIsIncompatible:1;
1325bc93d425SSumit.Saxena@lsi.com 		u32     hwIncompatible:1;
1326bc93d425SSumit.Saxena@lsi.com 		u32     fwVersionMismatch:1;
1327bc93d425SSumit.Saxena@lsi.com 		u32     ctrlPropIncompatible:1;
1328bc93d425SSumit.Saxena@lsi.com 		u32     premiumFeatureMismatch:1;
13298f67c8c5SSumit Saxena 		u32     passive:1;
13308f67c8c5SSumit Saxena 		u32     reserved:25;
133151087a86SSumit.Saxena@avagotech.com #endif
1332bc93d425SSumit.Saxena@lsi.com 	} cluster;
1333bc93d425SSumit.Saxena@lsi.com 
13348f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE]; /*0x7D4 */
1335229fe47cSadam radford 	struct {
1336229fe47cSadam radford 		u8  maxVFsSupported;            /*0x7E4*/
1337229fe47cSadam radford 		u8  numVFsEnabled;              /*0x7E5*/
1338229fe47cSadam radford 		u8  requestorId;                /*0x7E6 0:PF, 1:VF1, 2:VF2*/
1339229fe47cSadam radford 		u8  reserved;                   /*0x7E7*/
1340229fe47cSadam radford 	} iov;
1341bc93d425SSumit.Saxena@lsi.com 
1342fc62b3fcSSumit.Saxena@avagotech.com 	struct {
1343fc62b3fcSSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
13443761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
13453761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
13460be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
13470be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
13480be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
13490be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
13507497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
13517497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
13527497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
13537497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
13547497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
13557497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
13567497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
13577497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
13587497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
13597497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
13607497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
13617497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
13627497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
1363fc62b3fcSSumit.Saxena@avagotech.com 		u32     supportCrashDump:1;
136451087a86SSumit.Saxena@avagotech.com 		u32     supportMaxExtLDs:1;
136551087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
136651087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
136751087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
136851087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
1369fc62b3fcSSumit.Saxena@avagotech.com #else
137051087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
137151087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
137251087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
137351087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
137451087a86SSumit.Saxena@avagotech.com 		u32	supportMaxExtLDs:1;
1375fc62b3fcSSumit.Saxena@avagotech.com 		u32	supportCrashDump:1;
13767497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
13777497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
13787497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
13797497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
13807497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
13817497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
13827497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
13837497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
13847497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
13857497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
13867497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
13877497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
13887497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
13890be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
13900be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
13910be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
13920be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
13933761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
13943761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
1395fc62b3fcSSumit.Saxena@avagotech.com #endif
1396fc62b3fcSSumit.Saxena@avagotech.com 	} adapterOperations3;
1397fc62b3fcSSumit.Saxena@avagotech.com 
1398ede7c3ceSSasikumar Chandrasekaran 	struct {
1399ede7c3ceSSasikumar Chandrasekaran #if defined(__BIG_ENDIAN_BITFIELD)
1400ede7c3ceSSasikumar Chandrasekaran 	u8 reserved:7;
1401ede7c3ceSSasikumar Chandrasekaran 	/* Indicates whether the CPLD image is part of
1402ede7c3ceSSasikumar Chandrasekaran 	 *  the package and stored in flash
1403ede7c3ceSSasikumar Chandrasekaran 	 */
1404ede7c3ceSSasikumar Chandrasekaran 	u8 cpld_in_flash:1;
1405ede7c3ceSSasikumar Chandrasekaran #else
1406ede7c3ceSSasikumar Chandrasekaran 	u8 cpld_in_flash:1;
1407ede7c3ceSSasikumar Chandrasekaran 	u8 reserved:7;
1408ede7c3ceSSasikumar Chandrasekaran #endif
1409ede7c3ceSSasikumar Chandrasekaran 	u8 reserved1[3];
1410ede7c3ceSSasikumar Chandrasekaran 	/* Null terminated string. Has the version
1411ede7c3ceSSasikumar Chandrasekaran 	 *  information if cpld_in_flash = FALSE
1412ede7c3ceSSasikumar Chandrasekaran 	 */
1413ede7c3ceSSasikumar Chandrasekaran 	u8 userCodeDefinition[12];
1414ede7c3ceSSasikumar Chandrasekaran 	} cpld;  /* Valid only if upgradableCPLD is TRUE */
1415ede7c3ceSSasikumar Chandrasekaran 
1416ede7c3ceSSasikumar Chandrasekaran 	struct {
1417ede7c3ceSSasikumar Chandrasekaran 	#if defined(__BIG_ENDIAN_BITFIELD)
1418f870bcbeSShivasharan S 		u16 reserved:2;
1419f870bcbeSShivasharan S 		u16 support_nvme_passthru:1;
1420f870bcbeSShivasharan S 		u16 support_pl_debug_info:1;
1421f870bcbeSShivasharan S 		u16 support_flash_comp_info:1;
1422f870bcbeSShivasharan S 		u16 support_host_info:1;
1423f870bcbeSShivasharan S 		u16 support_dual_fw_update:1;
1424f870bcbeSShivasharan S 		u16 support_ssc_rev3:1;
1425ede7c3ceSSasikumar Chandrasekaran 		u16 fw_swaps_bbu_vpd_info:1;
1426ede7c3ceSSasikumar Chandrasekaran 		u16 support_pd_map_target_id:1;
1427ede7c3ceSSasikumar Chandrasekaran 		u16 support_ses_ctrl_in_multipathcfg:1;
1428ede7c3ceSSasikumar Chandrasekaran 		u16 image_upload_supported:1;
1429ede7c3ceSSasikumar Chandrasekaran 		u16 support_encrypted_mfc:1;
1430ede7c3ceSSasikumar Chandrasekaran 		u16 supported_enc_algo:1;
1431ede7c3ceSSasikumar Chandrasekaran 		u16 support_ibutton_less:1;
1432ede7c3ceSSasikumar Chandrasekaran 		u16 ctrl_info_ext_supported:1;
1433ede7c3ceSSasikumar Chandrasekaran 	#else
1434ede7c3ceSSasikumar Chandrasekaran 
1435ede7c3ceSSasikumar Chandrasekaran 		u16 ctrl_info_ext_supported:1;
1436ede7c3ceSSasikumar Chandrasekaran 		u16 support_ibutton_less:1;
1437ede7c3ceSSasikumar Chandrasekaran 		u16 supported_enc_algo:1;
1438ede7c3ceSSasikumar Chandrasekaran 		u16 support_encrypted_mfc:1;
1439ede7c3ceSSasikumar Chandrasekaran 		u16 image_upload_supported:1;
1440ede7c3ceSSasikumar Chandrasekaran 		/* FW supports LUN based association and target port based */
1441ede7c3ceSSasikumar Chandrasekaran 		u16 support_ses_ctrl_in_multipathcfg:1;
1442ede7c3ceSSasikumar Chandrasekaran 		/* association for the SES device connected in multipath mode */
1443ede7c3ceSSasikumar Chandrasekaran 		/* FW defines Jbod target Id within MR_PD_CFG_SEQ */
1444ede7c3ceSSasikumar Chandrasekaran 		u16 support_pd_map_target_id:1;
1445ede7c3ceSSasikumar Chandrasekaran 		/* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
1446ede7c3ceSSasikumar Chandrasekaran 		 *  provide the data in little endian order
1447ede7c3ceSSasikumar Chandrasekaran 		 */
1448ede7c3ceSSasikumar Chandrasekaran 		u16 fw_swaps_bbu_vpd_info:1;
1449f870bcbeSShivasharan S 		u16 support_ssc_rev3:1;
1450f870bcbeSShivasharan S 		/* FW supports CacheCade 3.0, only one SSCD creation allowed */
1451f870bcbeSShivasharan S 		u16 support_dual_fw_update:1;
1452f870bcbeSShivasharan S 		/* FW supports dual firmware update feature */
1453f870bcbeSShivasharan S 		u16 support_host_info:1;
1454f870bcbeSShivasharan S 		/* FW supports MR_DCMD_CTRL_HOST_INFO_SET/GET */
1455f870bcbeSShivasharan S 		u16 support_flash_comp_info:1;
1456f870bcbeSShivasharan S 		/* FW supports MR_DCMD_CTRL_FLASH_COMP_INFO_GET */
1457f870bcbeSShivasharan S 		u16 support_pl_debug_info:1;
1458f870bcbeSShivasharan S 		/* FW supports retrieval of PL debug information through apps */
1459f870bcbeSShivasharan S 		u16 support_nvme_passthru:1;
1460f870bcbeSShivasharan S 		/* FW supports NVMe passthru commands */
1461f870bcbeSShivasharan S 		u16 reserved:2;
1462ede7c3ceSSasikumar Chandrasekaran 	#endif
1463ede7c3ceSSasikumar Chandrasekaran 		} adapter_operations4;
1464ede7c3ceSSasikumar Chandrasekaran 	u8 pad[0x800 - 0x7FE]; /* 0x7FE pad to 2K for expansion */
1465e9495e2dSShivasharan S 
1466e9495e2dSShivasharan S 	u32 size;
1467e9495e2dSShivasharan S 	u32 pad1;
1468e9495e2dSShivasharan S 
1469e9495e2dSShivasharan S 	u8 reserved6[64];
1470e9495e2dSShivasharan S 
147158136856SChandrakanth Patil 	struct {
147258136856SChandrakanth Patil 	#if defined(__BIG_ENDIAN_BITFIELD)
147358136856SChandrakanth Patil 		u32 reserved:19;
147458136856SChandrakanth Patil 		u32 support_pci_lane_margining: 1;
147558136856SChandrakanth Patil 		u32 support_psoc_update:1;
147658136856SChandrakanth Patil 		u32 support_force_personality_change:1;
147758136856SChandrakanth Patil 		u32 support_fde_type_mix:1;
147858136856SChandrakanth Patil 		u32 support_snap_dump:1;
147958136856SChandrakanth Patil 		u32 support_nvme_tm:1;
148058136856SChandrakanth Patil 		u32 support_oce_only:1;
148158136856SChandrakanth Patil 		u32 support_ext_mfg_vpd:1;
148258136856SChandrakanth Patil 		u32 support_pcie:1;
148358136856SChandrakanth Patil 		u32 support_cvhealth_info:1;
148458136856SChandrakanth Patil 		u32 support_profile_change:2;
148558136856SChandrakanth Patil 		u32 mr_config_ext2_supported:1;
148658136856SChandrakanth Patil 	#else
148758136856SChandrakanth Patil 		u32 mr_config_ext2_supported:1;
148858136856SChandrakanth Patil 		u32 support_profile_change:2;
148958136856SChandrakanth Patil 		u32 support_cvhealth_info:1;
149058136856SChandrakanth Patil 		u32 support_pcie:1;
149158136856SChandrakanth Patil 		u32 support_ext_mfg_vpd:1;
149258136856SChandrakanth Patil 		u32 support_oce_only:1;
149358136856SChandrakanth Patil 		u32 support_nvme_tm:1;
149458136856SChandrakanth Patil 		u32 support_snap_dump:1;
149558136856SChandrakanth Patil 		u32 support_fde_type_mix:1;
149658136856SChandrakanth Patil 		u32 support_force_personality_change:1;
149758136856SChandrakanth Patil 		u32 support_psoc_update:1;
149858136856SChandrakanth Patil 		u32 support_pci_lane_margining: 1;
149958136856SChandrakanth Patil 		u32 reserved:19;
150058136856SChandrakanth Patil 	#endif
150158136856SChandrakanth Patil 	} adapter_operations5;
150258136856SChandrakanth Patil 
150358136856SChandrakanth Patil 	u32 rsvdForAdptOp[63];
1504e9495e2dSShivasharan S 
1505e9495e2dSShivasharan S 	u8 reserved7[3];
1506e9495e2dSShivasharan S 
1507e9495e2dSShivasharan S 	u8 TaskAbortTO;	/* Timeout value in seconds used by Abort Task TM */
1508e9495e2dSShivasharan S 	u8 MaxResetTO;	/* Max Supported Reset timeout in seconds. */
1509e9495e2dSShivasharan S 	u8 reserved8[3];
151081e403ceSYang, Bo } __packed;
1511c4a3e0a5SBagalkote, Sreenivas 
1512c4a3e0a5SBagalkote, Sreenivas /*
1513c4a3e0a5SBagalkote, Sreenivas  * ===============================
1514c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS driver definitions
1515c4a3e0a5SBagalkote, Sreenivas  * ===============================
1516c4a3e0a5SBagalkote, Sreenivas  */
1517c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_PD_CHANNELS			2
151851087a86SSumit.Saxena@avagotech.com #define MEGASAS_MAX_LD_CHANNELS			2
1519c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_CHANNELS			(MEGASAS_MAX_PD_CHANNELS + \
1520c4a3e0a5SBagalkote, Sreenivas 						MEGASAS_MAX_LD_CHANNELS)
1521c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_DEV_PER_CHANNEL		128
1522c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_DEFAULT_INIT_ID			-1
1523c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_LUN				8
15246bf579a3Sadam radford #define MEGASAS_DEFAULT_CMD_PER_LUN		256
152581e403ceSYang, Bo #define MEGASAS_MAX_PD                          (MEGASAS_MAX_PD_CHANNELS * \
152681e403ceSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1527bdc6fb8dSYang, Bo #define MEGASAS_MAX_LD_IDS			(MEGASAS_MAX_LD_CHANNELS * \
1528bdc6fb8dSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1529c4a3e0a5SBagalkote, Sreenivas 
15301fd10685SYang, Bo #define MEGASAS_MAX_SECTORS                    (2*1024)
153142a8d2b3Sadam radford #define MEGASAS_MAX_SECTORS_IEEE		(2*128)
1532658dcedbSSumant Patro #define MEGASAS_DBG_LVL				1
1533658dcedbSSumant Patro 
153405e9ebbeSSumant Patro #define MEGASAS_FW_BUSY				1
153505e9ebbeSSumant Patro 
1536def0eab3SShivasharan S /* Driver's internal Logging levels*/
153796c9603cSShivasharan S #define OCR_DEBUG    (1 << 0)
153896c9603cSShivasharan S #define TM_DEBUG     (1 << 1)
15390a11c0b0SShivasharan S #define LD_PD_DEBUG    (1 << 2)
1540def0eab3SShivasharan S 
154111c71cb4SSumit Saxena #define SCAN_PD_CHANNEL	0x1
154211c71cb4SSumit Saxena #define SCAN_VD_CHANNEL	0x2
154390dc9d98SSumit.Saxena@avagotech.com 
1544c3e385a1SSumit Saxena #define MEGASAS_KDUMP_QUEUE_DEPTH               100
1545a48ba0ecSShivasharan S #define MR_LARGE_IO_MIN_SIZE			(32 * 1024)
1546a48ba0ecSShivasharan S #define MR_R1_LDIO_PIGGYBACK_DEFAULT		4
1547c3e385a1SSumit Saxena 
15487497cde8SSumit.Saxena@avagotech.com enum MR_SCSI_CMD_TYPE {
15497497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_LDIO = 0,
15507497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_LDIO = 1,
15517497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_SYSPDIO = 2,
15527497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_SYSPDIO = 3,
15537497cde8SSumit.Saxena@avagotech.com };
15547497cde8SSumit.Saxena@avagotech.com 
15556d40afbcSSumit Saxena enum DCMD_TIMEOUT_ACTION {
15566d40afbcSSumit Saxena 	INITIATE_OCR = 0,
15576d40afbcSSumit Saxena 	KILL_ADAPTER = 1,
15586d40afbcSSumit Saxena 	IGNORE_TIMEOUT = 2,
15596d40afbcSSumit Saxena };
1560308ec459SSumit Saxena 
1561308ec459SSumit Saxena enum FW_BOOT_CONTEXT {
1562308ec459SSumit Saxena 	PROBE_CONTEXT = 0,
1563308ec459SSumit Saxena 	OCR_CONTEXT = 1,
1564308ec459SSumit Saxena };
1565308ec459SSumit Saxena 
1566d532dbe2Sbo yang /* Frame Type */
1567d532dbe2Sbo yang #define IO_FRAME				0
1568d532dbe2Sbo yang #define PTHRU_FRAME				1
1569d532dbe2Sbo yang 
1570c4a3e0a5SBagalkote, Sreenivas /*
1571c4a3e0a5SBagalkote, Sreenivas  * When SCSI mid-layer calls driver's reset routine, driver waits for
1572c4a3e0a5SBagalkote, Sreenivas  * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
1573c4a3e0a5SBagalkote, Sreenivas  * that the driver cannot _actually_ abort or reset pending commands. While
1574c4a3e0a5SBagalkote, Sreenivas  * it is waiting for the commands to complete, it prints a diagnostic message
1575c4a3e0a5SBagalkote, Sreenivas  * every MEGASAS_RESET_NOTICE_INTERVAL seconds
1576c4a3e0a5SBagalkote, Sreenivas  */
1577c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_RESET_WAIT_TIME			180
15782a3681e5SSumant Patro #define MEGASAS_INTERNAL_CMD_WAIT_TIME		180
1579c4a3e0a5SBagalkote, Sreenivas #define	MEGASAS_RESET_NOTICE_INTERVAL		5
1580c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOCTL_CMD			0
158105e9ebbeSSumant Patro #define MEGASAS_DEFAULT_CMD_TIMEOUT		90
1582c5daa6a9Sadam radford #define MEGASAS_THROTTLE_QUEUE_DEPTH		16
1583e9495e2dSShivasharan S #define MEGASAS_DEFAULT_TM_TIMEOUT		50
1584c4a3e0a5SBagalkote, Sreenivas /*
1585c4a3e0a5SBagalkote, Sreenivas  * FW reports the maximum of number of commands that it can accept (maximum
1586c4a3e0a5SBagalkote, Sreenivas  * commands that can be outstanding) at any time. The driver must report a
1587c4a3e0a5SBagalkote, Sreenivas  * lower number to the mid layer because it can issue a few internal commands
1588c4a3e0a5SBagalkote, Sreenivas  * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
1589c4a3e0a5SBagalkote, Sreenivas  * is shown below
1590c4a3e0a5SBagalkote, Sreenivas  */
1591c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_INT_CMDS			32
15927bebf5c7SYang, Bo #define MEGASAS_SKINNY_INT_CMDS			5
1593ec779595SShivasharan S #define MEGASAS_FUSION_INTERNAL_CMDS		8
1594ae09a6c1SSumit.Saxena@avagotech.com #define MEGASAS_FUSION_IOCTL_CMDS		3
1595f26ac3a1SSumit.Saxena@avagotech.com #define MEGASAS_MFI_IOCTL_CMDS			27
1596c4a3e0a5SBagalkote, Sreenivas 
1597d46a3ad6SSumit.Saxena@lsi.com #define MEGASAS_MAX_MSIX_QUEUES			128
1598c4a3e0a5SBagalkote, Sreenivas /*
1599c4a3e0a5SBagalkote, Sreenivas  * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
1600c4a3e0a5SBagalkote, Sreenivas  * SGLs based on the size of dma_addr_t
1601c4a3e0a5SBagalkote, Sreenivas  */
1602c4a3e0a5SBagalkote, Sreenivas #define IS_DMA64				(sizeof(dma_addr_t) == 8)
1603c4a3e0a5SBagalkote, Sreenivas 
160439a98554Sbo yang #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT		0x00000001
160539a98554Sbo yang 
160639a98554Sbo yang #define MFI_INTR_FLAG_REPLY_MESSAGE			0x00000001
160739a98554Sbo yang #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE		0x00000002
160839a98554Sbo yang #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT	0x00000004
160939a98554Sbo yang 
1610c4a3e0a5SBagalkote, Sreenivas #define MFI_OB_INTR_STATUS_MASK			0x00000002
161114faea9fSbo yang #define MFI_POLL_TIMEOUT_SECS			60
16126d40afbcSSumit Saxena #define MFI_IO_TIMEOUT_SECS			180
1613229fe47cSadam radford #define MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF	(5 * HZ)
1614229fe47cSadam radford #define MEGASAS_OCR_SETTLE_TIME_VF		(1000 * 30)
161544e8d693SShivasharan S #define MEGASAS_SRIOV_MAX_RESET_TRIES_VF	1
1616229fe47cSadam radford #define MEGASAS_ROUTINE_WAIT_TIME_VF		300
1617f9876f0bSSumant Patro #define MFI_REPLY_1078_MESSAGE_INTERRUPT	0x80000000
16186610a6b3SYang, Bo #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT	0x00000001
16196610a6b3SYang, Bo #define MFI_GEN2_ENABLE_INTERRUPT_MASK		(0x00000001 | 0x00000004)
162087911122SYang, Bo #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT	0x40000000
162187911122SYang, Bo #define MFI_SKINNY_ENABLE_INTERRUPT_MASK	(0x00000001)
16220e98936cSSumant Patro 
162339a98554Sbo yang #define MFI_1068_PCSR_OFFSET			0x84
162439a98554Sbo yang #define MFI_1068_FW_HANDSHAKE_OFFSET		0x64
162539a98554Sbo yang #define MFI_1068_FW_READY			0xDDDD0000
1626d46a3ad6SSumit.Saxena@lsi.com 
1627d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_OFFSET              0X0000001F
1628d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET          0X003FC000
1629d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT    14
1630d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_MSIX_REG_ARRAY                   16
1631179ac142SSumit Saxena #define MR_RDPQ_MODE_OFFSET			0X00800000
1632d889344eSSasikumar Chandrasekaran 
1633d889344eSSasikumar Chandrasekaran #define MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT	16
1634d889344eSSasikumar Chandrasekaran #define MR_MAX_RAID_MAP_SIZE_MASK		0x1FF
1635d889344eSSasikumar Chandrasekaran #define MR_MIN_MAP_SIZE				0x10000
1636d889344eSSasikumar Chandrasekaran /* 64k */
1637d889344eSSasikumar Chandrasekaran 
1638d0fc91d6SKashyap Desai #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000
1639d0fc91d6SKashyap Desai 
16405885571dSChandrakanth Patil #define MR_ATOMIC_DESCRIPTOR_SUPPORT_OFFSET	(1 << 24)
16415885571dSChandrakanth Patil 
1642107a60ddSShivasharan S #define MR_CAN_HANDLE_64_BIT_DMA_OFFSET		(1 << 25)
1643107a60ddSShivasharan S 
16443f6194afSShivasharan S #define MEGASAS_WATCHDOG_THREAD_INTERVAL	1000
16453f6194afSShivasharan S #define MEGASAS_WAIT_FOR_NEXT_DMA_MSECS		20
16463f6194afSShivasharan S #define MEGASAS_WATCHDOG_WAIT_COUNT		50
16473f6194afSShivasharan S 
1648c365178fSShivasharan S enum MR_ADAPTER_TYPE {
1649c365178fSShivasharan S 	MFI_SERIES = 1,
1650c365178fSShivasharan S 	THUNDERBOLT_SERIES = 2,
1651c365178fSShivasharan S 	INVADER_SERIES = 3,
1652c365178fSShivasharan S 	VENTURA_SERIES = 4,
1653154a7cdeSShivasharan S 	AERO_SERIES = 5,
1654c365178fSShivasharan S };
1655c365178fSShivasharan S 
16560e98936cSSumant Patro /*
16570e98936cSSumant Patro * register set for both 1068 and 1078 controllers
16580e98936cSSumant Patro * structure extended for 1078 registers
16590e98936cSSumant Patro */
1660c4a3e0a5SBagalkote, Sreenivas 
1661f9876f0bSSumant Patro struct megasas_register_set {
16629c915a8cSadam radford 	u32	doorbell;                       /*0000h*/
16639c915a8cSadam radford 	u32	fusion_seq_offset;		/*0004h*/
16649c915a8cSadam radford 	u32	fusion_host_diag;		/*0008h*/
16659c915a8cSadam radford 	u32	reserved_01;			/*000Ch*/
1666c4a3e0a5SBagalkote, Sreenivas 
1667c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_0;			/*0010h*/
1668c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_1;			/*0014h*/
1669c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_0;			/*0018h*/
1670c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_1;			/*001Ch*/
1671c4a3e0a5SBagalkote, Sreenivas 
1672c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_doorbell;		/*0020h*/
1673c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_status;		/*0024h*/
1674c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_mask;		/*0028h*/
1675c4a3e0a5SBagalkote, Sreenivas 
1676c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_doorbell;		/*002Ch*/
1677c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_status;		/*0030h*/
1678c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_mask;		/*0034h*/
1679c4a3e0a5SBagalkote, Sreenivas 
1680c4a3e0a5SBagalkote, Sreenivas 	u32 	reserved_1[2];			/*0038h*/
1681c4a3e0a5SBagalkote, Sreenivas 
1682c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_queue_port;		/*0040h*/
1683c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_queue_port;		/*0044h*/
1684c4a3e0a5SBagalkote, Sreenivas 
16859c915a8cSadam radford 	u32	reserved_2[9];			/*0048h*/
16869c915a8cSadam radford 	u32	reply_post_host_index;		/*006Ch*/
16879c915a8cSadam radford 	u32	reserved_2_2[12];		/*0070h*/
1688c4a3e0a5SBagalkote, Sreenivas 
1689f9876f0bSSumant Patro 	u32 	outbound_doorbell_clear;	/*00A0h*/
1690f9876f0bSSumant Patro 
1691f9876f0bSSumant Patro 	u32 	reserved_3[3];			/*00A4h*/
1692f9876f0bSSumant Patro 
169381b76452SShivasharan S 	u32	outbound_scratch_pad_0;		/*00B0h*/
169481b76452SShivasharan S 	u32	outbound_scratch_pad_1;         /*00B4h*/
169581b76452SShivasharan S 	u32	outbound_scratch_pad_2;         /*00B8h*/
169681b76452SShivasharan S 	u32	outbound_scratch_pad_3;         /*00BCh*/
1697f9876f0bSSumant Patro 
1698f9876f0bSSumant Patro 	u32 	inbound_low_queue_port ;	/*00C0h*/
1699f9876f0bSSumant Patro 
1700f9876f0bSSumant Patro 	u32 	inbound_high_queue_port ;	/*00C4h*/
1701f9876f0bSSumant Patro 
170245f4f2ebSSasikumar Chandrasekaran 	u32 inbound_single_queue_port;	/*00C8h*/
170339a98554Sbo yang 	u32	res_6[11];			/*CCh*/
170439a98554Sbo yang 	u32	host_diag;
170539a98554Sbo yang 	u32	seq_offset;
170639a98554Sbo yang 	u32 	index_registers[807];		/*00CCh*/
1707c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1708c4a3e0a5SBagalkote, Sreenivas 
1709c4a3e0a5SBagalkote, Sreenivas struct megasas_sge32 {
1710c4a3e0a5SBagalkote, Sreenivas 
17119ab9ed38SChristoph Hellwig 	__le32 phys_addr;
17129ab9ed38SChristoph Hellwig 	__le32 length;
1713c4a3e0a5SBagalkote, Sreenivas 
1714c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1715c4a3e0a5SBagalkote, Sreenivas 
1716c4a3e0a5SBagalkote, Sreenivas struct megasas_sge64 {
1717c4a3e0a5SBagalkote, Sreenivas 
17189ab9ed38SChristoph Hellwig 	__le64 phys_addr;
17199ab9ed38SChristoph Hellwig 	__le32 length;
1720c4a3e0a5SBagalkote, Sreenivas 
1721c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1722c4a3e0a5SBagalkote, Sreenivas 
1723f4c9a131SYang, Bo struct megasas_sge_skinny {
17249ab9ed38SChristoph Hellwig 	__le64 phys_addr;
17259ab9ed38SChristoph Hellwig 	__le32 length;
17269ab9ed38SChristoph Hellwig 	__le32 flag;
1727f4c9a131SYang, Bo } __packed;
1728f4c9a131SYang, Bo 
1729c4a3e0a5SBagalkote, Sreenivas union megasas_sgl {
1730c4a3e0a5SBagalkote, Sreenivas 
1731c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[1];
1732c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[1];
1733f4c9a131SYang, Bo 	struct megasas_sge_skinny sge_skinny[1];
1734c4a3e0a5SBagalkote, Sreenivas 
1735c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1736c4a3e0a5SBagalkote, Sreenivas 
1737c4a3e0a5SBagalkote, Sreenivas struct megasas_header {
1738c4a3e0a5SBagalkote, Sreenivas 
1739c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1740c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1741c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1742c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1743c4a3e0a5SBagalkote, Sreenivas 
1744c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1745c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1746c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1747c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1748c4a3e0a5SBagalkote, Sreenivas 
17499ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17509ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1751c4a3e0a5SBagalkote, Sreenivas 
17529ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17539ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
17549ab9ed38SChristoph Hellwig 	__le32 data_xferlen;	/*14h */
1755c4a3e0a5SBagalkote, Sreenivas 
1756c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1757c4a3e0a5SBagalkote, Sreenivas 
1758c4a3e0a5SBagalkote, Sreenivas union megasas_sgl_frame {
1759c4a3e0a5SBagalkote, Sreenivas 
1760c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[8];
1761c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[5];
1762c4a3e0a5SBagalkote, Sreenivas 
1763c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1764c4a3e0a5SBagalkote, Sreenivas 
1765d46a3ad6SSumit.Saxena@lsi.com typedef union _MFI_CAPABILITIES {
1766d46a3ad6SSumit.Saxena@lsi.com 	struct {
176794cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
1768f6fe5731SShivasharan S 	u32     reserved:16;
1769f6fe5731SShivasharan S 	u32	support_fw_exposed_dev_list:1;
1770f870bcbeSShivasharan S 	u32	support_nvme_passthru:1;
1771107a60ddSShivasharan S 	u32     support_64bit_mode:1;
1772ede7c3ceSSasikumar Chandrasekaran 	u32 support_pd_map_target_id:1;
177352b62ac7SSumit Saxena 	u32     support_qd_throttling:1;
17748f05024cSSumit Saxena 	u32     support_fp_rlbypass:1;
17758f05024cSSumit Saxena 	u32     support_vfid_in_ioframe:1;
1776bd5f9484Ssumit.saxena@avagotech.com 	u32     support_ext_io_size:1;
17770be3f4c9Ssumit.saxena@avagotech.com 	u32		support_ext_queue_depth:1;
17787497cde8SSumit.Saxena@avagotech.com 	u32     security_protocol_cmds_fw:1;
17797497cde8SSumit.Saxena@avagotech.com 	u32     support_core_affinity:1;
1780d2552ebeSSumit.Saxena@avagotech.com 	u32     support_ndrive_r1_lb:1;
178151087a86SSumit.Saxena@avagotech.com 	u32		support_max_255lds:1;
17827497cde8SSumit.Saxena@avagotech.com 	u32		support_fastpath_wb:1;
178394cd65ddSSumit.Saxena@lsi.com 	u32     support_additional_msix:1;
178494cd65ddSSumit.Saxena@lsi.com 	u32     support_fp_remote_lun:1;
178594cd65ddSSumit.Saxena@lsi.com #else
1786d46a3ad6SSumit.Saxena@lsi.com 	u32     support_fp_remote_lun:1;
1787d46a3ad6SSumit.Saxena@lsi.com 	u32     support_additional_msix:1;
17887497cde8SSumit.Saxena@avagotech.com 	u32		support_fastpath_wb:1;
178951087a86SSumit.Saxena@avagotech.com 	u32		support_max_255lds:1;
1790d2552ebeSSumit.Saxena@avagotech.com 	u32     support_ndrive_r1_lb:1;
17917497cde8SSumit.Saxena@avagotech.com 	u32     support_core_affinity:1;
17927497cde8SSumit.Saxena@avagotech.com 	u32     security_protocol_cmds_fw:1;
17930be3f4c9Ssumit.saxena@avagotech.com 	u32		support_ext_queue_depth:1;
1794bd5f9484Ssumit.saxena@avagotech.com 	u32     support_ext_io_size:1;
17958f05024cSSumit Saxena 	u32     support_vfid_in_ioframe:1;
17968f05024cSSumit Saxena 	u32     support_fp_rlbypass:1;
179752b62ac7SSumit Saxena 	u32     support_qd_throttling:1;
1798ede7c3ceSSasikumar Chandrasekaran 	u32	support_pd_map_target_id:1;
1799107a60ddSShivasharan S 	u32     support_64bit_mode:1;
1800f870bcbeSShivasharan S 	u32	support_nvme_passthru:1;
1801f6fe5731SShivasharan S 	u32	support_fw_exposed_dev_list:1;
1802f6fe5731SShivasharan S 	u32     reserved:16;
180394cd65ddSSumit.Saxena@lsi.com #endif
1804d46a3ad6SSumit.Saxena@lsi.com 	} mfi_capabilities;
18059ab9ed38SChristoph Hellwig 	__le32		reg;
1806d46a3ad6SSumit.Saxena@lsi.com } MFI_CAPABILITIES;
1807d46a3ad6SSumit.Saxena@lsi.com 
1808c4a3e0a5SBagalkote, Sreenivas struct megasas_init_frame {
1809c4a3e0a5SBagalkote, Sreenivas 
1810c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1811c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1812c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1813c4a3e0a5SBagalkote, Sreenivas 
1814c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
1815d46a3ad6SSumit.Saxena@lsi.com 	MFI_CAPABILITIES driver_operations; /*04h*/
1816c4a3e0a5SBagalkote, Sreenivas 
18179ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18189ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1819c4a3e0a5SBagalkote, Sreenivas 
18209ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18219ab9ed38SChristoph Hellwig 	__le16 reserved_3;		/*12h */
18229ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1823c4a3e0a5SBagalkote, Sreenivas 
18249ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_lo;	/*18h */
18259ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_hi;	/*1Ch */
18269ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_lo;	/*20h */
18279ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_hi;	/*24h */
18289ab9ed38SChristoph Hellwig 	__le32 reserved_4[2];	/*28h */
18299ab9ed38SChristoph Hellwig 	__le32 system_info_lo;      /*30h */
18309ab9ed38SChristoph Hellwig 	__le32 system_info_hi;      /*34h */
18319ab9ed38SChristoph Hellwig 	__le32 reserved_5[2];	/*38h */
1832c4a3e0a5SBagalkote, Sreenivas 
1833c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1834c4a3e0a5SBagalkote, Sreenivas 
1835c4a3e0a5SBagalkote, Sreenivas struct megasas_init_queue_info {
1836c4a3e0a5SBagalkote, Sreenivas 
18379ab9ed38SChristoph Hellwig 	__le32 init_flags;		/*00h */
18389ab9ed38SChristoph Hellwig 	__le32 reply_queue_entries;	/*04h */
1839c4a3e0a5SBagalkote, Sreenivas 
18409ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_lo;	/*08h */
18419ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_hi;	/*0Ch */
18429ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_lo;	/*10h */
18439ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_hi;	/*14h */
18449ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_lo;	/*18h */
18459ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_hi;	/*1Ch */
1846c4a3e0a5SBagalkote, Sreenivas 
1847c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1848c4a3e0a5SBagalkote, Sreenivas 
1849c4a3e0a5SBagalkote, Sreenivas struct megasas_io_frame {
1850c4a3e0a5SBagalkote, Sreenivas 
1851c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1852c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1853c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1854c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1855c4a3e0a5SBagalkote, Sreenivas 
1856c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1857c4a3e0a5SBagalkote, Sreenivas 	u8 access_byte;		/*05h */
1858c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*06h */
1859c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1860c4a3e0a5SBagalkote, Sreenivas 
18619ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18629ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1863c4a3e0a5SBagalkote, Sreenivas 
18649ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18659ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
18669ab9ed38SChristoph Hellwig 	__le32 lba_count;	/*14h */
1867c4a3e0a5SBagalkote, Sreenivas 
18689ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
18699ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1870c4a3e0a5SBagalkote, Sreenivas 
18719ab9ed38SChristoph Hellwig 	__le32 start_lba_lo;	/*20h */
18729ab9ed38SChristoph Hellwig 	__le32 start_lba_hi;	/*24h */
1873c4a3e0a5SBagalkote, Sreenivas 
1874c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1875c4a3e0a5SBagalkote, Sreenivas 
1876c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1877c4a3e0a5SBagalkote, Sreenivas 
1878c4a3e0a5SBagalkote, Sreenivas struct megasas_pthru_frame {
1879c4a3e0a5SBagalkote, Sreenivas 
1880c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1881c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1882c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1883c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1884c4a3e0a5SBagalkote, Sreenivas 
1885c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1886c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1887c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1888c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1889c4a3e0a5SBagalkote, Sreenivas 
18909ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18919ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1892c4a3e0a5SBagalkote, Sreenivas 
18939ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18949ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
18959ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1896c4a3e0a5SBagalkote, Sreenivas 
18979ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
18989ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1899c4a3e0a5SBagalkote, Sreenivas 
1900c4a3e0a5SBagalkote, Sreenivas 	u8 cdb[16];		/*20h */
1901c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*30h */
1902c4a3e0a5SBagalkote, Sreenivas 
1903c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1904c4a3e0a5SBagalkote, Sreenivas 
1905c4a3e0a5SBagalkote, Sreenivas struct megasas_dcmd_frame {
1906c4a3e0a5SBagalkote, Sreenivas 
1907c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1908c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1909c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1910c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1[4];	/*03h */
1911c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1912c4a3e0a5SBagalkote, Sreenivas 
19139ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
19149ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1915c4a3e0a5SBagalkote, Sreenivas 
19169ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
19179ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1918c4a3e0a5SBagalkote, Sreenivas 
19199ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
19209ab9ed38SChristoph Hellwig 	__le32 opcode;		/*18h */
1921c4a3e0a5SBagalkote, Sreenivas 
1922c4a3e0a5SBagalkote, Sreenivas 	union {			/*1Ch */
1923c4a3e0a5SBagalkote, Sreenivas 		u8 b[12];
19249ab9ed38SChristoph Hellwig 		__le16 s[6];
19259ab9ed38SChristoph Hellwig 		__le32 w[3];
1926c4a3e0a5SBagalkote, Sreenivas 	} mbox;
1927c4a3e0a5SBagalkote, Sreenivas 
1928c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1929c4a3e0a5SBagalkote, Sreenivas 
1930c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1931c4a3e0a5SBagalkote, Sreenivas 
1932c4a3e0a5SBagalkote, Sreenivas struct megasas_abort_frame {
1933c4a3e0a5SBagalkote, Sreenivas 
1934c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1935c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1936c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1937c4a3e0a5SBagalkote, Sreenivas 
1938c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
19399ab9ed38SChristoph Hellwig 	__le32 reserved_2;	/*04h */
1940c4a3e0a5SBagalkote, Sreenivas 
19419ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
19429ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1943c4a3e0a5SBagalkote, Sreenivas 
19449ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
19459ab9ed38SChristoph Hellwig 	__le16 reserved_3;	/*12h */
19469ab9ed38SChristoph Hellwig 	__le32 reserved_4;	/*14h */
1947c4a3e0a5SBagalkote, Sreenivas 
19489ab9ed38SChristoph Hellwig 	__le32 abort_context;	/*18h */
19499ab9ed38SChristoph Hellwig 	__le32 pad_1;		/*1Ch */
1950c4a3e0a5SBagalkote, Sreenivas 
19519ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_lo;	/*20h */
19529ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_hi;	/*24h */
1953c4a3e0a5SBagalkote, Sreenivas 
19549ab9ed38SChristoph Hellwig 	__le32 reserved_5[6];	/*28h */
1955c4a3e0a5SBagalkote, Sreenivas 
1956c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1957c4a3e0a5SBagalkote, Sreenivas 
1958c4a3e0a5SBagalkote, Sreenivas struct megasas_smp_frame {
1959c4a3e0a5SBagalkote, Sreenivas 
1960c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1961c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1962c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1963c4a3e0a5SBagalkote, Sreenivas 	u8 connection_status;	/*03h */
1964c4a3e0a5SBagalkote, Sreenivas 
1965c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[3];	/*04h */
1966c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1967c4a3e0a5SBagalkote, Sreenivas 
19689ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
19699ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1970c4a3e0a5SBagalkote, Sreenivas 
19719ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
19729ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1973c4a3e0a5SBagalkote, Sreenivas 
19749ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
19759ab9ed38SChristoph Hellwig 	__le64 sas_addr;	/*18h */
1976c4a3e0a5SBagalkote, Sreenivas 
1977c4a3e0a5SBagalkote, Sreenivas 	union {
1978c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: req */
1979c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: req */
1980c4a3e0a5SBagalkote, Sreenivas 	} sgl;
1981c4a3e0a5SBagalkote, Sreenivas 
1982c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1983c4a3e0a5SBagalkote, Sreenivas 
1984c4a3e0a5SBagalkote, Sreenivas struct megasas_stp_frame {
1985c4a3e0a5SBagalkote, Sreenivas 
1986c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1987c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1988c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1989c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2;		/*03h */
1990c4a3e0a5SBagalkote, Sreenivas 
1991c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1992c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_3[2];	/*05h */
1993c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1994c4a3e0a5SBagalkote, Sreenivas 
19959ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
19969ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1997c4a3e0a5SBagalkote, Sreenivas 
19989ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
19999ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
2000c4a3e0a5SBagalkote, Sreenivas 
20019ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
2002c4a3e0a5SBagalkote, Sreenivas 
20039ab9ed38SChristoph Hellwig 	__le16 fis[10];		/*18h */
20049ab9ed38SChristoph Hellwig 	__le32 stp_flags;
2005c4a3e0a5SBagalkote, Sreenivas 
2006c4a3e0a5SBagalkote, Sreenivas 	union {
2007c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: data */
2008c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: data */
2009c4a3e0a5SBagalkote, Sreenivas 	} sgl;
2010c4a3e0a5SBagalkote, Sreenivas 
2011c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2012c4a3e0a5SBagalkote, Sreenivas 
2013c4a3e0a5SBagalkote, Sreenivas union megasas_frame {
2014c4a3e0a5SBagalkote, Sreenivas 
2015c4a3e0a5SBagalkote, Sreenivas 	struct megasas_header hdr;
2016c4a3e0a5SBagalkote, Sreenivas 	struct megasas_init_frame init;
2017c4a3e0a5SBagalkote, Sreenivas 	struct megasas_io_frame io;
2018c4a3e0a5SBagalkote, Sreenivas 	struct megasas_pthru_frame pthru;
2019c4a3e0a5SBagalkote, Sreenivas 	struct megasas_dcmd_frame dcmd;
2020c4a3e0a5SBagalkote, Sreenivas 	struct megasas_abort_frame abort;
2021c4a3e0a5SBagalkote, Sreenivas 	struct megasas_smp_frame smp;
2022c4a3e0a5SBagalkote, Sreenivas 	struct megasas_stp_frame stp;
2023c4a3e0a5SBagalkote, Sreenivas 
2024c4a3e0a5SBagalkote, Sreenivas 	u8 raw_bytes[64];
2025c4a3e0a5SBagalkote, Sreenivas };
2026c4a3e0a5SBagalkote, Sreenivas 
202718365b13SSumit Saxena /**
202818365b13SSumit Saxena  * struct MR_PRIV_DEVICE - sdev private hostdata
202918365b13SSumit Saxena  * @is_tm_capable: firmware managed tm_capable flag
203018365b13SSumit Saxena  * @tm_busy: TM request is in progress
203118365b13SSumit Saxena  */
203218365b13SSumit Saxena struct MR_PRIV_DEVICE {
203318365b13SSumit Saxena 	bool is_tm_capable;
203418365b13SSumit Saxena 	bool tm_busy;
2035a48ba0ecSShivasharan S 	atomic_t r1_ldio_hint;
203615dd0381SShivasharan S 	u8 interface_type;
2037e9495e2dSShivasharan S 	u8 task_abort_tmo;
2038e9495e2dSShivasharan S 	u8 target_reset_tmo;
203918365b13SSumit Saxena };
2040c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd;
2041c4a3e0a5SBagalkote, Sreenivas 
2042c4a3e0a5SBagalkote, Sreenivas union megasas_evt_class_locale {
2043c4a3e0a5SBagalkote, Sreenivas 
2044c4a3e0a5SBagalkote, Sreenivas 	struct {
2045be26374bSSumit.Saxena@lsi.com #ifndef __BIG_ENDIAN_BITFIELD
2046c4a3e0a5SBagalkote, Sreenivas 		u16 locale;
2047c4a3e0a5SBagalkote, Sreenivas 		u8 reserved;
2048c4a3e0a5SBagalkote, Sreenivas 		s8 class;
2049be26374bSSumit.Saxena@lsi.com #else
2050be26374bSSumit.Saxena@lsi.com 		s8 class;
2051be26374bSSumit.Saxena@lsi.com 		u8 reserved;
2052be26374bSSumit.Saxena@lsi.com 		u16 locale;
2053be26374bSSumit.Saxena@lsi.com #endif
2054c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) members;
2055c4a3e0a5SBagalkote, Sreenivas 
2056c4a3e0a5SBagalkote, Sreenivas 	u32 word;
2057c4a3e0a5SBagalkote, Sreenivas 
2058c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2059c4a3e0a5SBagalkote, Sreenivas 
2060c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_log_info {
20619ab9ed38SChristoph Hellwig 	__le32 newest_seq_num;
20629ab9ed38SChristoph Hellwig 	__le32 oldest_seq_num;
20639ab9ed38SChristoph Hellwig 	__le32 clear_seq_num;
20649ab9ed38SChristoph Hellwig 	__le32 shutdown_seq_num;
20659ab9ed38SChristoph Hellwig 	__le32 boot_seq_num;
2066c4a3e0a5SBagalkote, Sreenivas 
2067c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2068c4a3e0a5SBagalkote, Sreenivas 
2069c4a3e0a5SBagalkote, Sreenivas struct megasas_progress {
2070c4a3e0a5SBagalkote, Sreenivas 
20719ab9ed38SChristoph Hellwig 	__le16 progress;
20729ab9ed38SChristoph Hellwig 	__le16 elapsed_seconds;
2073c4a3e0a5SBagalkote, Sreenivas 
2074c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2075c4a3e0a5SBagalkote, Sreenivas 
2076c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_ld {
2077c4a3e0a5SBagalkote, Sreenivas 
2078c4a3e0a5SBagalkote, Sreenivas 	u16 target_id;
2079c4a3e0a5SBagalkote, Sreenivas 	u8 ld_index;
2080c4a3e0a5SBagalkote, Sreenivas 	u8 reserved;
2081c4a3e0a5SBagalkote, Sreenivas 
2082c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2083c4a3e0a5SBagalkote, Sreenivas 
2084c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_pd {
2085c4a3e0a5SBagalkote, Sreenivas 	u16 device_id;
2086c4a3e0a5SBagalkote, Sreenivas 	u8 encl_index;
2087c4a3e0a5SBagalkote, Sreenivas 	u8 slot_number;
2088c4a3e0a5SBagalkote, Sreenivas 
2089c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2090c4a3e0a5SBagalkote, Sreenivas 
2091c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_detail {
2092c4a3e0a5SBagalkote, Sreenivas 
20939ab9ed38SChristoph Hellwig 	__le32 seq_num;
20949ab9ed38SChristoph Hellwig 	__le32 time_stamp;
20959ab9ed38SChristoph Hellwig 	__le32 code;
2096c4a3e0a5SBagalkote, Sreenivas 	union megasas_evt_class_locale cl;
2097c4a3e0a5SBagalkote, Sreenivas 	u8 arg_type;
2098c4a3e0a5SBagalkote, Sreenivas 	u8 reserved1[15];
2099c4a3e0a5SBagalkote, Sreenivas 
2100c4a3e0a5SBagalkote, Sreenivas 	union {
2101c4a3e0a5SBagalkote, Sreenivas 		struct {
2102c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2103c4a3e0a5SBagalkote, Sreenivas 			u8 cdb_length;
2104c4a3e0a5SBagalkote, Sreenivas 			u8 sense_length;
2105c4a3e0a5SBagalkote, Sreenivas 			u8 reserved[2];
2106c4a3e0a5SBagalkote, Sreenivas 			u8 cdb[16];
2107c4a3e0a5SBagalkote, Sreenivas 			u8 sense[64];
2108c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) cdbSense;
2109c4a3e0a5SBagalkote, Sreenivas 
2110c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_ld ld;
2111c4a3e0a5SBagalkote, Sreenivas 
2112c4a3e0a5SBagalkote, Sreenivas 		struct {
2113c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
21149ab9ed38SChristoph Hellwig 			__le64 count;
2115c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_count;
2116c4a3e0a5SBagalkote, Sreenivas 
2117c4a3e0a5SBagalkote, Sreenivas 		struct {
21189ab9ed38SChristoph Hellwig 			__le64 lba;
2119c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2120c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba;
2121c4a3e0a5SBagalkote, Sreenivas 
2122c4a3e0a5SBagalkote, Sreenivas 		struct {
2123c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
21249ab9ed38SChristoph Hellwig 			__le32 prevOwner;
21259ab9ed38SChristoph Hellwig 			__le32 newOwner;
2126c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_owner;
2127c4a3e0a5SBagalkote, Sreenivas 
2128c4a3e0a5SBagalkote, Sreenivas 		struct {
2129c4a3e0a5SBagalkote, Sreenivas 			u64 ld_lba;
2130c4a3e0a5SBagalkote, Sreenivas 			u64 pd_lba;
2131c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2132c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2133c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba_pd_lba;
2134c4a3e0a5SBagalkote, Sreenivas 
2135c4a3e0a5SBagalkote, Sreenivas 		struct {
2136c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2137c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
2138c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_prog;
2139c4a3e0a5SBagalkote, Sreenivas 
2140c4a3e0a5SBagalkote, Sreenivas 		struct {
2141c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2142c4a3e0a5SBagalkote, Sreenivas 			u32 prev_state;
2143c4a3e0a5SBagalkote, Sreenivas 			u32 new_state;
2144c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_state;
2145c4a3e0a5SBagalkote, Sreenivas 
2146c4a3e0a5SBagalkote, Sreenivas 		struct {
2147c4a3e0a5SBagalkote, Sreenivas 			u64 strip;
2148c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2149c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_strip;
2150c4a3e0a5SBagalkote, Sreenivas 
2151c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_pd pd;
2152c4a3e0a5SBagalkote, Sreenivas 
2153c4a3e0a5SBagalkote, Sreenivas 		struct {
2154c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2155c4a3e0a5SBagalkote, Sreenivas 			u32 err;
2156c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_err;
2157c4a3e0a5SBagalkote, Sreenivas 
2158c4a3e0a5SBagalkote, Sreenivas 		struct {
2159c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
2160c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2161c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba;
2162c4a3e0a5SBagalkote, Sreenivas 
2163c4a3e0a5SBagalkote, Sreenivas 		struct {
2164c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
2165c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2166c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2167c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba_ld;
2168c4a3e0a5SBagalkote, Sreenivas 
2169c4a3e0a5SBagalkote, Sreenivas 		struct {
2170c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2171c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
2172c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_prog;
2173c4a3e0a5SBagalkote, Sreenivas 
2174c4a3e0a5SBagalkote, Sreenivas 		struct {
2175c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2176c4a3e0a5SBagalkote, Sreenivas 			u32 prevState;
2177c4a3e0a5SBagalkote, Sreenivas 			u32 newState;
2178c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_state;
2179c4a3e0a5SBagalkote, Sreenivas 
2180c4a3e0a5SBagalkote, Sreenivas 		struct {
2181c4a3e0a5SBagalkote, Sreenivas 			u16 vendorId;
21829ab9ed38SChristoph Hellwig 			__le16 deviceId;
2183c4a3e0a5SBagalkote, Sreenivas 			u16 subVendorId;
2184c4a3e0a5SBagalkote, Sreenivas 			u16 subDeviceId;
2185c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pci;
2186c4a3e0a5SBagalkote, Sreenivas 
2187c4a3e0a5SBagalkote, Sreenivas 		u32 rate;
2188c4a3e0a5SBagalkote, Sreenivas 		char str[96];
2189c4a3e0a5SBagalkote, Sreenivas 
2190c4a3e0a5SBagalkote, Sreenivas 		struct {
2191c4a3e0a5SBagalkote, Sreenivas 			u32 rtc;
2192c4a3e0a5SBagalkote, Sreenivas 			u32 elapsedSeconds;
2193c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) time;
2194c4a3e0a5SBagalkote, Sreenivas 
2195c4a3e0a5SBagalkote, Sreenivas 		struct {
2196c4a3e0a5SBagalkote, Sreenivas 			u32 ecar;
2197c4a3e0a5SBagalkote, Sreenivas 			u32 elog;
2198c4a3e0a5SBagalkote, Sreenivas 			char str[64];
2199c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ecc;
2200c4a3e0a5SBagalkote, Sreenivas 
2201c4a3e0a5SBagalkote, Sreenivas 		u8 b[96];
22029ab9ed38SChristoph Hellwig 		__le16 s[48];
22039ab9ed38SChristoph Hellwig 		__le32 w[24];
22049ab9ed38SChristoph Hellwig 		__le64 d[12];
2205c4a3e0a5SBagalkote, Sreenivas 	} args;
2206c4a3e0a5SBagalkote, Sreenivas 
2207c4a3e0a5SBagalkote, Sreenivas 	char description[128];
2208c4a3e0a5SBagalkote, Sreenivas 
2209c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2210c4a3e0a5SBagalkote, Sreenivas 
22117e8a75f4SYang, Bo struct megasas_aen_event {
2212c1d390d8SXiaotian Feng 	struct delayed_work hotplug_work;
22137e8a75f4SYang, Bo 	struct megasas_instance *instance;
22147e8a75f4SYang, Bo };
22157e8a75f4SYang, Bo 
2216c8e858feSadam radford struct megasas_irq_context {
2217c8e858feSadam radford 	struct megasas_instance *instance;
2218c8e858feSadam radford 	u32 MSIxIndex;
221962a04f81SShivasharan S 	u32 os_irq;
222062a04f81SShivasharan S 	struct irq_poll irqpoll;
222162a04f81SShivasharan S 	bool irq_poll_scheduled;
2222a6ffd5bfSChandrakanth Patil 	bool irq_line_enable;
2223c8e858feSadam radford };
2224c8e858feSadam radford 
22255765c5b8SSumit.Saxena@avagotech.com struct MR_DRV_SYSTEM_INFO {
22265765c5b8SSumit.Saxena@avagotech.com 	u8	infoVersion;
22275765c5b8SSumit.Saxena@avagotech.com 	u8	systemIdLength;
22285765c5b8SSumit.Saxena@avagotech.com 	u16	reserved0;
22295765c5b8SSumit.Saxena@avagotech.com 	u8	systemId[64];
22305765c5b8SSumit.Saxena@avagotech.com 	u8	reserved[1980];
22315765c5b8SSumit.Saxena@avagotech.com };
22325765c5b8SSumit.Saxena@avagotech.com 
22332216c305SSumit Saxena enum MR_PD_TYPE {
22342216c305SSumit Saxena 	UNKNOWN_DRIVE = 0,
22352216c305SSumit Saxena 	PARALLEL_SCSI = 1,
22362216c305SSumit Saxena 	SAS_PD = 2,
22372216c305SSumit Saxena 	SATA_PD = 3,
22382216c305SSumit Saxena 	FC_PD = 4,
223915dd0381SShivasharan S 	NVME_PD = 5,
22402216c305SSumit Saxena };
22412216c305SSumit Saxena 
22422216c305SSumit Saxena /* JBOD Queue depth definitions */
22432216c305SSumit Saxena #define MEGASAS_SATA_QD	32
22442216c305SSumit Saxena #define MEGASAS_SAS_QD	64
22452216c305SSumit Saxena #define MEGASAS_DEFAULT_PD_QD	64
224615dd0381SShivasharan S #define MEGASAS_NVME_QD		32
224715dd0381SShivasharan S 
224815dd0381SShivasharan S #define MR_DEFAULT_NVME_PAGE_SIZE	4096
224915dd0381SShivasharan S #define MR_DEFAULT_NVME_PAGE_SHIFT	12
225015dd0381SShivasharan S #define MR_DEFAULT_NVME_MDTS_KB		128
225115dd0381SShivasharan S #define MR_NVME_PAGE_SIZE_MASK		0x000000FF
22522216c305SSumit Saxena 
2253c4a3e0a5SBagalkote, Sreenivas struct megasas_instance {
2254c4a3e0a5SBagalkote, Sreenivas 
2255adbe5523SMing Lei 	unsigned int *reply_map;
22569ab9ed38SChristoph Hellwig 	__le32 *producer;
2257c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t producer_h;
22589ab9ed38SChristoph Hellwig 	__le32 *consumer;
2259c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t consumer_h;
22605765c5b8SSumit.Saxena@avagotech.com 	struct MR_DRV_SYSTEM_INFO *system_info_buf;
22615765c5b8SSumit.Saxena@avagotech.com 	dma_addr_t system_info_h;
2262229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION *vf_affiliation;
2263229fe47cSadam radford 	dma_addr_t vf_affiliation_h;
2264229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION_111 *vf_affiliation_111;
2265229fe47cSadam radford 	dma_addr_t vf_affiliation_111_h;
2266229fe47cSadam radford 	struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
2267229fe47cSadam radford 	dma_addr_t hb_host_mem_h;
22682216c305SSumit Saxena 	struct MR_PD_INFO *pd_info;
22692216c305SSumit Saxena 	dma_addr_t pd_info_h;
227096188a89SShivasharan S 	struct MR_TARGET_PROPERTIES *tgt_prop;
227196188a89SShivasharan S 	dma_addr_t tgt_prop_h;
2272c4a3e0a5SBagalkote, Sreenivas 
22739ab9ed38SChristoph Hellwig 	__le32 *reply_queue;
2274c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t reply_queue_h;
2275c4a3e0a5SBagalkote, Sreenivas 
2276fc62b3fcSSumit.Saxena@avagotech.com 	u32 *crash_dump_buf;
2277fc62b3fcSSumit.Saxena@avagotech.com 	dma_addr_t crash_dump_h;
22789b3d028fSShivasharan S 
22799b3d028fSShivasharan S 	struct MR_PD_LIST *pd_list_buf;
22809b3d028fSShivasharan S 	dma_addr_t pd_list_buf_h;
22819b3d028fSShivasharan S 
22829b3d028fSShivasharan S 	struct megasas_ctrl_info *ctrl_info_buf;
22839b3d028fSShivasharan S 	dma_addr_t ctrl_info_buf_h;
22849b3d028fSShivasharan S 
22859b3d028fSShivasharan S 	struct MR_LD_LIST *ld_list_buf;
22869b3d028fSShivasharan S 	dma_addr_t ld_list_buf_h;
22879b3d028fSShivasharan S 
22889b3d028fSShivasharan S 	struct MR_LD_TARGETID_LIST *ld_targetid_list_buf;
22899b3d028fSShivasharan S 	dma_addr_t ld_targetid_list_buf_h;
22909b3d028fSShivasharan S 
2291f6fe5731SShivasharan S 	struct MR_HOST_DEVICE_LIST *host_device_list_buf;
2292f6fe5731SShivasharan S 	dma_addr_t host_device_list_buf_h;
2293f6fe5731SShivasharan S 
2294f0c21df6SShivasharan S 	struct MR_SNAPDUMP_PROPERTIES *snapdump_prop;
2295f0c21df6SShivasharan S 	dma_addr_t snapdump_prop_h;
2296f0c21df6SShivasharan S 
2297fc62b3fcSSumit.Saxena@avagotech.com 	void *crash_buf[MAX_CRASH_DUMP_SIZE];
2298fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_size;
2299fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_state;
2300fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_offset;
2301fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_index;
2302fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_alloc;
2303fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_fw_support;
2304fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_drv_support;
2305fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_app_support;
23067497cde8SSumit.Saxena@avagotech.com 	u32 secure_jbod_support;
2307ede7c3ceSSasikumar Chandrasekaran 	u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
23083761cb4cSsumit.saxena@avagotech.com 	bool use_seqnum_jbod_fp;   /* Added for PD sequence */
23091d15d909SShivasharan S 	bool smp_affinity_enable;
2310fc62b3fcSSumit.Saxena@avagotech.com 	spinlock_t crashdump_lock;
2311fc62b3fcSSumit.Saxena@avagotech.com 
2312c4a3e0a5SBagalkote, Sreenivas 	struct megasas_register_set __iomem *reg_set;
23138a232bb3SChristoph Hellwig 	u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
231481e403ceSYang, Bo 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
2315999ece0aSSumit.Saxena@lsi.com 	struct megasas_pd_list          local_pd_list[MEGASAS_MAX_PD];
2316bdc6fb8dSYang, Bo 	u8 ld_ids[MEGASAS_MAX_LD_IDS];
2317c4a3e0a5SBagalkote, Sreenivas 	s8 init_id;
2318c4a3e0a5SBagalkote, Sreenivas 
2319c4a3e0a5SBagalkote, Sreenivas 	u16 max_num_sge;
2320c4a3e0a5SBagalkote, Sreenivas 	u16 max_fw_cmds;
232169c337c0SSasikumar Chandrasekaran 	u16 max_mpt_cmds;
23229c915a8cSadam radford 	u16 max_mfi_cmds;
2323ae09a6c1SSumit.Saxena@avagotech.com 	u16 max_scsi_cmds;
2324308ec459SSumit Saxena 	u16 ldio_threshold;
2325308ec459SSumit Saxena 	u16 cur_can_queue;
2326c4a3e0a5SBagalkote, Sreenivas 	u32 max_sectors_per_req;
23271d15d909SShivasharan S 	bool msix_load_balance;
23287e8a75f4SYang, Bo 	struct megasas_aen_event *ev;
2329c4a3e0a5SBagalkote, Sreenivas 
2330c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd **cmd_list;
2331c4a3e0a5SBagalkote, Sreenivas 	struct list_head cmd_pool;
233239a98554Sbo yang 	/* used to sync fire the cmd to fw */
233390dc9d98SSumit.Saxena@avagotech.com 	spinlock_t mfi_pool_lock;
233439a98554Sbo yang 	/* used to sync fire the cmd to fw */
233539a98554Sbo yang 	spinlock_t hba_lock;
23367343eb65Sbo yang 	/* used to synch producer, consumer ptrs in dpc */
2337fdd84e25SSasikumar Chandrasekaran 	spinlock_t stream_lock;
23387343eb65Sbo yang 	spinlock_t completion_lock;
2339c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *frame_dma_pool;
2340c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *sense_dma_pool;
2341c4a3e0a5SBagalkote, Sreenivas 
2342c4a3e0a5SBagalkote, Sreenivas 	struct megasas_evt_detail *evt_detail;
2343c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t evt_detail_h;
2344c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd *aen_cmd;
2345c4a3e0a5SBagalkote, Sreenivas 	struct semaphore ioctl_sem;
2346c4a3e0a5SBagalkote, Sreenivas 
2347c4a3e0a5SBagalkote, Sreenivas 	struct Scsi_Host *host;
2348c4a3e0a5SBagalkote, Sreenivas 
2349c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t int_cmd_wait_q;
2350c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t abort_cmd_wait_q;
2351c4a3e0a5SBagalkote, Sreenivas 
2352c4a3e0a5SBagalkote, Sreenivas 	struct pci_dev *pdev;
2353c4a3e0a5SBagalkote, Sreenivas 	u32 unique_id;
235439a98554Sbo yang 	u32 fw_support_ieee;
235562a04f81SShivasharan S 	u32 threshold_reply_count;
2356c4a3e0a5SBagalkote, Sreenivas 
2357e4a082c7SSumant Patro 	atomic_t fw_outstanding;
2358308ec459SSumit Saxena 	atomic_t ldio_outstanding;
235939a98554Sbo yang 	atomic_t fw_reset_no_pci_access;
23601d15d909SShivasharan S 	atomic64_t total_io_count;
23611341c939SSumant Patro 
23621341c939SSumant Patro 	struct megasas_instance_template *instancet;
23635d018ad0SSumant Patro 	struct tasklet_struct isr_tasklet;
236439a98554Sbo yang 	struct work_struct work_init;
23653f6194afSShivasharan S 	struct delayed_work fw_fault_work;
23663f6194afSShivasharan S 	struct workqueue_struct *fw_fault_work_q;
23673f6194afSShivasharan S 	char fault_handler_work_q_name[48];
236805e9ebbeSSumant Patro 
236905e9ebbeSSumant Patro 	u8 flag;
2370c3518837SYang, Bo 	u8 unload;
2371f4c9a131SYang, Bo 	u8 flag_ieee;
237239a98554Sbo yang 	u8 issuepend_done;
237339a98554Sbo yang 	u8 disableOnlineCtrlReset;
2374bc93d425SSumit.Saxena@lsi.com 	u8 UnevenSpanSupport;
237551087a86SSumit.Saxena@avagotech.com 
237651087a86SSumit.Saxena@avagotech.com 	u8 supportmax256vd;
237730845586SSumit Saxena 	u8 pd_list_not_supported;
237851087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_vd_count;
237951087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_pd_count;
238051087a86SSumit.Saxena@avagotech.com 
238151087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_vd_count;
238251087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_pd_count;
238351087a86SSumit.Saxena@avagotech.com 
23848a01a41dSSumit Saxena 	atomic_t adprecovery;
238505e9ebbeSSumant Patro 	unsigned long last_time;
238639a98554Sbo yang 	u32 mfiStatus;
238739a98554Sbo yang 	u32 last_seq_num;
2388ad84db2eSbo yang 
238939a98554Sbo yang 	struct list_head internal_reset_pending_q;
239080d9da98Sadam radford 
239125985edcSLucas De Marchi 	/* Ptr to hba specific information */
23929c915a8cSadam radford 	void *ctrl_context;
2393c8e858feSadam radford 	unsigned int msix_vectors;
2394c8e858feSadam radford 	struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
23959c915a8cSadam radford 	u64 map_id;
23963761cb4cSsumit.saxena@avagotech.com 	u64 pd_seq_map_id;
23979c915a8cSadam radford 	struct megasas_cmd *map_update_cmd;
23983761cb4cSsumit.saxena@avagotech.com 	struct megasas_cmd *jbod_seq_cmd;
2399b6d5d880Sadam radford 	unsigned long bar;
24009c915a8cSadam radford 	long reset_flags;
24019c915a8cSadam radford 	struct mutex reset_mutex;
2402229fe47cSadam radford 	struct timer_list sriov_heartbeat_timer;
2403229fe47cSadam radford 	char skip_heartbeat_timer_del;
2404229fe47cSadam radford 	u8 requestorId;
2405229fe47cSadam radford 	char PlasmaFW111;
24068f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE];
24078f67c8c5SSumit Saxena 	u8 peerIsPresent;
24088f67c8c5SSumit Saxena 	u8 passive;
2409ae09a6c1SSumit.Saxena@avagotech.com 	u16 throttlequeuedepth;
2410d46a3ad6SSumit.Saxena@lsi.com 	u8 mask_interrupts;
2411bd5f9484Ssumit.saxena@avagotech.com 	u16 max_chain_frame_sz;
2412404a8a1aSSumit.Saxena@lsi.com 	u8 is_imr;
2413179ac142SSumit Saxena 	u8 is_rdpq;
24145765c5b8SSumit.Saxena@avagotech.com 	bool dev_handle;
2415d0fc91d6SKashyap Desai 	bool fw_sync_cache_support;
241621c34006SShivasharan S 	u32 mfi_frame_size;
24172493c67eSSasikumar Chandrasekaran 	bool msix_combined;
2418d889344eSSasikumar Chandrasekaran 	u16 max_raid_mapsize;
2419a48ba0ecSShivasharan S 	/* preffered count to send as LDIO irrspective of FP capable.*/
2420a48ba0ecSShivasharan S 	u8  r1_ldio_hint_default;
242115dd0381SShivasharan S 	u32 nvme_page_size;
2422c365178fSShivasharan S 	u8 adapter_type;
2423107a60ddSShivasharan S 	bool consistent_mask_64bit;
2424f870bcbeSShivasharan S 	bool support_nvme_passthru;
2425e9495e2dSShivasharan S 	u8 task_abort_tmo;
2426e9495e2dSShivasharan S 	u8 max_reset_tmo;
2427f0c21df6SShivasharan S 	u8 snapdump_wait_time;
2428ba53572bSShivasharan S #ifdef CONFIG_DEBUG_FS
2429ba53572bSShivasharan S 	struct dentry *debugfs_root;
2430ba53572bSShivasharan S 	struct dentry *raidmap_dump;
2431ba53572bSShivasharan S #endif
2432f6fe5731SShivasharan S 	u8 enable_fw_dev_list;
24335885571dSChandrakanth Patil 	bool atomic_desc_support;
243459db5a93SChandrakanth Patil 	bool support_seqnum_jbod_fp;
243558136856SChandrakanth Patil 	bool support_pci_lane_margining;
243639a98554Sbo yang };
243759db5a93SChandrakanth Patil 
2438229fe47cSadam radford struct MR_LD_VF_MAP {
2439229fe47cSadam radford 	u32 size;
2440229fe47cSadam radford 	union MR_LD_REF ref;
2441229fe47cSadam radford 	u8 ldVfCount;
2442229fe47cSadam radford 	u8 reserved[6];
2443229fe47cSadam radford 	u8 policy[1];
2444229fe47cSadam radford };
2445229fe47cSadam radford 
2446229fe47cSadam radford struct MR_LD_VF_AFFILIATION {
2447229fe47cSadam radford 	u32 size;
2448229fe47cSadam radford 	u8 ldCount;
2449229fe47cSadam radford 	u8 vfCount;
2450229fe47cSadam radford 	u8 thisVf;
2451229fe47cSadam radford 	u8 reserved[9];
2452229fe47cSadam radford 	struct MR_LD_VF_MAP map[1];
2453229fe47cSadam radford };
2454229fe47cSadam radford 
2455229fe47cSadam radford /* Plasma 1.11 FW backward compatibility structures */
2456229fe47cSadam radford #define IOV_111_OFFSET 0x7CE
2457229fe47cSadam radford #define MAX_VIRTUAL_FUNCTIONS 8
24584cbfea88SAdam Radford #define MR_LD_ACCESS_HIDDEN 15
2459229fe47cSadam radford 
2460229fe47cSadam radford struct IOV_111 {
2461229fe47cSadam radford 	u8 maxVFsSupported;
2462229fe47cSadam radford 	u8 numVFsEnabled;
2463229fe47cSadam radford 	u8 requestorId;
2464229fe47cSadam radford 	u8 reserved[5];
2465229fe47cSadam radford };
2466229fe47cSadam radford 
2467229fe47cSadam radford struct MR_LD_VF_MAP_111 {
2468229fe47cSadam radford 	u8 targetId;
2469229fe47cSadam radford 	u8 reserved[3];
2470229fe47cSadam radford 	u8 policy[MAX_VIRTUAL_FUNCTIONS];
2471229fe47cSadam radford };
2472229fe47cSadam radford 
2473229fe47cSadam radford struct MR_LD_VF_AFFILIATION_111 {
2474229fe47cSadam radford 	u8 vdCount;
2475229fe47cSadam radford 	u8 vfCount;
2476229fe47cSadam radford 	u8 thisVf;
2477229fe47cSadam radford 	u8 reserved[5];
2478229fe47cSadam radford 	struct MR_LD_VF_MAP_111 map[MAX_LOGICAL_DRIVES];
2479229fe47cSadam radford };
2480229fe47cSadam radford 
2481229fe47cSadam radford struct MR_CTRL_HB_HOST_MEM {
2482229fe47cSadam radford 	struct {
2483229fe47cSadam radford 		u32 fwCounter;	/* Firmware heart beat counter */
2484229fe47cSadam radford 		struct {
2485229fe47cSadam radford 			u32 debugmode:1; /* 1=Firmware is in debug mode.
2486229fe47cSadam radford 					    Heart beat will not be updated. */
2487229fe47cSadam radford 			u32 reserved:31;
2488229fe47cSadam radford 		} debug;
2489229fe47cSadam radford 		u32 reserved_fw[6];
2490229fe47cSadam radford 		u32 driverCounter; /* Driver heart beat counter.  0x20 */
2491229fe47cSadam radford 		u32 reserved_driver[7];
2492229fe47cSadam radford 	} HB;
2493229fe47cSadam radford 	u8 pad[0x400-0x40];
2494229fe47cSadam radford };
249539a98554Sbo yang 
249639a98554Sbo yang enum {
249739a98554Sbo yang 	MEGASAS_HBA_OPERATIONAL			= 0,
249839a98554Sbo yang 	MEGASAS_ADPRESET_SM_INFAULT		= 1,
249939a98554Sbo yang 	MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS	= 2,
250039a98554Sbo yang 	MEGASAS_ADPRESET_SM_OPERATIONAL		= 3,
250139a98554Sbo yang 	MEGASAS_HW_CRITICAL_ERROR		= 4,
2502229fe47cSadam radford 	MEGASAS_ADPRESET_SM_POLLING		= 5,
250339a98554Sbo yang 	MEGASAS_ADPRESET_INPROG_SIGN		= 0xDEADDEAD,
2504c4a3e0a5SBagalkote, Sreenivas };
2505c4a3e0a5SBagalkote, Sreenivas 
25060c79e681SYang, Bo struct megasas_instance_template {
25070c79e681SYang, Bo 	void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
25080c79e681SYang, Bo 		u32, struct megasas_register_set __iomem *);
25090c79e681SYang, Bo 
2510d46a3ad6SSumit.Saxena@lsi.com 	void (*enable_intr)(struct megasas_instance *);
2511d46a3ad6SSumit.Saxena@lsi.com 	void (*disable_intr)(struct megasas_instance *);
25120c79e681SYang, Bo 
2513de516379SShivasharan S 	int (*clear_intr)(struct megasas_instance *);
25140c79e681SYang, Bo 
2515de516379SShivasharan S 	u32 (*read_fw_status_reg)(struct megasas_instance *);
251639a98554Sbo yang 	int (*adp_reset)(struct megasas_instance *, \
251739a98554Sbo yang 		struct megasas_register_set __iomem *);
251839a98554Sbo yang 	int (*check_reset)(struct megasas_instance *, \
251939a98554Sbo yang 		struct megasas_register_set __iomem *);
2520cd50ba8eSadam radford 	irqreturn_t (*service_isr)(int irq, void *devp);
2521cd50ba8eSadam radford 	void (*tasklet)(unsigned long);
2522cd50ba8eSadam radford 	u32 (*init_adapter)(struct megasas_instance *);
2523cd50ba8eSadam radford 	u32 (*build_and_issue_cmd) (struct megasas_instance *,
2524cd50ba8eSadam radford 				    struct scsi_cmnd *);
2525f4fc2093SShivasharan S 	void (*issue_dcmd)(struct megasas_instance *instance,
2526cd50ba8eSadam radford 			    struct megasas_cmd *cmd);
25270c79e681SYang, Bo };
25280c79e681SYang, Bo 
25293cabd162SShivasharan S #define MEGASAS_IS_LOGICAL(sdev)					\
25303cabd162SShivasharan S 	((sdev->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
2531c4a3e0a5SBagalkote, Sreenivas 
25324a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_DEV_INDEX(scp)						\
25334a5c814dSSumit.Saxena@avagotech.com 	(((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) +	\
25344a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
25354a5c814dSSumit.Saxena@avagotech.com 
25364a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_PD_INDEX(scp)						\
25374a5c814dSSumit.Saxena@avagotech.com 	((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +		\
25384a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
2539c4a3e0a5SBagalkote, Sreenivas 
2540c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd {
2541c4a3e0a5SBagalkote, Sreenivas 
2542c4a3e0a5SBagalkote, Sreenivas 	union megasas_frame *frame;
2543c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t frame_phys_addr;
2544c4a3e0a5SBagalkote, Sreenivas 	u8 *sense;
2545c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t sense_phys_addr;
2546c4a3e0a5SBagalkote, Sreenivas 
2547c4a3e0a5SBagalkote, Sreenivas 	u32 index;
2548c4a3e0a5SBagalkote, Sreenivas 	u8 sync_cmd;
25492be2a988SSumit.Saxena@avagotech.com 	u8 cmd_status_drv;
255039a98554Sbo yang 	u8 abort_aen;
255139a98554Sbo yang 	u8 retry_for_fw_reset;
255239a98554Sbo yang 
2553c4a3e0a5SBagalkote, Sreenivas 
2554c4a3e0a5SBagalkote, Sreenivas 	struct list_head list;
2555c4a3e0a5SBagalkote, Sreenivas 	struct scsi_cmnd *scmd;
25564026e9aaSSumit.Saxena@avagotech.com 	u8 flags;
255790dc9d98SSumit.Saxena@avagotech.com 
2558c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance;
25599c915a8cSadam radford 	union {
25609c915a8cSadam radford 		struct {
25619c915a8cSadam radford 			u16 smid;
25629c915a8cSadam radford 			u16 resvd;
25639c915a8cSadam radford 		} context;
2564c4a3e0a5SBagalkote, Sreenivas 		u32 frame_count;
2565c4a3e0a5SBagalkote, Sreenivas 	};
25669c915a8cSadam radford };
2567c4a3e0a5SBagalkote, Sreenivas 
2568c4a3e0a5SBagalkote, Sreenivas #define MAX_MGMT_ADAPTERS		1024
2569c4a3e0a5SBagalkote, Sreenivas #define MAX_IOCTL_SGE			16
2570c4a3e0a5SBagalkote, Sreenivas 
2571c4a3e0a5SBagalkote, Sreenivas struct megasas_iocpacket {
2572c4a3e0a5SBagalkote, Sreenivas 
2573c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2574c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2575c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2576c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2577c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2578c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2579c4a3e0a5SBagalkote, Sreenivas 	union {
2580c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2581c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2582c4a3e0a5SBagalkote, Sreenivas 	} frame;
2583c4a3e0a5SBagalkote, Sreenivas 
2584c4a3e0a5SBagalkote, Sreenivas 	struct iovec sgl[MAX_IOCTL_SGE];
2585c4a3e0a5SBagalkote, Sreenivas 
2586c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2587c4a3e0a5SBagalkote, Sreenivas 
2588c4a3e0a5SBagalkote, Sreenivas struct megasas_aen {
2589c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2590c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2591c4a3e0a5SBagalkote, Sreenivas 	u32 seq_num;
2592c4a3e0a5SBagalkote, Sreenivas 	u32 class_locale_word;
2593c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2594c4a3e0a5SBagalkote, Sreenivas 
2595c4a3e0a5SBagalkote, Sreenivas #ifdef CONFIG_COMPAT
2596c4a3e0a5SBagalkote, Sreenivas struct compat_megasas_iocpacket {
2597c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2598c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2599c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2600c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2601c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2602c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2603c4a3e0a5SBagalkote, Sreenivas 	union {
2604c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2605c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2606c4a3e0a5SBagalkote, Sreenivas 	} frame;
2607c4a3e0a5SBagalkote, Sreenivas 	struct compat_iovec sgl[MAX_IOCTL_SGE];
2608c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2609c4a3e0a5SBagalkote, Sreenivas 
26100e98936cSSumant Patro #define MEGASAS_IOC_FIRMWARE32	_IOWR('M', 1, struct compat_megasas_iocpacket)
2611c4a3e0a5SBagalkote, Sreenivas #endif
2612c4a3e0a5SBagalkote, Sreenivas 
2613cb59aa6aSSumant Patro #define MEGASAS_IOC_FIRMWARE	_IOWR('M', 1, struct megasas_iocpacket)
2614c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOC_GET_AEN	_IOW('M', 3, struct megasas_aen)
2615c4a3e0a5SBagalkote, Sreenivas 
2616c4a3e0a5SBagalkote, Sreenivas struct megasas_mgmt_info {
2617c4a3e0a5SBagalkote, Sreenivas 
2618c4a3e0a5SBagalkote, Sreenivas 	u16 count;
2619c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
2620c4a3e0a5SBagalkote, Sreenivas 	int max_index;
2621c4a3e0a5SBagalkote, Sreenivas };
2622c4a3e0a5SBagalkote, Sreenivas 
26236d40afbcSSumit Saxena enum MEGASAS_OCR_CAUSE {
26246d40afbcSSumit Saxena 	FW_FAULT_OCR			= 0,
26256d40afbcSSumit Saxena 	SCSIIO_TIMEOUT_OCR		= 1,
26266d40afbcSSumit Saxena 	MFI_IO_TIMEOUT_OCR		= 2,
26276d40afbcSSumit Saxena };
26286d40afbcSSumit Saxena 
26296d40afbcSSumit Saxena enum DCMD_RETURN_STATUS {
26306d40afbcSSumit Saxena 	DCMD_SUCCESS		= 0,
26316d40afbcSSumit Saxena 	DCMD_TIMEOUT		= 1,
26326d40afbcSSumit Saxena 	DCMD_FAILED		= 2,
26336d40afbcSSumit Saxena 	DCMD_NOT_FIRED		= 3,
26346d40afbcSSumit Saxena };
26356d40afbcSSumit Saxena 
263621c9e160Sadam radford u8
263721c9e160Sadam radford MR_BuildRaidContext(struct megasas_instance *instance,
263821c9e160Sadam radford 		    struct IO_REQUEST_INFO *io_info,
263921c9e160Sadam radford 		    struct RAID_CONTEXT *pRAID_Context,
264051087a86SSumit.Saxena@avagotech.com 		    struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN);
2641d2d0358bSShivasharan S u16 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
264251087a86SSumit.Saxena@avagotech.com struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
264351087a86SSumit.Saxena@avagotech.com u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
264451087a86SSumit.Saxena@avagotech.com u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
26459ab9ed38SChristoph Hellwig __le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
264651087a86SSumit.Saxena@avagotech.com u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
264721c9e160Sadam radford 
26489ab9ed38SChristoph Hellwig __le16 get_updated_dev_handle(struct megasas_instance *instance,
264933203bc4SShivasharan S 			      struct LD_LOAD_BALANCE_INFO *lbInfo,
265033203bc4SShivasharan S 			      struct IO_REQUEST_INFO *in_info,
265133203bc4SShivasharan S 			      struct MR_DRV_RAID_MAP_ALL *drv_map);
265251087a86SSumit.Saxena@avagotech.com void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
265351087a86SSumit.Saxena@avagotech.com 	struct LD_LOAD_BALANCE_INFO *lbInfo);
2654d009b576SSumit.Saxena@avagotech.com int megasas_get_ctrl_info(struct megasas_instance *instance);
26553761cb4cSsumit.saxena@avagotech.com /* PD sequence */
26563761cb4cSsumit.saxena@avagotech.com int
26573761cb4cSsumit.saxena@avagotech.com megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
2658e9495e2dSShivasharan S void megasas_set_dynamic_target_properties(struct scsi_device *sdev,
2659e9495e2dSShivasharan S 					   bool is_target_prop);
2660e9495e2dSShivasharan S int megasas_get_target_prop(struct megasas_instance *instance,
2661e9495e2dSShivasharan S 			    struct scsi_device *sdev);
2662f0c21df6SShivasharan S void megasas_get_snapdump_properties(struct megasas_instance *instance);
2663e9495e2dSShivasharan S 
2664fc62b3fcSSumit.Saxena@avagotech.com int megasas_set_crash_dump_params(struct megasas_instance *instance,
2665fc62b3fcSSumit.Saxena@avagotech.com 	u8 crash_buf_state);
2666fc62b3fcSSumit.Saxena@avagotech.com void megasas_free_host_crash_buffer(struct megasas_instance *instance);
266751087a86SSumit.Saxena@avagotech.com 
266890dc9d98SSumit.Saxena@avagotech.com void megasas_return_cmd_fusion(struct megasas_instance *instance,
266990dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd_fusion *cmd);
267090dc9d98SSumit.Saxena@avagotech.com int megasas_issue_blocked_cmd(struct megasas_instance *instance,
267190dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd, int timeout);
267290dc9d98SSumit.Saxena@avagotech.com void __megasas_return_cmd(struct megasas_instance *instance,
267390dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd);
267490dc9d98SSumit.Saxena@avagotech.com 
267590dc9d98SSumit.Saxena@avagotech.com void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
267690dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
26777497cde8SSumit.Saxena@avagotech.com int megasas_cmd_type(struct scsi_cmnd *cmd);
26783761cb4cSsumit.saxena@avagotech.com void megasas_setup_jbod_map(struct megasas_instance *instance);
267990dc9d98SSumit.Saxena@avagotech.com 
268018365b13SSumit Saxena void megasas_update_sdev_properties(struct scsi_device *sdev);
268118365b13SSumit Saxena int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
268218365b13SSumit Saxena int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
268318365b13SSumit Saxena int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
268433203bc4SShivasharan S u32 mega_mod64(u64 dividend, u32 divisor);
26855fc499b6SShivasharan S int megasas_alloc_fusion_context(struct megasas_instance *instance);
26865fc499b6SShivasharan S void megasas_free_fusion_context(struct megasas_instance *instance);
26873f6194afSShivasharan S int megasas_fusion_start_watchdog(struct megasas_instance *instance);
26883f6194afSShivasharan S void megasas_fusion_stop_watchdog(struct megasas_instance *instance);
26893f6194afSShivasharan S 
2690107a60ddSShivasharan S void megasas_set_dma_settings(struct megasas_instance *instance,
2691107a60ddSShivasharan S 			      struct megasas_dcmd_frame *dcmd,
2692107a60ddSShivasharan S 			      dma_addr_t dma_addr, u32 dma_len);
269378409d4bSShivasharan S int megasas_adp_reset_wait_for_ready(struct megasas_instance *instance,
269478409d4bSShivasharan S 				     bool do_adp_reset,
269578409d4bSShivasharan S 				     int ocr_context);
269662a04f81SShivasharan S int megasas_irqpoll(struct irq_poll *irqpoll, int budget);
269796c9603cSShivasharan S void megasas_dump_fusion_io(struct scsi_cmnd *scmd);
2698c4a3e0a5SBagalkote, Sreenivas #endif				/*LSI_MEGARAID_SAS_H */
2699