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  */
38fd3e165aSKashyap Desai #define MEGASAS_VERSION				"06.812.07.00-rc1"
39fd3e165aSKashyap Desai #define MEGASAS_RELDATE				"August 22, 2016"
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
6045f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_HARPOON		    0x0016
6145f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_TOMCAT		    0x0017
6245f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_VENTURA_4PORT		0x001B
6345f4f2ebSSasikumar Chandrasekaran #define PCI_DEVICE_ID_LSI_CRUSADER_4PORT	0x001C
640e98936cSSumant Patro 
65c4a3e0a5SBagalkote, Sreenivas /*
6639b72c3cSSumit.Saxena@lsi.com  * Intel HBA SSDIDs
6739b72c3cSSumit.Saxena@lsi.com  */
6839b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_SSDID		0x9360
6939b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_SSDID		0x9362
7039b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_SSDID		0x9380
7139b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_SSDID		0x9381
7239b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_SSDID		0x9341
7339b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_SSDID		0x9343
747364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_SSDID		0x352B
7539b72c3cSSumit.Saxena@lsi.com 
7639b72c3cSSumit.Saxena@lsi.com /*
7790c204bcSsumit.saxena@avagotech.com  * Intruder HBA SSDIDs
7890c204bcSsumit.saxena@avagotech.com  */
7990c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID1		0x9371
8090c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID2		0x9390
8190c204bcSsumit.saxena@avagotech.com #define MEGARAID_INTRUDER_SSDID3		0x9370
8290c204bcSsumit.saxena@avagotech.com 
8390c204bcSsumit.saxena@avagotech.com /*
8439b72c3cSSumit.Saxena@lsi.com  * Intel HBA branding
8539b72c3cSSumit.Saxena@lsi.com  */
8639b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC080_BRANDING	\
8739b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC080"
8839b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3DC040_BRANDING	\
8939b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3DC040"
9039b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3SC008_BRANDING	\
9139b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3SC008"
9239b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3MC044_BRANDING	\
9339b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3MC044"
9439b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC080_BRANDING	\
9539b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC080"
9639b72c3cSSumit.Saxena@lsi.com #define MEGARAID_INTEL_RS3WC040_BRANDING	\
9739b72c3cSSumit.Saxena@lsi.com 	"Intel(R) RAID Controller RS3WC040"
987364d34bSsumit.saxena@avagotech.com #define MEGARAID_INTEL_RMS3BC160_BRANDING	\
997364d34bSsumit.saxena@avagotech.com 	"Intel(R) Integrated RAID Module RMS3BC160"
10039b72c3cSSumit.Saxena@lsi.com 
10139b72c3cSSumit.Saxena@lsi.com /*
102c4a3e0a5SBagalkote, Sreenivas  * =====================================
103c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS MFI firmware definitions
104c4a3e0a5SBagalkote, Sreenivas  * =====================================
105c4a3e0a5SBagalkote, Sreenivas  */
106c4a3e0a5SBagalkote, Sreenivas 
107c4a3e0a5SBagalkote, Sreenivas /*
108c4a3e0a5SBagalkote, Sreenivas  * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for
109c4a3e0a5SBagalkote, Sreenivas  * protocol between the software and firmware. Commands are issued using
110c4a3e0a5SBagalkote, Sreenivas  * "message frames"
111c4a3e0a5SBagalkote, Sreenivas  */
112c4a3e0a5SBagalkote, Sreenivas 
113a69b74d3SRandy Dunlap /*
114c4a3e0a5SBagalkote, Sreenivas  * FW posts its state in upper 4 bits of outbound_msg_0 register
115c4a3e0a5SBagalkote, Sreenivas  */
116c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_MASK				0xF0000000
117c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_UNDEFINED			0x00000000
118c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_BB_INIT			0x10000000
119c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT			0x40000000
120c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_WAIT_HANDSHAKE		0x60000000
121c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FW_INIT_2			0x70000000
122c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_DEVICE_SCAN			0x80000000
123e3bbff9fSSumant Patro #define MFI_STATE_BOOT_MESSAGE_PENDING		0x90000000
124c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FLUSH_CACHE			0xA0000000
125c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_READY				0xB0000000
126c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_OPERATIONAL			0xC0000000
127c4a3e0a5SBagalkote, Sreenivas #define MFI_STATE_FAULT				0xF0000000
128fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_FORCE_OCR			0x00000080
129fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_DMADONE			0x00000008
130fc62b3fcSSumit.Saxena@avagotech.com #define MFI_STATE_CRASH_DUMP_DONE		0x00000004
13139a98554Sbo yang #define MFI_RESET_REQUIRED			0x00000001
1327e70e733Sadam radford #define MFI_RESET_ADAPTER			0x00000002
133c4a3e0a5SBagalkote, Sreenivas #define MEGAMFI_FRAME_SIZE			64
134c4a3e0a5SBagalkote, Sreenivas 
135a69b74d3SRandy Dunlap /*
136c4a3e0a5SBagalkote, Sreenivas  * During FW init, clear pending cmds & reset state using inbound_msg_0
137c4a3e0a5SBagalkote, Sreenivas  *
138c4a3e0a5SBagalkote, Sreenivas  * ABORT	: Abort all pending cmds
139c4a3e0a5SBagalkote, Sreenivas  * READY	: Move from OPERATIONAL to READY state; discard queue info
140c4a3e0a5SBagalkote, Sreenivas  * MFIMODE	: Discard (possible) low MFA posted in 64-bit mode (??)
141c4a3e0a5SBagalkote, Sreenivas  * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
142e3bbff9fSSumant Patro  * HOTPLUG	: Resume from Hotplug
143e3bbff9fSSumant Patro  * MFI_STOP_ADP	: Send signal to FW to stop processing
144c4a3e0a5SBagalkote, Sreenivas  */
14539a98554Sbo yang #define WRITE_SEQUENCE_OFFSET		(0x0000000FC) /* I20 */
14639a98554Sbo yang #define HOST_DIAGNOSTIC_OFFSET		(0x000000F8)  /* I20 */
14739a98554Sbo yang #define DIAG_WRITE_ENABLE			(0x00000080)
14839a98554Sbo yang #define DIAG_RESET_ADAPTER			(0x00000004)
14939a98554Sbo yang 
15039a98554Sbo yang #define MFI_ADP_RESET				0x00000040
151e3bbff9fSSumant Patro #define MFI_INIT_ABORT				0x00000001
152c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_READY				0x00000002
153c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_MFIMODE			0x00000004
154c4a3e0a5SBagalkote, Sreenivas #define MFI_INIT_CLEAR_HANDSHAKE		0x00000008
155e3bbff9fSSumant Patro #define MFI_INIT_HOTPLUG			0x00000010
156e3bbff9fSSumant Patro #define MFI_STOP_ADP				0x00000020
157e3bbff9fSSumant Patro #define MFI_RESET_FLAGS				MFI_INIT_READY| \
158e3bbff9fSSumant Patro 						MFI_INIT_MFIMODE| \
159e3bbff9fSSumant Patro 						MFI_INIT_ABORT
160179ac142SSumit Saxena #define MPI2_IOCINIT_MSGFLAG_RDPQ_ARRAY_MODE    (0x01)
161c4a3e0a5SBagalkote, Sreenivas 
162a69b74d3SRandy Dunlap /*
163c4a3e0a5SBagalkote, Sreenivas  * MFI frame flags
164c4a3e0a5SBagalkote, Sreenivas  */
165c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_POST_IN_REPLY_QUEUE		0x0000
166c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE	0x0001
167c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL32				0x0000
168c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SGL64				0x0002
169c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE32			0x0000
170c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_SENSE64			0x0004
171c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_NONE			0x0000
172c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_WRITE			0x0008
173c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_READ			0x0010
174c4a3e0a5SBagalkote, Sreenivas #define MFI_FRAME_DIR_BOTH			0x0018
175f4c9a131SYang, Bo #define MFI_FRAME_IEEE                          0x0020
176c4a3e0a5SBagalkote, Sreenivas 
1774026e9aaSSumit.Saxena@avagotech.com /* Driver internal */
1784026e9aaSSumit.Saxena@avagotech.com #define DRV_DCMD_POLLED_MODE		0x1
1796d40afbcSSumit Saxena #define DRV_DCMD_SKIP_REFIRE		0x2
1804026e9aaSSumit.Saxena@avagotech.com 
181a69b74d3SRandy Dunlap /*
182c4a3e0a5SBagalkote, Sreenivas  * Definition for cmd_status
183c4a3e0a5SBagalkote, Sreenivas  */
184c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_STATUS_POLL_MODE		0xFF
185c4a3e0a5SBagalkote, Sreenivas 
186a69b74d3SRandy Dunlap /*
187c4a3e0a5SBagalkote, Sreenivas  * MFI command opcodes
188c4a3e0a5SBagalkote, Sreenivas  */
189c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_INIT				0x00
190c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_LD_READ				0x01
191c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_LD_WRITE			0x02
192c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_LD_SCSI_IO			0x03
193c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_PD_SCSI_IO			0x04
194c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_DCMD				0x05
195c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_ABORT				0x06
196c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_SMP				0x07
197c4a3e0a5SBagalkote, Sreenivas #define MFI_CMD_STP				0x08
198e5f93a36Sadam radford #define MFI_CMD_INVALID				0xff
199c4a3e0a5SBagalkote, Sreenivas 
200c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_GET_INFO			0x01010000
201bdc6fb8dSYang, Bo #define MR_DCMD_LD_GET_LIST			0x03010000
20221c9e160Sadam radford #define MR_DCMD_LD_LIST_QUERY			0x03010100
203c4a3e0a5SBagalkote, Sreenivas 
204c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_CACHE_FLUSH		0x01101000
205c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_CTRL_CACHE			0x01
206c4a3e0a5SBagalkote, Sreenivas #define MR_FLUSH_DISK_CACHE			0x02
207c4a3e0a5SBagalkote, Sreenivas 
208c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_SHUTDOWN			0x01050000
20931ea7088Sbo yang #define MR_DCMD_HIBERNATE_SHUTDOWN		0x01060000
210c4a3e0a5SBagalkote, Sreenivas #define MR_ENABLE_DRIVE_SPINDOWN		0x01
211c4a3e0a5SBagalkote, Sreenivas 
212c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET_INFO		0x01040100
213c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_GET			0x01040300
214c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CTRL_EVENT_WAIT			0x01040500
215c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_LD_GET_PROPERTIES		0x03030000
216c4a3e0a5SBagalkote, Sreenivas 
217c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER				0x08000000
218c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_ALL		0x08010100
219c4a3e0a5SBagalkote, Sreenivas #define MR_DCMD_CLUSTER_RESET_LD		0x08010200
22081e403ceSYang, Bo #define MR_DCMD_PD_LIST_QUERY                   0x02010100
221c4a3e0a5SBagalkote, Sreenivas 
222fc62b3fcSSumit.Saxena@avagotech.com #define MR_DCMD_CTRL_SET_CRASH_DUMP_PARAMS	0x01190100
223fc62b3fcSSumit.Saxena@avagotech.com #define MR_DRIVER_SET_APP_CRASHDUMP_MODE	(0xF0010000 | 0x0600)
2242216c305SSumit Saxena #define MR_DCMD_PD_GET_INFO			0x02020000
225fc62b3fcSSumit.Saxena@avagotech.com 
226a69b74d3SRandy Dunlap /*
227bc93d425SSumit.Saxena@lsi.com  * Global functions
228bc93d425SSumit.Saxena@lsi.com  */
229bc93d425SSumit.Saxena@lsi.com extern u8 MR_ValidateMapInfo(struct megasas_instance *instance);
230bc93d425SSumit.Saxena@lsi.com 
231bc93d425SSumit.Saxena@lsi.com 
232bc93d425SSumit.Saxena@lsi.com /*
233c4a3e0a5SBagalkote, Sreenivas  * MFI command completion codes
234c4a3e0a5SBagalkote, Sreenivas  */
235c4a3e0a5SBagalkote, Sreenivas enum MFI_STAT {
236c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_OK = 0x00,
237c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_CMD = 0x01,
238c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_DCMD = 0x02,
239c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_PARAMETER = 0x03,
240c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
241c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
242c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
243c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_IN_USE = 0x07,
244c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_APP_NOT_INITIALIZED = 0x08,
245c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
246c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
247c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
248c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
249c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
250c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
251c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_BUSY = 0x0f,
252c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_ERROR = 0x10,
253c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_BAD = 0x11,
254c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
255c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_OPEN = 0x13,
256c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLASH_NOT_STARTED = 0x14,
257c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_FLUSH_FAILED = 0x15,
258c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
259c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
260c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
261c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
262c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
263c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
264c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
265c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
266c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
267c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
268c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
269c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_MFC_HW_ERROR = 0x21,
270c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NO_HW_PRESENT = 0x22,
271c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_FOUND = 0x23,
272c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_NOT_IN_ENCL = 0x24,
273c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
274c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PD_TYPE_WRONG = 0x26,
275c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PR_DISABLED = 0x27,
276c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_ROW_INDEX_INVALID = 0x28,
277c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
278c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
279c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
280c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
281c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
282c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_IO_FAILED = 0x2e,
283c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
284c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_SHUTDOWN_FAILED = 0x30,
285c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_TIME_NOT_SET = 0x31,
286c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_WRONG_STATE = 0x32,
287c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_LD_OFFLINE = 0x33,
288c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
289c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
290c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
291c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
292c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
29336807e67Sadam radford 	MFI_STAT_CONFIG_SEQ_MISMATCH = 0x67,
294c4a3e0a5SBagalkote, Sreenivas 
295c4a3e0a5SBagalkote, Sreenivas 	MFI_STAT_INVALID_STATUS = 0xFF
296c4a3e0a5SBagalkote, Sreenivas };
297c4a3e0a5SBagalkote, Sreenivas 
298714f5177Ssumit.saxena@avagotech.com enum mfi_evt_class {
299714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEBUG =		-2,
300714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_PROGRESS =	-1,
301714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_INFO =		0,
302714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_WARNING =		1,
303714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_CRITICAL =	2,
304714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_FATAL =		3,
305714f5177Ssumit.saxena@avagotech.com 	MFI_EVT_CLASS_DEAD =		4
306714f5177Ssumit.saxena@avagotech.com };
307714f5177Ssumit.saxena@avagotech.com 
308c4a3e0a5SBagalkote, Sreenivas /*
309fc62b3fcSSumit.Saxena@avagotech.com  * Crash dump related defines
310fc62b3fcSSumit.Saxena@avagotech.com  */
311fc62b3fcSSumit.Saxena@avagotech.com #define MAX_CRASH_DUMP_SIZE 512
312fc62b3fcSSumit.Saxena@avagotech.com #define CRASH_DMA_BUF_SIZE  (1024 * 1024)
313fc62b3fcSSumit.Saxena@avagotech.com 
314fc62b3fcSSumit.Saxena@avagotech.com enum MR_FW_CRASH_DUMP_STATE {
315fc62b3fcSSumit.Saxena@avagotech.com 	UNAVAILABLE = 0,
316fc62b3fcSSumit.Saxena@avagotech.com 	AVAILABLE = 1,
317fc62b3fcSSumit.Saxena@avagotech.com 	COPYING = 2,
318fc62b3fcSSumit.Saxena@avagotech.com 	COPIED = 3,
319fc62b3fcSSumit.Saxena@avagotech.com 	COPY_ERROR = 4,
320fc62b3fcSSumit.Saxena@avagotech.com };
321fc62b3fcSSumit.Saxena@avagotech.com 
322fc62b3fcSSumit.Saxena@avagotech.com enum _MR_CRASH_BUF_STATUS {
323fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_OFF = 0,
324fc62b3fcSSumit.Saxena@avagotech.com 	MR_CRASH_BUF_TURN_ON = 1,
325fc62b3fcSSumit.Saxena@avagotech.com };
326fc62b3fcSSumit.Saxena@avagotech.com 
327fc62b3fcSSumit.Saxena@avagotech.com /*
328c4a3e0a5SBagalkote, Sreenivas  * Number of mailbox bytes in DCMD message frame
329c4a3e0a5SBagalkote, Sreenivas  */
330c4a3e0a5SBagalkote, Sreenivas #define MFI_MBOX_SIZE				12
331c4a3e0a5SBagalkote, Sreenivas 
332c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_CLASS {
333c4a3e0a5SBagalkote, Sreenivas 
334c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEBUG = -2,
335c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_PROGRESS = -1,
336c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_INFO = 0,
337c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_WARNING = 1,
338c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_CRITICAL = 2,
339c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_FATAL = 3,
340c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_CLASS_DEAD = 4,
341c4a3e0a5SBagalkote, Sreenivas 
342c4a3e0a5SBagalkote, Sreenivas };
343c4a3e0a5SBagalkote, Sreenivas 
344c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_LOCALE {
345c4a3e0a5SBagalkote, Sreenivas 
346c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_LD = 0x0001,
347c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_PD = 0x0002,
348c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ENCL = 0x0004,
349c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_BBU = 0x0008,
350c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_SAS = 0x0010,
351c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CTRL = 0x0020,
352c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CONFIG = 0x0040,
353c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_CLUSTER = 0x0080,
354c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_LOCALE_ALL = 0xffff,
355c4a3e0a5SBagalkote, Sreenivas 
356c4a3e0a5SBagalkote, Sreenivas };
357c4a3e0a5SBagalkote, Sreenivas 
358c4a3e0a5SBagalkote, Sreenivas enum MR_EVT_ARGS {
359c4a3e0a5SBagalkote, Sreenivas 
360c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_NONE,
361c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_CDB_SENSE,
362c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD,
363c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_COUNT,
364c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA,
365c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_OWNER,
366c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_LBA_PD_LBA,
367c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_PROG,
368c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STATE,
369c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_LD_STRIP,
370c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD,
371c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_ERR,
372c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA,
373c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_LBA_LD,
374c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_PROG,
375c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PD_STATE,
376c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_PCI,
377c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_RATE,
378c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_STR,
379c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_TIME,
380c4a3e0a5SBagalkote, Sreenivas 	MR_EVT_ARGS_ECC,
38181e403ceSYang, Bo 	MR_EVT_ARGS_LD_PROP,
38281e403ceSYang, Bo 	MR_EVT_ARGS_PD_SPARE,
38381e403ceSYang, Bo 	MR_EVT_ARGS_PD_INDEX,
38481e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_PASS,
38581e403ceSYang, Bo 	MR_EVT_ARGS_DIAG_FAIL,
38681e403ceSYang, Bo 	MR_EVT_ARGS_PD_LBA_LBA,
38781e403ceSYang, Bo 	MR_EVT_ARGS_PORT_PHY,
38881e403ceSYang, Bo 	MR_EVT_ARGS_PD_MISSING,
38981e403ceSYang, Bo 	MR_EVT_ARGS_PD_ADDRESS,
39081e403ceSYang, Bo 	MR_EVT_ARGS_BITMAP,
39181e403ceSYang, Bo 	MR_EVT_ARGS_CONNECTOR,
39281e403ceSYang, Bo 	MR_EVT_ARGS_PD_PD,
39381e403ceSYang, Bo 	MR_EVT_ARGS_PD_FRU,
39481e403ceSYang, Bo 	MR_EVT_ARGS_PD_PATHINFO,
39581e403ceSYang, Bo 	MR_EVT_ARGS_PD_POWER_STATE,
39681e403ceSYang, Bo 	MR_EVT_ARGS_GENERIC,
397c4a3e0a5SBagalkote, Sreenivas };
398c4a3e0a5SBagalkote, Sreenivas 
399357ae967Ssumit.saxena@avagotech.com 
400357ae967Ssumit.saxena@avagotech.com #define SGE_BUFFER_SIZE	4096
4018f67c8c5SSumit Saxena #define MEGASAS_CLUSTER_ID_SIZE	16
402c4a3e0a5SBagalkote, Sreenivas /*
40381e403ceSYang, Bo  * define constants for device list query options
40481e403ceSYang, Bo  */
40581e403ceSYang, Bo enum MR_PD_QUERY_TYPE {
40681e403ceSYang, Bo 	MR_PD_QUERY_TYPE_ALL                = 0,
40781e403ceSYang, Bo 	MR_PD_QUERY_TYPE_STATE              = 1,
40881e403ceSYang, Bo 	MR_PD_QUERY_TYPE_POWER_STATE        = 2,
40981e403ceSYang, Bo 	MR_PD_QUERY_TYPE_MEDIA_TYPE         = 3,
41081e403ceSYang, Bo 	MR_PD_QUERY_TYPE_SPEED              = 4,
41181e403ceSYang, Bo 	MR_PD_QUERY_TYPE_EXPOSED_TO_HOST    = 5,
41281e403ceSYang, Bo };
41381e403ceSYang, Bo 
41421c9e160Sadam radford enum MR_LD_QUERY_TYPE {
41521c9e160Sadam radford 	MR_LD_QUERY_TYPE_ALL	         = 0,
41621c9e160Sadam radford 	MR_LD_QUERY_TYPE_EXPOSED_TO_HOST = 1,
41721c9e160Sadam radford 	MR_LD_QUERY_TYPE_USED_TGT_IDS    = 2,
41821c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_ACCESS  = 3,
41921c9e160Sadam radford 	MR_LD_QUERY_TYPE_CLUSTER_LOCALE  = 4,
42021c9e160Sadam radford };
42121c9e160Sadam radford 
42221c9e160Sadam radford 
4237e8a75f4SYang, Bo #define MR_EVT_CFG_CLEARED                              0x0004
4247e8a75f4SYang, Bo #define MR_EVT_LD_STATE_CHANGE                          0x0051
4257e8a75f4SYang, Bo #define MR_EVT_PD_INSERTED                              0x005b
4267e8a75f4SYang, Bo #define MR_EVT_PD_REMOVED                               0x0070
4277e8a75f4SYang, Bo #define MR_EVT_LD_CREATED                               0x008a
4287e8a75f4SYang, Bo #define MR_EVT_LD_DELETED                               0x008b
4297e8a75f4SYang, Bo #define MR_EVT_FOREIGN_CFG_IMPORTED                     0x00db
4307e8a75f4SYang, Bo #define MR_EVT_LD_OFFLINE                               0x00fc
4317e8a75f4SYang, Bo #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED             0x0152
432c4bd2654Ssumit.saxena@avagotech.com #define MR_EVT_CTRL_PROP_CHANGED			0x012f
4337e8a75f4SYang, Bo 
43481e403ceSYang, Bo enum MR_PD_STATE {
43581e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_GOOD   = 0x00,
43681e403ceSYang, Bo 	MR_PD_STATE_UNCONFIGURED_BAD    = 0x01,
43781e403ceSYang, Bo 	MR_PD_STATE_HOT_SPARE           = 0x02,
43881e403ceSYang, Bo 	MR_PD_STATE_OFFLINE             = 0x10,
43981e403ceSYang, Bo 	MR_PD_STATE_FAILED              = 0x11,
44081e403ceSYang, Bo 	MR_PD_STATE_REBUILD             = 0x14,
44181e403ceSYang, Bo 	MR_PD_STATE_ONLINE              = 0x18,
44281e403ceSYang, Bo 	MR_PD_STATE_COPYBACK            = 0x20,
44381e403ceSYang, Bo 	MR_PD_STATE_SYSTEM              = 0x40,
44481e403ceSYang, Bo  };
44581e403ceSYang, Bo 
4462216c305SSumit Saxena union MR_PD_REF {
4472216c305SSumit Saxena 	struct {
4482216c305SSumit Saxena 		u16	 deviceId;
4492216c305SSumit Saxena 		u16	 seqNum;
4502216c305SSumit Saxena 	} mrPdRef;
4512216c305SSumit Saxena 	u32	 ref;
4522216c305SSumit Saxena };
4532216c305SSumit Saxena 
4542216c305SSumit Saxena /*
4552216c305SSumit Saxena  * define the DDF Type bit structure
4562216c305SSumit Saxena  */
4572216c305SSumit Saxena union MR_PD_DDF_TYPE {
4582216c305SSumit Saxena 	 struct {
4592216c305SSumit Saxena 		union {
4602216c305SSumit Saxena 			struct {
4612216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
4622216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4632216c305SSumit Saxena 				 u16	 inVD:1;
4642216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4652216c305SSumit Saxena 				 u16	 isSpare:1;
4662216c305SSumit Saxena 				 u16	 isForeign:1;
4672216c305SSumit Saxena 				 u16	 reserved:7;
4682216c305SSumit Saxena 				 u16	 intf:4;
4692216c305SSumit Saxena #else
4702216c305SSumit Saxena 				 u16	 intf:4;
4712216c305SSumit Saxena 				 u16	 reserved:7;
4722216c305SSumit Saxena 				 u16	 isForeign:1;
4732216c305SSumit Saxena 				 u16	 isSpare:1;
4742216c305SSumit Saxena 				 u16	 isGlobalSpare:1;
4752216c305SSumit Saxena 				 u16	 inVD:1;
4762216c305SSumit Saxena 				 u16	 forcedPDGUID:1;
4772216c305SSumit Saxena #endif
4782216c305SSumit Saxena 			 } pdType;
4792216c305SSumit Saxena 			 u16	 type;
4802216c305SSumit Saxena 		 };
4812216c305SSumit Saxena 		 u16	 reserved;
4822216c305SSumit Saxena 	 } ddf;
4832216c305SSumit Saxena 	 struct {
4842216c305SSumit Saxena 		 u32	reserved;
4852216c305SSumit Saxena 	 } nonDisk;
4862216c305SSumit Saxena 	 u32	 type;
4872216c305SSumit Saxena } __packed;
4882216c305SSumit Saxena 
4892216c305SSumit Saxena /*
4902216c305SSumit Saxena  * defines the progress structure
4912216c305SSumit Saxena  */
4922216c305SSumit Saxena union MR_PROGRESS {
4932216c305SSumit Saxena 	struct  {
4942216c305SSumit Saxena 		u16 progress;
4952216c305SSumit Saxena 		union {
4962216c305SSumit Saxena 			u16 elapsedSecs;
4972216c305SSumit Saxena 			u16 elapsedSecsForLastPercent;
4982216c305SSumit Saxena 		};
4992216c305SSumit Saxena 	} mrProgress;
5002216c305SSumit Saxena 	u32 w;
5012216c305SSumit Saxena } __packed;
5022216c305SSumit Saxena 
5032216c305SSumit Saxena /*
5042216c305SSumit Saxena  * defines the physical drive progress structure
5052216c305SSumit Saxena  */
5062216c305SSumit Saxena struct MR_PD_PROGRESS {
5072216c305SSumit Saxena 	struct {
5082216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5092216c305SSumit Saxena 		u32     rbld:1;
5102216c305SSumit Saxena 		u32     patrol:1;
5112216c305SSumit Saxena 		u32     clear:1;
5122216c305SSumit Saxena 		u32     copyBack:1;
5132216c305SSumit Saxena 		u32     erase:1;
5142216c305SSumit Saxena 		u32     locate:1;
5152216c305SSumit Saxena 		u32     reserved:26;
5162216c305SSumit Saxena #else
5172216c305SSumit Saxena 		u32     reserved:26;
5182216c305SSumit Saxena 		u32     locate:1;
5192216c305SSumit Saxena 		u32     erase:1;
5202216c305SSumit Saxena 		u32     copyBack:1;
5212216c305SSumit Saxena 		u32     clear:1;
5222216c305SSumit Saxena 		u32     patrol:1;
5232216c305SSumit Saxena 		u32     rbld:1;
5242216c305SSumit Saxena #endif
5252216c305SSumit Saxena 	} active;
5262216c305SSumit Saxena 	union MR_PROGRESS     rbld;
5272216c305SSumit Saxena 	union MR_PROGRESS     patrol;
5282216c305SSumit Saxena 	union {
5292216c305SSumit Saxena 		union MR_PROGRESS     clear;
5302216c305SSumit Saxena 		union MR_PROGRESS     erase;
5312216c305SSumit Saxena 	};
5322216c305SSumit Saxena 
5332216c305SSumit Saxena 	struct {
5342216c305SSumit Saxena #ifndef MFI_BIG_ENDIAN
5352216c305SSumit Saxena 		u32     rbld:1;
5362216c305SSumit Saxena 		u32     patrol:1;
5372216c305SSumit Saxena 		u32     clear:1;
5382216c305SSumit Saxena 		u32     copyBack:1;
5392216c305SSumit Saxena 		u32     erase:1;
5402216c305SSumit Saxena 		u32     reserved:27;
5412216c305SSumit Saxena #else
5422216c305SSumit Saxena 		u32     reserved:27;
5432216c305SSumit Saxena 		u32     erase:1;
5442216c305SSumit Saxena 		u32     copyBack:1;
5452216c305SSumit Saxena 		u32     clear:1;
5462216c305SSumit Saxena 		u32     patrol:1;
5472216c305SSumit Saxena 		u32     rbld:1;
5482216c305SSumit Saxena #endif
5492216c305SSumit Saxena 	} pause;
5502216c305SSumit Saxena 
5512216c305SSumit Saxena 	union MR_PROGRESS     reserved[3];
5522216c305SSumit Saxena } __packed;
5532216c305SSumit Saxena 
5542216c305SSumit Saxena struct  MR_PD_INFO {
5552216c305SSumit Saxena 	union MR_PD_REF	ref;
5562216c305SSumit Saxena 	u8 inquiryData[96];
5572216c305SSumit Saxena 	u8 vpdPage83[64];
5582216c305SSumit Saxena 	u8 notSupported;
5592216c305SSumit Saxena 	u8 scsiDevType;
5602216c305SSumit Saxena 
5612216c305SSumit Saxena 	union {
5622216c305SSumit Saxena 		u8 connectedPortBitmap;
5632216c305SSumit Saxena 		u8 connectedPortNumbers;
5642216c305SSumit Saxena 	};
5652216c305SSumit Saxena 
5662216c305SSumit Saxena 	u8 deviceSpeed;
5672216c305SSumit Saxena 	u32 mediaErrCount;
5682216c305SSumit Saxena 	u32 otherErrCount;
5692216c305SSumit Saxena 	u32 predFailCount;
5702216c305SSumit Saxena 	u32 lastPredFailEventSeqNum;
5712216c305SSumit Saxena 
5722216c305SSumit Saxena 	u16 fwState;
5732216c305SSumit Saxena 	u8 disabledForRemoval;
5742216c305SSumit Saxena 	u8 linkSpeed;
5752216c305SSumit Saxena 	union MR_PD_DDF_TYPE state;
5762216c305SSumit Saxena 
5772216c305SSumit Saxena 	struct {
5782216c305SSumit Saxena 		u8 count;
5792216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
5802216c305SSumit Saxena 		u8 isPathBroken:4;
5812216c305SSumit Saxena 		u8 reserved3:3;
5822216c305SSumit Saxena 		u8 widePortCapable:1;
5832216c305SSumit Saxena #else
5842216c305SSumit Saxena 		u8 widePortCapable:1;
5852216c305SSumit Saxena 		u8 reserved3:3;
5862216c305SSumit Saxena 		u8 isPathBroken:4;
5872216c305SSumit Saxena #endif
5882216c305SSumit Saxena 
5892216c305SSumit Saxena 		u8 connectorIndex[2];
5902216c305SSumit Saxena 		u8 reserved[4];
5912216c305SSumit Saxena 		u64 sasAddr[2];
5922216c305SSumit Saxena 		u8 reserved2[16];
5932216c305SSumit Saxena 	} pathInfo;
5942216c305SSumit Saxena 
5952216c305SSumit Saxena 	u64 rawSize;
5962216c305SSumit Saxena 	u64 nonCoercedSize;
5972216c305SSumit Saxena 	u64 coercedSize;
5982216c305SSumit Saxena 	u16 enclDeviceId;
5992216c305SSumit Saxena 	u8 enclIndex;
6002216c305SSumit Saxena 
6012216c305SSumit Saxena 	union {
6022216c305SSumit Saxena 		u8 slotNumber;
6032216c305SSumit Saxena 		u8 enclConnectorIndex;
6042216c305SSumit Saxena 	};
6052216c305SSumit Saxena 
6062216c305SSumit Saxena 	struct MR_PD_PROGRESS progInfo;
6072216c305SSumit Saxena 	u8 badBlockTableFull;
6082216c305SSumit Saxena 	u8 unusableInCurrentConfig;
6092216c305SSumit Saxena 	u8 vpdPage83Ext[64];
6102216c305SSumit Saxena 	u8 powerState;
6112216c305SSumit Saxena 	u8 enclPosition;
6122216c305SSumit Saxena 	u32 allowedOps;
6132216c305SSumit Saxena 	u16 copyBackPartnerId;
6142216c305SSumit Saxena 	u16 enclPartnerDeviceId;
6152216c305SSumit Saxena 	struct {
6162216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6172216c305SSumit Saxena 		u16 fdeCapable:1;
6182216c305SSumit Saxena 		u16 fdeEnabled:1;
6192216c305SSumit Saxena 		u16 secured:1;
6202216c305SSumit Saxena 		u16 locked:1;
6212216c305SSumit Saxena 		u16 foreign:1;
6222216c305SSumit Saxena 		u16 needsEKM:1;
6232216c305SSumit Saxena 		u16 reserved:10;
6242216c305SSumit Saxena #else
6252216c305SSumit Saxena 		u16 reserved:10;
6262216c305SSumit Saxena 		u16 needsEKM:1;
6272216c305SSumit Saxena 		u16 foreign:1;
6282216c305SSumit Saxena 		u16 locked:1;
6292216c305SSumit Saxena 		u16 secured:1;
6302216c305SSumit Saxena 		u16 fdeEnabled:1;
6312216c305SSumit Saxena 		u16 fdeCapable:1;
6322216c305SSumit Saxena #endif
6332216c305SSumit Saxena 	} security;
6342216c305SSumit Saxena 	u8 mediaType;
6352216c305SSumit Saxena 	u8 notCertified;
6362216c305SSumit Saxena 	u8 bridgeVendor[8];
6372216c305SSumit Saxena 	u8 bridgeProductIdentification[16];
6382216c305SSumit Saxena 	u8 bridgeProductRevisionLevel[4];
6392216c305SSumit Saxena 	u8 satBridgeExists;
6402216c305SSumit Saxena 
6412216c305SSumit Saxena 	u8 interfaceType;
6422216c305SSumit Saxena 	u8 temperature;
6432216c305SSumit Saxena 	u8 emulatedBlockSize;
6442216c305SSumit Saxena 	u16 userDataBlockSize;
6452216c305SSumit Saxena 	u16 reserved2;
6462216c305SSumit Saxena 
6472216c305SSumit Saxena 	struct {
6482216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6492216c305SSumit Saxena 		u32 piType:3;
6502216c305SSumit Saxena 		u32 piFormatted:1;
6512216c305SSumit Saxena 		u32 piEligible:1;
6522216c305SSumit Saxena 		u32 NCQ:1;
6532216c305SSumit Saxena 		u32 WCE:1;
6542216c305SSumit Saxena 		u32 commissionedSpare:1;
6552216c305SSumit Saxena 		u32 emergencySpare:1;
6562216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6572216c305SSumit Saxena 		u32 ineligibleForLd:1;
6582216c305SSumit Saxena 		u32 useSSEraseType:1;
6592216c305SSumit Saxena 		u32 wceUnchanged:1;
6602216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6612216c305SSumit Saxena 		u32 reserved:18;
6622216c305SSumit Saxena #else
6632216c305SSumit Saxena 		u32 reserved:18;
6642216c305SSumit Saxena 		u32 supportScsiUnmap:1;
6652216c305SSumit Saxena 		u32 wceUnchanged:1;
6662216c305SSumit Saxena 		u32 useSSEraseType:1;
6672216c305SSumit Saxena 		u32 ineligibleForLd:1;
6682216c305SSumit Saxena 		u32 ineligibleForSSCD:1;
6692216c305SSumit Saxena 		u32 emergencySpare:1;
6702216c305SSumit Saxena 		u32 commissionedSpare:1;
6712216c305SSumit Saxena 		u32 WCE:1;
6722216c305SSumit Saxena 		u32 NCQ:1;
6732216c305SSumit Saxena 		u32 piEligible:1;
6742216c305SSumit Saxena 		u32 piFormatted:1;
6752216c305SSumit Saxena 		u32 piType:3;
6762216c305SSumit Saxena #endif
6772216c305SSumit Saxena 	} properties;
6782216c305SSumit Saxena 
6792216c305SSumit Saxena 	u64 shieldDiagCompletionTime;
6802216c305SSumit Saxena 	u8 shieldCounter;
6812216c305SSumit Saxena 
6822216c305SSumit Saxena 	u8 linkSpeedOther;
6832216c305SSumit Saxena 	u8 reserved4[2];
6842216c305SSumit Saxena 
6852216c305SSumit Saxena 	struct {
6862216c305SSumit Saxena #ifndef __BIG_ENDIAN_BITFIELD
6872216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
6882216c305SSumit Saxena 		u32 bbmErrCount:31;
6892216c305SSumit Saxena #else
6902216c305SSumit Saxena 		u32 bbmErrCount:31;
6912216c305SSumit Saxena 		u32 bbmErrCountSupported:1;
6922216c305SSumit Saxena #endif
6932216c305SSumit Saxena 	} bbmErr;
6942216c305SSumit Saxena 
6952216c305SSumit Saxena 	u8 reserved1[512-428];
6962216c305SSumit Saxena } __packed;
69781e403ceSYang, Bo 
69881e403ceSYang, Bo  /*
69981e403ceSYang, Bo  * defines the physical drive address structure
70081e403ceSYang, Bo  */
70181e403ceSYang, Bo struct MR_PD_ADDRESS {
7029ab9ed38SChristoph Hellwig 	__le16	deviceId;
70381e403ceSYang, Bo 	u16     enclDeviceId;
70481e403ceSYang, Bo 
70581e403ceSYang, Bo 	union {
70681e403ceSYang, Bo 		struct {
70781e403ceSYang, Bo 			u8  enclIndex;
70881e403ceSYang, Bo 			u8  slotNumber;
70981e403ceSYang, Bo 		} mrPdAddress;
71081e403ceSYang, Bo 		struct {
71181e403ceSYang, Bo 			u8  enclPosition;
71281e403ceSYang, Bo 			u8  enclConnectorIndex;
71381e403ceSYang, Bo 		} mrEnclAddress;
71481e403ceSYang, Bo 	};
71581e403ceSYang, Bo 	u8      scsiDevType;
71681e403ceSYang, Bo 	union {
71781e403ceSYang, Bo 		u8      connectedPortBitmap;
71881e403ceSYang, Bo 		u8      connectedPortNumbers;
71981e403ceSYang, Bo 	};
72081e403ceSYang, Bo 	u64     sasAddr[2];
72181e403ceSYang, Bo } __packed;
72281e403ceSYang, Bo 
72381e403ceSYang, Bo /*
72481e403ceSYang, Bo  * defines the physical drive list structure
72581e403ceSYang, Bo  */
72681e403ceSYang, Bo struct MR_PD_LIST {
7279ab9ed38SChristoph Hellwig 	__le32		size;
7289ab9ed38SChristoph Hellwig 	__le32		count;
72981e403ceSYang, Bo 	struct MR_PD_ADDRESS   addr[1];
73081e403ceSYang, Bo } __packed;
73181e403ceSYang, Bo 
73281e403ceSYang, Bo struct megasas_pd_list {
73381e403ceSYang, Bo 	u16             tid;
73481e403ceSYang, Bo 	u8             driveType;
73581e403ceSYang, Bo 	u8             driveState;
7362216c305SSumit Saxena 	u8             interface;
73781e403ceSYang, Bo } __packed;
73881e403ceSYang, Bo 
73981e403ceSYang, Bo  /*
740bdc6fb8dSYang, Bo  * defines the logical drive reference structure
741bdc6fb8dSYang, Bo  */
742bdc6fb8dSYang, Bo union  MR_LD_REF {
743bdc6fb8dSYang, Bo 	struct {
744bdc6fb8dSYang, Bo 		u8      targetId;
745bdc6fb8dSYang, Bo 		u8      reserved;
7469ab9ed38SChristoph Hellwig 		__le16     seqNum;
747bdc6fb8dSYang, Bo 	};
7489ab9ed38SChristoph Hellwig 	__le32     ref;
749bdc6fb8dSYang, Bo } __packed;
750bdc6fb8dSYang, Bo 
751bdc6fb8dSYang, Bo /*
752bdc6fb8dSYang, Bo  * defines the logical drive list structure
753bdc6fb8dSYang, Bo  */
754bdc6fb8dSYang, Bo struct MR_LD_LIST {
7559ab9ed38SChristoph Hellwig 	__le32     ldCount;
7569ab9ed38SChristoph Hellwig 	__le32     reserved;
757bdc6fb8dSYang, Bo 	struct {
758bdc6fb8dSYang, Bo 		union MR_LD_REF   ref;
759bdc6fb8dSYang, Bo 		u8          state;
760bdc6fb8dSYang, Bo 		u8          reserved[3];
7619ab9ed38SChristoph Hellwig 		__le64		size;
76251087a86SSumit.Saxena@avagotech.com 	} ldList[MAX_LOGICAL_DRIVES_EXT];
763bdc6fb8dSYang, Bo } __packed;
764bdc6fb8dSYang, Bo 
76521c9e160Sadam radford struct MR_LD_TARGETID_LIST {
7669ab9ed38SChristoph Hellwig 	__le32	size;
7679ab9ed38SChristoph Hellwig 	__le32	count;
76821c9e160Sadam radford 	u8	pad[3];
76951087a86SSumit.Saxena@avagotech.com 	u8	targetId[MAX_LOGICAL_DRIVES_EXT];
77021c9e160Sadam radford };
77121c9e160Sadam radford 
77221c9e160Sadam radford 
773bdc6fb8dSYang, Bo /*
774c4a3e0a5SBagalkote, Sreenivas  * SAS controller properties
775c4a3e0a5SBagalkote, Sreenivas  */
776c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_prop {
777c4a3e0a5SBagalkote, Sreenivas 
778c4a3e0a5SBagalkote, Sreenivas 	u16 seq_num;
779c4a3e0a5SBagalkote, Sreenivas 	u16 pred_fail_poll_interval;
780c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_count;
781c4a3e0a5SBagalkote, Sreenivas 	u16 intr_throttle_timeouts;
782c4a3e0a5SBagalkote, Sreenivas 	u8 rebuild_rate;
783c4a3e0a5SBagalkote, Sreenivas 	u8 patrol_read_rate;
784c4a3e0a5SBagalkote, Sreenivas 	u8 bgi_rate;
785c4a3e0a5SBagalkote, Sreenivas 	u8 cc_rate;
786c4a3e0a5SBagalkote, Sreenivas 	u8 recon_rate;
787c4a3e0a5SBagalkote, Sreenivas 	u8 cache_flush_interval;
788c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_drv_count;
789c4a3e0a5SBagalkote, Sreenivas 	u8 spinup_delay;
790c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_enable;
791c4a3e0a5SBagalkote, Sreenivas 	u8 coercion_mode;
792c4a3e0a5SBagalkote, Sreenivas 	u8 alarm_enable;
793c4a3e0a5SBagalkote, Sreenivas 	u8 disable_auto_rebuild;
794c4a3e0a5SBagalkote, Sreenivas 	u8 disable_battery_warn;
795c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_size;
796c4a3e0a5SBagalkote, Sreenivas 	u16 ecc_bucket_leak_rate;
797c4a3e0a5SBagalkote, Sreenivas 	u8 restore_hotspare_on_insertion;
798c4a3e0a5SBagalkote, Sreenivas 	u8 expose_encl_devices;
79939a98554Sbo yang 	u8 maintainPdFailHistory;
80039a98554Sbo yang 	u8 disallowHostRequestReordering;
80139a98554Sbo yang 	u8 abortCCOnError;
80239a98554Sbo yang 	u8 loadBalanceMode;
80339a98554Sbo yang 	u8 disableAutoDetectBackplane;
804c4a3e0a5SBagalkote, Sreenivas 
80539a98554Sbo yang 	u8 snapVDSpace;
80639a98554Sbo yang 
80739a98554Sbo yang 	/*
80839a98554Sbo yang 	* Add properties that can be controlled by
80939a98554Sbo yang 	* a bit in the following structure.
81039a98554Sbo yang 	*/
81139a98554Sbo yang 	struct {
81294cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
81394cd65ddSSumit.Saxena@lsi.com 		u32     reserved:18;
81494cd65ddSSumit.Saxena@lsi.com 		u32     enableJBOD:1;
81594cd65ddSSumit.Saxena@lsi.com 		u32     disableSpinDownHS:1;
81694cd65ddSSumit.Saxena@lsi.com 		u32     allowBootWithPinnedCache:1;
81794cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlineCtrlReset:1;
81894cd65ddSSumit.Saxena@lsi.com 		u32     enableSecretKeyControl:1;
81994cd65ddSSumit.Saxena@lsi.com 		u32     autoEnhancedImport:1;
82094cd65ddSSumit.Saxena@lsi.com 		u32     enableSpinDownUnconfigured:1;
82194cd65ddSSumit.Saxena@lsi.com 		u32     SSDPatrolReadEnabled:1;
82294cd65ddSSumit.Saxena@lsi.com 		u32     SSDSMARTerEnabled:1;
82394cd65ddSSumit.Saxena@lsi.com 		u32     disableNCQ:1;
82494cd65ddSSumit.Saxena@lsi.com 		u32     useFdeOnly:1;
82594cd65ddSSumit.Saxena@lsi.com 		u32     prCorrectUnconfiguredAreas:1;
82694cd65ddSSumit.Saxena@lsi.com 		u32     SMARTerEnabled:1;
82794cd65ddSSumit.Saxena@lsi.com 		u32     copyBackDisabled:1;
82894cd65ddSSumit.Saxena@lsi.com #else
82939a98554Sbo yang 		u32     copyBackDisabled:1;
83039a98554Sbo yang 		u32     SMARTerEnabled:1;
83139a98554Sbo yang 		u32     prCorrectUnconfiguredAreas:1;
83239a98554Sbo yang 		u32     useFdeOnly:1;
83339a98554Sbo yang 		u32     disableNCQ:1;
83439a98554Sbo yang 		u32     SSDSMARTerEnabled:1;
83539a98554Sbo yang 		u32     SSDPatrolReadEnabled:1;
83639a98554Sbo yang 		u32     enableSpinDownUnconfigured:1;
83739a98554Sbo yang 		u32     autoEnhancedImport:1;
83839a98554Sbo yang 		u32     enableSecretKeyControl:1;
83939a98554Sbo yang 		u32     disableOnlineCtrlReset:1;
84039a98554Sbo yang 		u32     allowBootWithPinnedCache:1;
84139a98554Sbo yang 		u32     disableSpinDownHS:1;
84239a98554Sbo yang 		u32     enableJBOD:1;
84339a98554Sbo yang 		u32     reserved:18;
84494cd65ddSSumit.Saxena@lsi.com #endif
84539a98554Sbo yang 	} OnOffProperties;
84639a98554Sbo yang 	u8 autoSnapVDSpace;
84739a98554Sbo yang 	u8 viewSpace;
8489ab9ed38SChristoph Hellwig 	__le16 spinDownTime;
84939a98554Sbo yang 	u8  reserved[24];
85081e403ceSYang, Bo } __packed;
851c4a3e0a5SBagalkote, Sreenivas 
852c4a3e0a5SBagalkote, Sreenivas /*
853c4a3e0a5SBagalkote, Sreenivas  * SAS controller information
854c4a3e0a5SBagalkote, Sreenivas  */
855c4a3e0a5SBagalkote, Sreenivas struct megasas_ctrl_info {
856c4a3e0a5SBagalkote, Sreenivas 
857c4a3e0a5SBagalkote, Sreenivas 	/*
858c4a3e0a5SBagalkote, Sreenivas 	 * PCI device information
859c4a3e0a5SBagalkote, Sreenivas 	 */
860c4a3e0a5SBagalkote, Sreenivas 	struct {
861c4a3e0a5SBagalkote, Sreenivas 
8629ab9ed38SChristoph Hellwig 		__le16 vendor_id;
8639ab9ed38SChristoph Hellwig 		__le16 device_id;
8649ab9ed38SChristoph Hellwig 		__le16 sub_vendor_id;
8659ab9ed38SChristoph Hellwig 		__le16 sub_device_id;
866c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[24];
867c4a3e0a5SBagalkote, Sreenivas 
868c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pci;
869c4a3e0a5SBagalkote, Sreenivas 
870c4a3e0a5SBagalkote, Sreenivas 	/*
871c4a3e0a5SBagalkote, Sreenivas 	 * Host interface information
872c4a3e0a5SBagalkote, Sreenivas 	 */
873c4a3e0a5SBagalkote, Sreenivas 	struct {
874c4a3e0a5SBagalkote, Sreenivas 
875c4a3e0a5SBagalkote, Sreenivas 		u8 PCIX:1;
876c4a3e0a5SBagalkote, Sreenivas 		u8 PCIE:1;
877c4a3e0a5SBagalkote, Sreenivas 		u8 iSCSI:1;
878c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
879229fe47cSadam radford 		u8 SRIOV:1;
880229fe47cSadam radford 		u8 reserved_0:3;
881c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
882c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
883c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
884c4a3e0a5SBagalkote, Sreenivas 
885c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) host_interface;
886c4a3e0a5SBagalkote, Sreenivas 
887c4a3e0a5SBagalkote, Sreenivas 	/*
888c4a3e0a5SBagalkote, Sreenivas 	 * Device (backend) interface information
889c4a3e0a5SBagalkote, Sreenivas 	 */
890c4a3e0a5SBagalkote, Sreenivas 	struct {
891c4a3e0a5SBagalkote, Sreenivas 
892c4a3e0a5SBagalkote, Sreenivas 		u8 SPI:1;
893c4a3e0a5SBagalkote, Sreenivas 		u8 SAS_3G:1;
894c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_1_5G:1;
895c4a3e0a5SBagalkote, Sreenivas 		u8 SATA_3G:1;
896c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_0:4;
897c4a3e0a5SBagalkote, Sreenivas 		u8 reserved_1[6];
898c4a3e0a5SBagalkote, Sreenivas 		u8 port_count;
899c4a3e0a5SBagalkote, Sreenivas 		u64 port_addr[8];
900c4a3e0a5SBagalkote, Sreenivas 
901c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) device_interface;
902c4a3e0a5SBagalkote, Sreenivas 
903c4a3e0a5SBagalkote, Sreenivas 	/*
904c4a3e0a5SBagalkote, Sreenivas 	 * List of components residing in flash. All str are null terminated
905c4a3e0a5SBagalkote, Sreenivas 	 */
9069ab9ed38SChristoph Hellwig 	__le32 image_check_word;
9079ab9ed38SChristoph Hellwig 	__le32 image_component_count;
908c4a3e0a5SBagalkote, Sreenivas 
909c4a3e0a5SBagalkote, Sreenivas 	struct {
910c4a3e0a5SBagalkote, Sreenivas 
911c4a3e0a5SBagalkote, Sreenivas 		char name[8];
912c4a3e0a5SBagalkote, Sreenivas 		char version[32];
913c4a3e0a5SBagalkote, Sreenivas 		char build_date[16];
914c4a3e0a5SBagalkote, Sreenivas 		char built_time[16];
915c4a3e0a5SBagalkote, Sreenivas 
916c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) image_component[8];
917c4a3e0a5SBagalkote, Sreenivas 
918c4a3e0a5SBagalkote, Sreenivas 	/*
919c4a3e0a5SBagalkote, Sreenivas 	 * List of flash components that have been flashed on the card, but
920c4a3e0a5SBagalkote, Sreenivas 	 * are not in use, pending reset of the adapter. This list will be
921c4a3e0a5SBagalkote, Sreenivas 	 * empty if a flash operation has not occurred. All stings are null
922c4a3e0a5SBagalkote, Sreenivas 	 * terminated
923c4a3e0a5SBagalkote, Sreenivas 	 */
9249ab9ed38SChristoph Hellwig 	__le32 pending_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 build_time[16];
932c4a3e0a5SBagalkote, Sreenivas 
933c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pending_image_component[8];
934c4a3e0a5SBagalkote, Sreenivas 
935c4a3e0a5SBagalkote, Sreenivas 	u8 max_arms;
936c4a3e0a5SBagalkote, Sreenivas 	u8 max_spans;
937c4a3e0a5SBagalkote, Sreenivas 	u8 max_arrays;
938c4a3e0a5SBagalkote, Sreenivas 	u8 max_lds;
939c4a3e0a5SBagalkote, Sreenivas 
940c4a3e0a5SBagalkote, Sreenivas 	char product_name[80];
941c4a3e0a5SBagalkote, Sreenivas 	char serial_no[32];
942c4a3e0a5SBagalkote, Sreenivas 
943c4a3e0a5SBagalkote, Sreenivas 	/*
944c4a3e0a5SBagalkote, Sreenivas 	 * Other physical/controller/operation information. Indicates the
945c4a3e0a5SBagalkote, Sreenivas 	 * presence of the hardware
946c4a3e0a5SBagalkote, Sreenivas 	 */
947c4a3e0a5SBagalkote, Sreenivas 	struct {
948c4a3e0a5SBagalkote, Sreenivas 
949c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
950c4a3e0a5SBagalkote, Sreenivas 		u32 alarm:1;
951c4a3e0a5SBagalkote, Sreenivas 		u32 nvram:1;
952c4a3e0a5SBagalkote, Sreenivas 		u32 uart:1;
953c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:28;
954c4a3e0a5SBagalkote, Sreenivas 
955c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) hw_present;
956c4a3e0a5SBagalkote, Sreenivas 
9579ab9ed38SChristoph Hellwig 	__le32 current_fw_time;
958c4a3e0a5SBagalkote, Sreenivas 
959c4a3e0a5SBagalkote, Sreenivas 	/*
960c4a3e0a5SBagalkote, Sreenivas 	 * Maximum data transfer sizes
961c4a3e0a5SBagalkote, Sreenivas 	 */
9629ab9ed38SChristoph Hellwig 	__le16 max_concurrent_cmds;
9639ab9ed38SChristoph Hellwig 	__le16 max_sge_count;
9649ab9ed38SChristoph Hellwig 	__le32 max_request_size;
965c4a3e0a5SBagalkote, Sreenivas 
966c4a3e0a5SBagalkote, Sreenivas 	/*
967c4a3e0a5SBagalkote, Sreenivas 	 * Logical and physical device counts
968c4a3e0a5SBagalkote, Sreenivas 	 */
9699ab9ed38SChristoph Hellwig 	__le16 ld_present_count;
9709ab9ed38SChristoph Hellwig 	__le16 ld_degraded_count;
9719ab9ed38SChristoph Hellwig 	__le16 ld_offline_count;
972c4a3e0a5SBagalkote, Sreenivas 
9739ab9ed38SChristoph Hellwig 	__le16 pd_present_count;
9749ab9ed38SChristoph Hellwig 	__le16 pd_disk_present_count;
9759ab9ed38SChristoph Hellwig 	__le16 pd_disk_pred_failure_count;
9769ab9ed38SChristoph Hellwig 	__le16 pd_disk_failed_count;
977c4a3e0a5SBagalkote, Sreenivas 
978c4a3e0a5SBagalkote, Sreenivas 	/*
979c4a3e0a5SBagalkote, Sreenivas 	 * Memory size information
980c4a3e0a5SBagalkote, Sreenivas 	 */
9819ab9ed38SChristoph Hellwig 	__le16 nvram_size;
9829ab9ed38SChristoph Hellwig 	__le16 memory_size;
9839ab9ed38SChristoph Hellwig 	__le16 flash_size;
984c4a3e0a5SBagalkote, Sreenivas 
985c4a3e0a5SBagalkote, Sreenivas 	/*
986c4a3e0a5SBagalkote, Sreenivas 	 * Error counters
987c4a3e0a5SBagalkote, Sreenivas 	 */
9889ab9ed38SChristoph Hellwig 	__le16 mem_correctable_error_count;
9899ab9ed38SChristoph Hellwig 	__le16 mem_uncorrectable_error_count;
990c4a3e0a5SBagalkote, Sreenivas 
991c4a3e0a5SBagalkote, Sreenivas 	/*
992c4a3e0a5SBagalkote, Sreenivas 	 * Cluster information
993c4a3e0a5SBagalkote, Sreenivas 	 */
994c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_permitted;
995c4a3e0a5SBagalkote, Sreenivas 	u8 cluster_active;
996c4a3e0a5SBagalkote, Sreenivas 
997c4a3e0a5SBagalkote, Sreenivas 	/*
998c4a3e0a5SBagalkote, Sreenivas 	 * Additional max data transfer sizes
999c4a3e0a5SBagalkote, Sreenivas 	 */
10009ab9ed38SChristoph Hellwig 	__le16 max_strips_per_io;
1001c4a3e0a5SBagalkote, Sreenivas 
1002c4a3e0a5SBagalkote, Sreenivas 	/*
1003c4a3e0a5SBagalkote, Sreenivas 	 * Controller capabilities structures
1004c4a3e0a5SBagalkote, Sreenivas 	 */
1005c4a3e0a5SBagalkote, Sreenivas 	struct {
1006c4a3e0a5SBagalkote, Sreenivas 
1007c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_0:1;
1008c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1:1;
1009c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_5:1;
1010c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_1E:1;
1011c4a3e0a5SBagalkote, Sreenivas 		u32 raid_level_6:1;
1012c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1013c4a3e0a5SBagalkote, Sreenivas 
1014c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) raid_levels;
1015c4a3e0a5SBagalkote, Sreenivas 
1016c4a3e0a5SBagalkote, Sreenivas 	struct {
1017c4a3e0a5SBagalkote, Sreenivas 
1018c4a3e0a5SBagalkote, Sreenivas 		u32 rbld_rate:1;
1019c4a3e0a5SBagalkote, Sreenivas 		u32 cc_rate:1;
1020c4a3e0a5SBagalkote, Sreenivas 		u32 bgi_rate:1;
1021c4a3e0a5SBagalkote, Sreenivas 		u32 recon_rate:1;
1022c4a3e0a5SBagalkote, Sreenivas 		u32 patrol_rate:1;
1023c4a3e0a5SBagalkote, Sreenivas 		u32 alarm_control:1;
1024c4a3e0a5SBagalkote, Sreenivas 		u32 cluster_supported:1;
1025c4a3e0a5SBagalkote, Sreenivas 		u32 bbu:1;
1026c4a3e0a5SBagalkote, Sreenivas 		u32 spanning_allowed:1;
1027c4a3e0a5SBagalkote, Sreenivas 		u32 dedicated_hotspares:1;
1028c4a3e0a5SBagalkote, Sreenivas 		u32 revertible_hotspares:1;
1029c4a3e0a5SBagalkote, Sreenivas 		u32 foreign_config_import:1;
1030c4a3e0a5SBagalkote, Sreenivas 		u32 self_diagnostic:1;
1031c4a3e0a5SBagalkote, Sreenivas 		u32 mixed_redundancy_arr:1;
1032c4a3e0a5SBagalkote, Sreenivas 		u32 global_hot_spares:1;
1033c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:17;
1034c4a3e0a5SBagalkote, Sreenivas 
1035c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) adapter_operations;
1036c4a3e0a5SBagalkote, Sreenivas 
1037c4a3e0a5SBagalkote, Sreenivas 	struct {
1038c4a3e0a5SBagalkote, Sreenivas 
1039c4a3e0a5SBagalkote, Sreenivas 		u32 read_policy:1;
1040c4a3e0a5SBagalkote, Sreenivas 		u32 write_policy:1;
1041c4a3e0a5SBagalkote, Sreenivas 		u32 io_policy:1;
1042c4a3e0a5SBagalkote, Sreenivas 		u32 access_policy:1;
1043c4a3e0a5SBagalkote, Sreenivas 		u32 disk_cache_policy:1;
1044c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1045c4a3e0a5SBagalkote, Sreenivas 
1046c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) ld_operations;
1047c4a3e0a5SBagalkote, Sreenivas 
1048c4a3e0a5SBagalkote, Sreenivas 	struct {
1049c4a3e0a5SBagalkote, Sreenivas 
1050c4a3e0a5SBagalkote, Sreenivas 		u8 min;
1051c4a3e0a5SBagalkote, Sreenivas 		u8 max;
1052c4a3e0a5SBagalkote, Sreenivas 		u8 reserved[2];
1053c4a3e0a5SBagalkote, Sreenivas 
1054c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) stripe_sz_ops;
1055c4a3e0a5SBagalkote, Sreenivas 
1056c4a3e0a5SBagalkote, Sreenivas 	struct {
1057c4a3e0a5SBagalkote, Sreenivas 
1058c4a3e0a5SBagalkote, Sreenivas 		u32 force_online:1;
1059c4a3e0a5SBagalkote, Sreenivas 		u32 force_offline:1;
1060c4a3e0a5SBagalkote, Sreenivas 		u32 force_rebuild:1;
1061c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:29;
1062c4a3e0a5SBagalkote, Sreenivas 
1063c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_operations;
1064c4a3e0a5SBagalkote, Sreenivas 
1065c4a3e0a5SBagalkote, Sreenivas 	struct {
1066c4a3e0a5SBagalkote, Sreenivas 
1067c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sas:1;
1068c4a3e0a5SBagalkote, Sreenivas 		u32 ctrl_supports_sata:1;
1069c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_encl:1;
1070c4a3e0a5SBagalkote, Sreenivas 		u32 allow_mix_in_ld:1;
1071c4a3e0a5SBagalkote, Sreenivas 		u32 allow_sata_in_cluster:1;
1072c4a3e0a5SBagalkote, Sreenivas 		u32 reserved:27;
1073c4a3e0a5SBagalkote, Sreenivas 
1074c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) pd_mix_support;
1075c4a3e0a5SBagalkote, Sreenivas 
1076c4a3e0a5SBagalkote, Sreenivas 	/*
1077c4a3e0a5SBagalkote, Sreenivas 	 * Define ECC single-bit-error bucket information
1078c4a3e0a5SBagalkote, Sreenivas 	 */
1079c4a3e0a5SBagalkote, Sreenivas 	u8 ecc_bucket_count;
1080c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[11];
1081c4a3e0a5SBagalkote, Sreenivas 
1082c4a3e0a5SBagalkote, Sreenivas 	/*
1083c4a3e0a5SBagalkote, Sreenivas 	 * Include the controller properties (changeable items)
1084c4a3e0a5SBagalkote, Sreenivas 	 */
1085c4a3e0a5SBagalkote, Sreenivas 	struct megasas_ctrl_prop properties;
1086c4a3e0a5SBagalkote, Sreenivas 
1087c4a3e0a5SBagalkote, Sreenivas 	/*
1088c4a3e0a5SBagalkote, Sreenivas 	 * Define FW pkg version (set in envt v'bles on OEM basis)
1089c4a3e0a5SBagalkote, Sreenivas 	 */
1090c4a3e0a5SBagalkote, Sreenivas 	char package_version[0x60];
1091c4a3e0a5SBagalkote, Sreenivas 
1092c4a3e0a5SBagalkote, Sreenivas 
1093bc93d425SSumit.Saxena@lsi.com 	/*
1094bc93d425SSumit.Saxena@lsi.com 	* If adapterOperations.supportMoreThan8Phys is set,
1095bc93d425SSumit.Saxena@lsi.com 	* and deviceInterface.portCount is greater than 8,
1096bc93d425SSumit.Saxena@lsi.com 	* SAS Addrs for first 8 ports shall be populated in
1097bc93d425SSumit.Saxena@lsi.com 	* deviceInterface.portAddr, and the rest shall be
1098bc93d425SSumit.Saxena@lsi.com 	* populated in deviceInterfacePortAddr2.
1099bc93d425SSumit.Saxena@lsi.com 	*/
11009ab9ed38SChristoph Hellwig 	__le64	    deviceInterfacePortAddr2[8]; /*6a0h */
1101bc93d425SSumit.Saxena@lsi.com 	u8          reserved3[128];              /*6e0h */
1102bc93d425SSumit.Saxena@lsi.com 
1103bc93d425SSumit.Saxena@lsi.com 	struct {                                /*760h */
1104bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_0:4;
1105bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_0:12;
1106bc93d425SSumit.Saxena@lsi.com 
1107bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1:4;
1108bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1:12;
1109bc93d425SSumit.Saxena@lsi.com 
1110bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_5:4;
1111bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_5:12;
1112bc93d425SSumit.Saxena@lsi.com 
1113bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E:4;
1114bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E:12;
1115bc93d425SSumit.Saxena@lsi.com 
1116bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_6:4;
1117bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_6:12;
1118bc93d425SSumit.Saxena@lsi.com 
1119bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_10:4;
1120bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_10:12;
1121bc93d425SSumit.Saxena@lsi.com 
1122bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_50:4;
1123bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_50:12;
1124bc93d425SSumit.Saxena@lsi.com 
1125bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_60:4;
1126bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_60:12;
1127bc93d425SSumit.Saxena@lsi.com 
1128bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E_RLQ0:4;
1129bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E_RLQ0:12;
1130bc93d425SSumit.Saxena@lsi.com 
1131bc93d425SSumit.Saxena@lsi.com 		u16 minPdRaidLevel_1E0_RLQ0:4;
1132bc93d425SSumit.Saxena@lsi.com 		u16 maxPdRaidLevel_1E0_RLQ0:12;
1133bc93d425SSumit.Saxena@lsi.com 
1134bc93d425SSumit.Saxena@lsi.com 		u16 reserved[6];
1135bc93d425SSumit.Saxena@lsi.com 	} pdsForRaidLevels;
1136bc93d425SSumit.Saxena@lsi.com 
11379ab9ed38SChristoph Hellwig 	__le16 maxPds;                          /*780h */
11389ab9ed38SChristoph Hellwig 	__le16 maxDedHSPs;                      /*782h */
11399ab9ed38SChristoph Hellwig 	__le16 maxGlobalHSP;                    /*784h */
11409ab9ed38SChristoph Hellwig 	__le16 ddfSize;                         /*786h */
1141bc93d425SSumit.Saxena@lsi.com 	u8  maxLdsPerArray;                     /*788h */
1142bc93d425SSumit.Saxena@lsi.com 	u8  partitionsInDDF;                    /*789h */
1143bc93d425SSumit.Saxena@lsi.com 	u8  lockKeyBinding;                     /*78ah */
1144bc93d425SSumit.Saxena@lsi.com 	u8  maxPITsPerLd;                       /*78bh */
1145bc93d425SSumit.Saxena@lsi.com 	u8  maxViewsPerLd;                      /*78ch */
1146bc93d425SSumit.Saxena@lsi.com 	u8  maxTargetId;                        /*78dh */
11479ab9ed38SChristoph Hellwig 	__le16 maxBvlVdSize;                    /*78eh */
1148bc93d425SSumit.Saxena@lsi.com 
11499ab9ed38SChristoph Hellwig 	__le16 maxConfigurableSSCSize;          /*790h */
11509ab9ed38SChristoph Hellwig 	__le16 currentSSCsize;                  /*792h */
1151bc93d425SSumit.Saxena@lsi.com 
1152bc93d425SSumit.Saxena@lsi.com 	char    expanderFwVersion[12];          /*794h */
1153bc93d425SSumit.Saxena@lsi.com 
11549ab9ed38SChristoph Hellwig 	__le16 PFKTrialTimeRemaining;           /*7A0h */
1155bc93d425SSumit.Saxena@lsi.com 
11569ab9ed38SChristoph Hellwig 	__le16 cacheMemorySize;                 /*7A2h */
1157bc93d425SSumit.Saxena@lsi.com 
1158bc93d425SSumit.Saxena@lsi.com 	struct {                                /*7A4h */
115994cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
1160229fe47cSadam radford 		u32     reserved:5;
1161229fe47cSadam radford 		u32	activePassive:2;
1162229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1163229fe47cSadam radford 		u32	mpio:1;
1164229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1165229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
116694cd65ddSSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
116794cd65ddSSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
116894cd65ddSSumit.Saxena@lsi.com 		u32     headlessMode:1;
116994cd65ddSSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
117094cd65ddSSumit.Saxena@lsi.com 		u32     supportResetNow:1;
117194cd65ddSSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
117294cd65ddSSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
117394cd65ddSSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
117494cd65ddSSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
117594cd65ddSSumit.Saxena@lsi.com 		u32     supportJBOD:1;
117694cd65ddSSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
117794cd65ddSSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
117894cd65ddSSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
117994cd65ddSSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
118094cd65ddSSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
118194cd65ddSSumit.Saxena@lsi.com 		u32     supportShieldState:1;
118294cd65ddSSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
118394cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
118494cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
118594cd65ddSSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
118694cd65ddSSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
118794cd65ddSSumit.Saxena@lsi.com #else
1188bc93d425SSumit.Saxena@lsi.com 		u32     supportPIcontroller:1;
1189bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType1:1;
1190bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType2:1;
1191bc93d425SSumit.Saxena@lsi.com 		u32     supportLdPIType3:1;
1192bc93d425SSumit.Saxena@lsi.com 		u32     supportLdBBMInfo:1;
1193bc93d425SSumit.Saxena@lsi.com 		u32     supportShieldState:1;
1194bc93d425SSumit.Saxena@lsi.com 		u32     blockSSDWriteCacheChange:1;
1195bc93d425SSumit.Saxena@lsi.com 		u32     supportSuspendResumeBGops:1;
1196bc93d425SSumit.Saxena@lsi.com 		u32     supportEmergencySpares:1;
1197bc93d425SSumit.Saxena@lsi.com 		u32     supportSetLinkSpeed:1;
1198bc93d425SSumit.Saxena@lsi.com 		u32     supportBootTimePFKChange:1;
1199bc93d425SSumit.Saxena@lsi.com 		u32     supportJBOD:1;
1200bc93d425SSumit.Saxena@lsi.com 		u32     disableOnlinePFKChange:1;
1201bc93d425SSumit.Saxena@lsi.com 		u32     supportPerfTuning:1;
1202bc93d425SSumit.Saxena@lsi.com 		u32     supportSSDPatrolRead:1;
1203bc93d425SSumit.Saxena@lsi.com 		u32     realTimeScheduler:1;
1204bc93d425SSumit.Saxena@lsi.com 
1205bc93d425SSumit.Saxena@lsi.com 		u32     supportResetNow:1;
1206bc93d425SSumit.Saxena@lsi.com 		u32     supportEmulatedDrives:1;
1207bc93d425SSumit.Saxena@lsi.com 		u32     headlessMode:1;
1208bc93d425SSumit.Saxena@lsi.com 		u32     dedicatedHotSparesLimited:1;
1209bc93d425SSumit.Saxena@lsi.com 
1210bc93d425SSumit.Saxena@lsi.com 
1211bc93d425SSumit.Saxena@lsi.com 		u32     supportUnevenSpans:1;
1212229fe47cSadam radford 		u32	supportPointInTimeProgress:1;
1213229fe47cSadam radford 		u32	supportDataLDonSSCArray:1;
1214229fe47cSadam radford 		u32	mpio:1;
1215229fe47cSadam radford 		u32	supportConfigAutoBalance:1;
1216229fe47cSadam radford 		u32	activePassive:2;
1217229fe47cSadam radford 		u32     reserved:5;
121894cd65ddSSumit.Saxena@lsi.com #endif
1219bc93d425SSumit.Saxena@lsi.com 	} adapterOperations2;
1220bc93d425SSumit.Saxena@lsi.com 
1221bc93d425SSumit.Saxena@lsi.com 	u8  driverVersion[32];                  /*7A8h */
1222bc93d425SSumit.Saxena@lsi.com 	u8  maxDAPdCountSpinup60;               /*7C8h */
1223bc93d425SSumit.Saxena@lsi.com 	u8  temperatureROC;                     /*7C9h */
1224bc93d425SSumit.Saxena@lsi.com 	u8  temperatureCtrl;                    /*7CAh */
1225bc93d425SSumit.Saxena@lsi.com 	u8  reserved4;                          /*7CBh */
12269ab9ed38SChristoph Hellwig 	__le16 maxConfigurablePds;              /*7CCh */
1227bc93d425SSumit.Saxena@lsi.com 
1228bc93d425SSumit.Saxena@lsi.com 
1229bc93d425SSumit.Saxena@lsi.com 	u8  reserved5[2];                       /*0x7CDh */
1230bc93d425SSumit.Saxena@lsi.com 
1231bc93d425SSumit.Saxena@lsi.com 	/*
1232bc93d425SSumit.Saxena@lsi.com 	* HA cluster information
1233bc93d425SSumit.Saxena@lsi.com 	*/
1234bc93d425SSumit.Saxena@lsi.com 	struct {
123551087a86SSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
12368f67c8c5SSumit Saxena 		u32     reserved:25;
12378f67c8c5SSumit Saxena 		u32     passive:1;
123851087a86SSumit.Saxena@avagotech.com 		u32     premiumFeatureMismatch:1;
123951087a86SSumit.Saxena@avagotech.com 		u32     ctrlPropIncompatible:1;
124051087a86SSumit.Saxena@avagotech.com 		u32     fwVersionMismatch:1;
124151087a86SSumit.Saxena@avagotech.com 		u32     hwIncompatible:1;
124251087a86SSumit.Saxena@avagotech.com 		u32     peerIsIncompatible:1;
124351087a86SSumit.Saxena@avagotech.com 		u32     peerIsPresent:1;
124451087a86SSumit.Saxena@avagotech.com #else
1245bc93d425SSumit.Saxena@lsi.com 		u32     peerIsPresent:1;
1246bc93d425SSumit.Saxena@lsi.com 		u32     peerIsIncompatible:1;
1247bc93d425SSumit.Saxena@lsi.com 		u32     hwIncompatible:1;
1248bc93d425SSumit.Saxena@lsi.com 		u32     fwVersionMismatch:1;
1249bc93d425SSumit.Saxena@lsi.com 		u32     ctrlPropIncompatible:1;
1250bc93d425SSumit.Saxena@lsi.com 		u32     premiumFeatureMismatch:1;
12518f67c8c5SSumit Saxena 		u32     passive:1;
12528f67c8c5SSumit Saxena 		u32     reserved:25;
125351087a86SSumit.Saxena@avagotech.com #endif
1254bc93d425SSumit.Saxena@lsi.com 	} cluster;
1255bc93d425SSumit.Saxena@lsi.com 
12568f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE]; /*0x7D4 */
1257229fe47cSadam radford 	struct {
1258229fe47cSadam radford 		u8  maxVFsSupported;            /*0x7E4*/
1259229fe47cSadam radford 		u8  numVFsEnabled;              /*0x7E5*/
1260229fe47cSadam radford 		u8  requestorId;                /*0x7E6 0:PF, 1:VF1, 2:VF2*/
1261229fe47cSadam radford 		u8  reserved;                   /*0x7E7*/
1262229fe47cSadam radford 	} iov;
1263bc93d425SSumit.Saxena@lsi.com 
1264fc62b3fcSSumit.Saxena@avagotech.com 	struct {
1265fc62b3fcSSumit.Saxena@avagotech.com #if defined(__BIG_ENDIAN_BITFIELD)
12663761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
12673761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
12680be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
12690be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
12700be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
12710be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
12727497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
12737497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
12747497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
12757497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
12767497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
12777497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
12787497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
12797497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
12807497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
12817497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
12827497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
12837497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
12847497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
1285fc62b3fcSSumit.Saxena@avagotech.com 		u32     supportCrashDump:1;
128651087a86SSumit.Saxena@avagotech.com 		u32     supportMaxExtLDs:1;
128751087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
128851087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
128951087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
129051087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
1291fc62b3fcSSumit.Saxena@avagotech.com #else
129251087a86SSumit.Saxena@avagotech.com 		u32     supportPersonalityChange:2;
129351087a86SSumit.Saxena@avagotech.com 		u32     supportThermalPollInterval:1;
129451087a86SSumit.Saxena@avagotech.com 		u32     supportDisableImmediateIO:1;
129551087a86SSumit.Saxena@avagotech.com 		u32     supportT10RebuildAssist:1;
129651087a86SSumit.Saxena@avagotech.com 		u32	supportMaxExtLDs:1;
1297fc62b3fcSSumit.Saxena@avagotech.com 		u32	supportCrashDump:1;
12987497cde8SSumit.Saxena@avagotech.com 		u32     supportSwZone:1;
12997497cde8SSumit.Saxena@avagotech.com 		u32     supportDebugQueue:1;
13007497cde8SSumit.Saxena@avagotech.com 		u32     supportNVCacheErase:1;
13017497cde8SSumit.Saxena@avagotech.com 		u32     supportForceTo512e:1;
13027497cde8SSumit.Saxena@avagotech.com 		u32     supportHOQRebuild:1;
13037497cde8SSumit.Saxena@avagotech.com 		u32     supportAllowedOpsforDrvRemoval:1;
13047497cde8SSumit.Saxena@avagotech.com 		u32     supportDrvActivityLEDSetting:1;
13057497cde8SSumit.Saxena@avagotech.com 		u32     supportNVDRAM:1;
13067497cde8SSumit.Saxena@avagotech.com 		u32     supportForceFlash:1;
13077497cde8SSumit.Saxena@avagotech.com 		u32     supportDisableSESMonitoring:1;
13087497cde8SSumit.Saxena@avagotech.com 		u32     supportCacheBypassModes:1;
13097497cde8SSumit.Saxena@avagotech.com 		u32     supportSecurityonJBOD:1;
13107497cde8SSumit.Saxena@avagotech.com 		u32     discardCacheDuringLDDelete:1;
13110be3f4c9Ssumit.saxena@avagotech.com 		u32     supportTTYLogCompression:1;
13120be3f4c9Ssumit.saxena@avagotech.com 		u32     supportCPLDUpdate:1;
13130be3f4c9Ssumit.saxena@avagotech.com 		u32     supportDiskCacheSettingForSysPDs:1;
13140be3f4c9Ssumit.saxena@avagotech.com 		u32     supportExtendedSSCSize:1;
13153761cb4cSsumit.saxena@avagotech.com 		u32     useSeqNumJbodFP:1;
13163761cb4cSsumit.saxena@avagotech.com 		u32     reserved:7;
1317fc62b3fcSSumit.Saxena@avagotech.com #endif
1318fc62b3fcSSumit.Saxena@avagotech.com 	} adapterOperations3;
1319fc62b3fcSSumit.Saxena@avagotech.com 
1320fc62b3fcSSumit.Saxena@avagotech.com 	u8          pad[0x800-0x7EC];
132181e403ceSYang, Bo } __packed;
1322c4a3e0a5SBagalkote, Sreenivas 
1323c4a3e0a5SBagalkote, Sreenivas /*
1324c4a3e0a5SBagalkote, Sreenivas  * ===============================
1325c4a3e0a5SBagalkote, Sreenivas  * MegaRAID SAS driver definitions
1326c4a3e0a5SBagalkote, Sreenivas  * ===============================
1327c4a3e0a5SBagalkote, Sreenivas  */
1328c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_PD_CHANNELS			2
132951087a86SSumit.Saxena@avagotech.com #define MEGASAS_MAX_LD_CHANNELS			2
1330c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_CHANNELS			(MEGASAS_MAX_PD_CHANNELS + \
1331c4a3e0a5SBagalkote, Sreenivas 						MEGASAS_MAX_LD_CHANNELS)
1332c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_DEV_PER_CHANNEL		128
1333c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_DEFAULT_INIT_ID			-1
1334c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_MAX_LUN				8
13356bf579a3Sadam radford #define MEGASAS_DEFAULT_CMD_PER_LUN		256
133681e403ceSYang, Bo #define MEGASAS_MAX_PD                          (MEGASAS_MAX_PD_CHANNELS * \
133781e403ceSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1338bdc6fb8dSYang, Bo #define MEGASAS_MAX_LD_IDS			(MEGASAS_MAX_LD_CHANNELS * \
1339bdc6fb8dSYang, Bo 						MEGASAS_MAX_DEV_PER_CHANNEL)
1340c4a3e0a5SBagalkote, Sreenivas 
13411fd10685SYang, Bo #define MEGASAS_MAX_SECTORS                    (2*1024)
134242a8d2b3Sadam radford #define MEGASAS_MAX_SECTORS_IEEE		(2*128)
1343658dcedbSSumant Patro #define MEGASAS_DBG_LVL				1
1344658dcedbSSumant Patro 
134505e9ebbeSSumant Patro #define MEGASAS_FW_BUSY				1
134605e9ebbeSSumant Patro 
134751087a86SSumit.Saxena@avagotech.com #define VD_EXT_DEBUG 0
134851087a86SSumit.Saxena@avagotech.com 
134911c71cb4SSumit Saxena #define SCAN_PD_CHANNEL	0x1
135011c71cb4SSumit Saxena #define SCAN_VD_CHANNEL	0x2
135190dc9d98SSumit.Saxena@avagotech.com 
1352c3e385a1SSumit Saxena #define MEGASAS_KDUMP_QUEUE_DEPTH               100
1353c3e385a1SSumit Saxena 
13547497cde8SSumit.Saxena@avagotech.com enum MR_SCSI_CMD_TYPE {
13557497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_LDIO = 0,
13567497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_LDIO = 1,
13577497cde8SSumit.Saxena@avagotech.com 	READ_WRITE_SYSPDIO = 2,
13587497cde8SSumit.Saxena@avagotech.com 	NON_READ_WRITE_SYSPDIO = 3,
13597497cde8SSumit.Saxena@avagotech.com };
13607497cde8SSumit.Saxena@avagotech.com 
13616d40afbcSSumit Saxena enum DCMD_TIMEOUT_ACTION {
13626d40afbcSSumit Saxena 	INITIATE_OCR = 0,
13636d40afbcSSumit Saxena 	KILL_ADAPTER = 1,
13646d40afbcSSumit Saxena 	IGNORE_TIMEOUT = 2,
13656d40afbcSSumit Saxena };
1366308ec459SSumit Saxena 
1367308ec459SSumit Saxena enum FW_BOOT_CONTEXT {
1368308ec459SSumit Saxena 	PROBE_CONTEXT = 0,
1369308ec459SSumit Saxena 	OCR_CONTEXT = 1,
1370308ec459SSumit Saxena };
1371308ec459SSumit Saxena 
1372d532dbe2Sbo yang /* Frame Type */
1373d532dbe2Sbo yang #define IO_FRAME				0
1374d532dbe2Sbo yang #define PTHRU_FRAME				1
1375d532dbe2Sbo yang 
1376c4a3e0a5SBagalkote, Sreenivas /*
1377c4a3e0a5SBagalkote, Sreenivas  * When SCSI mid-layer calls driver's reset routine, driver waits for
1378c4a3e0a5SBagalkote, Sreenivas  * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
1379c4a3e0a5SBagalkote, Sreenivas  * that the driver cannot _actually_ abort or reset pending commands. While
1380c4a3e0a5SBagalkote, Sreenivas  * it is waiting for the commands to complete, it prints a diagnostic message
1381c4a3e0a5SBagalkote, Sreenivas  * every MEGASAS_RESET_NOTICE_INTERVAL seconds
1382c4a3e0a5SBagalkote, Sreenivas  */
1383c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_RESET_WAIT_TIME			180
13842a3681e5SSumant Patro #define MEGASAS_INTERNAL_CMD_WAIT_TIME		180
1385c4a3e0a5SBagalkote, Sreenivas #define	MEGASAS_RESET_NOTICE_INTERVAL		5
1386c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOCTL_CMD			0
138705e9ebbeSSumant Patro #define MEGASAS_DEFAULT_CMD_TIMEOUT		90
1388c5daa6a9Sadam radford #define MEGASAS_THROTTLE_QUEUE_DEPTH		16
138990dc9d98SSumit.Saxena@avagotech.com #define MEGASAS_BLOCKED_CMD_TIMEOUT		60
1390c4a3e0a5SBagalkote, Sreenivas /*
1391c4a3e0a5SBagalkote, Sreenivas  * FW reports the maximum of number of commands that it can accept (maximum
1392c4a3e0a5SBagalkote, Sreenivas  * commands that can be outstanding) at any time. The driver must report a
1393c4a3e0a5SBagalkote, Sreenivas  * lower number to the mid layer because it can issue a few internal commands
1394c4a3e0a5SBagalkote, Sreenivas  * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
1395c4a3e0a5SBagalkote, Sreenivas  * is shown below
1396c4a3e0a5SBagalkote, Sreenivas  */
1397c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_INT_CMDS			32
13987bebf5c7SYang, Bo #define MEGASAS_SKINNY_INT_CMDS			5
1399ae09a6c1SSumit.Saxena@avagotech.com #define MEGASAS_FUSION_INTERNAL_CMDS		5
1400ae09a6c1SSumit.Saxena@avagotech.com #define MEGASAS_FUSION_IOCTL_CMDS		3
1401f26ac3a1SSumit.Saxena@avagotech.com #define MEGASAS_MFI_IOCTL_CMDS			27
1402c4a3e0a5SBagalkote, Sreenivas 
1403d46a3ad6SSumit.Saxena@lsi.com #define MEGASAS_MAX_MSIX_QUEUES			128
1404c4a3e0a5SBagalkote, Sreenivas /*
1405c4a3e0a5SBagalkote, Sreenivas  * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
1406c4a3e0a5SBagalkote, Sreenivas  * SGLs based on the size of dma_addr_t
1407c4a3e0a5SBagalkote, Sreenivas  */
1408c4a3e0a5SBagalkote, Sreenivas #define IS_DMA64				(sizeof(dma_addr_t) == 8)
1409c4a3e0a5SBagalkote, Sreenivas 
141039a98554Sbo yang #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT		0x00000001
141139a98554Sbo yang 
141239a98554Sbo yang #define MFI_INTR_FLAG_REPLY_MESSAGE			0x00000001
141339a98554Sbo yang #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE		0x00000002
141439a98554Sbo yang #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT	0x00000004
141539a98554Sbo yang 
1416c4a3e0a5SBagalkote, Sreenivas #define MFI_OB_INTR_STATUS_MASK			0x00000002
141714faea9fSbo yang #define MFI_POLL_TIMEOUT_SECS			60
14186d40afbcSSumit Saxena #define MFI_IO_TIMEOUT_SECS			180
1419229fe47cSadam radford #define MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF	(5 * HZ)
1420229fe47cSadam radford #define MEGASAS_OCR_SETTLE_TIME_VF		(1000 * 30)
1421229fe47cSadam radford #define MEGASAS_ROUTINE_WAIT_TIME_VF		300
1422f9876f0bSSumant Patro #define MFI_REPLY_1078_MESSAGE_INTERRUPT	0x80000000
14236610a6b3SYang, Bo #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT	0x00000001
14246610a6b3SYang, Bo #define MFI_GEN2_ENABLE_INTERRUPT_MASK		(0x00000001 | 0x00000004)
142587911122SYang, Bo #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT	0x40000000
142687911122SYang, Bo #define MFI_SKINNY_ENABLE_INTERRUPT_MASK	(0x00000001)
14270e98936cSSumant Patro 
142839a98554Sbo yang #define MFI_1068_PCSR_OFFSET			0x84
142939a98554Sbo yang #define MFI_1068_FW_HANDSHAKE_OFFSET		0x64
143039a98554Sbo yang #define MFI_1068_FW_READY			0xDDDD0000
1431d46a3ad6SSumit.Saxena@lsi.com 
1432d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_OFFSET              0X0000001F
1433d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET          0X003FC000
1434d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT    14
1435d46a3ad6SSumit.Saxena@lsi.com #define MR_MAX_MSIX_REG_ARRAY                   16
1436179ac142SSumit Saxena #define MR_RDPQ_MODE_OFFSET			0X00800000
1437d0fc91d6SKashyap Desai #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000
1438d0fc91d6SKashyap Desai 
14390e98936cSSumant Patro /*
14400e98936cSSumant Patro * register set for both 1068 and 1078 controllers
14410e98936cSSumant Patro * structure extended for 1078 registers
14420e98936cSSumant Patro */
1443c4a3e0a5SBagalkote, Sreenivas 
1444f9876f0bSSumant Patro struct megasas_register_set {
14459c915a8cSadam radford 	u32	doorbell;                       /*0000h*/
14469c915a8cSadam radford 	u32	fusion_seq_offset;		/*0004h*/
14479c915a8cSadam radford 	u32	fusion_host_diag;		/*0008h*/
14489c915a8cSadam radford 	u32	reserved_01;			/*000Ch*/
1449c4a3e0a5SBagalkote, Sreenivas 
1450c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_0;			/*0010h*/
1451c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_msg_1;			/*0014h*/
1452c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_0;			/*0018h*/
1453c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_msg_1;			/*001Ch*/
1454c4a3e0a5SBagalkote, Sreenivas 
1455c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_doorbell;		/*0020h*/
1456c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_status;		/*0024h*/
1457c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_intr_mask;		/*0028h*/
1458c4a3e0a5SBagalkote, Sreenivas 
1459c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_doorbell;		/*002Ch*/
1460c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_status;		/*0030h*/
1461c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_intr_mask;		/*0034h*/
1462c4a3e0a5SBagalkote, Sreenivas 
1463c4a3e0a5SBagalkote, Sreenivas 	u32 	reserved_1[2];			/*0038h*/
1464c4a3e0a5SBagalkote, Sreenivas 
1465c4a3e0a5SBagalkote, Sreenivas 	u32 	inbound_queue_port;		/*0040h*/
1466c4a3e0a5SBagalkote, Sreenivas 	u32 	outbound_queue_port;		/*0044h*/
1467c4a3e0a5SBagalkote, Sreenivas 
14689c915a8cSadam radford 	u32	reserved_2[9];			/*0048h*/
14699c915a8cSadam radford 	u32	reply_post_host_index;		/*006Ch*/
14709c915a8cSadam radford 	u32	reserved_2_2[12];		/*0070h*/
1471c4a3e0a5SBagalkote, Sreenivas 
1472f9876f0bSSumant Patro 	u32 	outbound_doorbell_clear;	/*00A0h*/
1473f9876f0bSSumant Patro 
1474f9876f0bSSumant Patro 	u32 	reserved_3[3];			/*00A4h*/
1475f9876f0bSSumant Patro 
1476f9876f0bSSumant Patro 	u32 	outbound_scratch_pad ;		/*00B0h*/
14779c915a8cSadam radford 	u32	outbound_scratch_pad_2;         /*00B4h*/
1478179ac142SSumit Saxena 	u32	outbound_scratch_pad_3;         /*00B8h*/
1479f9876f0bSSumant Patro 
1480179ac142SSumit Saxena 	u32	reserved_4;			/*00BCh*/
1481f9876f0bSSumant Patro 
1482f9876f0bSSumant Patro 	u32 	inbound_low_queue_port ;	/*00C0h*/
1483f9876f0bSSumant Patro 
1484f9876f0bSSumant Patro 	u32 	inbound_high_queue_port ;	/*00C4h*/
1485f9876f0bSSumant Patro 
148645f4f2ebSSasikumar Chandrasekaran 	u32 inbound_single_queue_port;	/*00C8h*/
148739a98554Sbo yang 	u32	res_6[11];			/*CCh*/
148839a98554Sbo yang 	u32	host_diag;
148939a98554Sbo yang 	u32	seq_offset;
149039a98554Sbo yang 	u32 	index_registers[807];		/*00CCh*/
1491c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1492c4a3e0a5SBagalkote, Sreenivas 
1493c4a3e0a5SBagalkote, Sreenivas struct megasas_sge32 {
1494c4a3e0a5SBagalkote, Sreenivas 
14959ab9ed38SChristoph Hellwig 	__le32 phys_addr;
14969ab9ed38SChristoph Hellwig 	__le32 length;
1497c4a3e0a5SBagalkote, Sreenivas 
1498c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1499c4a3e0a5SBagalkote, Sreenivas 
1500c4a3e0a5SBagalkote, Sreenivas struct megasas_sge64 {
1501c4a3e0a5SBagalkote, Sreenivas 
15029ab9ed38SChristoph Hellwig 	__le64 phys_addr;
15039ab9ed38SChristoph Hellwig 	__le32 length;
1504c4a3e0a5SBagalkote, Sreenivas 
1505c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1506c4a3e0a5SBagalkote, Sreenivas 
1507f4c9a131SYang, Bo struct megasas_sge_skinny {
15089ab9ed38SChristoph Hellwig 	__le64 phys_addr;
15099ab9ed38SChristoph Hellwig 	__le32 length;
15109ab9ed38SChristoph Hellwig 	__le32 flag;
1511f4c9a131SYang, Bo } __packed;
1512f4c9a131SYang, Bo 
1513c4a3e0a5SBagalkote, Sreenivas union megasas_sgl {
1514c4a3e0a5SBagalkote, Sreenivas 
1515c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[1];
1516c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[1];
1517f4c9a131SYang, Bo 	struct megasas_sge_skinny sge_skinny[1];
1518c4a3e0a5SBagalkote, Sreenivas 
1519c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1520c4a3e0a5SBagalkote, Sreenivas 
1521c4a3e0a5SBagalkote, Sreenivas struct megasas_header {
1522c4a3e0a5SBagalkote, Sreenivas 
1523c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1524c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1525c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1526c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1527c4a3e0a5SBagalkote, Sreenivas 
1528c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1529c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1530c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1531c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1532c4a3e0a5SBagalkote, Sreenivas 
15339ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
15349ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1535c4a3e0a5SBagalkote, Sreenivas 
15369ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
15379ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
15389ab9ed38SChristoph Hellwig 	__le32 data_xferlen;	/*14h */
1539c4a3e0a5SBagalkote, Sreenivas 
1540c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1541c4a3e0a5SBagalkote, Sreenivas 
1542c4a3e0a5SBagalkote, Sreenivas union megasas_sgl_frame {
1543c4a3e0a5SBagalkote, Sreenivas 
1544c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge32 sge32[8];
1545c4a3e0a5SBagalkote, Sreenivas 	struct megasas_sge64 sge64[5];
1546c4a3e0a5SBagalkote, Sreenivas 
1547c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1548c4a3e0a5SBagalkote, Sreenivas 
1549d46a3ad6SSumit.Saxena@lsi.com typedef union _MFI_CAPABILITIES {
1550d46a3ad6SSumit.Saxena@lsi.com 	struct {
155194cd65ddSSumit.Saxena@lsi.com #if   defined(__BIG_ENDIAN_BITFIELD)
155252b62ac7SSumit Saxena 		u32     reserved:20;
155352b62ac7SSumit Saxena 		u32     support_qd_throttling:1;
15548f05024cSSumit Saxena 		u32     support_fp_rlbypass:1;
15558f05024cSSumit Saxena 		u32     support_vfid_in_ioframe:1;
1556bd5f9484Ssumit.saxena@avagotech.com 		u32     support_ext_io_size:1;
15570be3f4c9Ssumit.saxena@avagotech.com 		u32	support_ext_queue_depth:1;
15587497cde8SSumit.Saxena@avagotech.com 		u32     security_protocol_cmds_fw:1;
15597497cde8SSumit.Saxena@avagotech.com 		u32     support_core_affinity:1;
1560d2552ebeSSumit.Saxena@avagotech.com 		u32     support_ndrive_r1_lb:1;
156151087a86SSumit.Saxena@avagotech.com 		u32	support_max_255lds:1;
15627497cde8SSumit.Saxena@avagotech.com 		u32	support_fastpath_wb:1;
156394cd65ddSSumit.Saxena@lsi.com 		u32     support_additional_msix:1;
156494cd65ddSSumit.Saxena@lsi.com 		u32     support_fp_remote_lun:1;
156594cd65ddSSumit.Saxena@lsi.com #else
1566d46a3ad6SSumit.Saxena@lsi.com 		u32     support_fp_remote_lun:1;
1567d46a3ad6SSumit.Saxena@lsi.com 		u32     support_additional_msix:1;
15687497cde8SSumit.Saxena@avagotech.com 		u32	support_fastpath_wb:1;
156951087a86SSumit.Saxena@avagotech.com 		u32	support_max_255lds:1;
1570d2552ebeSSumit.Saxena@avagotech.com 		u32     support_ndrive_r1_lb:1;
15717497cde8SSumit.Saxena@avagotech.com 		u32     support_core_affinity:1;
15727497cde8SSumit.Saxena@avagotech.com 		u32     security_protocol_cmds_fw:1;
15730be3f4c9Ssumit.saxena@avagotech.com 		u32	support_ext_queue_depth:1;
1574bd5f9484Ssumit.saxena@avagotech.com 		u32     support_ext_io_size:1;
15758f05024cSSumit Saxena 		u32     support_vfid_in_ioframe:1;
15768f05024cSSumit Saxena 		u32     support_fp_rlbypass:1;
157752b62ac7SSumit Saxena 		u32     support_qd_throttling:1;
157852b62ac7SSumit Saxena 		u32     reserved:20;
157994cd65ddSSumit.Saxena@lsi.com #endif
1580d46a3ad6SSumit.Saxena@lsi.com 	} mfi_capabilities;
15819ab9ed38SChristoph Hellwig 	__le32		reg;
1582d46a3ad6SSumit.Saxena@lsi.com } MFI_CAPABILITIES;
1583d46a3ad6SSumit.Saxena@lsi.com 
1584c4a3e0a5SBagalkote, Sreenivas struct megasas_init_frame {
1585c4a3e0a5SBagalkote, Sreenivas 
1586c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1587c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1588c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1589c4a3e0a5SBagalkote, Sreenivas 
1590c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
1591d46a3ad6SSumit.Saxena@lsi.com 	MFI_CAPABILITIES driver_operations; /*04h*/
1592c4a3e0a5SBagalkote, Sreenivas 
15939ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
15949ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1595c4a3e0a5SBagalkote, Sreenivas 
15969ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
15979ab9ed38SChristoph Hellwig 	__le16 reserved_3;		/*12h */
15989ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1599c4a3e0a5SBagalkote, Sreenivas 
16009ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_lo;	/*18h */
16019ab9ed38SChristoph Hellwig 	__le32 queue_info_new_phys_addr_hi;	/*1Ch */
16029ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_lo;	/*20h */
16039ab9ed38SChristoph Hellwig 	__le32 queue_info_old_phys_addr_hi;	/*24h */
16049ab9ed38SChristoph Hellwig 	__le32 reserved_4[2];	/*28h */
16059ab9ed38SChristoph Hellwig 	__le32 system_info_lo;      /*30h */
16069ab9ed38SChristoph Hellwig 	__le32 system_info_hi;      /*34h */
16079ab9ed38SChristoph Hellwig 	__le32 reserved_5[2];	/*38h */
1608c4a3e0a5SBagalkote, Sreenivas 
1609c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1610c4a3e0a5SBagalkote, Sreenivas 
1611c4a3e0a5SBagalkote, Sreenivas struct megasas_init_queue_info {
1612c4a3e0a5SBagalkote, Sreenivas 
16139ab9ed38SChristoph Hellwig 	__le32 init_flags;		/*00h */
16149ab9ed38SChristoph Hellwig 	__le32 reply_queue_entries;	/*04h */
1615c4a3e0a5SBagalkote, Sreenivas 
16169ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_lo;	/*08h */
16179ab9ed38SChristoph Hellwig 	__le32 reply_queue_start_phys_addr_hi;	/*0Ch */
16189ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_lo;	/*10h */
16199ab9ed38SChristoph Hellwig 	__le32 producer_index_phys_addr_hi;	/*14h */
16209ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_lo;	/*18h */
16219ab9ed38SChristoph Hellwig 	__le32 consumer_index_phys_addr_hi;	/*1Ch */
1622c4a3e0a5SBagalkote, Sreenivas 
1623c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1624c4a3e0a5SBagalkote, Sreenivas 
1625c4a3e0a5SBagalkote, Sreenivas struct megasas_io_frame {
1626c4a3e0a5SBagalkote, Sreenivas 
1627c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1628c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1629c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1630c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1631c4a3e0a5SBagalkote, Sreenivas 
1632c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1633c4a3e0a5SBagalkote, Sreenivas 	u8 access_byte;		/*05h */
1634c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*06h */
1635c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1636c4a3e0a5SBagalkote, Sreenivas 
16379ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
16389ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1639c4a3e0a5SBagalkote, Sreenivas 
16409ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
16419ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
16429ab9ed38SChristoph Hellwig 	__le32 lba_count;	/*14h */
1643c4a3e0a5SBagalkote, Sreenivas 
16449ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
16459ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1646c4a3e0a5SBagalkote, Sreenivas 
16479ab9ed38SChristoph Hellwig 	__le32 start_lba_lo;	/*20h */
16489ab9ed38SChristoph Hellwig 	__le32 start_lba_hi;	/*24h */
1649c4a3e0a5SBagalkote, Sreenivas 
1650c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1651c4a3e0a5SBagalkote, Sreenivas 
1652c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1653c4a3e0a5SBagalkote, Sreenivas 
1654c4a3e0a5SBagalkote, Sreenivas struct megasas_pthru_frame {
1655c4a3e0a5SBagalkote, Sreenivas 
1656c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1657c4a3e0a5SBagalkote, Sreenivas 	u8 sense_len;		/*01h */
1658c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1659c4a3e0a5SBagalkote, Sreenivas 	u8 scsi_status;		/*03h */
1660c4a3e0a5SBagalkote, Sreenivas 
1661c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1662c4a3e0a5SBagalkote, Sreenivas 	u8 lun;			/*05h */
1663c4a3e0a5SBagalkote, Sreenivas 	u8 cdb_len;		/*06h */
1664c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1665c4a3e0a5SBagalkote, Sreenivas 
16669ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
16679ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1668c4a3e0a5SBagalkote, Sreenivas 
16699ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
16709ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
16719ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1672c4a3e0a5SBagalkote, Sreenivas 
16739ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_lo;	/*18h */
16749ab9ed38SChristoph Hellwig 	__le32 sense_buf_phys_addr_hi;	/*1Ch */
1675c4a3e0a5SBagalkote, Sreenivas 
1676c4a3e0a5SBagalkote, Sreenivas 	u8 cdb[16];		/*20h */
1677c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*30h */
1678c4a3e0a5SBagalkote, Sreenivas 
1679c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1680c4a3e0a5SBagalkote, Sreenivas 
1681c4a3e0a5SBagalkote, Sreenivas struct megasas_dcmd_frame {
1682c4a3e0a5SBagalkote, Sreenivas 
1683c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1684c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1685c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1686c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1[4];	/*03h */
1687c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1688c4a3e0a5SBagalkote, Sreenivas 
16899ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
16909ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1691c4a3e0a5SBagalkote, Sreenivas 
16929ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
16939ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1694c4a3e0a5SBagalkote, Sreenivas 
16959ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
16969ab9ed38SChristoph Hellwig 	__le32 opcode;		/*18h */
1697c4a3e0a5SBagalkote, Sreenivas 
1698c4a3e0a5SBagalkote, Sreenivas 	union {			/*1Ch */
1699c4a3e0a5SBagalkote, Sreenivas 		u8 b[12];
17009ab9ed38SChristoph Hellwig 		__le16 s[6];
17019ab9ed38SChristoph Hellwig 		__le32 w[3];
1702c4a3e0a5SBagalkote, Sreenivas 	} mbox;
1703c4a3e0a5SBagalkote, Sreenivas 
1704c4a3e0a5SBagalkote, Sreenivas 	union megasas_sgl sgl;	/*28h */
1705c4a3e0a5SBagalkote, Sreenivas 
1706c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1707c4a3e0a5SBagalkote, Sreenivas 
1708c4a3e0a5SBagalkote, Sreenivas struct megasas_abort_frame {
1709c4a3e0a5SBagalkote, Sreenivas 
1710c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1711c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_0;		/*01h */
1712c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1713c4a3e0a5SBagalkote, Sreenivas 
1714c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*03h */
17159ab9ed38SChristoph Hellwig 	__le32 reserved_2;	/*04h */
1716c4a3e0a5SBagalkote, Sreenivas 
17179ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17189ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1719c4a3e0a5SBagalkote, Sreenivas 
17209ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17219ab9ed38SChristoph Hellwig 	__le16 reserved_3;	/*12h */
17229ab9ed38SChristoph Hellwig 	__le32 reserved_4;	/*14h */
1723c4a3e0a5SBagalkote, Sreenivas 
17249ab9ed38SChristoph Hellwig 	__le32 abort_context;	/*18h */
17259ab9ed38SChristoph Hellwig 	__le32 pad_1;		/*1Ch */
1726c4a3e0a5SBagalkote, Sreenivas 
17279ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_lo;	/*20h */
17289ab9ed38SChristoph Hellwig 	__le32 abort_mfi_phys_addr_hi;	/*24h */
1729c4a3e0a5SBagalkote, Sreenivas 
17309ab9ed38SChristoph Hellwig 	__le32 reserved_5[6];	/*28h */
1731c4a3e0a5SBagalkote, Sreenivas 
1732c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1733c4a3e0a5SBagalkote, Sreenivas 
1734c4a3e0a5SBagalkote, Sreenivas struct megasas_smp_frame {
1735c4a3e0a5SBagalkote, Sreenivas 
1736c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1737c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1738c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1739c4a3e0a5SBagalkote, Sreenivas 	u8 connection_status;	/*03h */
1740c4a3e0a5SBagalkote, Sreenivas 
1741c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2[3];	/*04h */
1742c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1743c4a3e0a5SBagalkote, Sreenivas 
17449ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17459ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1746c4a3e0a5SBagalkote, Sreenivas 
17479ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17489ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1749c4a3e0a5SBagalkote, Sreenivas 
17509ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
17519ab9ed38SChristoph Hellwig 	__le64 sas_addr;	/*18h */
1752c4a3e0a5SBagalkote, Sreenivas 
1753c4a3e0a5SBagalkote, Sreenivas 	union {
1754c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: req */
1755c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: req */
1756c4a3e0a5SBagalkote, Sreenivas 	} sgl;
1757c4a3e0a5SBagalkote, Sreenivas 
1758c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1759c4a3e0a5SBagalkote, Sreenivas 
1760c4a3e0a5SBagalkote, Sreenivas struct megasas_stp_frame {
1761c4a3e0a5SBagalkote, Sreenivas 
1762c4a3e0a5SBagalkote, Sreenivas 	u8 cmd;			/*00h */
1763c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_1;		/*01h */
1764c4a3e0a5SBagalkote, Sreenivas 	u8 cmd_status;		/*02h */
1765c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_2;		/*03h */
1766c4a3e0a5SBagalkote, Sreenivas 
1767c4a3e0a5SBagalkote, Sreenivas 	u8 target_id;		/*04h */
1768c4a3e0a5SBagalkote, Sreenivas 	u8 reserved_3[2];	/*05h */
1769c4a3e0a5SBagalkote, Sreenivas 	u8 sge_count;		/*07h */
1770c4a3e0a5SBagalkote, Sreenivas 
17719ab9ed38SChristoph Hellwig 	__le32 context;		/*08h */
17729ab9ed38SChristoph Hellwig 	__le32 pad_0;		/*0Ch */
1773c4a3e0a5SBagalkote, Sreenivas 
17749ab9ed38SChristoph Hellwig 	__le16 flags;		/*10h */
17759ab9ed38SChristoph Hellwig 	__le16 timeout;		/*12h */
1776c4a3e0a5SBagalkote, Sreenivas 
17779ab9ed38SChristoph Hellwig 	__le32 data_xfer_len;	/*14h */
1778c4a3e0a5SBagalkote, Sreenivas 
17799ab9ed38SChristoph Hellwig 	__le16 fis[10];		/*18h */
17809ab9ed38SChristoph Hellwig 	__le32 stp_flags;
1781c4a3e0a5SBagalkote, Sreenivas 
1782c4a3e0a5SBagalkote, Sreenivas 	union {
1783c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: data */
1784c4a3e0a5SBagalkote, Sreenivas 		struct megasas_sge64 sge64[2];	/* [0]: resp [1]: data */
1785c4a3e0a5SBagalkote, Sreenivas 	} sgl;
1786c4a3e0a5SBagalkote, Sreenivas 
1787c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1788c4a3e0a5SBagalkote, Sreenivas 
1789c4a3e0a5SBagalkote, Sreenivas union megasas_frame {
1790c4a3e0a5SBagalkote, Sreenivas 
1791c4a3e0a5SBagalkote, Sreenivas 	struct megasas_header hdr;
1792c4a3e0a5SBagalkote, Sreenivas 	struct megasas_init_frame init;
1793c4a3e0a5SBagalkote, Sreenivas 	struct megasas_io_frame io;
1794c4a3e0a5SBagalkote, Sreenivas 	struct megasas_pthru_frame pthru;
1795c4a3e0a5SBagalkote, Sreenivas 	struct megasas_dcmd_frame dcmd;
1796c4a3e0a5SBagalkote, Sreenivas 	struct megasas_abort_frame abort;
1797c4a3e0a5SBagalkote, Sreenivas 	struct megasas_smp_frame smp;
1798c4a3e0a5SBagalkote, Sreenivas 	struct megasas_stp_frame stp;
1799c4a3e0a5SBagalkote, Sreenivas 
1800c4a3e0a5SBagalkote, Sreenivas 	u8 raw_bytes[64];
1801c4a3e0a5SBagalkote, Sreenivas };
1802c4a3e0a5SBagalkote, Sreenivas 
180318365b13SSumit Saxena /**
180418365b13SSumit Saxena  * struct MR_PRIV_DEVICE - sdev private hostdata
180518365b13SSumit Saxena  * @is_tm_capable: firmware managed tm_capable flag
180618365b13SSumit Saxena  * @tm_busy: TM request is in progress
180718365b13SSumit Saxena  */
180818365b13SSumit Saxena struct MR_PRIV_DEVICE {
180918365b13SSumit Saxena 	bool is_tm_capable;
181018365b13SSumit Saxena 	bool tm_busy;
181118365b13SSumit Saxena };
1812c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd;
1813c4a3e0a5SBagalkote, Sreenivas 
1814c4a3e0a5SBagalkote, Sreenivas union megasas_evt_class_locale {
1815c4a3e0a5SBagalkote, Sreenivas 
1816c4a3e0a5SBagalkote, Sreenivas 	struct {
1817be26374bSSumit.Saxena@lsi.com #ifndef __BIG_ENDIAN_BITFIELD
1818c4a3e0a5SBagalkote, Sreenivas 		u16 locale;
1819c4a3e0a5SBagalkote, Sreenivas 		u8 reserved;
1820c4a3e0a5SBagalkote, Sreenivas 		s8 class;
1821be26374bSSumit.Saxena@lsi.com #else
1822be26374bSSumit.Saxena@lsi.com 		s8 class;
1823be26374bSSumit.Saxena@lsi.com 		u8 reserved;
1824be26374bSSumit.Saxena@lsi.com 		u16 locale;
1825be26374bSSumit.Saxena@lsi.com #endif
1826c4a3e0a5SBagalkote, Sreenivas 	} __attribute__ ((packed)) members;
1827c4a3e0a5SBagalkote, Sreenivas 
1828c4a3e0a5SBagalkote, Sreenivas 	u32 word;
1829c4a3e0a5SBagalkote, Sreenivas 
1830c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1831c4a3e0a5SBagalkote, Sreenivas 
1832c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_log_info {
18339ab9ed38SChristoph Hellwig 	__le32 newest_seq_num;
18349ab9ed38SChristoph Hellwig 	__le32 oldest_seq_num;
18359ab9ed38SChristoph Hellwig 	__le32 clear_seq_num;
18369ab9ed38SChristoph Hellwig 	__le32 shutdown_seq_num;
18379ab9ed38SChristoph Hellwig 	__le32 boot_seq_num;
1838c4a3e0a5SBagalkote, Sreenivas 
1839c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1840c4a3e0a5SBagalkote, Sreenivas 
1841c4a3e0a5SBagalkote, Sreenivas struct megasas_progress {
1842c4a3e0a5SBagalkote, Sreenivas 
18439ab9ed38SChristoph Hellwig 	__le16 progress;
18449ab9ed38SChristoph Hellwig 	__le16 elapsed_seconds;
1845c4a3e0a5SBagalkote, Sreenivas 
1846c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1847c4a3e0a5SBagalkote, Sreenivas 
1848c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_ld {
1849c4a3e0a5SBagalkote, Sreenivas 
1850c4a3e0a5SBagalkote, Sreenivas 	u16 target_id;
1851c4a3e0a5SBagalkote, Sreenivas 	u8 ld_index;
1852c4a3e0a5SBagalkote, Sreenivas 	u8 reserved;
1853c4a3e0a5SBagalkote, Sreenivas 
1854c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1855c4a3e0a5SBagalkote, Sreenivas 
1856c4a3e0a5SBagalkote, Sreenivas struct megasas_evtarg_pd {
1857c4a3e0a5SBagalkote, Sreenivas 	u16 device_id;
1858c4a3e0a5SBagalkote, Sreenivas 	u8 encl_index;
1859c4a3e0a5SBagalkote, Sreenivas 	u8 slot_number;
1860c4a3e0a5SBagalkote, Sreenivas 
1861c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1862c4a3e0a5SBagalkote, Sreenivas 
1863c4a3e0a5SBagalkote, Sreenivas struct megasas_evt_detail {
1864c4a3e0a5SBagalkote, Sreenivas 
18659ab9ed38SChristoph Hellwig 	__le32 seq_num;
18669ab9ed38SChristoph Hellwig 	__le32 time_stamp;
18679ab9ed38SChristoph Hellwig 	__le32 code;
1868c4a3e0a5SBagalkote, Sreenivas 	union megasas_evt_class_locale cl;
1869c4a3e0a5SBagalkote, Sreenivas 	u8 arg_type;
1870c4a3e0a5SBagalkote, Sreenivas 	u8 reserved1[15];
1871c4a3e0a5SBagalkote, Sreenivas 
1872c4a3e0a5SBagalkote, Sreenivas 	union {
1873c4a3e0a5SBagalkote, Sreenivas 		struct {
1874c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1875c4a3e0a5SBagalkote, Sreenivas 			u8 cdb_length;
1876c4a3e0a5SBagalkote, Sreenivas 			u8 sense_length;
1877c4a3e0a5SBagalkote, Sreenivas 			u8 reserved[2];
1878c4a3e0a5SBagalkote, Sreenivas 			u8 cdb[16];
1879c4a3e0a5SBagalkote, Sreenivas 			u8 sense[64];
1880c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) cdbSense;
1881c4a3e0a5SBagalkote, Sreenivas 
1882c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_ld ld;
1883c4a3e0a5SBagalkote, Sreenivas 
1884c4a3e0a5SBagalkote, Sreenivas 		struct {
1885c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
18869ab9ed38SChristoph Hellwig 			__le64 count;
1887c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_count;
1888c4a3e0a5SBagalkote, Sreenivas 
1889c4a3e0a5SBagalkote, Sreenivas 		struct {
18909ab9ed38SChristoph Hellwig 			__le64 lba;
1891c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1892c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba;
1893c4a3e0a5SBagalkote, Sreenivas 
1894c4a3e0a5SBagalkote, Sreenivas 		struct {
1895c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
18969ab9ed38SChristoph Hellwig 			__le32 prevOwner;
18979ab9ed38SChristoph Hellwig 			__le32 newOwner;
1898c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_owner;
1899c4a3e0a5SBagalkote, Sreenivas 
1900c4a3e0a5SBagalkote, Sreenivas 		struct {
1901c4a3e0a5SBagalkote, Sreenivas 			u64 ld_lba;
1902c4a3e0a5SBagalkote, Sreenivas 			u64 pd_lba;
1903c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1904c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1905c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_lba_pd_lba;
1906c4a3e0a5SBagalkote, Sreenivas 
1907c4a3e0a5SBagalkote, Sreenivas 		struct {
1908c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1909c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
1910c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_prog;
1911c4a3e0a5SBagalkote, Sreenivas 
1912c4a3e0a5SBagalkote, Sreenivas 		struct {
1913c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1914c4a3e0a5SBagalkote, Sreenivas 			u32 prev_state;
1915c4a3e0a5SBagalkote, Sreenivas 			u32 new_state;
1916c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_state;
1917c4a3e0a5SBagalkote, Sreenivas 
1918c4a3e0a5SBagalkote, Sreenivas 		struct {
1919c4a3e0a5SBagalkote, Sreenivas 			u64 strip;
1920c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1921c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ld_strip;
1922c4a3e0a5SBagalkote, Sreenivas 
1923c4a3e0a5SBagalkote, Sreenivas 		struct megasas_evtarg_pd pd;
1924c4a3e0a5SBagalkote, Sreenivas 
1925c4a3e0a5SBagalkote, Sreenivas 		struct {
1926c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1927c4a3e0a5SBagalkote, Sreenivas 			u32 err;
1928c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_err;
1929c4a3e0a5SBagalkote, Sreenivas 
1930c4a3e0a5SBagalkote, Sreenivas 		struct {
1931c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
1932c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1933c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba;
1934c4a3e0a5SBagalkote, Sreenivas 
1935c4a3e0a5SBagalkote, Sreenivas 		struct {
1936c4a3e0a5SBagalkote, Sreenivas 			u64 lba;
1937c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1938c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_ld ld;
1939c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_lba_ld;
1940c4a3e0a5SBagalkote, Sreenivas 
1941c4a3e0a5SBagalkote, Sreenivas 		struct {
1942c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1943c4a3e0a5SBagalkote, Sreenivas 			struct megasas_progress prog;
1944c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_prog;
1945c4a3e0a5SBagalkote, Sreenivas 
1946c4a3e0a5SBagalkote, Sreenivas 		struct {
1947c4a3e0a5SBagalkote, Sreenivas 			struct megasas_evtarg_pd pd;
1948c4a3e0a5SBagalkote, Sreenivas 			u32 prevState;
1949c4a3e0a5SBagalkote, Sreenivas 			u32 newState;
1950c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pd_state;
1951c4a3e0a5SBagalkote, Sreenivas 
1952c4a3e0a5SBagalkote, Sreenivas 		struct {
1953c4a3e0a5SBagalkote, Sreenivas 			u16 vendorId;
19549ab9ed38SChristoph Hellwig 			__le16 deviceId;
1955c4a3e0a5SBagalkote, Sreenivas 			u16 subVendorId;
1956c4a3e0a5SBagalkote, Sreenivas 			u16 subDeviceId;
1957c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) pci;
1958c4a3e0a5SBagalkote, Sreenivas 
1959c4a3e0a5SBagalkote, Sreenivas 		u32 rate;
1960c4a3e0a5SBagalkote, Sreenivas 		char str[96];
1961c4a3e0a5SBagalkote, Sreenivas 
1962c4a3e0a5SBagalkote, Sreenivas 		struct {
1963c4a3e0a5SBagalkote, Sreenivas 			u32 rtc;
1964c4a3e0a5SBagalkote, Sreenivas 			u32 elapsedSeconds;
1965c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) time;
1966c4a3e0a5SBagalkote, Sreenivas 
1967c4a3e0a5SBagalkote, Sreenivas 		struct {
1968c4a3e0a5SBagalkote, Sreenivas 			u32 ecar;
1969c4a3e0a5SBagalkote, Sreenivas 			u32 elog;
1970c4a3e0a5SBagalkote, Sreenivas 			char str[64];
1971c4a3e0a5SBagalkote, Sreenivas 		} __attribute__ ((packed)) ecc;
1972c4a3e0a5SBagalkote, Sreenivas 
1973c4a3e0a5SBagalkote, Sreenivas 		u8 b[96];
19749ab9ed38SChristoph Hellwig 		__le16 s[48];
19759ab9ed38SChristoph Hellwig 		__le32 w[24];
19769ab9ed38SChristoph Hellwig 		__le64 d[12];
1977c4a3e0a5SBagalkote, Sreenivas 	} args;
1978c4a3e0a5SBagalkote, Sreenivas 
1979c4a3e0a5SBagalkote, Sreenivas 	char description[128];
1980c4a3e0a5SBagalkote, Sreenivas 
1981c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
1982c4a3e0a5SBagalkote, Sreenivas 
19837e8a75f4SYang, Bo struct megasas_aen_event {
1984c1d390d8SXiaotian Feng 	struct delayed_work hotplug_work;
19857e8a75f4SYang, Bo 	struct megasas_instance *instance;
19867e8a75f4SYang, Bo };
19877e8a75f4SYang, Bo 
1988c8e858feSadam radford struct megasas_irq_context {
1989c8e858feSadam radford 	struct megasas_instance *instance;
1990c8e858feSadam radford 	u32 MSIxIndex;
1991c8e858feSadam radford };
1992c8e858feSadam radford 
19935765c5b8SSumit.Saxena@avagotech.com struct MR_DRV_SYSTEM_INFO {
19945765c5b8SSumit.Saxena@avagotech.com 	u8	infoVersion;
19955765c5b8SSumit.Saxena@avagotech.com 	u8	systemIdLength;
19965765c5b8SSumit.Saxena@avagotech.com 	u16	reserved0;
19975765c5b8SSumit.Saxena@avagotech.com 	u8	systemId[64];
19985765c5b8SSumit.Saxena@avagotech.com 	u8	reserved[1980];
19995765c5b8SSumit.Saxena@avagotech.com };
20005765c5b8SSumit.Saxena@avagotech.com 
20012216c305SSumit Saxena enum MR_PD_TYPE {
20022216c305SSumit Saxena 		 UNKNOWN_DRIVE = 0,
20032216c305SSumit Saxena 		 PARALLEL_SCSI = 1,
20042216c305SSumit Saxena 		 SAS_PD = 2,
20052216c305SSumit Saxena 		 SATA_PD = 3,
20062216c305SSumit Saxena 		 FC_PD = 4,
20072216c305SSumit Saxena };
20082216c305SSumit Saxena 
20092216c305SSumit Saxena /* JBOD Queue depth definitions */
20102216c305SSumit Saxena #define MEGASAS_SATA_QD	32
20112216c305SSumit Saxena #define MEGASAS_SAS_QD	64
20122216c305SSumit Saxena #define MEGASAS_DEFAULT_PD_QD	64
20132216c305SSumit Saxena 
2014c4a3e0a5SBagalkote, Sreenivas struct megasas_instance {
2015c4a3e0a5SBagalkote, Sreenivas 
20169ab9ed38SChristoph Hellwig 	__le32 *producer;
2017c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t producer_h;
20189ab9ed38SChristoph Hellwig 	__le32 *consumer;
2019c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t consumer_h;
20205765c5b8SSumit.Saxena@avagotech.com 	struct MR_DRV_SYSTEM_INFO *system_info_buf;
20215765c5b8SSumit.Saxena@avagotech.com 	dma_addr_t system_info_h;
2022229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION *vf_affiliation;
2023229fe47cSadam radford 	dma_addr_t vf_affiliation_h;
2024229fe47cSadam radford 	struct MR_LD_VF_AFFILIATION_111 *vf_affiliation_111;
2025229fe47cSadam radford 	dma_addr_t vf_affiliation_111_h;
2026229fe47cSadam radford 	struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
2027229fe47cSadam radford 	dma_addr_t hb_host_mem_h;
20282216c305SSumit Saxena 	struct MR_PD_INFO *pd_info;
20292216c305SSumit Saxena 	dma_addr_t pd_info_h;
2030c4a3e0a5SBagalkote, Sreenivas 
20319ab9ed38SChristoph Hellwig 	__le32 *reply_queue;
2032c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t reply_queue_h;
2033c4a3e0a5SBagalkote, Sreenivas 
2034fc62b3fcSSumit.Saxena@avagotech.com 	u32 *crash_dump_buf;
2035fc62b3fcSSumit.Saxena@avagotech.com 	dma_addr_t crash_dump_h;
2036fc62b3fcSSumit.Saxena@avagotech.com 	void *crash_buf[MAX_CRASH_DUMP_SIZE];
2037fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_buf_pages;
2038fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_size;
2039fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_state;
2040fc62b3fcSSumit.Saxena@avagotech.com 	unsigned int    fw_crash_buffer_offset;
2041fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_index;
2042fc62b3fcSSumit.Saxena@avagotech.com 	u32 drv_buf_alloc;
2043fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_fw_support;
2044fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_drv_support;
2045fc62b3fcSSumit.Saxena@avagotech.com 	u32 crash_dump_app_support;
20467497cde8SSumit.Saxena@avagotech.com 	u32 secure_jbod_support;
20473761cb4cSsumit.saxena@avagotech.com 	bool use_seqnum_jbod_fp;   /* Added for PD sequence */
2048fc62b3fcSSumit.Saxena@avagotech.com 	spinlock_t crashdump_lock;
2049fc62b3fcSSumit.Saxena@avagotech.com 
2050c4a3e0a5SBagalkote, Sreenivas 	struct megasas_register_set __iomem *reg_set;
20518a232bb3SChristoph Hellwig 	u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
205281e403ceSYang, Bo 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
2053999ece0aSSumit.Saxena@lsi.com 	struct megasas_pd_list          local_pd_list[MEGASAS_MAX_PD];
2054bdc6fb8dSYang, Bo 	u8 ld_ids[MEGASAS_MAX_LD_IDS];
2055c4a3e0a5SBagalkote, Sreenivas 	s8 init_id;
2056c4a3e0a5SBagalkote, Sreenivas 
2057c4a3e0a5SBagalkote, Sreenivas 	u16 max_num_sge;
2058c4a3e0a5SBagalkote, Sreenivas 	u16 max_fw_cmds;
20599c915a8cSadam radford 	u16 max_mfi_cmds;
2060ae09a6c1SSumit.Saxena@avagotech.com 	u16 max_scsi_cmds;
2061308ec459SSumit Saxena 	u16 ldio_threshold;
2062308ec459SSumit Saxena 	u16 cur_can_queue;
2063c4a3e0a5SBagalkote, Sreenivas 	u32 max_sectors_per_req;
20647e8a75f4SYang, Bo 	struct megasas_aen_event *ev;
2065c4a3e0a5SBagalkote, Sreenivas 
2066c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd **cmd_list;
2067c4a3e0a5SBagalkote, Sreenivas 	struct list_head cmd_pool;
206839a98554Sbo yang 	/* used to sync fire the cmd to fw */
206990dc9d98SSumit.Saxena@avagotech.com 	spinlock_t mfi_pool_lock;
207039a98554Sbo yang 	/* used to sync fire the cmd to fw */
207139a98554Sbo yang 	spinlock_t hba_lock;
20727343eb65Sbo yang 	/* used to synch producer, consumer ptrs in dpc */
20737343eb65Sbo yang 	spinlock_t completion_lock;
2074c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *frame_dma_pool;
2075c4a3e0a5SBagalkote, Sreenivas 	struct dma_pool *sense_dma_pool;
2076c4a3e0a5SBagalkote, Sreenivas 
2077c4a3e0a5SBagalkote, Sreenivas 	struct megasas_evt_detail *evt_detail;
2078c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t evt_detail_h;
2079c4a3e0a5SBagalkote, Sreenivas 	struct megasas_cmd *aen_cmd;
20802216c305SSumit Saxena 	struct mutex hba_mutex;
2081c4a3e0a5SBagalkote, Sreenivas 	struct semaphore ioctl_sem;
2082c4a3e0a5SBagalkote, Sreenivas 
2083c4a3e0a5SBagalkote, Sreenivas 	struct Scsi_Host *host;
2084c4a3e0a5SBagalkote, Sreenivas 
2085c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t int_cmd_wait_q;
2086c4a3e0a5SBagalkote, Sreenivas 	wait_queue_head_t abort_cmd_wait_q;
2087c4a3e0a5SBagalkote, Sreenivas 
2088c4a3e0a5SBagalkote, Sreenivas 	struct pci_dev *pdev;
2089c4a3e0a5SBagalkote, Sreenivas 	u32 unique_id;
209039a98554Sbo yang 	u32 fw_support_ieee;
2091c4a3e0a5SBagalkote, Sreenivas 
2092e4a082c7SSumant Patro 	atomic_t fw_outstanding;
2093308ec459SSumit Saxena 	atomic_t ldio_outstanding;
209439a98554Sbo yang 	atomic_t fw_reset_no_pci_access;
20951341c939SSumant Patro 
20961341c939SSumant Patro 	struct megasas_instance_template *instancet;
20975d018ad0SSumant Patro 	struct tasklet_struct isr_tasklet;
209839a98554Sbo yang 	struct work_struct work_init;
2099fc62b3fcSSumit.Saxena@avagotech.com 	struct work_struct crash_init;
210005e9ebbeSSumant Patro 
210105e9ebbeSSumant Patro 	u8 flag;
2102c3518837SYang, Bo 	u8 unload;
2103f4c9a131SYang, Bo 	u8 flag_ieee;
210439a98554Sbo yang 	u8 issuepend_done;
210539a98554Sbo yang 	u8 disableOnlineCtrlReset;
2106bc93d425SSumit.Saxena@lsi.com 	u8 UnevenSpanSupport;
210751087a86SSumit.Saxena@avagotech.com 
210851087a86SSumit.Saxena@avagotech.com 	u8 supportmax256vd;
210930845586SSumit Saxena 	u8 pd_list_not_supported;
211051087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_vd_count;
211151087a86SSumit.Saxena@avagotech.com 	u16 fw_supported_pd_count;
211251087a86SSumit.Saxena@avagotech.com 
211351087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_vd_count;
211451087a86SSumit.Saxena@avagotech.com 	u16 drv_supported_pd_count;
211551087a86SSumit.Saxena@avagotech.com 
21168a01a41dSSumit Saxena 	atomic_t adprecovery;
211705e9ebbeSSumant Patro 	unsigned long last_time;
211839a98554Sbo yang 	u32 mfiStatus;
211939a98554Sbo yang 	u32 last_seq_num;
2120ad84db2eSbo yang 
212139a98554Sbo yang 	struct list_head internal_reset_pending_q;
212280d9da98Sadam radford 
212325985edcSLucas De Marchi 	/* Ptr to hba specific information */
21249c915a8cSadam radford 	void *ctrl_context;
212551087a86SSumit.Saxena@avagotech.com 	u32 ctrl_context_pages;
212651087a86SSumit.Saxena@avagotech.com 	struct megasas_ctrl_info *ctrl_info;
2127c8e858feSadam radford 	unsigned int msix_vectors;
2128c8e858feSadam radford 	struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
21299c915a8cSadam radford 	u64 map_id;
21303761cb4cSsumit.saxena@avagotech.com 	u64 pd_seq_map_id;
21319c915a8cSadam radford 	struct megasas_cmd *map_update_cmd;
21323761cb4cSsumit.saxena@avagotech.com 	struct megasas_cmd *jbod_seq_cmd;
2133b6d5d880Sadam radford 	unsigned long bar;
21349c915a8cSadam radford 	long reset_flags;
21359c915a8cSadam radford 	struct mutex reset_mutex;
2136229fe47cSadam radford 	struct timer_list sriov_heartbeat_timer;
2137229fe47cSadam radford 	char skip_heartbeat_timer_del;
2138229fe47cSadam radford 	u8 requestorId;
2139229fe47cSadam radford 	char PlasmaFW111;
21408f67c8c5SSumit Saxena 	char clusterId[MEGASAS_CLUSTER_ID_SIZE];
21418f67c8c5SSumit Saxena 	u8 peerIsPresent;
21428f67c8c5SSumit Saxena 	u8 passive;
2143ae09a6c1SSumit.Saxena@avagotech.com 	u16 throttlequeuedepth;
2144d46a3ad6SSumit.Saxena@lsi.com 	u8 mask_interrupts;
2145bd5f9484Ssumit.saxena@avagotech.com 	u16 max_chain_frame_sz;
2146404a8a1aSSumit.Saxena@lsi.com 	u8 is_imr;
2147179ac142SSumit Saxena 	u8 is_rdpq;
21485765c5b8SSumit.Saxena@avagotech.com 	bool dev_handle;
2149d0fc91d6SKashyap Desai 	bool fw_sync_cache_support;
215045f4f2ebSSasikumar Chandrasekaran 	bool is_ventura;
21512493c67eSSasikumar Chandrasekaran 	bool msix_combined;
215239a98554Sbo yang };
2153229fe47cSadam radford struct MR_LD_VF_MAP {
2154229fe47cSadam radford 	u32 size;
2155229fe47cSadam radford 	union MR_LD_REF ref;
2156229fe47cSadam radford 	u8 ldVfCount;
2157229fe47cSadam radford 	u8 reserved[6];
2158229fe47cSadam radford 	u8 policy[1];
2159229fe47cSadam radford };
2160229fe47cSadam radford 
2161229fe47cSadam radford struct MR_LD_VF_AFFILIATION {
2162229fe47cSadam radford 	u32 size;
2163229fe47cSadam radford 	u8 ldCount;
2164229fe47cSadam radford 	u8 vfCount;
2165229fe47cSadam radford 	u8 thisVf;
2166229fe47cSadam radford 	u8 reserved[9];
2167229fe47cSadam radford 	struct MR_LD_VF_MAP map[1];
2168229fe47cSadam radford };
2169229fe47cSadam radford 
2170229fe47cSadam radford /* Plasma 1.11 FW backward compatibility structures */
2171229fe47cSadam radford #define IOV_111_OFFSET 0x7CE
2172229fe47cSadam radford #define MAX_VIRTUAL_FUNCTIONS 8
21734cbfea88SAdam Radford #define MR_LD_ACCESS_HIDDEN 15
2174229fe47cSadam radford 
2175229fe47cSadam radford struct IOV_111 {
2176229fe47cSadam radford 	u8 maxVFsSupported;
2177229fe47cSadam radford 	u8 numVFsEnabled;
2178229fe47cSadam radford 	u8 requestorId;
2179229fe47cSadam radford 	u8 reserved[5];
2180229fe47cSadam radford };
2181229fe47cSadam radford 
2182229fe47cSadam radford struct MR_LD_VF_MAP_111 {
2183229fe47cSadam radford 	u8 targetId;
2184229fe47cSadam radford 	u8 reserved[3];
2185229fe47cSadam radford 	u8 policy[MAX_VIRTUAL_FUNCTIONS];
2186229fe47cSadam radford };
2187229fe47cSadam radford 
2188229fe47cSadam radford struct MR_LD_VF_AFFILIATION_111 {
2189229fe47cSadam radford 	u8 vdCount;
2190229fe47cSadam radford 	u8 vfCount;
2191229fe47cSadam radford 	u8 thisVf;
2192229fe47cSadam radford 	u8 reserved[5];
2193229fe47cSadam radford 	struct MR_LD_VF_MAP_111 map[MAX_LOGICAL_DRIVES];
2194229fe47cSadam radford };
2195229fe47cSadam radford 
2196229fe47cSadam radford struct MR_CTRL_HB_HOST_MEM {
2197229fe47cSadam radford 	struct {
2198229fe47cSadam radford 		u32 fwCounter;	/* Firmware heart beat counter */
2199229fe47cSadam radford 		struct {
2200229fe47cSadam radford 			u32 debugmode:1; /* 1=Firmware is in debug mode.
2201229fe47cSadam radford 					    Heart beat will not be updated. */
2202229fe47cSadam radford 			u32 reserved:31;
2203229fe47cSadam radford 		} debug;
2204229fe47cSadam radford 		u32 reserved_fw[6];
2205229fe47cSadam radford 		u32 driverCounter; /* Driver heart beat counter.  0x20 */
2206229fe47cSadam radford 		u32 reserved_driver[7];
2207229fe47cSadam radford 	} HB;
2208229fe47cSadam radford 	u8 pad[0x400-0x40];
2209229fe47cSadam radford };
221039a98554Sbo yang 
221139a98554Sbo yang enum {
221239a98554Sbo yang 	MEGASAS_HBA_OPERATIONAL			= 0,
221339a98554Sbo yang 	MEGASAS_ADPRESET_SM_INFAULT		= 1,
221439a98554Sbo yang 	MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS	= 2,
221539a98554Sbo yang 	MEGASAS_ADPRESET_SM_OPERATIONAL		= 3,
221639a98554Sbo yang 	MEGASAS_HW_CRITICAL_ERROR		= 4,
2217229fe47cSadam radford 	MEGASAS_ADPRESET_SM_POLLING		= 5,
221839a98554Sbo yang 	MEGASAS_ADPRESET_INPROG_SIGN		= 0xDEADDEAD,
2219c4a3e0a5SBagalkote, Sreenivas };
2220c4a3e0a5SBagalkote, Sreenivas 
22210c79e681SYang, Bo struct megasas_instance_template {
22220c79e681SYang, Bo 	void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
22230c79e681SYang, Bo 		u32, struct megasas_register_set __iomem *);
22240c79e681SYang, Bo 
2225d46a3ad6SSumit.Saxena@lsi.com 	void (*enable_intr)(struct megasas_instance *);
2226d46a3ad6SSumit.Saxena@lsi.com 	void (*disable_intr)(struct megasas_instance *);
22270c79e681SYang, Bo 
22280c79e681SYang, Bo 	int (*clear_intr)(struct megasas_register_set __iomem *);
22290c79e681SYang, Bo 
22300c79e681SYang, Bo 	u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
223139a98554Sbo yang 	int (*adp_reset)(struct megasas_instance *, \
223239a98554Sbo yang 		struct megasas_register_set __iomem *);
223339a98554Sbo yang 	int (*check_reset)(struct megasas_instance *, \
223439a98554Sbo yang 		struct megasas_register_set __iomem *);
2235cd50ba8eSadam radford 	irqreturn_t (*service_isr)(int irq, void *devp);
2236cd50ba8eSadam radford 	void (*tasklet)(unsigned long);
2237cd50ba8eSadam radford 	u32 (*init_adapter)(struct megasas_instance *);
2238cd50ba8eSadam radford 	u32 (*build_and_issue_cmd) (struct megasas_instance *,
2239cd50ba8eSadam radford 				    struct scsi_cmnd *);
22406d40afbcSSumit Saxena 	int (*issue_dcmd)(struct megasas_instance *instance,
2241cd50ba8eSadam radford 			    struct megasas_cmd *cmd);
22420c79e681SYang, Bo };
22430c79e681SYang, Bo 
2244c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IS_LOGICAL(scp)						\
22455e5ec175SSumit Saxena 	((scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
2246c4a3e0a5SBagalkote, Sreenivas 
22474a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_DEV_INDEX(scp)						\
22484a5c814dSSumit.Saxena@avagotech.com 	(((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) +	\
22494a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
22504a5c814dSSumit.Saxena@avagotech.com 
22514a5c814dSSumit.Saxena@avagotech.com #define MEGASAS_PD_INDEX(scp)						\
22524a5c814dSSumit.Saxena@avagotech.com 	((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +		\
22534a5c814dSSumit.Saxena@avagotech.com 	scp->device->id)
2254c4a3e0a5SBagalkote, Sreenivas 
2255c4a3e0a5SBagalkote, Sreenivas struct megasas_cmd {
2256c4a3e0a5SBagalkote, Sreenivas 
2257c4a3e0a5SBagalkote, Sreenivas 	union megasas_frame *frame;
2258c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t frame_phys_addr;
2259c4a3e0a5SBagalkote, Sreenivas 	u8 *sense;
2260c4a3e0a5SBagalkote, Sreenivas 	dma_addr_t sense_phys_addr;
2261c4a3e0a5SBagalkote, Sreenivas 
2262c4a3e0a5SBagalkote, Sreenivas 	u32 index;
2263c4a3e0a5SBagalkote, Sreenivas 	u8 sync_cmd;
22642be2a988SSumit.Saxena@avagotech.com 	u8 cmd_status_drv;
226539a98554Sbo yang 	u8 abort_aen;
226639a98554Sbo yang 	u8 retry_for_fw_reset;
226739a98554Sbo yang 
2268c4a3e0a5SBagalkote, Sreenivas 
2269c4a3e0a5SBagalkote, Sreenivas 	struct list_head list;
2270c4a3e0a5SBagalkote, Sreenivas 	struct scsi_cmnd *scmd;
22714026e9aaSSumit.Saxena@avagotech.com 	u8 flags;
227290dc9d98SSumit.Saxena@avagotech.com 
2273c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance;
22749c915a8cSadam radford 	union {
22759c915a8cSadam radford 		struct {
22769c915a8cSadam radford 			u16 smid;
22779c915a8cSadam radford 			u16 resvd;
22789c915a8cSadam radford 		} context;
2279c4a3e0a5SBagalkote, Sreenivas 		u32 frame_count;
2280c4a3e0a5SBagalkote, Sreenivas 	};
22819c915a8cSadam radford };
2282c4a3e0a5SBagalkote, Sreenivas 
2283c4a3e0a5SBagalkote, Sreenivas #define MAX_MGMT_ADAPTERS		1024
2284c4a3e0a5SBagalkote, Sreenivas #define MAX_IOCTL_SGE			16
2285c4a3e0a5SBagalkote, Sreenivas 
2286c4a3e0a5SBagalkote, Sreenivas struct megasas_iocpacket {
2287c4a3e0a5SBagalkote, Sreenivas 
2288c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2289c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2290c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2291c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2292c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2293c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2294c4a3e0a5SBagalkote, Sreenivas 	union {
2295c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2296c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2297c4a3e0a5SBagalkote, Sreenivas 	} frame;
2298c4a3e0a5SBagalkote, Sreenivas 
2299c4a3e0a5SBagalkote, Sreenivas 	struct iovec sgl[MAX_IOCTL_SGE];
2300c4a3e0a5SBagalkote, Sreenivas 
2301c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2302c4a3e0a5SBagalkote, Sreenivas 
2303c4a3e0a5SBagalkote, Sreenivas struct megasas_aen {
2304c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2305c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2306c4a3e0a5SBagalkote, Sreenivas 	u32 seq_num;
2307c4a3e0a5SBagalkote, Sreenivas 	u32 class_locale_word;
2308c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2309c4a3e0a5SBagalkote, Sreenivas 
2310c4a3e0a5SBagalkote, Sreenivas #ifdef CONFIG_COMPAT
2311c4a3e0a5SBagalkote, Sreenivas struct compat_megasas_iocpacket {
2312c4a3e0a5SBagalkote, Sreenivas 	u16 host_no;
2313c4a3e0a5SBagalkote, Sreenivas 	u16 __pad1;
2314c4a3e0a5SBagalkote, Sreenivas 	u32 sgl_off;
2315c4a3e0a5SBagalkote, Sreenivas 	u32 sge_count;
2316c4a3e0a5SBagalkote, Sreenivas 	u32 sense_off;
2317c4a3e0a5SBagalkote, Sreenivas 	u32 sense_len;
2318c4a3e0a5SBagalkote, Sreenivas 	union {
2319c4a3e0a5SBagalkote, Sreenivas 		u8 raw[128];
2320c4a3e0a5SBagalkote, Sreenivas 		struct megasas_header hdr;
2321c4a3e0a5SBagalkote, Sreenivas 	} frame;
2322c4a3e0a5SBagalkote, Sreenivas 	struct compat_iovec sgl[MAX_IOCTL_SGE];
2323c4a3e0a5SBagalkote, Sreenivas } __attribute__ ((packed));
2324c4a3e0a5SBagalkote, Sreenivas 
23250e98936cSSumant Patro #define MEGASAS_IOC_FIRMWARE32	_IOWR('M', 1, struct compat_megasas_iocpacket)
2326c4a3e0a5SBagalkote, Sreenivas #endif
2327c4a3e0a5SBagalkote, Sreenivas 
2328cb59aa6aSSumant Patro #define MEGASAS_IOC_FIRMWARE	_IOWR('M', 1, struct megasas_iocpacket)
2329c4a3e0a5SBagalkote, Sreenivas #define MEGASAS_IOC_GET_AEN	_IOW('M', 3, struct megasas_aen)
2330c4a3e0a5SBagalkote, Sreenivas 
2331c4a3e0a5SBagalkote, Sreenivas struct megasas_mgmt_info {
2332c4a3e0a5SBagalkote, Sreenivas 
2333c4a3e0a5SBagalkote, Sreenivas 	u16 count;
2334c4a3e0a5SBagalkote, Sreenivas 	struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
2335c4a3e0a5SBagalkote, Sreenivas 	int max_index;
2336c4a3e0a5SBagalkote, Sreenivas };
2337c4a3e0a5SBagalkote, Sreenivas 
23386d40afbcSSumit Saxena enum MEGASAS_OCR_CAUSE {
23396d40afbcSSumit Saxena 	FW_FAULT_OCR			= 0,
23406d40afbcSSumit Saxena 	SCSIIO_TIMEOUT_OCR		= 1,
23416d40afbcSSumit Saxena 	MFI_IO_TIMEOUT_OCR		= 2,
23426d40afbcSSumit Saxena };
23436d40afbcSSumit Saxena 
23446d40afbcSSumit Saxena enum DCMD_RETURN_STATUS {
23456d40afbcSSumit Saxena 	DCMD_SUCCESS		= 0,
23466d40afbcSSumit Saxena 	DCMD_TIMEOUT		= 1,
23476d40afbcSSumit Saxena 	DCMD_FAILED		= 2,
23486d40afbcSSumit Saxena 	DCMD_NOT_FIRED		= 3,
23496d40afbcSSumit Saxena };
23506d40afbcSSumit Saxena 
235121c9e160Sadam radford u8
235221c9e160Sadam radford MR_BuildRaidContext(struct megasas_instance *instance,
235321c9e160Sadam radford 		    struct IO_REQUEST_INFO *io_info,
235421c9e160Sadam radford 		    struct RAID_CONTEXT *pRAID_Context,
235551087a86SSumit.Saxena@avagotech.com 		    struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN);
235651087a86SSumit.Saxena@avagotech.com u8 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
235751087a86SSumit.Saxena@avagotech.com struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
235851087a86SSumit.Saxena@avagotech.com u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
235951087a86SSumit.Saxena@avagotech.com u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
23609ab9ed38SChristoph Hellwig __le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
236151087a86SSumit.Saxena@avagotech.com u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
236221c9e160Sadam radford 
23639ab9ed38SChristoph Hellwig __le16 get_updated_dev_handle(struct megasas_instance *instance,
2364d2552ebeSSumit.Saxena@avagotech.com 	struct LD_LOAD_BALANCE_INFO *lbInfo, struct IO_REQUEST_INFO *in_info);
236551087a86SSumit.Saxena@avagotech.com void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
236651087a86SSumit.Saxena@avagotech.com 	struct LD_LOAD_BALANCE_INFO *lbInfo);
2367d009b576SSumit.Saxena@avagotech.com int megasas_get_ctrl_info(struct megasas_instance *instance);
23683761cb4cSsumit.saxena@avagotech.com /* PD sequence */
23693761cb4cSsumit.saxena@avagotech.com int
23703761cb4cSsumit.saxena@avagotech.com megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
2371fc62b3fcSSumit.Saxena@avagotech.com int megasas_set_crash_dump_params(struct megasas_instance *instance,
2372fc62b3fcSSumit.Saxena@avagotech.com 	u8 crash_buf_state);
2373fc62b3fcSSumit.Saxena@avagotech.com void megasas_free_host_crash_buffer(struct megasas_instance *instance);
2374fc62b3fcSSumit.Saxena@avagotech.com void megasas_fusion_crash_dump_wq(struct work_struct *work);
237551087a86SSumit.Saxena@avagotech.com 
237690dc9d98SSumit.Saxena@avagotech.com void megasas_return_cmd_fusion(struct megasas_instance *instance,
237790dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd_fusion *cmd);
237890dc9d98SSumit.Saxena@avagotech.com int megasas_issue_blocked_cmd(struct megasas_instance *instance,
237990dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd, int timeout);
238090dc9d98SSumit.Saxena@avagotech.com void __megasas_return_cmd(struct megasas_instance *instance,
238190dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd);
238290dc9d98SSumit.Saxena@avagotech.com 
238390dc9d98SSumit.Saxena@avagotech.com void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
238490dc9d98SSumit.Saxena@avagotech.com 	struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
23857497cde8SSumit.Saxena@avagotech.com int megasas_cmd_type(struct scsi_cmnd *cmd);
23863761cb4cSsumit.saxena@avagotech.com void megasas_setup_jbod_map(struct megasas_instance *instance);
238790dc9d98SSumit.Saxena@avagotech.com 
238818365b13SSumit Saxena void megasas_update_sdev_properties(struct scsi_device *sdev);
238918365b13SSumit Saxena int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
239018365b13SSumit Saxena int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
239118365b13SSumit Saxena int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
2392c4a3e0a5SBagalkote, Sreenivas #endif				/*LSI_MEGARAID_SAS_H */
2393