18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This is the Fusion MPT base driver providing common API layer interface
38c2ecf20Sopenharmony_ci * for access to MPT (Message Passing Technology) firmware.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
68c2ecf20Sopenharmony_ci * Copyright (C) 2012-2014  LSI Corporation
78c2ecf20Sopenharmony_ci * Copyright (C) 2013-2014 Avago Technologies
88c2ecf20Sopenharmony_ci *  (mailto: MPT-FusionLinux.pdl@avagotech.com)
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
118c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License
128c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 2
138c2ecf20Sopenharmony_ci * of the License, or (at your option) any later version.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful,
168c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
178c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
188c2ecf20Sopenharmony_ci * GNU General Public License for more details.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * NO WARRANTY
218c2ecf20Sopenharmony_ci * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
228c2ecf20Sopenharmony_ci * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
238c2ecf20Sopenharmony_ci * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
248c2ecf20Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
258c2ecf20Sopenharmony_ci * solely responsible for determining the appropriateness of using and
268c2ecf20Sopenharmony_ci * distributing the Program and assumes all risks associated with its
278c2ecf20Sopenharmony_ci * exercise of rights under this Agreement, including but not limited to
288c2ecf20Sopenharmony_ci * the risks and costs of program errors, damage to or loss of data,
298c2ecf20Sopenharmony_ci * programs or equipment, and unavailability or interruption of operations.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci * DISCLAIMER OF LIABILITY
328c2ecf20Sopenharmony_ci * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
338c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
348c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
358c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
368c2ecf20Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
378c2ecf20Sopenharmony_ci * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
388c2ecf20Sopenharmony_ci * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License
418c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software
428c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
438c2ecf20Sopenharmony_ci * USA.
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifndef MPT3SAS_BASE_H_INCLUDED
478c2ecf20Sopenharmony_ci#define MPT3SAS_BASE_H_INCLUDED
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#include "mpi/mpi2_type.h"
508c2ecf20Sopenharmony_ci#include "mpi/mpi2.h"
518c2ecf20Sopenharmony_ci#include "mpi/mpi2_ioc.h"
528c2ecf20Sopenharmony_ci#include "mpi/mpi2_cnfg.h"
538c2ecf20Sopenharmony_ci#include "mpi/mpi2_init.h"
548c2ecf20Sopenharmony_ci#include "mpi/mpi2_raid.h"
558c2ecf20Sopenharmony_ci#include "mpi/mpi2_tool.h"
568c2ecf20Sopenharmony_ci#include "mpi/mpi2_sas.h"
578c2ecf20Sopenharmony_ci#include "mpi/mpi2_pci.h"
588c2ecf20Sopenharmony_ci#include "mpi/mpi2_image.h"
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
618c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h>
628c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
638c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
648c2ecf20Sopenharmony_ci#include <scsi/scsi_tcq.h>
658c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_sas.h>
668c2ecf20Sopenharmony_ci#include <scsi/scsi_dbg.h>
678c2ecf20Sopenharmony_ci#include <scsi/scsi_eh.h>
688c2ecf20Sopenharmony_ci#include <linux/pci.h>
698c2ecf20Sopenharmony_ci#include <linux/poll.h>
708c2ecf20Sopenharmony_ci#include <linux/irq_poll.h>
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#include "mpt3sas_debug.h"
738c2ecf20Sopenharmony_ci#include "mpt3sas_trigger_diag.h"
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* driver versioning info */
768c2ecf20Sopenharmony_ci#define MPT3SAS_DRIVER_NAME		"mpt3sas"
778c2ecf20Sopenharmony_ci#define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
788c2ecf20Sopenharmony_ci#define MPT3SAS_DESCRIPTION	"LSI MPT Fusion SAS 3.0 Device Driver"
798c2ecf20Sopenharmony_ci#define MPT3SAS_DRIVER_VERSION		"35.100.00.00"
808c2ecf20Sopenharmony_ci#define MPT3SAS_MAJOR_VERSION		35
818c2ecf20Sopenharmony_ci#define MPT3SAS_MINOR_VERSION		100
828c2ecf20Sopenharmony_ci#define MPT3SAS_BUILD_VERSION		0
838c2ecf20Sopenharmony_ci#define MPT3SAS_RELEASE_VERSION	00
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define MPT2SAS_DRIVER_NAME		"mpt2sas"
868c2ecf20Sopenharmony_ci#define MPT2SAS_DESCRIPTION	"LSI MPT Fusion SAS 2.0 Device Driver"
878c2ecf20Sopenharmony_ci#define MPT2SAS_DRIVER_VERSION		"20.102.00.00"
888c2ecf20Sopenharmony_ci#define MPT2SAS_MAJOR_VERSION		20
898c2ecf20Sopenharmony_ci#define MPT2SAS_MINOR_VERSION		102
908c2ecf20Sopenharmony_ci#define MPT2SAS_BUILD_VERSION		0
918c2ecf20Sopenharmony_ci#define MPT2SAS_RELEASE_VERSION	00
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* CoreDump: Default timeout */
948c2ecf20Sopenharmony_ci#define MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS	(15) /*15 seconds*/
958c2ecf20Sopenharmony_ci#define MPT3SAS_COREDUMP_LOOP_DONE                     (0xFF)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/*
988c2ecf20Sopenharmony_ci * Set MPT3SAS_SG_DEPTH value based on user input.
998c2ecf20Sopenharmony_ci */
1008c2ecf20Sopenharmony_ci#define MPT_MAX_PHYS_SEGMENTS	SG_CHUNK_SIZE
1018c2ecf20Sopenharmony_ci#define MPT_MIN_PHYS_SEGMENTS	16
1028c2ecf20Sopenharmony_ci#define MPT_KDUMP_MIN_PHYS_SEGMENTS	32
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define MCPU_MAX_CHAINS_PER_IO	3
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
1078c2ecf20Sopenharmony_ci#define MPT3SAS_SG_DEPTH		CONFIG_SCSI_MPT3SAS_MAX_SGE
1088c2ecf20Sopenharmony_ci#else
1098c2ecf20Sopenharmony_ci#define MPT3SAS_SG_DEPTH		MPT_MAX_PHYS_SEGMENTS
1108c2ecf20Sopenharmony_ci#endif
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
1138c2ecf20Sopenharmony_ci#define MPT2SAS_SG_DEPTH		CONFIG_SCSI_MPT2SAS_MAX_SGE
1148c2ecf20Sopenharmony_ci#else
1158c2ecf20Sopenharmony_ci#define MPT2SAS_SG_DEPTH		MPT_MAX_PHYS_SEGMENTS
1168c2ecf20Sopenharmony_ci#endif
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/*
1198c2ecf20Sopenharmony_ci * Generic Defines
1208c2ecf20Sopenharmony_ci */
1218c2ecf20Sopenharmony_ci#define MPT3SAS_SATA_QUEUE_DEPTH	32
1228c2ecf20Sopenharmony_ci#define MPT3SAS_SAS_QUEUE_DEPTH		254
1238c2ecf20Sopenharmony_ci#define MPT3SAS_RAID_QUEUE_DEPTH	128
1248c2ecf20Sopenharmony_ci#define MPT3SAS_KDUMP_SCSI_IO_DEPTH	200
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define MPT3SAS_RAID_MAX_SECTORS	8192
1278c2ecf20Sopenharmony_ci#define MPT3SAS_HOST_PAGE_SIZE_4K	12
1288c2ecf20Sopenharmony_ci#define MPT3SAS_NVME_QUEUE_DEPTH	128
1298c2ecf20Sopenharmony_ci#define MPT_NAME_LENGTH			32	/* generic length of strings */
1308c2ecf20Sopenharmony_ci#define MPT_STRING_LENGTH		64
1318c2ecf20Sopenharmony_ci#define MPI_FRAME_START_OFFSET		256
1328c2ecf20Sopenharmony_ci#define REPLY_FREE_POOL_SIZE		512 /*(32 maxcredix *4)*(4 times)*/
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define MPT_MAX_CALLBACKS		32
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define INTERNAL_CMDS_COUNT		10	/* reserved cmds */
1378c2ecf20Sopenharmony_ci/* reserved for issuing internally framed scsi io cmds */
1388c2ecf20Sopenharmony_ci#define INTERNAL_SCSIIO_CMDS_COUNT	3
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define MPI3_HIM_MASK			0xFFFFFFFF /* mask every bit*/
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#define MPT3SAS_INVALID_DEVICE_HANDLE	0xFFFF
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#define MAX_CHAIN_ELEMT_SZ		16
1458c2ecf20Sopenharmony_ci#define DEFAULT_NUM_FWCHAIN_ELEMTS	8
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT 6
1488c2ecf20Sopenharmony_ci#define FW_IMG_HDR_READ_TIMEOUT	15
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define IOC_OPERATIONAL_WAIT_COUNT	10
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci/*
1538c2ecf20Sopenharmony_ci * NVMe defines
1548c2ecf20Sopenharmony_ci */
1558c2ecf20Sopenharmony_ci#define	NVME_PRP_SIZE			8	/* PRP size */
1568c2ecf20Sopenharmony_ci#define	NVME_ERROR_RESPONSE_SIZE	16	/* Max NVME Error Response */
1578c2ecf20Sopenharmony_ci#define NVME_TASK_ABORT_MIN_TIMEOUT	6
1588c2ecf20Sopenharmony_ci#define NVME_TASK_ABORT_MAX_TIMEOUT	60
1598c2ecf20Sopenharmony_ci#define NVME_TASK_MNGT_CUSTOM_MASK	(0x0010)
1608c2ecf20Sopenharmony_ci#define	NVME_PRP_PAGE_SIZE		4096	/* Page size */
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistruct mpt3sas_nvme_cmd {
1638c2ecf20Sopenharmony_ci	u8	rsvd[24];
1648c2ecf20Sopenharmony_ci	__le64	prp1;
1658c2ecf20Sopenharmony_ci	__le64	prp2;
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/*
1698c2ecf20Sopenharmony_ci * logging format
1708c2ecf20Sopenharmony_ci */
1718c2ecf20Sopenharmony_ci#define ioc_err(ioc, fmt, ...)						\
1728c2ecf20Sopenharmony_ci	pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
1738c2ecf20Sopenharmony_ci#define ioc_notice(ioc, fmt, ...)					\
1748c2ecf20Sopenharmony_ci	pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
1758c2ecf20Sopenharmony_ci#define ioc_warn(ioc, fmt, ...)						\
1768c2ecf20Sopenharmony_ci	pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
1778c2ecf20Sopenharmony_ci#define ioc_info(ioc, fmt, ...)						\
1788c2ecf20Sopenharmony_ci	pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci/*
1818c2ecf20Sopenharmony_ci *  WarpDrive Specific Log codes
1828c2ecf20Sopenharmony_ci */
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#define MPT2_WARPDRIVE_LOGENTRY		(0x8002)
1858c2ecf20Sopenharmony_ci#define MPT2_WARPDRIVE_LC_SSDT			(0x41)
1868c2ecf20Sopenharmony_ci#define MPT2_WARPDRIVE_LC_SSDLW		(0x43)
1878c2ecf20Sopenharmony_ci#define MPT2_WARPDRIVE_LC_SSDLF		(0x44)
1888c2ecf20Sopenharmony_ci#define MPT2_WARPDRIVE_LC_BRMF			(0x4D)
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci/*
1918c2ecf20Sopenharmony_ci * per target private data
1928c2ecf20Sopenharmony_ci */
1938c2ecf20Sopenharmony_ci#define MPT_TARGET_FLAGS_RAID_COMPONENT	0x01
1948c2ecf20Sopenharmony_ci#define MPT_TARGET_FLAGS_VOLUME		0x02
1958c2ecf20Sopenharmony_ci#define MPT_TARGET_FLAGS_DELETED	0x04
1968c2ecf20Sopenharmony_ci#define MPT_TARGET_FASTPATH_IO		0x08
1978c2ecf20Sopenharmony_ci#define MPT_TARGET_FLAGS_PCIE_DEVICE	0x10
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define SAS2_PCI_DEVICE_B0_REVISION	(0x01)
2008c2ecf20Sopenharmony_ci#define SAS3_PCI_DEVICE_C0_REVISION	(0x02)
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci/* Atlas PCIe Switch Management Port */
2038c2ecf20Sopenharmony_ci#define MPI26_ATLAS_PCIe_SWITCH_DEVID	(0x00B2)
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci/*
2068c2ecf20Sopenharmony_ci * Intel HBA branding
2078c2ecf20Sopenharmony_ci */
2088c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25JB080_BRANDING    \
2098c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25JB080"
2108c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25JB040_BRANDING    \
2118c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25JB040"
2128c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25KB080_BRANDING    \
2138c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25KB080"
2148c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25KB040_BRANDING    \
2158c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25KB040"
2168c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25LB040_BRANDING	\
2178c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25LB040"
2188c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25LB080_BRANDING	\
2198c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS25LB080"
2208c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS2LL080_BRANDING	\
2218c2ecf20Sopenharmony_ci	"Intel Integrated RAID Module RMS2LL080"
2228c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS2LL040_BRANDING	\
2238c2ecf20Sopenharmony_ci	"Intel Integrated RAID Module RMS2LL040"
2248c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RS25GB008_BRANDING       \
2258c2ecf20Sopenharmony_ci	"Intel(R) RAID Controller RS25GB008"
2268c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_SSD910_BRANDING          \
2278c2ecf20Sopenharmony_ci	"Intel(R) SSD 910 Series"
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RMS3JC080_BRANDING       \
2308c2ecf20Sopenharmony_ci	"Intel(R) Integrated RAID Module RMS3JC080"
2318c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3GC008_BRANDING       \
2328c2ecf20Sopenharmony_ci	"Intel(R) RAID Controller RS3GC008"
2338c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3FC044_BRANDING       \
2348c2ecf20Sopenharmony_ci	"Intel(R) RAID Controller RS3FC044"
2358c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3UC080_BRANDING       \
2368c2ecf20Sopenharmony_ci	"Intel(R) RAID Controller RS3UC080"
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci/*
2398c2ecf20Sopenharmony_ci * Intel HBA SSDIDs
2408c2ecf20Sopenharmony_ci */
2418c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25JB080_SSDID		0x3516
2428c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25JB040_SSDID		0x3517
2438c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25KB080_SSDID		0x3518
2448c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25KB040_SSDID		0x3519
2458c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25LB040_SSDID		0x351A
2468c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS25LB080_SSDID		0x351B
2478c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS2LL080_SSDID		0x350E
2488c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RMS2LL040_SSDID		0x350F
2498c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_RS25GB008_SSDID		0x3000
2508c2ecf20Sopenharmony_ci#define MPT2SAS_INTEL_SSD910_SSDID		0x3700
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RMS3JC080_SSDID		0x3521
2538c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3GC008_SSDID		0x3522
2548c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3FC044_SSDID		0x3523
2558c2ecf20Sopenharmony_ci#define MPT3SAS_INTEL_RS3UC080_SSDID		0x3524
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/*
2588c2ecf20Sopenharmony_ci * Dell HBA branding
2598c2ecf20Sopenharmony_ci */
2608c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_BRANDING_SIZE                 32
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING        "Dell 6Gbps SAS HBA"
2638c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING    "Dell PERC H200 Adapter"
2648c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
2658c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING    "Dell PERC H200 Modular"
2668c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING   "Dell PERC H200 Embedded"
2678c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_BRANDING            "Dell PERC H200"
2688c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_6GBPS_SAS_BRANDING            "Dell 6Gbps SAS"
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci#define MPT3SAS_DELL_12G_HBA_BRANDING       \
2718c2ecf20Sopenharmony_ci	"Dell 12Gbps HBA"
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/*
2748c2ecf20Sopenharmony_ci * Dell HBA SSDIDs
2758c2ecf20Sopenharmony_ci */
2768c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID	0x1F1C
2778c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID	0x1F1D
2788c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID	0x1F1E
2798c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID	0x1F1F
2808c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID	0x1F20
2818c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_PERC_H200_SSDID		0x1F21
2828c2ecf20Sopenharmony_ci#define MPT2SAS_DELL_6GBPS_SAS_SSDID		0x1F22
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#define MPT3SAS_DELL_12G_HBA_SSDID		0x1F46
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci/*
2878c2ecf20Sopenharmony_ci * Cisco HBA branding
2888c2ecf20Sopenharmony_ci */
2898c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_8E_HBA_BRANDING		\
2908c2ecf20Sopenharmony_ci	"Cisco 9300-8E 12G SAS HBA"
2918c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_8I_HBA_BRANDING		\
2928c2ecf20Sopenharmony_ci	"Cisco 9300-8i 12G SAS HBA"
2938c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING	\
2948c2ecf20Sopenharmony_ci	"Cisco 12G Modular SAS Pass through Controller"
2958c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING		\
2968c2ecf20Sopenharmony_ci	"UCS C3X60 12G SAS Pass through Controller"
2978c2ecf20Sopenharmony_ci/*
2988c2ecf20Sopenharmony_ci * Cisco HBA SSSDIDs
2998c2ecf20Sopenharmony_ci */
3008c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_8E_HBA_SSDID  0x14C
3018c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_8I_HBA_SSDID  0x154
3028c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_AVILA_HBA_SSDID  0x155
3038c2ecf20Sopenharmony_ci#define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID  0x156
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci/*
3068c2ecf20Sopenharmony_ci * status bits for ioc->diag_buffer_status
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_ci#define MPT3_DIAG_BUFFER_IS_REGISTERED	(0x01)
3098c2ecf20Sopenharmony_ci#define MPT3_DIAG_BUFFER_IS_RELEASED	(0x02)
3108c2ecf20Sopenharmony_ci#define MPT3_DIAG_BUFFER_IS_DIAG_RESET	(0x04)
3118c2ecf20Sopenharmony_ci#define MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED (0x08)
3128c2ecf20Sopenharmony_ci#define MPT3_DIAG_BUFFER_IS_APP_OWNED (0x10)
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci/*
3158c2ecf20Sopenharmony_ci * HP HBA branding
3168c2ecf20Sopenharmony_ci */
3178c2ecf20Sopenharmony_ci#define MPT2SAS_HP_3PAR_SSVID                0x1590
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci#define MPT2SAS_HP_2_4_INTERNAL_BRANDING	\
3208c2ecf20Sopenharmony_ci	"HP H220 Host Bus Adapter"
3218c2ecf20Sopenharmony_ci#define MPT2SAS_HP_2_4_EXTERNAL_BRANDING	\
3228c2ecf20Sopenharmony_ci	"HP H221 Host Bus Adapter"
3238c2ecf20Sopenharmony_ci#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING	\
3248c2ecf20Sopenharmony_ci	"HP H222 Host Bus Adapter"
3258c2ecf20Sopenharmony_ci#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING	\
3268c2ecf20Sopenharmony_ci	"HP H220i Host Bus Adapter"
3278c2ecf20Sopenharmony_ci#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING	\
3288c2ecf20Sopenharmony_ci	"HP H210i Host Bus Adapter"
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci/*
3318c2ecf20Sopenharmony_ci * HO HBA SSDIDs
3328c2ecf20Sopenharmony_ci */
3338c2ecf20Sopenharmony_ci#define MPT2SAS_HP_2_4_INTERNAL_SSDID			0x0041
3348c2ecf20Sopenharmony_ci#define MPT2SAS_HP_2_4_EXTERNAL_SSDID			0x0042
3358c2ecf20Sopenharmony_ci#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID	0x0043
3368c2ecf20Sopenharmony_ci#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID		0x0044
3378c2ecf20Sopenharmony_ci#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID		0x0046
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/*
3408c2ecf20Sopenharmony_ci * Combined Reply Queue constants,
3418c2ecf20Sopenharmony_ci * There are twelve Supplemental Reply Post Host Index Registers
3428c2ecf20Sopenharmony_ci * and each register is at offset 0x10 bytes from the previous one.
3438c2ecf20Sopenharmony_ci */
3448c2ecf20Sopenharmony_ci#define MAX_COMBINED_MSIX_VECTORS(gen35) ((gen35 == 1) ? 16 : 8)
3458c2ecf20Sopenharmony_ci#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3	12
3468c2ecf20Sopenharmony_ci#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35	16
3478c2ecf20Sopenharmony_ci#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET	(0x10)
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci/* OEM Identifiers */
3508c2ecf20Sopenharmony_ci#define MFG10_OEM_ID_INVALID                   (0x00000000)
3518c2ecf20Sopenharmony_ci#define MFG10_OEM_ID_DELL                      (0x00000001)
3528c2ecf20Sopenharmony_ci#define MFG10_OEM_ID_FSC                       (0x00000002)
3538c2ecf20Sopenharmony_ci#define MFG10_OEM_ID_SUN                       (0x00000003)
3548c2ecf20Sopenharmony_ci#define MFG10_OEM_ID_IBM                       (0x00000004)
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci/* GENERIC Flags 0*/
3578c2ecf20Sopenharmony_ci#define MFG10_GF0_OCE_DISABLED                 (0x00000001)
3588c2ecf20Sopenharmony_ci#define MFG10_GF0_R1E_DRIVE_COUNT              (0x00000002)
3598c2ecf20Sopenharmony_ci#define MFG10_GF0_R10_DISPLAY                  (0x00000004)
3608c2ecf20Sopenharmony_ci#define MFG10_GF0_SSD_DATA_SCRUB_DISABLE       (0x00000008)
3618c2ecf20Sopenharmony_ci#define MFG10_GF0_SINGLE_DRIVE_R0              (0x00000010)
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci#define VIRTUAL_IO_FAILED_RETRY			(0x32010081)
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci/* High IOPs definitions */
3668c2ecf20Sopenharmony_ci#define MPT3SAS_DEVICE_HIGH_IOPS_DEPTH		8
3678c2ecf20Sopenharmony_ci#define MPT3SAS_HIGH_IOPS_REPLY_QUEUES		8
3688c2ecf20Sopenharmony_ci#define MPT3SAS_HIGH_IOPS_BATCH_COUNT		16
3698c2ecf20Sopenharmony_ci#define MPT3SAS_GEN35_MAX_MSIX_QUEUES		128
3708c2ecf20Sopenharmony_ci#define RDPQ_MAX_INDEX_IN_ONE_CHUNK		16
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci/* OEM Specific Flags will come from OEM specific header files */
3738c2ecf20Sopenharmony_cistruct Mpi2ManufacturingPage10_t {
3748c2ecf20Sopenharmony_ci	MPI2_CONFIG_PAGE_HEADER	Header;		/* 00h */
3758c2ecf20Sopenharmony_ci	U8	OEMIdentifier;			/* 04h */
3768c2ecf20Sopenharmony_ci	U8	Reserved1;			/* 05h */
3778c2ecf20Sopenharmony_ci	U16	Reserved2;			/* 08h */
3788c2ecf20Sopenharmony_ci	U32	Reserved3;			/* 0Ch */
3798c2ecf20Sopenharmony_ci	U32	GenericFlags0;			/* 10h */
3808c2ecf20Sopenharmony_ci	U32	GenericFlags1;			/* 14h */
3818c2ecf20Sopenharmony_ci	U32	Reserved4;			/* 18h */
3828c2ecf20Sopenharmony_ci	U32	OEMSpecificFlags0;		/* 1Ch */
3838c2ecf20Sopenharmony_ci	U32	OEMSpecificFlags1;		/* 20h */
3848c2ecf20Sopenharmony_ci	U32	Reserved5[18];			/* 24h - 60h*/
3858c2ecf20Sopenharmony_ci};
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci/* Miscellaneous options */
3898c2ecf20Sopenharmony_cistruct Mpi2ManufacturingPage11_t {
3908c2ecf20Sopenharmony_ci	MPI2_CONFIG_PAGE_HEADER Header;		/* 00h */
3918c2ecf20Sopenharmony_ci	__le32	Reserved1;			/* 04h */
3928c2ecf20Sopenharmony_ci	u8	Reserved2;			/* 08h */
3938c2ecf20Sopenharmony_ci	u8	EEDPTagMode;			/* 09h */
3948c2ecf20Sopenharmony_ci	u8	Reserved3;			/* 0Ah */
3958c2ecf20Sopenharmony_ci	u8	Reserved4;			/* 0Bh */
3968c2ecf20Sopenharmony_ci	__le32	Reserved5[8];			/* 0Ch-2Ch */
3978c2ecf20Sopenharmony_ci	u16	AddlFlags2;			/* 2Ch */
3988c2ecf20Sopenharmony_ci	u8	AddlFlags3;			/* 2Eh */
3998c2ecf20Sopenharmony_ci	u8	Reserved6;			/* 2Fh */
4008c2ecf20Sopenharmony_ci	__le32	Reserved7[7];			/* 30h - 4Bh */
4018c2ecf20Sopenharmony_ci	u8	NVMeAbortTO;			/* 4Ch */
4028c2ecf20Sopenharmony_ci	u8	NumPerDevEvents;		/* 4Dh */
4038c2ecf20Sopenharmony_ci	u8	HostTraceBufferDecrementSizeKB;	/* 4Eh */
4048c2ecf20Sopenharmony_ci	u8	HostTraceBufferFlags;		/* 4Fh */
4058c2ecf20Sopenharmony_ci	u16	HostTraceBufferMaxSizeKB;	/* 50h */
4068c2ecf20Sopenharmony_ci	u16	HostTraceBufferMinSizeKB;	/* 52h */
4078c2ecf20Sopenharmony_ci	u8	CoreDumpTOSec;			/* 54h */
4088c2ecf20Sopenharmony_ci	u8	Reserved8;			/* 55h */
4098c2ecf20Sopenharmony_ci	u16	Reserved9;			/* 56h */
4108c2ecf20Sopenharmony_ci	__le32	Reserved10;			/* 58h */
4118c2ecf20Sopenharmony_ci};
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci/**
4148c2ecf20Sopenharmony_ci * struct MPT3SAS_TARGET - starget private hostdata
4158c2ecf20Sopenharmony_ci * @starget: starget object
4168c2ecf20Sopenharmony_ci * @sas_address: target sas address
4178c2ecf20Sopenharmony_ci * @raid_device: raid_device pointer to access volume data
4188c2ecf20Sopenharmony_ci * @handle: device handle
4198c2ecf20Sopenharmony_ci * @num_luns: number luns
4208c2ecf20Sopenharmony_ci * @flags: MPT_TARGET_FLAGS_XXX flags
4218c2ecf20Sopenharmony_ci * @deleted: target flaged for deletion
4228c2ecf20Sopenharmony_ci * @tm_busy: target is busy with TM request.
4238c2ecf20Sopenharmony_ci * @sas_dev: The sas_device associated with this target
4248c2ecf20Sopenharmony_ci * @pcie_dev: The pcie device associated with this target
4258c2ecf20Sopenharmony_ci */
4268c2ecf20Sopenharmony_cistruct MPT3SAS_TARGET {
4278c2ecf20Sopenharmony_ci	struct scsi_target *starget;
4288c2ecf20Sopenharmony_ci	u64	sas_address;
4298c2ecf20Sopenharmony_ci	struct _raid_device *raid_device;
4308c2ecf20Sopenharmony_ci	u16	handle;
4318c2ecf20Sopenharmony_ci	int	num_luns;
4328c2ecf20Sopenharmony_ci	u32	flags;
4338c2ecf20Sopenharmony_ci	u8	deleted;
4348c2ecf20Sopenharmony_ci	u8	tm_busy;
4358c2ecf20Sopenharmony_ci	struct _sas_device *sas_dev;
4368c2ecf20Sopenharmony_ci	struct _pcie_device *pcie_dev;
4378c2ecf20Sopenharmony_ci};
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci/*
4418c2ecf20Sopenharmony_ci * per device private data
4428c2ecf20Sopenharmony_ci */
4438c2ecf20Sopenharmony_ci#define MPT_DEVICE_FLAGS_INIT		0x01
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci#define MFG_PAGE10_HIDE_SSDS_MASK	(0x00000003)
4468c2ecf20Sopenharmony_ci#define MFG_PAGE10_HIDE_ALL_DISKS	(0x00)
4478c2ecf20Sopenharmony_ci#define MFG_PAGE10_EXPOSE_ALL_DISKS	(0x01)
4488c2ecf20Sopenharmony_ci#define MFG_PAGE10_HIDE_IF_VOL_PRESENT	(0x02)
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci/**
4518c2ecf20Sopenharmony_ci * struct MPT3SAS_DEVICE - sdev private hostdata
4528c2ecf20Sopenharmony_ci * @sas_target: starget private hostdata
4538c2ecf20Sopenharmony_ci * @lun: lun number
4548c2ecf20Sopenharmony_ci * @flags: MPT_DEVICE_XXX flags
4558c2ecf20Sopenharmony_ci * @configured_lun: lun is configured
4568c2ecf20Sopenharmony_ci * @block: device is in SDEV_BLOCK state
4578c2ecf20Sopenharmony_ci * @tlr_snoop_check: flag used in determining whether to disable TLR
4588c2ecf20Sopenharmony_ci * @eedp_enable: eedp support enable bit
4598c2ecf20Sopenharmony_ci * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
4608c2ecf20Sopenharmony_ci * @eedp_block_length: block size
4618c2ecf20Sopenharmony_ci * @ata_command_pending: SATL passthrough outstanding for device
4628c2ecf20Sopenharmony_ci */
4638c2ecf20Sopenharmony_cistruct MPT3SAS_DEVICE {
4648c2ecf20Sopenharmony_ci	struct MPT3SAS_TARGET *sas_target;
4658c2ecf20Sopenharmony_ci	unsigned int	lun;
4668c2ecf20Sopenharmony_ci	u32	flags;
4678c2ecf20Sopenharmony_ci	u8	configured_lun;
4688c2ecf20Sopenharmony_ci	u8	block;
4698c2ecf20Sopenharmony_ci	u8	tlr_snoop_check;
4708c2ecf20Sopenharmony_ci	u8	ignore_delay_remove;
4718c2ecf20Sopenharmony_ci	/* Iopriority Command Handling */
4728c2ecf20Sopenharmony_ci	u8	ncq_prio_enable;
4738c2ecf20Sopenharmony_ci	/*
4748c2ecf20Sopenharmony_ci	 * Bug workaround for SATL handling: the mpt2/3sas firmware
4758c2ecf20Sopenharmony_ci	 * doesn't return BUSY or TASK_SET_FULL for subsequent
4768c2ecf20Sopenharmony_ci	 * commands while a SATL pass through is in operation as the
4778c2ecf20Sopenharmony_ci	 * spec requires, it simply does nothing with them until the
4788c2ecf20Sopenharmony_ci	 * pass through completes, causing them possibly to timeout if
4798c2ecf20Sopenharmony_ci	 * the passthrough is a long executing command (like format or
4808c2ecf20Sopenharmony_ci	 * secure erase).  This variable allows us to do the right
4818c2ecf20Sopenharmony_ci	 * thing while a SATL command is pending.
4828c2ecf20Sopenharmony_ci	 */
4838c2ecf20Sopenharmony_ci	unsigned long ata_command_pending;
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci};
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_ci#define MPT3_CMD_NOT_USED	0x8000	/* free */
4888c2ecf20Sopenharmony_ci#define MPT3_CMD_COMPLETE	0x0001	/* completed */
4898c2ecf20Sopenharmony_ci#define MPT3_CMD_PENDING	0x0002	/* pending */
4908c2ecf20Sopenharmony_ci#define MPT3_CMD_REPLY_VALID	0x0004	/* reply is valid */
4918c2ecf20Sopenharmony_ci#define MPT3_CMD_RESET		0x0008	/* host reset dropped the command */
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci/**
4948c2ecf20Sopenharmony_ci * struct _internal_cmd - internal commands struct
4958c2ecf20Sopenharmony_ci * @mutex: mutex
4968c2ecf20Sopenharmony_ci * @done: completion
4978c2ecf20Sopenharmony_ci * @reply: reply message pointer
4988c2ecf20Sopenharmony_ci * @sense: sense data
4998c2ecf20Sopenharmony_ci * @status: MPT3_CMD_XXX status
5008c2ecf20Sopenharmony_ci * @smid: system message id
5018c2ecf20Sopenharmony_ci */
5028c2ecf20Sopenharmony_cistruct _internal_cmd {
5038c2ecf20Sopenharmony_ci	struct mutex mutex;
5048c2ecf20Sopenharmony_ci	struct completion done;
5058c2ecf20Sopenharmony_ci	void	*reply;
5068c2ecf20Sopenharmony_ci	void	*sense;
5078c2ecf20Sopenharmony_ci	u16	status;
5088c2ecf20Sopenharmony_ci	u16	smid;
5098c2ecf20Sopenharmony_ci};
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci/**
5148c2ecf20Sopenharmony_ci * struct _sas_device - attached device information
5158c2ecf20Sopenharmony_ci * @list: sas device list
5168c2ecf20Sopenharmony_ci * @starget: starget object
5178c2ecf20Sopenharmony_ci * @sas_address: device sas address
5188c2ecf20Sopenharmony_ci * @device_name: retrieved from the SAS IDENTIFY frame.
5198c2ecf20Sopenharmony_ci * @handle: device handle
5208c2ecf20Sopenharmony_ci * @sas_address_parent: sas address of parent expander or sas host
5218c2ecf20Sopenharmony_ci * @enclosure_handle: enclosure handle
5228c2ecf20Sopenharmony_ci * @enclosure_logical_id: enclosure logical identifier
5238c2ecf20Sopenharmony_ci * @volume_handle: volume handle (valid when hidden raid member)
5248c2ecf20Sopenharmony_ci * @volume_wwid: volume unique identifier
5258c2ecf20Sopenharmony_ci * @device_info: bitfield provides detailed info about the device
5268c2ecf20Sopenharmony_ci * @id: target id
5278c2ecf20Sopenharmony_ci * @channel: target channel
5288c2ecf20Sopenharmony_ci * @slot: number number
5298c2ecf20Sopenharmony_ci * @phy: phy identifier provided in sas device page 0
5308c2ecf20Sopenharmony_ci * @responding: used in _scsih_sas_device_mark_responding
5318c2ecf20Sopenharmony_ci * @fast_path: fast path feature enable bit
5328c2ecf20Sopenharmony_ci * @pfa_led_on: flag for PFA LED status
5338c2ecf20Sopenharmony_ci * @pend_sas_rphy_add: flag to check if device is in sas_rphy_add()
5348c2ecf20Sopenharmony_ci *	addition routine.
5358c2ecf20Sopenharmony_ci * @chassis_slot: chassis slot
5368c2ecf20Sopenharmony_ci * @is_chassis_slot_valid: chassis slot valid or not
5378c2ecf20Sopenharmony_ci */
5388c2ecf20Sopenharmony_cistruct _sas_device {
5398c2ecf20Sopenharmony_ci	struct list_head list;
5408c2ecf20Sopenharmony_ci	struct scsi_target *starget;
5418c2ecf20Sopenharmony_ci	u64	sas_address;
5428c2ecf20Sopenharmony_ci	u64	device_name;
5438c2ecf20Sopenharmony_ci	u16	handle;
5448c2ecf20Sopenharmony_ci	u64	sas_address_parent;
5458c2ecf20Sopenharmony_ci	u16	enclosure_handle;
5468c2ecf20Sopenharmony_ci	u64	enclosure_logical_id;
5478c2ecf20Sopenharmony_ci	u16	volume_handle;
5488c2ecf20Sopenharmony_ci	u64	volume_wwid;
5498c2ecf20Sopenharmony_ci	u32	device_info;
5508c2ecf20Sopenharmony_ci	int	id;
5518c2ecf20Sopenharmony_ci	int	channel;
5528c2ecf20Sopenharmony_ci	u16	slot;
5538c2ecf20Sopenharmony_ci	u8	phy;
5548c2ecf20Sopenharmony_ci	u8	responding;
5558c2ecf20Sopenharmony_ci	u8	fast_path;
5568c2ecf20Sopenharmony_ci	u8	pfa_led_on;
5578c2ecf20Sopenharmony_ci	u8	pend_sas_rphy_add;
5588c2ecf20Sopenharmony_ci	u8	enclosure_level;
5598c2ecf20Sopenharmony_ci	u8	chassis_slot;
5608c2ecf20Sopenharmony_ci	u8	is_chassis_slot_valid;
5618c2ecf20Sopenharmony_ci	u8	connector_name[5];
5628c2ecf20Sopenharmony_ci	struct kref refcount;
5638c2ecf20Sopenharmony_ci};
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_cistatic inline void sas_device_get(struct _sas_device *s)
5668c2ecf20Sopenharmony_ci{
5678c2ecf20Sopenharmony_ci	kref_get(&s->refcount);
5688c2ecf20Sopenharmony_ci}
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_cistatic inline void sas_device_free(struct kref *r)
5718c2ecf20Sopenharmony_ci{
5728c2ecf20Sopenharmony_ci	kfree(container_of(r, struct _sas_device, refcount));
5738c2ecf20Sopenharmony_ci}
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_cistatic inline void sas_device_put(struct _sas_device *s)
5768c2ecf20Sopenharmony_ci{
5778c2ecf20Sopenharmony_ci	kref_put(&s->refcount, sas_device_free);
5788c2ecf20Sopenharmony_ci}
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci/*
5818c2ecf20Sopenharmony_ci * struct _pcie_device - attached PCIe device information
5828c2ecf20Sopenharmony_ci * @list: pcie device list
5838c2ecf20Sopenharmony_ci * @starget: starget object
5848c2ecf20Sopenharmony_ci * @wwid: device WWID
5858c2ecf20Sopenharmony_ci * @handle: device handle
5868c2ecf20Sopenharmony_ci * @device_info: bitfield provides detailed info about the device
5878c2ecf20Sopenharmony_ci * @id: target id
5888c2ecf20Sopenharmony_ci * @channel: target channel
5898c2ecf20Sopenharmony_ci * @slot: slot number
5908c2ecf20Sopenharmony_ci * @port_num: port number
5918c2ecf20Sopenharmony_ci * @responding: used in _scsih_pcie_device_mark_responding
5928c2ecf20Sopenharmony_ci * @fast_path: fast path feature enable bit
5938c2ecf20Sopenharmony_ci * @nvme_mdts: MaximumDataTransferSize from PCIe Device Page 2 for
5948c2ecf20Sopenharmony_ci *		NVMe device only
5958c2ecf20Sopenharmony_ci * @enclosure_handle: enclosure handle
5968c2ecf20Sopenharmony_ci * @enclosure_logical_id: enclosure logical identifier
5978c2ecf20Sopenharmony_ci * @enclosure_level: The level of device's enclosure from the controller
5988c2ecf20Sopenharmony_ci * @connector_name: ASCII value of the Connector's name
5998c2ecf20Sopenharmony_ci * @serial_number: pointer of serial number string allocated runtime
6008c2ecf20Sopenharmony_ci * @access_status: Device's Access Status
6018c2ecf20Sopenharmony_ci * @shutdown_latency: NVMe device's RTD3 Entry Latency
6028c2ecf20Sopenharmony_ci * @refcount: reference count for deletion
6038c2ecf20Sopenharmony_ci */
6048c2ecf20Sopenharmony_cistruct _pcie_device {
6058c2ecf20Sopenharmony_ci	struct list_head list;
6068c2ecf20Sopenharmony_ci	struct scsi_target *starget;
6078c2ecf20Sopenharmony_ci	u64	wwid;
6088c2ecf20Sopenharmony_ci	u16	handle;
6098c2ecf20Sopenharmony_ci	u32	device_info;
6108c2ecf20Sopenharmony_ci	int	id;
6118c2ecf20Sopenharmony_ci	int	channel;
6128c2ecf20Sopenharmony_ci	u16	slot;
6138c2ecf20Sopenharmony_ci	u8	port_num;
6148c2ecf20Sopenharmony_ci	u8	responding;
6158c2ecf20Sopenharmony_ci	u8	fast_path;
6168c2ecf20Sopenharmony_ci	u32	nvme_mdts;
6178c2ecf20Sopenharmony_ci	u16	enclosure_handle;
6188c2ecf20Sopenharmony_ci	u64	enclosure_logical_id;
6198c2ecf20Sopenharmony_ci	u8	enclosure_level;
6208c2ecf20Sopenharmony_ci	u8	connector_name[4];
6218c2ecf20Sopenharmony_ci	u8	*serial_number;
6228c2ecf20Sopenharmony_ci	u8	reset_timeout;
6238c2ecf20Sopenharmony_ci	u8	access_status;
6248c2ecf20Sopenharmony_ci	u16	shutdown_latency;
6258c2ecf20Sopenharmony_ci	struct kref refcount;
6268c2ecf20Sopenharmony_ci};
6278c2ecf20Sopenharmony_ci/**
6288c2ecf20Sopenharmony_ci * pcie_device_get - Increment the pcie device reference count
6298c2ecf20Sopenharmony_ci *
6308c2ecf20Sopenharmony_ci * @p: pcie_device object
6318c2ecf20Sopenharmony_ci *
6328c2ecf20Sopenharmony_ci * When ever this function called it will increment the
6338c2ecf20Sopenharmony_ci * reference count of the pcie device for which this function called.
6348c2ecf20Sopenharmony_ci *
6358c2ecf20Sopenharmony_ci */
6368c2ecf20Sopenharmony_cistatic inline void pcie_device_get(struct _pcie_device *p)
6378c2ecf20Sopenharmony_ci{
6388c2ecf20Sopenharmony_ci	kref_get(&p->refcount);
6398c2ecf20Sopenharmony_ci}
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci/**
6428c2ecf20Sopenharmony_ci * pcie_device_free - Release the pcie device object
6438c2ecf20Sopenharmony_ci * @r - kref object
6448c2ecf20Sopenharmony_ci *
6458c2ecf20Sopenharmony_ci * Free's the pcie device object. It will be called when reference count
6468c2ecf20Sopenharmony_ci * reaches to zero.
6478c2ecf20Sopenharmony_ci */
6488c2ecf20Sopenharmony_cistatic inline void pcie_device_free(struct kref *r)
6498c2ecf20Sopenharmony_ci{
6508c2ecf20Sopenharmony_ci	kfree(container_of(r, struct _pcie_device, refcount));
6518c2ecf20Sopenharmony_ci}
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_ci/**
6548c2ecf20Sopenharmony_ci * pcie_device_put - Decrement the pcie device reference count
6558c2ecf20Sopenharmony_ci *
6568c2ecf20Sopenharmony_ci * @p: pcie_device object
6578c2ecf20Sopenharmony_ci *
6588c2ecf20Sopenharmony_ci * When ever this function called it will decrement the
6598c2ecf20Sopenharmony_ci * reference count of the pcie device for which this function called.
6608c2ecf20Sopenharmony_ci *
6618c2ecf20Sopenharmony_ci * When refernce count reaches to Zero, this will call pcie_device_free to the
6628c2ecf20Sopenharmony_ci * pcie_device object.
6638c2ecf20Sopenharmony_ci */
6648c2ecf20Sopenharmony_cistatic inline void pcie_device_put(struct _pcie_device *p)
6658c2ecf20Sopenharmony_ci{
6668c2ecf20Sopenharmony_ci	kref_put(&p->refcount, pcie_device_free);
6678c2ecf20Sopenharmony_ci}
6688c2ecf20Sopenharmony_ci/**
6698c2ecf20Sopenharmony_ci * struct _raid_device - raid volume link list
6708c2ecf20Sopenharmony_ci * @list: sas device list
6718c2ecf20Sopenharmony_ci * @starget: starget object
6728c2ecf20Sopenharmony_ci * @sdev: scsi device struct (volumes are single lun)
6738c2ecf20Sopenharmony_ci * @wwid: unique identifier for the volume
6748c2ecf20Sopenharmony_ci * @handle: device handle
6758c2ecf20Sopenharmony_ci * @block_size: Block size of the volume
6768c2ecf20Sopenharmony_ci * @id: target id
6778c2ecf20Sopenharmony_ci * @channel: target channel
6788c2ecf20Sopenharmony_ci * @volume_type: the raid level
6798c2ecf20Sopenharmony_ci * @device_info: bitfield provides detailed info about the hidden components
6808c2ecf20Sopenharmony_ci * @num_pds: number of hidden raid components
6818c2ecf20Sopenharmony_ci * @responding: used in _scsih_raid_device_mark_responding
6828c2ecf20Sopenharmony_ci * @percent_complete: resync percent complete
6838c2ecf20Sopenharmony_ci * @direct_io_enabled: Whether direct io to PDs are allowed or not
6848c2ecf20Sopenharmony_ci * @stripe_exponent: X where 2powX is the stripe sz in blocks
6858c2ecf20Sopenharmony_ci * @block_exponent: X where 2powX is the block sz in bytes
6868c2ecf20Sopenharmony_ci * @max_lba: Maximum number of LBA in the volume
6878c2ecf20Sopenharmony_ci * @stripe_sz: Stripe Size of the volume
6888c2ecf20Sopenharmony_ci * @device_info: Device info of the volume member disk
6898c2ecf20Sopenharmony_ci * @pd_handle: Array of handles of the physical drives for direct I/O in le16
6908c2ecf20Sopenharmony_ci */
6918c2ecf20Sopenharmony_ci#define MPT_MAX_WARPDRIVE_PDS		8
6928c2ecf20Sopenharmony_cistruct _raid_device {
6938c2ecf20Sopenharmony_ci	struct list_head list;
6948c2ecf20Sopenharmony_ci	struct scsi_target *starget;
6958c2ecf20Sopenharmony_ci	struct scsi_device *sdev;
6968c2ecf20Sopenharmony_ci	u64	wwid;
6978c2ecf20Sopenharmony_ci	u16	handle;
6988c2ecf20Sopenharmony_ci	u16	block_sz;
6998c2ecf20Sopenharmony_ci	int	id;
7008c2ecf20Sopenharmony_ci	int	channel;
7018c2ecf20Sopenharmony_ci	u8	volume_type;
7028c2ecf20Sopenharmony_ci	u8	num_pds;
7038c2ecf20Sopenharmony_ci	u8	responding;
7048c2ecf20Sopenharmony_ci	u8	percent_complete;
7058c2ecf20Sopenharmony_ci	u8	direct_io_enabled;
7068c2ecf20Sopenharmony_ci	u8	stripe_exponent;
7078c2ecf20Sopenharmony_ci	u8	block_exponent;
7088c2ecf20Sopenharmony_ci	u64	max_lba;
7098c2ecf20Sopenharmony_ci	u32	stripe_sz;
7108c2ecf20Sopenharmony_ci	u32	device_info;
7118c2ecf20Sopenharmony_ci	u16	pd_handle[MPT_MAX_WARPDRIVE_PDS];
7128c2ecf20Sopenharmony_ci};
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci/**
7158c2ecf20Sopenharmony_ci * struct _boot_device - boot device info
7168c2ecf20Sopenharmony_ci *
7178c2ecf20Sopenharmony_ci * @channel: sas, raid, or pcie channel
7188c2ecf20Sopenharmony_ci * @device: holds pointer for struct _sas_device, struct _raid_device or
7198c2ecf20Sopenharmony_ci *     struct _pcie_device
7208c2ecf20Sopenharmony_ci */
7218c2ecf20Sopenharmony_cistruct _boot_device {
7228c2ecf20Sopenharmony_ci	int channel;
7238c2ecf20Sopenharmony_ci	void *device;
7248c2ecf20Sopenharmony_ci};
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_ci/**
7278c2ecf20Sopenharmony_ci * struct _sas_port - wide/narrow sas port information
7288c2ecf20Sopenharmony_ci * @port_list: list of ports belonging to expander
7298c2ecf20Sopenharmony_ci * @num_phys: number of phys belonging to this port
7308c2ecf20Sopenharmony_ci * @remote_identify: attached device identification
7318c2ecf20Sopenharmony_ci * @rphy: sas transport rphy object
7328c2ecf20Sopenharmony_ci * @port: sas transport wide/narrow port object
7338c2ecf20Sopenharmony_ci * @phy_list: _sas_phy list objects belonging to this port
7348c2ecf20Sopenharmony_ci */
7358c2ecf20Sopenharmony_cistruct _sas_port {
7368c2ecf20Sopenharmony_ci	struct list_head port_list;
7378c2ecf20Sopenharmony_ci	u8	num_phys;
7388c2ecf20Sopenharmony_ci	struct sas_identify remote_identify;
7398c2ecf20Sopenharmony_ci	struct sas_rphy *rphy;
7408c2ecf20Sopenharmony_ci	struct sas_port *port;
7418c2ecf20Sopenharmony_ci	struct list_head phy_list;
7428c2ecf20Sopenharmony_ci};
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci/**
7458c2ecf20Sopenharmony_ci * struct _sas_phy - phy information
7468c2ecf20Sopenharmony_ci * @port_siblings: list of phys belonging to a port
7478c2ecf20Sopenharmony_ci * @identify: phy identification
7488c2ecf20Sopenharmony_ci * @remote_identify: attached device identification
7498c2ecf20Sopenharmony_ci * @phy: sas transport phy object
7508c2ecf20Sopenharmony_ci * @phy_id: unique phy id
7518c2ecf20Sopenharmony_ci * @handle: device handle for this phy
7528c2ecf20Sopenharmony_ci * @attached_handle: device handle for attached device
7538c2ecf20Sopenharmony_ci * @phy_belongs_to_port: port has been created for this phy
7548c2ecf20Sopenharmony_ci */
7558c2ecf20Sopenharmony_cistruct _sas_phy {
7568c2ecf20Sopenharmony_ci	struct list_head port_siblings;
7578c2ecf20Sopenharmony_ci	struct sas_identify identify;
7588c2ecf20Sopenharmony_ci	struct sas_identify remote_identify;
7598c2ecf20Sopenharmony_ci	struct sas_phy *phy;
7608c2ecf20Sopenharmony_ci	u8	phy_id;
7618c2ecf20Sopenharmony_ci	u16	handle;
7628c2ecf20Sopenharmony_ci	u16	attached_handle;
7638c2ecf20Sopenharmony_ci	u8	phy_belongs_to_port;
7648c2ecf20Sopenharmony_ci};
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci/**
7678c2ecf20Sopenharmony_ci * struct _sas_node - sas_host/expander information
7688c2ecf20Sopenharmony_ci * @list: list of expanders
7698c2ecf20Sopenharmony_ci * @parent_dev: parent device class
7708c2ecf20Sopenharmony_ci * @num_phys: number phys belonging to this sas_host/expander
7718c2ecf20Sopenharmony_ci * @sas_address: sas address of this sas_host/expander
7728c2ecf20Sopenharmony_ci * @handle: handle for this sas_host/expander
7738c2ecf20Sopenharmony_ci * @sas_address_parent: sas address of parent expander or sas host
7748c2ecf20Sopenharmony_ci * @enclosure_handle: handle for this a member of an enclosure
7758c2ecf20Sopenharmony_ci * @device_info: bitwise defining capabilities of this sas_host/expander
7768c2ecf20Sopenharmony_ci * @responding: used in _scsih_expander_device_mark_responding
7778c2ecf20Sopenharmony_ci * @phy: a list of phys that make up this sas_host/expander
7788c2ecf20Sopenharmony_ci * @sas_port_list: list of ports attached to this sas_host/expander
7798c2ecf20Sopenharmony_ci */
7808c2ecf20Sopenharmony_cistruct _sas_node {
7818c2ecf20Sopenharmony_ci	struct list_head list;
7828c2ecf20Sopenharmony_ci	struct device *parent_dev;
7838c2ecf20Sopenharmony_ci	u8	num_phys;
7848c2ecf20Sopenharmony_ci	u64	sas_address;
7858c2ecf20Sopenharmony_ci	u16	handle;
7868c2ecf20Sopenharmony_ci	u64	sas_address_parent;
7878c2ecf20Sopenharmony_ci	u16	enclosure_handle;
7888c2ecf20Sopenharmony_ci	u64	enclosure_logical_id;
7898c2ecf20Sopenharmony_ci	u8	responding;
7908c2ecf20Sopenharmony_ci	struct	_sas_phy *phy;
7918c2ecf20Sopenharmony_ci	struct list_head sas_port_list;
7928c2ecf20Sopenharmony_ci};
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci/**
7968c2ecf20Sopenharmony_ci * struct _enclosure_node - enclosure information
7978c2ecf20Sopenharmony_ci * @list: list of enclosures
7988c2ecf20Sopenharmony_ci * @pg0: enclosure pg0;
7998c2ecf20Sopenharmony_ci */
8008c2ecf20Sopenharmony_cistruct _enclosure_node {
8018c2ecf20Sopenharmony_ci	struct list_head list;
8028c2ecf20Sopenharmony_ci	Mpi2SasEnclosurePage0_t pg0;
8038c2ecf20Sopenharmony_ci};
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci/**
8068c2ecf20Sopenharmony_ci * enum reset_type - reset state
8078c2ecf20Sopenharmony_ci * @FORCE_BIG_HAMMER: issue diagnostic reset
8088c2ecf20Sopenharmony_ci * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
8098c2ecf20Sopenharmony_ci */
8108c2ecf20Sopenharmony_cienum reset_type {
8118c2ecf20Sopenharmony_ci	FORCE_BIG_HAMMER,
8128c2ecf20Sopenharmony_ci	SOFT_RESET,
8138c2ecf20Sopenharmony_ci};
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_ci/**
8168c2ecf20Sopenharmony_ci * struct pcie_sg_list - PCIe SGL buffer (contiguous per I/O)
8178c2ecf20Sopenharmony_ci * @pcie_sgl: PCIe native SGL for NVMe devices
8188c2ecf20Sopenharmony_ci * @pcie_sgl_dma: physical address
8198c2ecf20Sopenharmony_ci */
8208c2ecf20Sopenharmony_cistruct pcie_sg_list {
8218c2ecf20Sopenharmony_ci	void            *pcie_sgl;
8228c2ecf20Sopenharmony_ci	dma_addr_t      pcie_sgl_dma;
8238c2ecf20Sopenharmony_ci};
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci/**
8268c2ecf20Sopenharmony_ci * struct chain_tracker - firmware chain tracker
8278c2ecf20Sopenharmony_ci * @chain_buffer: chain buffer
8288c2ecf20Sopenharmony_ci * @chain_buffer_dma: physical address
8298c2ecf20Sopenharmony_ci * @tracker_list: list of free request (ioc->free_chain_list)
8308c2ecf20Sopenharmony_ci */
8318c2ecf20Sopenharmony_cistruct chain_tracker {
8328c2ecf20Sopenharmony_ci	void *chain_buffer;
8338c2ecf20Sopenharmony_ci	dma_addr_t chain_buffer_dma;
8348c2ecf20Sopenharmony_ci};
8358c2ecf20Sopenharmony_ci
8368c2ecf20Sopenharmony_cistruct chain_lookup {
8378c2ecf20Sopenharmony_ci	struct chain_tracker *chains_per_smid;
8388c2ecf20Sopenharmony_ci	atomic_t	chain_offset;
8398c2ecf20Sopenharmony_ci};
8408c2ecf20Sopenharmony_ci
8418c2ecf20Sopenharmony_ci/**
8428c2ecf20Sopenharmony_ci * struct scsiio_tracker - scsi mf request tracker
8438c2ecf20Sopenharmony_ci * @smid: system message id
8448c2ecf20Sopenharmony_ci * @cb_idx: callback index
8458c2ecf20Sopenharmony_ci * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
8468c2ecf20Sopenharmony_ci * @chain_list: list of associated firmware chain tracker
8478c2ecf20Sopenharmony_ci * @msix_io: IO's msix
8488c2ecf20Sopenharmony_ci */
8498c2ecf20Sopenharmony_cistruct scsiio_tracker {
8508c2ecf20Sopenharmony_ci	u16	smid;
8518c2ecf20Sopenharmony_ci	struct scsi_cmnd *scmd;
8528c2ecf20Sopenharmony_ci	u8	cb_idx;
8538c2ecf20Sopenharmony_ci	u8	direct_io;
8548c2ecf20Sopenharmony_ci	struct pcie_sg_list pcie_sg_list;
8558c2ecf20Sopenharmony_ci	struct list_head chain_list;
8568c2ecf20Sopenharmony_ci	u16     msix_io;
8578c2ecf20Sopenharmony_ci};
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ci/**
8608c2ecf20Sopenharmony_ci * struct request_tracker - firmware request tracker
8618c2ecf20Sopenharmony_ci * @smid: system message id
8628c2ecf20Sopenharmony_ci * @cb_idx: callback index
8638c2ecf20Sopenharmony_ci * @tracker_list: list of free request (ioc->free_list)
8648c2ecf20Sopenharmony_ci */
8658c2ecf20Sopenharmony_cistruct request_tracker {
8668c2ecf20Sopenharmony_ci	u16	smid;
8678c2ecf20Sopenharmony_ci	u8	cb_idx;
8688c2ecf20Sopenharmony_ci	struct list_head tracker_list;
8698c2ecf20Sopenharmony_ci};
8708c2ecf20Sopenharmony_ci
8718c2ecf20Sopenharmony_ci/**
8728c2ecf20Sopenharmony_ci * struct _tr_list - target reset list
8738c2ecf20Sopenharmony_ci * @handle: device handle
8748c2ecf20Sopenharmony_ci * @state: state machine
8758c2ecf20Sopenharmony_ci */
8768c2ecf20Sopenharmony_cistruct _tr_list {
8778c2ecf20Sopenharmony_ci	struct list_head list;
8788c2ecf20Sopenharmony_ci	u16	handle;
8798c2ecf20Sopenharmony_ci	u16	state;
8808c2ecf20Sopenharmony_ci};
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci/**
8838c2ecf20Sopenharmony_ci * struct _sc_list - delayed SAS_IO_UNIT_CONTROL message list
8848c2ecf20Sopenharmony_ci * @handle: device handle
8858c2ecf20Sopenharmony_ci */
8868c2ecf20Sopenharmony_cistruct _sc_list {
8878c2ecf20Sopenharmony_ci	struct list_head list;
8888c2ecf20Sopenharmony_ci	u16     handle;
8898c2ecf20Sopenharmony_ci};
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci/**
8928c2ecf20Sopenharmony_ci * struct _event_ack_list - delayed event acknowledgment list
8938c2ecf20Sopenharmony_ci * @Event: Event ID
8948c2ecf20Sopenharmony_ci * @EventContext: used to track the event uniquely
8958c2ecf20Sopenharmony_ci */
8968c2ecf20Sopenharmony_cistruct _event_ack_list {
8978c2ecf20Sopenharmony_ci	struct list_head list;
8988c2ecf20Sopenharmony_ci	U16     Event;
8998c2ecf20Sopenharmony_ci	U32     EventContext;
9008c2ecf20Sopenharmony_ci};
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci/**
9038c2ecf20Sopenharmony_ci * struct adapter_reply_queue - the reply queue struct
9048c2ecf20Sopenharmony_ci * @ioc: per adapter object
9058c2ecf20Sopenharmony_ci * @msix_index: msix index into vector table
9068c2ecf20Sopenharmony_ci * @vector: irq vector
9078c2ecf20Sopenharmony_ci * @reply_post_host_index: head index in the pool where FW completes IO
9088c2ecf20Sopenharmony_ci * @reply_post_free: reply post base virt address
9098c2ecf20Sopenharmony_ci * @name: the name registered to request_irq()
9108c2ecf20Sopenharmony_ci * @busy: isr is actively processing replies on another cpu
9118c2ecf20Sopenharmony_ci * @os_irq: irq number
9128c2ecf20Sopenharmony_ci * @irqpoll: irq_poll object
9138c2ecf20Sopenharmony_ci * @irq_poll_scheduled: Tells whether irq poll is scheduled or not
9148c2ecf20Sopenharmony_ci * @list: this list
9158c2ecf20Sopenharmony_ci*/
9168c2ecf20Sopenharmony_cistruct adapter_reply_queue {
9178c2ecf20Sopenharmony_ci	struct MPT3SAS_ADAPTER	*ioc;
9188c2ecf20Sopenharmony_ci	u8			msix_index;
9198c2ecf20Sopenharmony_ci	u32			reply_post_host_index;
9208c2ecf20Sopenharmony_ci	Mpi2ReplyDescriptorsUnion_t *reply_post_free;
9218c2ecf20Sopenharmony_ci	char			name[MPT_NAME_LENGTH];
9228c2ecf20Sopenharmony_ci	atomic_t		busy;
9238c2ecf20Sopenharmony_ci	u32			os_irq;
9248c2ecf20Sopenharmony_ci	struct irq_poll         irqpoll;
9258c2ecf20Sopenharmony_ci	bool			irq_poll_scheduled;
9268c2ecf20Sopenharmony_ci	bool			irq_line_enable;
9278c2ecf20Sopenharmony_ci	struct list_head	list;
9288c2ecf20Sopenharmony_ci};
9298c2ecf20Sopenharmony_ci
9308c2ecf20Sopenharmony_citypedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_ci/* SAS3.0 support */
9338c2ecf20Sopenharmony_citypedef int (*MPT_BUILD_SG_SCMD)(struct MPT3SAS_ADAPTER *ioc,
9348c2ecf20Sopenharmony_ci	struct scsi_cmnd *scmd, u16 smid, struct _pcie_device *pcie_device);
9358c2ecf20Sopenharmony_citypedef void (*MPT_BUILD_SG)(struct MPT3SAS_ADAPTER *ioc, void *psge,
9368c2ecf20Sopenharmony_ci		dma_addr_t data_out_dma, size_t data_out_sz,
9378c2ecf20Sopenharmony_ci		dma_addr_t data_in_dma, size_t data_in_sz);
9388c2ecf20Sopenharmony_citypedef void (*MPT_BUILD_ZERO_LEN_SGE)(struct MPT3SAS_ADAPTER *ioc,
9398c2ecf20Sopenharmony_ci		void *paddr);
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_ci/* SAS3.5 support */
9428c2ecf20Sopenharmony_citypedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid,
9438c2ecf20Sopenharmony_ci	Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request,
9448c2ecf20Sopenharmony_ci	dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma,
9458c2ecf20Sopenharmony_ci	size_t data_in_sz);
9468c2ecf20Sopenharmony_ci
9478c2ecf20Sopenharmony_ci/* To support atomic and non atomic descriptors*/
9488c2ecf20Sopenharmony_citypedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
9498c2ecf20Sopenharmony_ci	u16 funcdep);
9508c2ecf20Sopenharmony_citypedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
9518c2ecf20Sopenharmony_citypedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr);
9528c2ecf20Sopenharmony_ci/*
9538c2ecf20Sopenharmony_ci * To get high iops reply queue's msix index when high iops mode is enabled
9548c2ecf20Sopenharmony_ci * else get the msix index of general reply queues.
9558c2ecf20Sopenharmony_ci */
9568c2ecf20Sopenharmony_citypedef u8 (*GET_MSIX_INDEX) (struct MPT3SAS_ADAPTER *ioc,
9578c2ecf20Sopenharmony_ci	struct scsi_cmnd *scmd);
9588c2ecf20Sopenharmony_ci
9598c2ecf20Sopenharmony_ci/* IOC Facts and Port Facts converted from little endian to cpu */
9608c2ecf20Sopenharmony_ciunion mpi3_version_union {
9618c2ecf20Sopenharmony_ci	MPI2_VERSION_STRUCT		Struct;
9628c2ecf20Sopenharmony_ci	u32				Word;
9638c2ecf20Sopenharmony_ci};
9648c2ecf20Sopenharmony_ci
9658c2ecf20Sopenharmony_cistruct mpt3sas_facts {
9668c2ecf20Sopenharmony_ci	u16			MsgVersion;
9678c2ecf20Sopenharmony_ci	u16			HeaderVersion;
9688c2ecf20Sopenharmony_ci	u8			IOCNumber;
9698c2ecf20Sopenharmony_ci	u8			VP_ID;
9708c2ecf20Sopenharmony_ci	u8			VF_ID;
9718c2ecf20Sopenharmony_ci	u16			IOCExceptions;
9728c2ecf20Sopenharmony_ci	u16			IOCStatus;
9738c2ecf20Sopenharmony_ci	u32			IOCLogInfo;
9748c2ecf20Sopenharmony_ci	u8			MaxChainDepth;
9758c2ecf20Sopenharmony_ci	u8			WhoInit;
9768c2ecf20Sopenharmony_ci	u8			NumberOfPorts;
9778c2ecf20Sopenharmony_ci	u8			MaxMSIxVectors;
9788c2ecf20Sopenharmony_ci	u16			RequestCredit;
9798c2ecf20Sopenharmony_ci	u16			ProductID;
9808c2ecf20Sopenharmony_ci	u32			IOCCapabilities;
9818c2ecf20Sopenharmony_ci	union mpi3_version_union	FWVersion;
9828c2ecf20Sopenharmony_ci	u16			IOCRequestFrameSize;
9838c2ecf20Sopenharmony_ci	u16			IOCMaxChainSegmentSize;
9848c2ecf20Sopenharmony_ci	u16			MaxInitiators;
9858c2ecf20Sopenharmony_ci	u16			MaxTargets;
9868c2ecf20Sopenharmony_ci	u16			MaxSasExpanders;
9878c2ecf20Sopenharmony_ci	u16			MaxEnclosures;
9888c2ecf20Sopenharmony_ci	u16			ProtocolFlags;
9898c2ecf20Sopenharmony_ci	u16			HighPriorityCredit;
9908c2ecf20Sopenharmony_ci	u16			MaxReplyDescriptorPostQueueDepth;
9918c2ecf20Sopenharmony_ci	u8			ReplyFrameSize;
9928c2ecf20Sopenharmony_ci	u8			MaxVolumes;
9938c2ecf20Sopenharmony_ci	u16			MaxDevHandle;
9948c2ecf20Sopenharmony_ci	u16			MaxPersistentEntries;
9958c2ecf20Sopenharmony_ci	u16			MinDevHandle;
9968c2ecf20Sopenharmony_ci	u8			CurrentHostPageSize;
9978c2ecf20Sopenharmony_ci};
9988c2ecf20Sopenharmony_ci
9998c2ecf20Sopenharmony_cistruct mpt3sas_port_facts {
10008c2ecf20Sopenharmony_ci	u8			PortNumber;
10018c2ecf20Sopenharmony_ci	u8			VP_ID;
10028c2ecf20Sopenharmony_ci	u8			VF_ID;
10038c2ecf20Sopenharmony_ci	u8			PortType;
10048c2ecf20Sopenharmony_ci	u16			MaxPostedCmdBuffers;
10058c2ecf20Sopenharmony_ci};
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_cistruct reply_post_struct {
10088c2ecf20Sopenharmony_ci	Mpi2ReplyDescriptorsUnion_t	*reply_post_free;
10098c2ecf20Sopenharmony_ci	dma_addr_t			reply_post_free_dma;
10108c2ecf20Sopenharmony_ci};
10118c2ecf20Sopenharmony_ci
10128c2ecf20Sopenharmony_citypedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
10138c2ecf20Sopenharmony_ci/**
10148c2ecf20Sopenharmony_ci * struct MPT3SAS_ADAPTER - per adapter struct
10158c2ecf20Sopenharmony_ci * @list: ioc_list
10168c2ecf20Sopenharmony_ci * @shost: shost object
10178c2ecf20Sopenharmony_ci * @id: unique adapter id
10188c2ecf20Sopenharmony_ci * @cpu_count: number online cpus
10198c2ecf20Sopenharmony_ci * @name: generic ioc string
10208c2ecf20Sopenharmony_ci * @tmp_string: tmp string used for logging
10218c2ecf20Sopenharmony_ci * @pdev: pci pdev object
10228c2ecf20Sopenharmony_ci * @pio_chip: physical io register space
10238c2ecf20Sopenharmony_ci * @chip: memory mapped register space
10248c2ecf20Sopenharmony_ci * @chip_phys: physical addrss prior to mapping
10258c2ecf20Sopenharmony_ci * @logging_level: see mpt3sas_debug.h
10268c2ecf20Sopenharmony_ci * @fwfault_debug: debuging FW timeouts
10278c2ecf20Sopenharmony_ci * @ir_firmware: IR firmware present
10288c2ecf20Sopenharmony_ci * @bars: bitmask of BAR's that must be configured
10298c2ecf20Sopenharmony_ci * @mask_interrupts: ignore interrupt
10308c2ecf20Sopenharmony_ci * @pci_access_mutex: Mutex to synchronize ioctl, sysfs show path and
10318c2ecf20Sopenharmony_ci *			pci resource handling
10328c2ecf20Sopenharmony_ci * @fault_reset_work_q_name: fw fault work queue
10338c2ecf20Sopenharmony_ci * @fault_reset_work_q: ""
10348c2ecf20Sopenharmony_ci * @fault_reset_work: ""
10358c2ecf20Sopenharmony_ci * @firmware_event_name: fw event work queue
10368c2ecf20Sopenharmony_ci * @firmware_event_thread: ""
10378c2ecf20Sopenharmony_ci * @fw_event_lock:
10388c2ecf20Sopenharmony_ci * @fw_event_list: list of fw events
10398c2ecf20Sopenharmony_ci * @current_evet: current processing firmware event
10408c2ecf20Sopenharmony_ci * @fw_event_cleanup: set to one while cleaning up the fw events
10418c2ecf20Sopenharmony_ci * @aen_event_read_flag: event log was read
10428c2ecf20Sopenharmony_ci * @broadcast_aen_busy: broadcast aen waiting to be serviced
10438c2ecf20Sopenharmony_ci * @shost_recovery: host reset in progress
10448c2ecf20Sopenharmony_ci * @ioc_reset_in_progress_lock:
10458c2ecf20Sopenharmony_ci * @ioc_link_reset_in_progress: phy/hard reset in progress
10468c2ecf20Sopenharmony_ci * @ignore_loginfos: ignore loginfos during task management
10478c2ecf20Sopenharmony_ci * @remove_host: flag for when driver unloads, to avoid sending dev resets
10488c2ecf20Sopenharmony_ci * @pci_error_recovery: flag to prevent ioc access until slot reset completes
10498c2ecf20Sopenharmony_ci * @wait_for_discovery_to_complete: flag set at driver load time when
10508c2ecf20Sopenharmony_ci *                                               waiting on reporting devices
10518c2ecf20Sopenharmony_ci * @is_driver_loading: flag set at driver load time
10528c2ecf20Sopenharmony_ci * @port_enable_failed: flag set when port enable has failed
10538c2ecf20Sopenharmony_ci * @start_scan: flag set from scan_start callback, cleared from _mpt3sas_fw_work
10548c2ecf20Sopenharmony_ci * @start_scan_failed: means port enable failed, return's the ioc_status
10558c2ecf20Sopenharmony_ci * @msix_enable: flag indicating msix is enabled
10568c2ecf20Sopenharmony_ci * @msix_vector_count: number msix vectors
10578c2ecf20Sopenharmony_ci * @cpu_msix_table: table for mapping cpus to msix index
10588c2ecf20Sopenharmony_ci * @cpu_msix_table_sz: table size
10598c2ecf20Sopenharmony_ci * @total_io_cnt: Gives total IO count, used to load balance the interrupts
10608c2ecf20Sopenharmony_ci * @ioc_coredump_loop: will have non-zero value when FW is in CoreDump state
10618c2ecf20Sopenharmony_ci * @high_iops_outstanding: used to load balance the interrupts
10628c2ecf20Sopenharmony_ci *				within high iops reply queues
10638c2ecf20Sopenharmony_ci * @msix_load_balance: Enables load balancing of interrupts across
10648c2ecf20Sopenharmony_ci * the multiple MSIXs
10658c2ecf20Sopenharmony_ci * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
10668c2ecf20Sopenharmony_ci * @thresh_hold: Max number of reply descriptors processed
10678c2ecf20Sopenharmony_ci *				before updating Host Index
10688c2ecf20Sopenharmony_ci * @drv_support_bitmap: driver's supported feature bit map
10698c2ecf20Sopenharmony_ci * @use_32bit_dma: Flag to use 32 bit consistent dma mask
10708c2ecf20Sopenharmony_ci * @scsi_io_cb_idx: shost generated commands
10718c2ecf20Sopenharmony_ci * @tm_cb_idx: task management commands
10728c2ecf20Sopenharmony_ci * @scsih_cb_idx: scsih internal commands
10738c2ecf20Sopenharmony_ci * @transport_cb_idx: transport internal commands
10748c2ecf20Sopenharmony_ci * @ctl_cb_idx: clt internal commands
10758c2ecf20Sopenharmony_ci * @base_cb_idx: base internal commands
10768c2ecf20Sopenharmony_ci * @config_cb_idx: base internal commands
10778c2ecf20Sopenharmony_ci * @tm_tr_cb_idx : device removal target reset handshake
10788c2ecf20Sopenharmony_ci * @tm_tr_volume_cb_idx : volume removal target reset
10798c2ecf20Sopenharmony_ci * @base_cmds:
10808c2ecf20Sopenharmony_ci * @transport_cmds:
10818c2ecf20Sopenharmony_ci * @scsih_cmds:
10828c2ecf20Sopenharmony_ci * @tm_cmds:
10838c2ecf20Sopenharmony_ci * @ctl_cmds:
10848c2ecf20Sopenharmony_ci * @config_cmds:
10858c2ecf20Sopenharmony_ci * @base_add_sg_single: handler for either 32/64 bit sgl's
10868c2ecf20Sopenharmony_ci * @event_type: bits indicating which events to log
10878c2ecf20Sopenharmony_ci * @event_context: unique id for each logged event
10888c2ecf20Sopenharmony_ci * @event_log: event log pointer
10898c2ecf20Sopenharmony_ci * @event_masks: events that are masked
10908c2ecf20Sopenharmony_ci * @max_shutdown_latency: timeout value for NVMe shutdown operation,
10918c2ecf20Sopenharmony_ci *			which is equal that NVMe drive's RTD3 Entry Latency
10928c2ecf20Sopenharmony_ci *			which has reported maximum RTD3 Entry Latency value
10938c2ecf20Sopenharmony_ci *			among attached NVMe drives.
10948c2ecf20Sopenharmony_ci * @facts: static facts data
10958c2ecf20Sopenharmony_ci * @prev_fw_facts: previous fw facts data
10968c2ecf20Sopenharmony_ci * @pfacts: static port facts data
10978c2ecf20Sopenharmony_ci * @manu_pg0: static manufacturing page 0
10988c2ecf20Sopenharmony_ci * @manu_pg10: static manufacturing page 10
10998c2ecf20Sopenharmony_ci * @manu_pg11: static manufacturing page 11
11008c2ecf20Sopenharmony_ci * @bios_pg2: static bios page 2
11018c2ecf20Sopenharmony_ci * @bios_pg3: static bios page 3
11028c2ecf20Sopenharmony_ci * @ioc_pg8: static ioc page 8
11038c2ecf20Sopenharmony_ci * @iounit_pg0: static iounit page 0
11048c2ecf20Sopenharmony_ci * @iounit_pg1: static iounit page 1
11058c2ecf20Sopenharmony_ci * @iounit_pg8: static iounit page 8
11068c2ecf20Sopenharmony_ci * @sas_hba: sas host object
11078c2ecf20Sopenharmony_ci * @sas_expander_list: expander object list
11088c2ecf20Sopenharmony_ci * @enclosure_list: enclosure object list
11098c2ecf20Sopenharmony_ci * @sas_node_lock:
11108c2ecf20Sopenharmony_ci * @sas_device_list: sas device object list
11118c2ecf20Sopenharmony_ci * @sas_device_init_list: sas device object list (used only at init time)
11128c2ecf20Sopenharmony_ci * @sas_device_lock:
11138c2ecf20Sopenharmony_ci * @pcie_device_list: pcie device object list
11148c2ecf20Sopenharmony_ci * @pcie_device_init_list: pcie device object list (used only at init time)
11158c2ecf20Sopenharmony_ci * @pcie_device_lock:
11168c2ecf20Sopenharmony_ci * @io_missing_delay: time for IO completed by fw when PDR enabled
11178c2ecf20Sopenharmony_ci * @device_missing_delay: time for device missing by fw when PDR enabled
11188c2ecf20Sopenharmony_ci * @sas_id : used for setting volume target IDs
11198c2ecf20Sopenharmony_ci * @pcie_target_id: used for setting pcie target IDs
11208c2ecf20Sopenharmony_ci * @blocking_handles: bitmask used to identify which devices need blocking
11218c2ecf20Sopenharmony_ci * @pd_handles : bitmask for PD handles
11228c2ecf20Sopenharmony_ci * @pd_handles_sz : size of pd_handle bitmask
11238c2ecf20Sopenharmony_ci * @config_page_sz: config page size
11248c2ecf20Sopenharmony_ci * @config_page: reserve memory for config page payload
11258c2ecf20Sopenharmony_ci * @config_page_dma:
11268c2ecf20Sopenharmony_ci * @hba_queue_depth: hba request queue depth
11278c2ecf20Sopenharmony_ci * @sge_size: sg element size for either 32/64 bit
11288c2ecf20Sopenharmony_ci * @scsiio_depth: SCSI_IO queue depth
11298c2ecf20Sopenharmony_ci * @request_sz: per request frame size
11308c2ecf20Sopenharmony_ci * @request: pool of request frames
11318c2ecf20Sopenharmony_ci * @request_dma:
11328c2ecf20Sopenharmony_ci * @request_dma_sz:
11338c2ecf20Sopenharmony_ci * @scsi_lookup: firmware request tracker list
11348c2ecf20Sopenharmony_ci * @scsi_lookup_lock:
11358c2ecf20Sopenharmony_ci * @free_list: free list of request
11368c2ecf20Sopenharmony_ci * @pending_io_count:
11378c2ecf20Sopenharmony_ci * @reset_wq:
11388c2ecf20Sopenharmony_ci * @chain: pool of chains
11398c2ecf20Sopenharmony_ci * @chain_dma:
11408c2ecf20Sopenharmony_ci * @max_sges_in_main_message: number sg elements in main message
11418c2ecf20Sopenharmony_ci * @max_sges_in_chain_message: number sg elements per chain
11428c2ecf20Sopenharmony_ci * @chains_needed_per_io: max chains per io
11438c2ecf20Sopenharmony_ci * @chain_depth: total chains allocated
11448c2ecf20Sopenharmony_ci * @chain_segment_sz: gives the max number of
11458c2ecf20Sopenharmony_ci *			SGEs accommodate on single chain buffer
11468c2ecf20Sopenharmony_ci * @hi_priority_smid:
11478c2ecf20Sopenharmony_ci * @hi_priority:
11488c2ecf20Sopenharmony_ci * @hi_priority_dma:
11498c2ecf20Sopenharmony_ci * @hi_priority_depth:
11508c2ecf20Sopenharmony_ci * @hpr_lookup:
11518c2ecf20Sopenharmony_ci * @hpr_free_list:
11528c2ecf20Sopenharmony_ci * @internal_smid:
11538c2ecf20Sopenharmony_ci * @internal:
11548c2ecf20Sopenharmony_ci * @internal_dma:
11558c2ecf20Sopenharmony_ci * @internal_depth:
11568c2ecf20Sopenharmony_ci * @internal_lookup:
11578c2ecf20Sopenharmony_ci * @internal_free_list:
11588c2ecf20Sopenharmony_ci * @sense: pool of sense
11598c2ecf20Sopenharmony_ci * @sense_dma:
11608c2ecf20Sopenharmony_ci * @sense_dma_pool:
11618c2ecf20Sopenharmony_ci * @reply_depth: hba reply queue depth:
11628c2ecf20Sopenharmony_ci * @reply_sz: per reply frame size:
11638c2ecf20Sopenharmony_ci * @reply: pool of replys:
11648c2ecf20Sopenharmony_ci * @reply_dma:
11658c2ecf20Sopenharmony_ci * @reply_dma_pool:
11668c2ecf20Sopenharmony_ci * @reply_free_queue_depth: reply free depth
11678c2ecf20Sopenharmony_ci * @reply_free: pool for reply free queue (32 bit addr)
11688c2ecf20Sopenharmony_ci * @reply_free_dma:
11698c2ecf20Sopenharmony_ci * @reply_free_dma_pool:
11708c2ecf20Sopenharmony_ci * @reply_free_host_index: tail index in pool to insert free replys
11718c2ecf20Sopenharmony_ci * @reply_post_queue_depth: reply post queue depth
11728c2ecf20Sopenharmony_ci * @reply_post_struct: struct for reply_post_free physical & virt address
11738c2ecf20Sopenharmony_ci * @rdpq_array_capable: FW supports multiple reply queue addresses in ioc_init
11748c2ecf20Sopenharmony_ci * @rdpq_array_enable: rdpq_array support is enabled in the driver
11758c2ecf20Sopenharmony_ci * @rdpq_array_enable_assigned: this ensures that rdpq_array_enable flag
11768c2ecf20Sopenharmony_ci *				is assigned only ones
11778c2ecf20Sopenharmony_ci * @reply_queue_count: number of reply queue's
11788c2ecf20Sopenharmony_ci * @reply_queue_list: link list contaning the reply queue info
11798c2ecf20Sopenharmony_ci * @msix96_vector: 96 MSI-X vector support
11808c2ecf20Sopenharmony_ci * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
11818c2ecf20Sopenharmony_ci * @delayed_tr_list: target reset link list
11828c2ecf20Sopenharmony_ci * @delayed_tr_volume_list: volume target reset link list
11838c2ecf20Sopenharmony_ci * @delayed_sc_list:
11848c2ecf20Sopenharmony_ci * @delayed_event_ack_list:
11858c2ecf20Sopenharmony_ci * @temp_sensors_count: flag to carry the number of temperature sensors
11868c2ecf20Sopenharmony_ci * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
11878c2ecf20Sopenharmony_ci *	pci resource handling. PCI resource freeing will lead to free
11888c2ecf20Sopenharmony_ci *	vital hardware/memory resource, which might be in use by cli/sysfs
11898c2ecf20Sopenharmony_ci *	path functions resulting in Null pointer reference followed by kernel
11908c2ecf20Sopenharmony_ci *	crash. To avoid the above race condition we use mutex syncrhonization
11918c2ecf20Sopenharmony_ci *	which ensures the syncrhonization between cli/sysfs_show path.
11928c2ecf20Sopenharmony_ci * @atomic_desc_capable: Atomic Request Descriptor support.
11938c2ecf20Sopenharmony_ci * @GET_MSIX_INDEX: Get the msix index of high iops queues.
11948c2ecf20Sopenharmony_ci */
11958c2ecf20Sopenharmony_cistruct MPT3SAS_ADAPTER {
11968c2ecf20Sopenharmony_ci	struct list_head list;
11978c2ecf20Sopenharmony_ci	struct Scsi_Host *shost;
11988c2ecf20Sopenharmony_ci	u8		id;
11998c2ecf20Sopenharmony_ci	int		cpu_count;
12008c2ecf20Sopenharmony_ci	char		name[MPT_NAME_LENGTH];
12018c2ecf20Sopenharmony_ci	char		driver_name[MPT_NAME_LENGTH - 8];
12028c2ecf20Sopenharmony_ci	char		tmp_string[MPT_STRING_LENGTH];
12038c2ecf20Sopenharmony_ci	struct pci_dev	*pdev;
12048c2ecf20Sopenharmony_ci	Mpi2SystemInterfaceRegs_t __iomem *chip;
12058c2ecf20Sopenharmony_ci	phys_addr_t	chip_phys;
12068c2ecf20Sopenharmony_ci	int		logging_level;
12078c2ecf20Sopenharmony_ci	int		fwfault_debug;
12088c2ecf20Sopenharmony_ci	u8		ir_firmware;
12098c2ecf20Sopenharmony_ci	int		bars;
12108c2ecf20Sopenharmony_ci	u8		mask_interrupts;
12118c2ecf20Sopenharmony_ci
12128c2ecf20Sopenharmony_ci	/* fw fault handler */
12138c2ecf20Sopenharmony_ci	char		fault_reset_work_q_name[20];
12148c2ecf20Sopenharmony_ci	struct workqueue_struct *fault_reset_work_q;
12158c2ecf20Sopenharmony_ci	struct delayed_work fault_reset_work;
12168c2ecf20Sopenharmony_ci
12178c2ecf20Sopenharmony_ci	/* fw event handler */
12188c2ecf20Sopenharmony_ci	char		firmware_event_name[20];
12198c2ecf20Sopenharmony_ci	struct workqueue_struct	*firmware_event_thread;
12208c2ecf20Sopenharmony_ci	spinlock_t	fw_event_lock;
12218c2ecf20Sopenharmony_ci	struct list_head fw_event_list;
12228c2ecf20Sopenharmony_ci	struct fw_event_work	*current_event;
12238c2ecf20Sopenharmony_ci	u8		fw_events_cleanup;
12248c2ecf20Sopenharmony_ci
12258c2ecf20Sopenharmony_ci	 /* misc flags */
12268c2ecf20Sopenharmony_ci	int		aen_event_read_flag;
12278c2ecf20Sopenharmony_ci	u8		broadcast_aen_busy;
12288c2ecf20Sopenharmony_ci	u16		broadcast_aen_pending;
12298c2ecf20Sopenharmony_ci	u8		shost_recovery;
12308c2ecf20Sopenharmony_ci	u8		got_task_abort_from_ioctl;
12318c2ecf20Sopenharmony_ci
12328c2ecf20Sopenharmony_ci	struct mutex	reset_in_progress_mutex;
12338c2ecf20Sopenharmony_ci	spinlock_t	ioc_reset_in_progress_lock;
12348c2ecf20Sopenharmony_ci	u8		ioc_link_reset_in_progress;
12358c2ecf20Sopenharmony_ci
12368c2ecf20Sopenharmony_ci	u8		ignore_loginfos;
12378c2ecf20Sopenharmony_ci	u8		remove_host;
12388c2ecf20Sopenharmony_ci	u8		pci_error_recovery;
12398c2ecf20Sopenharmony_ci	u8		wait_for_discovery_to_complete;
12408c2ecf20Sopenharmony_ci	u8		is_driver_loading;
12418c2ecf20Sopenharmony_ci	u8		port_enable_failed;
12428c2ecf20Sopenharmony_ci	u8		start_scan;
12438c2ecf20Sopenharmony_ci	u16		start_scan_failed;
12448c2ecf20Sopenharmony_ci
12458c2ecf20Sopenharmony_ci	u8		msix_enable;
12468c2ecf20Sopenharmony_ci	u16		msix_vector_count;
12478c2ecf20Sopenharmony_ci	u8		*cpu_msix_table;
12488c2ecf20Sopenharmony_ci	u16		cpu_msix_table_sz;
12498c2ecf20Sopenharmony_ci	resource_size_t __iomem **reply_post_host_index;
12508c2ecf20Sopenharmony_ci	u32		ioc_reset_count;
12518c2ecf20Sopenharmony_ci	MPT3SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
12528c2ecf20Sopenharmony_ci	u32             non_operational_loop;
12538c2ecf20Sopenharmony_ci	u8              ioc_coredump_loop;
12548c2ecf20Sopenharmony_ci	atomic64_t      total_io_cnt;
12558c2ecf20Sopenharmony_ci	atomic64_t	high_iops_outstanding;
12568c2ecf20Sopenharmony_ci	bool            msix_load_balance;
12578c2ecf20Sopenharmony_ci	u16		thresh_hold;
12588c2ecf20Sopenharmony_ci	u8		high_iops_queues;
12598c2ecf20Sopenharmony_ci	u32		drv_support_bitmap;
12608c2ecf20Sopenharmony_ci	u32             dma_mask;
12618c2ecf20Sopenharmony_ci	bool		enable_sdev_max_qd;
12628c2ecf20Sopenharmony_ci	bool		use_32bit_dma;
12638c2ecf20Sopenharmony_ci
12648c2ecf20Sopenharmony_ci	/* internal commands, callback index */
12658c2ecf20Sopenharmony_ci	u8		scsi_io_cb_idx;
12668c2ecf20Sopenharmony_ci	u8		tm_cb_idx;
12678c2ecf20Sopenharmony_ci	u8		transport_cb_idx;
12688c2ecf20Sopenharmony_ci	u8		scsih_cb_idx;
12698c2ecf20Sopenharmony_ci	u8		ctl_cb_idx;
12708c2ecf20Sopenharmony_ci	u8		base_cb_idx;
12718c2ecf20Sopenharmony_ci	u8		port_enable_cb_idx;
12728c2ecf20Sopenharmony_ci	u8		config_cb_idx;
12738c2ecf20Sopenharmony_ci	u8		tm_tr_cb_idx;
12748c2ecf20Sopenharmony_ci	u8		tm_tr_volume_cb_idx;
12758c2ecf20Sopenharmony_ci	u8		tm_sas_control_cb_idx;
12768c2ecf20Sopenharmony_ci	struct _internal_cmd base_cmds;
12778c2ecf20Sopenharmony_ci	struct _internal_cmd port_enable_cmds;
12788c2ecf20Sopenharmony_ci	struct _internal_cmd transport_cmds;
12798c2ecf20Sopenharmony_ci	struct _internal_cmd scsih_cmds;
12808c2ecf20Sopenharmony_ci	struct _internal_cmd tm_cmds;
12818c2ecf20Sopenharmony_ci	struct _internal_cmd ctl_cmds;
12828c2ecf20Sopenharmony_ci	struct _internal_cmd config_cmds;
12838c2ecf20Sopenharmony_ci
12848c2ecf20Sopenharmony_ci	MPT_ADD_SGE	base_add_sg_single;
12858c2ecf20Sopenharmony_ci
12868c2ecf20Sopenharmony_ci	/* function ptr for either IEEE or MPI sg elements */
12878c2ecf20Sopenharmony_ci	MPT_BUILD_SG_SCMD build_sg_scmd;
12888c2ecf20Sopenharmony_ci	MPT_BUILD_SG    build_sg;
12898c2ecf20Sopenharmony_ci	MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
12908c2ecf20Sopenharmony_ci	u16             sge_size_ieee;
12918c2ecf20Sopenharmony_ci	u16		hba_mpi_version_belonged;
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_ci	/* function ptr for MPI sg elements only */
12948c2ecf20Sopenharmony_ci	MPT_BUILD_SG    build_sg_mpi;
12958c2ecf20Sopenharmony_ci	MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge_mpi;
12968c2ecf20Sopenharmony_ci
12978c2ecf20Sopenharmony_ci	/* function ptr for NVMe PRP elements only */
12988c2ecf20Sopenharmony_ci	NVME_BUILD_PRP  build_nvme_prp;
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	/* event log */
13018c2ecf20Sopenharmony_ci	u32		event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
13028c2ecf20Sopenharmony_ci	u32		event_context;
13038c2ecf20Sopenharmony_ci	void		*event_log;
13048c2ecf20Sopenharmony_ci	u32		event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_ci	u8		tm_custom_handling;
13078c2ecf20Sopenharmony_ci	u8		nvme_abort_timeout;
13088c2ecf20Sopenharmony_ci	u16		max_shutdown_latency;
13098c2ecf20Sopenharmony_ci
13108c2ecf20Sopenharmony_ci	/* static config pages */
13118c2ecf20Sopenharmony_ci	struct mpt3sas_facts facts;
13128c2ecf20Sopenharmony_ci	struct mpt3sas_facts prev_fw_facts;
13138c2ecf20Sopenharmony_ci	struct mpt3sas_port_facts *pfacts;
13148c2ecf20Sopenharmony_ci	Mpi2ManufacturingPage0_t manu_pg0;
13158c2ecf20Sopenharmony_ci	struct Mpi2ManufacturingPage10_t manu_pg10;
13168c2ecf20Sopenharmony_ci	struct Mpi2ManufacturingPage11_t manu_pg11;
13178c2ecf20Sopenharmony_ci	Mpi2BiosPage2_t	bios_pg2;
13188c2ecf20Sopenharmony_ci	Mpi2BiosPage3_t	bios_pg3;
13198c2ecf20Sopenharmony_ci	Mpi2IOCPage8_t ioc_pg8;
13208c2ecf20Sopenharmony_ci	Mpi2IOUnitPage0_t iounit_pg0;
13218c2ecf20Sopenharmony_ci	Mpi2IOUnitPage1_t iounit_pg1;
13228c2ecf20Sopenharmony_ci	Mpi2IOUnitPage8_t iounit_pg8;
13238c2ecf20Sopenharmony_ci	Mpi2IOCPage1_t	ioc_pg1_copy;
13248c2ecf20Sopenharmony_ci
13258c2ecf20Sopenharmony_ci	struct _boot_device req_boot_device;
13268c2ecf20Sopenharmony_ci	struct _boot_device req_alt_boot_device;
13278c2ecf20Sopenharmony_ci	struct _boot_device current_boot_device;
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci	/* sas hba, expander, and device list */
13308c2ecf20Sopenharmony_ci	struct _sas_node sas_hba;
13318c2ecf20Sopenharmony_ci	struct list_head sas_expander_list;
13328c2ecf20Sopenharmony_ci	struct list_head enclosure_list;
13338c2ecf20Sopenharmony_ci	spinlock_t	sas_node_lock;
13348c2ecf20Sopenharmony_ci	struct list_head sas_device_list;
13358c2ecf20Sopenharmony_ci	struct list_head sas_device_init_list;
13368c2ecf20Sopenharmony_ci	spinlock_t	sas_device_lock;
13378c2ecf20Sopenharmony_ci	struct list_head pcie_device_list;
13388c2ecf20Sopenharmony_ci	struct list_head pcie_device_init_list;
13398c2ecf20Sopenharmony_ci	spinlock_t      pcie_device_lock;
13408c2ecf20Sopenharmony_ci
13418c2ecf20Sopenharmony_ci	struct list_head raid_device_list;
13428c2ecf20Sopenharmony_ci	spinlock_t	raid_device_lock;
13438c2ecf20Sopenharmony_ci	u8		io_missing_delay;
13448c2ecf20Sopenharmony_ci	u16		device_missing_delay;
13458c2ecf20Sopenharmony_ci	int		sas_id;
13468c2ecf20Sopenharmony_ci	int		pcie_target_id;
13478c2ecf20Sopenharmony_ci
13488c2ecf20Sopenharmony_ci	void		*blocking_handles;
13498c2ecf20Sopenharmony_ci	void		*pd_handles;
13508c2ecf20Sopenharmony_ci	u16		pd_handles_sz;
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_ci	void		*pend_os_device_add;
13538c2ecf20Sopenharmony_ci	u16		pend_os_device_add_sz;
13548c2ecf20Sopenharmony_ci
13558c2ecf20Sopenharmony_ci	/* config page */
13568c2ecf20Sopenharmony_ci	u16		config_page_sz;
13578c2ecf20Sopenharmony_ci	void		*config_page;
13588c2ecf20Sopenharmony_ci	dma_addr_t	config_page_dma;
13598c2ecf20Sopenharmony_ci	void		*config_vaddr;
13608c2ecf20Sopenharmony_ci
13618c2ecf20Sopenharmony_ci	/* scsiio request */
13628c2ecf20Sopenharmony_ci	u16		hba_queue_depth;
13638c2ecf20Sopenharmony_ci	u16		sge_size;
13648c2ecf20Sopenharmony_ci	u16		scsiio_depth;
13658c2ecf20Sopenharmony_ci	u16		request_sz;
13668c2ecf20Sopenharmony_ci	u8		*request;
13678c2ecf20Sopenharmony_ci	dma_addr_t	request_dma;
13688c2ecf20Sopenharmony_ci	u32		request_dma_sz;
13698c2ecf20Sopenharmony_ci	struct pcie_sg_list *pcie_sg_lookup;
13708c2ecf20Sopenharmony_ci	spinlock_t	scsi_lookup_lock;
13718c2ecf20Sopenharmony_ci	int		pending_io_count;
13728c2ecf20Sopenharmony_ci	wait_queue_head_t reset_wq;
13738c2ecf20Sopenharmony_ci
13748c2ecf20Sopenharmony_ci	/* PCIe SGL */
13758c2ecf20Sopenharmony_ci	struct dma_pool *pcie_sgl_dma_pool;
13768c2ecf20Sopenharmony_ci	/* Host Page Size */
13778c2ecf20Sopenharmony_ci	u32		page_size;
13788c2ecf20Sopenharmony_ci
13798c2ecf20Sopenharmony_ci	/* chain */
13808c2ecf20Sopenharmony_ci	struct chain_lookup *chain_lookup;
13818c2ecf20Sopenharmony_ci	struct list_head free_chain_list;
13828c2ecf20Sopenharmony_ci	struct dma_pool *chain_dma_pool;
13838c2ecf20Sopenharmony_ci	ulong		chain_pages;
13848c2ecf20Sopenharmony_ci	u16		max_sges_in_main_message;
13858c2ecf20Sopenharmony_ci	u16		max_sges_in_chain_message;
13868c2ecf20Sopenharmony_ci	u16		chains_needed_per_io;
13878c2ecf20Sopenharmony_ci	u32		chain_depth;
13888c2ecf20Sopenharmony_ci	u16		chain_segment_sz;
13898c2ecf20Sopenharmony_ci	u16		chains_per_prp_buffer;
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_ci	/* hi-priority queue */
13928c2ecf20Sopenharmony_ci	u16		hi_priority_smid;
13938c2ecf20Sopenharmony_ci	u8		*hi_priority;
13948c2ecf20Sopenharmony_ci	dma_addr_t	hi_priority_dma;
13958c2ecf20Sopenharmony_ci	u16		hi_priority_depth;
13968c2ecf20Sopenharmony_ci	struct request_tracker *hpr_lookup;
13978c2ecf20Sopenharmony_ci	struct list_head hpr_free_list;
13988c2ecf20Sopenharmony_ci
13998c2ecf20Sopenharmony_ci	/* internal queue */
14008c2ecf20Sopenharmony_ci	u16		internal_smid;
14018c2ecf20Sopenharmony_ci	u8		*internal;
14028c2ecf20Sopenharmony_ci	dma_addr_t	internal_dma;
14038c2ecf20Sopenharmony_ci	u16		internal_depth;
14048c2ecf20Sopenharmony_ci	struct request_tracker *internal_lookup;
14058c2ecf20Sopenharmony_ci	struct list_head internal_free_list;
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_ci	/* sense */
14088c2ecf20Sopenharmony_ci	u8		*sense;
14098c2ecf20Sopenharmony_ci	dma_addr_t	sense_dma;
14108c2ecf20Sopenharmony_ci	struct dma_pool *sense_dma_pool;
14118c2ecf20Sopenharmony_ci
14128c2ecf20Sopenharmony_ci	/* reply */
14138c2ecf20Sopenharmony_ci	u16		reply_sz;
14148c2ecf20Sopenharmony_ci	u8		*reply;
14158c2ecf20Sopenharmony_ci	dma_addr_t	reply_dma;
14168c2ecf20Sopenharmony_ci	u32		reply_dma_max_address;
14178c2ecf20Sopenharmony_ci	u32		reply_dma_min_address;
14188c2ecf20Sopenharmony_ci	struct dma_pool *reply_dma_pool;
14198c2ecf20Sopenharmony_ci
14208c2ecf20Sopenharmony_ci	/* reply free queue */
14218c2ecf20Sopenharmony_ci	u16		reply_free_queue_depth;
14228c2ecf20Sopenharmony_ci	__le32		*reply_free;
14238c2ecf20Sopenharmony_ci	dma_addr_t	reply_free_dma;
14248c2ecf20Sopenharmony_ci	struct dma_pool *reply_free_dma_pool;
14258c2ecf20Sopenharmony_ci	u32		reply_free_host_index;
14268c2ecf20Sopenharmony_ci
14278c2ecf20Sopenharmony_ci	/* reply post queue */
14288c2ecf20Sopenharmony_ci	u16		reply_post_queue_depth;
14298c2ecf20Sopenharmony_ci	struct reply_post_struct *reply_post;
14308c2ecf20Sopenharmony_ci	u8		rdpq_array_capable;
14318c2ecf20Sopenharmony_ci	u8		rdpq_array_enable;
14328c2ecf20Sopenharmony_ci	u8		rdpq_array_enable_assigned;
14338c2ecf20Sopenharmony_ci	struct dma_pool *reply_post_free_dma_pool;
14348c2ecf20Sopenharmony_ci	struct dma_pool *reply_post_free_array_dma_pool;
14358c2ecf20Sopenharmony_ci	Mpi2IOCInitRDPQArrayEntry *reply_post_free_array;
14368c2ecf20Sopenharmony_ci	dma_addr_t reply_post_free_array_dma;
14378c2ecf20Sopenharmony_ci	u8		reply_queue_count;
14388c2ecf20Sopenharmony_ci	struct list_head reply_queue_list;
14398c2ecf20Sopenharmony_ci
14408c2ecf20Sopenharmony_ci	u8		combined_reply_queue;
14418c2ecf20Sopenharmony_ci	u8		combined_reply_index_count;
14428c2ecf20Sopenharmony_ci	u8		smp_affinity_enable;
14438c2ecf20Sopenharmony_ci	/* reply post register index */
14448c2ecf20Sopenharmony_ci	resource_size_t	**replyPostRegisterIndex;
14458c2ecf20Sopenharmony_ci
14468c2ecf20Sopenharmony_ci	struct list_head delayed_tr_list;
14478c2ecf20Sopenharmony_ci	struct list_head delayed_tr_volume_list;
14488c2ecf20Sopenharmony_ci	struct list_head delayed_sc_list;
14498c2ecf20Sopenharmony_ci	struct list_head delayed_event_ack_list;
14508c2ecf20Sopenharmony_ci	u8		temp_sensors_count;
14518c2ecf20Sopenharmony_ci	struct mutex pci_access_mutex;
14528c2ecf20Sopenharmony_ci
14538c2ecf20Sopenharmony_ci	/* diag buffer support */
14548c2ecf20Sopenharmony_ci	u8		*diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
14558c2ecf20Sopenharmony_ci	u32		diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
14568c2ecf20Sopenharmony_ci	dma_addr_t	diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
14578c2ecf20Sopenharmony_ci	u8		diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
14588c2ecf20Sopenharmony_ci	u32		unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
14598c2ecf20Sopenharmony_ci	u32		product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
14608c2ecf20Sopenharmony_ci	u32		diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
14618c2ecf20Sopenharmony_ci	u32		ring_buffer_offset;
14628c2ecf20Sopenharmony_ci	u32		ring_buffer_sz;
14638c2ecf20Sopenharmony_ci	u8		is_warpdrive;
14648c2ecf20Sopenharmony_ci	u8		is_mcpu_endpoint;
14658c2ecf20Sopenharmony_ci	u8		hide_ir_msg;
14668c2ecf20Sopenharmony_ci	u8		mfg_pg10_hide_flag;
14678c2ecf20Sopenharmony_ci	u8		hide_drives;
14688c2ecf20Sopenharmony_ci	spinlock_t	diag_trigger_lock;
14698c2ecf20Sopenharmony_ci	u8		diag_trigger_active;
14708c2ecf20Sopenharmony_ci	u8		atomic_desc_capable;
14718c2ecf20Sopenharmony_ci	BASE_READ_REG	base_readl;
14728c2ecf20Sopenharmony_ci	BASE_READ_REG	base_readl_ext_retry;
14738c2ecf20Sopenharmony_ci	struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
14748c2ecf20Sopenharmony_ci	struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
14758c2ecf20Sopenharmony_ci	struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
14768c2ecf20Sopenharmony_ci	struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
14778c2ecf20Sopenharmony_ci	void		*device_remove_in_progress;
14788c2ecf20Sopenharmony_ci	u16		device_remove_in_progress_sz;
14798c2ecf20Sopenharmony_ci	u8		is_gen35_ioc;
14808c2ecf20Sopenharmony_ci	u8		is_aero_ioc;
14818c2ecf20Sopenharmony_ci	struct dentry	*debugfs_root;
14828c2ecf20Sopenharmony_ci	struct dentry	*ioc_dump;
14838c2ecf20Sopenharmony_ci	PUT_SMID_IO_FP_HIP put_smid_scsi_io;
14848c2ecf20Sopenharmony_ci	PUT_SMID_IO_FP_HIP put_smid_fast_path;
14858c2ecf20Sopenharmony_ci	PUT_SMID_IO_FP_HIP put_smid_hi_priority;
14868c2ecf20Sopenharmony_ci	PUT_SMID_DEFAULT put_smid_default;
14878c2ecf20Sopenharmony_ci	GET_MSIX_INDEX get_msix_index_for_smlio;
14888c2ecf20Sopenharmony_ci};
14898c2ecf20Sopenharmony_ci
14908c2ecf20Sopenharmony_cistruct mpt3sas_debugfs_buffer {
14918c2ecf20Sopenharmony_ci	void	*buf;
14928c2ecf20Sopenharmony_ci	u32	len;
14938c2ecf20Sopenharmony_ci};
14948c2ecf20Sopenharmony_ci
14958c2ecf20Sopenharmony_ci#define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_citypedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
14988c2ecf20Sopenharmony_ci	u32 reply);
14998c2ecf20Sopenharmony_ci
15008c2ecf20Sopenharmony_ci
15018c2ecf20Sopenharmony_ci/* base shared API */
15028c2ecf20Sopenharmony_ciextern struct list_head mpt3sas_ioc_list;
15038c2ecf20Sopenharmony_ciextern char    driver_name[MPT_NAME_LENGTH];
15048c2ecf20Sopenharmony_ci/* spinlock on list operations over IOCs
15058c2ecf20Sopenharmony_ci * Case: when multiple warpdrive cards(IOCs) are in use
15068c2ecf20Sopenharmony_ci * Each IOC will added to the ioc list structure on initialization.
15078c2ecf20Sopenharmony_ci * Watchdog threads run at regular intervals to check IOC for any
15088c2ecf20Sopenharmony_ci * fault conditions which will trigger the dead_ioc thread to
15098c2ecf20Sopenharmony_ci * deallocate pci resource, resulting deleting the IOC netry from list,
15108c2ecf20Sopenharmony_ci * this deletion need to protected by spinlock to enusre that
15118c2ecf20Sopenharmony_ci * ioc removal is syncrhonized, if not synchronized it might lead to
15128c2ecf20Sopenharmony_ci * list_del corruption as the ioc list is traversed in cli path.
15138c2ecf20Sopenharmony_ci */
15148c2ecf20Sopenharmony_ciextern spinlock_t gioc_lock;
15158c2ecf20Sopenharmony_ci
15168c2ecf20Sopenharmony_civoid mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc);
15178c2ecf20Sopenharmony_civoid mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc);
15188c2ecf20Sopenharmony_ci
15198c2ecf20Sopenharmony_ciint mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc);
15208c2ecf20Sopenharmony_civoid mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc);
15218c2ecf20Sopenharmony_ciint mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
15228c2ecf20Sopenharmony_civoid mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc);
15238c2ecf20Sopenharmony_civoid mpt3sas_free_enclosure_list(struct MPT3SAS_ADAPTER *ioc);
15248c2ecf20Sopenharmony_ciint mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
15258c2ecf20Sopenharmony_ci	enum reset_type type);
15268c2ecf20Sopenharmony_ci
15278c2ecf20Sopenharmony_civoid *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15288c2ecf20Sopenharmony_civoid *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15298c2ecf20Sopenharmony_ci__le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
15308c2ecf20Sopenharmony_ci	u16 smid);
15318c2ecf20Sopenharmony_civoid *mpt3sas_base_get_pcie_sgl(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15328c2ecf20Sopenharmony_cidma_addr_t mpt3sas_base_get_pcie_sgl_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15338c2ecf20Sopenharmony_civoid mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc, u8 poll);
15348c2ecf20Sopenharmony_civoid mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc);
15358c2ecf20Sopenharmony_civoid mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc);
15368c2ecf20Sopenharmony_ci
15378c2ecf20Sopenharmony_civoid mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
15388c2ecf20Sopenharmony_ci	u16 handle);
15398c2ecf20Sopenharmony_civoid mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
15408c2ecf20Sopenharmony_ci	u16 msix_task);
15418c2ecf20Sopenharmony_civoid mpt3sas_base_put_smid_nvme_encap(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15428c2ecf20Sopenharmony_civoid mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15438c2ecf20Sopenharmony_ci/* hi-priority queue */
15448c2ecf20Sopenharmony_ciu16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
15458c2ecf20Sopenharmony_ciu16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
15468c2ecf20Sopenharmony_ci		struct scsi_cmnd *scmd);
15478c2ecf20Sopenharmony_civoid mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
15488c2ecf20Sopenharmony_ci		struct scsiio_tracker *st);
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ciu16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
15518c2ecf20Sopenharmony_civoid mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid);
15528c2ecf20Sopenharmony_civoid mpt3sas_base_initialize_callback_handler(void);
15538c2ecf20Sopenharmony_ciu8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func);
15548c2ecf20Sopenharmony_civoid mpt3sas_base_release_callback_handler(u8 cb_idx);
15558c2ecf20Sopenharmony_ci
15568c2ecf20Sopenharmony_ciu8 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
15578c2ecf20Sopenharmony_ci	u32 reply);
15588c2ecf20Sopenharmony_ciu8 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid,
15598c2ecf20Sopenharmony_ci	u8 msix_index, u32 reply);
15608c2ecf20Sopenharmony_civoid *mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc,
15618c2ecf20Sopenharmony_ci	u32 phys_addr);
15628c2ecf20Sopenharmony_ci
15638c2ecf20Sopenharmony_ciu32 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked);
15648c2ecf20Sopenharmony_ci
15658c2ecf20Sopenharmony_civoid mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code);
15668c2ecf20Sopenharmony_ci#define mpt3sas_print_fault_code(ioc, fault_code) \
15678c2ecf20Sopenharmony_cido { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
15688c2ecf20Sopenharmony_ci	mpt3sas_base_fault_info(ioc, fault_code); } while (0)
15698c2ecf20Sopenharmony_ci
15708c2ecf20Sopenharmony_civoid mpt3sas_base_coredump_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code);
15718c2ecf20Sopenharmony_ci#define mpt3sas_print_coredump_info(ioc, fault_code) \
15728c2ecf20Sopenharmony_cido { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
15738c2ecf20Sopenharmony_ci	mpt3sas_base_coredump_info(ioc, fault_code); } while (0)
15748c2ecf20Sopenharmony_ci
15758c2ecf20Sopenharmony_ciint mpt3sas_base_wait_for_coredump_completion(struct MPT3SAS_ADAPTER *ioc,
15768c2ecf20Sopenharmony_ci		const char *caller);
15778c2ecf20Sopenharmony_ciint mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc,
15788c2ecf20Sopenharmony_ci	Mpi2SasIoUnitControlReply_t *mpi_reply,
15798c2ecf20Sopenharmony_ci	Mpi2SasIoUnitControlRequest_t *mpi_request);
15808c2ecf20Sopenharmony_ciint mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc,
15818c2ecf20Sopenharmony_ci	Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
15828c2ecf20Sopenharmony_ci
15838c2ecf20Sopenharmony_civoid mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc,
15848c2ecf20Sopenharmony_ci	u32 *event_type);
15858c2ecf20Sopenharmony_ci
15868c2ecf20Sopenharmony_civoid mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc);
15878c2ecf20Sopenharmony_ci
15888c2ecf20Sopenharmony_civoid mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
15898c2ecf20Sopenharmony_ci	u16 device_missing_delay, u8 io_missing_delay);
15908c2ecf20Sopenharmony_ci
15918c2ecf20Sopenharmony_ciint mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
15928c2ecf20Sopenharmony_ci
15938c2ecf20Sopenharmony_civoid
15948c2ecf20Sopenharmony_cimpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc);
15958c2ecf20Sopenharmony_ci
15968c2ecf20Sopenharmony_ciu8 mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc,
15978c2ecf20Sopenharmony_ci	u8 status, void *mpi_request, int sz);
15988c2ecf20Sopenharmony_ci#define mpt3sas_check_cmd_timeout(ioc, status, mpi_request, sz, issue_reset) \
15998c2ecf20Sopenharmony_cido {	ioc_err(ioc, "In func: %s\n", __func__); \
16008c2ecf20Sopenharmony_ci	issue_reset = mpt3sas_base_check_cmd_timeout(ioc, \
16018c2ecf20Sopenharmony_ci	status, mpi_request, sz); } while (0)
16028c2ecf20Sopenharmony_ci
16038c2ecf20Sopenharmony_ciint mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int wait_count);
16048c2ecf20Sopenharmony_ci
16058c2ecf20Sopenharmony_ci/* scsih shared API */
16068c2ecf20Sopenharmony_cistruct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
16078c2ecf20Sopenharmony_ci	u16 smid);
16088c2ecf20Sopenharmony_ciu8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
16098c2ecf20Sopenharmony_ci	u32 reply);
16108c2ecf20Sopenharmony_civoid mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
16118c2ecf20Sopenharmony_civoid mpt3sas_scsih_clear_outstanding_scsi_tm_commands(
16128c2ecf20Sopenharmony_ci	struct MPT3SAS_ADAPTER *ioc);
16138c2ecf20Sopenharmony_civoid mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
16148c2ecf20Sopenharmony_ci
16158c2ecf20Sopenharmony_ciint mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
16168c2ecf20Sopenharmony_ci	uint channel, uint id, u64 lun, u8 type, u16 smid_task,
16178c2ecf20Sopenharmony_ci	u16 msix_task, u8 timeout, u8 tr_method);
16188c2ecf20Sopenharmony_ciint mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
16198c2ecf20Sopenharmony_ci	uint channel, uint id, u64 lun, u8 type, u16 smid_task,
16208c2ecf20Sopenharmony_ci	u16 msix_task, u8 timeout, u8 tr_method);
16218c2ecf20Sopenharmony_ci
16228c2ecf20Sopenharmony_civoid mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
16238c2ecf20Sopenharmony_civoid mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
16248c2ecf20Sopenharmony_civoid mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
16258c2ecf20Sopenharmony_civoid mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
16268c2ecf20Sopenharmony_ci	u64 sas_address);
16278c2ecf20Sopenharmony_ciu8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
16288c2ecf20Sopenharmony_ci	u16 smid);
16298c2ecf20Sopenharmony_ci
16308c2ecf20Sopenharmony_cistruct _sas_node *mpt3sas_scsih_expander_find_by_handle(
16318c2ecf20Sopenharmony_ci	struct MPT3SAS_ADAPTER *ioc, u16 handle);
16328c2ecf20Sopenharmony_cistruct _sas_node *mpt3sas_scsih_expander_find_by_sas_address(
16338c2ecf20Sopenharmony_ci	struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
16348c2ecf20Sopenharmony_cistruct _sas_device *mpt3sas_get_sdev_by_addr(
16358c2ecf20Sopenharmony_ci	 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
16368c2ecf20Sopenharmony_cistruct _sas_device *__mpt3sas_get_sdev_by_addr(
16378c2ecf20Sopenharmony_ci	 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
16388c2ecf20Sopenharmony_cistruct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
16398c2ecf20Sopenharmony_ci	u16 handle);
16408c2ecf20Sopenharmony_cistruct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
16418c2ecf20Sopenharmony_ci	u16 handle);
16428c2ecf20Sopenharmony_ci
16438c2ecf20Sopenharmony_civoid mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
16448c2ecf20Sopenharmony_cistruct _raid_device *
16458c2ecf20Sopenharmony_cimpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
16468c2ecf20Sopenharmony_civoid mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
16478c2ecf20Sopenharmony_ci
16488c2ecf20Sopenharmony_ci/* config shared API */
16498c2ecf20Sopenharmony_ciu8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
16508c2ecf20Sopenharmony_ci	u32 reply);
16518c2ecf20Sopenharmony_ciint mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER *ioc,
16528c2ecf20Sopenharmony_ci	u8 *num_phys);
16538c2ecf20Sopenharmony_ciint mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER *ioc,
16548c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
16558c2ecf20Sopenharmony_ciint mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER *ioc,
16568c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage7_t *config_page,
16578c2ecf20Sopenharmony_ci	u16 sz);
16588c2ecf20Sopenharmony_ciint mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER *ioc,
16598c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply,
16608c2ecf20Sopenharmony_ci	struct Mpi2ManufacturingPage10_t *config_page);
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_ciint mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
16638c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply,
16648c2ecf20Sopenharmony_ci	struct Mpi2ManufacturingPage11_t  *config_page);
16658c2ecf20Sopenharmony_ciint mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
16668c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply,
16678c2ecf20Sopenharmony_ci	struct Mpi2ManufacturingPage11_t *config_page);
16688c2ecf20Sopenharmony_ci
16698c2ecf20Sopenharmony_ciint mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16708c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2BiosPage2_t *config_page);
16718c2ecf20Sopenharmony_ciint mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16728c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2BiosPage3_t *config_page);
16738c2ecf20Sopenharmony_ciint mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16748c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOUnitPage0_t *config_page);
16758c2ecf20Sopenharmony_ciint mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc,
16768c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage0_t *config_page,
16778c2ecf20Sopenharmony_ci	u32 form, u32 handle);
16788c2ecf20Sopenharmony_ciint mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc,
16798c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page,
16808c2ecf20Sopenharmony_ci	u32 form, u32 handle);
16818c2ecf20Sopenharmony_ciint mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc,
16828c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page,
16838c2ecf20Sopenharmony_ci	u32 form, u32 handle);
16848c2ecf20Sopenharmony_ciint mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc,
16858c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page,
16868c2ecf20Sopenharmony_ci	u32 form, u32 handle);
16878c2ecf20Sopenharmony_ciint mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc,
16888c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page,
16898c2ecf20Sopenharmony_ci	u16 sz);
16908c2ecf20Sopenharmony_ciint mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16918c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOUnitPage1_t *config_page);
16928c2ecf20Sopenharmony_ciint mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER *ioc,
16938c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
16948c2ecf20Sopenharmony_ciint mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16958c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOUnitPage1_t *config_page);
16968c2ecf20Sopenharmony_ciint mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
16978c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOUnitPage8_t *config_page);
16988c2ecf20Sopenharmony_ciint mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
16998c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
17008c2ecf20Sopenharmony_ci	u16 sz);
17018c2ecf20Sopenharmony_ciint mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
17028c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
17038c2ecf20Sopenharmony_ci	u16 sz);
17048c2ecf20Sopenharmony_ciint mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17058c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOCPage1_t *config_page);
17068c2ecf20Sopenharmony_ciint mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17078c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOCPage1_t *config_page);
17088c2ecf20Sopenharmony_ciint mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17098c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2IOCPage8_t *config_page);
17108c2ecf20Sopenharmony_ciint mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER *ioc,
17118c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage0_t *config_page,
17128c2ecf20Sopenharmony_ci	u32 form, u32 handle);
17138c2ecf20Sopenharmony_ciint mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER *ioc,
17148c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage1_t *config_page,
17158c2ecf20Sopenharmony_ci	u32 phy_number, u16 handle);
17168c2ecf20Sopenharmony_ciint mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER *ioc,
17178c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2SasEnclosurePage0_t *config_page,
17188c2ecf20Sopenharmony_ci	u32 form, u32 handle);
17198c2ecf20Sopenharmony_ciint mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17208c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
17218c2ecf20Sopenharmony_ciint mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
17228c2ecf20Sopenharmony_ci	*mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
17238c2ecf20Sopenharmony_ciint mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER *ioc,
17248c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
17258c2ecf20Sopenharmony_ci	u32 handle);
17268c2ecf20Sopenharmony_ciint mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER *ioc, u16 handle,
17278c2ecf20Sopenharmony_ci	u8 *num_pds);
17288c2ecf20Sopenharmony_ciint mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER *ioc,
17298c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
17308c2ecf20Sopenharmony_ci	u32 handle, u16 sz);
17318c2ecf20Sopenharmony_ciint mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER *ioc,
17328c2ecf20Sopenharmony_ci	Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
17338c2ecf20Sopenharmony_ci	u32 form, u32 form_specific);
17348c2ecf20Sopenharmony_ciint mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER *ioc, u16 pd_handle,
17358c2ecf20Sopenharmony_ci	u16 *volume_handle);
17368c2ecf20Sopenharmony_ciint mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER *ioc,
17378c2ecf20Sopenharmony_ci	u16 volume_handle, u64 *wwid);
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_ci/* ctl shared API */
17408c2ecf20Sopenharmony_ciextern struct device_attribute *mpt3sas_host_attrs[];
17418c2ecf20Sopenharmony_ciextern struct device_attribute *mpt3sas_dev_attrs[];
17428c2ecf20Sopenharmony_civoid mpt3sas_ctl_init(ushort hbas_to_enumerate);
17438c2ecf20Sopenharmony_civoid mpt3sas_ctl_exit(ushort hbas_to_enumerate);
17448c2ecf20Sopenharmony_ciu8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
17458c2ecf20Sopenharmony_ci	u32 reply);
17468c2ecf20Sopenharmony_civoid mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
17478c2ecf20Sopenharmony_civoid mpt3sas_ctl_clear_outstanding_ioctls(struct MPT3SAS_ADAPTER *ioc);
17488c2ecf20Sopenharmony_civoid mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
17498c2ecf20Sopenharmony_ciu8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
17508c2ecf20Sopenharmony_ci	u8 msix_index, u32 reply);
17518c2ecf20Sopenharmony_civoid mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
17528c2ecf20Sopenharmony_ci	Mpi2EventNotificationReply_t *mpi_reply);
17538c2ecf20Sopenharmony_ci
17548c2ecf20Sopenharmony_civoid mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc,
17558c2ecf20Sopenharmony_ci	u8 bits_to_register);
17568c2ecf20Sopenharmony_ciint mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
17578c2ecf20Sopenharmony_ci	u8 *issue_reset);
17588c2ecf20Sopenharmony_ci
17598c2ecf20Sopenharmony_ci/* transport shared API */
17608c2ecf20Sopenharmony_ciextern struct scsi_transport_template *mpt3sas_transport_template;
17618c2ecf20Sopenharmony_ciu8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
17628c2ecf20Sopenharmony_ci	u32 reply);
17638c2ecf20Sopenharmony_cistruct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
17648c2ecf20Sopenharmony_ci	u16 handle, u64 sas_address);
17658c2ecf20Sopenharmony_civoid mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
17668c2ecf20Sopenharmony_ci	u64 sas_address_parent);
17678c2ecf20Sopenharmony_ciint mpt3sas_transport_add_host_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_phy
17688c2ecf20Sopenharmony_ci	*mpt3sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
17698c2ecf20Sopenharmony_ciint mpt3sas_transport_add_expander_phy(struct MPT3SAS_ADAPTER *ioc,
17708c2ecf20Sopenharmony_ci	struct _sas_phy *mpt3sas_phy, Mpi2ExpanderPage1_t expander_pg1,
17718c2ecf20Sopenharmony_ci	struct device *parent_dev);
17728c2ecf20Sopenharmony_civoid mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
17738c2ecf20Sopenharmony_ci	u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
17748c2ecf20Sopenharmony_ciextern struct sas_function_template mpt3sas_transport_functions;
17758c2ecf20Sopenharmony_ciextern struct scsi_transport_template *mpt3sas_transport_template;
17768c2ecf20Sopenharmony_ci/* trigger data externs */
17778c2ecf20Sopenharmony_civoid mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
17788c2ecf20Sopenharmony_ci	struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
17798c2ecf20Sopenharmony_civoid mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
17808c2ecf20Sopenharmony_ci	struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
17818c2ecf20Sopenharmony_civoid mpt3sas_trigger_master(struct MPT3SAS_ADAPTER *ioc,
17828c2ecf20Sopenharmony_ci	u32 trigger_bitmask);
17838c2ecf20Sopenharmony_civoid mpt3sas_trigger_event(struct MPT3SAS_ADAPTER *ioc, u16 event,
17848c2ecf20Sopenharmony_ci	u16 log_entry_qualifier);
17858c2ecf20Sopenharmony_civoid mpt3sas_trigger_scsi(struct MPT3SAS_ADAPTER *ioc, u8 sense_key,
17868c2ecf20Sopenharmony_ci	u8 asc, u8 ascq);
17878c2ecf20Sopenharmony_civoid mpt3sas_trigger_mpi(struct MPT3SAS_ADAPTER *ioc, u16 ioc_status,
17888c2ecf20Sopenharmony_ci	u32 loginfo);
17898c2ecf20Sopenharmony_ci
17908c2ecf20Sopenharmony_ci/* warpdrive APIs */
17918c2ecf20Sopenharmony_ciu8 mpt3sas_get_num_volumes(struct MPT3SAS_ADAPTER *ioc);
17928c2ecf20Sopenharmony_civoid mpt3sas_init_warpdrive_properties(struct MPT3SAS_ADAPTER *ioc,
17938c2ecf20Sopenharmony_ci	struct _raid_device *raid_device);
17948c2ecf20Sopenharmony_civoid
17958c2ecf20Sopenharmony_cimpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
17968c2ecf20Sopenharmony_ci	struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request);
17978c2ecf20Sopenharmony_ci
17988c2ecf20Sopenharmony_ci/* NCQ Prio Handling Check */
17998c2ecf20Sopenharmony_cibool scsih_ncq_prio_supp(struct scsi_device *sdev);
18008c2ecf20Sopenharmony_ci
18018c2ecf20Sopenharmony_civoid mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc);
18028c2ecf20Sopenharmony_civoid mpt3sas_destroy_debugfs(struct MPT3SAS_ADAPTER *ioc);
18038c2ecf20Sopenharmony_civoid mpt3sas_init_debugfs(void);
18048c2ecf20Sopenharmony_civoid mpt3sas_exit_debugfs(void);
18058c2ecf20Sopenharmony_ci
18068c2ecf20Sopenharmony_ci/**
18078c2ecf20Sopenharmony_ci * _scsih_is_pcie_scsi_device - determines if device is an pcie scsi device
18088c2ecf20Sopenharmony_ci * @device_info: bitfield providing information about the device.
18098c2ecf20Sopenharmony_ci * Context: none
18108c2ecf20Sopenharmony_ci *
18118c2ecf20Sopenharmony_ci * Returns 1 if scsi device.
18128c2ecf20Sopenharmony_ci */
18138c2ecf20Sopenharmony_cistatic inline int
18148c2ecf20Sopenharmony_cimpt3sas_scsih_is_pcie_scsi_device(u32 device_info)
18158c2ecf20Sopenharmony_ci{
18168c2ecf20Sopenharmony_ci	if ((device_info &
18178c2ecf20Sopenharmony_ci	    MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI)
18188c2ecf20Sopenharmony_ci		return 1;
18198c2ecf20Sopenharmony_ci	else
18208c2ecf20Sopenharmony_ci		return 0;
18218c2ecf20Sopenharmony_ci}
18228c2ecf20Sopenharmony_ci#endif /* MPT3SAS_BASE_H_INCLUDED */
1823