xref: /linux/drivers/scsi/mpt3sas/mpt3sas_base.h (revision 4f6b838c378a52ea3ae0b15f12ca8a20849072fa)
1f92363d1SSreekanth Reddy /*
2f92363d1SSreekanth Reddy  * This is the Fusion MPT base driver providing common API layer interface
3f92363d1SSreekanth Reddy  * for access to MPT (Message Passing Technology) firmware.
4f92363d1SSreekanth Reddy  *
5f92363d1SSreekanth Reddy  * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
6a4ffce0dSSreekanth Reddy  * Copyright (C) 2012-2014  LSI Corporation
7a03bd153SSreekanth Reddy  * Copyright (C) 2013-2014 Avago Technologies
8a03bd153SSreekanth Reddy  *  (mailto: MPT-FusionLinux.pdl@avagotech.com)
9f92363d1SSreekanth Reddy  *
10f92363d1SSreekanth Reddy  * This program is free software; you can redistribute it and/or
11f92363d1SSreekanth Reddy  * modify it under the terms of the GNU General Public License
12f92363d1SSreekanth Reddy  * as published by the Free Software Foundation; either version 2
13f92363d1SSreekanth Reddy  * of the License, or (at your option) any later version.
14f92363d1SSreekanth Reddy  *
15f92363d1SSreekanth Reddy  * This program is distributed in the hope that it will be useful,
16f92363d1SSreekanth Reddy  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17f92363d1SSreekanth Reddy  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18f92363d1SSreekanth Reddy  * GNU General Public License for more details.
19f92363d1SSreekanth Reddy  *
20f92363d1SSreekanth Reddy  * NO WARRANTY
21f92363d1SSreekanth Reddy  * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
22f92363d1SSreekanth Reddy  * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
23f92363d1SSreekanth Reddy  * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
24f92363d1SSreekanth Reddy  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
25f92363d1SSreekanth Reddy  * solely responsible for determining the appropriateness of using and
26f92363d1SSreekanth Reddy  * distributing the Program and assumes all risks associated with its
27f92363d1SSreekanth Reddy  * exercise of rights under this Agreement, including but not limited to
28f92363d1SSreekanth Reddy  * the risks and costs of program errors, damage to or loss of data,
29f92363d1SSreekanth Reddy  * programs or equipment, and unavailability or interruption of operations.
30f92363d1SSreekanth Reddy 
31f92363d1SSreekanth Reddy  * DISCLAIMER OF LIABILITY
32f92363d1SSreekanth Reddy  * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
33f92363d1SSreekanth Reddy  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34f92363d1SSreekanth Reddy  * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
35f92363d1SSreekanth Reddy  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36f92363d1SSreekanth Reddy  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37f92363d1SSreekanth Reddy  * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
38f92363d1SSreekanth Reddy  * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39f92363d1SSreekanth Reddy 
40f92363d1SSreekanth Reddy  * You should have received a copy of the GNU General Public License
41f92363d1SSreekanth Reddy  * along with this program; if not, write to the Free Software
42f92363d1SSreekanth Reddy  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
43f92363d1SSreekanth Reddy  * USA.
44f92363d1SSreekanth Reddy  */
45f92363d1SSreekanth Reddy 
46f92363d1SSreekanth Reddy #ifndef MPT3SAS_BASE_H_INCLUDED
47f92363d1SSreekanth Reddy #define MPT3SAS_BASE_H_INCLUDED
48f92363d1SSreekanth Reddy 
49f92363d1SSreekanth Reddy #include "mpi/mpi2_type.h"
50f92363d1SSreekanth Reddy #include "mpi/mpi2.h"
51f92363d1SSreekanth Reddy #include "mpi/mpi2_ioc.h"
52f92363d1SSreekanth Reddy #include "mpi/mpi2_cnfg.h"
53f92363d1SSreekanth Reddy #include "mpi/mpi2_init.h"
54f92363d1SSreekanth Reddy #include "mpi/mpi2_raid.h"
55f92363d1SSreekanth Reddy #include "mpi/mpi2_tool.h"
56f92363d1SSreekanth Reddy #include "mpi/mpi2_sas.h"
57016d5c35SSuganath Prabu Subramani #include "mpi/mpi2_pci.h"
58ff92b9ddSSuganath Prabu #include "mpi/mpi2_image.h"
59f92363d1SSreekanth Reddy 
60f92363d1SSreekanth Reddy #include <scsi/scsi.h>
61f92363d1SSreekanth Reddy #include <scsi/scsi_cmnd.h>
62f92363d1SSreekanth Reddy #include <scsi/scsi_device.h>
63f92363d1SSreekanth Reddy #include <scsi/scsi_host.h>
64f92363d1SSreekanth Reddy #include <scsi/scsi_tcq.h>
65f92363d1SSreekanth Reddy #include <scsi/scsi_transport_sas.h>
66f92363d1SSreekanth Reddy #include <scsi/scsi_dbg.h>
67f92363d1SSreekanth Reddy #include <scsi/scsi_eh.h>
688a7e4c24SSreekanth Reddy #include <linux/pci.h>
698a7e4c24SSreekanth Reddy #include <linux/poll.h>
70320e77acSSuganath Prabu #include <linux/irq_poll.h>
71f92363d1SSreekanth Reddy 
72f92363d1SSreekanth Reddy #include "mpt3sas_debug.h"
73f92363d1SSreekanth Reddy #include "mpt3sas_trigger_diag.h"
74f92363d1SSreekanth Reddy 
75f92363d1SSreekanth Reddy /* driver versioning info */
76f92363d1SSreekanth Reddy #define MPT3SAS_DRIVER_NAME		"mpt3sas"
77a03bd153SSreekanth Reddy #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
78f92363d1SSreekanth Reddy #define MPT3SAS_DESCRIPTION	"LSI MPT Fusion SAS 3.0 Device Driver"
79*0491bdc7SSuganath Prabu S #define MPT3SAS_DRIVER_VERSION		"35.100.00.00"
80*0491bdc7SSuganath Prabu S #define MPT3SAS_MAJOR_VERSION		35
812b01b293SSuganath Prabu #define MPT3SAS_MINOR_VERSION		100
82e9ce9c86SSreekanth Reddy #define MPT3SAS_BUILD_VERSION		0
83f92363d1SSreekanth Reddy #define MPT3SAS_RELEASE_VERSION	00
84f92363d1SSreekanth Reddy 
85d0c627afSSreekanth Reddy #define MPT2SAS_DRIVER_NAME		"mpt2sas"
86d0c627afSSreekanth Reddy #define MPT2SAS_DESCRIPTION	"LSI MPT Fusion SAS 2.0 Device Driver"
87d0c627afSSreekanth Reddy #define MPT2SAS_DRIVER_VERSION		"20.102.00.00"
88d0c627afSSreekanth Reddy #define MPT2SAS_MAJOR_VERSION		20
89d0c627afSSreekanth Reddy #define MPT2SAS_MINOR_VERSION		102
90d0c627afSSreekanth Reddy #define MPT2SAS_BUILD_VERSION		0
91d0c627afSSreekanth Reddy #define MPT2SAS_RELEASE_VERSION	00
92d0c627afSSreekanth Reddy 
93e8c2307eSSreekanth Reddy /* CoreDump: Default timeout */
94e8c2307eSSreekanth Reddy #define MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS	(15) /*15 seconds*/
95fce0aa08SSreekanth Reddy #define MPT3SAS_COREDUMP_LOOP_DONE                     (0xFF)
96e8c2307eSSreekanth Reddy 
97f92363d1SSreekanth Reddy /*
98f92363d1SSreekanth Reddy  * Set MPT3SAS_SG_DEPTH value based on user input.
99f92363d1SSreekanth Reddy  */
10065e8617fSMing Lin #define MPT_MAX_PHYS_SEGMENTS	SG_CHUNK_SIZE
1018a7e4c24SSreekanth Reddy #define MPT_MIN_PHYS_SEGMENTS	16
10206f5f976SSreekanth Reddy #define MPT_KDUMP_MIN_PHYS_SEGMENTS	32
1038a7e4c24SSreekanth Reddy 
104182ac784SSuganath Prabu Subramani #define MCPU_MAX_CHAINS_PER_IO	3
105182ac784SSuganath Prabu Subramani 
106f92363d1SSreekanth Reddy #ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
107f92363d1SSreekanth Reddy #define MPT3SAS_SG_DEPTH		CONFIG_SCSI_MPT3SAS_MAX_SGE
108f92363d1SSreekanth Reddy #else
1098a7e4c24SSreekanth Reddy #define MPT3SAS_SG_DEPTH		MPT_MAX_PHYS_SEGMENTS
110f92363d1SSreekanth Reddy #endif
111f92363d1SSreekanth Reddy 
1128a7e4c24SSreekanth Reddy #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
1138a7e4c24SSreekanth Reddy #define MPT2SAS_SG_DEPTH		CONFIG_SCSI_MPT2SAS_MAX_SGE
1148a7e4c24SSreekanth Reddy #else
1158a7e4c24SSreekanth Reddy #define MPT2SAS_SG_DEPTH		MPT_MAX_PHYS_SEGMENTS
1168a7e4c24SSreekanth Reddy #endif
117f92363d1SSreekanth Reddy 
118f92363d1SSreekanth Reddy /*
119f92363d1SSreekanth Reddy  * Generic Defines
120f92363d1SSreekanth Reddy  */
121f92363d1SSreekanth Reddy #define MPT3SAS_SATA_QUEUE_DEPTH	32
122f92363d1SSreekanth Reddy #define MPT3SAS_SAS_QUEUE_DEPTH		254
123f92363d1SSreekanth Reddy #define MPT3SAS_RAID_QUEUE_DEPTH	128
12406f5f976SSreekanth Reddy #define MPT3SAS_KDUMP_SCSI_IO_DEPTH	200
125f92363d1SSreekanth Reddy 
1266c197093SChaitra P B #define MPT3SAS_RAID_MAX_SECTORS	8192
127016d5c35SSuganath Prabu Subramani #define MPT3SAS_HOST_PAGE_SIZE_4K	12
128d1b01d14SSuganath Prabu Subramani #define MPT3SAS_NVME_QUEUE_DEPTH	128
129f92363d1SSreekanth Reddy #define MPT_NAME_LENGTH			32	/* generic length of strings */
130f92363d1SSreekanth Reddy #define MPT_STRING_LENGTH		64
13122ae5a3cSSuganath Prabu Subramani #define MPI_FRAME_START_OFFSET		256
13222ae5a3cSSuganath Prabu Subramani #define REPLY_FREE_POOL_SIZE		512 /*(32 maxcredix *4)*(4 times)*/
133f92363d1SSreekanth Reddy 
134f92363d1SSreekanth Reddy #define MPT_MAX_CALLBACKS		32
135f92363d1SSreekanth Reddy 
136f92363d1SSreekanth Reddy #define INTERNAL_CMDS_COUNT		10	/* reserved cmds */
137fd0331b3SSuganath prabu Subramani /* reserved for issuing internally framed scsi io cmds */
138fd0331b3SSuganath prabu Subramani #define INTERNAL_SCSIIO_CMDS_COUNT	3
139f92363d1SSreekanth Reddy 
140f92363d1SSreekanth Reddy #define MPI3_HIM_MASK			0xFFFFFFFF /* mask every bit*/
141f92363d1SSreekanth Reddy 
142f92363d1SSreekanth Reddy #define MPT3SAS_INVALID_DEVICE_HANDLE	0xFFFF
143f92363d1SSreekanth Reddy 
144ebb3024eSSuganath prabu Subramani #define MAX_CHAIN_ELEMT_SZ		16
145ebb3024eSSuganath prabu Subramani #define DEFAULT_NUM_FWCHAIN_ELEMTS	8
146ebb3024eSSuganath prabu Subramani 
147d3f623aeSSreekanth Reddy #define IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT 6
1483d29ed85SChaitra P B #define FW_IMG_HDR_READ_TIMEOUT	15
14902abcbc2SSuganath Prabu 
15002abcbc2SSuganath Prabu #define IOC_OPERATIONAL_WAIT_COUNT	10
15102abcbc2SSuganath Prabu 
152f92363d1SSreekanth Reddy /*
153016d5c35SSuganath Prabu Subramani  * NVMe defines
154016d5c35SSuganath Prabu Subramani  */
155016d5c35SSuganath Prabu Subramani #define	NVME_PRP_SIZE			8	/* PRP size */
156016d5c35SSuganath Prabu Subramani #define	NVME_ERROR_RESPONSE_SIZE	16	/* Max NVME Error Response */
157c1a6c5acSChaitra P B #define NVME_TASK_ABORT_MIN_TIMEOUT	6
158c1a6c5acSChaitra P B #define NVME_TASK_ABORT_MAX_TIMEOUT	60
159c1a6c5acSChaitra P B #define NVME_TASK_MNGT_CUSTOM_MASK	(0x0010)
160016d5c35SSuganath Prabu Subramani #define	NVME_PRP_PAGE_SIZE		4096	/* Page size */
161016d5c35SSuganath Prabu Subramani 
16284203b35SBart Van Assche struct mpt3sas_nvme_cmd {
16384203b35SBart Van Assche 	u8	rsvd[24];
16484203b35SBart Van Assche 	__le64	prp1;
16584203b35SBart Van Assche 	__le64	prp2;
16684203b35SBart Van Assche };
167c1a6c5acSChaitra P B 
168016d5c35SSuganath Prabu Subramani /*
169f92363d1SSreekanth Reddy  * logging format
170f92363d1SSreekanth Reddy  */
171645a20c6SJoe Perches #define ioc_err(ioc, fmt, ...)						\
172645a20c6SJoe Perches 	pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
173645a20c6SJoe Perches #define ioc_notice(ioc, fmt, ...)					\
174645a20c6SJoe Perches 	pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
175645a20c6SJoe Perches #define ioc_warn(ioc, fmt, ...)						\
176645a20c6SJoe Perches 	pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
177645a20c6SJoe Perches #define ioc_info(ioc, fmt, ...)						\
178645a20c6SJoe Perches 	pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
179645a20c6SJoe Perches 
180f92363d1SSreekanth Reddy /*
1817786ab6aSSreekanth Reddy  *  WarpDrive Specific Log codes
1827786ab6aSSreekanth Reddy  */
1837786ab6aSSreekanth Reddy 
1847786ab6aSSreekanth Reddy #define MPT2_WARPDRIVE_LOGENTRY		(0x8002)
1857786ab6aSSreekanth Reddy #define MPT2_WARPDRIVE_LC_SSDT			(0x41)
1867786ab6aSSreekanth Reddy #define MPT2_WARPDRIVE_LC_SSDLW		(0x43)
1877786ab6aSSreekanth Reddy #define MPT2_WARPDRIVE_LC_SSDLF		(0x44)
1887786ab6aSSreekanth Reddy #define MPT2_WARPDRIVE_LC_BRMF			(0x4D)
1897786ab6aSSreekanth Reddy 
1907786ab6aSSreekanth Reddy /*
191f92363d1SSreekanth Reddy  * per target private data
192f92363d1SSreekanth Reddy  */
193f92363d1SSreekanth Reddy #define MPT_TARGET_FLAGS_RAID_COMPONENT	0x01
194f92363d1SSreekanth Reddy #define MPT_TARGET_FLAGS_VOLUME		0x02
195f92363d1SSreekanth Reddy #define MPT_TARGET_FLAGS_DELETED	0x04
196f92363d1SSreekanth Reddy #define MPT_TARGET_FASTPATH_IO		0x08
197d88e1eabSSuganath Prabu Subramani #define MPT_TARGET_FLAGS_PCIE_DEVICE	0x10
198f92363d1SSreekanth Reddy 
19942081173SSreekanth Reddy #define SAS2_PCI_DEVICE_B0_REVISION	(0x01)
20042081173SSreekanth Reddy #define SAS3_PCI_DEVICE_C0_REVISION	(0x02)
20142081173SSreekanth Reddy 
202eb9c7ce5SSuganath Prabu S /* Atlas PCIe Switch Management Port */
203eb9c7ce5SSuganath Prabu S #define MPI26_ATLAS_PCIe_SWITCH_DEVID	(0x00B2)
204eb9c7ce5SSuganath Prabu S 
2051117b31aSSreekanth Reddy /*
2061117b31aSSreekanth Reddy  * Intel HBA branding
2071117b31aSSreekanth Reddy  */
208989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25JB080_BRANDING    \
209989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25JB080"
210989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25JB040_BRANDING    \
211989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25JB040"
212989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25KB080_BRANDING    \
213989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25KB080"
214989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25KB040_BRANDING    \
215989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25KB040"
216989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25LB040_BRANDING	\
217989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25LB040"
218989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25LB080_BRANDING	\
219989e43c7SSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS25LB080"
220989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS2LL080_BRANDING	\
221989e43c7SSreekanth Reddy 	"Intel Integrated RAID Module RMS2LL080"
222989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS2LL040_BRANDING	\
223989e43c7SSreekanth Reddy 	"Intel Integrated RAID Module RMS2LL040"
224989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RS25GB008_BRANDING       \
225989e43c7SSreekanth Reddy 	"Intel(R) RAID Controller RS25GB008"
226989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_SSD910_BRANDING          \
227989e43c7SSreekanth Reddy 	"Intel(R) SSD 910 Series"
228989e43c7SSreekanth Reddy 
2291117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RMS3JC080_BRANDING       \
2301117b31aSSreekanth Reddy 	"Intel(R) Integrated RAID Module RMS3JC080"
2311117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3GC008_BRANDING       \
2321117b31aSSreekanth Reddy 	"Intel(R) RAID Controller RS3GC008"
2331117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3FC044_BRANDING       \
2341117b31aSSreekanth Reddy 	"Intel(R) RAID Controller RS3FC044"
2351117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3UC080_BRANDING       \
2361117b31aSSreekanth Reddy 	"Intel(R) RAID Controller RS3UC080"
237f92363d1SSreekanth Reddy 
2381117b31aSSreekanth Reddy /*
2391117b31aSSreekanth Reddy  * Intel HBA SSDIDs
2401117b31aSSreekanth Reddy  */
241989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25JB080_SSDID		0x3516
242989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25JB040_SSDID		0x3517
243989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25KB080_SSDID		0x3518
244989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25KB040_SSDID		0x3519
245989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25LB040_SSDID		0x351A
246989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS25LB080_SSDID		0x351B
247989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS2LL080_SSDID		0x350E
248989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RMS2LL040_SSDID		0x350F
249989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_RS25GB008_SSDID		0x3000
250989e43c7SSreekanth Reddy #define MPT2SAS_INTEL_SSD910_SSDID		0x3700
251989e43c7SSreekanth Reddy 
2521117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RMS3JC080_SSDID		0x3521
2531117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3GC008_SSDID		0x3522
2541117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3FC044_SSDID		0x3523
2551117b31aSSreekanth Reddy #define MPT3SAS_INTEL_RS3UC080_SSDID		0x3524
256f92363d1SSreekanth Reddy 
257f92363d1SSreekanth Reddy /*
258fb84dfc4SSreekanth Reddy  * Dell HBA branding
259fb84dfc4SSreekanth Reddy  */
260989e43c7SSreekanth Reddy #define MPT2SAS_DELL_BRANDING_SIZE                 32
261989e43c7SSreekanth Reddy 
262989e43c7SSreekanth Reddy #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING        "Dell 6Gbps SAS HBA"
263989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING    "Dell PERC H200 Adapter"
264989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
265989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING    "Dell PERC H200 Modular"
266989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING   "Dell PERC H200 Embedded"
267989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_BRANDING            "Dell PERC H200"
268989e43c7SSreekanth Reddy #define MPT2SAS_DELL_6GBPS_SAS_BRANDING            "Dell 6Gbps SAS"
269989e43c7SSreekanth Reddy 
270fb84dfc4SSreekanth Reddy #define MPT3SAS_DELL_12G_HBA_BRANDING       \
271fb84dfc4SSreekanth Reddy 	"Dell 12Gbps HBA"
272fb84dfc4SSreekanth Reddy 
273fb84dfc4SSreekanth Reddy /*
274fb84dfc4SSreekanth Reddy  * Dell HBA SSDIDs
275fb84dfc4SSreekanth Reddy  */
276989e43c7SSreekanth Reddy #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID	0x1F1C
277989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID	0x1F1D
278989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID	0x1F1E
279989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID	0x1F1F
280989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID	0x1F20
281989e43c7SSreekanth Reddy #define MPT2SAS_DELL_PERC_H200_SSDID		0x1F21
282989e43c7SSreekanth Reddy #define MPT2SAS_DELL_6GBPS_SAS_SSDID		0x1F22
283989e43c7SSreekanth Reddy 
284fb84dfc4SSreekanth Reddy #define MPT3SAS_DELL_12G_HBA_SSDID		0x1F46
285fb84dfc4SSreekanth Reddy 
286fb84dfc4SSreekanth Reddy /*
28738e4141eSSreekanth Reddy  * Cisco HBA branding
28838e4141eSSreekanth Reddy  */
289d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_8E_HBA_BRANDING		\
29038e4141eSSreekanth Reddy 	"Cisco 9300-8E 12G SAS HBA"
291d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_8I_HBA_BRANDING		\
292d8eb4a47SSreekanth Reddy 	"Cisco 9300-8i 12G SAS HBA"
293d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING	\
294d8eb4a47SSreekanth Reddy 	"Cisco 12G Modular SAS Pass through Controller"
295d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING		\
296d8eb4a47SSreekanth Reddy 	"UCS C3X60 12G SAS Pass through Controller"
29738e4141eSSreekanth Reddy /*
29838e4141eSSreekanth Reddy  * Cisco HBA SSSDIDs
29938e4141eSSreekanth Reddy  */
300d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_8E_HBA_SSDID  0x14C
301d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_8I_HBA_SSDID  0x154
302d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_AVILA_HBA_SSDID  0x155
303d8eb4a47SSreekanth Reddy #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID  0x156
30438e4141eSSreekanth Reddy 
30538e4141eSSreekanth Reddy /*
306f92363d1SSreekanth Reddy  * status bits for ioc->diag_buffer_status
307f92363d1SSreekanth Reddy  */
308f92363d1SSreekanth Reddy #define MPT3_DIAG_BUFFER_IS_REGISTERED	(0x01)
309f92363d1SSreekanth Reddy #define MPT3_DIAG_BUFFER_IS_RELEASED	(0x02)
310f92363d1SSreekanth Reddy #define MPT3_DIAG_BUFFER_IS_DIAG_RESET	(0x04)
311a066f4c3SSreekanth Reddy #define MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED (0x08)
312a8a6cbcdSSreekanth Reddy #define MPT3_DIAG_BUFFER_IS_APP_OWNED (0x10)
313f92363d1SSreekanth Reddy 
314fb77bb53SSreekanth Reddy /*
315989e43c7SSreekanth Reddy  * HP HBA branding
316989e43c7SSreekanth Reddy  */
317989e43c7SSreekanth Reddy #define MPT2SAS_HP_3PAR_SSVID                0x1590
318989e43c7SSreekanth Reddy 
319989e43c7SSreekanth Reddy #define MPT2SAS_HP_2_4_INTERNAL_BRANDING	\
320989e43c7SSreekanth Reddy 	"HP H220 Host Bus Adapter"
321989e43c7SSreekanth Reddy #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING	\
322989e43c7SSreekanth Reddy 	"HP H221 Host Bus Adapter"
323989e43c7SSreekanth Reddy #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING	\
324989e43c7SSreekanth Reddy 	"HP H222 Host Bus Adapter"
325989e43c7SSreekanth Reddy #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING	\
326989e43c7SSreekanth Reddy 	"HP H220i Host Bus Adapter"
327989e43c7SSreekanth Reddy #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING	\
328989e43c7SSreekanth Reddy 	"HP H210i Host Bus Adapter"
329989e43c7SSreekanth Reddy 
330989e43c7SSreekanth Reddy /*
331989e43c7SSreekanth Reddy  * HO HBA SSDIDs
332989e43c7SSreekanth Reddy  */
333989e43c7SSreekanth Reddy #define MPT2SAS_HP_2_4_INTERNAL_SSDID			0x0041
334989e43c7SSreekanth Reddy #define MPT2SAS_HP_2_4_EXTERNAL_SSDID			0x0042
335989e43c7SSreekanth Reddy #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID	0x0043
336989e43c7SSreekanth Reddy #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID		0x0044
337989e43c7SSreekanth Reddy #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID		0x0046
338989e43c7SSreekanth Reddy 
339989e43c7SSreekanth Reddy /*
340fb77bb53SSreekanth Reddy  * Combined Reply Queue constants,
341fb77bb53SSreekanth Reddy  * There are twelve Supplemental Reply Post Host Index Registers
342fb77bb53SSreekanth Reddy  * and each register is at offset 0x10 bytes from the previous one.
343fb77bb53SSreekanth Reddy  */
3442b48be65SChaitra P B #define MAX_COMBINED_MSIX_VECTORS(gen35) ((gen35 == 1) ? 16 : 8)
3450bb337c9SSuganath Prabu Subramani #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3	12
3460bb337c9SSuganath Prabu Subramani #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35	16
347fb77bb53SSreekanth Reddy #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET	(0x10)
348f92363d1SSreekanth Reddy 
349f92363d1SSreekanth Reddy /* OEM Identifiers */
350f92363d1SSreekanth Reddy #define MFG10_OEM_ID_INVALID                   (0x00000000)
351f92363d1SSreekanth Reddy #define MFG10_OEM_ID_DELL                      (0x00000001)
352f92363d1SSreekanth Reddy #define MFG10_OEM_ID_FSC                       (0x00000002)
353f92363d1SSreekanth Reddy #define MFG10_OEM_ID_SUN                       (0x00000003)
354f92363d1SSreekanth Reddy #define MFG10_OEM_ID_IBM                       (0x00000004)
355f92363d1SSreekanth Reddy 
356f92363d1SSreekanth Reddy /* GENERIC Flags 0*/
357f92363d1SSreekanth Reddy #define MFG10_GF0_OCE_DISABLED                 (0x00000001)
358f92363d1SSreekanth Reddy #define MFG10_GF0_R1E_DRIVE_COUNT              (0x00000002)
359f92363d1SSreekanth Reddy #define MFG10_GF0_R10_DISPLAY                  (0x00000004)
360f92363d1SSreekanth Reddy #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE       (0x00000008)
361f92363d1SSreekanth Reddy #define MFG10_GF0_SINGLE_DRIVE_R0              (0x00000010)
362f92363d1SSreekanth Reddy 
3633898f08eSSreekanth Reddy #define VIRTUAL_IO_FAILED_RETRY			(0x32010081)
3643898f08eSSreekanth Reddy 
36518fd3d8cSSuganath Prabu S /* High IOPs definitions */
3665dd48a55SSuganath Prabu S #define MPT3SAS_DEVICE_HIGH_IOPS_DEPTH		8
36718fd3d8cSSuganath Prabu S #define MPT3SAS_HIGH_IOPS_REPLY_QUEUES		8
3685dd48a55SSuganath Prabu S #define MPT3SAS_HIGH_IOPS_BATCH_COUNT		16
36918fd3d8cSSuganath Prabu S #define MPT3SAS_GEN35_MAX_MSIX_QUEUES		128
3708012209eSSuganath Prabu #define RDPQ_MAX_INDEX_IN_ONE_CHUNK		16
37118fd3d8cSSuganath Prabu S 
372f92363d1SSreekanth Reddy /* OEM Specific Flags will come from OEM specific header files */
373f92363d1SSreekanth Reddy struct Mpi2ManufacturingPage10_t {
374f92363d1SSreekanth Reddy 	MPI2_CONFIG_PAGE_HEADER	Header;		/* 00h */
375f92363d1SSreekanth Reddy 	U8	OEMIdentifier;			/* 04h */
376f92363d1SSreekanth Reddy 	U8	Reserved1;			/* 05h */
377f92363d1SSreekanth Reddy 	U16	Reserved2;			/* 08h */
378f92363d1SSreekanth Reddy 	U32	Reserved3;			/* 0Ch */
379f92363d1SSreekanth Reddy 	U32	GenericFlags0;			/* 10h */
380f92363d1SSreekanth Reddy 	U32	GenericFlags1;			/* 14h */
381f92363d1SSreekanth Reddy 	U32	Reserved4;			/* 18h */
382f92363d1SSreekanth Reddy 	U32	OEMSpecificFlags0;		/* 1Ch */
383f92363d1SSreekanth Reddy 	U32	OEMSpecificFlags1;		/* 20h */
384f92363d1SSreekanth Reddy 	U32	Reserved5[18];			/* 24h - 60h*/
385f92363d1SSreekanth Reddy };
386f92363d1SSreekanth Reddy 
387f92363d1SSreekanth Reddy 
388f92363d1SSreekanth Reddy /* Miscellaneous options */
389f92363d1SSreekanth Reddy struct Mpi2ManufacturingPage11_t {
390f92363d1SSreekanth Reddy 	MPI2_CONFIG_PAGE_HEADER Header;		/* 00h */
391f92363d1SSreekanth Reddy 	__le32	Reserved1;			/* 04h */
392f92363d1SSreekanth Reddy 	u8	Reserved2;			/* 08h */
393f92363d1SSreekanth Reddy 	u8	EEDPTagMode;			/* 09h */
394f92363d1SSreekanth Reddy 	u8	Reserved3;			/* 0Ah */
395f92363d1SSreekanth Reddy 	u8	Reserved4;			/* 0Bh */
396c1a6c5acSChaitra P B 	__le32	Reserved5[8];			/* 0Ch-2Ch */
397c1a6c5acSChaitra P B 	u16	AddlFlags2;			/* 2Ch */
398c1a6c5acSChaitra P B 	u8	AddlFlags3;			/* 2Eh */
399c1a6c5acSChaitra P B 	u8	Reserved6;			/* 2Fh */
400c1a6c5acSChaitra P B 	__le32	Reserved7[7];			/* 30h - 4Bh */
401c1a6c5acSChaitra P B 	u8	NVMeAbortTO;			/* 4Ch */
402d04a6edfSSreekanth Reddy 	u8	NumPerDevEvents;		/* 4Dh */
403d04a6edfSSreekanth Reddy 	u8	HostTraceBufferDecrementSizeKB;	/* 4Eh */
404d04a6edfSSreekanth Reddy 	u8	HostTraceBufferFlags;		/* 4Fh */
405d04a6edfSSreekanth Reddy 	u16	HostTraceBufferMaxSizeKB;	/* 50h */
406d04a6edfSSreekanth Reddy 	u16	HostTraceBufferMinSizeKB;	/* 52h */
407e8c2307eSSreekanth Reddy 	u8	CoreDumpTOSec;			/* 54h */
408e8c2307eSSreekanth Reddy 	u8	Reserved8;			/* 55h */
409e8c2307eSSreekanth Reddy 	u16	Reserved9;			/* 56h */
410e8c2307eSSreekanth Reddy 	__le32	Reserved10;			/* 58h */
411f92363d1SSreekanth Reddy };
412f92363d1SSreekanth Reddy 
413f92363d1SSreekanth Reddy /**
414f92363d1SSreekanth Reddy  * struct MPT3SAS_TARGET - starget private hostdata
415f92363d1SSreekanth Reddy  * @starget: starget object
416f92363d1SSreekanth Reddy  * @sas_address: target sas address
4177786ab6aSSreekanth Reddy  * @raid_device: raid_device pointer to access volume data
418f92363d1SSreekanth Reddy  * @handle: device handle
419f92363d1SSreekanth Reddy  * @num_luns: number luns
420f92363d1SSreekanth Reddy  * @flags: MPT_TARGET_FLAGS_XXX flags
421f92363d1SSreekanth Reddy  * @deleted: target flaged for deletion
422f92363d1SSreekanth Reddy  * @tm_busy: target is busy with TM request.
423d88e1eabSSuganath Prabu Subramani  * @sas_dev: The sas_device associated with this target
424d88e1eabSSuganath Prabu Subramani  * @pcie_dev: The pcie device associated with this target
425f92363d1SSreekanth Reddy  */
426f92363d1SSreekanth Reddy struct MPT3SAS_TARGET {
427f92363d1SSreekanth Reddy 	struct scsi_target *starget;
428f92363d1SSreekanth Reddy 	u64	sas_address;
4297786ab6aSSreekanth Reddy 	struct _raid_device *raid_device;
430f92363d1SSreekanth Reddy 	u16	handle;
431f92363d1SSreekanth Reddy 	int	num_luns;
432f92363d1SSreekanth Reddy 	u32	flags;
433f92363d1SSreekanth Reddy 	u8	deleted;
434f92363d1SSreekanth Reddy 	u8	tm_busy;
435d88e1eabSSuganath Prabu Subramani 	struct _sas_device *sas_dev;
436d88e1eabSSuganath Prabu Subramani 	struct _pcie_device *pcie_dev;
437f92363d1SSreekanth Reddy };
438f92363d1SSreekanth Reddy 
439f92363d1SSreekanth Reddy 
440f92363d1SSreekanth Reddy /*
441f92363d1SSreekanth Reddy  * per device private data
442f92363d1SSreekanth Reddy  */
443f92363d1SSreekanth Reddy #define MPT_DEVICE_FLAGS_INIT		0x01
444f92363d1SSreekanth Reddy 
4457786ab6aSSreekanth Reddy #define MFG_PAGE10_HIDE_SSDS_MASK	(0x00000003)
4467786ab6aSSreekanth Reddy #define MFG_PAGE10_HIDE_ALL_DISKS	(0x00)
4477786ab6aSSreekanth Reddy #define MFG_PAGE10_EXPOSE_ALL_DISKS	(0x01)
4487786ab6aSSreekanth Reddy #define MFG_PAGE10_HIDE_IF_VOL_PRESENT	(0x02)
4497786ab6aSSreekanth Reddy 
450f92363d1SSreekanth Reddy /**
451f92363d1SSreekanth Reddy  * struct MPT3SAS_DEVICE - sdev private hostdata
452f92363d1SSreekanth Reddy  * @sas_target: starget private hostdata
453f92363d1SSreekanth Reddy  * @lun: lun number
454f92363d1SSreekanth Reddy  * @flags: MPT_DEVICE_XXX flags
455f92363d1SSreekanth Reddy  * @configured_lun: lun is configured
456f92363d1SSreekanth Reddy  * @block: device is in SDEV_BLOCK state
457f92363d1SSreekanth Reddy  * @tlr_snoop_check: flag used in determining whether to disable TLR
458f92363d1SSreekanth Reddy  * @eedp_enable: eedp support enable bit
459f92363d1SSreekanth Reddy  * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
460f92363d1SSreekanth Reddy  * @eedp_block_length: block size
461ffb58456SJames Bottomley  * @ata_command_pending: SATL passthrough outstanding for device
462f92363d1SSreekanth Reddy  */
463f92363d1SSreekanth Reddy struct MPT3SAS_DEVICE {
464f92363d1SSreekanth Reddy 	struct MPT3SAS_TARGET *sas_target;
465f92363d1SSreekanth Reddy 	unsigned int	lun;
466f92363d1SSreekanth Reddy 	u32	flags;
467f92363d1SSreekanth Reddy 	u8	configured_lun;
468f92363d1SSreekanth Reddy 	u8	block;
469f92363d1SSreekanth Reddy 	u8	tlr_snoop_check;
47030158dc9SSuganath prabu Subramani 	u8	ignore_delay_remove;
471307d9075SAdam Manzanares 	/* Iopriority Command Handling */
472307d9075SAdam Manzanares 	u8	ncq_prio_enable;
473ffb58456SJames Bottomley 	/*
474ffb58456SJames Bottomley 	 * Bug workaround for SATL handling: the mpt2/3sas firmware
475ffb58456SJames Bottomley 	 * doesn't return BUSY or TASK_SET_FULL for subsequent
476ffb58456SJames Bottomley 	 * commands while a SATL pass through is in operation as the
477ffb58456SJames Bottomley 	 * spec requires, it simply does nothing with them until the
478ffb58456SJames Bottomley 	 * pass through completes, causing them possibly to timeout if
479ffb58456SJames Bottomley 	 * the passthrough is a long executing command (like format or
480ffb58456SJames Bottomley 	 * secure erase).  This variable allows us to do the right
481ffb58456SJames Bottomley 	 * thing while a SATL command is pending.
482ffb58456SJames Bottomley 	 */
483ffb58456SJames Bottomley 	unsigned long ata_command_pending;
484307d9075SAdam Manzanares 
485f92363d1SSreekanth Reddy };
486f92363d1SSreekanth Reddy 
487f92363d1SSreekanth Reddy #define MPT3_CMD_NOT_USED	0x8000	/* free */
488f92363d1SSreekanth Reddy #define MPT3_CMD_COMPLETE	0x0001	/* completed */
489f92363d1SSreekanth Reddy #define MPT3_CMD_PENDING	0x0002	/* pending */
490f92363d1SSreekanth Reddy #define MPT3_CMD_REPLY_VALID	0x0004	/* reply is valid */
491f92363d1SSreekanth Reddy #define MPT3_CMD_RESET		0x0008	/* host reset dropped the command */
492f92363d1SSreekanth Reddy 
493f92363d1SSreekanth Reddy /**
494f92363d1SSreekanth Reddy  * struct _internal_cmd - internal commands struct
495f92363d1SSreekanth Reddy  * @mutex: mutex
496f92363d1SSreekanth Reddy  * @done: completion
497f92363d1SSreekanth Reddy  * @reply: reply message pointer
498f92363d1SSreekanth Reddy  * @sense: sense data
499f92363d1SSreekanth Reddy  * @status: MPT3_CMD_XXX status
500f92363d1SSreekanth Reddy  * @smid: system message id
501f92363d1SSreekanth Reddy  */
502f92363d1SSreekanth Reddy struct _internal_cmd {
503f92363d1SSreekanth Reddy 	struct mutex mutex;
504f92363d1SSreekanth Reddy 	struct completion done;
505f92363d1SSreekanth Reddy 	void	*reply;
506f92363d1SSreekanth Reddy 	void	*sense;
507f92363d1SSreekanth Reddy 	u16	status;
508f92363d1SSreekanth Reddy 	u16	smid;
509f92363d1SSreekanth Reddy };
510f92363d1SSreekanth Reddy 
511f92363d1SSreekanth Reddy 
512f92363d1SSreekanth Reddy 
513f92363d1SSreekanth Reddy /**
514f92363d1SSreekanth Reddy  * struct _sas_device - attached device information
515f92363d1SSreekanth Reddy  * @list: sas device list
516f92363d1SSreekanth Reddy  * @starget: starget object
517f92363d1SSreekanth Reddy  * @sas_address: device sas address
518f92363d1SSreekanth Reddy  * @device_name: retrieved from the SAS IDENTIFY frame.
519f92363d1SSreekanth Reddy  * @handle: device handle
520f92363d1SSreekanth Reddy  * @sas_address_parent: sas address of parent expander or sas host
521f92363d1SSreekanth Reddy  * @enclosure_handle: enclosure handle
522f92363d1SSreekanth Reddy  * @enclosure_logical_id: enclosure logical identifier
523f92363d1SSreekanth Reddy  * @volume_handle: volume handle (valid when hidden raid member)
524f92363d1SSreekanth Reddy  * @volume_wwid: volume unique identifier
525f92363d1SSreekanth Reddy  * @device_info: bitfield provides detailed info about the device
526f92363d1SSreekanth Reddy  * @id: target id
527f92363d1SSreekanth Reddy  * @channel: target channel
528f92363d1SSreekanth Reddy  * @slot: number number
529f92363d1SSreekanth Reddy  * @phy: phy identifier provided in sas device page 0
530f92363d1SSreekanth Reddy  * @responding: used in _scsih_sas_device_mark_responding
5310f624c39SSreekanth Reddy  * @fast_path: fast path feature enable bit
5320f624c39SSreekanth Reddy  * @pfa_led_on: flag for PFA LED status
533e4bc7f5cSSreekanth Reddy  * @pend_sas_rphy_add: flag to check if device is in sas_rphy_add()
534e4bc7f5cSSreekanth Reddy  *	addition routine.
53575888956SSreekanth Reddy  * @chassis_slot: chassis slot
53675888956SSreekanth Reddy  * @is_chassis_slot_valid: chassis slot valid or not
537f92363d1SSreekanth Reddy  */
538f92363d1SSreekanth Reddy struct _sas_device {
539f92363d1SSreekanth Reddy 	struct list_head list;
540f92363d1SSreekanth Reddy 	struct scsi_target *starget;
541f92363d1SSreekanth Reddy 	u64	sas_address;
542f92363d1SSreekanth Reddy 	u64	device_name;
543f92363d1SSreekanth Reddy 	u16	handle;
544f92363d1SSreekanth Reddy 	u64	sas_address_parent;
545f92363d1SSreekanth Reddy 	u16	enclosure_handle;
546f92363d1SSreekanth Reddy 	u64	enclosure_logical_id;
547f92363d1SSreekanth Reddy 	u16	volume_handle;
548f92363d1SSreekanth Reddy 	u64	volume_wwid;
549f92363d1SSreekanth Reddy 	u32	device_info;
550f92363d1SSreekanth Reddy 	int	id;
551f92363d1SSreekanth Reddy 	int	channel;
552f92363d1SSreekanth Reddy 	u16	slot;
553f92363d1SSreekanth Reddy 	u8	phy;
554f92363d1SSreekanth Reddy 	u8	responding;
555f92363d1SSreekanth Reddy 	u8	fast_path;
5560f624c39SSreekanth Reddy 	u8	pfa_led_on;
557e4bc7f5cSSreekanth Reddy 	u8	pend_sas_rphy_add;
558e6d45e3eSSreekanth Reddy 	u8	enclosure_level;
55975888956SSreekanth Reddy 	u8	chassis_slot;
56075888956SSreekanth Reddy 	u8	is_chassis_slot_valid;
561310c8e40SCalvin Owens 	u8	connector_name[5];
562d1cb5e49SSreekanth Reddy 	struct kref refcount;
563f92363d1SSreekanth Reddy };
564f92363d1SSreekanth Reddy 
565d1cb5e49SSreekanth Reddy static inline void sas_device_get(struct _sas_device *s)
566d1cb5e49SSreekanth Reddy {
567d1cb5e49SSreekanth Reddy 	kref_get(&s->refcount);
568d1cb5e49SSreekanth Reddy }
569d1cb5e49SSreekanth Reddy 
570d1cb5e49SSreekanth Reddy static inline void sas_device_free(struct kref *r)
571d1cb5e49SSreekanth Reddy {
572d1cb5e49SSreekanth Reddy 	kfree(container_of(r, struct _sas_device, refcount));
573d1cb5e49SSreekanth Reddy }
574d1cb5e49SSreekanth Reddy 
575d1cb5e49SSreekanth Reddy static inline void sas_device_put(struct _sas_device *s)
576d1cb5e49SSreekanth Reddy {
577d1cb5e49SSreekanth Reddy 	kref_put(&s->refcount, sas_device_free);
578d1cb5e49SSreekanth Reddy }
579d1cb5e49SSreekanth Reddy 
580d88e1eabSSuganath Prabu Subramani /*
581d88e1eabSSuganath Prabu Subramani  * struct _pcie_device - attached PCIe device information
582d88e1eabSSuganath Prabu Subramani  * @list: pcie device list
583d88e1eabSSuganath Prabu Subramani  * @starget: starget object
584d88e1eabSSuganath Prabu Subramani  * @wwid: device WWID
585d88e1eabSSuganath Prabu Subramani  * @handle: device handle
586d88e1eabSSuganath Prabu Subramani  * @device_info: bitfield provides detailed info about the device
587d88e1eabSSuganath Prabu Subramani  * @id: target id
588d88e1eabSSuganath Prabu Subramani  * @channel: target channel
589d88e1eabSSuganath Prabu Subramani  * @slot: slot number
590d88e1eabSSuganath Prabu Subramani  * @port_num: port number
591d88e1eabSSuganath Prabu Subramani  * @responding: used in _scsih_pcie_device_mark_responding
592d88e1eabSSuganath Prabu Subramani  * @fast_path: fast path feature enable bit
593d88e1eabSSuganath Prabu Subramani  * @nvme_mdts: MaximumDataTransferSize from PCIe Device Page 2 for
594d88e1eabSSuganath Prabu Subramani  *		NVMe device only
595d88e1eabSSuganath Prabu Subramani  * @enclosure_handle: enclosure handle
596d88e1eabSSuganath Prabu Subramani  * @enclosure_logical_id: enclosure logical identifier
597d88e1eabSSuganath Prabu Subramani  * @enclosure_level: The level of device's enclosure from the controller
598d88e1eabSSuganath Prabu Subramani  * @connector_name: ASCII value of the Connector's name
599d88e1eabSSuganath Prabu Subramani  * @serial_number: pointer of serial number string allocated runtime
6003c090ce3SSuganath Prabu  * @access_status: Device's Access Status
601d3f623aeSSreekanth Reddy  * @shutdown_latency: NVMe device's RTD3 Entry Latency
602d88e1eabSSuganath Prabu Subramani  * @refcount: reference count for deletion
603d88e1eabSSuganath Prabu Subramani  */
604d88e1eabSSuganath Prabu Subramani struct _pcie_device {
605d88e1eabSSuganath Prabu Subramani 	struct list_head list;
606d88e1eabSSuganath Prabu Subramani 	struct scsi_target *starget;
607d88e1eabSSuganath Prabu Subramani 	u64	wwid;
608d88e1eabSSuganath Prabu Subramani 	u16	handle;
609d88e1eabSSuganath Prabu Subramani 	u32	device_info;
610d88e1eabSSuganath Prabu Subramani 	int	id;
611d88e1eabSSuganath Prabu Subramani 	int	channel;
612d88e1eabSSuganath Prabu Subramani 	u16	slot;
613d88e1eabSSuganath Prabu Subramani 	u8	port_num;
614d88e1eabSSuganath Prabu Subramani 	u8	responding;
615d88e1eabSSuganath Prabu Subramani 	u8	fast_path;
616d88e1eabSSuganath Prabu Subramani 	u32	nvme_mdts;
617d88e1eabSSuganath Prabu Subramani 	u16	enclosure_handle;
618d88e1eabSSuganath Prabu Subramani 	u64	enclosure_logical_id;
619d88e1eabSSuganath Prabu Subramani 	u8	enclosure_level;
620d88e1eabSSuganath Prabu Subramani 	u8	connector_name[4];
621d88e1eabSSuganath Prabu Subramani 	u8	*serial_number;
622c1a6c5acSChaitra P B 	u8	reset_timeout;
6233c090ce3SSuganath Prabu 	u8	access_status;
624d3f623aeSSreekanth Reddy 	u16	shutdown_latency;
625d88e1eabSSuganath Prabu Subramani 	struct kref refcount;
626d88e1eabSSuganath Prabu Subramani };
627d88e1eabSSuganath Prabu Subramani /**
628d88e1eabSSuganath Prabu Subramani  * pcie_device_get - Increment the pcie device reference count
629d88e1eabSSuganath Prabu Subramani  *
630d88e1eabSSuganath Prabu Subramani  * @p: pcie_device object
631d88e1eabSSuganath Prabu Subramani  *
632d88e1eabSSuganath Prabu Subramani  * When ever this function called it will increment the
633d88e1eabSSuganath Prabu Subramani  * reference count of the pcie device for which this function called.
634d88e1eabSSuganath Prabu Subramani  *
635d88e1eabSSuganath Prabu Subramani  */
636d88e1eabSSuganath Prabu Subramani static inline void pcie_device_get(struct _pcie_device *p)
637d88e1eabSSuganath Prabu Subramani {
638d88e1eabSSuganath Prabu Subramani 	kref_get(&p->refcount);
639d88e1eabSSuganath Prabu Subramani }
640d88e1eabSSuganath Prabu Subramani 
641d88e1eabSSuganath Prabu Subramani /**
642d88e1eabSSuganath Prabu Subramani  * pcie_device_free - Release the pcie device object
643d88e1eabSSuganath Prabu Subramani  * @r - kref object
644d88e1eabSSuganath Prabu Subramani  *
645d88e1eabSSuganath Prabu Subramani  * Free's the pcie device object. It will be called when reference count
646d88e1eabSSuganath Prabu Subramani  * reaches to zero.
647d88e1eabSSuganath Prabu Subramani  */
648d88e1eabSSuganath Prabu Subramani static inline void pcie_device_free(struct kref *r)
649d88e1eabSSuganath Prabu Subramani {
650d88e1eabSSuganath Prabu Subramani 	kfree(container_of(r, struct _pcie_device, refcount));
651d88e1eabSSuganath Prabu Subramani }
652d88e1eabSSuganath Prabu Subramani 
653d88e1eabSSuganath Prabu Subramani /**
654d88e1eabSSuganath Prabu Subramani  * pcie_device_put - Decrement the pcie device reference count
655d88e1eabSSuganath Prabu Subramani  *
656d88e1eabSSuganath Prabu Subramani  * @p: pcie_device object
657d88e1eabSSuganath Prabu Subramani  *
658d88e1eabSSuganath Prabu Subramani  * When ever this function called it will decrement the
659d88e1eabSSuganath Prabu Subramani  * reference count of the pcie device for which this function called.
660d88e1eabSSuganath Prabu Subramani  *
661d88e1eabSSuganath Prabu Subramani  * When refernce count reaches to Zero, this will call pcie_device_free to the
662d88e1eabSSuganath Prabu Subramani  * pcie_device object.
663d88e1eabSSuganath Prabu Subramani  */
664d88e1eabSSuganath Prabu Subramani static inline void pcie_device_put(struct _pcie_device *p)
665d88e1eabSSuganath Prabu Subramani {
666d88e1eabSSuganath Prabu Subramani 	kref_put(&p->refcount, pcie_device_free);
667d88e1eabSSuganath Prabu Subramani }
668f92363d1SSreekanth Reddy /**
669f92363d1SSreekanth Reddy  * struct _raid_device - raid volume link list
670f92363d1SSreekanth Reddy  * @list: sas device list
671f92363d1SSreekanth Reddy  * @starget: starget object
672f92363d1SSreekanth Reddy  * @sdev: scsi device struct (volumes are single lun)
673f92363d1SSreekanth Reddy  * @wwid: unique identifier for the volume
674f92363d1SSreekanth Reddy  * @handle: device handle
6757786ab6aSSreekanth Reddy  * @block_size: Block size of the volume
676f92363d1SSreekanth Reddy  * @id: target id
677f92363d1SSreekanth Reddy  * @channel: target channel
678f92363d1SSreekanth Reddy  * @volume_type: the raid level
679f92363d1SSreekanth Reddy  * @device_info: bitfield provides detailed info about the hidden components
680f92363d1SSreekanth Reddy  * @num_pds: number of hidden raid components
681f92363d1SSreekanth Reddy  * @responding: used in _scsih_raid_device_mark_responding
682f92363d1SSreekanth Reddy  * @percent_complete: resync percent complete
6837786ab6aSSreekanth Reddy  * @direct_io_enabled: Whether direct io to PDs are allowed or not
6847786ab6aSSreekanth Reddy  * @stripe_exponent: X where 2powX is the stripe sz in blocks
6857786ab6aSSreekanth Reddy  * @block_exponent: X where 2powX is the block sz in bytes
6867786ab6aSSreekanth Reddy  * @max_lba: Maximum number of LBA in the volume
6877786ab6aSSreekanth Reddy  * @stripe_sz: Stripe Size of the volume
6887786ab6aSSreekanth Reddy  * @device_info: Device info of the volume member disk
6897786ab6aSSreekanth Reddy  * @pd_handle: Array of handles of the physical drives for direct I/O in le16
690f92363d1SSreekanth Reddy  */
691f92363d1SSreekanth Reddy #define MPT_MAX_WARPDRIVE_PDS		8
692f92363d1SSreekanth Reddy struct _raid_device {
693f92363d1SSreekanth Reddy 	struct list_head list;
694f92363d1SSreekanth Reddy 	struct scsi_target *starget;
695f92363d1SSreekanth Reddy 	struct scsi_device *sdev;
696f92363d1SSreekanth Reddy 	u64	wwid;
697f92363d1SSreekanth Reddy 	u16	handle;
6987786ab6aSSreekanth Reddy 	u16	block_sz;
699f92363d1SSreekanth Reddy 	int	id;
700f92363d1SSreekanth Reddy 	int	channel;
701f92363d1SSreekanth Reddy 	u8	volume_type;
702f92363d1SSreekanth Reddy 	u8	num_pds;
703f92363d1SSreekanth Reddy 	u8	responding;
704f92363d1SSreekanth Reddy 	u8	percent_complete;
7057786ab6aSSreekanth Reddy 	u8	direct_io_enabled;
7067786ab6aSSreekanth Reddy 	u8	stripe_exponent;
7077786ab6aSSreekanth Reddy 	u8	block_exponent;
7087786ab6aSSreekanth Reddy 	u64	max_lba;
7097786ab6aSSreekanth Reddy 	u32	stripe_sz;
710f92363d1SSreekanth Reddy 	u32	device_info;
7117786ab6aSSreekanth Reddy 	u16	pd_handle[MPT_MAX_WARPDRIVE_PDS];
712f92363d1SSreekanth Reddy };
713f92363d1SSreekanth Reddy 
714f92363d1SSreekanth Reddy /**
715f92363d1SSreekanth Reddy  * struct _boot_device - boot device info
716d88e1eabSSuganath Prabu Subramani  *
717d88e1eabSSuganath Prabu Subramani  * @channel: sas, raid, or pcie channel
718d88e1eabSSuganath Prabu Subramani  * @device: holds pointer for struct _sas_device, struct _raid_device or
719d88e1eabSSuganath Prabu Subramani  *     struct _pcie_device
720f92363d1SSreekanth Reddy  */
721f92363d1SSreekanth Reddy struct _boot_device {
722d88e1eabSSuganath Prabu Subramani 	int channel;
723f92363d1SSreekanth Reddy 	void *device;
724f92363d1SSreekanth Reddy };
725f92363d1SSreekanth Reddy 
726f92363d1SSreekanth Reddy /**
727f92363d1SSreekanth Reddy  * struct _sas_port - wide/narrow sas port information
728f92363d1SSreekanth Reddy  * @port_list: list of ports belonging to expander
729f92363d1SSreekanth Reddy  * @num_phys: number of phys belonging to this port
730f92363d1SSreekanth Reddy  * @remote_identify: attached device identification
731f92363d1SSreekanth Reddy  * @rphy: sas transport rphy object
732f92363d1SSreekanth Reddy  * @port: sas transport wide/narrow port object
733f92363d1SSreekanth Reddy  * @phy_list: _sas_phy list objects belonging to this port
734f92363d1SSreekanth Reddy  */
735f92363d1SSreekanth Reddy struct _sas_port {
736f92363d1SSreekanth Reddy 	struct list_head port_list;
737f92363d1SSreekanth Reddy 	u8	num_phys;
738f92363d1SSreekanth Reddy 	struct sas_identify remote_identify;
739f92363d1SSreekanth Reddy 	struct sas_rphy *rphy;
740f92363d1SSreekanth Reddy 	struct sas_port *port;
741f92363d1SSreekanth Reddy 	struct list_head phy_list;
742f92363d1SSreekanth Reddy };
743f92363d1SSreekanth Reddy 
744f92363d1SSreekanth Reddy /**
745f92363d1SSreekanth Reddy  * struct _sas_phy - phy information
746f92363d1SSreekanth Reddy  * @port_siblings: list of phys belonging to a port
747f92363d1SSreekanth Reddy  * @identify: phy identification
748f92363d1SSreekanth Reddy  * @remote_identify: attached device identification
749f92363d1SSreekanth Reddy  * @phy: sas transport phy object
750f92363d1SSreekanth Reddy  * @phy_id: unique phy id
751f92363d1SSreekanth Reddy  * @handle: device handle for this phy
752f92363d1SSreekanth Reddy  * @attached_handle: device handle for attached device
753f92363d1SSreekanth Reddy  * @phy_belongs_to_port: port has been created for this phy
754f92363d1SSreekanth Reddy  */
755f92363d1SSreekanth Reddy struct _sas_phy {
756f92363d1SSreekanth Reddy 	struct list_head port_siblings;
757f92363d1SSreekanth Reddy 	struct sas_identify identify;
758f92363d1SSreekanth Reddy 	struct sas_identify remote_identify;
759f92363d1SSreekanth Reddy 	struct sas_phy *phy;
760f92363d1SSreekanth Reddy 	u8	phy_id;
761f92363d1SSreekanth Reddy 	u16	handle;
762f92363d1SSreekanth Reddy 	u16	attached_handle;
763f92363d1SSreekanth Reddy 	u8	phy_belongs_to_port;
764f92363d1SSreekanth Reddy };
765f92363d1SSreekanth Reddy 
766f92363d1SSreekanth Reddy /**
767f92363d1SSreekanth Reddy  * struct _sas_node - sas_host/expander information
768f92363d1SSreekanth Reddy  * @list: list of expanders
769f92363d1SSreekanth Reddy  * @parent_dev: parent device class
770f92363d1SSreekanth Reddy  * @num_phys: number phys belonging to this sas_host/expander
771f92363d1SSreekanth Reddy  * @sas_address: sas address of this sas_host/expander
772f92363d1SSreekanth Reddy  * @handle: handle for this sas_host/expander
773f92363d1SSreekanth Reddy  * @sas_address_parent: sas address of parent expander or sas host
774f92363d1SSreekanth Reddy  * @enclosure_handle: handle for this a member of an enclosure
775f92363d1SSreekanth Reddy  * @device_info: bitwise defining capabilities of this sas_host/expander
776f92363d1SSreekanth Reddy  * @responding: used in _scsih_expander_device_mark_responding
777f92363d1SSreekanth Reddy  * @phy: a list of phys that make up this sas_host/expander
778f92363d1SSreekanth Reddy  * @sas_port_list: list of ports attached to this sas_host/expander
779f92363d1SSreekanth Reddy  */
780f92363d1SSreekanth Reddy struct _sas_node {
781f92363d1SSreekanth Reddy 	struct list_head list;
782f92363d1SSreekanth Reddy 	struct device *parent_dev;
783f92363d1SSreekanth Reddy 	u8	num_phys;
784f92363d1SSreekanth Reddy 	u64	sas_address;
785f92363d1SSreekanth Reddy 	u16	handle;
786f92363d1SSreekanth Reddy 	u64	sas_address_parent;
787f92363d1SSreekanth Reddy 	u16	enclosure_handle;
788f92363d1SSreekanth Reddy 	u64	enclosure_logical_id;
789f92363d1SSreekanth Reddy 	u8	responding;
790f92363d1SSreekanth Reddy 	struct	_sas_phy *phy;
791f92363d1SSreekanth Reddy 	struct list_head sas_port_list;
792f92363d1SSreekanth Reddy };
793f92363d1SSreekanth Reddy 
79422a923c3SChaitra P B 
79522a923c3SChaitra P B /**
79622a923c3SChaitra P B  * struct _enclosure_node - enclosure information
79722a923c3SChaitra P B  * @list: list of enclosures
79822a923c3SChaitra P B  * @pg0: enclosure pg0;
79922a923c3SChaitra P B  */
80022a923c3SChaitra P B struct _enclosure_node {
80122a923c3SChaitra P B 	struct list_head list;
80222a923c3SChaitra P B 	Mpi2SasEnclosurePage0_t pg0;
80322a923c3SChaitra P B };
80422a923c3SChaitra P B 
805f92363d1SSreekanth Reddy /**
806f92363d1SSreekanth Reddy  * enum reset_type - reset state
807f92363d1SSreekanth Reddy  * @FORCE_BIG_HAMMER: issue diagnostic reset
808f92363d1SSreekanth Reddy  * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
809f92363d1SSreekanth Reddy  */
810f92363d1SSreekanth Reddy enum reset_type {
811f92363d1SSreekanth Reddy 	FORCE_BIG_HAMMER,
812f92363d1SSreekanth Reddy 	SOFT_RESET,
813f92363d1SSreekanth Reddy };
814f92363d1SSreekanth Reddy 
815f92363d1SSreekanth Reddy /**
816016d5c35SSuganath Prabu Subramani  * struct pcie_sg_list - PCIe SGL buffer (contiguous per I/O)
817016d5c35SSuganath Prabu Subramani  * @pcie_sgl: PCIe native SGL for NVMe devices
818016d5c35SSuganath Prabu Subramani  * @pcie_sgl_dma: physical address
819016d5c35SSuganath Prabu Subramani  */
820016d5c35SSuganath Prabu Subramani struct pcie_sg_list {
821016d5c35SSuganath Prabu Subramani 	void            *pcie_sgl;
822016d5c35SSuganath Prabu Subramani 	dma_addr_t      pcie_sgl_dma;
823016d5c35SSuganath Prabu Subramani };
824016d5c35SSuganath Prabu Subramani 
825016d5c35SSuganath Prabu Subramani /**
826f92363d1SSreekanth Reddy  * struct chain_tracker - firmware chain tracker
827f92363d1SSreekanth Reddy  * @chain_buffer: chain buffer
828f92363d1SSreekanth Reddy  * @chain_buffer_dma: physical address
829f92363d1SSreekanth Reddy  * @tracker_list: list of free request (ioc->free_chain_list)
830f92363d1SSreekanth Reddy  */
831f92363d1SSreekanth Reddy struct chain_tracker {
832f92363d1SSreekanth Reddy 	void *chain_buffer;
833f92363d1SSreekanth Reddy 	dma_addr_t chain_buffer_dma;
83493204b78SChaitra P B };
83593204b78SChaitra P B 
83693204b78SChaitra P B struct chain_lookup {
83793204b78SChaitra P B 	struct chain_tracker *chains_per_smid;
83893204b78SChaitra P B 	atomic_t	chain_offset;
839f92363d1SSreekanth Reddy };
840f92363d1SSreekanth Reddy 
841f92363d1SSreekanth Reddy /**
842f92363d1SSreekanth Reddy  * struct scsiio_tracker - scsi mf request tracker
843f92363d1SSreekanth Reddy  * @smid: system message id
844f92363d1SSreekanth Reddy  * @cb_idx: callback index
8457786ab6aSSreekanth Reddy  * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
846dbec4c90SSuganath Prabu Subramani  * @chain_list: list of associated firmware chain tracker
84703d1fb3aSSuganath prabu Subramani  * @msix_io: IO's msix
848f92363d1SSreekanth Reddy  */
849f92363d1SSreekanth Reddy struct scsiio_tracker {
850f92363d1SSreekanth Reddy 	u16	smid;
851998c3001SSuganath Prabu S 	struct scsi_cmnd *scmd;
852f92363d1SSreekanth Reddy 	u8	cb_idx;
8537786ab6aSSreekanth Reddy 	u8	direct_io;
854016d5c35SSuganath Prabu Subramani 	struct pcie_sg_list pcie_sg_list;
855f92363d1SSreekanth Reddy 	struct list_head chain_list;
85603d1fb3aSSuganath prabu Subramani 	u16     msix_io;
857f92363d1SSreekanth Reddy };
858f92363d1SSreekanth Reddy 
859f92363d1SSreekanth Reddy /**
860f92363d1SSreekanth Reddy  * struct request_tracker - firmware request tracker
861f92363d1SSreekanth Reddy  * @smid: system message id
862f92363d1SSreekanth Reddy  * @cb_idx: callback index
863f92363d1SSreekanth Reddy  * @tracker_list: list of free request (ioc->free_list)
864f92363d1SSreekanth Reddy  */
865f92363d1SSreekanth Reddy struct request_tracker {
866f92363d1SSreekanth Reddy 	u16	smid;
867f92363d1SSreekanth Reddy 	u8	cb_idx;
868f92363d1SSreekanth Reddy 	struct list_head tracker_list;
869f92363d1SSreekanth Reddy };
870f92363d1SSreekanth Reddy 
871f92363d1SSreekanth Reddy /**
872f92363d1SSreekanth Reddy  * struct _tr_list - target reset list
873f92363d1SSreekanth Reddy  * @handle: device handle
874f92363d1SSreekanth Reddy  * @state: state machine
875f92363d1SSreekanth Reddy  */
876f92363d1SSreekanth Reddy struct _tr_list {
877f92363d1SSreekanth Reddy 	struct list_head list;
878f92363d1SSreekanth Reddy 	u16	handle;
879f92363d1SSreekanth Reddy 	u16	state;
880f92363d1SSreekanth Reddy };
881f92363d1SSreekanth Reddy 
882fd0331b3SSuganath prabu Subramani /**
883fd0331b3SSuganath prabu Subramani  * struct _sc_list - delayed SAS_IO_UNIT_CONTROL message list
884fd0331b3SSuganath prabu Subramani  * @handle: device handle
885fd0331b3SSuganath prabu Subramani  */
886fd0331b3SSuganath prabu Subramani struct _sc_list {
887fd0331b3SSuganath prabu Subramani 	struct list_head list;
888fd0331b3SSuganath prabu Subramani 	u16     handle;
889fd0331b3SSuganath prabu Subramani };
890fd0331b3SSuganath prabu Subramani 
891fd0331b3SSuganath prabu Subramani /**
892fd0331b3SSuganath prabu Subramani  * struct _event_ack_list - delayed event acknowledgment list
893fd0331b3SSuganath prabu Subramani  * @Event: Event ID
894fd0331b3SSuganath prabu Subramani  * @EventContext: used to track the event uniquely
895fd0331b3SSuganath prabu Subramani  */
896fd0331b3SSuganath prabu Subramani struct _event_ack_list {
897fd0331b3SSuganath prabu Subramani 	struct list_head list;
898cf6bf971SChaitra P B 	U16     Event;
899cf6bf971SChaitra P B 	U32     EventContext;
900fd0331b3SSuganath prabu Subramani };
901f92363d1SSreekanth Reddy 
902f92363d1SSreekanth Reddy /**
903f92363d1SSreekanth Reddy  * struct adapter_reply_queue - the reply queue struct
904f92363d1SSreekanth Reddy  * @ioc: per adapter object
905f92363d1SSreekanth Reddy  * @msix_index: msix index into vector table
906f92363d1SSreekanth Reddy  * @vector: irq vector
907f92363d1SSreekanth Reddy  * @reply_post_host_index: head index in the pool where FW completes IO
908f92363d1SSreekanth Reddy  * @reply_post_free: reply post base virt address
909f92363d1SSreekanth Reddy  * @name: the name registered to request_irq()
910f92363d1SSreekanth Reddy  * @busy: isr is actively processing replies on another cpu
911320e77acSSuganath Prabu  * @os_irq: irq number
912320e77acSSuganath Prabu  * @irqpoll: irq_poll object
913320e77acSSuganath Prabu  * @irq_poll_scheduled: Tells whether irq poll is scheduled or not
914f92363d1SSreekanth Reddy  * @list: this list
915f92363d1SSreekanth Reddy */
916f92363d1SSreekanth Reddy struct adapter_reply_queue {
917f92363d1SSreekanth Reddy 	struct MPT3SAS_ADAPTER	*ioc;
918f92363d1SSreekanth Reddy 	u8			msix_index;
919f92363d1SSreekanth Reddy 	u32			reply_post_host_index;
920f92363d1SSreekanth Reddy 	Mpi2ReplyDescriptorsUnion_t *reply_post_free;
921f92363d1SSreekanth Reddy 	char			name[MPT_NAME_LENGTH];
922f92363d1SSreekanth Reddy 	atomic_t		busy;
923320e77acSSuganath Prabu 	u32			os_irq;
924320e77acSSuganath Prabu 	struct irq_poll         irqpoll;
925320e77acSSuganath Prabu 	bool			irq_poll_scheduled;
926320e77acSSuganath Prabu 	bool			irq_line_enable;
927f92363d1SSreekanth Reddy 	struct list_head	list;
928f92363d1SSreekanth Reddy };
929f92363d1SSreekanth Reddy 
930f92363d1SSreekanth Reddy typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
931f92363d1SSreekanth Reddy 
932f92363d1SSreekanth Reddy /* SAS3.0 support */
933f92363d1SSreekanth Reddy typedef int (*MPT_BUILD_SG_SCMD)(struct MPT3SAS_ADAPTER *ioc,
934016d5c35SSuganath Prabu Subramani 	struct scsi_cmnd *scmd, u16 smid, struct _pcie_device *pcie_device);
935f92363d1SSreekanth Reddy typedef void (*MPT_BUILD_SG)(struct MPT3SAS_ADAPTER *ioc, void *psge,
936f92363d1SSreekanth Reddy 		dma_addr_t data_out_dma, size_t data_out_sz,
937f92363d1SSreekanth Reddy 		dma_addr_t data_in_dma, size_t data_in_sz);
938f92363d1SSreekanth Reddy typedef void (*MPT_BUILD_ZERO_LEN_SGE)(struct MPT3SAS_ADAPTER *ioc,
939f92363d1SSreekanth Reddy 		void *paddr);
940f92363d1SSreekanth Reddy 
941016d5c35SSuganath Prabu Subramani /* SAS3.5 support */
942016d5c35SSuganath Prabu Subramani typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid,
943016d5c35SSuganath Prabu Subramani 	Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request,
944016d5c35SSuganath Prabu Subramani 	dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma,
945016d5c35SSuganath Prabu Subramani 	size_t data_in_sz);
946016d5c35SSuganath Prabu Subramani 
94781c16f83SSuganath Prabu Subramani /* To support atomic and non atomic descriptors*/
94881c16f83SSuganath Prabu Subramani typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
94981c16f83SSuganath Prabu Subramani 	u16 funcdep);
95081c16f83SSuganath Prabu Subramani typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
951b8992029SSuganath Prabu typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr);
9525dd48a55SSuganath Prabu S /*
9535dd48a55SSuganath Prabu S  * To get high iops reply queue's msix index when high iops mode is enabled
9545dd48a55SSuganath Prabu S  * else get the msix index of general reply queues.
9555dd48a55SSuganath Prabu S  */
9565dd48a55SSuganath Prabu S typedef u8 (*GET_MSIX_INDEX) (struct MPT3SAS_ADAPTER *ioc,
9575dd48a55SSuganath Prabu S 	struct scsi_cmnd *scmd);
958f92363d1SSreekanth Reddy 
959f92363d1SSreekanth Reddy /* IOC Facts and Port Facts converted from little endian to cpu */
960f92363d1SSreekanth Reddy union mpi3_version_union {
961f92363d1SSreekanth Reddy 	MPI2_VERSION_STRUCT		Struct;
962f92363d1SSreekanth Reddy 	u32				Word;
963f92363d1SSreekanth Reddy };
964f92363d1SSreekanth Reddy 
965f92363d1SSreekanth Reddy struct mpt3sas_facts {
966f92363d1SSreekanth Reddy 	u16			MsgVersion;
967f92363d1SSreekanth Reddy 	u16			HeaderVersion;
968f92363d1SSreekanth Reddy 	u8			IOCNumber;
969f92363d1SSreekanth Reddy 	u8			VP_ID;
970f92363d1SSreekanth Reddy 	u8			VF_ID;
971f92363d1SSreekanth Reddy 	u16			IOCExceptions;
972f92363d1SSreekanth Reddy 	u16			IOCStatus;
973f92363d1SSreekanth Reddy 	u32			IOCLogInfo;
974f92363d1SSreekanth Reddy 	u8			MaxChainDepth;
975f92363d1SSreekanth Reddy 	u8			WhoInit;
976f92363d1SSreekanth Reddy 	u8			NumberOfPorts;
977f92363d1SSreekanth Reddy 	u8			MaxMSIxVectors;
978f92363d1SSreekanth Reddy 	u16			RequestCredit;
979f92363d1SSreekanth Reddy 	u16			ProductID;
980f92363d1SSreekanth Reddy 	u32			IOCCapabilities;
981f92363d1SSreekanth Reddy 	union mpi3_version_union	FWVersion;
982f92363d1SSreekanth Reddy 	u16			IOCRequestFrameSize;
983ebb3024eSSuganath prabu Subramani 	u16			IOCMaxChainSegmentSize;
984f92363d1SSreekanth Reddy 	u16			MaxInitiators;
985f92363d1SSreekanth Reddy 	u16			MaxTargets;
986f92363d1SSreekanth Reddy 	u16			MaxSasExpanders;
987f92363d1SSreekanth Reddy 	u16			MaxEnclosures;
988f92363d1SSreekanth Reddy 	u16			ProtocolFlags;
989f92363d1SSreekanth Reddy 	u16			HighPriorityCredit;
990f92363d1SSreekanth Reddy 	u16			MaxReplyDescriptorPostQueueDepth;
991f92363d1SSreekanth Reddy 	u8			ReplyFrameSize;
992f92363d1SSreekanth Reddy 	u8			MaxVolumes;
993f92363d1SSreekanth Reddy 	u16			MaxDevHandle;
994f92363d1SSreekanth Reddy 	u16			MaxPersistentEntries;
995f92363d1SSreekanth Reddy 	u16			MinDevHandle;
996016d5c35SSuganath Prabu Subramani 	u8			CurrentHostPageSize;
997f92363d1SSreekanth Reddy };
998f92363d1SSreekanth Reddy 
999f92363d1SSreekanth Reddy struct mpt3sas_port_facts {
1000f92363d1SSreekanth Reddy 	u8			PortNumber;
1001f92363d1SSreekanth Reddy 	u8			VP_ID;
1002f92363d1SSreekanth Reddy 	u8			VF_ID;
1003f92363d1SSreekanth Reddy 	u8			PortType;
1004f92363d1SSreekanth Reddy 	u16			MaxPostedCmdBuffers;
1005f92363d1SSreekanth Reddy };
1006f92363d1SSreekanth Reddy 
10079b05c91aSSreekanth Reddy struct reply_post_struct {
10089b05c91aSSreekanth Reddy 	Mpi2ReplyDescriptorsUnion_t	*reply_post_free;
10099b05c91aSSreekanth Reddy 	dma_addr_t			reply_post_free_dma;
10109b05c91aSSreekanth Reddy };
10119b05c91aSSreekanth Reddy 
1012f92363d1SSreekanth Reddy typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
1013f92363d1SSreekanth Reddy /**
1014f92363d1SSreekanth Reddy  * struct MPT3SAS_ADAPTER - per adapter struct
1015f92363d1SSreekanth Reddy  * @list: ioc_list
1016f92363d1SSreekanth Reddy  * @shost: shost object
1017f92363d1SSreekanth Reddy  * @id: unique adapter id
1018f92363d1SSreekanth Reddy  * @cpu_count: number online cpus
1019f92363d1SSreekanth Reddy  * @name: generic ioc string
1020f92363d1SSreekanth Reddy  * @tmp_string: tmp string used for logging
1021f92363d1SSreekanth Reddy  * @pdev: pci pdev object
1022f92363d1SSreekanth Reddy  * @pio_chip: physical io register space
1023f92363d1SSreekanth Reddy  * @chip: memory mapped register space
1024f92363d1SSreekanth Reddy  * @chip_phys: physical addrss prior to mapping
1025f92363d1SSreekanth Reddy  * @logging_level: see mpt3sas_debug.h
1026f92363d1SSreekanth Reddy  * @fwfault_debug: debuging FW timeouts
1027f92363d1SSreekanth Reddy  * @ir_firmware: IR firmware present
1028f92363d1SSreekanth Reddy  * @bars: bitmask of BAR's that must be configured
1029f92363d1SSreekanth Reddy  * @mask_interrupts: ignore interrupt
1030d88e1eabSSuganath Prabu Subramani  * @pci_access_mutex: Mutex to synchronize ioctl, sysfs show path and
1031d88e1eabSSuganath Prabu Subramani  *			pci resource handling
1032f92363d1SSreekanth Reddy  * @fault_reset_work_q_name: fw fault work queue
1033f92363d1SSreekanth Reddy  * @fault_reset_work_q: ""
1034f92363d1SSreekanth Reddy  * @fault_reset_work: ""
1035f92363d1SSreekanth Reddy  * @firmware_event_name: fw event work queue
1036f92363d1SSreekanth Reddy  * @firmware_event_thread: ""
1037f92363d1SSreekanth Reddy  * @fw_event_lock:
1038f92363d1SSreekanth Reddy  * @fw_event_list: list of fw events
10399e73ed2eSSuganath Prabu S  * @current_evet: current processing firmware event
10409e73ed2eSSuganath Prabu S  * @fw_event_cleanup: set to one while cleaning up the fw events
1041f92363d1SSreekanth Reddy  * @aen_event_read_flag: event log was read
1042f92363d1SSreekanth Reddy  * @broadcast_aen_busy: broadcast aen waiting to be serviced
1043f92363d1SSreekanth Reddy  * @shost_recovery: host reset in progress
1044f92363d1SSreekanth Reddy  * @ioc_reset_in_progress_lock:
1045f92363d1SSreekanth Reddy  * @ioc_link_reset_in_progress: phy/hard reset in progress
1046f92363d1SSreekanth Reddy  * @ignore_loginfos: ignore loginfos during task management
1047f92363d1SSreekanth Reddy  * @remove_host: flag for when driver unloads, to avoid sending dev resets
1048f92363d1SSreekanth Reddy  * @pci_error_recovery: flag to prevent ioc access until slot reset completes
1049f92363d1SSreekanth Reddy  * @wait_for_discovery_to_complete: flag set at driver load time when
1050f92363d1SSreekanth Reddy  *                                               waiting on reporting devices
1051f92363d1SSreekanth Reddy  * @is_driver_loading: flag set at driver load time
1052f92363d1SSreekanth Reddy  * @port_enable_failed: flag set when port enable has failed
1053f92363d1SSreekanth Reddy  * @start_scan: flag set from scan_start callback, cleared from _mpt3sas_fw_work
1054f92363d1SSreekanth Reddy  * @start_scan_failed: means port enable failed, return's the ioc_status
1055f92363d1SSreekanth Reddy  * @msix_enable: flag indicating msix is enabled
1056f92363d1SSreekanth Reddy  * @msix_vector_count: number msix vectors
1057f92363d1SSreekanth Reddy  * @cpu_msix_table: table for mapping cpus to msix index
1058f92363d1SSreekanth Reddy  * @cpu_msix_table_sz: table size
105951e3b2adSSuganath Prabu  * @total_io_cnt: Gives total IO count, used to load balance the interrupts
1060fce0aa08SSreekanth Reddy  * @ioc_coredump_loop: will have non-zero value when FW is in CoreDump state
10615dd48a55SSuganath Prabu S  * @high_iops_outstanding: used to load balance the interrupts
10625dd48a55SSuganath Prabu S  *				within high iops reply queues
106351e3b2adSSuganath Prabu  * @msix_load_balance: Enables load balancing of interrupts across
106451e3b2adSSuganath Prabu  * the multiple MSIXs
1065f92363d1SSreekanth Reddy  * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
1066288addd6SSuganath Prabu  * @thresh_hold: Max number of reply descriptors processed
1067288addd6SSuganath Prabu  *				before updating Host Index
10683ac8e47bSSuganath Prabu  * @drv_support_bitmap: driver's supported feature bit map
10698012209eSSuganath Prabu  * @use_32bit_dma: Flag to use 32 bit consistent dma mask
1070f92363d1SSreekanth Reddy  * @scsi_io_cb_idx: shost generated commands
1071f92363d1SSreekanth Reddy  * @tm_cb_idx: task management commands
1072f92363d1SSreekanth Reddy  * @scsih_cb_idx: scsih internal commands
1073f92363d1SSreekanth Reddy  * @transport_cb_idx: transport internal commands
1074f92363d1SSreekanth Reddy  * @ctl_cb_idx: clt internal commands
1075f92363d1SSreekanth Reddy  * @base_cb_idx: base internal commands
1076f92363d1SSreekanth Reddy  * @config_cb_idx: base internal commands
1077f92363d1SSreekanth Reddy  * @tm_tr_cb_idx : device removal target reset handshake
1078f92363d1SSreekanth Reddy  * @tm_tr_volume_cb_idx : volume removal target reset
1079f92363d1SSreekanth Reddy  * @base_cmds:
1080f92363d1SSreekanth Reddy  * @transport_cmds:
1081f92363d1SSreekanth Reddy  * @scsih_cmds:
1082f92363d1SSreekanth Reddy  * @tm_cmds:
1083f92363d1SSreekanth Reddy  * @ctl_cmds:
1084f92363d1SSreekanth Reddy  * @config_cmds:
1085f92363d1SSreekanth Reddy  * @base_add_sg_single: handler for either 32/64 bit sgl's
1086f92363d1SSreekanth Reddy  * @event_type: bits indicating which events to log
1087f92363d1SSreekanth Reddy  * @event_context: unique id for each logged event
1088f92363d1SSreekanth Reddy  * @event_log: event log pointer
1089f92363d1SSreekanth Reddy  * @event_masks: events that are masked
1090d3f623aeSSreekanth Reddy  * @max_shutdown_latency: timeout value for NVMe shutdown operation,
1091d3f623aeSSreekanth Reddy  *			which is equal that NVMe drive's RTD3 Entry Latency
1092d3f623aeSSreekanth Reddy  *			which has reported maximum RTD3 Entry Latency value
1093d3f623aeSSreekanth Reddy  *			among attached NVMe drives.
1094f92363d1SSreekanth Reddy  * @facts: static facts data
1095ffedeae1SSuganath Prabu  * @prev_fw_facts: previous fw facts data
1096f92363d1SSreekanth Reddy  * @pfacts: static port facts data
1097f92363d1SSreekanth Reddy  * @manu_pg0: static manufacturing page 0
1098f92363d1SSreekanth Reddy  * @manu_pg10: static manufacturing page 10
1099f92363d1SSreekanth Reddy  * @manu_pg11: static manufacturing page 11
1100f92363d1SSreekanth Reddy  * @bios_pg2: static bios page 2
1101f92363d1SSreekanth Reddy  * @bios_pg3: static bios page 3
1102f92363d1SSreekanth Reddy  * @ioc_pg8: static ioc page 8
1103f92363d1SSreekanth Reddy  * @iounit_pg0: static iounit page 0
1104f92363d1SSreekanth Reddy  * @iounit_pg1: static iounit page 1
11052d8ce8c9SSreekanth Reddy  * @iounit_pg8: static iounit page 8
1106f92363d1SSreekanth Reddy  * @sas_hba: sas host object
1107f92363d1SSreekanth Reddy  * @sas_expander_list: expander object list
110822a923c3SChaitra P B  * @enclosure_list: enclosure object list
1109f92363d1SSreekanth Reddy  * @sas_node_lock:
1110f92363d1SSreekanth Reddy  * @sas_device_list: sas device object list
1111f92363d1SSreekanth Reddy  * @sas_device_init_list: sas device object list (used only at init time)
1112f92363d1SSreekanth Reddy  * @sas_device_lock:
1113d88e1eabSSuganath Prabu Subramani  * @pcie_device_list: pcie device object list
1114d88e1eabSSuganath Prabu Subramani  * @pcie_device_init_list: pcie device object list (used only at init time)
1115d88e1eabSSuganath Prabu Subramani  * @pcie_device_lock:
1116f92363d1SSreekanth Reddy  * @io_missing_delay: time for IO completed by fw when PDR enabled
1117f92363d1SSreekanth Reddy  * @device_missing_delay: time for device missing by fw when PDR enabled
1118f92363d1SSreekanth Reddy  * @sas_id : used for setting volume target IDs
1119d88e1eabSSuganath Prabu Subramani  * @pcie_target_id: used for setting pcie target IDs
1120f92363d1SSreekanth Reddy  * @blocking_handles: bitmask used to identify which devices need blocking
1121f92363d1SSreekanth Reddy  * @pd_handles : bitmask for PD handles
1122f92363d1SSreekanth Reddy  * @pd_handles_sz : size of pd_handle bitmask
1123f92363d1SSreekanth Reddy  * @config_page_sz: config page size
1124f92363d1SSreekanth Reddy  * @config_page: reserve memory for config page payload
1125f92363d1SSreekanth Reddy  * @config_page_dma:
1126f92363d1SSreekanth Reddy  * @hba_queue_depth: hba request queue depth
1127f92363d1SSreekanth Reddy  * @sge_size: sg element size for either 32/64 bit
1128f92363d1SSreekanth Reddy  * @scsiio_depth: SCSI_IO queue depth
1129f92363d1SSreekanth Reddy  * @request_sz: per request frame size
1130f92363d1SSreekanth Reddy  * @request: pool of request frames
1131f92363d1SSreekanth Reddy  * @request_dma:
1132f92363d1SSreekanth Reddy  * @request_dma_sz:
1133f92363d1SSreekanth Reddy  * @scsi_lookup: firmware request tracker list
1134f92363d1SSreekanth Reddy  * @scsi_lookup_lock:
1135f92363d1SSreekanth Reddy  * @free_list: free list of request
1136f92363d1SSreekanth Reddy  * @pending_io_count:
1137f92363d1SSreekanth Reddy  * @reset_wq:
1138f92363d1SSreekanth Reddy  * @chain: pool of chains
1139f92363d1SSreekanth Reddy  * @chain_dma:
1140f92363d1SSreekanth Reddy  * @max_sges_in_main_message: number sg elements in main message
1141f92363d1SSreekanth Reddy  * @max_sges_in_chain_message: number sg elements per chain
1142f92363d1SSreekanth Reddy  * @chains_needed_per_io: max chains per io
1143f92363d1SSreekanth Reddy  * @chain_depth: total chains allocated
1144ebb3024eSSuganath prabu Subramani  * @chain_segment_sz: gives the max number of
1145ebb3024eSSuganath prabu Subramani  *			SGEs accommodate on single chain buffer
1146f92363d1SSreekanth Reddy  * @hi_priority_smid:
1147f92363d1SSreekanth Reddy  * @hi_priority:
1148f92363d1SSreekanth Reddy  * @hi_priority_dma:
1149f92363d1SSreekanth Reddy  * @hi_priority_depth:
1150f92363d1SSreekanth Reddy  * @hpr_lookup:
1151f92363d1SSreekanth Reddy  * @hpr_free_list:
1152f92363d1SSreekanth Reddy  * @internal_smid:
1153f92363d1SSreekanth Reddy  * @internal:
1154f92363d1SSreekanth Reddy  * @internal_dma:
1155f92363d1SSreekanth Reddy  * @internal_depth:
1156f92363d1SSreekanth Reddy  * @internal_lookup:
1157f92363d1SSreekanth Reddy  * @internal_free_list:
1158f92363d1SSreekanth Reddy  * @sense: pool of sense
1159f92363d1SSreekanth Reddy  * @sense_dma:
1160f92363d1SSreekanth Reddy  * @sense_dma_pool:
1161f92363d1SSreekanth Reddy  * @reply_depth: hba reply queue depth:
1162f92363d1SSreekanth Reddy  * @reply_sz: per reply frame size:
1163f92363d1SSreekanth Reddy  * @reply: pool of replys:
1164f92363d1SSreekanth Reddy  * @reply_dma:
1165f92363d1SSreekanth Reddy  * @reply_dma_pool:
1166f92363d1SSreekanth Reddy  * @reply_free_queue_depth: reply free depth
1167f92363d1SSreekanth Reddy  * @reply_free: pool for reply free queue (32 bit addr)
1168f92363d1SSreekanth Reddy  * @reply_free_dma:
1169f92363d1SSreekanth Reddy  * @reply_free_dma_pool:
1170f92363d1SSreekanth Reddy  * @reply_free_host_index: tail index in pool to insert free replys
1171f92363d1SSreekanth Reddy  * @reply_post_queue_depth: reply post queue depth
11729b05c91aSSreekanth Reddy  * @reply_post_struct: struct for reply_post_free physical & virt address
11739b05c91aSSreekanth Reddy  * @rdpq_array_capable: FW supports multiple reply queue addresses in ioc_init
11749b05c91aSSreekanth Reddy  * @rdpq_array_enable: rdpq_array support is enabled in the driver
11759b05c91aSSreekanth Reddy  * @rdpq_array_enable_assigned: this ensures that rdpq_array_enable flag
11769b05c91aSSreekanth Reddy  *				is assigned only ones
1177f92363d1SSreekanth Reddy  * @reply_queue_count: number of reply queue's
1178f92363d1SSreekanth Reddy  * @reply_queue_list: link list contaning the reply queue info
1179fb77bb53SSreekanth Reddy  * @msix96_vector: 96 MSI-X vector support
1180fb77bb53SSreekanth Reddy  * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
1181f92363d1SSreekanth Reddy  * @delayed_tr_list: target reset link list
1182f92363d1SSreekanth Reddy  * @delayed_tr_volume_list: volume target reset link list
1183fd0331b3SSuganath prabu Subramani  * @delayed_sc_list:
1184fd0331b3SSuganath prabu Subramani  * @delayed_event_ack_list:
118508c4d550SSreekanth Reddy  * @temp_sensors_count: flag to carry the number of temperature sensors
118608c4d550SSreekanth Reddy  * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
118708c4d550SSreekanth Reddy  *	pci resource handling. PCI resource freeing will lead to free
118808c4d550SSreekanth Reddy  *	vital hardware/memory resource, which might be in use by cli/sysfs
118908c4d550SSreekanth Reddy  *	path functions resulting in Null pointer reference followed by kernel
119008c4d550SSreekanth Reddy  *	crash. To avoid the above race condition we use mutex syncrhonization
119108c4d550SSreekanth Reddy  *	which ensures the syncrhonization between cli/sysfs_show path.
119279c74d03SSuganath Prabu S  * @atomic_desc_capable: Atomic Request Descriptor support.
11935dd48a55SSuganath Prabu S  * @GET_MSIX_INDEX: Get the msix index of high iops queues.
1194f92363d1SSreekanth Reddy  */
1195f92363d1SSreekanth Reddy struct MPT3SAS_ADAPTER {
1196f92363d1SSreekanth Reddy 	struct list_head list;
1197f92363d1SSreekanth Reddy 	struct Scsi_Host *shost;
1198f92363d1SSreekanth Reddy 	u8		id;
1199f92363d1SSreekanth Reddy 	int		cpu_count;
1200f92363d1SSreekanth Reddy 	char		name[MPT_NAME_LENGTH];
1201bbfd8e8bSArnd Bergmann 	char		driver_name[MPT_NAME_LENGTH - 8];
1202f92363d1SSreekanth Reddy 	char		tmp_string[MPT_STRING_LENGTH];
1203f92363d1SSreekanth Reddy 	struct pci_dev	*pdev;
1204f92363d1SSreekanth Reddy 	Mpi2SystemInterfaceRegs_t __iomem *chip;
12056f9e09fdSArnd Bergmann 	phys_addr_t	chip_phys;
1206f92363d1SSreekanth Reddy 	int		logging_level;
1207f92363d1SSreekanth Reddy 	int		fwfault_debug;
1208f92363d1SSreekanth Reddy 	u8		ir_firmware;
1209f92363d1SSreekanth Reddy 	int		bars;
1210f92363d1SSreekanth Reddy 	u8		mask_interrupts;
1211f92363d1SSreekanth Reddy 
1212f92363d1SSreekanth Reddy 	/* fw fault handler */
1213f92363d1SSreekanth Reddy 	char		fault_reset_work_q_name[20];
1214f92363d1SSreekanth Reddy 	struct workqueue_struct *fault_reset_work_q;
1215f92363d1SSreekanth Reddy 	struct delayed_work fault_reset_work;
1216f92363d1SSreekanth Reddy 
1217f92363d1SSreekanth Reddy 	/* fw event handler */
1218f92363d1SSreekanth Reddy 	char		firmware_event_name[20];
1219f92363d1SSreekanth Reddy 	struct workqueue_struct	*firmware_event_thread;
1220f92363d1SSreekanth Reddy 	spinlock_t	fw_event_lock;
1221f92363d1SSreekanth Reddy 	struct list_head fw_event_list;
12229e73ed2eSSuganath Prabu S 	struct fw_event_work	*current_event;
12239e73ed2eSSuganath Prabu S 	u8		fw_events_cleanup;
1224f92363d1SSreekanth Reddy 
1225f92363d1SSreekanth Reddy 	 /* misc flags */
1226f92363d1SSreekanth Reddy 	int		aen_event_read_flag;
1227f92363d1SSreekanth Reddy 	u8		broadcast_aen_busy;
1228f92363d1SSreekanth Reddy 	u16		broadcast_aen_pending;
1229f92363d1SSreekanth Reddy 	u8		shost_recovery;
1230459325c4SChaitra P B 	u8		got_task_abort_from_ioctl;
1231f92363d1SSreekanth Reddy 
1232f92363d1SSreekanth Reddy 	struct mutex	reset_in_progress_mutex;
1233f92363d1SSreekanth Reddy 	spinlock_t	ioc_reset_in_progress_lock;
1234f92363d1SSreekanth Reddy 	u8		ioc_link_reset_in_progress;
1235f92363d1SSreekanth Reddy 
1236f92363d1SSreekanth Reddy 	u8		ignore_loginfos;
1237f92363d1SSreekanth Reddy 	u8		remove_host;
1238f92363d1SSreekanth Reddy 	u8		pci_error_recovery;
1239f92363d1SSreekanth Reddy 	u8		wait_for_discovery_to_complete;
1240f92363d1SSreekanth Reddy 	u8		is_driver_loading;
1241f92363d1SSreekanth Reddy 	u8		port_enable_failed;
1242f92363d1SSreekanth Reddy 	u8		start_scan;
1243f92363d1SSreekanth Reddy 	u16		start_scan_failed;
1244f92363d1SSreekanth Reddy 
1245f92363d1SSreekanth Reddy 	u8		msix_enable;
1246f92363d1SSreekanth Reddy 	u16		msix_vector_count;
1247f92363d1SSreekanth Reddy 	u8		*cpu_msix_table;
1248f92363d1SSreekanth Reddy 	u16		cpu_msix_table_sz;
12497786ab6aSSreekanth Reddy 	resource_size_t __iomem **reply_post_host_index;
1250f92363d1SSreekanth Reddy 	u32		ioc_reset_count;
1251f92363d1SSreekanth Reddy 	MPT3SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
125216e179bdSSreekanth Reddy 	u32             non_operational_loop;
1253fce0aa08SSreekanth Reddy 	u8              ioc_coredump_loop;
125451e3b2adSSuganath Prabu 	atomic64_t      total_io_cnt;
12555dd48a55SSuganath Prabu S 	atomic64_t	high_iops_outstanding;
125651e3b2adSSuganath Prabu 	bool            msix_load_balance;
1257288addd6SSuganath Prabu 	u16		thresh_hold;
125818fd3d8cSSuganath Prabu S 	u8		high_iops_queues;
12593ac8e47bSSuganath Prabu 	u32		drv_support_bitmap;
12608dc8d29aSSreekanth Reddy 	bool		enable_sdev_max_qd;
12618012209eSSuganath Prabu 	bool		use_32bit_dma;
1262f92363d1SSreekanth Reddy 
1263f92363d1SSreekanth Reddy 	/* internal commands, callback index */
1264f92363d1SSreekanth Reddy 	u8		scsi_io_cb_idx;
1265f92363d1SSreekanth Reddy 	u8		tm_cb_idx;
1266f92363d1SSreekanth Reddy 	u8		transport_cb_idx;
1267f92363d1SSreekanth Reddy 	u8		scsih_cb_idx;
1268f92363d1SSreekanth Reddy 	u8		ctl_cb_idx;
1269f92363d1SSreekanth Reddy 	u8		base_cb_idx;
1270f92363d1SSreekanth Reddy 	u8		port_enable_cb_idx;
1271f92363d1SSreekanth Reddy 	u8		config_cb_idx;
1272f92363d1SSreekanth Reddy 	u8		tm_tr_cb_idx;
1273f92363d1SSreekanth Reddy 	u8		tm_tr_volume_cb_idx;
1274f92363d1SSreekanth Reddy 	u8		tm_sas_control_cb_idx;
1275f92363d1SSreekanth Reddy 	struct _internal_cmd base_cmds;
1276f92363d1SSreekanth Reddy 	struct _internal_cmd port_enable_cmds;
1277f92363d1SSreekanth Reddy 	struct _internal_cmd transport_cmds;
1278f92363d1SSreekanth Reddy 	struct _internal_cmd scsih_cmds;
1279f92363d1SSreekanth Reddy 	struct _internal_cmd tm_cmds;
1280f92363d1SSreekanth Reddy 	struct _internal_cmd ctl_cmds;
1281f92363d1SSreekanth Reddy 	struct _internal_cmd config_cmds;
1282f92363d1SSreekanth Reddy 
1283f92363d1SSreekanth Reddy 	MPT_ADD_SGE	base_add_sg_single;
1284f92363d1SSreekanth Reddy 
1285f92363d1SSreekanth Reddy 	/* function ptr for either IEEE or MPI sg elements */
1286f92363d1SSreekanth Reddy 	MPT_BUILD_SG_SCMD build_sg_scmd;
1287f92363d1SSreekanth Reddy 	MPT_BUILD_SG    build_sg;
1288f92363d1SSreekanth Reddy 	MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
1289f92363d1SSreekanth Reddy 	u16             sge_size_ieee;
1290d357e84dSSreekanth Reddy 	u16		hba_mpi_version_belonged;
1291f92363d1SSreekanth Reddy 
1292f92363d1SSreekanth Reddy 	/* function ptr for MPI sg elements only */
1293f92363d1SSreekanth Reddy 	MPT_BUILD_SG    build_sg_mpi;
1294f92363d1SSreekanth Reddy 	MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge_mpi;
1295f92363d1SSreekanth Reddy 
1296aff39e61SSuganath Prabu Subramani 	/* function ptr for NVMe PRP elements only */
1297aff39e61SSuganath Prabu Subramani 	NVME_BUILD_PRP  build_nvme_prp;
1298aff39e61SSuganath Prabu Subramani 
1299f92363d1SSreekanth Reddy 	/* event log */
1300f92363d1SSreekanth Reddy 	u32		event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
1301f92363d1SSreekanth Reddy 	u32		event_context;
1302f92363d1SSreekanth Reddy 	void		*event_log;
1303f92363d1SSreekanth Reddy 	u32		event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
1304f92363d1SSreekanth Reddy 
1305c1a6c5acSChaitra P B 	u8		tm_custom_handling;
1306c1a6c5acSChaitra P B 	u8		nvme_abort_timeout;
1307d3f623aeSSreekanth Reddy 	u16		max_shutdown_latency;
1308c1a6c5acSChaitra P B 
1309f92363d1SSreekanth Reddy 	/* static config pages */
1310f92363d1SSreekanth Reddy 	struct mpt3sas_facts facts;
1311ffedeae1SSuganath Prabu 	struct mpt3sas_facts prev_fw_facts;
1312f92363d1SSreekanth Reddy 	struct mpt3sas_port_facts *pfacts;
1313f92363d1SSreekanth Reddy 	Mpi2ManufacturingPage0_t manu_pg0;
1314f92363d1SSreekanth Reddy 	struct Mpi2ManufacturingPage10_t manu_pg10;
1315f92363d1SSreekanth Reddy 	struct Mpi2ManufacturingPage11_t manu_pg11;
1316f92363d1SSreekanth Reddy 	Mpi2BiosPage2_t	bios_pg2;
1317f92363d1SSreekanth Reddy 	Mpi2BiosPage3_t	bios_pg3;
1318f92363d1SSreekanth Reddy 	Mpi2IOCPage8_t ioc_pg8;
1319f92363d1SSreekanth Reddy 	Mpi2IOUnitPage0_t iounit_pg0;
1320f92363d1SSreekanth Reddy 	Mpi2IOUnitPage1_t iounit_pg1;
13212d8ce8c9SSreekanth Reddy 	Mpi2IOUnitPage8_t iounit_pg8;
13222426f209SSuganath Prabu S 	Mpi2IOCPage1_t	ioc_pg1_copy;
1323f92363d1SSreekanth Reddy 
1324f92363d1SSreekanth Reddy 	struct _boot_device req_boot_device;
1325f92363d1SSreekanth Reddy 	struct _boot_device req_alt_boot_device;
1326f92363d1SSreekanth Reddy 	struct _boot_device current_boot_device;
1327f92363d1SSreekanth Reddy 
1328f92363d1SSreekanth Reddy 	/* sas hba, expander, and device list */
1329f92363d1SSreekanth Reddy 	struct _sas_node sas_hba;
1330f92363d1SSreekanth Reddy 	struct list_head sas_expander_list;
133122a923c3SChaitra P B 	struct list_head enclosure_list;
1332f92363d1SSreekanth Reddy 	spinlock_t	sas_node_lock;
1333f92363d1SSreekanth Reddy 	struct list_head sas_device_list;
1334f92363d1SSreekanth Reddy 	struct list_head sas_device_init_list;
1335f92363d1SSreekanth Reddy 	spinlock_t	sas_device_lock;
1336d88e1eabSSuganath Prabu Subramani 	struct list_head pcie_device_list;
1337d88e1eabSSuganath Prabu Subramani 	struct list_head pcie_device_init_list;
1338d88e1eabSSuganath Prabu Subramani 	spinlock_t      pcie_device_lock;
1339d88e1eabSSuganath Prabu Subramani 
1340f92363d1SSreekanth Reddy 	struct list_head raid_device_list;
1341f92363d1SSreekanth Reddy 	spinlock_t	raid_device_lock;
1342f92363d1SSreekanth Reddy 	u8		io_missing_delay;
1343f92363d1SSreekanth Reddy 	u16		device_missing_delay;
1344f92363d1SSreekanth Reddy 	int		sas_id;
1345d88e1eabSSuganath Prabu Subramani 	int		pcie_target_id;
1346f92363d1SSreekanth Reddy 
1347f92363d1SSreekanth Reddy 	void		*blocking_handles;
1348f92363d1SSreekanth Reddy 	void		*pd_handles;
1349f92363d1SSreekanth Reddy 	u16		pd_handles_sz;
1350f92363d1SSreekanth Reddy 
1351c696f7b8SSuganath Prabu Subramani 	void		*pend_os_device_add;
1352c696f7b8SSuganath Prabu Subramani 	u16		pend_os_device_add_sz;
1353c696f7b8SSuganath Prabu Subramani 
1354f92363d1SSreekanth Reddy 	/* config page */
1355f92363d1SSreekanth Reddy 	u16		config_page_sz;
1356f92363d1SSreekanth Reddy 	void		*config_page;
1357f92363d1SSreekanth Reddy 	dma_addr_t	config_page_dma;
1358182ac784SSuganath Prabu Subramani 	void		*config_vaddr;
1359f92363d1SSreekanth Reddy 
1360f92363d1SSreekanth Reddy 	/* scsiio request */
1361f92363d1SSreekanth Reddy 	u16		hba_queue_depth;
1362f92363d1SSreekanth Reddy 	u16		sge_size;
1363f92363d1SSreekanth Reddy 	u16		scsiio_depth;
1364f92363d1SSreekanth Reddy 	u16		request_sz;
1365f92363d1SSreekanth Reddy 	u8		*request;
1366f92363d1SSreekanth Reddy 	dma_addr_t	request_dma;
1367f92363d1SSreekanth Reddy 	u32		request_dma_sz;
1368dbec4c90SSuganath Prabu Subramani 	struct pcie_sg_list *pcie_sg_lookup;
1369f92363d1SSreekanth Reddy 	spinlock_t	scsi_lookup_lock;
1370f92363d1SSreekanth Reddy 	int		pending_io_count;
1371f92363d1SSreekanth Reddy 	wait_queue_head_t reset_wq;
1372f92363d1SSreekanth Reddy 
1373016d5c35SSuganath Prabu Subramani 	/* PCIe SGL */
1374016d5c35SSuganath Prabu Subramani 	struct dma_pool *pcie_sgl_dma_pool;
1375016d5c35SSuganath Prabu Subramani 	/* Host Page Size */
1376016d5c35SSuganath Prabu Subramani 	u32		page_size;
1377016d5c35SSuganath Prabu Subramani 
1378f92363d1SSreekanth Reddy 	/* chain */
137993204b78SChaitra P B 	struct chain_lookup *chain_lookup;
1380f92363d1SSreekanth Reddy 	struct list_head free_chain_list;
1381f92363d1SSreekanth Reddy 	struct dma_pool *chain_dma_pool;
1382f92363d1SSreekanth Reddy 	ulong		chain_pages;
1383f92363d1SSreekanth Reddy 	u16		max_sges_in_main_message;
1384f92363d1SSreekanth Reddy 	u16		max_sges_in_chain_message;
1385f92363d1SSreekanth Reddy 	u16		chains_needed_per_io;
1386f92363d1SSreekanth Reddy 	u32		chain_depth;
1387ebb3024eSSuganath prabu Subramani 	u16		chain_segment_sz;
1388dbec4c90SSuganath Prabu Subramani 	u16		chains_per_prp_buffer;
1389f92363d1SSreekanth Reddy 
1390f92363d1SSreekanth Reddy 	/* hi-priority queue */
1391f92363d1SSreekanth Reddy 	u16		hi_priority_smid;
1392f92363d1SSreekanth Reddy 	u8		*hi_priority;
1393f92363d1SSreekanth Reddy 	dma_addr_t	hi_priority_dma;
1394f92363d1SSreekanth Reddy 	u16		hi_priority_depth;
1395f92363d1SSreekanth Reddy 	struct request_tracker *hpr_lookup;
1396f92363d1SSreekanth Reddy 	struct list_head hpr_free_list;
1397f92363d1SSreekanth Reddy 
1398f92363d1SSreekanth Reddy 	/* internal queue */
1399f92363d1SSreekanth Reddy 	u16		internal_smid;
1400f92363d1SSreekanth Reddy 	u8		*internal;
1401f92363d1SSreekanth Reddy 	dma_addr_t	internal_dma;
1402f92363d1SSreekanth Reddy 	u16		internal_depth;
1403f92363d1SSreekanth Reddy 	struct request_tracker *internal_lookup;
1404f92363d1SSreekanth Reddy 	struct list_head internal_free_list;
1405f92363d1SSreekanth Reddy 
1406f92363d1SSreekanth Reddy 	/* sense */
1407f92363d1SSreekanth Reddy 	u8		*sense;
1408f92363d1SSreekanth Reddy 	dma_addr_t	sense_dma;
1409f92363d1SSreekanth Reddy 	struct dma_pool *sense_dma_pool;
1410f92363d1SSreekanth Reddy 
1411f92363d1SSreekanth Reddy 	/* reply */
1412f92363d1SSreekanth Reddy 	u16		reply_sz;
1413f92363d1SSreekanth Reddy 	u8		*reply;
1414f92363d1SSreekanth Reddy 	dma_addr_t	reply_dma;
1415f92363d1SSreekanth Reddy 	u32		reply_dma_max_address;
1416f92363d1SSreekanth Reddy 	u32		reply_dma_min_address;
1417f92363d1SSreekanth Reddy 	struct dma_pool *reply_dma_pool;
1418f92363d1SSreekanth Reddy 
1419f92363d1SSreekanth Reddy 	/* reply free queue */
1420f92363d1SSreekanth Reddy 	u16		reply_free_queue_depth;
1421f92363d1SSreekanth Reddy 	__le32		*reply_free;
1422f92363d1SSreekanth Reddy 	dma_addr_t	reply_free_dma;
1423f92363d1SSreekanth Reddy 	struct dma_pool *reply_free_dma_pool;
1424f92363d1SSreekanth Reddy 	u32		reply_free_host_index;
1425f92363d1SSreekanth Reddy 
1426f92363d1SSreekanth Reddy 	/* reply post queue */
1427f92363d1SSreekanth Reddy 	u16		reply_post_queue_depth;
14289b05c91aSSreekanth Reddy 	struct reply_post_struct *reply_post;
14299b05c91aSSreekanth Reddy 	u8		rdpq_array_capable;
14309b05c91aSSreekanth Reddy 	u8		rdpq_array_enable;
14319b05c91aSSreekanth Reddy 	u8		rdpq_array_enable_assigned;
1432f92363d1SSreekanth Reddy 	struct dma_pool *reply_post_free_dma_pool;
1433cd33223bSChaitra P B 	struct dma_pool *reply_post_free_array_dma_pool;
1434cd33223bSChaitra P B 	Mpi2IOCInitRDPQArrayEntry *reply_post_free_array;
1435cd33223bSChaitra P B 	dma_addr_t reply_post_free_array_dma;
1436f92363d1SSreekanth Reddy 	u8		reply_queue_count;
1437f92363d1SSreekanth Reddy 	struct list_head reply_queue_list;
1438f92363d1SSreekanth Reddy 
14390bb337c9SSuganath Prabu Subramani 	u8		combined_reply_queue;
14400bb337c9SSuganath Prabu Subramani 	u8		combined_reply_index_count;
1441610ef1e9SSreekanth Reddy 	u8		smp_affinity_enable;
1442fb77bb53SSreekanth Reddy 	/* reply post register index */
1443fb77bb53SSreekanth Reddy 	resource_size_t	**replyPostRegisterIndex;
1444fb77bb53SSreekanth Reddy 
1445f92363d1SSreekanth Reddy 	struct list_head delayed_tr_list;
1446f92363d1SSreekanth Reddy 	struct list_head delayed_tr_volume_list;
1447fd0331b3SSuganath prabu Subramani 	struct list_head delayed_sc_list;
1448fd0331b3SSuganath prabu Subramani 	struct list_head delayed_event_ack_list;
14492d8ce8c9SSreekanth Reddy 	u8		temp_sensors_count;
145008c4d550SSreekanth Reddy 	struct mutex pci_access_mutex;
1451f92363d1SSreekanth Reddy 
1452f92363d1SSreekanth Reddy 	/* diag buffer support */
1453f92363d1SSreekanth Reddy 	u8		*diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
1454f92363d1SSreekanth Reddy 	u32		diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
1455f92363d1SSreekanth Reddy 	dma_addr_t	diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
1456f92363d1SSreekanth Reddy 	u8		diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
1457f92363d1SSreekanth Reddy 	u32		unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
1458f92363d1SSreekanth Reddy 	u32		product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
1459f92363d1SSreekanth Reddy 	u32		diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
1460f92363d1SSreekanth Reddy 	u32		ring_buffer_offset;
1461f92363d1SSreekanth Reddy 	u32		ring_buffer_sz;
14627786ab6aSSreekanth Reddy 	u8		is_warpdrive;
1463c520691bSSuganath Prabu Subramani 	u8		is_mcpu_endpoint;
14647786ab6aSSreekanth Reddy 	u8		hide_ir_msg;
14657786ab6aSSreekanth Reddy 	u8		mfg_pg10_hide_flag;
14667786ab6aSSreekanth Reddy 	u8		hide_drives;
1467f92363d1SSreekanth Reddy 	spinlock_t	diag_trigger_lock;
1468f92363d1SSreekanth Reddy 	u8		diag_trigger_active;
146979c74d03SSuganath Prabu S 	u8		atomic_desc_capable;
1470b8992029SSuganath Prabu 	BASE_READ_REG	base_readl;
1471f92363d1SSreekanth Reddy 	struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
1472f92363d1SSreekanth Reddy 	struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
1473f92363d1SSreekanth Reddy 	struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
1474f92363d1SSreekanth Reddy 	struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
1475c696f7b8SSuganath Prabu Subramani 	void		*device_remove_in_progress;
1476c696f7b8SSuganath Prabu Subramani 	u16		device_remove_in_progress_sz;
1477998f26aeSSuganath Prabu Subramani 	u8		is_gen35_ioc;
1478cc68e607SSuganath Prabu 	u8		is_aero_ioc;
14792b01b293SSuganath Prabu 	struct dentry	*debugfs_root;
14802b01b293SSuganath Prabu 	struct dentry	*ioc_dump;
148181c16f83SSuganath Prabu Subramani 	PUT_SMID_IO_FP_HIP put_smid_scsi_io;
1482078a4cc1SSuganath Prabu S 	PUT_SMID_IO_FP_HIP put_smid_fast_path;
1483078a4cc1SSuganath Prabu S 	PUT_SMID_IO_FP_HIP put_smid_hi_priority;
1484078a4cc1SSuganath Prabu S 	PUT_SMID_DEFAULT put_smid_default;
14855dd48a55SSuganath Prabu S 	GET_MSIX_INDEX get_msix_index_for_smlio;
1486f92363d1SSreekanth Reddy };
1487f92363d1SSreekanth Reddy 
14882b01b293SSuganath Prabu struct mpt3sas_debugfs_buffer {
14892b01b293SSuganath Prabu 	void	*buf;
14902b01b293SSuganath Prabu 	u32	len;
14912b01b293SSuganath Prabu };
14922b01b293SSuganath Prabu 
14933ac8e47bSSuganath Prabu #define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001
14943ac8e47bSSuganath Prabu 
1495f92363d1SSreekanth Reddy typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1496f92363d1SSreekanth Reddy 	u32 reply);
1497f92363d1SSreekanth Reddy 
1498f92363d1SSreekanth Reddy 
1499f92363d1SSreekanth Reddy /* base shared API */
1500f92363d1SSreekanth Reddy extern struct list_head mpt3sas_ioc_list;
1501d357e84dSSreekanth Reddy extern char    driver_name[MPT_NAME_LENGTH];
150208c4d550SSreekanth Reddy /* spinlock on list operations over IOCs
150308c4d550SSreekanth Reddy  * Case: when multiple warpdrive cards(IOCs) are in use
150408c4d550SSreekanth Reddy  * Each IOC will added to the ioc list structure on initialization.
150508c4d550SSreekanth Reddy  * Watchdog threads run at regular intervals to check IOC for any
150608c4d550SSreekanth Reddy  * fault conditions which will trigger the dead_ioc thread to
150708c4d550SSreekanth Reddy  * deallocate pci resource, resulting deleting the IOC netry from list,
150808c4d550SSreekanth Reddy  * this deletion need to protected by spinlock to enusre that
150908c4d550SSreekanth Reddy  * ioc removal is syncrhonized, if not synchronized it might lead to
151008c4d550SSreekanth Reddy  * list_del corruption as the ioc list is traversed in cli path.
151108c4d550SSreekanth Reddy  */
151208c4d550SSreekanth Reddy extern spinlock_t gioc_lock;
1513d357e84dSSreekanth Reddy 
1514f92363d1SSreekanth Reddy void mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc);
1515f92363d1SSreekanth Reddy void mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc);
1516f92363d1SSreekanth Reddy 
1517f92363d1SSreekanth Reddy int mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc);
1518f92363d1SSreekanth Reddy void mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc);
1519f92363d1SSreekanth Reddy int mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
1520f92363d1SSreekanth Reddy void mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc);
152122a923c3SChaitra P B void mpt3sas_free_enclosure_list(struct MPT3SAS_ADAPTER *ioc);
152298c56ad3SCalvin Owens int mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
1523f92363d1SSreekanth Reddy 	enum reset_type type);
1524f92363d1SSreekanth Reddy 
1525f92363d1SSreekanth Reddy void *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1526f92363d1SSreekanth Reddy void *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1527f92363d1SSreekanth Reddy __le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
1528f92363d1SSreekanth Reddy 	u16 smid);
1529016d5c35SSuganath Prabu Subramani void *mpt3sas_base_get_pcie_sgl(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1530d8335ae2SArnd Bergmann dma_addr_t mpt3sas_base_get_pcie_sgl_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1531711a923cSSuganath Prabu S void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc, u8 poll);
15325afa9d44SSuganath Prabu S void mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc);
15335afa9d44SSuganath Prabu S void mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc);
1534f92363d1SSreekanth Reddy 
153540114bdeSSuganath Prabu S void mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
153640114bdeSSuganath Prabu S 	u16 handle);
153740114bdeSSuganath Prabu S void mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
153840114bdeSSuganath Prabu S 	u16 msix_task);
153940114bdeSSuganath Prabu S void mpt3sas_base_put_smid_nvme_encap(struct MPT3SAS_ADAPTER *ioc, u16 smid);
154040114bdeSSuganath Prabu S void mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1541f92363d1SSreekanth Reddy /* hi-priority queue */
1542f92363d1SSreekanth Reddy u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
1543f92363d1SSreekanth Reddy u16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
1544f92363d1SSreekanth Reddy 		struct scsi_cmnd *scmd);
1545dbec4c90SSuganath Prabu Subramani void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
1546dbec4c90SSuganath Prabu Subramani 		struct scsiio_tracker *st);
1547f92363d1SSreekanth Reddy 
1548f92363d1SSreekanth Reddy u16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
1549f92363d1SSreekanth Reddy void mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1550f92363d1SSreekanth Reddy void mpt3sas_base_initialize_callback_handler(void);
1551f92363d1SSreekanth Reddy u8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func);
1552f92363d1SSreekanth Reddy void mpt3sas_base_release_callback_handler(u8 cb_idx);
1553f92363d1SSreekanth Reddy 
1554f92363d1SSreekanth Reddy u8 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1555f92363d1SSreekanth Reddy 	u32 reply);
1556f92363d1SSreekanth Reddy u8 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid,
1557f92363d1SSreekanth Reddy 	u8 msix_index, u32 reply);
1558f92363d1SSreekanth Reddy void *mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc,
1559f92363d1SSreekanth Reddy 	u32 phys_addr);
1560f92363d1SSreekanth Reddy 
1561f92363d1SSreekanth Reddy u32 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked);
1562f92363d1SSreekanth Reddy 
1563f92363d1SSreekanth Reddy void mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code);
1564c5977718SSreekanth Reddy #define mpt3sas_print_fault_code(ioc, fault_code) \
1565c5977718SSreekanth Reddy do { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
1566c5977718SSreekanth Reddy 	mpt3sas_base_fault_info(ioc, fault_code); } while (0)
1567c5977718SSreekanth Reddy 
1568e8c2307eSSreekanth Reddy void mpt3sas_base_coredump_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code);
1569c5977718SSreekanth Reddy #define mpt3sas_print_coredump_info(ioc, fault_code) \
1570c5977718SSreekanth Reddy do { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
1571c5977718SSreekanth Reddy 	mpt3sas_base_coredump_info(ioc, fault_code); } while (0)
1572c5977718SSreekanth Reddy 
1573e8c2307eSSreekanth Reddy int mpt3sas_base_wait_for_coredump_completion(struct MPT3SAS_ADAPTER *ioc,
1574e8c2307eSSreekanth Reddy 		const char *caller);
1575f92363d1SSreekanth Reddy int mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc,
1576f92363d1SSreekanth Reddy 	Mpi2SasIoUnitControlReply_t *mpi_reply,
1577f92363d1SSreekanth Reddy 	Mpi2SasIoUnitControlRequest_t *mpi_request);
1578f92363d1SSreekanth Reddy int mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc,
1579f92363d1SSreekanth Reddy 	Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
1580f92363d1SSreekanth Reddy 
1581f92363d1SSreekanth Reddy void mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc,
1582f92363d1SSreekanth Reddy 	u32 *event_type);
1583f92363d1SSreekanth Reddy 
1584f92363d1SSreekanth Reddy void mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc);
1585f92363d1SSreekanth Reddy 
1586f92363d1SSreekanth Reddy void mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
1587f92363d1SSreekanth Reddy 	u16 device_missing_delay, u8 io_missing_delay);
1588f92363d1SSreekanth Reddy 
1589f92363d1SSreekanth Reddy int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
1590f92363d1SSreekanth Reddy 
1591c666d3beSSreekanth Reddy void
1592c666d3beSSreekanth Reddy mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc);
1593c666d3beSSreekanth Reddy 
1594d37306caSChaitra P B u8 mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc,
1595d37306caSChaitra P B 	u8 status, void *mpi_request, int sz);
1596c6bdb6a1SSreekanth Reddy #define mpt3sas_check_cmd_timeout(ioc, status, mpi_request, sz, issue_reset) \
1597c6bdb6a1SSreekanth Reddy do {	ioc_err(ioc, "In func: %s\n", __func__); \
1598c6bdb6a1SSreekanth Reddy 	issue_reset = mpt3sas_base_check_cmd_timeout(ioc, \
1599c6bdb6a1SSreekanth Reddy 	status, mpi_request, sz); } while (0)
1600c6bdb6a1SSreekanth Reddy 
1601f4305749SSuganath Prabu int mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int wait_count);
1602f92363d1SSreekanth Reddy 
1603f92363d1SSreekanth Reddy /* scsih shared API */
1604dbec4c90SSuganath Prabu Subramani struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
1605dbec4c90SSuganath Prabu Subramani 	u16 smid);
1606f92363d1SSreekanth Reddy u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
1607f92363d1SSreekanth Reddy 	u32 reply);
1608c7a35705SBart Van Assche void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
160936c6c7f7SSreekanth Reddy void mpt3sas_scsih_clear_outstanding_scsi_tm_commands(
161036c6c7f7SSreekanth Reddy 	struct MPT3SAS_ADAPTER *ioc);
1611c7a35705SBart Van Assche void mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
1612f92363d1SSreekanth Reddy 
1613521e9c0bSSuganath Prabu S int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
1614521e9c0bSSuganath Prabu S 	uint channel, uint id, u64 lun, u8 type, u16 smid_task,
1615521e9c0bSSuganath Prabu S 	u16 msix_task, u8 timeout, u8 tr_method);
161696902835SCalvin Owens int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
1617521e9c0bSSuganath Prabu S 	uint channel, uint id, u64 lun, u8 type, u16 smid_task,
1618521e9c0bSSuganath Prabu S 	u16 msix_task, u8 timeout, u8 tr_method);
161996902835SCalvin Owens 
1620f92363d1SSreekanth Reddy void mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1621f92363d1SSreekanth Reddy void mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1622f92363d1SSreekanth Reddy void mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1623f92363d1SSreekanth Reddy void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
1624f92363d1SSreekanth Reddy 	u64 sas_address);
1625fd0331b3SSuganath prabu Subramani u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
1626fd0331b3SSuganath prabu Subramani 	u16 smid);
1627f92363d1SSreekanth Reddy 
1628f92363d1SSreekanth Reddy struct _sas_node *mpt3sas_scsih_expander_find_by_handle(
1629f92363d1SSreekanth Reddy 	struct MPT3SAS_ADAPTER *ioc, u16 handle);
1630f92363d1SSreekanth Reddy struct _sas_node *mpt3sas_scsih_expander_find_by_sas_address(
1631f92363d1SSreekanth Reddy 	struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1632d1cb5e49SSreekanth Reddy struct _sas_device *mpt3sas_get_sdev_by_addr(
1633d1cb5e49SSreekanth Reddy 	 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1634d1cb5e49SSreekanth Reddy struct _sas_device *__mpt3sas_get_sdev_by_addr(
1635f92363d1SSreekanth Reddy 	 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1636c102e00cSSuganath Prabu Subramani struct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
1637c102e00cSSuganath Prabu Subramani 	u16 handle);
1638c102e00cSSuganath Prabu Subramani struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
1639c102e00cSSuganath Prabu Subramani 	u16 handle);
1640f92363d1SSreekanth Reddy 
1641f92363d1SSreekanth Reddy void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
1642c84b06a4SSreekanth Reddy struct _raid_device *
1643c84b06a4SSreekanth Reddy mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
16448dc8d29aSSreekanth Reddy void mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
16458a7e4c24SSreekanth Reddy 
1646f92363d1SSreekanth Reddy /* config shared API */
1647f92363d1SSreekanth Reddy u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1648f92363d1SSreekanth Reddy 	u32 reply);
1649f92363d1SSreekanth Reddy int mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER *ioc,
1650f92363d1SSreekanth Reddy 	u8 *num_phys);
1651f92363d1SSreekanth Reddy int mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER *ioc,
1652f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
1653f92363d1SSreekanth Reddy int mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER *ioc,
1654f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage7_t *config_page,
1655f92363d1SSreekanth Reddy 	u16 sz);
1656f92363d1SSreekanth Reddy int mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER *ioc,
1657f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply,
1658f92363d1SSreekanth Reddy 	struct Mpi2ManufacturingPage10_t *config_page);
1659f92363d1SSreekanth Reddy 
1660f92363d1SSreekanth Reddy int mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
1661f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply,
1662f92363d1SSreekanth Reddy 	struct Mpi2ManufacturingPage11_t  *config_page);
1663f92363d1SSreekanth Reddy int mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
1664f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply,
1665f92363d1SSreekanth Reddy 	struct Mpi2ManufacturingPage11_t *config_page);
1666f92363d1SSreekanth Reddy 
1667f92363d1SSreekanth Reddy int mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1668f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2BiosPage2_t *config_page);
1669f92363d1SSreekanth Reddy int mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1670f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2BiosPage3_t *config_page);
1671f92363d1SSreekanth Reddy int mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1672f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2IOUnitPage0_t *config_page);
1673f92363d1SSreekanth Reddy int mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc,
1674f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage0_t *config_page,
1675f92363d1SSreekanth Reddy 	u32 form, u32 handle);
1676f92363d1SSreekanth Reddy int mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc,
1677f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page,
1678f92363d1SSreekanth Reddy 	u32 form, u32 handle);
1679c102e00cSSuganath Prabu Subramani int mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc,
1680c102e00cSSuganath Prabu Subramani 	Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page,
1681c102e00cSSuganath Prabu Subramani 	u32 form, u32 handle);
1682c102e00cSSuganath Prabu Subramani int mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc,
1683c102e00cSSuganath Prabu Subramani 	Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page,
1684c102e00cSSuganath Prabu Subramani 	u32 form, u32 handle);
1685f92363d1SSreekanth Reddy int mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc,
1686f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page,
1687f92363d1SSreekanth Reddy 	u16 sz);
1688f92363d1SSreekanth Reddy int mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1689f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2IOUnitPage1_t *config_page);
169042263095SSreekanth Reddy int mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER *ioc,
169142263095SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
1692f92363d1SSreekanth Reddy int mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1693f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2IOUnitPage1_t *config_page);
16942d8ce8c9SSreekanth Reddy int mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16952d8ce8c9SSreekanth Reddy 	*mpi_reply, Mpi2IOUnitPage8_t *config_page);
1696f92363d1SSreekanth Reddy int mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
1697f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
1698f92363d1SSreekanth Reddy 	u16 sz);
1699f92363d1SSreekanth Reddy int mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
1700f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
1701f92363d1SSreekanth Reddy 	u16 sz);
17022426f209SSuganath Prabu S int mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17032426f209SSuganath Prabu S 	*mpi_reply, Mpi2IOCPage1_t *config_page);
17042426f209SSuganath Prabu S int mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17052426f209SSuganath Prabu S 	*mpi_reply, Mpi2IOCPage1_t *config_page);
1706f92363d1SSreekanth Reddy int mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1707f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2IOCPage8_t *config_page);
1708f92363d1SSreekanth Reddy int mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER *ioc,
1709f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage0_t *config_page,
1710f92363d1SSreekanth Reddy 	u32 form, u32 handle);
1711f92363d1SSreekanth Reddy int mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER *ioc,
1712f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage1_t *config_page,
1713f92363d1SSreekanth Reddy 	u32 phy_number, u16 handle);
1714f92363d1SSreekanth Reddy int mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER *ioc,
1715f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2SasEnclosurePage0_t *config_page,
1716f92363d1SSreekanth Reddy 	u32 form, u32 handle);
1717f92363d1SSreekanth Reddy int mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1718f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
1719f92363d1SSreekanth Reddy int mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1720f92363d1SSreekanth Reddy 	*mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
1721f92363d1SSreekanth Reddy int mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER *ioc,
1722f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
1723f92363d1SSreekanth Reddy 	u32 handle);
1724f92363d1SSreekanth Reddy int mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER *ioc, u16 handle,
1725f92363d1SSreekanth Reddy 	u8 *num_pds);
1726f92363d1SSreekanth Reddy int mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER *ioc,
1727f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
1728f92363d1SSreekanth Reddy 	u32 handle, u16 sz);
1729f92363d1SSreekanth Reddy int mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER *ioc,
1730f92363d1SSreekanth Reddy 	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
1731f92363d1SSreekanth Reddy 	u32 form, u32 form_specific);
1732f92363d1SSreekanth Reddy int mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER *ioc, u16 pd_handle,
1733f92363d1SSreekanth Reddy 	u16 *volume_handle);
1734f92363d1SSreekanth Reddy int mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER *ioc,
1735f92363d1SSreekanth Reddy 	u16 volume_handle, u64 *wwid);
1736f92363d1SSreekanth Reddy 
1737f92363d1SSreekanth Reddy /* ctl shared API */
1738f92363d1SSreekanth Reddy extern struct device_attribute *mpt3sas_host_attrs[];
1739f92363d1SSreekanth Reddy extern struct device_attribute *mpt3sas_dev_attrs[];
1740c84b06a4SSreekanth Reddy void mpt3sas_ctl_init(ushort hbas_to_enumerate);
1741c84b06a4SSreekanth Reddy void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
1742f92363d1SSreekanth Reddy u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1743f92363d1SSreekanth Reddy 	u32 reply);
1744c7a35705SBart Van Assche void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
174536c6c7f7SSreekanth Reddy void mpt3sas_ctl_clear_outstanding_ioctls(struct MPT3SAS_ADAPTER *ioc);
1746c7a35705SBart Van Assche void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
1747f92363d1SSreekanth Reddy u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
1748f92363d1SSreekanth Reddy 	u8 msix_index, u32 reply);
1749f92363d1SSreekanth Reddy void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
1750f92363d1SSreekanth Reddy 	Mpi2EventNotificationReply_t *mpi_reply);
1751f92363d1SSreekanth Reddy 
1752f92363d1SSreekanth Reddy void mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc,
1753ad61dd30SStephen Boyd 	u8 bits_to_register);
1754f92363d1SSreekanth Reddy int mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
1755f92363d1SSreekanth Reddy 	u8 *issue_reset);
1756f92363d1SSreekanth Reddy 
1757f92363d1SSreekanth Reddy /* transport shared API */
17587497392aSSreekanth Reddy extern struct scsi_transport_template *mpt3sas_transport_template;
1759f92363d1SSreekanth Reddy u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1760f92363d1SSreekanth Reddy 	u32 reply);
1761f92363d1SSreekanth Reddy struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
1762f92363d1SSreekanth Reddy 	u16 handle, u64 sas_address);
1763f92363d1SSreekanth Reddy void mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
1764f92363d1SSreekanth Reddy 	u64 sas_address_parent);
1765f92363d1SSreekanth Reddy int mpt3sas_transport_add_host_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_phy
1766f92363d1SSreekanth Reddy 	*mpt3sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
1767f92363d1SSreekanth Reddy int mpt3sas_transport_add_expander_phy(struct MPT3SAS_ADAPTER *ioc,
1768f92363d1SSreekanth Reddy 	struct _sas_phy *mpt3sas_phy, Mpi2ExpanderPage1_t expander_pg1,
1769f92363d1SSreekanth Reddy 	struct device *parent_dev);
1770f92363d1SSreekanth Reddy void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
1771f92363d1SSreekanth Reddy 	u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
1772f92363d1SSreekanth Reddy extern struct sas_function_template mpt3sas_transport_functions;
1773f92363d1SSreekanth Reddy extern struct scsi_transport_template *mpt3sas_transport_template;
1774f92363d1SSreekanth Reddy /* trigger data externs */
1775f92363d1SSreekanth Reddy void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
1776f92363d1SSreekanth Reddy 	struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
1777f92363d1SSreekanth Reddy void mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
1778f92363d1SSreekanth Reddy 	struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
1779f92363d1SSreekanth Reddy void mpt3sas_trigger_master(struct MPT3SAS_ADAPTER *ioc,
1780896c9b49SFlavio Suligoi 	u32 trigger_bitmask);
1781f92363d1SSreekanth Reddy void mpt3sas_trigger_event(struct MPT3SAS_ADAPTER *ioc, u16 event,
1782f92363d1SSreekanth Reddy 	u16 log_entry_qualifier);
1783f92363d1SSreekanth Reddy void mpt3sas_trigger_scsi(struct MPT3SAS_ADAPTER *ioc, u8 sense_key,
1784f92363d1SSreekanth Reddy 	u8 asc, u8 ascq);
1785f92363d1SSreekanth Reddy void mpt3sas_trigger_mpi(struct MPT3SAS_ADAPTER *ioc, u16 ioc_status,
1786f92363d1SSreekanth Reddy 	u32 loginfo);
1787c84b06a4SSreekanth Reddy 
1788c84b06a4SSreekanth Reddy /* warpdrive APIs */
1789c84b06a4SSreekanth Reddy u8 mpt3sas_get_num_volumes(struct MPT3SAS_ADAPTER *ioc);
1790c84b06a4SSreekanth Reddy void mpt3sas_init_warpdrive_properties(struct MPT3SAS_ADAPTER *ioc,
1791c84b06a4SSreekanth Reddy 	struct _raid_device *raid_device);
1792c84b06a4SSreekanth Reddy void
1793c84b06a4SSreekanth Reddy mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
1794dbec4c90SSuganath Prabu Subramani 	struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request);
1795c84b06a4SSreekanth Reddy 
1796307d9075SAdam Manzanares /* NCQ Prio Handling Check */
1797307d9075SAdam Manzanares bool scsih_ncq_prio_supp(struct scsi_device *sdev);
1798307d9075SAdam Manzanares 
17992b01b293SSuganath Prabu void mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc);
18002b01b293SSuganath Prabu void mpt3sas_destroy_debugfs(struct MPT3SAS_ADAPTER *ioc);
18012b01b293SSuganath Prabu void mpt3sas_init_debugfs(void);
18022b01b293SSuganath Prabu void mpt3sas_exit_debugfs(void);
18032b01b293SSuganath Prabu 
18045bb309dbSSuganath Prabu /**
18055bb309dbSSuganath Prabu  * _scsih_is_pcie_scsi_device - determines if device is an pcie scsi device
18065bb309dbSSuganath Prabu  * @device_info: bitfield providing information about the device.
18075bb309dbSSuganath Prabu  * Context: none
18085bb309dbSSuganath Prabu  *
18095bb309dbSSuganath Prabu  * Returns 1 if scsi device.
18105bb309dbSSuganath Prabu  */
18115bb309dbSSuganath Prabu static inline int
18125bb309dbSSuganath Prabu mpt3sas_scsih_is_pcie_scsi_device(u32 device_info)
18135bb309dbSSuganath Prabu {
18145bb309dbSSuganath Prabu 	if ((device_info &
18155bb309dbSSuganath Prabu 	    MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI)
18165bb309dbSSuganath Prabu 		return 1;
18175bb309dbSSuganath Prabu 	else
18185bb309dbSSuganath Prabu 		return 0;
18195bb309dbSSuganath Prabu }
1820f92363d1SSreekanth Reddy #endif /* MPT3SAS_BASE_H_INCLUDED */
1821