1c4a3e0a5SBagalkote, Sreenivas /*
2c4a3e0a5SBagalkote, Sreenivas  *  Linux MegaRAID driver for SAS based RAID controllers
3c4a3e0a5SBagalkote, Sreenivas  *
4e399065bSSumit.Saxena@avagotech.com  *  Copyright (c) 2003-2013  LSI Corporation
5e399065bSSumit.Saxena@avagotech.com  *  Copyright (c) 2013-2014  Avago Technologies
6c4a3e0a5SBagalkote, Sreenivas  *
7c4a3e0a5SBagalkote, Sreenivas  *  This program is free software; you can redistribute it and/or
8c4a3e0a5SBagalkote, Sreenivas  *  modify it under the terms of the GNU General Public License
93f1530c1Sadam radford  *  as published by the Free Software Foundation; either version 2
103f1530c1Sadam radford  *  of the License, or (at your option) any later version.
113f1530c1Sadam radford  *
123f1530c1Sadam radford  *  This program is distributed in the hope that it will be useful,
133f1530c1Sadam radford  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
143f1530c1Sadam radford  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
153f1530c1Sadam radford  *  GNU General Public License for more details.
163f1530c1Sadam radford  *
173f1530c1Sadam radford  *  You should have received a copy of the GNU General Public License
18e399065bSSumit.Saxena@avagotech.com  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19c4a3e0a5SBagalkote, Sreenivas  *
20c4a3e0a5SBagalkote, Sreenivas  *  FILE: megaraid_sas.h
213f1530c1Sadam radford  *
22e399065bSSumit.Saxena@avagotech.com  *  Authors: Avago Technologies
23e399065bSSumit.Saxena@avagotech.com  *           Kashyap Desai <kashyap.desai@avagotech.com>
24e399065bSSumit.Saxena@avagotech.com  *           Sumit Saxena <sumit.saxena@avagotech.com>
253f1530c1Sadam radford  *
26e399065bSSumit.Saxena@avagotech.com  *  Send feedback to: megaraidlinux.pdl@avagotech.com
273f1530c1Sadam radford  *
28e399065bSSumit.Saxena@avagotech.com  *  Mail to: Avago Technologies, 350 West Trimble Road, Building 90,
29e399065bSSumit.Saxena@avagotech.com  *  San Jose, California 95131
30c4a3e0a5SBagalkote, Sreenivas  */
31c4a3e0a5SBagalkote, Sreenivas 
32c4a3e0a5SBagalkote, Sreenivas #ifndef LSI_MEGARAID_SAS_H
33c4a3e0a5SBagalkote, Sreenivas #define LSI_MEGARAID_SAS_H
34c4a3e0a5SBagalkote, Sreenivas 
35a69b74d3SRandy Dunlap /*
36c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS Driver meta data
37c4a3e0a5SBagalkote, Sreenivas  */
3867c5490aSShivasharan S #define MEGASAS_VERSION				"07.705.02.00-rc1"
3967c5490aSShivasharan S #define MEGASAS_RELDATE				"April 4, 2018"
400e98936cSSumant Patro 
410e98936cSSumant Patro /*
420e98936cSSumant Patro  * Device IDs
430e98936cSSumant Patro  */
440e98936cSSumant Patro #define	PCI_DEVICE_ID_LSI_SAS1078R		0x0060
45af7a5647Sbo yang #define	PCI_DEVICE_ID_LSI_SAS1078DE		0x007C
460e98936cSSumant Patro #define	PCI_DEVICE_ID_LSI_VERDE_ZCR		0x0413
476610a6b3SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS1078GEN2		0x0078
486610a6b3SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0079GEN2		0x0079
4987911122SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0073SKINNY		0x0073
5087911122SYang, Bo #define	PCI_DEVICE_ID_LSI_SAS0071SKINNY		0x0071
519c915a8cSadam radford #define	PCI_DEVICE_ID_LSI_FUSION		0x005b
52229fe47cSadam radford #define PCI_DEVICE_ID_LSI_PLASMA		0x002f
5336807e67Sadam radford #define PCI_DEVICE_ID_LSI_INVADER		0x005d
5421d3c710SSumit.Saxena@lsi.com #define PCI_DEVICE_ID_LSI_FURY			0x005f
5590c204bcSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_INTRUDER		0x00ce
5690c204bcSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_INTRUDER_24		0x00cf
577364d34bSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_CUTLASS_52		0x0052
587364d34bSsumit.saxena@avagotech.com #define PCI_DEVICE_ID_LSI_CUTLASS_53		0x0053
5945f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_VENTURA		    0x0014
60754f1baeSShivasharan S #define PCI_DEVICE_ID_LSI_CRUSADER		    0x0015
6145f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_HARPOON		    0x0016
6245f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_TOMCAT		    0x0017
6345f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_VENTURA_4PORT		0x001B
6445f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_CRUSADER_4PORT	0x001C
650e98936cSSumant Patro 
66c4a3e0a5SBagalkote, Sreenivas /*
6739b72c3cSSumit.Saxena@lsi.com  * Intel HBA SSDIDs
6839b72c3cSSumit.Saxena@lsi.com  */
6939b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_SSDID		0x9360
7039b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_SSDID		0x9362
7139b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_SSDID		0x9380
7239b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_SSDID		0x9381
7339b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_SSDID		0x9341
7439b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_SSDID		0x9343
757364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_SSDID		0x352B
7639b72c3cSSumit.Saxena@lsi.com 
7739b72c3cSSumit.Saxena@lsi.com /*
7890c204bcSsumit.saxena@avagotech.com  * Intruder HBA SSDIDs
7990c204bcSsumit.saxena@avagotech.com  */
8090c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID1		0x9371
8190c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID2		0x9390
8290c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID3		0x9370
8390c204bcSsumit.saxena@avagotech.com 
8490c204bcSsumit.saxena@avagotech.com /*
8539b72c3cSSumit.Saxena@lsi.com  * Intel HBA branding
8639b72c3cSSumit.Saxena@lsi.com  */
8739b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_BRANDING	\
8839b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC080"
8939b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_BRANDING	\
9039b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC040"
9139b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_BRANDING	\
9239b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3SC008"
9339b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_BRANDING	\
9439b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3MC044"
9539b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_BRANDING	\
9639b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC080"
9739b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_BRANDING	\
9839b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC040"
997364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_BRANDING	\
1007364d34bSsumit.saxena@avagotech.com 	"Intel(R) Integrated RAID Module RMS3BC160"
10139b72c3cSSumit.Saxena@lsi.com 
10239b72c3cSSumit.Saxena@lsi.com /*
103c4a3e0a5SBagalkote, Sreenivas  * =====================================
104c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS MFI firmware definitions
105c4a3e0a5SBagalkote, Sreenivas  * =====================================
106c4a3e0a5SBagalkote, Sreenivas  */
107c4a3e0a5SBagalkote, Sreenivas 
108c4a3e0a5SBagalkote, Sreenivas /*
109c4a3e0a5SBagalkote, Sreenivas  * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for
110c4a3e0a5SBagalkote, Sreenivas  * protocol between the software and firmware. Commands are issued using
111c4a3e0a5SBagalkote, Sreenivas  * "message frames"
112c4a3e0a5SBagalkote, Sreenivas  */
113c4a3e0a5SBagalkote, Sreenivas 
114a69b74d3SRandy Dunlap /*
115c4a3e0a5SBagalkote, Sreenivas  * FW posts its state in upper 4 bits of outbound_msg_0 register
116c4a3e0a5SBagalkote, Sreenivas  */
117c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_MASK				0xF0000000
118c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_UNDEFINED			0x00000000
119c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_BB_INIT			0x10000000
120c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT			0x40000000
121c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_WAIT_HANDSHAKE		0x60000000
122c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT_2			0x70000000
123c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_DEVICE_SCAN			0x80000000
124e3bbff9fSSumant Patro #define MFI_STATE_BOOT_MESSAGE_PENDING		0x90000000
125c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FLUSH_CACHE			0xA0000000
126c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_READY				0xB0000000
127c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_OPERATIONAL			0xC0000000
128c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FAULT				0xF0000000
129fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_FORCE_OCR			0x00000080
130fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_DMADONE			0x00000008
131fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_CRASH_DUMP_DONE		0x00000004
13239a98554Sbo yang #define MFI_RESET_REQUIRED			0x00000001
1337e70e733Sadam radford #define MFI_RESET_ADAPTER			0x00000002
134c4a3e0a5SBagalkote, Sreenivas #define MEGAMFI_FRAME_SIZE			64
135c4a3e0a5SBagalkote, Sreenivas 
136a69b74d3SRandy Dunlap /*
137c4a3e0a5SBagalkote, Sreenivas  * During FW init, clear pending cmds & reset state using inbound_msg_0
138c4a3e0a5SBagalkote, Sreenivas  *
139c4a3e0a5SBagalkote, Sreenivas  * ABORT	: Abort all pending cmds
140c4a3e0a5SBagalkote, Sreenivas  * READY	: Move from OPERATIONAL to READY state; discard queue info
141c4a3e0a5SBagalkote, Sreenivas  * MFIMODE	: Discard (possible) low MFA posted in 64-bit mode (??)
142c4a3e0a5SBagalkote, Sreenivas  * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
143e3bbff9fSSumant Patro  * HOTPLUG	: Resume from Hotplug
144e3bbff9fSSumant Patro  * MFI_STOP_ADP	: Send signal to FW to stop processing
145c4a3e0a5SBagalkote, Sreenivas  */
14639a98554Sbo yang #define WRITE_SEQUENCE_OFFSET		(0x0000000FC) /* I20 */
14739a98554Sbo yang #define HOST_DIAGNOSTIC_OFFSET		(0x000000F8)  /* I20 */
14839a98554Sbo yang #define DIAG_WRITE_ENABLE			(0x00000080)
14939a98554Sbo yang #define DIAG_RESET_ADAPTER			(0x00000004)
15039a98554Sbo yang 
15139a98554Sbo yang #define MFI_ADP_RESET				0x00000040
152e3bbff9fSSumant Patro #define MFI_INIT_ABORT				0x00000001
153c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_READY				0x00000002
154c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_MFIMODE			0x00000004
155c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_CLEAR_HANDSHAKE		0x00000008
156e3bbff9fSSumant Patro #define MFI_INIT_HOTPLUG			0x00000010
157e3bbff9fSSumant Patro #define MFI_STOP_ADP				0x00000020
158e3bbff9fSSumant Patro #define MFI_RESET_FLAGS				MFI_INIT_READY| \
159e3bbff9fSSumant Patro 						MFI_INIT_MFIMODE| \
160e3bbff9fSSumant Patro 						MFI_INIT_ABORT
161179ac142SSumit Saxena #define MPI2_IOCINIT_MSGFLAG_RDPQ_ARRAY_MODE    (0x01)
162c4a3e0a5SBagalkote, Sreenivas 
163a69b74d3SRandy Dunlap /*
164c4a3e0a5SBagalkote, Sreenivas  * MFI frame flags
165c4a3e0a5SBagalkote, Sreenivas  */
166c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_POST_IN_REPLY_QUEUE		0x0000
167c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE	0x0001
168c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL32				0x0000
169c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL64				0x0002
170c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE32			0x0000
171c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE64			0x0004
172c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_NONE			0x0000
173c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_WRITE			0x0008
174c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_READ			0x0010
175c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_BOTH			0x0018
176f4c9a131SYang, Bo #define MFI_FRAME_IEEE                          0x0020
177c4a3e0a5SBagalkote, Sreenivas 
1784026e9aaSSumit.Saxena@avagotech.com /* Driver internal */
1794026e9aaSSumit.Saxena@avagotech.com #define DRV_DCMD_POLLED_MODE		0x1
1806d40afbcSSumit Saxena #define DRV_DCMD_SKIP_REFIRE		0x2
1814026e9aaSSumit.Saxena@avagotech.com 
182a69b74d3SRandy Dunlap /*
183c4a3e0a5SBagalkote, Sreenivas  * Definition for cmd_status
184c4a3e0a5SBagalkote, Sreenivas  */
185c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_STATUS_POLL_MODE		0xFF
186c4a3e0a5SBagalkote, Sreenivas 
187a69b74d3SRandy Dunlap /*
188c4a3e0a5SBagalkote, Sreenivas  * MFI command opcodes
189c4a3e0a5SBagalkote, Sreenivas  */
19082add4e1SShivasharan S enum MFI_CMD_OP {
19182add4e1SShivasharan S 	MFI_CMD_INIT		= 0x0,
19282add4e1SShivasharan S 	MFI_CMD_LD_READ		= 0x1,
19382add4e1SShivasharan S 	MFI_CMD_LD_WRITE	= 0x2,
19482add4e1SShivasharan S 	MFI_CMD_LD_SCSI_IO	= 0x3,
19582add4e1SShivasharan S 	MFI_CMD_PD_SCSI_IO	= 0x4,
19682add4e1SShivasharan S 	MFI_CMD_DCMD		= 0x5,
19782add4e1SShivasharan S 	MFI_CMD_ABORT		= 0x6,
19882add4e1SShivasharan S 	MFI_CMD_SMP		= 0x7,
19982add4e1SShivasharan S 	MFI_CMD_STP		= 0x8,
200f870bcbeSShivasharan S 	MFI_CMD_NVME		= 0x9,
20182add4e1SShivasharan S 	MFI_CMD_OP_COUNT,
20282add4e1SShivasharan S 	MFI_CMD_INVALID		= 0xff
20382add4e1SShivasharan S };
204c4a3e0a5SBagalkote, Sreenivas 
205c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_GET_INFO			0x01010000
206bdc6fb8dSYang, Bo #define MR_DCMD_LD_GET_LIST			0x03010000
20721c9e160Sadam radford #define MR_DCMD_LD_LIST_QUERY			0x03010100
208c4a3e0a5SBagalkote, Sreenivas 
209c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_CACHE_FLUSH		0x01101000
210c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_CTRL_CACHE			0x01
211c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_DISK_CACHE			0x02
212c4a3e0a5SBagalkote, Sreenivas 
213c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_SHUTDOWN			0x01050000
21431ea7088Sbo yang #define MR_DCMD_HIBERNATE_SHUTDOWN		0x01060000
215c4a3e0a5SBagalkote, Sreenivas #define MR_ENABLE_DRIVE_SPINDOWN		0x01
216c4a3e0a5SBagalkote, Sreenivas 
217c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET_INFO		0x01040100
218c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET			0x01040300
219c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_WAIT			0x01040500
220c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_LD_GET_PROPERTIES		0x03030000
221c4a3e0a5SBagalkote, Sreenivas 
222c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER				0x08000000
223c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_ALL		0x08010100
224c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_LD		0x08010200
22581e403ceSYang, Bo #define MR_DCMD_PD_LIST_QUERY                   0x02010100
226c4a3e0a5SBagalkote, Sreenivas 
227fc62b3fcSSumit.Saxena@avagotech.com #define MR_DCMD_CTRL_SET_CRASH_DUMP_PARAMS	0x01190100
228fc62b3fcSSumit.Saxena@avagotech.com #define MR_DRIVER_SET_APP_CRASHDUMP_MODE	(0xF0010000 | 0x0600)
2292216c305SSumit Saxena #define MR_DCMD_PD_GET_INFO			0x02020000
230fc62b3fcSSumit.Saxena@avagotech.com 
231a69b74d3SRandy Dunlap /*
232bc93d425SSumit.Saxena@lsi.com  * Global functions
233bc93d425SSumit.Saxena@lsi.com  */
2345f19f7c8SShivasharan S extern u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id);
235bc93d425SSumit.Saxena@lsi.com 
236bc93d425SSumit.Saxena@lsi.com 
237bc93d425SSumit.Saxena@lsi.com /*
238c4a3e0a5SBagalkote, Sreenivas  * MFI command completion codes
239c4a3e0a5SBagalkote, Sreenivas  */
240c4a3e0a5SBagalkote, Sreenivas enum MFI_STAT {
241c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_OK = 0x00,
242c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_CMD = 0x01,
243c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_DCMD = 0x02,
244c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_PARAMETER = 0x03,
245c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
246c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
247c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
248c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_IN_USE = 0x07,
249c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_NOT_INITIALIZED = 0x08,
250c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
251c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
252c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
253c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
254c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
255c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
256c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_BUSY = 0x0f,
257c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ERROR = 0x10,
258c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_BAD = 0x11,
259c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
260c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_OPEN = 0x13,
261c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_STARTED = 0x14,
262c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLUSH_FAILED = 0x15,
263c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
264c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
265c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
266c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
267c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
268c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
269c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
270c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
271c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
272c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
273c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
274c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MFC_HW_ERROR = 0x21,
275c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NO_HW_PRESENT = 0x22,
276c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_FOUND = 0x23,
277c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_IN_ENCL = 0x24,
278c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
279c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_TYPE_WRONG = 0x26,
280c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PR_DISABLED = 0x27,
281c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ROW_INDEX_INVALID = 0x28,
282c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
283c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
284c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
285c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
286c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
287c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_IO_FAILED = 0x2e,
288c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
289c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SHUTDOWN_FAILED = 0x30,
290c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_TIME_NOT_SET = 0x31,
291c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_WRONG_STATE = 0x32,
292c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_OFFLINE = 0x33,
293c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
294c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
295c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
296c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
297c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
29836807e67Sadam radford 	MFI_STAT_CONFIG_SEQ_MISMATCH = 0x67,
299c4a3e0a5SBagalkote, Sreenivas 
300c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_STATUS = 0xFF
301c4a3e0a5SBagalkote, Sreenivas };
302c4a3e0a5SBagalkote, Sreenivas 
303714f5177Ssumit.saxena@avagotech.com enum mfi_evt_class {
304714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEBUG =		-2,
305714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_PROGRESS =	-1,
306714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_INFO =		0,
307714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_WARNING =		1,
308714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_CRITICAL =	2,
309714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_FATAL =		3,
310714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEAD =		4
311714f5177Ssumit.saxena@avagotech.com };
312714f5177Ssumit.saxena@avagotech.com 
313c4a3e0a5SBagalkote, Sreenivas /*
314fc62b3fcSSumit.Saxena@avagotech.com  * Crash dump related defines
315fc62b3fcSSumit.Saxena@avagotech.com  */
316fc62b3fcSSumit.Saxena@avagotech.com #define MAX_CRASH_DUMP_SIZE 512
317fc62b3fcSSumit.Saxena@avagotech.com #define CRASH_DMA_BUF_SIZE  (1024 * 1024)
318fc62b3fcSSumit.Saxena@avagotech.com 
319fc62b3fcSSumit.Saxena@avagotech.com enum MR_FW_CRASH_DUMP_STATE {
320fc62b3fcSSumit.Saxena@avagotech.com 	UNAVAILABLE = 0,
321fc62b3fcSSumit.Saxena@avagotech.com 	AVAILABLE = 1,
322fc62b3fcSSumit.Saxena@avagotech.com 	COPYING = 2,
323fc62b3fcSSumit.Saxena@avagotech.com 	COPIED = 3,
324fc62b3fcSSumit.Saxena@avagotech.com 	COPY_ERROR = 4,
325fc62b3fcSSumit.Saxena@avagotech.com };
326fc62b3fcSSumit.Saxena@avagotech.com 
327fc62b3fcSSumit.Saxena@avagotech.com enum _MR_CRASH_BUF_STATUS {
328fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_OFF = 0,
329fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_ON = 1,
330fc62b3fcSSumit.Saxena@avagotech.com };
331fc62b3fcSSumit.Saxena@avagotech.com 
332fc62b3fcSSumit.Saxena@avagotech.com /*
333c4a3e0a5SBagalkote, Sreenivas  * Number of mailbox bytes in DCMD message frame
334c4a3e0a5SBagalkote, Sreenivas  */
335c4a3e0a5SBagalkote, Sreenivas #define MFI_MBOX_SIZE				12
336c4a3e0a5SBagalkote, Sreenivas 
337c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_CLASS {
338c4a3e0a5SBagalkote, Sreenivas 
339c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEBUG = -2,
340c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_PROGRESS = -1,
341c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_INFO = 0,
342c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_WARNING = 1,
343c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_CRITICAL = 2,
344c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_FATAL = 3,
345c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEAD = 4,
346c4a3e0a5SBagalkote, Sreenivas 
347c4a3e0a5SBagalkote, Sreenivas };
348c4a3e0a5SBagalkote, Sreenivas 
349c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_LOCALE {
350c4a3e0a5SBagalkote, Sreenivas 
351c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_LD = 0x0001,
352c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_PD = 0x0002,
353c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ENCL = 0x0004,
354c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_BBU = 0x0008,
355c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_SAS = 0x0010,
356c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CTRL = 0x0020,
357c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CONFIG = 0x0040,
358c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CLUSTER = 0x0080,
359c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ALL = 0xffff,
360c4a3e0a5SBagalkote, Sreenivas 
361c4a3e0a5SBagalkote, Sreenivas };
362c4a3e0a5SBagalkote, Sreenivas 
363c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_ARGS {
364c4a3e0a5SBagalkote, Sreenivas 
365c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_NONE,
366c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_CDB_SENSE,
367c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD,
368c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_COUNT,
369c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA,
370c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_OWNER,
371c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA_PD_LBA,
372c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_PROG,
373c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STATE,
374c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STRIP,
375c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD,
376c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_ERR,
377c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA,
378c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA_LD,
379c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_PROG,
380c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_STATE,
381c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PCI,
382c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_RATE,
383c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_STR,
384c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_TIME,
385c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_ECC,
38681e403ceSYang, Bo 	MR_EVT_ARGS_LD_PROP,
38781e403ceSYang, Bo 	MR_EVT_ARGS_PD_SPARE,
38881e403ceSYang, Bo 	MR_EVT_ARGS_PD_INDEX,
38981e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_PASS,
39081e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_FAIL,
39181e403ceSYang, Bo 	MR_EVT_ARGS_PD_LBA_LBA,
39281e403ceSYang, Bo 	MR_EVT_ARGS_PORT_PHY,
39381e403ceSYang, Bo 	MR_EVT_ARGS_PD_MISSING,
39481e403ceSYang, Bo 	MR_EVT_ARGS_PD_ADDRESS,
39581e403ceSYang, Bo 	MR_EVT_ARGS_BITMAP,
39681e403ceSYang, Bo 	MR_EVT_ARGS_CONNECTOR,
39781e403ceSYang, Bo 	MR_EVT_ARGS_PD_PD,
39881e403ceSYang, Bo 	MR_EVT_ARGS_PD_FRU,
39981e403ceSYang, Bo 	MR_EVT_ARGS_PD_PATHINFO,
40081e403ceSYang, Bo 	MR_EVT_ARGS_PD_POWER_STATE,
40181e403ceSYang, Bo 	MR_EVT_ARGS_GENERIC,
402c4a3e0a5SBagalkote, Sreenivas };
403c4a3e0a5SBagalkote, Sreenivas 
404357ae967Ssumit.saxena@avagotech.com 
405357ae967Ssumit.saxena@avagotech.com #define SGE_BUFFER_SIZE	4096
4068f67c8c5SSumit Saxena #define MEGASAS_CLUSTER_ID_SIZE	16
407c4a3e0a5SBagalkote, Sreenivas /*
40881e403ceSYang, Bo  * define constants for device list query options
40981e403ceSYang, Bo  */
41081e403ceSYang, Bo enum MR_PD_QUERY_TYPE {
41181e403ceSYang, Bo 	MR_PD_QUERY_TYPE_ALL                = 0,
41281e403ceSYang, Bo 	MR_PD_QUERY_TYPE_STATE              = 1,
41381e403ceSYang, Bo 	MR_PD_QUERY_TYPE_POWER_STATE        = 2,
41481e403ceSYang, Bo 	MR_PD_QUERY_TYPE_MEDIA_TYPE         = 3,
41581e403ceSYang, Bo 	MR_PD_QUERY_TYPE_SPEED              = 4,
41681e403ceSYang, Bo 	MR_PD_QUERY_TYPE_EXPOSED_TO_HOST    = 5,
41781e403ceSYang, Bo };
41881e403ceSYang, Bo 
41921c9e160Sadam radford enum MR_LD_QUERY_TYPE {
42021c9e160Sadam radford 	MR_LD_QUERY_TYPE_ALL	         = 0,
42121c9e160Sadam radford 	MR_LD_QUERY_TYPE_EXPOSED_TO_HOST = 1,
42221c9e160Sadam radford 	MR_LD_QUERY_TYPE_USED_TGT_IDS    = 2,
42321c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_ACCESS  = 3,
42421c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_LOCALE  = 4,
42521c9e160Sadam radford };
42621c9e160Sadam radford 
42721c9e160Sadam radford 
4287e8a75f4SYang, Bo #define MR_EVT_CFG_CLEARED                              0x0004
4297e8a75f4SYang, Bo #define MR_EVT_LD_STATE_CHANGE                          0x0051
4307e8a75f4SYang, Bo #define MR_EVT_PD_INSERTED                              0x005b
4317e8a75f4SYang, Bo #define MR_EVT_PD_REMOVED                               0x0070
4327e8a75f4SYang, Bo #define MR_EVT_LD_CREATED                               0x008a
4337e8a75f4SYang, Bo #define MR_EVT_LD_DELETED                               0x008b
4347e8a75f4SYang, Bo #define MR_EVT_FOREIGN_CFG_IMPORTED                     0x00db
4357e8a75f4SYang, Bo #define MR_EVT_LD_OFFLINE                               0x00fc
4367e8a75f4SYang, Bo #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED             0x0152
437c4bd2654Ssumit.saxena@avagotech.com #define MR_EVT_CTRL_PROP_CHANGED			0x012f
4387e8a75f4SYang, Bo 
43981e403ceSYang, Bo enum MR_PD_STATE {
44081e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_GOOD   = 0x00,
44181e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_BAD    = 0x01,
44281e403ceSYang, Bo 	MR_PD_STATE_HOT_SPARE           = 0x02,
44381e403ceSYang, Bo 	MR_PD_STATE_OFFLINE             = 0x10,
44481e403ceSYang, Bo 	MR_PD_STATE_FAILED              = 0x11,
44581e403ceSYang, Bo 	MR_PD_STATE_REBUILD             = 0x14,
44681e403ceSYang, Bo 	MR_PD_STATE_ONLINE              = 0x18,
44781e403ceSYang, Bo 	MR_PD_STATE_COPYBACK            = 0x20,
44881e403ceSYang, Bo 	MR_PD_STATE_SYSTEM              = 0x40,
44981e403ceSYang, Bo  };
45081e403ceSYang, Bo 
4512216c305SSumit Saxena union MR_PD_REF {
4522216c305SSumit Saxena 	struct {
4532216c305SSumit Saxena 		u16	 deviceId;
4542216c305SSumit Saxena 		u16	 seqNum;
4552216c305SSumit Saxena 	} mrPdRef;
4562216c305SSumit Saxena 	u32	 ref;
4572216c305SSumit Saxena };
4582216c305SSumit Saxena 
4592216c305SSumit Saxena /*
4602216c305SSumit Saxena  * define the DDF Type bit structure
4612216c305SSumit Saxena  */
4622216c305SSumit Saxena union MR_PD_DDF_TYPE {
4632216c305SSumit Saxena 	 struct {
4642216c305SSumit Saxena 		union {
4652216c305SSumit Saxena 			struct {
4662216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
4672216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4682216c305SSumit Saxena 				 u16	 inVD:1;
4692216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4702216c305SSumit Saxena 				 u16	 isSpare:1;
4712216c305SSumit Saxena 				 u16	 isForeign:1;
4722216c305SSumit Saxena 				 u16	 reserved:7;
4732216c305SSumit Saxena 				 u16	 intf:4;
4742216c305SSumit Saxena #else
4752216c305SSumit Saxena 				 u16	 intf:4;
4762216c305SSumit Saxena 				 u16	 reserved:7;
4772216c305SSumit Saxena 				 u16	 isForeign:1;
4782216c305SSumit Saxena 				 u16	 isSpare:1;
4792216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4802216c305SSumit Saxena 				 u16	 inVD:1;
4812216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4822216c305SSumit Saxena #endif
4832216c305SSumit Saxena 			 } pdType;
4842216c305SSumit Saxena 			 u16	 type;
4852216c305SSumit Saxena 		 };
4862216c305SSumit Saxena 		 u16	 reserved;
4872216c305SSumit Saxena 	 } ddf;
4882216c305SSumit Saxena 	 struct {
4892216c305SSumit Saxena 		 u32	reserved;
4902216c305SSumit Saxena 	 } nonDisk;
4912216c305SSumit Saxena 	 u32	 type;
4922216c305SSumit Saxena } __packed;
4932216c305SSumit Saxena 
4942216c305SSumit Saxena /*
4952216c305SSumit Saxena  * defines the progress structure
4962216c305SSumit Saxena  */
4972216c305SSumit Saxena union MR_PROGRESS {
4982216c305SSumit Saxena 	struct  {
4992216c305SSumit Saxena 		u16 progress;
5002216c305SSumit Saxena 		union {
5012216c305SSumit Saxena 			u16 elapsedSecs;
5022216c305SSumit Saxena 			u16 elapsedSecsForLastPercent;
5032216c305SSumit Saxena 		};
5042216c305SSumit Saxena 	} mrProgress;
5052216c305SSumit Saxena 	u32 w;
5062216c305SSumit Saxena } __packed;
5072216c305SSumit Saxena 
5082216c305SSumit Saxena /*
5092216c305SSumit Saxena  * defines the physical drive progress structure
5102216c305SSumit Saxena  */
5112216c305SSumit Saxena struct MR_PD_PROGRESS {
5122216c305SSumit Saxena 	struct {
5132216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5142216c305SSumit Saxena 		u32     rbld:1;
5152216c305SSumit Saxena 		u32     patrol:1;
5162216c305SSumit Saxena 		u32     clear:1;
5172216c305SSumit Saxena 		u32     copyBack:1;
5182216c305SSumit Saxena 		u32     erase:1;
5192216c305SSumit Saxena 		u32     locate:1;
5202216c305SSumit Saxena 		u32     reserved:26;
5212216c305SSumit Saxena #else
5222216c305SSumit Saxena 		u32     reserved:26;
5232216c305SSumit Saxena 		u32     locate:1;
5242216c305SSumit Saxena 		u32     erase:1;
5252216c305SSumit Saxena 		u32     copyBack:1;
5262216c305SSumit Saxena 		u32     clear:1;
5272216c305SSumit Saxena 		u32     patrol:1;
5282216c305SSumit Saxena 		u32     rbld:1;
5292216c305SSumit Saxena #endif
5302216c305SSumit Saxena 	} active;
5312216c305SSumit Saxena 	union MR_PROGRESS     rbld;
5322216c305SSumit Saxena 	union MR_PROGRESS     patrol;
5332216c305SSumit Saxena 	union {
5342216c305SSumit Saxena 		union MR_PROGRESS     clear;
5352216c305SSumit Saxena 		union MR_PROGRESS     erase;
5362216c305SSumit Saxena 	};
5372216c305SSumit Saxena 
5382216c305SSumit Saxena 	struct {
5392216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5402216c305SSumit Saxena 		u32     rbld:1;
5412216c305SSumit Saxena 		u32     patrol:1;
5422216c305SSumit Saxena 		u32     clear:1;
5432216c305SSumit Saxena 		u32     copyBack:1;
5442216c305SSumit Saxena 		u32     erase:1;
5452216c305SSumit Saxena 		u32     reserved:27;
5462216c305SSumit Saxena #else
5472216c305SSumit Saxena 		u32     reserved:27;
5482216c305SSumit Saxena 		u32     erase:1;
5492216c305SSumit Saxena 		u32     copyBack:1;
5502216c305SSumit Saxena 		u32     clear:1;
5512216c305SSumit Saxena 		u32     patrol:1;
5522216c305SSumit Saxena 		u32     rbld:1;
5532216c305SSumit Saxena #endif
5542216c305SSumit Saxena 	} pause;
5552216c305SSumit Saxena 
5562216c305SSumit Saxena 	union MR_PROGRESS     reserved[3];
5572216c305SSumit Saxena } __packed;
5582216c305SSumit Saxena 
5592216c305SSumit Saxena struct  MR_PD_INFO {
5602216c305SSumit Saxena 	union MR_PD_REF	ref;
5612216c305SSumit Saxena 	u8 inquiryData[96];
5622216c305SSumit Saxena 	u8 vpdPage83[64];
5632216c305SSumit Saxena 	u8 notSupported;
5642216c305SSumit Saxena 	u8 scsiDevType;
5652216c305SSumit Saxena 
5662216c305SSumit Saxena 	union {
5672216c305SSumit Saxena 		u8 connectedPortBitmap;
5682216c305SSumit Saxena 		u8 connectedPortNumbers;
5692216c305SSumit Saxena 	};
5702216c305SSumit Saxena 
5712216c305SSumit Saxena 	u8 deviceSpeed;
5722216c305SSumit Saxena 	u32 mediaErrCount;
5732216c305SSumit Saxena 	u32 otherErrCount;
5742216c305SSumit Saxena 	u32 predFailCount;
5752216c305SSumit Saxena 	u32 lastPredFailEventSeqNum;
5762216c305SSumit Saxena 
5772216c305SSumit Saxena 	u16 fwState;
5782216c305SSumit Saxena 	u8 disabledForRemoval;
5792216c305SSumit Saxena 	u8 linkSpeed;
5802216c305SSumit Saxena 	union MR_PD_DDF_TYPE state;
5812216c305SSumit Saxena 
5822216c305SSumit Saxena 	struct {
5832216c305SSumit Saxena 		u8 count;
5842216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
5852216c305SSumit Saxena 		u8 isPathBroken:4;
5862216c305SSumit Saxena 		u8 reserved3:3;
5872216c305SSumit Saxena 		u8 widePortCapable:1;
5882216c305SSumit Saxena #else
5892216c305SSumit Saxena 		u8 widePortCapable:1;
5902216c305SSumit Saxena 		u8 reserved3:3;
5912216c305SSumit Saxena 		u8 isPathBroken:4;
5922216c305SSumit Saxena #endif
5932216c305SSumit Saxena 
5942216c305SSumit Saxena 		u8 connectorIndex[2];
5952216c305SSumit Saxena 		u8 reserved[4];
5962216c305SSumit Saxena 		u64 sasAddr[2];
5972216c305SSumit Saxena 		u8 reserved2[16];
5982216c305SSumit Saxena 	} pathInfo;
5992216c305SSumit Saxena 
6002216c305SSumit Saxena 	u64 rawSize;
6012216c305SSumit Saxena 	u64 nonCoercedSize;
6022216c305SSumit Saxena 	u64 coercedSize;
6032216c305SSumit Saxena 	u16 enclDeviceId;
6042216c305SSumit Saxena 	u8 enclIndex;
6052216c305SSumit Saxena 
6062216c305SSumit Saxena 	union {
6072216c305SSumit Saxena 		u8 slotNumber;
6082216c305SSumit Saxena 		u8 enclConnectorIndex;
6092216c305SSumit Saxena 	};
6102216c305SSumit Saxena 
6112216c305SSumit Saxena 	struct MR_PD_PROGRESS progInfo;
6122216c305SSumit Saxena 	u8 badBlockTableFull;
6132216c305SSumit Saxena 	u8 unusableInCurrentConfig;
6142216c305SSumit Saxena 	u8 vpdPage83Ext[64];
6152216c305SSumit Saxena 	u8 powerState;
6162216c305SSumit Saxena 	u8 enclPosition;
6172216c305SSumit Saxena 	u32 allowedOps;
6182216c305SSumit Saxena 	u16 copyBackPartnerId;
6192216c305SSumit Saxena 	u16 enclPartnerDeviceId;
6202216c305SSumit Saxena 	struct {
6212216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6222216c305SSumit Saxena 		u16 fdeCapable:1;
6232216c305SSumit Saxena 		u16 fdeEnabled:1;
6242216c305SSumit Saxena 		u16 secured:1;
6252216c305SSumit Saxena 		u16 locked:1;
6262216c305SSumit Saxena 		u16 foreign:1;
6272216c305SSumit Saxena 		u16 needsEKM:1;
6282216c305SSumit Saxena 		u16 reserved:10;
6292216c305SSumit Saxena #else
6302216c305SSumit Saxena 		u16 reserved:10;
6312216c305SSumit Saxena 		u16 needsEKM:1;
6322216c305SSumit Saxena 		u16 foreign:1;
6332216c305SSumit Saxena 		u16 locked:1;
6342216c305SSumit Saxena 		u16 secured:1;
6352216c305SSumit Saxena 		u16 fdeEnabled:1;
6362216c305SSumit Saxena 		u16 fdeCapable:1;
6372216c305SSumit Saxena #endif
6382216c305SSumit Saxena 	} security;
6392216c305SSumit Saxena 	u8 mediaType;
6402216c305SSumit Saxena 	u8 notCertified;
6412216c305SSumit Saxena 	u8 bridgeVendor[8];
6422216c305SSumit Saxena 	u8 bridgeProductIdentification[16];
6432216c305SSumit Saxena 	u8 bridgeProductRevisionLevel[4];
6442216c305SSumit Saxena 	u8 satBridgeExists;
6452216c305SSumit Saxena 
6462216c305SSumit Saxena 	u8 interfaceType;
6472216c305SSumit Saxena 	u8 temperature;
6482216c305SSumit Saxena 	u8 emulatedBlockSize;
6492216c305SSumit Saxena 	u16 userDataBlockSize;
6502216c305SSumit Saxena 	u16 reserved2;
6512216c305SSumit Saxena 
6522216c305SSumit Saxena 	struct {
6532216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6542216c305SSumit Saxena 		u32 piType:3;
6552216c305SSumit Saxena 		u32 piFormatted:1;
6562216c305SSumit Saxena 		u32 piEligible:1;
6572216c305SSumit Saxena 		u32 NCQ:1;
6582216c305SSumit Saxena 		u32 WCE:1;
6592216c305SSumit Saxena 		u32 commissionedSpare:1;
6602216c305SSumit Saxena 		u32 emergencySpare:1;
6612216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6622216c305SSumit Saxena 		u32 ineligibleForLd:1;
6632216c305SSumit Saxena 		u32 useSSEraseType:1;
6642216c305SSumit Saxena 		u32 wceUnchanged:1;
6652216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6662216c305SSumit Saxena 		u32 reserved:18;
6672216c305SSumit Saxena #else
6682216c305SSumit Saxena 		u32 reserved:18;
6692216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6702216c305SSumit Saxena 		u32 wceUnchanged:1;
6712216c305SSumit Saxena 		u32 useSSEraseType:1;
6722216c305SSumit Saxena 		u32 ineligibleForLd:1;
6732216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6742216c305SSumit Saxena 		u32 emergencySpare:1;
6752216c305SSumit Saxena 		u32 commissionedSpare:1;
6762216c305SSumit Saxena 		u32 WCE:1;
6772216c305SSumit Saxena 		u32 NCQ:1;
6782216c305SSumit Saxena 		u32 piEligible:1;
6792216c305SSumit Saxena 		u32 piFormatted:1;
6802216c305SSumit Saxena 		u32 piType:3;
6812216c305SSumit Saxena #endif
6822216c305SSumit Saxena 	} properties;
6832216c305SSumit Saxena 
6842216c305SSumit Saxena 	u64 shieldDiagCompletionTime;
6852216c305SSumit Saxena 	u8 shieldCounter;
6862216c305SSumit Saxena 
6872216c305SSumit Saxena 	u8 linkSpeedOther;
6882216c305SSumit Saxena 	u8 reserved4[2];
6892216c305SSumit Saxena 
6902216c305SSumit Saxena 	struct {
6912216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6922216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
6932216c305SSumit Saxena 		u32 bbmErrCount:31;
6942216c305SSumit Saxena #else
6952216c305SSumit Saxena 		u32 bbmErrCount:31;
6962216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
6972216c305SSumit Saxena #endif
6982216c305SSumit Saxena 	} bbmErr;
6992216c305SSumit Saxena 
7002216c305SSumit Saxena 	u8 reserved1[512-428];
7012216c305SSumit Saxena } __packed;
70281e403ceSYang, Bo 
70381e403ceSYang, Bo /*
70496188a89SShivasharan S  * Definition of structure used to expose attributes of VD or JBOD
70596188a89SShivasharan S  * (this structure is to be filled by firmware when MR_DCMD_DRV_GET_TARGET_PROP
70696188a89SShivasharan S  * is fired by driver)
70796188a89SShivasharan S  */
70896188a89SShivasharan S struct MR_TARGET_PROPERTIES {
70996188a89SShivasharan S 	u32    max_io_size_kb;
71096188a89SShivasharan S 	u32    device_qdepth;
71196188a89SShivasharan S 	u32    sector_size;
712e9495e2dSShivasharan S 	u8     reset_tmo;
713e9495e2dSShivasharan S 	u8     reserved[499];
71496188a89SShivasharan S } __packed;
71596188a89SShivasharan S 
71696188a89SShivasharan S  /*
71781e403ceSYang, Bo  * defines the physical drive address structure
71881e403ceSYang, Bo  */
71981e403ceSYang, Bo struct MR_PD_ADDRESS {
7209ab9ed38SChristoph Hellwig 	__le16	deviceId;
72181e403ceSYang, Bo 	u16     enclDeviceId;
72281e403ceSYang, Bo 
72381e403ceSYang, Bo 	union {
72481e403ceSYang, Bo 		struct {
72581e403ceSYang, Bo 			u8  enclIndex;
72681e403ceSYang, Bo 			u8  slotNumber;
72781e403ceSYang, Bo 		} mrPdAddress;
72881e403ceSYang, Bo 		struct {
72981e403ceSYang, Bo 			u8  enclPosition;
73081e403ceSYang, Bo 			u8  enclConnectorIndex;
73181e403ceSYang, Bo 		} mrEnclAddress;
73281e403ceSYang, Bo 	};
73381e403ceSYang, Bo 	u8      scsiDevType;
73481e403ceSYang, Bo 	union {
73581e403ceSYang, Bo 		u8      connectedPortBitmap;
73681e403ceSYang, Bo 		u8      connectedPortNumbers;
73781e403ceSYang, Bo 	};
73881e403ceSYang, Bo 	u64     sasAddr[2];
73981e403ceSYang, Bo } __packed;
74081e403ceSYang, Bo 
74181e403ceSYang, Bo /*
74281e403ceSYang, Bo  * defines the physical drive list structure
74381e403ceSYang, Bo  */
74481e403ceSYang, Bo struct MR_PD_LIST {
7459ab9ed38SChristoph Hellwig 	__le32		size;
7469ab9ed38SChristoph Hellwig 	__le32		count;
74781e403ceSYang, Bo 	struct MR_PD_ADDRESS   addr[1];
74881e403ceSYang, Bo } __packed;
74981e403ceSYang, Bo 
75081e403ceSYang, Bo struct megasas_pd_list {
75181e403ceSYang, Bo 	u16             tid;
75281e403ceSYang, Bo 	u8             driveType;
75381e403ceSYang, Bo 	u8             driveState;
75481e403ceSYang, Bo } __packed;
75581e403ceSYang, Bo 
75681e403ceSYang, Bo  /*
757bdc6fb8dSYang, Bo  * defines the logical drive reference structure
758bdc6fb8dSYang, Bo  */
759bdc6fb8dSYang, Bo union  MR_LD_REF {
760bdc6fb8dSYang, Bo 	struct {
761bdc6fb8dSYang, Bo 		u8      targetId;
762bdc6fb8dSYang, Bo 		u8      reserved;
7639ab9ed38SChristoph Hellwig 		__le16     seqNum;
764bdc6fb8dSYang, Bo 	};
7659ab9ed38SChristoph Hellwig 	__le32     ref;
766bdc6fb8dSYang, Bo } __packed;
767bdc6fb8dSYang, Bo 
768bdc6fb8dSYang, Bo /*
769bdc6fb8dSYang, Bo  * defines the logical drive list structure
770bdc6fb8dSYang, Bo  */
771bdc6fb8dSYang, Bo struct MR_LD_LIST {
7729ab9ed38SChristoph Hellwig 	__le32     ldCount;
7739ab9ed38SChristoph Hellwig 	__le32     reserved;
774bdc6fb8dSYang, Bo 	struct {
775bdc6fb8dSYang, Bo 		union MR_LD_REF   ref;
776bdc6fb8dSYang, Bo 		u8          state;
777bdc6fb8dSYang, Bo 		u8          reserved[3];
7789ab9ed38SChristoph Hellwig 		__le64		size;
77951087a86SSumit.Saxena@avagotech.com 	} ldList[MAX_LOGICAL_DRIVES_EXT];
780bdc6fb8dSYang, Bo } __packed;
781bdc6fb8dSYang, Bo 
78221c9e160Sadam radford struct MR_LD_TARGETID_LIST {
7839ab9ed38SChristoph Hellwig 	__le32	size;
7849ab9ed38SChristoph Hellwig 	__le32	count;
78521c9e160Sadam radford 	u8	pad[3];
78651087a86SSumit.Saxena@avagotech.com 	u8	targetId[MAX_LOGICAL_DRIVES_EXT];
78721c9e160Sadam radford };
78821c9e160Sadam radford 
78921c9e160Sadam radford 
790bdc6fb8dSYang, Bo /*
791c4a3e0a5SBagalkote, Sreenivas  * SAS controller properties
792c4a3e0a5SBagalkote, Sreenivas  */
793c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_prop {
794c4a3e0a5SBagalkote, Sreenivas 
795c4a3e0a5SBagalkote, Sreenivas 	u16 seq_num;
796c4a3e0a5SBagalkote, Sreenivas 	u16 pred_fail_poll_interval;
797c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_count;
798c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_timeouts;
799c4a3e0a5SBagalkote, Sreenivas 	u8 rebuild_rate;
800c4a3e0a5SBagalkote, Sreenivas 	u8 patrol_read_rate;
801c4a3e0a5SBagalkote, Sreenivas 	u8 bgi_rate;
802c4a3e0a5SBagalkote, Sreenivas 	u8 cc_rate;
803c4a3e0a5SBagalkote, Sreenivas 	u8 recon_rate;
804c4a3e0a5SBagalkote, Sreenivas 	u8 cache_flush_interval;
805c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_drv_count;
806c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_delay;
807c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_enable;
808c4a3e0a5SBagalkote, Sreenivas 	u8 coercion_mode;
809c4a3e0a5SBagalkote, Sreenivas 	u8 alarm_enable;
810c4a3e0a5SBagalkote, Sreenivas 	u8 disable_auto_rebuild;
811c4a3e0a5SBagalkote, Sreenivas 	u8 disable_battery_warn;
812c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_size;
813c4a3e0a5SBagalkote, Sreenivas 	u16 ecc_bucket_leak_rate;
814c4a3e0a5SBagalkote, Sreenivas 	u8 restore_hotspare_on_insertion;
815c4a3e0a5SBagalkote, Sreenivas 	u8 expose_encl_devices;
81639a98554Sbo yang 	u8 maintainPdFailHistory;
81739a98554Sbo yang 	u8 disallowHostRequestReordering;
81839a98554Sbo yang 	u8 abortCCOnError;
81939a98554Sbo yang 	u8 loadBalanceMode;
82039a98554Sbo yang 	u8 disableAutoDetectBackplane;
821c4a3e0a5SBagalkote, Sreenivas 
82239a98554Sbo yang 	u8 snapVDSpace;
82339a98554Sbo yang 
82439a98554Sbo yang 	/*
82539a98554Sbo yang 	* Add properties that can be controlled by
82639a98554Sbo yang 	* a bit in the following structure.
82739a98554Sbo yang 	*/
82839a98554Sbo yang 	struct {
82994cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
83094cd65ddSSumit.Saxena@lsi.com 		u32     reserved:18;
83194cd65ddSSumit.Saxena@lsi.com 		u32     enableJBOD:1;
83294cd65ddSSumit.Saxena@lsi.com 		u32     disableSpinDownHS:1;
83394cd65ddSSumit.Saxena@lsi.com 		u32     allowBootWithPinnedCache:1;
83494cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlineCtrlReset:1;
83594cd65ddSSumit.Saxena@lsi.com 		u32     enableSecretKeyControl:1;
83694cd65ddSSumit.Saxena@lsi.com 		u32     autoEnhancedImport:1;
83794cd65ddSSumit.Saxena@lsi.com 		u32     enableSpinDownUnconfigured:1;
83894cd65ddSSumit.Saxena@lsi.com 		u32     SSDPatrolReadEnabled:1;
83994cd65ddSSumit.Saxena@lsi.com 		u32     SSDSMARTerEnabled:1;
84094cd65ddSSumit.Saxena@lsi.com 		u32     disableNCQ:1;
84194cd65ddSSumit.Saxena@lsi.com 		u32     useFdeOnly:1;
84294cd65ddSSumit.Saxena@lsi.com 		u32     prCorrectUnconfiguredAreas:1;
84394cd65ddSSumit.Saxena@lsi.com 		u32     SMARTerEnabled:1;
84494cd65ddSSumit.Saxena@lsi.com 		u32     copyBackDisabled:1;
84594cd65ddSSumit.Saxena@lsi.com #else
84639a98554Sbo yang 		u32     copyBackDisabled:1;
84739a98554Sbo yang 		u32     SMARTerEnabled:1;
84839a98554Sbo yang 		u32     prCorrectUnconfiguredAreas:1;
84939a98554Sbo yang 		u32     useFdeOnly:1;
85039a98554Sbo yang 		u32     disableNCQ:1;
85139a98554Sbo yang 		u32     SSDSMARTerEnabled:1;
85239a98554Sbo yang 		u32     SSDPatrolReadEnabled:1;
85339a98554Sbo yang 		u32     enableSpinDownUnconfigured:1;
85439a98554Sbo yang 		u32     autoEnhancedImport:1;
85539a98554Sbo yang 		u32     enableSecretKeyControl:1;
85639a98554Sbo yang 		u32     disableOnlineCtrlReset:1;
85739a98554Sbo yang 		u32     allowBootWithPinnedCache:1;
85839a98554Sbo yang 		u32     disableSpinDownHS:1;
85939a98554Sbo yang 		u32     enableJBOD:1;
86039a98554Sbo yang 		u32     reserved:18;
86194cd65ddSSumit.Saxena@lsi.com #endif
86239a98554Sbo yang 	} OnOffProperties;
86339a98554Sbo yang 	u8 autoSnapVDSpace;
86439a98554Sbo yang 	u8 viewSpace;
8659ab9ed38SChristoph Hellwig 	__le16 spinDownTime;
86639a98554Sbo yang 	u8  reserved[24];
86781e403ceSYang, Bo } __packed;
868c4a3e0a5SBagalkote, Sreenivas 
869c4a3e0a5SBagalkote, Sreenivas /*
870c4a3e0a5SBagalkote, Sreenivas  * SAS controller information
871c4a3e0a5SBagalkote, Sreenivas  */
872c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_info {
873c4a3e0a5SBagalkote, Sreenivas 
874c4a3e0a5SBagalkote, Sreenivas 	/*
875c4a3e0a5SBagalkote, Sreenivas 	 * PCI device information
876c4a3e0a5SBagalkote, Sreenivas 	 */
877c4a3e0a5SBagalkote, Sreenivas 	struct {
878c4a3e0a5SBagalkote, Sreenivas 
8799ab9ed38SChristoph Hellwig 		__le16 vendor_id;
8809ab9ed38SChristoph Hellwig 		__le16 device_id;
8819ab9ed38SChristoph Hellwig 		__le16 sub_vendor_id;
8829ab9ed38SChristoph Hellwig 		__le16 sub_device_id;
883c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[24];
884c4a3e0a5SBagalkote, Sreenivas 
885c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pci;
886c4a3e0a5SBagalkote, Sreenivas 
887c4a3e0a5SBagalkote, Sreenivas 	/*
888c4a3e0a5SBagalkote, Sreenivas 	 * Host interface information
889c4a3e0a5SBagalkote, Sreenivas 	 */
890c4a3e0a5SBagalkote, Sreenivas 	struct {
891c4a3e0a5SBagalkote, Sreenivas 
892c4a3e0a5SBagalkote, Sreenivas 		u8 PCIX:1;
893c4a3e0a5SBagalkote, Sreenivas 		u8 PCIE:1;
894c4a3e0a5SBagalkote, Sreenivas 		u8 iSCSI:1;
895c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
896229fe47cSadam radford 		u8 SRIOV:1;
897229fe47cSadam radford 		u8 reserved_0:3;
898c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
899c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
900c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
901c4a3e0a5SBagalkote, Sreenivas 
902c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) host_interface;
903c4a3e0a5SBagalkote, Sreenivas 
904c4a3e0a5SBagalkote, Sreenivas 	/*
905c4a3e0a5SBagalkote, Sreenivas 	 * Device (backend) interface information
906c4a3e0a5SBagalkote, Sreenivas 	 */
907c4a3e0a5SBagalkote, Sreenivas 	struct {
908c4a3e0a5SBagalkote, Sreenivas 
909c4a3e0a5SBagalkote, Sreenivas 		u8 SPI:1;
910c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
911c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_1_5G:1;
912c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_3G:1;
913c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_0:4;
914c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
915c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
916c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
917c4a3e0a5SBagalkote, Sreenivas 
918c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) device_interface;
919c4a3e0a5SBagalkote, Sreenivas 
920c4a3e0a5SBagalkote, Sreenivas 	/*
921c4a3e0a5SBagalkote, Sreenivas 	 * List of components residing in flash. All str are null terminated
922c4a3e0a5SBagalkote, Sreenivas 	 */
9239ab9ed38SChristoph Hellwig 	__le32 image_check_word;
9249ab9ed38SChristoph Hellwig 	__le32 image_component_count;
925c4a3e0a5SBagalkote, Sreenivas 
926c4a3e0a5SBagalkote, Sreenivas 	struct {
927c4a3e0a5SBagalkote, Sreenivas 
928c4a3e0a5SBagalkote, Sreenivas 		char name[8];
929c4a3e0a5SBagalkote, Sreenivas 		char version[32];
930c4a3e0a5SBagalkote, Sreenivas 		char build_date[16];
931c4a3e0a5SBagalkote, Sreenivas 		char built_time[16];
932c4a3e0a5SBagalkote, Sreenivas 
933c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) image_component[8];
934c4a3e0a5SBagalkote, Sreenivas 
935c4a3e0a5SBagalkote, Sreenivas 	/*
936c4a3e0a5SBagalkote, Sreenivas 	 * List of flash components that have been flashed on the card, but
937c4a3e0a5SBagalkote, Sreenivas 	 * are not in use, pending reset of the adapter. This list will be
938c4a3e0a5SBagalkote, Sreenivas 	 * empty if a flash operation has not occurred. All stings are null
939c4a3e0a5SBagalkote, Sreenivas 	 * terminated
940c4a3e0a5SBagalkote, Sreenivas 	 */
9419ab9ed38SChristoph Hellwig 	__le32 pending_image_component_count;
942c4a3e0a5SBagalkote, Sreenivas 
943c4a3e0a5SBagalkote, Sreenivas 	struct {
944c4a3e0a5SBagalkote, Sreenivas 
945c4a3e0a5SBagalkote, Sreenivas 		char name[8];
946c4a3e0a5SBagalkote, Sreenivas 		char version[32];
947c4a3e0a5SBagalkote, Sreenivas 		char build_date[16];
948c4a3e0a5SBagalkote, Sreenivas 		char build_time[16];
949c4a3e0a5SBagalkote, Sreenivas 
950c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pending_image_component[8];
951c4a3e0a5SBagalkote, Sreenivas 
952c4a3e0a5SBagalkote, Sreenivas 	u8 max_arms;
953c4a3e0a5SBagalkote, Sreenivas 	u8 max_spans;
954c4a3e0a5SBagalkote, Sreenivas 	u8 max_arrays;
955c4a3e0a5SBagalkote, Sreenivas 	u8 max_lds;
956c4a3e0a5SBagalkote, Sreenivas 
957c4a3e0a5SBagalkote, Sreenivas 	char product_name[80];
958c4a3e0a5SBagalkote, Sreenivas 	char serial_no[32];
959c4a3e0a5SBagalkote, Sreenivas 
960c4a3e0a5SBagalkote, Sreenivas 	/*
961c4a3e0a5SBagalkote, Sreenivas 	 * Other physical/controller/operation information. Indicates the
962c4a3e0a5SBagalkote, Sreenivas 	 * presence of the hardware
963c4a3e0a5SBagalkote, Sreenivas 	 */
964c4a3e0a5SBagalkote, Sreenivas 	struct {
965c4a3e0a5SBagalkote, Sreenivas 
966c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
967c4a3e0a5SBagalkote, Sreenivas 		u32 alarm:1;
968c4a3e0a5SBagalkote, Sreenivas 		u32 nvram:1;
969c4a3e0a5SBagalkote, Sreenivas 		u32 uart:1;
970c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:28;
971c4a3e0a5SBagalkote, Sreenivas 
972c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) hw_present;
973c4a3e0a5SBagalkote, Sreenivas 
9749ab9ed38SChristoph Hellwig 	__le32 current_fw_time;
975c4a3e0a5SBagalkote, Sreenivas 
976c4a3e0a5SBagalkote, Sreenivas 	/*
977c4a3e0a5SBagalkote, Sreenivas 	 * Maximum data transfer sizes
978c4a3e0a5SBagalkote, Sreenivas 	 */
9799ab9ed38SChristoph Hellwig 	__le16 max_concurrent_cmds;
9809ab9ed38SChristoph Hellwig 	__le16 max_sge_count;
9819ab9ed38SChristoph Hellwig 	__le32 max_request_size;
982c4a3e0a5SBagalkote, Sreenivas 
983c4a3e0a5SBagalkote, Sreenivas 	/*
984c4a3e0a5SBagalkote, Sreenivas 	 * Logical and physical device counts
985c4a3e0a5SBagalkote, Sreenivas 	 */
9869ab9ed38SChristoph Hellwig 	__le16 ld_present_count;
9879ab9ed38SChristoph Hellwig 	__le16 ld_degraded_count;
9889ab9ed38SChristoph Hellwig 	__le16 ld_offline_count;
989c4a3e0a5SBagalkote, Sreenivas 
9909ab9ed38SChristoph Hellwig 	__le16 pd_present_count;
9919ab9ed38SChristoph Hellwig 	__le16 pd_disk_present_count;
9929ab9ed38SChristoph Hellwig 	__le16 pd_disk_pred_failure_count;
9939ab9ed38SChristoph Hellwig 	__le16 pd_disk_failed_count;
994c4a3e0a5SBagalkote, Sreenivas 
995c4a3e0a5SBagalkote, Sreenivas 	/*
996c4a3e0a5SBagalkote, Sreenivas 	 * Memory size information
997c4a3e0a5SBagalkote, Sreenivas 	 */
9989ab9ed38SChristoph Hellwig 	__le16 nvram_size;
9999ab9ed38SChristoph Hellwig 	__le16 memory_size;
10009ab9ed38SChristoph Hellwig 	__le16 flash_size;
1001c4a3e0a5SBagalkote, Sreenivas 
1002c4a3e0a5SBagalkote, Sreenivas 	/*
1003c4a3e0a5SBagalkote, Sreenivas 	 * Error counters
1004c4a3e0a5SBagalkote, Sreenivas 	 */
10059ab9ed38SChristoph Hellwig 	__le16 mem_correctable_error_count;
10069ab9ed38SChristoph Hellwig 	__le16 mem_uncorrectable_error_count;
1007c4a3e0a5SBagalkote, Sreenivas 
1008c4a3e0a5SBagalkote, Sreenivas 	/*
1009c4a3e0a5SBagalkote, Sreenivas 	 * Cluster information
1010c4a3e0a5SBagalkote, Sreenivas 	 */
1011c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_permitted;
1012c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_active;
1013c4a3e0a5SBagalkote, Sreenivas 
1014c4a3e0a5SBagalkote, Sreenivas 	/*
1015c4a3e0a5SBagalkote, Sreenivas 	 * Additional max data transfer sizes
1016c4a3e0a5SBagalkote, Sreenivas 	 */
10179ab9ed38SChristoph Hellwig 	__le16 max_strips_per_io;
1018c4a3e0a5SBagalkote, Sreenivas 
1019c4a3e0a5SBagalkote, Sreenivas 	/*
1020c4a3e0a5SBagalkote, Sreenivas 	 * Controller capabilities structures
1021c4a3e0a5SBagalkote, Sreenivas 	 */
1022c4a3e0a5SBagalkote, Sreenivas 	struct {
1023c4a3e0a5SBagalkote, Sreenivas 
1024c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_0:1;
1025c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1:1;
1026c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_5:1;
1027c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1E:1;
1028c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_6:1;
1029c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1030c4a3e0a5SBagalkote, Sreenivas 
1031c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) raid_levels;
1032c4a3e0a5SBagalkote, Sreenivas 
1033c4a3e0a5SBagalkote, Sreenivas 	struct {
1034c4a3e0a5SBagalkote, Sreenivas 
1035c4a3e0a5SBagalkote, Sreenivas 		u32 rbld_rate:1;
1036c4a3e0a5SBagalkote, Sreenivas 		u32 cc_rate:1;
1037c4a3e0a5SBagalkote, Sreenivas 		u32 bgi_rate:1;
1038c4a3e0a5SBagalkote, Sreenivas 		u32 recon_rate:1;
1039c4a3e0a5SBagalkote, Sreenivas 		u32 patrol_rate:1;
1040c4a3e0a5SBagalkote, Sreenivas 		u32 alarm_control:1;
1041c4a3e0a5SBagalkote, Sreenivas 		u32 cluster_supported:1;
1042c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
1043c4a3e0a5SBagalkote, Sreenivas 		u32 spanning_allowed:1;
1044c4a3e0a5SBagalkote, Sreenivas 		u32 dedicated_hotspares:1;
1045c4a3e0a5SBagalkote, Sreenivas 		u32 revertible_hotspares:1;
1046c4a3e0a5SBagalkote, Sreenivas 		u32 foreign_config_import:1;
1047c4a3e0a5SBagalkote, Sreenivas 		u32 self_diagnostic:1;
1048c4a3e0a5SBagalkote, Sreenivas 		u32 mixed_redundancy_arr:1;
1049c4a3e0a5SBagalkote, Sreenivas 		u32 global_hot_spares:1;
1050c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:17;
1051c4a3e0a5SBagalkote, Sreenivas 
1052c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) adapter_operations;
1053c4a3e0a5SBagalkote, Sreenivas 
1054c4a3e0a5SBagalkote, Sreenivas 	struct {
1055c4a3e0a5SBagalkote, Sreenivas 
1056c4a3e0a5SBagalkote, Sreenivas 		u32 read_policy:1;
1057c4a3e0a5SBagalkote, Sreenivas 		u32 write_policy:1;
1058c4a3e0a5SBagalkote, Sreenivas 		u32 io_policy:1;
1059c4a3e0a5SBagalkote, Sreenivas 		u32 access_policy:1;
1060c4a3e0a5SBagalkote, Sreenivas 		u32 disk_cache_policy:1;
1061c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1062c4a3e0a5SBagalkote, Sreenivas 
1063c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) ld_operations;
1064c4a3e0a5SBagalkote, Sreenivas 
1065c4a3e0a5SBagalkote, Sreenivas 	struct {
1066c4a3e0a5SBagalkote, Sreenivas 
1067c4a3e0a5SBagalkote, Sreenivas 		u8 min;
1068c4a3e0a5SBagalkote, Sreenivas 		u8 max;
1069c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[2];
1070c4a3e0a5SBagalkote, Sreenivas 
1071c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) stripe_sz_ops;
1072c4a3e0a5SBagalkote, Sreenivas 
1073c4a3e0a5SBagalkote, Sreenivas 	struct {
1074c4a3e0a5SBagalkote, Sreenivas 
1075c4a3e0a5SBagalkote, Sreenivas 		u32 force_online:1;
1076c4a3e0a5SBagalkote, Sreenivas 		u32 force_offline:1;
1077c4a3e0a5SBagalkote, Sreenivas 		u32 force_rebuild:1;
1078c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:29;
1079c4a3e0a5SBagalkote, Sreenivas 
1080c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_operations;
1081c4a3e0a5SBagalkote, Sreenivas 
1082c4a3e0a5SBagalkote, Sreenivas 	struct {
1083c4a3e0a5SBagalkote, Sreenivas 
1084c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sas:1;
1085c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sata:1;
1086c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_encl:1;
1087c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_ld:1;
1088c4a3e0a5SBagalkote, Sreenivas 		u32 allow_sata_in_cluster:1;
1089c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1090c4a3e0a5SBagalkote, Sreenivas 
1091c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_mix_support;
1092c4a3e0a5SBagalkote, Sreenivas 
1093c4a3e0a5SBagalkote, Sreenivas 	/*
1094c4a3e0a5SBagalkote, Sreenivas 	 * Define ECC single-bit-error bucket information
1095c4a3e0a5SBagalkote, Sreenivas 	 */
1096c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_count;
1097c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[11];
1098c4a3e0a5SBagalkote, Sreenivas 
1099c4a3e0a5SBagalkote, Sreenivas 	/*
1100c4a3e0a5SBagalkote, Sreenivas 	 * Include the controller properties (changeable items)
1101c4a3e0a5SBagalkote, Sreenivas 	 */
1102c4a3e0a5SBagalkote, Sreenivas 	struct megasas_ctrl_prop properties;
1103c4a3e0a5SBagalkote, Sreenivas 
1104c4a3e0a5SBagalkote, Sreenivas 	/*
1105c4a3e0a5SBagalkote, Sreenivas 	 * Define FW pkg version (set in envt v'bles on OEM basis)
1106c4a3e0a5SBagalkote, Sreenivas 	 */
1107c4a3e0a5SBagalkote, Sreenivas 	char package_version[0x60];
1108c4a3e0a5SBagalkote, Sreenivas 
1109c4a3e0a5SBagalkote, Sreenivas 
1110bc93d425SSumit.Saxena@lsi.com 	/*
1111bc93d425SSumit.Saxena@lsi.com 	* If adapterOperations.supportMoreThan8Phys is set,
1112bc93d425SSumit.Saxena@lsi.com 	* and deviceInterface.portCount is greater than 8,
1113bc93d425SSumit.Saxena@lsi.com 	* SAS Addrs for first 8 ports shall be populated in
1114bc93d425SSumit.Saxena@lsi.com 	* deviceInterface.portAddr, and the rest shall be
1115bc93d425SSumit.Saxena@lsi.com 	* populated in deviceInterfacePortAddr2.
1116bc93d425SSumit.Saxena@lsi.com 	*/
11179ab9ed38SChristoph Hellwig 	__le64	    deviceInterfacePortAddr2[8]; /*6a0h */
1118bc93d425SSumit.Saxena@lsi.com 	u8          reserved3[128];              /*6e0h */
1119bc93d425SSumit.Saxena@lsi.com 
1120bc93d425SSumit.Saxena@lsi.com 	struct {                                /*760h */
1121bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_0:4;
1122bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_0:12;
1123bc93d425SSumit.Saxena@lsi.com 
1124bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1:4;
1125bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1:12;
1126bc93d425SSumit.Saxena@lsi.com 
1127bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_5:4;
1128bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_5:12;
1129bc93d425SSumit.Saxena@lsi.com 
1130bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E:4;
1131bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E:12;
1132bc93d425SSumit.Saxena@lsi.com 
1133bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_6:4;
1134bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_6:12;
1135bc93d425SSumit.Saxena@lsi.com 
1136bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_10:4;
1137bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_10:12;
1138bc93d425SSumit.Saxena@lsi.com 
1139bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_50:4;
1140bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_50:12;
1141bc93d425SSumit.Saxena@lsi.com 
1142bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_60:4;
1143bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_60:12;
1144bc93d425SSumit.Saxena@lsi.com 
1145bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E_RLQ0:4;
1146bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E_RLQ0:12;
1147bc93d425SSumit.Saxena@lsi.com 
1148bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E0_RLQ0:4;
1149bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E0_RLQ0:12;
1150bc93d425SSumit.Saxena@lsi.com 
1151bc93d425SSumit.Saxena@lsi.com 		u16 reserved[6];
1152bc93d425SSumit.Saxena@lsi.com 	} pdsForRaidLevels;
1153bc93d425SSumit.Saxena@lsi.com 
11549ab9ed38SChristoph Hellwig 	__le16 maxPds;                          /*780h */
11559ab9ed38SChristoph Hellwig 	__le16 maxDedHSPs;                      /*782h */
11569ab9ed38SChristoph Hellwig 	__le16 maxGlobalHSP;                    /*784h */
11579ab9ed38SChristoph Hellwig 	__le16 ddfSize;                         /*786h */
1158bc93d425SSumit.Saxena@lsi.com 	u8  maxLdsPerArray;                     /*788h */
1159bc93d425SSumit.Saxena@lsi.com 	u8  partitionsInDDF;                    /*789h */
1160bc93d425SSumit.Saxena@lsi.com 	u8  lockKeyBinding;                     /*78ah */
1161bc93d425SSumit.Saxena@lsi.com 	u8  maxPITsPerLd;                       /*78bh */
1162bc93d425SSumit.Saxena@lsi.com 	u8  maxViewsPerLd;                      /*78ch */
1163bc93d425SSumit.Saxena@lsi.com 	u8  maxTargetId;                        /*78dh */
11649ab9ed38SChristoph Hellwig 	__le16 maxBvlVdSize;                    /*78eh */
1165bc93d425SSumit.Saxena@lsi.com 
11669ab9ed38SChristoph Hellwig 	__le16 maxConfigurableSSCSize;          /*790h */
11679ab9ed38SChristoph Hellwig 	__le16 currentSSCsize;                  /*792h */
1168bc93d425SSumit.Saxena@lsi.com 
1169bc93d425SSumit.Saxena@lsi.com 	char    expanderFwVersion[12];          /*794h */
1170bc93d425SSumit.Saxena@lsi.com 
11719ab9ed38SChristoph Hellwig 	__le16 PFKTrialTimeRemaining;           /*7A0h */
1172bc93d425SSumit.Saxena@lsi.com 
11739ab9ed38SChristoph Hellwig 	__le16 cacheMemorySize;                 /*7A2h */
1174bc93d425SSumit.Saxena@lsi.com 
1175bc93d425SSumit.Saxena@lsi.com 	struct {                                /*7A4h */
117694cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
1177229fe47cSadam radford 		u32     reserved:5;
1178229fe47cSadam radford 		u32	activePassive:2;
1179229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1180229fe47cSadam radford 		u32	mpio:1;
1181229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1182229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
118394cd65ddSSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
118494cd65ddSSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
118594cd65ddSSumit.Saxena@lsi.com 		u32     headlessMode:1;
118694cd65ddSSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
118794cd65ddSSumit.Saxena@lsi.com 		u32     supportResetNow:1;
118894cd65ddSSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
118994cd65ddSSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
119094cd65ddSSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
119194cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
119294cd65ddSSumit.Saxena@lsi.com 		u32     supportJBOD:1;
119394cd65ddSSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
119494cd65ddSSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
119594cd65ddSSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
119694cd65ddSSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
119794cd65ddSSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
119894cd65ddSSumit.Saxena@lsi.com 		u32     supportShieldState:1;
119994cd65ddSSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
120094cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
120194cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
120294cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
120394cd65ddSSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
120494cd65ddSSumit.Saxena@lsi.com #else
1205bc93d425SSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
1206bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
1207bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
1208bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
1209bc93d425SSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
1210bc93d425SSumit.Saxena@lsi.com 		u32     supportShieldState:1;
1211bc93d425SSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
1212bc93d425SSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
1213bc93d425SSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
1214bc93d425SSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
1215bc93d425SSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
1216bc93d425SSumit.Saxena@lsi.com 		u32     supportJBOD:1;
1217bc93d425SSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
1218bc93d425SSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
1219bc93d425SSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
1220bc93d425SSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
1221bc93d425SSumit.Saxena@lsi.com 
1222bc93d425SSumit.Saxena@lsi.com 		u32     supportResetNow:1;
1223bc93d425SSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
1224bc93d425SSumit.Saxena@lsi.com 		u32     headlessMode:1;
1225bc93d425SSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
1226bc93d425SSumit.Saxena@lsi.com 
1227bc93d425SSumit.Saxena@lsi.com 
1228bc93d425SSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
1229229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
1230229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1231229fe47cSadam radford 		u32	mpio:1;
1232229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1233229fe47cSadam radford 		u32	activePassive:2;
1234229fe47cSadam radford 		u32     reserved:5;
123594cd65ddSSumit.Saxena@lsi.com #endif
1236bc93d425SSumit.Saxena@lsi.com 	} adapterOperations2;
1237bc93d425SSumit.Saxena@lsi.com 
1238bc93d425SSumit.Saxena@lsi.com 	u8  driverVersion[32];                  /*7A8h */
1239bc93d425SSumit.Saxena@lsi.com 	u8  maxDAPdCountSpinup60;               /*7C8h */
1240bc93d425SSumit.Saxena@lsi.com 	u8  temperatureROC;                     /*7C9h */
1241bc93d425SSumit.Saxena@lsi.com 	u8  temperatureCtrl;                    /*7CAh */
1242bc93d425SSumit.Saxena@lsi.com 	u8  reserved4;                          /*7CBh */
12439ab9ed38SChristoph Hellwig 	__le16 maxConfigurablePds;              /*7CCh */
1244bc93d425SSumit.Saxena@lsi.com 
1245bc93d425SSumit.Saxena@lsi.com 
1246bc93d425SSumit.Saxena@lsi.com 	u8  reserved5[2];                       /*0x7CDh */
1247bc93d425SSumit.Saxena@lsi.com 
1248bc93d425SSumit.Saxena@lsi.com 	/*
1249bc93d425SSumit.Saxena@lsi.com 	* HA cluster information
1250bc93d425SSumit.Saxena@lsi.com 	*/
1251bc93d425SSumit.Saxena@lsi.com 	struct {
125251087a86SSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
12538f67c8c5SSumit Saxena 		u32     reserved:25;
12548f67c8c5SSumit Saxena 		u32     passive:1;
125551087a86SSumit.Saxena@avagotech.com 		u32     premiumFeatureMismatch:1;
125651087a86SSumit.Saxena@avagotech.com 		u32     ctrlPropIncompatible:1;
125751087a86SSumit.Saxena@avagotech.com 		u32     fwVersionMismatch:1;
125851087a86SSumit.Saxena@avagotech.com 		u32     hwIncompatible:1;
125951087a86SSumit.Saxena@avagotech.com 		u32     peerIsIncompatible:1;
126051087a86SSumit.Saxena@avagotech.com 		u32     peerIsPresent:1;
126151087a86SSumit.Saxena@avagotech.com #else
1262bc93d425SSumit.Saxena@lsi.com 		u32     peerIsPresent:1;
1263bc93d425SSumit.Saxena@lsi.com 		u32     peerIsIncompatible:1;
1264bc93d425SSumit.Saxena@lsi.com 		u32     hwIncompatible:1;
1265bc93d425SSumit.Saxena@lsi.com 		u32     fwVersionMismatch:1;
1266bc93d425SSumit.Saxena@lsi.com 		u32     ctrlPropIncompatible:1;
1267bc93d425SSumit.Saxena@lsi.com 		u32     premiumFeatureMismatch:1;
12688f67c8c5SSumit Saxena 		u32     passive:1;
12698f67c8c5SSumit Saxena 		u32     reserved:25;
127051087a86SSumit.Saxena@avagotech.com #endif
1271bc93d425SSumit.Saxena@lsi.com 	} cluster;
1272bc93d425SSumit.Saxena@lsi.com 
12738f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE]; /*0x7D4 */
1274229fe47cSadam radford 	struct {
1275229fe47cSadam radford 		u8  maxVFsSupported;            /*0x7E4*/
1276229fe47cSadam radford 		u8  numVFsEnabled;              /*0x7E5*/
1277229fe47cSadam radford 		u8  requestorId;                /*0x7E6 0:PF, 1:VF1, 2:VF2*/
1278229fe47cSadam radford 		u8  reserved;                   /*0x7E7*/
1279229fe47cSadam radford 	} iov;
1280bc93d425SSumit.Saxena@lsi.com 
1281fc62b3fcSSumit.Saxena@avagotech.com 	struct {
1282fc62b3fcSSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
12833761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
12843761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
12850be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
12860be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
12870be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
12880be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
12897497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
12907497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
12917497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
12927497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
12937497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
12947497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
12957497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
12967497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
12977497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
12987497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
12997497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
13007497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
13017497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
1302fc62b3fcSSumit.Saxena@avagotech.com 		u32     supportCrashDump:1;
130351087a86SSumit.Saxena@avagotech.com 		u32     supportMaxExtLDs:1;
130451087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
130551087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
130651087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
130751087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
1308fc62b3fcSSumit.Saxena@avagotech.com #else
130951087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
131051087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
131151087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
131251087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
131351087a86SSumit.Saxena@avagotech.com 		u32	supportMaxExtLDs:1;
1314fc62b3fcSSumit.Saxena@avagotech.com 		u32	supportCrashDump:1;
13157497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
13167497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
13177497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
13187497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
13197497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
13207497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
13217497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
13227497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
13237497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
13247497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
13257497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
13267497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
13277497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
13280be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
13290be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
13300be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
13310be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
13323761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
13333761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
1334fc62b3fcSSumit.Saxena@avagotech.com #endif
1335fc62b3fcSSumit.Saxena@avagotech.com 	} adapterOperations3;
1336fc62b3fcSSumit.Saxena@avagotech.com 
1337ede7c3ceSSasikumar Chandrasekaran 	struct {
1338ede7c3ceSSasikumar Chandrasekaran #if defined(__BIG_ENDIAN_BITFIELD)
1339ede7c3ceSSasikumar Chandrasekaran 	u8 reserved:7;
1340ede7c3ceSSasikumar Chandrasekaran 	/* Indicates whether the CPLD image is part of
1341ede7c3ceSSasikumar Chandrasekaran 	 *  the package and stored in flash
1342ede7c3ceSSasikumar Chandrasekaran 	 */
1343ede7c3ceSSasikumar Chandrasekaran 	u8 cpld_in_flash:1;
1344ede7c3ceSSasikumar Chandrasekaran #else
1345ede7c3ceSSasikumar Chandrasekaran 	u8 cpld_in_flash:1;
1346ede7c3ceSSasikumar Chandrasekaran 	u8 reserved:7;
1347ede7c3ceSSasikumar Chandrasekaran #endif
1348ede7c3ceSSasikumar Chandrasekaran 	u8 reserved1[3];
1349ede7c3ceSSasikumar Chandrasekaran 	/* Null terminated string. Has the version
1350ede7c3ceSSasikumar Chandrasekaran 	 *  information if cpld_in_flash = FALSE
1351ede7c3ceSSasikumar Chandrasekaran 	 */
1352ede7c3ceSSasikumar Chandrasekaran 	u8 userCodeDefinition[12];
1353ede7c3ceSSasikumar Chandrasekaran 	} cpld;  /* Valid only if upgradableCPLD is TRUE */
1354ede7c3ceSSasikumar Chandrasekaran 
1355ede7c3ceSSasikumar Chandrasekaran 	struct {
1356ede7c3ceSSasikumar Chandrasekaran 	#if defined(__BIG_ENDIAN_BITFIELD)
1357f870bcbeSShivasharan S 		u16 reserved:2;
1358f870bcbeSShivasharan S 		u16 support_nvme_passthru:1;
1359f870bcbeSShivasharan S 		u16 support_pl_debug_info:1;
1360f870bcbeSShivasharan S 		u16 support_flash_comp_info:1;
1361f870bcbeSShivasharan S 		u16 support_host_info:1;
1362f870bcbeSShivasharan S 		u16 support_dual_fw_update:1;
1363f870bcbeSShivasharan S 		u16 support_ssc_rev3:1;
1364ede7c3ceSSasikumar Chandrasekaran 		u16 fw_swaps_bbu_vpd_info:1;
1365ede7c3ceSSasikumar Chandrasekaran 		u16 support_pd_map_target_id:1;
1366ede7c3ceSSasikumar Chandrasekaran 		u16 support_ses_ctrl_in_multipathcfg:1;
1367ede7c3ceSSasikumar Chandrasekaran 		u16 image_upload_supported:1;
1368ede7c3ceSSasikumar Chandrasekaran 		u16 support_encrypted_mfc:1;
1369ede7c3ceSSasikumar Chandrasekaran 		u16 supported_enc_algo:1;
1370ede7c3ceSSasikumar Chandrasekaran 		u16 support_ibutton_less:1;
1371ede7c3ceSSasikumar Chandrasekaran 		u16 ctrl_info_ext_supported:1;
1372ede7c3ceSSasikumar Chandrasekaran 	#else
1373ede7c3ceSSasikumar Chandrasekaran 
1374ede7c3ceSSasikumar Chandrasekaran 		u16 ctrl_info_ext_supported:1;
1375ede7c3ceSSasikumar Chandrasekaran 		u16 support_ibutton_less:1;
1376ede7c3ceSSasikumar Chandrasekaran 		u16 supported_enc_algo:1;
1377ede7c3ceSSasikumar Chandrasekaran 		u16 support_encrypted_mfc:1;
1378ede7c3ceSSasikumar Chandrasekaran 		u16 image_upload_supported:1;
1379ede7c3ceSSasikumar Chandrasekaran 		/* FW supports LUN based association and target port based */
1380ede7c3ceSSasikumar Chandrasekaran 		u16 support_ses_ctrl_in_multipathcfg:1;
1381ede7c3ceSSasikumar Chandrasekaran 		/* association for the SES device connected in multipath mode */
1382ede7c3ceSSasikumar Chandrasekaran 		/* FW defines Jbod target Id within MR_PD_CFG_SEQ */
1383ede7c3ceSSasikumar Chandrasekaran 		u16 support_pd_map_target_id:1;
1384ede7c3ceSSasikumar Chandrasekaran 		/* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
1385ede7c3ceSSasikumar Chandrasekaran 		 *  provide the data in little endian order
1386ede7c3ceSSasikumar Chandrasekaran 		 */
1387ede7c3ceSSasikumar Chandrasekaran 		u16 fw_swaps_bbu_vpd_info:1;
1388f870bcbeSShivasharan S 		u16 support_ssc_rev3:1;
1389f870bcbeSShivasharan S 		/* FW supports CacheCade 3.0, only one SSCD creation allowed */
1390f870bcbeSShivasharan S 		u16 support_dual_fw_update:1;
1391f870bcbeSShivasharan S 		/* FW supports dual firmware update feature */
1392f870bcbeSShivasharan S 		u16 support_host_info:1;
1393f870bcbeSShivasharan S 		/* FW supports MR_DCMD_CTRL_HOST_INFO_SET/GET */
1394f870bcbeSShivasharan S 		u16 support_flash_comp_info:1;
1395f870bcbeSShivasharan S 		/* FW supports MR_DCMD_CTRL_FLASH_COMP_INFO_GET */
1396f870bcbeSShivasharan S 		u16 support_pl_debug_info:1;
1397f870bcbeSShivasharan S 		/* FW supports retrieval of PL debug information through apps */
1398f870bcbeSShivasharan S 		u16 support_nvme_passthru:1;
1399f870bcbeSShivasharan S 		/* FW supports NVMe passthru commands */
1400f870bcbeSShivasharan S 		u16 reserved:2;
1401ede7c3ceSSasikumar Chandrasekaran 	#endif
1402ede7c3ceSSasikumar Chandrasekaran 		} adapter_operations4;
1403ede7c3ceSSasikumar Chandrasekaran 	u8 pad[0x800 - 0x7FE]; /* 0x7FE pad to 2K for expansion */
1404e9495e2dSShivasharan S 
1405e9495e2dSShivasharan S 	u32 size;
1406e9495e2dSShivasharan S 	u32 pad1;
1407e9495e2dSShivasharan S 
1408e9495e2dSShivasharan S 	u8 reserved6[64];
1409e9495e2dSShivasharan S 
1410e9495e2dSShivasharan S 	u32 rsvdForAdptOp[64];
1411e9495e2dSShivasharan S 
1412e9495e2dSShivasharan S 	u8 reserved7[3];
1413e9495e2dSShivasharan S 
1414e9495e2dSShivasharan S 	u8 TaskAbortTO;	/* Timeout value in seconds used by Abort Task TM */
1415e9495e2dSShivasharan S 	u8 MaxResetTO;	/* Max Supported Reset timeout in seconds. */
1416e9495e2dSShivasharan S 	u8 reserved8[3];
141781e403ceSYang, Bo } __packed;
1418c4a3e0a5SBagalkote, Sreenivas 
1419c4a3e0a5SBagalkote, Sreenivas /*
1420c4a3e0a5SBagalkote, Sreenivas  * ===============================
1421c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS driver definitions
1422c4a3e0a5SBagalkote, Sreenivas  * ===============================
1423c4a3e0a5SBagalkote, Sreenivas  */
1424c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_PD_CHANNELS			2
142551087a86SSumit.Saxena@avagotech.com #define MEGASAS_MAX_LD_CHANNELS			2
1426c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_CHANNELS			(MEGASAS_MAX_PD_CHANNELS + \
1427c4a3e0a5SBagalkote, Sreenivas 						MEGASAS_MAX_LD_CHANNELS)
1428c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_DEV_PER_CHANNEL		128
1429c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_DEFAULT_INIT_ID			-1
1430c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_LUN				8
14316bf579a3Sadam radford #define MEGASAS_DEFAULT_CMD_PER_LUN		256
143281e403ceSYang, Bo #define MEGASAS_MAX_PD                          (MEGASAS_MAX_PD_CHANNELS * \
143381e403ceSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1434bdc6fb8dSYang, Bo #define MEGASAS_MAX_LD_IDS			(MEGASAS_MAX_LD_CHANNELS * \
1435bdc6fb8dSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1436c4a3e0a5SBagalkote, Sreenivas 
14371fd10685SYang, Bo #define MEGASAS_MAX_SECTORS                    (2*1024)
143842a8d2b3Sadam radford #define MEGASAS_MAX_SECTORS_IEEE		(2*128)
1439658dcedbSSumant Patro #define MEGASAS_DBG_LVL				1
1440658dcedbSSumant Patro 
144105e9ebbeSSumant Patro #define MEGASAS_FW_BUSY				1
144205e9ebbeSSumant Patro 
1443def0eab3SShivasharan S /* Driver's internal Logging levels*/
1444def0eab3SShivasharan S #define OCR_LOGS    (1 << 0)
1445def0eab3SShivasharan S 
144611c71cb4SSumit Saxena #define SCAN_PD_CHANNEL	0x1
144711c71cb4SSumit Saxena #define SCAN_VD_CHANNEL	0x2
144890dc9d98SSumit.Saxena@avagotech.com 
1449c3e385a1SSumit Saxena #define MEGASAS_KDUMP_QUEUE_DEPTH               100
1450a48ba0ecSShivasharan S #define MR_LARGE_IO_MIN_SIZE			(32 * 1024)
1451a48ba0ecSShivasharan S #define MR_R1_LDIO_PIGGYBACK_DEFAULT		4
1452c3e385a1SSumit Saxena 
14537497cde8SSumit.Saxena@avagotech.com enum MR_SCSI_CMD_TYPE {
14547497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_LDIO = 0,
14557497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_LDIO = 1,
14567497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_SYSPDIO = 2,
14577497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_SYSPDIO = 3,
14587497cde8SSumit.Saxena@avagotech.com };
14597497cde8SSumit.Saxena@avagotech.com 
14606d40afbcSSumit Saxena enum DCMD_TIMEOUT_ACTION {
14616d40afbcSSumit Saxena 	INITIATE_OCR = 0,
14626d40afbcSSumit Saxena 	KILL_ADAPTER = 1,
14636d40afbcSSumit Saxena 	IGNORE_TIMEOUT = 2,
14646d40afbcSSumit Saxena };
1465308ec459SSumit Saxena 
1466308ec459SSumit Saxena enum FW_BOOT_CONTEXT {
1467308ec459SSumit Saxena 	PROBE_CONTEXT = 0,
1468308ec459SSumit Saxena 	OCR_CONTEXT = 1,
1469308ec459SSumit Saxena };
1470308ec459SSumit Saxena 
1471d532dbe2Sbo yang /* Frame Type */
1472d532dbe2Sbo yang #define IO_FRAME				0
1473d532dbe2Sbo yang #define PTHRU_FRAME				1
1474d532dbe2Sbo yang 
1475c4a3e0a5SBagalkote, Sreenivas /*
1476c4a3e0a5SBagalkote, Sreenivas  * When SCSI mid-layer calls driver's reset routine, driver waits for
1477c4a3e0a5SBagalkote, Sreenivas  * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
1478c4a3e0a5SBagalkote, Sreenivas  * that the driver cannot _actually_ abort or reset pending commands. While
1479c4a3e0a5SBagalkote, Sreenivas  * it is waiting for the commands to complete, it prints a diagnostic message
1480c4a3e0a5SBagalkote, Sreenivas  * every MEGASAS_RESET_NOTICE_INTERVAL seconds
1481c4a3e0a5SBagalkote, Sreenivas  */
1482c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_RESET_WAIT_TIME			180
14832a3681e5SSumant Patro #define MEGASAS_INTERNAL_CMD_WAIT_TIME		180
1484c4a3e0a5SBagalkote, Sreenivas #define	MEGASAS_RESET_NOTICE_INTERVAL		5
1485c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOCTL_CMD			0
148605e9ebbeSSumant Patro #define MEGASAS_DEFAULT_CMD_TIMEOUT		90
1487c5daa6a9Sadam radford #define MEGASAS_THROTTLE_QUEUE_DEPTH		16
148890dc9d98SSumit.Saxena@avagotech.com #define MEGASAS_BLOCKED_CMD_TIMEOUT		60
1489e9495e2dSShivasharan S #define MEGASAS_DEFAULT_TM_TIMEOUT		50
1490c4a3e0a5SBagalkote, Sreenivas /*
1491c4a3e0a5SBagalkote, Sreenivas  * FW reports the maximum of number of commands that it can accept (maximum
1492c4a3e0a5SBagalkote, Sreenivas  * commands that can be outstanding) at any time. The driver must report a
1493c4a3e0a5SBagalkote, Sreenivas  * lower number to the mid layer because it can issue a few internal commands
1494c4a3e0a5SBagalkote, Sreenivas  * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
1495c4a3e0a5SBagalkote, Sreenivas  * is shown below
1496c4a3e0a5SBagalkote, Sreenivas  */
1497c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_INT_CMDS			32
14987bebf5c7SYang, Bo #define MEGASAS_SKINNY_INT_CMDS			5
1499ec779595SShivasharan S #define MEGASAS_FUSION_INTERNAL_CMDS		8
1500ae09a6c1SSumit.Saxena@avagotech.com #define MEGASAS_FUSION_IOCTL_CMDS		3
1501f26ac3a1SSumit.Saxena@avagotech.com #define MEGASAS_MFI_IOCTL_CMDS			27
1502c4a3e0a5SBagalkote, Sreenivas 
1503d46a3ad6SSumit.Saxena@lsi.com #define MEGASAS_MAX_MSIX_QUEUES			128
1504c4a3e0a5SBagalkote, Sreenivas /*
1505c4a3e0a5SBagalkote, Sreenivas  * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
1506c4a3e0a5SBagalkote, Sreenivas  * SGLs based on the size of dma_addr_t
1507c4a3e0a5SBagalkote, Sreenivas  */
1508c4a3e0a5SBagalkote, Sreenivas #define IS_DMA64				(sizeof(dma_addr_t) == 8)
1509c4a3e0a5SBagalkote, Sreenivas 
151039a98554Sbo yang #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT		0x00000001
151139a98554Sbo yang 
151239a98554Sbo yang #define MFI_INTR_FLAG_REPLY_MESSAGE			0x00000001
151339a98554Sbo yang #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE		0x00000002
151439a98554Sbo yang #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT	0x00000004
151539a98554Sbo yang 
1516c4a3e0a5SBagalkote, Sreenivas #define MFI_OB_INTR_STATUS_MASK			0x00000002
151714faea9fSbo yang #define MFI_POLL_TIMEOUT_SECS			60
15186d40afbcSSumit Saxena #define MFI_IO_TIMEOUT_SECS			180
1519229fe47cSadam radford #define MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF	(5 * HZ)
1520229fe47cSadam radford #define MEGASAS_OCR_SETTLE_TIME_VF		(1000 * 30)
1521229fe47cSadam radford #define MEGASAS_ROUTINE_WAIT_TIME_VF		300
1522f9876f0bSSumant Patro #define MFI_REPLY_1078_MESSAGE_INTERRUPT	0x80000000
15236610a6b3SYang, Bo #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT	0x00000001
15246610a6b3SYang, Bo #define MFI_GEN2_ENABLE_INTERRUPT_MASK		(0x00000001 | 0x00000004)
152587911122SYang, Bo #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT	0x40000000
152687911122SYang, Bo #define MFI_SKINNY_ENABLE_INTERRUPT_MASK	(0x00000001)
15270e98936cSSumant Patro 
152839a98554Sbo yang #define MFI_1068_PCSR_OFFSET			0x84
152939a98554Sbo yang #define MFI_1068_FW_HANDSHAKE_OFFSET		0x64
153039a98554Sbo yang #define MFI_1068_FW_READY			0xDDDD0000
1531d46a3ad6SSumit.Saxena@lsi.com 
1532d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_OFFSET              0X0000001F
1533d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET          0X003FC000
1534d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT    14
1535d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_MSIX_REG_ARRAY                   16
1536179ac142SSumit Saxena #define MR_RDPQ_MODE_OFFSET			0X00800000
1537d889344eSSasikumar Chandrasekaran 
1538d889344eSSasikumar Chandrasekaran #define MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT	16
1539d889344eSSasikumar Chandrasekaran #define MR_MAX_RAID_MAP_SIZE_MASK		0x1FF
1540d889344eSSasikumar Chandrasekaran #define MR_MIN_MAP_SIZE				0x10000
1541d889344eSSasikumar Chandrasekaran /* 64k */
1542d889344eSSasikumar Chandrasekaran 
1543d0fc91d6SKashyap Desai #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000
1544d0fc91d6SKashyap Desai 
1545107a60ddSShivasharan S #define MR_CAN_HANDLE_64_BIT_DMA_OFFSET		(1 << 25)
1546107a60ddSShivasharan S 
1547c365178fSShivasharan S enum MR_ADAPTER_TYPE {
1548c365178fSShivasharan S 	MFI_SERIES = 1,
1549c365178fSShivasharan S 	THUNDERBOLT_SERIES = 2,
1550c365178fSShivasharan S 	INVADER_SERIES = 3,
1551c365178fSShivasharan S 	VENTURA_SERIES = 4,
1552c365178fSShivasharan S };
1553c365178fSShivasharan S 
15540e98936cSSumant Patro /*
15550e98936cSSumant Patro * register set for both 1068 and 1078 controllers
15560e98936cSSumant Patro * structure extended for 1078 registers
15570e98936cSSumant Patro */
1558c4a3e0a5SBagalkote, Sreenivas 
1559f9876f0bSSumant Patro struct megasas_register_set {
15609c915a8cSadam radford 	u32	doorbell;                       /*0000h*/
15619c915a8cSadam radford 	u32	fusion_seq_offset;		/*0004h*/
15629c915a8cSadam radford 	u32	fusion_host_diag;		/*0008h*/
15639c915a8cSadam radford 	u32	reserved_01;			/*000Ch*/
1564c4a3e0a5SBagalkote, Sreenivas 
1565c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_0;			/*0010h*/
1566c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_1;			/*0014h*/
1567c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_0;			/*0018h*/
1568c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_1;			/*001Ch*/
1569c4a3e0a5SBagalkote, Sreenivas 
1570c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_doorbell;		/*0020h*/
1571c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_status;		/*0024h*/
1572c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_mask;		/*0028h*/
1573c4a3e0a5SBagalkote, Sreenivas 
1574c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_doorbell;		/*002Ch*/
1575c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_status;		/*0030h*/
1576c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_mask;		/*0034h*/
1577c4a3e0a5SBagalkote, Sreenivas 
1578c4a3e0a5SBagalkote, Sreenivas 	u32 	reserved_1[2];			/*0038h*/
1579c4a3e0a5SBagalkote, Sreenivas 
1580c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_queue_port;		/*0040h*/
1581c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_queue_port;		/*0044h*/
1582c4a3e0a5SBagalkote, Sreenivas 
15839c915a8cSadam radford 	u32	reserved_2[9];			/*0048h*/
15849c915a8cSadam radford 	u32	reply_post_host_index;		/*006Ch*/
15859c915a8cSadam radford 	u32	reserved_2_2[12];		/*0070h*/
1586c4a3e0a5SBagalkote, Sreenivas 
1587f9876f0bSSumant Patro 	u32 	outbound_doorbell_clear;	/*00A0h*/
1588f9876f0bSSumant Patro 
1589f9876f0bSSumant Patro 	u32 	reserved_3[3];			/*00A4h*/
1590f9876f0bSSumant Patro 
1591f9876f0bSSumant Patro 	u32 	outbound_scratch_pad ;		/*00B0h*/
15929c915a8cSadam radford 	u32	outbound_scratch_pad_2;         /*00B4h*/
1593179ac142SSumit Saxena 	u32	outbound_scratch_pad_3;         /*00B8h*/
159415dd0381SShivasharan S 	u32	outbound_scratch_pad_4;         /*00BCh*/
1595f9876f0bSSumant Patro 
1596f9876f0bSSumant Patro 
1597f9876f0bSSumant Patro 	u32 	inbound_low_queue_port ;	/*00C0h*/
1598f9876f0bSSumant Patro 
1599f9876f0bSSumant Patro 	u32 	inbound_high_queue_port ;	/*00C4h*/
1600f9876f0bSSumant Patro 
160145f4f2ebSSasikumar Chandrasekaran 	u32 inbound_single_queue_port;	/*00C8h*/
160239a98554Sbo yang 	u32	res_6[11];			/*CCh*/
160339a98554Sbo yang 	u32	host_diag;
160439a98554Sbo yang 	u32	seq_offset;
160539a98554Sbo yang 	u32 	index_registers[807];		/*00CCh*/
1606c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1607c4a3e0a5SBagalkote, Sreenivas 
1608c4a3e0a5SBagalkote, Sreenivas struct megasas_sge32 {
1609c4a3e0a5SBagalkote, Sreenivas 
16109ab9ed38SChristoph Hellwig 	__le32 phys_addr;
16119ab9ed38SChristoph Hellwig 	__le32 length;
1612c4a3e0a5SBagalkote, Sreenivas 
1613c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1614c4a3e0a5SBagalkote, Sreenivas 
1615c4a3e0a5SBagalkote, Sreenivas struct megasas_sge64 {
1616c4a3e0a5SBagalkote, Sreenivas 
16179ab9ed38SChristoph Hellwig 	__le64 phys_addr;
16189ab9ed38SChristoph Hellwig 	__le32 length;
1619c4a3e0a5SBagalkote, Sreenivas 
1620c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1621c4a3e0a5SBagalkote, Sreenivas 
1622f4c9a131SYang, Bo struct megasas_sge_skinny {
16239ab9ed38SChristoph Hellwig 	__le64 phys_addr;
16249ab9ed38SChristoph Hellwig 	__le32 length;
16259ab9ed38SChristoph Hellwig 	__le32 flag;
1626f4c9a131SYang, Bo } __packed;
1627f4c9a131SYang, Bo 
1628c4a3e0a5SBagalkote, Sreenivas union megasas_sgl {
1629c4a3e0a5SBagalkote, Sreenivas 
1630c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[1];
1631c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[1];
1632f4c9a131SYang, Bo 	struct megasas_sge_skinny sge_skinny[1];
1633c4a3e0a5SBagalkote, Sreenivas 
1634c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1635c4a3e0a5SBagalkote, Sreenivas 
1636c4a3e0a5SBagalkote, Sreenivas struct megasas_header {
1637c4a3e0a5SBagalkote, Sreenivas 
1638c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1639c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1640c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1641c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1642c4a3e0a5SBagalkote, Sreenivas 
1643c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1644c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1645c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1646c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1647c4a3e0a5SBagalkote, Sreenivas 
16489ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
16499ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1650c4a3e0a5SBagalkote, Sreenivas 
16519ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
16529ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
16539ab9ed38SChristoph Hellwig 	__le32 data_xferlen;	/*14h */
1654c4a3e0a5SBagalkote, Sreenivas 
1655c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1656c4a3e0a5SBagalkote, Sreenivas 
1657c4a3e0a5SBagalkote, Sreenivas union megasas_sgl_frame {
1658c4a3e0a5SBagalkote, Sreenivas 
1659c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[8];
1660c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[5];
1661c4a3e0a5SBagalkote, Sreenivas 
1662c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1663c4a3e0a5SBagalkote, Sreenivas 
1664d46a3ad6SSumit.Saxena@lsi.com typedef union _MFI_CAPABILITIES {
1665d46a3ad6SSumit.Saxena@lsi.com 	struct {
166694cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
1667f870bcbeSShivasharan S 	u32     reserved:17;
1668f870bcbeSShivasharan S 	u32	support_nvme_passthru:1;
1669107a60ddSShivasharan S 	u32     support_64bit_mode:1;
1670ede7c3ceSSasikumar Chandrasekaran 	u32 support_pd_map_target_id:1;
167152b62ac7SSumit Saxena 	u32     support_qd_throttling:1;
16728f05024cSSumit Saxena 	u32     support_fp_rlbypass:1;
16738f05024cSSumit Saxena 	u32     support_vfid_in_ioframe:1;
1674bd5f9484Ssumit.saxena@avagotech.com 	u32     support_ext_io_size:1;
16750be3f4c9Ssumit.saxena@avagotech.com 	u32		support_ext_queue_depth:1;
16767497cde8SSumit.Saxena@avagotech.com 	u32     security_protocol_cmds_fw:1;
16777497cde8SSumit.Saxena@avagotech.com 	u32     support_core_affinity:1;
1678d2552ebeSSumit.Saxena@avagotech.com 	u32     support_ndrive_r1_lb:1;
167951087a86SSumit.Saxena@avagotech.com 	u32		support_max_255lds:1;
16807497cde8SSumit.Saxena@avagotech.com 	u32		support_fastpath_wb:1;
168194cd65ddSSumit.Saxena@lsi.com 	u32     support_additional_msix:1;
168294cd65ddSSumit.Saxena@lsi.com 	u32     support_fp_remote_lun:1;
168394cd65ddSSumit.Saxena@lsi.com #else
1684d46a3ad6SSumit.Saxena@lsi.com 	u32     support_fp_remote_lun:1;
1685d46a3ad6SSumit.Saxena@lsi.com 	u32     support_additional_msix:1;
16867497cde8SSumit.Saxena@avagotech.com 	u32		support_fastpath_wb:1;
168751087a86SSumit.Saxena@avagotech.com 	u32		support_max_255lds:1;
1688d2552ebeSSumit.Saxena@avagotech.com 	u32     support_ndrive_r1_lb:1;
16897497cde8SSumit.Saxena@avagotech.com 	u32     support_core_affinity:1;
16907497cde8SSumit.Saxena@avagotech.com 	u32     security_protocol_cmds_fw:1;
16910be3f4c9Ssumit.saxena@avagotech.com 	u32		support_ext_queue_depth:1;
1692bd5f9484Ssumit.saxena@avagotech.com 	u32     support_ext_io_size:1;
16938f05024cSSumit Saxena 	u32     support_vfid_in_ioframe:1;
16948f05024cSSumit Saxena 	u32     support_fp_rlbypass:1;
169552b62ac7SSumit Saxena 	u32     support_qd_throttling:1;
1696ede7c3ceSSasikumar Chandrasekaran 	u32	support_pd_map_target_id:1;
1697107a60ddSShivasharan S 	u32     support_64bit_mode:1;
1698f870bcbeSShivasharan S 	u32	support_nvme_passthru:1;
1699f870bcbeSShivasharan S 	u32     reserved:17;
170094cd65ddSSumit.Saxena@lsi.com #endif
1701d46a3ad6SSumit.Saxena@lsi.com 	} mfi_capabilities;
17029ab9ed38SChristoph Hellwig 	__le32		reg;
1703d46a3ad6SSumit.Saxena@lsi.com } MFI_CAPABILITIES;
1704d46a3ad6SSumit.Saxena@lsi.com 
1705c4a3e0a5SBagalkote, Sreenivas struct megasas_init_frame {
1706c4a3e0a5SBagalkote, Sreenivas 
1707c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1708c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1709c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1710c4a3e0a5SBagalkote, Sreenivas 
1711c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
1712d46a3ad6SSumit.Saxena@lsi.com 	MFI_CAPABILITIES driver_operations; /*04h*/
1713c4a3e0a5SBagalkote, Sreenivas 
17149ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17159ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1716c4a3e0a5SBagalkote, Sreenivas 
17179ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17189ab9ed38SChristoph Hellwig 	__le16 reserved_3;		/*12h */
17199ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1720c4a3e0a5SBagalkote, Sreenivas 
17219ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_lo;	/*18h */
17229ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_hi;	/*1Ch */
17239ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_lo;	/*20h */
17249ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_hi;	/*24h */
17259ab9ed38SChristoph Hellwig 	__le32 reserved_4[2];	/*28h */
17269ab9ed38SChristoph Hellwig 	__le32 system_info_lo;      /*30h */
17279ab9ed38SChristoph Hellwig 	__le32 system_info_hi;      /*34h */
17289ab9ed38SChristoph Hellwig 	__le32 reserved_5[2];	/*38h */
1729c4a3e0a5SBagalkote, Sreenivas 
1730c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1731c4a3e0a5SBagalkote, Sreenivas 
1732c4a3e0a5SBagalkote, Sreenivas struct megasas_init_queue_info {
1733c4a3e0a5SBagalkote, Sreenivas 
17349ab9ed38SChristoph Hellwig 	__le32 init_flags;		/*00h */
17359ab9ed38SChristoph Hellwig 	__le32 reply_queue_entries;	/*04h */
1736c4a3e0a5SBagalkote, Sreenivas 
17379ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_lo;	/*08h */
17389ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_hi;	/*0Ch */
17399ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_lo;	/*10h */
17409ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_hi;	/*14h */
17419ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_lo;	/*18h */
17429ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_hi;	/*1Ch */
1743c4a3e0a5SBagalkote, Sreenivas 
1744c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1745c4a3e0a5SBagalkote, Sreenivas 
1746c4a3e0a5SBagalkote, Sreenivas struct megasas_io_frame {
1747c4a3e0a5SBagalkote, Sreenivas 
1748c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1749c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1750c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1751c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1752c4a3e0a5SBagalkote, Sreenivas 
1753c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1754c4a3e0a5SBagalkote, Sreenivas 	u8 access_byte;		/*05h */
1755c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*06h */
1756c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1757c4a3e0a5SBagalkote, Sreenivas 
17589ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17599ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1760c4a3e0a5SBagalkote, Sreenivas 
17619ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17629ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
17639ab9ed38SChristoph Hellwig 	__le32 lba_count;	/*14h */
1764c4a3e0a5SBagalkote, Sreenivas 
17659ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
17669ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1767c4a3e0a5SBagalkote, Sreenivas 
17689ab9ed38SChristoph Hellwig 	__le32 start_lba_lo;	/*20h */
17699ab9ed38SChristoph Hellwig 	__le32 start_lba_hi;	/*24h */
1770c4a3e0a5SBagalkote, Sreenivas 
1771c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1772c4a3e0a5SBagalkote, Sreenivas 
1773c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1774c4a3e0a5SBagalkote, Sreenivas 
1775c4a3e0a5SBagalkote, Sreenivas struct megasas_pthru_frame {
1776c4a3e0a5SBagalkote, Sreenivas 
1777c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1778c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1779c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1780c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1781c4a3e0a5SBagalkote, Sreenivas 
1782c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1783c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1784c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1785c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1786c4a3e0a5SBagalkote, Sreenivas 
17879ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17889ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1789c4a3e0a5SBagalkote, Sreenivas 
17909ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17919ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
17929ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1793c4a3e0a5SBagalkote, Sreenivas 
17949ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
17959ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1796c4a3e0a5SBagalkote, Sreenivas 
1797c4a3e0a5SBagalkote, Sreenivas 	u8 cdb[16];		/*20h */
1798c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*30h */
1799c4a3e0a5SBagalkote, Sreenivas 
1800c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1801c4a3e0a5SBagalkote, Sreenivas 
1802c4a3e0a5SBagalkote, Sreenivas struct megasas_dcmd_frame {
1803c4a3e0a5SBagalkote, Sreenivas 
1804c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1805c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1806c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1807c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1[4];	/*03h */
1808c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1809c4a3e0a5SBagalkote, Sreenivas 
18109ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18119ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1812c4a3e0a5SBagalkote, Sreenivas 
18139ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18149ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1815c4a3e0a5SBagalkote, Sreenivas 
18169ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
18179ab9ed38SChristoph Hellwig 	__le32 opcode;		/*18h */
1818c4a3e0a5SBagalkote, Sreenivas 
1819c4a3e0a5SBagalkote, Sreenivas 	union {			/*1Ch */
1820c4a3e0a5SBagalkote, Sreenivas 		u8 b[12];
18219ab9ed38SChristoph Hellwig 		__le16 s[6];
18229ab9ed38SChristoph Hellwig 		__le32 w[3];
1823c4a3e0a5SBagalkote, Sreenivas 	} mbox;
1824c4a3e0a5SBagalkote, Sreenivas 
1825c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1826c4a3e0a5SBagalkote, Sreenivas 
1827c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1828c4a3e0a5SBagalkote, Sreenivas 
1829c4a3e0a5SBagalkote, Sreenivas struct megasas_abort_frame {
1830c4a3e0a5SBagalkote, Sreenivas 
1831c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1832c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1833c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1834c4a3e0a5SBagalkote, Sreenivas 
1835c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
18369ab9ed38SChristoph Hellwig 	__le32 reserved_2;	/*04h */
1837c4a3e0a5SBagalkote, Sreenivas 
18389ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18399ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1840c4a3e0a5SBagalkote, Sreenivas 
18419ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18429ab9ed38SChristoph Hellwig 	__le16 reserved_3;	/*12h */
18439ab9ed38SChristoph Hellwig 	__le32 reserved_4;	/*14h */
1844c4a3e0a5SBagalkote, Sreenivas 
18459ab9ed38SChristoph Hellwig 	__le32 abort_context;	/*18h */
18469ab9ed38SChristoph Hellwig 	__le32 pad_1;		/*1Ch */
1847c4a3e0a5SBagalkote, Sreenivas 
18489ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_lo;	/*20h */
18499ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_hi;	/*24h */
1850c4a3e0a5SBagalkote, Sreenivas 
18519ab9ed38SChristoph Hellwig 	__le32 reserved_5[6];	/*28h */
1852c4a3e0a5SBagalkote, Sreenivas 
1853c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1854c4a3e0a5SBagalkote, Sreenivas 
1855c4a3e0a5SBagalkote, Sreenivas struct megasas_smp_frame {
1856c4a3e0a5SBagalkote, Sreenivas 
1857c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1858c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1859c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1860c4a3e0a5SBagalkote, Sreenivas 	u8 connection_status;	/*03h */
1861c4a3e0a5SBagalkote, Sreenivas 
1862c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[3];	/*04h */
1863c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1864c4a3e0a5SBagalkote, Sreenivas 
18659ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18669ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1867c4a3e0a5SBagalkote, Sreenivas 
18689ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18699ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1870c4a3e0a5SBagalkote, Sreenivas 
18719ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
18729ab9ed38SChristoph Hellwig 	__le64 sas_addr;	/*18h */
1873c4a3e0a5SBagalkote, Sreenivas 
1874c4a3e0a5SBagalkote, Sreenivas 	union {
1875c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: req */
1876c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: req */
1877c4a3e0a5SBagalkote, Sreenivas 	} sgl;
1878c4a3e0a5SBagalkote, Sreenivas 
1879c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1880c4a3e0a5SBagalkote, Sreenivas 
1881c4a3e0a5SBagalkote, Sreenivas struct megasas_stp_frame {
1882c4a3e0a5SBagalkote, Sreenivas 
1883c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1884c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1885c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1886c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2;		/*03h */
1887c4a3e0a5SBagalkote, Sreenivas 
1888c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1889c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_3[2];	/*05h */
1890c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1891c4a3e0a5SBagalkote, Sreenivas 
18929ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
18939ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1894c4a3e0a5SBagalkote, Sreenivas 
18959ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
18969ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1897c4a3e0a5SBagalkote, Sreenivas 
18989ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1899c4a3e0a5SBagalkote, Sreenivas 
19009ab9ed38SChristoph Hellwig 	__le16 fis[10];		/*18h */
19019ab9ed38SChristoph Hellwig 	__le32 stp_flags;
1902c4a3e0a5SBagalkote, Sreenivas 
1903c4a3e0a5SBagalkote, Sreenivas 	union {
1904c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: data */
1905c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: data */
1906c4a3e0a5SBagalkote, Sreenivas 	} sgl;
1907c4a3e0a5SBagalkote, Sreenivas 
1908c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1909c4a3e0a5SBagalkote, Sreenivas 
1910c4a3e0a5SBagalkote, Sreenivas union megasas_frame {
1911c4a3e0a5SBagalkote, Sreenivas 
1912c4a3e0a5SBagalkote, Sreenivas 	struct megasas_header hdr;
1913c4a3e0a5SBagalkote, Sreenivas 	struct megasas_init_frame init;
1914c4a3e0a5SBagalkote, Sreenivas 	struct megasas_io_frame io;
1915c4a3e0a5SBagalkote, Sreenivas 	struct megasas_pthru_frame pthru;
1916c4a3e0a5SBagalkote, Sreenivas 	struct megasas_dcmd_frame dcmd;
1917c4a3e0a5SBagalkote, Sreenivas 	struct megasas_abort_frame abort;
1918c4a3e0a5SBagalkote, Sreenivas 	struct megasas_smp_frame smp;
1919c4a3e0a5SBagalkote, Sreenivas 	struct megasas_stp_frame stp;
1920c4a3e0a5SBagalkote, Sreenivas 
1921c4a3e0a5SBagalkote, Sreenivas 	u8 raw_bytes[64];
1922c4a3e0a5SBagalkote, Sreenivas };
1923c4a3e0a5SBagalkote, Sreenivas 
192418365b13SSumit Saxena /**
192518365b13SSumit Saxena  * struct MR_PRIV_DEVICE - sdev private hostdata
192618365b13SSumit Saxena  * @is_tm_capable: firmware managed tm_capable flag
192718365b13SSumit Saxena  * @tm_busy: TM request is in progress
192818365b13SSumit Saxena  */
192918365b13SSumit Saxena struct MR_PRIV_DEVICE {
193018365b13SSumit Saxena 	bool is_tm_capable;
193118365b13SSumit Saxena 	bool tm_busy;
1932a48ba0ecSShivasharan S 	atomic_t r1_ldio_hint;
193315dd0381SShivasharan S 	u8 interface_type;
1934e9495e2dSShivasharan S 	u8 task_abort_tmo;
1935e9495e2dSShivasharan S 	u8 target_reset_tmo;
193618365b13SSumit Saxena };
1937c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd;
1938c4a3e0a5SBagalkote, Sreenivas 
1939c4a3e0a5SBagalkote, Sreenivas union megasas_evt_class_locale {
1940c4a3e0a5SBagalkote, Sreenivas 
1941c4a3e0a5SBagalkote, Sreenivas 	struct {
1942be26374bSSumit.Saxena@lsi.com #ifndef __BIG_ENDIAN_BITFIELD
1943c4a3e0a5SBagalkote, Sreenivas 		u16 locale;
1944c4a3e0a5SBagalkote, Sreenivas 		u8 reserved;
1945c4a3e0a5SBagalkote, Sreenivas 		s8 class;
1946be26374bSSumit.Saxena@lsi.com #else
1947be26374bSSumit.Saxena@lsi.com 		s8 class;
1948be26374bSSumit.Saxena@lsi.com 		u8 reserved;
1949be26374bSSumit.Saxena@lsi.com 		u16 locale;
1950be26374bSSumit.Saxena@lsi.com #endif
1951c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) members;
1952c4a3e0a5SBagalkote, Sreenivas 
1953c4a3e0a5SBagalkote, Sreenivas 	u32 word;
1954c4a3e0a5SBagalkote, Sreenivas 
1955c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1956c4a3e0a5SBagalkote, Sreenivas 
1957c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_log_info {
19589ab9ed38SChristoph Hellwig 	__le32 newest_seq_num;
19599ab9ed38SChristoph Hellwig 	__le32 oldest_seq_num;
19609ab9ed38SChristoph Hellwig 	__le32 clear_seq_num;
19619ab9ed38SChristoph Hellwig 	__le32 shutdown_seq_num;
19629ab9ed38SChristoph Hellwig 	__le32 boot_seq_num;
1963c4a3e0a5SBagalkote, Sreenivas 
1964c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1965c4a3e0a5SBagalkote, Sreenivas 
1966c4a3e0a5SBagalkote, Sreenivas struct megasas_progress {
1967c4a3e0a5SBagalkote, Sreenivas 
19689ab9ed38SChristoph Hellwig 	__le16 progress;
19699ab9ed38SChristoph Hellwig 	__le16 elapsed_seconds;
1970c4a3e0a5SBagalkote, Sreenivas 
1971c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1972c4a3e0a5SBagalkote, Sreenivas 
1973c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_ld {
1974c4a3e0a5SBagalkote, Sreenivas 
1975c4a3e0a5SBagalkote, Sreenivas 	u16 target_id;
1976c4a3e0a5SBagalkote, Sreenivas 	u8 ld_index;
1977c4a3e0a5SBagalkote, Sreenivas 	u8 reserved;
1978c4a3e0a5SBagalkote, Sreenivas 
1979c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1980c4a3e0a5SBagalkote, Sreenivas 
1981c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_pd {
1982c4a3e0a5SBagalkote, Sreenivas 	u16 device_id;
1983c4a3e0a5SBagalkote, Sreenivas 	u8 encl_index;
1984c4a3e0a5SBagalkote, Sreenivas 	u8 slot_number;
1985c4a3e0a5SBagalkote, Sreenivas 
1986c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1987c4a3e0a5SBagalkote, Sreenivas 
1988c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_detail {
1989c4a3e0a5SBagalkote, Sreenivas 
19909ab9ed38SChristoph Hellwig 	__le32 seq_num;
19919ab9ed38SChristoph Hellwig 	__le32 time_stamp;
19929ab9ed38SChristoph Hellwig 	__le32 code;
1993c4a3e0a5SBagalkote, Sreenivas 	union megasas_evt_class_locale cl;
1994c4a3e0a5SBagalkote, Sreenivas 	u8 arg_type;
1995c4a3e0a5SBagalkote, Sreenivas 	u8 reserved1[15];
1996c4a3e0a5SBagalkote, Sreenivas 
1997c4a3e0a5SBagalkote, Sreenivas 	union {
1998c4a3e0a5SBagalkote, Sreenivas 		struct {
1999c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2000c4a3e0a5SBagalkote, Sreenivas 			u8 cdb_length;
2001c4a3e0a5SBagalkote, Sreenivas 			u8 sense_length;
2002c4a3e0a5SBagalkote, Sreenivas 			u8 reserved[2];
2003c4a3e0a5SBagalkote, Sreenivas 			u8 cdb[16];
2004c4a3e0a5SBagalkote, Sreenivas 			u8 sense[64];
2005c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) cdbSense;
2006c4a3e0a5SBagalkote, Sreenivas 
2007c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_ld ld;
2008c4a3e0a5SBagalkote, Sreenivas 
2009c4a3e0a5SBagalkote, Sreenivas 		struct {
2010c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
20119ab9ed38SChristoph Hellwig 			__le64 count;
2012c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_count;
2013c4a3e0a5SBagalkote, Sreenivas 
2014c4a3e0a5SBagalkote, Sreenivas 		struct {
20159ab9ed38SChristoph Hellwig 			__le64 lba;
2016c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2017c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba;
2018c4a3e0a5SBagalkote, Sreenivas 
2019c4a3e0a5SBagalkote, Sreenivas 		struct {
2020c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
20219ab9ed38SChristoph Hellwig 			__le32 prevOwner;
20229ab9ed38SChristoph Hellwig 			__le32 newOwner;
2023c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_owner;
2024c4a3e0a5SBagalkote, Sreenivas 
2025c4a3e0a5SBagalkote, Sreenivas 		struct {
2026c4a3e0a5SBagalkote, Sreenivas 			u64 ld_lba;
2027c4a3e0a5SBagalkote, Sreenivas 			u64 pd_lba;
2028c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2029c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2030c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba_pd_lba;
2031c4a3e0a5SBagalkote, Sreenivas 
2032c4a3e0a5SBagalkote, Sreenivas 		struct {
2033c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2034c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
2035c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_prog;
2036c4a3e0a5SBagalkote, Sreenivas 
2037c4a3e0a5SBagalkote, Sreenivas 		struct {
2038c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2039c4a3e0a5SBagalkote, Sreenivas 			u32 prev_state;
2040c4a3e0a5SBagalkote, Sreenivas 			u32 new_state;
2041c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_state;
2042c4a3e0a5SBagalkote, Sreenivas 
2043c4a3e0a5SBagalkote, Sreenivas 		struct {
2044c4a3e0a5SBagalkote, Sreenivas 			u64 strip;
2045c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2046c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_strip;
2047c4a3e0a5SBagalkote, Sreenivas 
2048c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_pd pd;
2049c4a3e0a5SBagalkote, Sreenivas 
2050c4a3e0a5SBagalkote, Sreenivas 		struct {
2051c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2052c4a3e0a5SBagalkote, Sreenivas 			u32 err;
2053c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_err;
2054c4a3e0a5SBagalkote, Sreenivas 
2055c4a3e0a5SBagalkote, Sreenivas 		struct {
2056c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
2057c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2058c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba;
2059c4a3e0a5SBagalkote, Sreenivas 
2060c4a3e0a5SBagalkote, Sreenivas 		struct {
2061c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
2062c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2063c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
2064c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba_ld;
2065c4a3e0a5SBagalkote, Sreenivas 
2066c4a3e0a5SBagalkote, Sreenivas 		struct {
2067c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2068c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
2069c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_prog;
2070c4a3e0a5SBagalkote, Sreenivas 
2071c4a3e0a5SBagalkote, Sreenivas 		struct {
2072c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
2073c4a3e0a5SBagalkote, Sreenivas 			u32 prevState;
2074c4a3e0a5SBagalkote, Sreenivas 			u32 newState;
2075c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_state;
2076c4a3e0a5SBagalkote, Sreenivas 
2077c4a3e0a5SBagalkote, Sreenivas 		struct {
2078c4a3e0a5SBagalkote, Sreenivas 			u16 vendorId;
20799ab9ed38SChristoph Hellwig 			__le16 deviceId;
2080c4a3e0a5SBagalkote, Sreenivas 			u16 subVendorId;
2081c4a3e0a5SBagalkote, Sreenivas 			u16 subDeviceId;
2082c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pci;
2083c4a3e0a5SBagalkote, Sreenivas 
2084c4a3e0a5SBagalkote, Sreenivas 		u32 rate;
2085c4a3e0a5SBagalkote, Sreenivas 		char str[96];
2086c4a3e0a5SBagalkote, Sreenivas 
2087c4a3e0a5SBagalkote, Sreenivas 		struct {
2088c4a3e0a5SBagalkote, Sreenivas 			u32 rtc;
2089c4a3e0a5SBagalkote, Sreenivas 			u32 elapsedSeconds;
2090c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) time;
2091c4a3e0a5SBagalkote, Sreenivas 
2092c4a3e0a5SBagalkote, Sreenivas 		struct {
2093c4a3e0a5SBagalkote, Sreenivas 			u32 ecar;
2094c4a3e0a5SBagalkote, Sreenivas 			u32 elog;
2095c4a3e0a5SBagalkote, Sreenivas 			char str[64];
2096c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ecc;
2097c4a3e0a5SBagalkote, Sreenivas 
2098c4a3e0a5SBagalkote, Sreenivas 		u8 b[96];
20999ab9ed38SChristoph Hellwig 		__le16 s[48];
21009ab9ed38SChristoph Hellwig 		__le32 w[24];
21019ab9ed38SChristoph Hellwig 		__le64 d[12];
2102c4a3e0a5SBagalkote, Sreenivas 	} args;
2103c4a3e0a5SBagalkote, Sreenivas 
2104c4a3e0a5SBagalkote, Sreenivas 	char description[128];
2105c4a3e0a5SBagalkote, Sreenivas 
2106c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2107c4a3e0a5SBagalkote, Sreenivas 
21087e8a75f4SYang, Bo struct megasas_aen_event {
2109c1d390d8SXiaotian Feng 	struct delayed_work hotplug_work;
21107e8a75f4SYang, Bo 	struct megasas_instance *instance;
21117e8a75f4SYang, Bo };
21127e8a75f4SYang, Bo 
2113c8e858feSadam radford struct megasas_irq_context {
2114c8e858feSadam radford 	struct megasas_instance *instance;
2115c8e858feSadam radford 	u32 MSIxIndex;
2116c8e858feSadam radford };
2117c8e858feSadam radford 
21185765c5b8SSumit.Saxena@avagotech.com struct MR_DRV_SYSTEM_INFO {
21195765c5b8SSumit.Saxena@avagotech.com 	u8	infoVersion;
21205765c5b8SSumit.Saxena@avagotech.com 	u8	systemIdLength;
21215765c5b8SSumit.Saxena@avagotech.com 	u16	reserved0;
21225765c5b8SSumit.Saxena@avagotech.com 	u8	systemId[64];
21235765c5b8SSumit.Saxena@avagotech.com 	u8	reserved[1980];
21245765c5b8SSumit.Saxena@avagotech.com };
21255765c5b8SSumit.Saxena@avagotech.com 
21262216c305SSumit Saxena enum MR_PD_TYPE {
21272216c305SSumit Saxena 	UNKNOWN_DRIVE = 0,
21282216c305SSumit Saxena 	PARALLEL_SCSI = 1,
21292216c305SSumit Saxena 	SAS_PD = 2,
21302216c305SSumit Saxena 	SATA_PD = 3,
21312216c305SSumit Saxena 	FC_PD = 4,
213215dd0381SShivasharan S 	NVME_PD = 5,
21332216c305SSumit Saxena };
21342216c305SSumit Saxena 
21352216c305SSumit Saxena /* JBOD Queue depth definitions */
21362216c305SSumit Saxena #define MEGASAS_SATA_QD	32
21372216c305SSumit Saxena #define MEGASAS_SAS_QD	64
21382216c305SSumit Saxena #define MEGASAS_DEFAULT_PD_QD	64
213915dd0381SShivasharan S #define MEGASAS_NVME_QD		32
214015dd0381SShivasharan S 
214115dd0381SShivasharan S #define MR_DEFAULT_NVME_PAGE_SIZE	4096
214215dd0381SShivasharan S #define MR_DEFAULT_NVME_PAGE_SHIFT	12
214315dd0381SShivasharan S #define MR_DEFAULT_NVME_MDTS_KB		128
214415dd0381SShivasharan S #define MR_NVME_PAGE_SIZE_MASK		0x000000FF
21452216c305SSumit Saxena 
2146c4a3e0a5SBagalkote, Sreenivas struct megasas_instance {
2147c4a3e0a5SBagalkote, Sreenivas 
2148adbe5523SMing Lei 	unsigned int *reply_map;
21499ab9ed38SChristoph Hellwig 	__le32 *producer;
2150c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t producer_h;
21519ab9ed38SChristoph Hellwig 	__le32 *consumer;
2152c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t consumer_h;
21535765c5b8SSumit.Saxena@avagotech.com 	struct MR_DRV_SYSTEM_INFO *system_info_buf;
21545765c5b8SSumit.Saxena@avagotech.com 	dma_addr_t system_info_h;
2155229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION *vf_affiliation;
2156229fe47cSadam radford 	dma_addr_t vf_affiliation_h;
2157229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION_111 *vf_affiliation_111;
2158229fe47cSadam radford 	dma_addr_t vf_affiliation_111_h;
2159229fe47cSadam radford 	struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
2160229fe47cSadam radford 	dma_addr_t hb_host_mem_h;
21612216c305SSumit Saxena 	struct MR_PD_INFO *pd_info;
21622216c305SSumit Saxena 	dma_addr_t pd_info_h;
216396188a89SShivasharan S 	struct MR_TARGET_PROPERTIES *tgt_prop;
216496188a89SShivasharan S 	dma_addr_t tgt_prop_h;
2165c4a3e0a5SBagalkote, Sreenivas 
21669ab9ed38SChristoph Hellwig 	__le32 *reply_queue;
2167c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t reply_queue_h;
2168c4a3e0a5SBagalkote, Sreenivas 
2169fc62b3fcSSumit.Saxena@avagotech.com 	u32 *crash_dump_buf;
2170fc62b3fcSSumit.Saxena@avagotech.com 	dma_addr_t crash_dump_h;
21719b3d028fSShivasharan S 
21729b3d028fSShivasharan S 	struct MR_PD_LIST *pd_list_buf;
21739b3d028fSShivasharan S 	dma_addr_t pd_list_buf_h;
21749b3d028fSShivasharan S 
21759b3d028fSShivasharan S 	struct megasas_ctrl_info *ctrl_info_buf;
21769b3d028fSShivasharan S 	dma_addr_t ctrl_info_buf_h;
21779b3d028fSShivasharan S 
21789b3d028fSShivasharan S 	struct MR_LD_LIST *ld_list_buf;
21799b3d028fSShivasharan S 	dma_addr_t ld_list_buf_h;
21809b3d028fSShivasharan S 
21819b3d028fSShivasharan S 	struct MR_LD_TARGETID_LIST *ld_targetid_list_buf;
21829b3d028fSShivasharan S 	dma_addr_t ld_targetid_list_buf_h;
21839b3d028fSShivasharan S 
2184fc62b3fcSSumit.Saxena@avagotech.com 	void *crash_buf[MAX_CRASH_DUMP_SIZE];
2185fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_size;
2186fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_state;
2187fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_offset;
2188fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_index;
2189fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_alloc;
2190fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_fw_support;
2191fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_drv_support;
2192fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_app_support;
21937497cde8SSumit.Saxena@avagotech.com 	u32 secure_jbod_support;
2194ede7c3ceSSasikumar Chandrasekaran 	u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
21953761cb4cSsumit.saxena@avagotech.com 	bool use_seqnum_jbod_fp;   /* Added for PD sequence */
2196fc62b3fcSSumit.Saxena@avagotech.com 	spinlock_t crashdump_lock;
2197fc62b3fcSSumit.Saxena@avagotech.com 
2198c4a3e0a5SBagalkote, Sreenivas 	struct megasas_register_set __iomem *reg_set;
21998a232bb3SChristoph Hellwig 	u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
220081e403ceSYang, Bo 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
2201999ece0aSSumit.Saxena@lsi.com 	struct megasas_pd_list          local_pd_list[MEGASAS_MAX_PD];
2202bdc6fb8dSYang, Bo 	u8 ld_ids[MEGASAS_MAX_LD_IDS];
2203c4a3e0a5SBagalkote, Sreenivas 	s8 init_id;
2204c4a3e0a5SBagalkote, Sreenivas 
2205c4a3e0a5SBagalkote, Sreenivas 	u16 max_num_sge;
2206c4a3e0a5SBagalkote, Sreenivas 	u16 max_fw_cmds;
220769c337c0SSasikumar Chandrasekaran 	u16 max_mpt_cmds;
22089c915a8cSadam radford 	u16 max_mfi_cmds;
2209ae09a6c1SSumit.Saxena@avagotech.com 	u16 max_scsi_cmds;
2210308ec459SSumit Saxena 	u16 ldio_threshold;
2211308ec459SSumit Saxena 	u16 cur_can_queue;
2212c4a3e0a5SBagalkote, Sreenivas 	u32 max_sectors_per_req;
22137e8a75f4SYang, Bo 	struct megasas_aen_event *ev;
2214c4a3e0a5SBagalkote, Sreenivas 
2215c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd **cmd_list;
2216c4a3e0a5SBagalkote, Sreenivas 	struct list_head cmd_pool;
221739a98554Sbo yang 	/* used to sync fire the cmd to fw */
221890dc9d98SSumit.Saxena@avagotech.com 	spinlock_t mfi_pool_lock;
221939a98554Sbo yang 	/* used to sync fire the cmd to fw */
222039a98554Sbo yang 	spinlock_t hba_lock;
22217343eb65Sbo yang 	/* used to synch producer, consumer ptrs in dpc */
2222fdd84e25SSasikumar Chandrasekaran 	spinlock_t stream_lock;
22237343eb65Sbo yang 	spinlock_t completion_lock;
2224c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *frame_dma_pool;
2225c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *sense_dma_pool;
2226c4a3e0a5SBagalkote, Sreenivas 
2227c4a3e0a5SBagalkote, Sreenivas 	struct megasas_evt_detail *evt_detail;
2228c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t evt_detail_h;
2229c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd *aen_cmd;
2230c4a3e0a5SBagalkote, Sreenivas 	struct semaphore ioctl_sem;
2231c4a3e0a5SBagalkote, Sreenivas 
2232c4a3e0a5SBagalkote, Sreenivas 	struct Scsi_Host *host;
2233c4a3e0a5SBagalkote, Sreenivas 
2234c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t int_cmd_wait_q;
2235c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t abort_cmd_wait_q;
2236c4a3e0a5SBagalkote, Sreenivas 
2237c4a3e0a5SBagalkote, Sreenivas 	struct pci_dev *pdev;
2238c4a3e0a5SBagalkote, Sreenivas 	u32 unique_id;
223939a98554Sbo yang 	u32 fw_support_ieee;
2240c4a3e0a5SBagalkote, Sreenivas 
2241e4a082c7SSumant Patro 	atomic_t fw_outstanding;
2242308ec459SSumit Saxena 	atomic_t ldio_outstanding;
224339a98554Sbo yang 	atomic_t fw_reset_no_pci_access;
224433203bc4SShivasharan S 	atomic_t ieee_sgl;
224533203bc4SShivasharan S 	atomic_t prp_sgl;
224633203bc4SShivasharan S 	atomic_t sge_holes_type1;
224733203bc4SShivasharan S 	atomic_t sge_holes_type2;
224833203bc4SShivasharan S 	atomic_t sge_holes_type3;
22491341c939SSumant Patro 
22501341c939SSumant Patro 	struct megasas_instance_template *instancet;
22515d018ad0SSumant Patro 	struct tasklet_struct isr_tasklet;
225239a98554Sbo yang 	struct work_struct work_init;
2253fc62b3fcSSumit.Saxena@avagotech.com 	struct work_struct crash_init;
225405e9ebbeSSumant Patro 
225505e9ebbeSSumant Patro 	u8 flag;
2256c3518837SYang, Bo 	u8 unload;
2257f4c9a131SYang, Bo 	u8 flag_ieee;
225839a98554Sbo yang 	u8 issuepend_done;
225939a98554Sbo yang 	u8 disableOnlineCtrlReset;
2260bc93d425SSumit.Saxena@lsi.com 	u8 UnevenSpanSupport;
226151087a86SSumit.Saxena@avagotech.com 
226251087a86SSumit.Saxena@avagotech.com 	u8 supportmax256vd;
226330845586SSumit Saxena 	u8 pd_list_not_supported;
226451087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_vd_count;
226551087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_pd_count;
226651087a86SSumit.Saxena@avagotech.com 
226751087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_vd_count;
226851087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_pd_count;
226951087a86SSumit.Saxena@avagotech.com 
22708a01a41dSSumit Saxena 	atomic_t adprecovery;
227105e9ebbeSSumant Patro 	unsigned long last_time;
227239a98554Sbo yang 	u32 mfiStatus;
227339a98554Sbo yang 	u32 last_seq_num;
2274ad84db2eSbo yang 
227539a98554Sbo yang 	struct list_head internal_reset_pending_q;
227680d9da98Sadam radford 
227725985edcSLucas De Marchi 	/* Ptr to hba specific information */
22789c915a8cSadam radford 	void *ctrl_context;
2279c8e858feSadam radford 	unsigned int msix_vectors;
2280c8e858feSadam radford 	struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
22819c915a8cSadam radford 	u64 map_id;
22823761cb4cSsumit.saxena@avagotech.com 	u64 pd_seq_map_id;
22839c915a8cSadam radford 	struct megasas_cmd *map_update_cmd;
22843761cb4cSsumit.saxena@avagotech.com 	struct megasas_cmd *jbod_seq_cmd;
2285b6d5d880Sadam radford 	unsigned long bar;
22869c915a8cSadam radford 	long reset_flags;
22879c915a8cSadam radford 	struct mutex reset_mutex;
2288229fe47cSadam radford 	struct timer_list sriov_heartbeat_timer;
2289229fe47cSadam radford 	char skip_heartbeat_timer_del;
2290229fe47cSadam radford 	u8 requestorId;
2291229fe47cSadam radford 	char PlasmaFW111;
22928f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE];
22938f67c8c5SSumit Saxena 	u8 peerIsPresent;
22948f67c8c5SSumit Saxena 	u8 passive;
2295ae09a6c1SSumit.Saxena@avagotech.com 	u16 throttlequeuedepth;
2296d46a3ad6SSumit.Saxena@lsi.com 	u8 mask_interrupts;
2297bd5f9484Ssumit.saxena@avagotech.com 	u16 max_chain_frame_sz;
2298404a8a1aSSumit.Saxena@lsi.com 	u8 is_imr;
2299179ac142SSumit Saxena 	u8 is_rdpq;
23005765c5b8SSumit.Saxena@avagotech.com 	bool dev_handle;
2301d0fc91d6SKashyap Desai 	bool fw_sync_cache_support;
230221c34006SShivasharan S 	u32 mfi_frame_size;
23032493c67eSSasikumar Chandrasekaran 	bool msix_combined;
2304d889344eSSasikumar Chandrasekaran 	u16 max_raid_mapsize;
2305a48ba0ecSShivasharan S 	/* preffered count to send as LDIO irrspective of FP capable.*/
2306a48ba0ecSShivasharan S 	u8  r1_ldio_hint_default;
230715dd0381SShivasharan S 	u32 nvme_page_size;
2308c365178fSShivasharan S 	u8 adapter_type;
2309107a60ddSShivasharan S 	bool consistent_mask_64bit;
2310f870bcbeSShivasharan S 	bool support_nvme_passthru;
2311e9495e2dSShivasharan S 	u8 task_abort_tmo;
2312e9495e2dSShivasharan S 	u8 max_reset_tmo;
231339a98554Sbo yang };
2314229fe47cSadam radford struct MR_LD_VF_MAP {
2315229fe47cSadam radford 	u32 size;
2316229fe47cSadam radford 	union MR_LD_REF ref;
2317229fe47cSadam radford 	u8 ldVfCount;
2318229fe47cSadam radford 	u8 reserved[6];
2319229fe47cSadam radford 	u8 policy[1];
2320229fe47cSadam radford };
2321229fe47cSadam radford 
2322229fe47cSadam radford struct MR_LD_VF_AFFILIATION {
2323229fe47cSadam radford 	u32 size;
2324229fe47cSadam radford 	u8 ldCount;
2325229fe47cSadam radford 	u8 vfCount;
2326229fe47cSadam radford 	u8 thisVf;
2327229fe47cSadam radford 	u8 reserved[9];
2328229fe47cSadam radford 	struct MR_LD_VF_MAP map[1];
2329229fe47cSadam radford };
2330229fe47cSadam radford 
2331229fe47cSadam radford /* Plasma 1.11 FW backward compatibility structures */
2332229fe47cSadam radford #define IOV_111_OFFSET 0x7CE
2333229fe47cSadam radford #define MAX_VIRTUAL_FUNCTIONS 8
23344cbfea88SAdam Radford #define MR_LD_ACCESS_HIDDEN 15
2335229fe47cSadam radford 
2336229fe47cSadam radford struct IOV_111 {
2337229fe47cSadam radford 	u8 maxVFsSupported;
2338229fe47cSadam radford 	u8 numVFsEnabled;
2339229fe47cSadam radford 	u8 requestorId;
2340229fe47cSadam radford 	u8 reserved[5];
2341229fe47cSadam radford };
2342229fe47cSadam radford 
2343229fe47cSadam radford struct MR_LD_VF_MAP_111 {
2344229fe47cSadam radford 	u8 targetId;
2345229fe47cSadam radford 	u8 reserved[3];
2346229fe47cSadam radford 	u8 policy[MAX_VIRTUAL_FUNCTIONS];
2347229fe47cSadam radford };
2348229fe47cSadam radford 
2349229fe47cSadam radford struct MR_LD_VF_AFFILIATION_111 {
2350229fe47cSadam radford 	u8 vdCount;
2351229fe47cSadam radford 	u8 vfCount;
2352229fe47cSadam radford 	u8 thisVf;
2353229fe47cSadam radford 	u8 reserved[5];
2354229fe47cSadam radford 	struct MR_LD_VF_MAP_111 map[MAX_LOGICAL_DRIVES];
2355229fe47cSadam radford };
2356229fe47cSadam radford 
2357229fe47cSadam radford struct MR_CTRL_HB_HOST_MEM {
2358229fe47cSadam radford 	struct {
2359229fe47cSadam radford 		u32 fwCounter;	/* Firmware heart beat counter */
2360229fe47cSadam radford 		struct {
2361229fe47cSadam radford 			u32 debugmode:1; /* 1=Firmware is in debug mode.
2362229fe47cSadam radford 					    Heart beat will not be updated. */
2363229fe47cSadam radford 			u32 reserved:31;
2364229fe47cSadam radford 		} debug;
2365229fe47cSadam radford 		u32 reserved_fw[6];
2366229fe47cSadam radford 		u32 driverCounter; /* Driver heart beat counter.  0x20 */
2367229fe47cSadam radford 		u32 reserved_driver[7];
2368229fe47cSadam radford 	} HB;
2369229fe47cSadam radford 	u8 pad[0x400-0x40];
2370229fe47cSadam radford };
237139a98554Sbo yang 
237239a98554Sbo yang enum {
237339a98554Sbo yang 	MEGASAS_HBA_OPERATIONAL			= 0,
237439a98554Sbo yang 	MEGASAS_ADPRESET_SM_INFAULT		= 1,
237539a98554Sbo yang 	MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS	= 2,
237639a98554Sbo yang 	MEGASAS_ADPRESET_SM_OPERATIONAL		= 3,
237739a98554Sbo yang 	MEGASAS_HW_CRITICAL_ERROR		= 4,
2378229fe47cSadam radford 	MEGASAS_ADPRESET_SM_POLLING		= 5,
237939a98554Sbo yang 	MEGASAS_ADPRESET_INPROG_SIGN		= 0xDEADDEAD,
2380c4a3e0a5SBagalkote, Sreenivas };
2381c4a3e0a5SBagalkote, Sreenivas 
23820c79e681SYang, Bo struct megasas_instance_template {
23830c79e681SYang, Bo 	void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
23840c79e681SYang, Bo 		u32, struct megasas_register_set __iomem *);
23850c79e681SYang, Bo 
2386d46a3ad6SSumit.Saxena@lsi.com 	void (*enable_intr)(struct megasas_instance *);
2387d46a3ad6SSumit.Saxena@lsi.com 	void (*disable_intr)(struct megasas_instance *);
23880c79e681SYang, Bo 
23890c79e681SYang, Bo 	int (*clear_intr)(struct megasas_register_set __iomem *);
23900c79e681SYang, Bo 
23910c79e681SYang, Bo 	u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
239239a98554Sbo yang 	int (*adp_reset)(struct megasas_instance *, \
239339a98554Sbo yang 		struct megasas_register_set __iomem *);
239439a98554Sbo yang 	int (*check_reset)(struct megasas_instance *, \
239539a98554Sbo yang 		struct megasas_register_set __iomem *);
2396cd50ba8eSadam radford 	irqreturn_t (*service_isr)(int irq, void *devp);
2397cd50ba8eSadam radford 	void (*tasklet)(unsigned long);
2398cd50ba8eSadam radford 	u32 (*init_adapter)(struct megasas_instance *);
2399cd50ba8eSadam radford 	u32 (*build_and_issue_cmd) (struct megasas_instance *,
2400cd50ba8eSadam radford 				    struct scsi_cmnd *);
2401f4fc2093SShivasharan S 	void (*issue_dcmd)(struct megasas_instance *instance,
2402cd50ba8eSadam radford 			    struct megasas_cmd *cmd);
24030c79e681SYang, Bo };
24040c79e681SYang, Bo 
24053cabd162SShivasharan S #define MEGASAS_IS_LOGICAL(sdev)					\
24063cabd162SShivasharan S 	((sdev->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
2407c4a3e0a5SBagalkote, Sreenivas 
24084a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_DEV_INDEX(scp)						\
24094a5c814dSSumit.Saxena@avagotech.com 	(((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) +	\
24104a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
24114a5c814dSSumit.Saxena@avagotech.com 
24124a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_PD_INDEX(scp)						\
24134a5c814dSSumit.Saxena@avagotech.com 	((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +		\
24144a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
2415c4a3e0a5SBagalkote, Sreenivas 
2416c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd {
2417c4a3e0a5SBagalkote, Sreenivas 
2418c4a3e0a5SBagalkote, Sreenivas 	union megasas_frame *frame;
2419c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t frame_phys_addr;
2420c4a3e0a5SBagalkote, Sreenivas 	u8 *sense;
2421c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t sense_phys_addr;
2422c4a3e0a5SBagalkote, Sreenivas 
2423c4a3e0a5SBagalkote, Sreenivas 	u32 index;
2424c4a3e0a5SBagalkote, Sreenivas 	u8 sync_cmd;
24252be2a988SSumit.Saxena@avagotech.com 	u8 cmd_status_drv;
242639a98554Sbo yang 	u8 abort_aen;
242739a98554Sbo yang 	u8 retry_for_fw_reset;
242839a98554Sbo yang 
2429c4a3e0a5SBagalkote, Sreenivas 
2430c4a3e0a5SBagalkote, Sreenivas 	struct list_head list;
2431c4a3e0a5SBagalkote, Sreenivas 	struct scsi_cmnd *scmd;
24324026e9aaSSumit.Saxena@avagotech.com 	u8 flags;
243390dc9d98SSumit.Saxena@avagotech.com 
2434c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance;
24359c915a8cSadam radford 	union {
24369c915a8cSadam radford 		struct {
24379c915a8cSadam radford 			u16 smid;
24389c915a8cSadam radford 			u16 resvd;
24399c915a8cSadam radford 		} context;
2440c4a3e0a5SBagalkote, Sreenivas 		u32 frame_count;
2441c4a3e0a5SBagalkote, Sreenivas 	};
24429c915a8cSadam radford };
2443c4a3e0a5SBagalkote, Sreenivas 
2444c4a3e0a5SBagalkote, Sreenivas #define MAX_MGMT_ADAPTERS		1024
2445c4a3e0a5SBagalkote, Sreenivas #define MAX_IOCTL_SGE			16
2446c4a3e0a5SBagalkote, Sreenivas 
2447c4a3e0a5SBagalkote, Sreenivas struct megasas_iocpacket {
2448c4a3e0a5SBagalkote, Sreenivas 
2449c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2450c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2451c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2452c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2453c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2454c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2455c4a3e0a5SBagalkote, Sreenivas 	union {
2456c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2457c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2458c4a3e0a5SBagalkote, Sreenivas 	} frame;
2459c4a3e0a5SBagalkote, Sreenivas 
2460c4a3e0a5SBagalkote, Sreenivas 	struct iovec sgl[MAX_IOCTL_SGE];
2461c4a3e0a5SBagalkote, Sreenivas 
2462c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2463c4a3e0a5SBagalkote, Sreenivas 
2464c4a3e0a5SBagalkote, Sreenivas struct megasas_aen {
2465c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2466c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2467c4a3e0a5SBagalkote, Sreenivas 	u32 seq_num;
2468c4a3e0a5SBagalkote, Sreenivas 	u32 class_locale_word;
2469c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2470c4a3e0a5SBagalkote, Sreenivas 
2471c4a3e0a5SBagalkote, Sreenivas #ifdef CONFIG_COMPAT
2472c4a3e0a5SBagalkote, Sreenivas struct compat_megasas_iocpacket {
2473c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2474c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2475c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2476c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2477c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2478c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2479c4a3e0a5SBagalkote, Sreenivas 	union {
2480c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2481c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2482c4a3e0a5SBagalkote, Sreenivas 	} frame;
2483c4a3e0a5SBagalkote, Sreenivas 	struct compat_iovec sgl[MAX_IOCTL_SGE];
2484c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2485c4a3e0a5SBagalkote, Sreenivas 
24860e98936cSSumant Patro #define MEGASAS_IOC_FIRMWARE32	_IOWR('M', 1, struct compat_megasas_iocpacket)
2487c4a3e0a5SBagalkote, Sreenivas #endif
2488c4a3e0a5SBagalkote, Sreenivas 
2489cb59aa6aSSumant Patro #define MEGASAS_IOC_FIRMWARE	_IOWR('M', 1, struct megasas_iocpacket)
2490c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOC_GET_AEN	_IOW('M', 3, struct megasas_aen)
2491c4a3e0a5SBagalkote, Sreenivas 
2492c4a3e0a5SBagalkote, Sreenivas struct megasas_mgmt_info {
2493c4a3e0a5SBagalkote, Sreenivas 
2494c4a3e0a5SBagalkote, Sreenivas 	u16 count;
2495c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
2496c4a3e0a5SBagalkote, Sreenivas 	int max_index;
2497c4a3e0a5SBagalkote, Sreenivas };
2498c4a3e0a5SBagalkote, Sreenivas 
24996d40afbcSSumit Saxena enum MEGASAS_OCR_CAUSE {
25006d40afbcSSumit Saxena 	FW_FAULT_OCR			= 0,
25016d40afbcSSumit Saxena 	SCSIIO_TIMEOUT_OCR		= 1,
25026d40afbcSSumit Saxena 	MFI_IO_TIMEOUT_OCR		= 2,
25036d40afbcSSumit Saxena };
25046d40afbcSSumit Saxena 
25056d40afbcSSumit Saxena enum DCMD_RETURN_STATUS {
25066d40afbcSSumit Saxena 	DCMD_SUCCESS		= 0,
25076d40afbcSSumit Saxena 	DCMD_TIMEOUT		= 1,
25086d40afbcSSumit Saxena 	DCMD_FAILED		= 2,
25096d40afbcSSumit Saxena 	DCMD_NOT_FIRED		= 3,
25106d40afbcSSumit Saxena };
25116d40afbcSSumit Saxena 
251221c9e160Sadam radford u8
251321c9e160Sadam radford MR_BuildRaidContext(struct megasas_instance *instance,
251421c9e160Sadam radford 		    struct IO_REQUEST_INFO *io_info,
251521c9e160Sadam radford 		    struct RAID_CONTEXT *pRAID_Context,
251651087a86SSumit.Saxena@avagotech.com 		    struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN);
2517d2d0358bSShivasharan S u16 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
251851087a86SSumit.Saxena@avagotech.com struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
251951087a86SSumit.Saxena@avagotech.com u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
252051087a86SSumit.Saxena@avagotech.com u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
25219ab9ed38SChristoph Hellwig __le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
252251087a86SSumit.Saxena@avagotech.com u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
252321c9e160Sadam radford 
25249ab9ed38SChristoph Hellwig __le16 get_updated_dev_handle(struct megasas_instance *instance,
252533203bc4SShivasharan S 			      struct LD_LOAD_BALANCE_INFO *lbInfo,
252633203bc4SShivasharan S 			      struct IO_REQUEST_INFO *in_info,
252733203bc4SShivasharan S 			      struct MR_DRV_RAID_MAP_ALL *drv_map);
252851087a86SSumit.Saxena@avagotech.com void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
252951087a86SSumit.Saxena@avagotech.com 	struct LD_LOAD_BALANCE_INFO *lbInfo);
2530d009b576SSumit.Saxena@avagotech.com int megasas_get_ctrl_info(struct megasas_instance *instance);
25313761cb4cSsumit.saxena@avagotech.com /* PD sequence */
25323761cb4cSsumit.saxena@avagotech.com int
25333761cb4cSsumit.saxena@avagotech.com megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
2534e9495e2dSShivasharan S void megasas_set_dynamic_target_properties(struct scsi_device *sdev,
2535e9495e2dSShivasharan S 					   bool is_target_prop);
2536e9495e2dSShivasharan S int megasas_get_target_prop(struct megasas_instance *instance,
2537e9495e2dSShivasharan S 			    struct scsi_device *sdev);
2538e9495e2dSShivasharan S 
2539fc62b3fcSSumit.Saxena@avagotech.com int megasas_set_crash_dump_params(struct megasas_instance *instance,
2540fc62b3fcSSumit.Saxena@avagotech.com 	u8 crash_buf_state);
2541fc62b3fcSSumit.Saxena@avagotech.com void megasas_free_host_crash_buffer(struct megasas_instance *instance);
2542fc62b3fcSSumit.Saxena@avagotech.com void megasas_fusion_crash_dump_wq(struct work_struct *work);
254351087a86SSumit.Saxena@avagotech.com 
254490dc9d98SSumit.Saxena@avagotech.com void megasas_return_cmd_fusion(struct megasas_instance *instance,
254590dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd_fusion *cmd);
254690dc9d98SSumit.Saxena@avagotech.com int megasas_issue_blocked_cmd(struct megasas_instance *instance,
254790dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd, int timeout);
254890dc9d98SSumit.Saxena@avagotech.com void __megasas_return_cmd(struct megasas_instance *instance,
254990dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd);
255090dc9d98SSumit.Saxena@avagotech.com 
255190dc9d98SSumit.Saxena@avagotech.com void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
255290dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
25537497cde8SSumit.Saxena@avagotech.com int megasas_cmd_type(struct scsi_cmnd *cmd);
25543761cb4cSsumit.saxena@avagotech.com void megasas_setup_jbod_map(struct megasas_instance *instance);
255590dc9d98SSumit.Saxena@avagotech.com 
255618365b13SSumit Saxena void megasas_update_sdev_properties(struct scsi_device *sdev);
255718365b13SSumit Saxena int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
255818365b13SSumit Saxena int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
255918365b13SSumit Saxena int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
256033203bc4SShivasharan S u32 mega_mod64(u64 dividend, u32 divisor);
25615fc499b6SShivasharan S int megasas_alloc_fusion_context(struct megasas_instance *instance);
25625fc499b6SShivasharan S void megasas_free_fusion_context(struct megasas_instance *instance);
2563107a60ddSShivasharan S void megasas_set_dma_settings(struct megasas_instance *instance,
2564107a60ddSShivasharan S 			      struct megasas_dcmd_frame *dcmd,
2565107a60ddSShivasharan S 			      dma_addr_t dma_addr, u32 dma_len);
2566c4a3e0a5SBagalkote, Sreenivas #endif				/*LSI_MEGARAID_SAS_H */
2567