18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *	Adaptec AAC series RAID controller driver
48c2ecf20Sopenharmony_ci *	(c) Copyright 2001 Red Hat Inc.	<alan@redhat.com>
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * based on the old aacraid driver that is..
78c2ecf20Sopenharmony_ci * Adaptec aacraid device driver for Linux.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (c) 2000-2010 Adaptec, Inc.
108c2ecf20Sopenharmony_ci *               2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
118c2ecf20Sopenharmony_ci *		 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * Module Name:
148c2ecf20Sopenharmony_ci *  aacraid.h
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * Abstract: Contains all routines for control of the aacraid driver
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifndef _AACRAID_H_
208c2ecf20Sopenharmony_ci#define _AACRAID_H_
218c2ecf20Sopenharmony_ci#ifndef dprintk
228c2ecf20Sopenharmony_ci# define dprintk(x)
238c2ecf20Sopenharmony_ci#endif
248c2ecf20Sopenharmony_ci/* eg: if (nblank(dprintk(x))) */
258c2ecf20Sopenharmony_ci#define _nblank(x) #x
268c2ecf20Sopenharmony_ci#define nblank(x) _nblank(x)[0]
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
298c2ecf20Sopenharmony_ci#include <linux/completion.h>
308c2ecf20Sopenharmony_ci#include <linux/pci.h>
318c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*------------------------------------------------------------------------------
348c2ecf20Sopenharmony_ci *              D E F I N E S
358c2ecf20Sopenharmony_ci *----------------------------------------------------------------------------*/
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define AAC_MAX_MSIX		32	/* vectors */
388c2ecf20Sopenharmony_ci#define AAC_PCI_MSI_ENABLE	0x8000
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cienum {
418c2ecf20Sopenharmony_ci	AAC_ENABLE_INTERRUPT	= 0x0,
428c2ecf20Sopenharmony_ci	AAC_DISABLE_INTERRUPT,
438c2ecf20Sopenharmony_ci	AAC_ENABLE_MSIX,
448c2ecf20Sopenharmony_ci	AAC_DISABLE_MSIX,
458c2ecf20Sopenharmony_ci	AAC_CLEAR_AIF_BIT,
468c2ecf20Sopenharmony_ci	AAC_CLEAR_SYNC_BIT,
478c2ecf20Sopenharmony_ci	AAC_ENABLE_INTX
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define AAC_INT_MODE_INTX		(1<<0)
518c2ecf20Sopenharmony_ci#define AAC_INT_MODE_MSI		(1<<1)
528c2ecf20Sopenharmony_ci#define AAC_INT_MODE_AIF		(1<<2)
538c2ecf20Sopenharmony_ci#define AAC_INT_MODE_SYNC		(1<<3)
548c2ecf20Sopenharmony_ci#define AAC_INT_MODE_MSIX		(1<<16)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define AAC_INT_ENABLE_TYPE1_INTX	0xfffffffb
578c2ecf20Sopenharmony_ci#define AAC_INT_ENABLE_TYPE1_MSIX	0xfffffffa
588c2ecf20Sopenharmony_ci#define AAC_INT_DISABLE_ALL		0xffffffff
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Bit definitions in IOA->Host Interrupt Register */
618c2ecf20Sopenharmony_ci#define PMC_TRANSITION_TO_OPERATIONAL	(1<<31)
628c2ecf20Sopenharmony_ci#define PMC_IOARCB_TRANSFER_FAILED	(1<<28)
638c2ecf20Sopenharmony_ci#define PMC_IOA_UNIT_CHECK		(1<<27)
648c2ecf20Sopenharmony_ci#define PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE (1<<26)
658c2ecf20Sopenharmony_ci#define PMC_CRITICAL_IOA_OP_IN_PROGRESS	(1<<25)
668c2ecf20Sopenharmony_ci#define PMC_IOARRIN_LOST		(1<<4)
678c2ecf20Sopenharmony_ci#define PMC_SYSTEM_BUS_MMIO_ERROR	(1<<3)
688c2ecf20Sopenharmony_ci#define PMC_IOA_PROCESSOR_IN_ERROR_STATE (1<<2)
698c2ecf20Sopenharmony_ci#define PMC_HOST_RRQ_VALID		(1<<1)
708c2ecf20Sopenharmony_ci#define PMC_OPERATIONAL_STATUS		(1<<31)
718c2ecf20Sopenharmony_ci#define PMC_ALLOW_MSIX_VECTOR0		(1<<0)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define PMC_IOA_ERROR_INTERRUPTS	(PMC_IOARCB_TRANSFER_FAILED | \
748c2ecf20Sopenharmony_ci					 PMC_IOA_UNIT_CHECK | \
758c2ecf20Sopenharmony_ci					 PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE | \
768c2ecf20Sopenharmony_ci					 PMC_IOARRIN_LOST | \
778c2ecf20Sopenharmony_ci					 PMC_SYSTEM_BUS_MMIO_ERROR | \
788c2ecf20Sopenharmony_ci					 PMC_IOA_PROCESSOR_IN_ERROR_STATE)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define PMC_ALL_INTERRUPT_BITS		(PMC_IOA_ERROR_INTERRUPTS | \
818c2ecf20Sopenharmony_ci					 PMC_HOST_RRQ_VALID | \
828c2ecf20Sopenharmony_ci					 PMC_TRANSITION_TO_OPERATIONAL | \
838c2ecf20Sopenharmony_ci					 PMC_ALLOW_MSIX_VECTOR0)
848c2ecf20Sopenharmony_ci#define	PMC_GLOBAL_INT_BIT2		0x00000004
858c2ecf20Sopenharmony_ci#define	PMC_GLOBAL_INT_BIT0		0x00000001
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#ifndef AAC_DRIVER_BUILD
888c2ecf20Sopenharmony_ci# define AAC_DRIVER_BUILD 50983
898c2ecf20Sopenharmony_ci# define AAC_DRIVER_BRANCH "-custom"
908c2ecf20Sopenharmony_ci#endif
918c2ecf20Sopenharmony_ci#define MAXIMUM_NUM_CONTAINERS	32
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define AAC_NUM_MGT_FIB         8
948c2ecf20Sopenharmony_ci#define AAC_NUM_IO_FIB		(1024 - AAC_NUM_MGT_FIB)
958c2ecf20Sopenharmony_ci#define AAC_NUM_FIB		(AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define AAC_MAX_LUN		256
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
1008c2ecf20Sopenharmony_ci#define AAC_MAX_32BIT_SGBCOUNT	((unsigned short)256)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define AAC_DEBUG_INSTRUMENT_AIF_DELETE
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define AAC_MAX_NATIVE_TARGETS		1024
1058c2ecf20Sopenharmony_ci/* Thor: 5 phys. buses: #0: empty, 1-4: 256 targets each */
1068c2ecf20Sopenharmony_ci#define AAC_MAX_BUSES			5
1078c2ecf20Sopenharmony_ci#define AAC_MAX_TARGETS		256
1088c2ecf20Sopenharmony_ci#define AAC_BUS_TARGET_LOOP		(AAC_MAX_BUSES * AAC_MAX_TARGETS)
1098c2ecf20Sopenharmony_ci#define AAC_MAX_NATIVE_SIZE		2048
1108c2ecf20Sopenharmony_ci#define FW_ERROR_BUFFER_SIZE		512
1118c2ecf20Sopenharmony_ci#define AAC_SA_TIMEOUT			180
1128c2ecf20Sopenharmony_ci#define AAC_ARC_TIMEOUT			60
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define get_bus_number(x)	(x/AAC_MAX_TARGETS)
1158c2ecf20Sopenharmony_ci#define get_target_number(x)	(x%AAC_MAX_TARGETS)
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/* Thor AIF events */
1188c2ecf20Sopenharmony_ci#define SA_AIF_HOTPLUG			(1<<1)
1198c2ecf20Sopenharmony_ci#define SA_AIF_HARDWARE		(1<<2)
1208c2ecf20Sopenharmony_ci#define SA_AIF_PDEV_CHANGE		(1<<4)
1218c2ecf20Sopenharmony_ci#define SA_AIF_LDEV_CHANGE		(1<<5)
1228c2ecf20Sopenharmony_ci#define SA_AIF_BPSTAT_CHANGE		(1<<30)
1238c2ecf20Sopenharmony_ci#define SA_AIF_BPCFG_CHANGE		(1<<31)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define HBA_MAX_SG_EMBEDDED		28
1268c2ecf20Sopenharmony_ci#define HBA_MAX_SG_SEPARATE		90
1278c2ecf20Sopenharmony_ci#define HBA_SENSE_DATA_LEN_MAX		32
1288c2ecf20Sopenharmony_ci#define HBA_REQUEST_TAG_ERROR_FLAG	0x00000002
1298c2ecf20Sopenharmony_ci#define HBA_SGL_FLAGS_EXT		0x80000000UL
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistruct aac_hba_sgl {
1328c2ecf20Sopenharmony_ci	u32		addr_lo; /* Lower 32-bits of SGL element address */
1338c2ecf20Sopenharmony_ci	u32		addr_hi; /* Upper 32-bits of SGL element address */
1348c2ecf20Sopenharmony_ci	u32		len;	/* Length of SGL element in bytes */
1358c2ecf20Sopenharmony_ci	u32		flags;	/* SGL element flags */
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cienum {
1398c2ecf20Sopenharmony_ci	HBA_IU_TYPE_SCSI_CMD_REQ		= 0x40,
1408c2ecf20Sopenharmony_ci	HBA_IU_TYPE_SCSI_TM_REQ			= 0x41,
1418c2ecf20Sopenharmony_ci	HBA_IU_TYPE_SATA_REQ			= 0x42,
1428c2ecf20Sopenharmony_ci	HBA_IU_TYPE_RESP			= 0x60,
1438c2ecf20Sopenharmony_ci	HBA_IU_TYPE_COALESCED_RESP		= 0x61,
1448c2ecf20Sopenharmony_ci	HBA_IU_TYPE_INT_COALESCING_CFG_REQ	= 0x70
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cienum {
1488c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_DATA_DIR_IN		= 0x1,
1498c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_DATA_DIR_OUT		= 0x2,
1508c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_DATA_TYPE_DDR		= 0x4,
1518c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_CRYPTO_ENABLE		= 0x8
1528c2ecf20Sopenharmony_ci};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cienum {
1558c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_BITOFF_DATA_DIR_IN	= 0x0,
1568c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_BITOFF_DATA_DIR_OUT,
1578c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_BITOFF_DATA_TYPE_DDR,
1588c2ecf20Sopenharmony_ci	HBA_CMD_BYTE1_BITOFF_CRYPTO_ENABLE
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cienum {
1628c2ecf20Sopenharmony_ci	HBA_RESP_DATAPRES_NO_DATA		= 0x0,
1638c2ecf20Sopenharmony_ci	HBA_RESP_DATAPRES_RESPONSE_DATA,
1648c2ecf20Sopenharmony_ci	HBA_RESP_DATAPRES_SENSE_DATA
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cienum {
1688c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_TASK_COMPLETE		= 0x0,
1698c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_FAILURE,
1708c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_TMF_COMPLETE,
1718c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_TMF_SUCCEEDED,
1728c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_TMF_REJECTED,
1738c2ecf20Sopenharmony_ci	HBA_RESP_SVCRES_TMF_LUN_INVALID
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_cienum {
1778c2ecf20Sopenharmony_ci	HBA_RESP_STAT_IO_ERROR			= 0x1,
1788c2ecf20Sopenharmony_ci	HBA_RESP_STAT_IO_ABORTED,
1798c2ecf20Sopenharmony_ci	HBA_RESP_STAT_NO_PATH_TO_DEVICE,
1808c2ecf20Sopenharmony_ci	HBA_RESP_STAT_INVALID_DEVICE,
1818c2ecf20Sopenharmony_ci	HBA_RESP_STAT_HBAMODE_DISABLED		= 0xE,
1828c2ecf20Sopenharmony_ci	HBA_RESP_STAT_UNDERRUN			= 0x51,
1838c2ecf20Sopenharmony_ci	HBA_RESP_STAT_OVERRUN			= 0x75
1848c2ecf20Sopenharmony_ci};
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistruct aac_hba_cmd_req {
1878c2ecf20Sopenharmony_ci	u8	iu_type;	/* HBA information unit type */
1888c2ecf20Sopenharmony_ci	/*
1898c2ecf20Sopenharmony_ci	 * byte1:
1908c2ecf20Sopenharmony_ci	 * [1:0] DIR - 0=No data, 0x1 = IN, 0x2 = OUT
1918c2ecf20Sopenharmony_ci	 * [2]   TYPE - 0=PCI, 1=DDR
1928c2ecf20Sopenharmony_ci	 * [3]   CRYPTO_ENABLE - 0=Crypto disabled, 1=Crypto enabled
1938c2ecf20Sopenharmony_ci	 */
1948c2ecf20Sopenharmony_ci	u8	byte1;
1958c2ecf20Sopenharmony_ci	u8	reply_qid;	/* Host reply queue to post response to */
1968c2ecf20Sopenharmony_ci	u8	reserved1;
1978c2ecf20Sopenharmony_ci	__le32	it_nexus;	/* Device handle for the request */
1988c2ecf20Sopenharmony_ci	__le32	request_id;	/* Sender context */
1998c2ecf20Sopenharmony_ci	/* Lower 32-bits of tweak value for crypto enabled IOs */
2008c2ecf20Sopenharmony_ci	__le32	tweak_value_lo;
2018c2ecf20Sopenharmony_ci	u8	cdb[16];	/* SCSI CDB of the command */
2028c2ecf20Sopenharmony_ci	u8	lun[8];		/* SCSI LUN of the command */
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	/* Total data length in bytes to be read/written (if any) */
2058c2ecf20Sopenharmony_ci	__le32	data_length;
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	/* [2:0] Task Attribute, [6:3] Command Priority */
2088c2ecf20Sopenharmony_ci	u8	attr_prio;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	/* Number of SGL elements embedded in the HBA req */
2118c2ecf20Sopenharmony_ci	u8	emb_data_desc_count;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	__le16	dek_index;	/* DEK index for crypto enabled IOs */
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	/* Lower 32-bits of reserved error data target location on the host */
2168c2ecf20Sopenharmony_ci	__le32	error_ptr_lo;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci	/* Upper 32-bits of reserved error data target location on the host */
2198c2ecf20Sopenharmony_ci	__le32	error_ptr_hi;
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	/* Length of reserved error data area on the host in bytes */
2228c2ecf20Sopenharmony_ci	__le32	error_length;
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	/* Upper 32-bits of tweak value for crypto enabled IOs */
2258c2ecf20Sopenharmony_ci	__le32	tweak_value_hi;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	struct aac_hba_sgl sge[HBA_MAX_SG_SEPARATE+2]; /* SG list space */
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	/*
2308c2ecf20Sopenharmony_ci	 * structure must not exceed
2318c2ecf20Sopenharmony_ci	 * AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE
2328c2ecf20Sopenharmony_ci	 */
2338c2ecf20Sopenharmony_ci};
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci/* Task Management Functions (TMF) */
2368c2ecf20Sopenharmony_ci#define HBA_TMF_ABORT_TASK	0x01
2378c2ecf20Sopenharmony_ci#define HBA_TMF_LUN_RESET	0x08
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistruct aac_hba_tm_req {
2408c2ecf20Sopenharmony_ci	u8	iu_type;	/* HBA information unit type */
2418c2ecf20Sopenharmony_ci	u8	reply_qid;	/* Host reply queue to post response to */
2428c2ecf20Sopenharmony_ci	u8	tmf;		/* Task management function */
2438c2ecf20Sopenharmony_ci	u8	reserved1;
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci	__le32	it_nexus;	/* Device handle for the command */
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	u8	lun[8];		/* SCSI LUN */
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	/* Used to hold sender context. */
2508c2ecf20Sopenharmony_ci	__le32	request_id;	/* Sender context */
2518c2ecf20Sopenharmony_ci	__le32	reserved2;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	/* Request identifier of managed task */
2548c2ecf20Sopenharmony_ci	__le32	managed_request_id;	/* Sender context being managed */
2558c2ecf20Sopenharmony_ci	__le32	reserved3;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	/* Lower 32-bits of reserved error data target location on the host */
2588c2ecf20Sopenharmony_ci	__le32	error_ptr_lo;
2598c2ecf20Sopenharmony_ci	/* Upper 32-bits of reserved error data target location on the host */
2608c2ecf20Sopenharmony_ci	__le32	error_ptr_hi;
2618c2ecf20Sopenharmony_ci	/* Length of reserved error data area on the host in bytes */
2628c2ecf20Sopenharmony_ci	__le32	error_length;
2638c2ecf20Sopenharmony_ci};
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistruct aac_hba_reset_req {
2668c2ecf20Sopenharmony_ci	u8	iu_type;	/* HBA information unit type */
2678c2ecf20Sopenharmony_ci	/* 0 - reset specified device, 1 - reset all devices */
2688c2ecf20Sopenharmony_ci	u8	reset_type;
2698c2ecf20Sopenharmony_ci	u8	reply_qid;	/* Host reply queue to post response to */
2708c2ecf20Sopenharmony_ci	u8	reserved1;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	__le32	it_nexus;	/* Device handle for the command */
2738c2ecf20Sopenharmony_ci	__le32	request_id;	/* Sender context */
2748c2ecf20Sopenharmony_ci	/* Lower 32-bits of reserved error data target location on the host */
2758c2ecf20Sopenharmony_ci	__le32	error_ptr_lo;
2768c2ecf20Sopenharmony_ci	/* Upper 32-bits of reserved error data target location on the host */
2778c2ecf20Sopenharmony_ci	__le32	error_ptr_hi;
2788c2ecf20Sopenharmony_ci	/* Length of reserved error data area on the host in bytes */
2798c2ecf20Sopenharmony_ci	__le32	error_length;
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistruct aac_hba_resp {
2838c2ecf20Sopenharmony_ci	u8	iu_type;		/* HBA information unit type */
2848c2ecf20Sopenharmony_ci	u8	reserved1[3];
2858c2ecf20Sopenharmony_ci	__le32	request_identifier;	/* sender context */
2868c2ecf20Sopenharmony_ci	__le32	reserved2;
2878c2ecf20Sopenharmony_ci	u8	service_response;	/* SCSI service response */
2888c2ecf20Sopenharmony_ci	u8	status;			/* SCSI status */
2898c2ecf20Sopenharmony_ci	u8	datapres;	/* [1:0] - data present, [7:2] - reserved */
2908c2ecf20Sopenharmony_ci	u8	sense_response_data_len;	/* Sense/response data length */
2918c2ecf20Sopenharmony_ci	__le32	residual_count;		/* Residual data length in bytes */
2928c2ecf20Sopenharmony_ci	/* Sense/response data */
2938c2ecf20Sopenharmony_ci	u8	sense_response_buf[HBA_SENSE_DATA_LEN_MAX];
2948c2ecf20Sopenharmony_ci};
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_cistruct aac_native_hba {
2978c2ecf20Sopenharmony_ci	union {
2988c2ecf20Sopenharmony_ci		struct aac_hba_cmd_req cmd;
2998c2ecf20Sopenharmony_ci		struct aac_hba_tm_req tmr;
3008c2ecf20Sopenharmony_ci		u8 cmd_bytes[AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE];
3018c2ecf20Sopenharmony_ci	} cmd;
3028c2ecf20Sopenharmony_ci	union {
3038c2ecf20Sopenharmony_ci		struct aac_hba_resp err;
3048c2ecf20Sopenharmony_ci		u8 resp_bytes[FW_ERROR_BUFFER_SIZE];
3058c2ecf20Sopenharmony_ci	} resp;
3068c2ecf20Sopenharmony_ci};
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci#define CISS_REPORT_PHYSICAL_LUNS	0xc3
3098c2ecf20Sopenharmony_ci#define WRITE_HOST_WELLNESS		0xa5
3108c2ecf20Sopenharmony_ci#define CISS_IDENTIFY_PHYSICAL_DEVICE	0x15
3118c2ecf20Sopenharmony_ci#define BMIC_IN			0x26
3128c2ecf20Sopenharmony_ci#define BMIC_OUT			0x27
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistruct aac_ciss_phys_luns_resp {
3158c2ecf20Sopenharmony_ci	u8	list_length[4];		/* LUN list length (N-7, big endian) */
3168c2ecf20Sopenharmony_ci	u8	resp_flag;		/* extended response_flag */
3178c2ecf20Sopenharmony_ci	u8	reserved[3];
3188c2ecf20Sopenharmony_ci	struct _ciss_lun {
3198c2ecf20Sopenharmony_ci		u8	tid[3];		/* Target ID */
3208c2ecf20Sopenharmony_ci		u8	bus;		/* Bus, flag (bits 6,7) */
3218c2ecf20Sopenharmony_ci		u8	level3[2];
3228c2ecf20Sopenharmony_ci		u8	level2[2];
3238c2ecf20Sopenharmony_ci		u8	node_ident[16];	/* phys. node identifier */
3248c2ecf20Sopenharmony_ci	} lun[1];			/* List of phys. devices */
3258c2ecf20Sopenharmony_ci};
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/*
3288c2ecf20Sopenharmony_ci * Interrupts
3298c2ecf20Sopenharmony_ci */
3308c2ecf20Sopenharmony_ci#define AAC_MAX_HRRQ		64
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistruct aac_ciss_identify_pd {
3338c2ecf20Sopenharmony_ci	u8 scsi_bus;			/* SCSI Bus number on controller */
3348c2ecf20Sopenharmony_ci	u8 scsi_id;			/* SCSI ID on this bus */
3358c2ecf20Sopenharmony_ci	u16 block_size;			/* sector size in bytes */
3368c2ecf20Sopenharmony_ci	u32 total_blocks;		/* number for sectors on drive */
3378c2ecf20Sopenharmony_ci	u32 reserved_blocks;		/* controller reserved (RIS) */
3388c2ecf20Sopenharmony_ci	u8 model[40];			/* Physical Drive Model */
3398c2ecf20Sopenharmony_ci	u8 serial_number[40];		/* Drive Serial Number */
3408c2ecf20Sopenharmony_ci	u8 firmware_revision[8];	/* drive firmware revision */
3418c2ecf20Sopenharmony_ci	u8 scsi_inquiry_bits;		/* inquiry byte 7 bits */
3428c2ecf20Sopenharmony_ci	u8 compaq_drive_stamp;		/* 0 means drive not stamped */
3438c2ecf20Sopenharmony_ci	u8 last_failure_reason;
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	u8  flags;
3468c2ecf20Sopenharmony_ci	u8  more_flags;
3478c2ecf20Sopenharmony_ci	u8  scsi_lun;			/* SCSI LUN for phys drive */
3488c2ecf20Sopenharmony_ci	u8  yet_more_flags;
3498c2ecf20Sopenharmony_ci	u8  even_more_flags;
3508c2ecf20Sopenharmony_ci	u32 spi_speed_rules;		/* SPI Speed :Ultra disable diagnose */
3518c2ecf20Sopenharmony_ci	u8  phys_connector[2];		/* connector number on controller */
3528c2ecf20Sopenharmony_ci	u8  phys_box_on_bus;		/* phys enclosure this drive resides */
3538c2ecf20Sopenharmony_ci	u8  phys_bay_in_box;		/* phys drv bay this drive resides */
3548c2ecf20Sopenharmony_ci	u32 rpm;			/* Drive rotational speed in rpm */
3558c2ecf20Sopenharmony_ci	u8  device_type;		/* type of drive */
3568c2ecf20Sopenharmony_ci	u8  sata_version;		/* only valid when drive_type is SATA */
3578c2ecf20Sopenharmony_ci	u64 big_total_block_count;
3588c2ecf20Sopenharmony_ci	u64 ris_starting_lba;
3598c2ecf20Sopenharmony_ci	u32 ris_size;
3608c2ecf20Sopenharmony_ci	u8  wwid[20];
3618c2ecf20Sopenharmony_ci	u8  controller_phy_map[32];
3628c2ecf20Sopenharmony_ci	u16 phy_count;
3638c2ecf20Sopenharmony_ci	u8  phy_connected_dev_type[256];
3648c2ecf20Sopenharmony_ci	u8  phy_to_drive_bay_num[256];
3658c2ecf20Sopenharmony_ci	u16 phy_to_attached_dev_index[256];
3668c2ecf20Sopenharmony_ci	u8  box_index;
3678c2ecf20Sopenharmony_ci	u8  spitfire_support;
3688c2ecf20Sopenharmony_ci	u16 extra_physical_drive_flags;
3698c2ecf20Sopenharmony_ci	u8  negotiated_link_rate[256];
3708c2ecf20Sopenharmony_ci	u8  phy_to_phy_map[256];
3718c2ecf20Sopenharmony_ci	u8  redundant_path_present_map;
3728c2ecf20Sopenharmony_ci	u8  redundant_path_failure_map;
3738c2ecf20Sopenharmony_ci	u8  active_path_number;
3748c2ecf20Sopenharmony_ci	u16 alternate_paths_phys_connector[8];
3758c2ecf20Sopenharmony_ci	u8  alternate_paths_phys_box_on_port[8];
3768c2ecf20Sopenharmony_ci	u8  multi_lun_device_lun_count;
3778c2ecf20Sopenharmony_ci	u8  minimum_good_fw_revision[8];
3788c2ecf20Sopenharmony_ci	u8  unique_inquiry_bytes[20];
3798c2ecf20Sopenharmony_ci	u8  current_temperature_degreesC;
3808c2ecf20Sopenharmony_ci	u8  temperature_threshold_degreesC;
3818c2ecf20Sopenharmony_ci	u8  max_temperature_degreesC;
3828c2ecf20Sopenharmony_ci	u8  logical_blocks_per_phys_block_exp;	/* phyblocksize = 512 * 2^exp */
3838c2ecf20Sopenharmony_ci	u16 current_queue_depth_limit;
3848c2ecf20Sopenharmony_ci	u8  switch_name[10];
3858c2ecf20Sopenharmony_ci	u16 switch_port;
3868c2ecf20Sopenharmony_ci	u8  alternate_paths_switch_name[40];
3878c2ecf20Sopenharmony_ci	u8  alternate_paths_switch_port[8];
3888c2ecf20Sopenharmony_ci	u16 power_on_hours;		/* valid only if gas gauge supported */
3898c2ecf20Sopenharmony_ci	u16 percent_endurance_used;	/* valid only if gas gauge supported. */
3908c2ecf20Sopenharmony_ci	u8  drive_authentication;
3918c2ecf20Sopenharmony_ci	u8  smart_carrier_authentication;
3928c2ecf20Sopenharmony_ci	u8  smart_carrier_app_fw_version;
3938c2ecf20Sopenharmony_ci	u8  smart_carrier_bootloader_fw_version;
3948c2ecf20Sopenharmony_ci	u8  SanitizeSecureEraseSupport;
3958c2ecf20Sopenharmony_ci	u8  DriveKeyFlags;
3968c2ecf20Sopenharmony_ci	u8  encryption_key_name[64];
3978c2ecf20Sopenharmony_ci	u32 misc_drive_flags;
3988c2ecf20Sopenharmony_ci	u16 dek_index;
3998c2ecf20Sopenharmony_ci	u16 drive_encryption_flags;
4008c2ecf20Sopenharmony_ci	u8  sanitize_maximum_time[6];
4018c2ecf20Sopenharmony_ci	u8  connector_info_mode;
4028c2ecf20Sopenharmony_ci	u8  connector_info_number[4];
4038c2ecf20Sopenharmony_ci	u8  long_connector_name[64];
4048c2ecf20Sopenharmony_ci	u8  device_unique_identifier[16];
4058c2ecf20Sopenharmony_ci	u8  padto_2K[17];
4068c2ecf20Sopenharmony_ci} __packed;
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci/*
4098c2ecf20Sopenharmony_ci * These macros convert from physical channels to virtual channels
4108c2ecf20Sopenharmony_ci */
4118c2ecf20Sopenharmony_ci#define CONTAINER_CHANNEL		(0)
4128c2ecf20Sopenharmony_ci#define NATIVE_CHANNEL			(1)
4138c2ecf20Sopenharmony_ci#define CONTAINER_TO_CHANNEL(cont)	(CONTAINER_CHANNEL)
4148c2ecf20Sopenharmony_ci#define CONTAINER_TO_ID(cont)		(cont)
4158c2ecf20Sopenharmony_ci#define CONTAINER_TO_LUN(cont)		(0)
4168c2ecf20Sopenharmony_ci#define ENCLOSURE_CHANNEL		(3)
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci#define PMC_DEVICE_S6	0x28b
4198c2ecf20Sopenharmony_ci#define PMC_DEVICE_S7	0x28c
4208c2ecf20Sopenharmony_ci#define PMC_DEVICE_S8	0x28d
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci#define aac_phys_to_logical(x)  ((x)+1)
4238c2ecf20Sopenharmony_ci#define aac_logical_to_phys(x)  ((x)?(x)-1:0)
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci/*
4268c2ecf20Sopenharmony_ci * These macros are for keeping track of
4278c2ecf20Sopenharmony_ci * character device state.
4288c2ecf20Sopenharmony_ci */
4298c2ecf20Sopenharmony_ci#define AAC_CHARDEV_UNREGISTERED	(-1)
4308c2ecf20Sopenharmony_ci#define AAC_CHARDEV_NEEDS_REINIT	(-2)
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci/* #define AAC_DETAILED_STATUS_INFO */
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_cistruct diskparm
4358c2ecf20Sopenharmony_ci{
4368c2ecf20Sopenharmony_ci	int heads;
4378c2ecf20Sopenharmony_ci	int sectors;
4388c2ecf20Sopenharmony_ci	int cylinders;
4398c2ecf20Sopenharmony_ci};
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci/*
4438c2ecf20Sopenharmony_ci *	Firmware constants
4448c2ecf20Sopenharmony_ci */
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci#define		CT_NONE			0
4478c2ecf20Sopenharmony_ci#define		CT_OK			218
4488c2ecf20Sopenharmony_ci#define		FT_FILESYS	8	/* ADAPTEC's "FSA"(tm) filesystem */
4498c2ecf20Sopenharmony_ci#define		FT_DRIVE	9	/* physical disk - addressable in scsi by bus/id/lun */
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci/*
4528c2ecf20Sopenharmony_ci *	Host side memory scatter gather list
4538c2ecf20Sopenharmony_ci *	Used by the adapter for read, write, and readdirplus operations
4548c2ecf20Sopenharmony_ci *	We have separate 32 and 64 bit version because even
4558c2ecf20Sopenharmony_ci *	on 64 bit systems not all cards support the 64 bit version
4568c2ecf20Sopenharmony_ci */
4578c2ecf20Sopenharmony_cistruct sgentry {
4588c2ecf20Sopenharmony_ci	__le32	addr;	/* 32-bit address. */
4598c2ecf20Sopenharmony_ci	__le32	count;	/* Length. */
4608c2ecf20Sopenharmony_ci};
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cistruct user_sgentry {
4638c2ecf20Sopenharmony_ci	u32	addr;	/* 32-bit address. */
4648c2ecf20Sopenharmony_ci	u32	count;	/* Length. */
4658c2ecf20Sopenharmony_ci};
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_cistruct sgentry64 {
4688c2ecf20Sopenharmony_ci	__le32	addr[2];	/* 64-bit addr. 2 pieces for data alignment */
4698c2ecf20Sopenharmony_ci	__le32	count;	/* Length. */
4708c2ecf20Sopenharmony_ci};
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_cistruct user_sgentry64 {
4738c2ecf20Sopenharmony_ci	u32	addr[2];	/* 64-bit addr. 2 pieces for data alignment */
4748c2ecf20Sopenharmony_ci	u32	count;	/* Length. */
4758c2ecf20Sopenharmony_ci};
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_cistruct sgentryraw {
4788c2ecf20Sopenharmony_ci	__le32		next;	/* reserved for F/W use */
4798c2ecf20Sopenharmony_ci	__le32		prev;	/* reserved for F/W use */
4808c2ecf20Sopenharmony_ci	__le32		addr[2];
4818c2ecf20Sopenharmony_ci	__le32		count;
4828c2ecf20Sopenharmony_ci	__le32		flags;	/* reserved for F/W use */
4838c2ecf20Sopenharmony_ci};
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_cistruct user_sgentryraw {
4868c2ecf20Sopenharmony_ci	u32		next;	/* reserved for F/W use */
4878c2ecf20Sopenharmony_ci	u32		prev;	/* reserved for F/W use */
4888c2ecf20Sopenharmony_ci	u32		addr[2];
4898c2ecf20Sopenharmony_ci	u32		count;
4908c2ecf20Sopenharmony_ci	u32		flags;	/* reserved for F/W use */
4918c2ecf20Sopenharmony_ci};
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_cistruct sge_ieee1212 {
4948c2ecf20Sopenharmony_ci	u32	addrLow;
4958c2ecf20Sopenharmony_ci	u32	addrHigh;
4968c2ecf20Sopenharmony_ci	u32	length;
4978c2ecf20Sopenharmony_ci	u32	flags;
4988c2ecf20Sopenharmony_ci};
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci/*
5018c2ecf20Sopenharmony_ci *	SGMAP
5028c2ecf20Sopenharmony_ci *
5038c2ecf20Sopenharmony_ci *	This is the SGMAP structure for all commands that use
5048c2ecf20Sopenharmony_ci *	32-bit addressing.
5058c2ecf20Sopenharmony_ci */
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_cistruct sgmap {
5088c2ecf20Sopenharmony_ci	__le32		count;
5098c2ecf20Sopenharmony_ci	struct sgentry	sg[1];
5108c2ecf20Sopenharmony_ci};
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_cistruct user_sgmap {
5138c2ecf20Sopenharmony_ci	u32		count;
5148c2ecf20Sopenharmony_ci	struct user_sgentry	sg[1];
5158c2ecf20Sopenharmony_ci};
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_cistruct sgmap64 {
5188c2ecf20Sopenharmony_ci	__le32		count;
5198c2ecf20Sopenharmony_ci	struct sgentry64 sg[1];
5208c2ecf20Sopenharmony_ci};
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_cistruct user_sgmap64 {
5238c2ecf20Sopenharmony_ci	u32		count;
5248c2ecf20Sopenharmony_ci	struct user_sgentry64 sg[1];
5258c2ecf20Sopenharmony_ci};
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_cistruct sgmapraw {
5288c2ecf20Sopenharmony_ci	__le32		  count;
5298c2ecf20Sopenharmony_ci	struct sgentryraw sg[1];
5308c2ecf20Sopenharmony_ci};
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_cistruct user_sgmapraw {
5338c2ecf20Sopenharmony_ci	u32		  count;
5348c2ecf20Sopenharmony_ci	struct user_sgentryraw sg[1];
5358c2ecf20Sopenharmony_ci};
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistruct creation_info
5388c2ecf20Sopenharmony_ci{
5398c2ecf20Sopenharmony_ci	u8		buildnum;		/* e.g., 588 */
5408c2ecf20Sopenharmony_ci	u8		usec;			/* e.g., 588 */
5418c2ecf20Sopenharmony_ci	u8		via;			/* e.g., 1 = FSU,
5428c2ecf20Sopenharmony_ci						 *	 2 = API
5438c2ecf20Sopenharmony_ci						 */
5448c2ecf20Sopenharmony_ci	u8		year;			/* e.g., 1997 = 97 */
5458c2ecf20Sopenharmony_ci	__le32		date;			/*
5468c2ecf20Sopenharmony_ci						 * unsigned	Month		:4;	// 1 - 12
5478c2ecf20Sopenharmony_ci						 * unsigned	Day		:6;	// 1 - 32
5488c2ecf20Sopenharmony_ci						 * unsigned	Hour		:6;	// 0 - 23
5498c2ecf20Sopenharmony_ci						 * unsigned	Minute		:6;	// 0 - 60
5508c2ecf20Sopenharmony_ci						 * unsigned	Second		:6;	// 0 - 60
5518c2ecf20Sopenharmony_ci						 */
5528c2ecf20Sopenharmony_ci	__le32		serial[2];			/* e.g., 0x1DEADB0BFAFAF001 */
5538c2ecf20Sopenharmony_ci};
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci/*
5578c2ecf20Sopenharmony_ci *	Define all the constants needed for the communication interface
5588c2ecf20Sopenharmony_ci */
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci/*
5618c2ecf20Sopenharmony_ci *	Define how many queue entries each queue will have and the total
5628c2ecf20Sopenharmony_ci *	number of entries for the entire communication interface. Also define
5638c2ecf20Sopenharmony_ci *	how many queues we support.
5648c2ecf20Sopenharmony_ci *
5658c2ecf20Sopenharmony_ci *	This has to match the controller
5668c2ecf20Sopenharmony_ci */
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci#define NUMBER_OF_COMM_QUEUES  8   // 4 command; 4 response
5698c2ecf20Sopenharmony_ci#define HOST_HIGH_CMD_ENTRIES  4
5708c2ecf20Sopenharmony_ci#define HOST_NORM_CMD_ENTRIES  8
5718c2ecf20Sopenharmony_ci#define ADAP_HIGH_CMD_ENTRIES  4
5728c2ecf20Sopenharmony_ci#define ADAP_NORM_CMD_ENTRIES  512
5738c2ecf20Sopenharmony_ci#define HOST_HIGH_RESP_ENTRIES 4
5748c2ecf20Sopenharmony_ci#define HOST_NORM_RESP_ENTRIES 512
5758c2ecf20Sopenharmony_ci#define ADAP_HIGH_RESP_ENTRIES 4
5768c2ecf20Sopenharmony_ci#define ADAP_NORM_RESP_ENTRIES 8
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci#define TOTAL_QUEUE_ENTRIES  \
5798c2ecf20Sopenharmony_ci    (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \
5808c2ecf20Sopenharmony_ci	    HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES)
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci/*
5848c2ecf20Sopenharmony_ci *	Set the queues on a 16 byte alignment
5858c2ecf20Sopenharmony_ci */
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci#define QUEUE_ALIGNMENT		16
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci/*
5908c2ecf20Sopenharmony_ci *	The queue headers define the Communication Region queues. These
5918c2ecf20Sopenharmony_ci *	are physically contiguous and accessible by both the adapter and the
5928c2ecf20Sopenharmony_ci *	host. Even though all queue headers are in the same contiguous block
5938c2ecf20Sopenharmony_ci *	they will be represented as individual units in the data structures.
5948c2ecf20Sopenharmony_ci */
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_cistruct aac_entry {
5978c2ecf20Sopenharmony_ci	__le32 size; /* Size in bytes of Fib which this QE points to */
5988c2ecf20Sopenharmony_ci	__le32 addr; /* Receiver address of the FIB */
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci/*
6028c2ecf20Sopenharmony_ci *	The adapter assumes the ProducerIndex and ConsumerIndex are grouped
6038c2ecf20Sopenharmony_ci *	adjacently and in that order.
6048c2ecf20Sopenharmony_ci */
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_cistruct aac_qhdr {
6078c2ecf20Sopenharmony_ci	__le64 header_addr;/* Address to hand the adapter to access
6088c2ecf20Sopenharmony_ci			      to this queue head */
6098c2ecf20Sopenharmony_ci	__le32 *producer; /* The producer index for this queue (host address) */
6108c2ecf20Sopenharmony_ci	__le32 *consumer; /* The consumer index for this queue (host address) */
6118c2ecf20Sopenharmony_ci};
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci/*
6148c2ecf20Sopenharmony_ci *	Define all the events which the adapter would like to notify
6158c2ecf20Sopenharmony_ci *	the host of.
6168c2ecf20Sopenharmony_ci */
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci#define		HostNormCmdQue		1	/* Change in host normal priority command queue */
6198c2ecf20Sopenharmony_ci#define		HostHighCmdQue		2	/* Change in host high priority command queue */
6208c2ecf20Sopenharmony_ci#define		HostNormRespQue		3	/* Change in host normal priority response queue */
6218c2ecf20Sopenharmony_ci#define		HostHighRespQue		4	/* Change in host high priority response queue */
6228c2ecf20Sopenharmony_ci#define		AdapNormRespNotFull	5
6238c2ecf20Sopenharmony_ci#define		AdapHighRespNotFull	6
6248c2ecf20Sopenharmony_ci#define		AdapNormCmdNotFull	7
6258c2ecf20Sopenharmony_ci#define		AdapHighCmdNotFull	8
6268c2ecf20Sopenharmony_ci#define		SynchCommandComplete	9
6278c2ecf20Sopenharmony_ci#define		AdapInternalError	0xfe    /* The adapter detected an internal error shutting down */
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci/*
6308c2ecf20Sopenharmony_ci *	Define all the events the host wishes to notify the
6318c2ecf20Sopenharmony_ci *	adapter of. The first four values much match the Qid the
6328c2ecf20Sopenharmony_ci *	corresponding queue.
6338c2ecf20Sopenharmony_ci */
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci#define		AdapNormCmdQue		2
6368c2ecf20Sopenharmony_ci#define		AdapHighCmdQue		3
6378c2ecf20Sopenharmony_ci#define		AdapNormRespQue		6
6388c2ecf20Sopenharmony_ci#define		AdapHighRespQue		7
6398c2ecf20Sopenharmony_ci#define		HostShutdown		8
6408c2ecf20Sopenharmony_ci#define		HostPowerFail		9
6418c2ecf20Sopenharmony_ci#define		FatalCommError		10
6428c2ecf20Sopenharmony_ci#define		HostNormRespNotFull	11
6438c2ecf20Sopenharmony_ci#define		HostHighRespNotFull	12
6448c2ecf20Sopenharmony_ci#define		HostNormCmdNotFull	13
6458c2ecf20Sopenharmony_ci#define		HostHighCmdNotFull	14
6468c2ecf20Sopenharmony_ci#define		FastIo			15
6478c2ecf20Sopenharmony_ci#define		AdapPrintfDone		16
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci/*
6508c2ecf20Sopenharmony_ci *	Define all the queues that the adapter and host use to communicate
6518c2ecf20Sopenharmony_ci *	Number them to match the physical queue layout.
6528c2ecf20Sopenharmony_ci */
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_cienum aac_queue_types {
6558c2ecf20Sopenharmony_ci        HostNormCmdQueue = 0,	/* Adapter to host normal priority command traffic */
6568c2ecf20Sopenharmony_ci        HostHighCmdQueue,	/* Adapter to host high priority command traffic */
6578c2ecf20Sopenharmony_ci        AdapNormCmdQueue,	/* Host to adapter normal priority command traffic */
6588c2ecf20Sopenharmony_ci        AdapHighCmdQueue,	/* Host to adapter high priority command traffic */
6598c2ecf20Sopenharmony_ci        HostNormRespQueue,	/* Adapter to host normal priority response traffic */
6608c2ecf20Sopenharmony_ci        HostHighRespQueue,	/* Adapter to host high priority response traffic */
6618c2ecf20Sopenharmony_ci        AdapNormRespQueue,	/* Host to adapter normal priority response traffic */
6628c2ecf20Sopenharmony_ci        AdapHighRespQueue	/* Host to adapter high priority response traffic */
6638c2ecf20Sopenharmony_ci};
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci/*
6668c2ecf20Sopenharmony_ci *	Assign type values to the FSA communication data structures
6678c2ecf20Sopenharmony_ci */
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci#define		FIB_MAGIC	0x0001
6708c2ecf20Sopenharmony_ci#define		FIB_MAGIC2	0x0004
6718c2ecf20Sopenharmony_ci#define		FIB_MAGIC2_64	0x0005
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci/*
6748c2ecf20Sopenharmony_ci *	Define the priority levels the FSA communication routines support.
6758c2ecf20Sopenharmony_ci */
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci#define		FsaNormal	1
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci/* transport FIB header (PMC) */
6808c2ecf20Sopenharmony_cistruct aac_fib_xporthdr {
6818c2ecf20Sopenharmony_ci	__le64	HostAddress;	/* FIB host address w/o xport header */
6828c2ecf20Sopenharmony_ci	__le32	Size;		/* FIB size excluding xport header */
6838c2ecf20Sopenharmony_ci	__le32	Handle;		/* driver handle to reference the FIB */
6848c2ecf20Sopenharmony_ci	__le64	Reserved[2];
6858c2ecf20Sopenharmony_ci};
6868c2ecf20Sopenharmony_ci
6878c2ecf20Sopenharmony_ci#define		ALIGN32		32
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci/*
6908c2ecf20Sopenharmony_ci * Define the FIB. The FIB is the where all the requested data and
6918c2ecf20Sopenharmony_ci * command information are put to the application on the FSA adapter.
6928c2ecf20Sopenharmony_ci */
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_cistruct aac_fibhdr {
6958c2ecf20Sopenharmony_ci	__le32 XferState;	/* Current transfer state for this CCB */
6968c2ecf20Sopenharmony_ci	__le16 Command;		/* Routing information for the destination */
6978c2ecf20Sopenharmony_ci	u8 StructType;		/* Type FIB */
6988c2ecf20Sopenharmony_ci	u8 Unused;		/* Unused */
6998c2ecf20Sopenharmony_ci	__le16 Size;		/* Size of this FIB in bytes */
7008c2ecf20Sopenharmony_ci	__le16 SenderSize;	/* Size of the FIB in the sender
7018c2ecf20Sopenharmony_ci				   (for response sizing) */
7028c2ecf20Sopenharmony_ci	__le32 SenderFibAddress;  /* Host defined data in the FIB */
7038c2ecf20Sopenharmony_ci	union {
7048c2ecf20Sopenharmony_ci		__le32 ReceiverFibAddress;/* Logical address of this FIB for
7058c2ecf20Sopenharmony_ci				     the adapter (old) */
7068c2ecf20Sopenharmony_ci		__le32 SenderFibAddressHigh;/* upper 32bit of phys. FIB address */
7078c2ecf20Sopenharmony_ci		__le32 TimeStamp;	/* otherwise timestamp for FW internal use */
7088c2ecf20Sopenharmony_ci	} u;
7098c2ecf20Sopenharmony_ci	__le32 Handle;		/* FIB handle used for MSGU commnunication */
7108c2ecf20Sopenharmony_ci	u32 Previous;		/* FW internal use */
7118c2ecf20Sopenharmony_ci	u32 Next;		/* FW internal use */
7128c2ecf20Sopenharmony_ci};
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_cistruct hw_fib {
7158c2ecf20Sopenharmony_ci	struct aac_fibhdr header;
7168c2ecf20Sopenharmony_ci	u8 data[512-sizeof(struct aac_fibhdr)];	// Command specific data
7178c2ecf20Sopenharmony_ci};
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci/*
7208c2ecf20Sopenharmony_ci *	FIB commands
7218c2ecf20Sopenharmony_ci */
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci#define		TestCommandResponse		1
7248c2ecf20Sopenharmony_ci#define		TestAdapterCommand		2
7258c2ecf20Sopenharmony_ci/*
7268c2ecf20Sopenharmony_ci *	Lowlevel and comm commands
7278c2ecf20Sopenharmony_ci */
7288c2ecf20Sopenharmony_ci#define		LastTestCommand			100
7298c2ecf20Sopenharmony_ci#define		ReinitHostNormCommandQueue	101
7308c2ecf20Sopenharmony_ci#define		ReinitHostHighCommandQueue	102
7318c2ecf20Sopenharmony_ci#define		ReinitHostHighRespQueue		103
7328c2ecf20Sopenharmony_ci#define		ReinitHostNormRespQueue		104
7338c2ecf20Sopenharmony_ci#define		ReinitAdapNormCommandQueue	105
7348c2ecf20Sopenharmony_ci#define		ReinitAdapHighCommandQueue	107
7358c2ecf20Sopenharmony_ci#define		ReinitAdapHighRespQueue		108
7368c2ecf20Sopenharmony_ci#define		ReinitAdapNormRespQueue		109
7378c2ecf20Sopenharmony_ci#define		InterfaceShutdown		110
7388c2ecf20Sopenharmony_ci#define		DmaCommandFib			120
7398c2ecf20Sopenharmony_ci#define		StartProfile			121
7408c2ecf20Sopenharmony_ci#define		TermProfile			122
7418c2ecf20Sopenharmony_ci#define		SpeedTest			123
7428c2ecf20Sopenharmony_ci#define		TakeABreakPt			124
7438c2ecf20Sopenharmony_ci#define		RequestPerfData			125
7448c2ecf20Sopenharmony_ci#define		SetInterruptDefTimer		126
7458c2ecf20Sopenharmony_ci#define		SetInterruptDefCount		127
7468c2ecf20Sopenharmony_ci#define		GetInterruptDefStatus		128
7478c2ecf20Sopenharmony_ci#define		LastCommCommand			129
7488c2ecf20Sopenharmony_ci/*
7498c2ecf20Sopenharmony_ci *	Filesystem commands
7508c2ecf20Sopenharmony_ci */
7518c2ecf20Sopenharmony_ci#define		NuFileSystem			300
7528c2ecf20Sopenharmony_ci#define		UFS				301
7538c2ecf20Sopenharmony_ci#define		HostFileSystem			302
7548c2ecf20Sopenharmony_ci#define		LastFileSystemCommand		303
7558c2ecf20Sopenharmony_ci/*
7568c2ecf20Sopenharmony_ci *	Container Commands
7578c2ecf20Sopenharmony_ci */
7588c2ecf20Sopenharmony_ci#define		ContainerCommand		500
7598c2ecf20Sopenharmony_ci#define		ContainerCommand64		501
7608c2ecf20Sopenharmony_ci#define		ContainerRawIo			502
7618c2ecf20Sopenharmony_ci#define		ContainerRawIo2			503
7628c2ecf20Sopenharmony_ci/*
7638c2ecf20Sopenharmony_ci *	Scsi Port commands (scsi passthrough)
7648c2ecf20Sopenharmony_ci */
7658c2ecf20Sopenharmony_ci#define		ScsiPortCommand			600
7668c2ecf20Sopenharmony_ci#define		ScsiPortCommand64		601
7678c2ecf20Sopenharmony_ci/*
7688c2ecf20Sopenharmony_ci *	Misc house keeping and generic adapter initiated commands
7698c2ecf20Sopenharmony_ci */
7708c2ecf20Sopenharmony_ci#define		AifRequest			700
7718c2ecf20Sopenharmony_ci#define		CheckRevision			701
7728c2ecf20Sopenharmony_ci#define		FsaHostShutdown			702
7738c2ecf20Sopenharmony_ci#define		RequestAdapterInfo		703
7748c2ecf20Sopenharmony_ci#define		IsAdapterPaused			704
7758c2ecf20Sopenharmony_ci#define		SendHostTime			705
7768c2ecf20Sopenharmony_ci#define		RequestSupplementAdapterInfo	706
7778c2ecf20Sopenharmony_ci#define		LastMiscCommand			707
7788c2ecf20Sopenharmony_ci
7798c2ecf20Sopenharmony_ci/*
7808c2ecf20Sopenharmony_ci * Commands that will target the failover level on the FSA adapter
7818c2ecf20Sopenharmony_ci */
7828c2ecf20Sopenharmony_ci
7838c2ecf20Sopenharmony_cienum fib_xfer_state {
7848c2ecf20Sopenharmony_ci	HostOwned			= (1<<0),
7858c2ecf20Sopenharmony_ci	AdapterOwned			= (1<<1),
7868c2ecf20Sopenharmony_ci	FibInitialized			= (1<<2),
7878c2ecf20Sopenharmony_ci	FibEmpty			= (1<<3),
7888c2ecf20Sopenharmony_ci	AllocatedFromPool		= (1<<4),
7898c2ecf20Sopenharmony_ci	SentFromHost			= (1<<5),
7908c2ecf20Sopenharmony_ci	SentFromAdapter			= (1<<6),
7918c2ecf20Sopenharmony_ci	ResponseExpected		= (1<<7),
7928c2ecf20Sopenharmony_ci	NoResponseExpected		= (1<<8),
7938c2ecf20Sopenharmony_ci	AdapterProcessed		= (1<<9),
7948c2ecf20Sopenharmony_ci	HostProcessed			= (1<<10),
7958c2ecf20Sopenharmony_ci	HighPriority			= (1<<11),
7968c2ecf20Sopenharmony_ci	NormalPriority			= (1<<12),
7978c2ecf20Sopenharmony_ci	Async				= (1<<13),
7988c2ecf20Sopenharmony_ci	AsyncIo				= (1<<13),	// rpbfix: remove with new regime
7998c2ecf20Sopenharmony_ci	PageFileIo			= (1<<14),	// rpbfix: remove with new regime
8008c2ecf20Sopenharmony_ci	ShutdownRequest			= (1<<15),
8018c2ecf20Sopenharmony_ci	LazyWrite			= (1<<16),	// rpbfix: remove with new regime
8028c2ecf20Sopenharmony_ci	AdapterMicroFib			= (1<<17),
8038c2ecf20Sopenharmony_ci	BIOSFibPath			= (1<<18),
8048c2ecf20Sopenharmony_ci	FastResponseCapable		= (1<<19),
8058c2ecf20Sopenharmony_ci	ApiFib				= (1<<20),	/* Its an API Fib */
8068c2ecf20Sopenharmony_ci	/* PMC NEW COMM: There is no more AIF data pending */
8078c2ecf20Sopenharmony_ci	NoMoreAifDataAvailable		= (1<<21)
8088c2ecf20Sopenharmony_ci};
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci/*
8118c2ecf20Sopenharmony_ci *	The following defines needs to be updated any time there is an
8128c2ecf20Sopenharmony_ci *	incompatible change made to the aac_init structure.
8138c2ecf20Sopenharmony_ci */
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_ci#define ADAPTER_INIT_STRUCT_REVISION		3
8168c2ecf20Sopenharmony_ci#define ADAPTER_INIT_STRUCT_REVISION_4		4 // rocket science
8178c2ecf20Sopenharmony_ci#define ADAPTER_INIT_STRUCT_REVISION_6		6 /* PMC src */
8188c2ecf20Sopenharmony_ci#define ADAPTER_INIT_STRUCT_REVISION_7		7 /* Denali */
8198c2ecf20Sopenharmony_ci#define ADAPTER_INIT_STRUCT_REVISION_8		8 // Thor
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ciunion aac_init
8228c2ecf20Sopenharmony_ci{
8238c2ecf20Sopenharmony_ci	struct _r7 {
8248c2ecf20Sopenharmony_ci		__le32	init_struct_revision;
8258c2ecf20Sopenharmony_ci		__le32	no_of_msix_vectors;
8268c2ecf20Sopenharmony_ci		__le32	fsrev;
8278c2ecf20Sopenharmony_ci		__le32	comm_header_address;
8288c2ecf20Sopenharmony_ci		__le32	fast_io_comm_area_address;
8298c2ecf20Sopenharmony_ci		__le32	adapter_fibs_physical_address;
8308c2ecf20Sopenharmony_ci		__le32	adapter_fibs_virtual_address;
8318c2ecf20Sopenharmony_ci		__le32	adapter_fibs_size;
8328c2ecf20Sopenharmony_ci		__le32	adapter_fib_align;
8338c2ecf20Sopenharmony_ci		__le32	printfbuf;
8348c2ecf20Sopenharmony_ci		__le32	printfbufsiz;
8358c2ecf20Sopenharmony_ci		/* number of 4k pages of host phys. mem. */
8368c2ecf20Sopenharmony_ci		__le32	host_phys_mem_pages;
8378c2ecf20Sopenharmony_ci		/* number of seconds since 1970. */
8388c2ecf20Sopenharmony_ci		__le32	host_elapsed_seconds;
8398c2ecf20Sopenharmony_ci		/* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
8408c2ecf20Sopenharmony_ci		__le32	init_flags;	/* flags for supported features */
8418c2ecf20Sopenharmony_ci#define INITFLAGS_NEW_COMM_SUPPORTED	0x00000001
8428c2ecf20Sopenharmony_ci#define INITFLAGS_DRIVER_USES_UTC_TIME	0x00000010
8438c2ecf20Sopenharmony_ci#define INITFLAGS_DRIVER_SUPPORTS_PM	0x00000020
8448c2ecf20Sopenharmony_ci#define INITFLAGS_NEW_COMM_TYPE1_SUPPORTED	0x00000040
8458c2ecf20Sopenharmony_ci#define INITFLAGS_FAST_JBOD_SUPPORTED	0x00000080
8468c2ecf20Sopenharmony_ci#define INITFLAGS_NEW_COMM_TYPE2_SUPPORTED	0x00000100
8478c2ecf20Sopenharmony_ci#define INITFLAGS_DRIVER_SUPPORTS_HBA_MODE  0x00000400
8488c2ecf20Sopenharmony_ci		__le32	max_io_commands;	/* max outstanding commands */
8498c2ecf20Sopenharmony_ci		__le32	max_io_size;	/* largest I/O command */
8508c2ecf20Sopenharmony_ci		__le32	max_fib_size;	/* largest FIB to adapter */
8518c2ecf20Sopenharmony_ci		/* ADAPTER_INIT_STRUCT_REVISION_5 begins here */
8528c2ecf20Sopenharmony_ci		__le32	max_num_aif;	/* max number of aif */
8538c2ecf20Sopenharmony_ci		/* ADAPTER_INIT_STRUCT_REVISION_6 begins here */
8548c2ecf20Sopenharmony_ci		/* Host RRQ (response queue) for SRC */
8558c2ecf20Sopenharmony_ci		__le32	host_rrq_addr_low;
8568c2ecf20Sopenharmony_ci		__le32	host_rrq_addr_high;
8578c2ecf20Sopenharmony_ci	} r7;
8588c2ecf20Sopenharmony_ci	struct _r8 {
8598c2ecf20Sopenharmony_ci		/* ADAPTER_INIT_STRUCT_REVISION_8 */
8608c2ecf20Sopenharmony_ci		__le32	init_struct_revision;
8618c2ecf20Sopenharmony_ci		__le32	rr_queue_count;
8628c2ecf20Sopenharmony_ci		__le32	host_elapsed_seconds; /* number of secs since 1970. */
8638c2ecf20Sopenharmony_ci		__le32	init_flags;
8648c2ecf20Sopenharmony_ci		__le32	max_io_size;	/* largest I/O command */
8658c2ecf20Sopenharmony_ci		__le32	max_num_aif;	/* max number of aif */
8668c2ecf20Sopenharmony_ci		__le32	reserved1;
8678c2ecf20Sopenharmony_ci		__le32	reserved2;
8688c2ecf20Sopenharmony_ci		struct _rrq {
8698c2ecf20Sopenharmony_ci			__le32	host_addr_low;
8708c2ecf20Sopenharmony_ci			__le32	host_addr_high;
8718c2ecf20Sopenharmony_ci			__le16	msix_id;
8728c2ecf20Sopenharmony_ci			__le16	element_count;
8738c2ecf20Sopenharmony_ci			__le16	comp_thresh;
8748c2ecf20Sopenharmony_ci			__le16	unused;
8758c2ecf20Sopenharmony_ci		} rrq[1];		/* up to 64 RRQ addresses */
8768c2ecf20Sopenharmony_ci	} r8;
8778c2ecf20Sopenharmony_ci};
8788c2ecf20Sopenharmony_ci
8798c2ecf20Sopenharmony_cienum aac_log_level {
8808c2ecf20Sopenharmony_ci	LOG_AAC_INIT			= 10,
8818c2ecf20Sopenharmony_ci	LOG_AAC_INFORMATIONAL		= 20,
8828c2ecf20Sopenharmony_ci	LOG_AAC_WARNING			= 30,
8838c2ecf20Sopenharmony_ci	LOG_AAC_LOW_ERROR		= 40,
8848c2ecf20Sopenharmony_ci	LOG_AAC_MEDIUM_ERROR		= 50,
8858c2ecf20Sopenharmony_ci	LOG_AAC_HIGH_ERROR		= 60,
8868c2ecf20Sopenharmony_ci	LOG_AAC_PANIC			= 70,
8878c2ecf20Sopenharmony_ci	LOG_AAC_DEBUG			= 80,
8888c2ecf20Sopenharmony_ci	LOG_AAC_WINDBG_PRINT		= 90
8898c2ecf20Sopenharmony_ci};
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci#define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT	0x030b
8928c2ecf20Sopenharmony_ci#define FSAFS_NTC_FIB_CONTEXT			0x030c
8938c2ecf20Sopenharmony_ci
8948c2ecf20Sopenharmony_cistruct aac_dev;
8958c2ecf20Sopenharmony_cistruct fib;
8968c2ecf20Sopenharmony_cistruct scsi_cmnd;
8978c2ecf20Sopenharmony_ci
8988c2ecf20Sopenharmony_cistruct adapter_ops
8998c2ecf20Sopenharmony_ci{
9008c2ecf20Sopenharmony_ci	/* Low level operations */
9018c2ecf20Sopenharmony_ci	void (*adapter_interrupt)(struct aac_dev *dev);
9028c2ecf20Sopenharmony_ci	void (*adapter_notify)(struct aac_dev *dev, u32 event);
9038c2ecf20Sopenharmony_ci	void (*adapter_disable_int)(struct aac_dev *dev);
9048c2ecf20Sopenharmony_ci	void (*adapter_enable_int)(struct aac_dev *dev);
9058c2ecf20Sopenharmony_ci	int  (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
9068c2ecf20Sopenharmony_ci	int  (*adapter_check_health)(struct aac_dev *dev);
9078c2ecf20Sopenharmony_ci	int  (*adapter_restart)(struct aac_dev *dev, int bled, u8 reset_type);
9088c2ecf20Sopenharmony_ci	void (*adapter_start)(struct aac_dev *dev);
9098c2ecf20Sopenharmony_ci	/* Transport operations */
9108c2ecf20Sopenharmony_ci	int  (*adapter_ioremap)(struct aac_dev * dev, u32 size);
9118c2ecf20Sopenharmony_ci	irq_handler_t adapter_intr;
9128c2ecf20Sopenharmony_ci	/* Packet operations */
9138c2ecf20Sopenharmony_ci	int  (*adapter_deliver)(struct fib * fib);
9148c2ecf20Sopenharmony_ci	int  (*adapter_bounds)(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba);
9158c2ecf20Sopenharmony_ci	int  (*adapter_read)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count);
9168c2ecf20Sopenharmony_ci	int  (*adapter_write)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua);
9178c2ecf20Sopenharmony_ci	int  (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
9188c2ecf20Sopenharmony_ci	/* Administrative operations */
9198c2ecf20Sopenharmony_ci	int  (*adapter_comm)(struct aac_dev * dev, int comm);
9208c2ecf20Sopenharmony_ci};
9218c2ecf20Sopenharmony_ci
9228c2ecf20Sopenharmony_ci/*
9238c2ecf20Sopenharmony_ci *	Define which interrupt handler needs to be installed
9248c2ecf20Sopenharmony_ci */
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_cistruct aac_driver_ident
9278c2ecf20Sopenharmony_ci{
9288c2ecf20Sopenharmony_ci	int	(*init)(struct aac_dev *dev);
9298c2ecf20Sopenharmony_ci	char *	name;
9308c2ecf20Sopenharmony_ci	char *	vname;
9318c2ecf20Sopenharmony_ci	char *	model;
9328c2ecf20Sopenharmony_ci	u16	channels;
9338c2ecf20Sopenharmony_ci	int	quirks;
9348c2ecf20Sopenharmony_ci};
9358c2ecf20Sopenharmony_ci/*
9368c2ecf20Sopenharmony_ci * Some adapter firmware needs communication memory
9378c2ecf20Sopenharmony_ci * below 2gig. This tells the init function to set the
9388c2ecf20Sopenharmony_ci * dma mask such that fib memory will be allocated where the
9398c2ecf20Sopenharmony_ci * adapter firmware can get to it.
9408c2ecf20Sopenharmony_ci */
9418c2ecf20Sopenharmony_ci#define AAC_QUIRK_31BIT	0x0001
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_ci/*
9448c2ecf20Sopenharmony_ci * Some adapter firmware, when the raid card's cache is turned off, can not
9458c2ecf20Sopenharmony_ci * split up scatter gathers in order to deal with the limits of the
9468c2ecf20Sopenharmony_ci * underlying CHIM. This limit is 34 scatter gather elements.
9478c2ecf20Sopenharmony_ci */
9488c2ecf20Sopenharmony_ci#define AAC_QUIRK_34SG	0x0002
9498c2ecf20Sopenharmony_ci
9508c2ecf20Sopenharmony_ci/*
9518c2ecf20Sopenharmony_ci * This adapter is a slave (no Firmware)
9528c2ecf20Sopenharmony_ci */
9538c2ecf20Sopenharmony_ci#define AAC_QUIRK_SLAVE 0x0004
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_ci/*
9568c2ecf20Sopenharmony_ci * This adapter is a master.
9578c2ecf20Sopenharmony_ci */
9588c2ecf20Sopenharmony_ci#define AAC_QUIRK_MASTER 0x0008
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_ci/*
9618c2ecf20Sopenharmony_ci * Some adapter firmware perform poorly when it must split up scatter gathers
9628c2ecf20Sopenharmony_ci * in order to deal with the limits of the underlying CHIM. This limit in this
9638c2ecf20Sopenharmony_ci * class of adapters is 17 scatter gather elements.
9648c2ecf20Sopenharmony_ci */
9658c2ecf20Sopenharmony_ci#define AAC_QUIRK_17SG	0x0010
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci/*
9688c2ecf20Sopenharmony_ci *	Some adapter firmware does not support 64 bit scsi passthrough
9698c2ecf20Sopenharmony_ci * commands.
9708c2ecf20Sopenharmony_ci */
9718c2ecf20Sopenharmony_ci#define AAC_QUIRK_SCSI_32	0x0020
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_ci/*
9748c2ecf20Sopenharmony_ci * SRC based adapters support the AifReqEvent functions
9758c2ecf20Sopenharmony_ci */
9768c2ecf20Sopenharmony_ci#define AAC_QUIRK_SRC 0x0040
9778c2ecf20Sopenharmony_ci
9788c2ecf20Sopenharmony_ci/*
9798c2ecf20Sopenharmony_ci *	The adapter interface specs all queues to be located in the same
9808c2ecf20Sopenharmony_ci *	physically contiguous block. The host structure that defines the
9818c2ecf20Sopenharmony_ci *	commuication queues will assume they are each a separate physically
9828c2ecf20Sopenharmony_ci *	contiguous memory region that will support them all being one big
9838c2ecf20Sopenharmony_ci *	contiguous block.
9848c2ecf20Sopenharmony_ci *	There is a command and response queue for each level and direction of
9858c2ecf20Sopenharmony_ci *	commuication. These regions are accessed by both the host and adapter.
9868c2ecf20Sopenharmony_ci */
9878c2ecf20Sopenharmony_ci
9888c2ecf20Sopenharmony_cistruct aac_queue {
9898c2ecf20Sopenharmony_ci	u64			logical;	/*address we give the adapter */
9908c2ecf20Sopenharmony_ci	struct aac_entry	*base;		/*system virtual address */
9918c2ecf20Sopenharmony_ci	struct aac_qhdr		headers;	/*producer,consumer q headers*/
9928c2ecf20Sopenharmony_ci	u32			entries;	/*Number of queue entries */
9938c2ecf20Sopenharmony_ci	wait_queue_head_t	qfull;		/*Event to wait on if q full */
9948c2ecf20Sopenharmony_ci	wait_queue_head_t	cmdready;	/*Cmd ready from the adapter */
9958c2ecf20Sopenharmony_ci		/* This is only valid for adapter to host command queues. */
9968c2ecf20Sopenharmony_ci	spinlock_t		*lock;		/* Spinlock for this queue must take this lock before accessing the lock */
9978c2ecf20Sopenharmony_ci	spinlock_t		lockdata;	/* Actual lock (used only on one side of the lock) */
9988c2ecf20Sopenharmony_ci	struct list_head	cmdq;		/* A queue of FIBs which need to be prcessed by the FS thread. This is */
9998c2ecf20Sopenharmony_ci						/* only valid for command queues which receive entries from the adapter. */
10008c2ecf20Sopenharmony_ci	/* Number of entries on outstanding queue. */
10018c2ecf20Sopenharmony_ci	atomic_t		numpending;
10028c2ecf20Sopenharmony_ci	struct aac_dev *	dev;		/* Back pointer to adapter structure */
10038c2ecf20Sopenharmony_ci};
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ci/*
10068c2ecf20Sopenharmony_ci *	Message queues. The order here is important, see also the
10078c2ecf20Sopenharmony_ci *	queue type ordering
10088c2ecf20Sopenharmony_ci */
10098c2ecf20Sopenharmony_ci
10108c2ecf20Sopenharmony_cistruct aac_queue_block
10118c2ecf20Sopenharmony_ci{
10128c2ecf20Sopenharmony_ci	struct aac_queue queue[8];
10138c2ecf20Sopenharmony_ci};
10148c2ecf20Sopenharmony_ci
10158c2ecf20Sopenharmony_ci/*
10168c2ecf20Sopenharmony_ci *	SaP1 Message Unit Registers
10178c2ecf20Sopenharmony_ci */
10188c2ecf20Sopenharmony_ci
10198c2ecf20Sopenharmony_cistruct sa_drawbridge_CSR {
10208c2ecf20Sopenharmony_ci				/*	Offset	|  Name */
10218c2ecf20Sopenharmony_ci	__le32	reserved[10];	/*	00h-27h |  Reserved */
10228c2ecf20Sopenharmony_ci	u8	LUT_Offset;	/*	28h	|  Lookup Table Offset */
10238c2ecf20Sopenharmony_ci	u8	reserved1[3];	/*	29h-2bh	|  Reserved */
10248c2ecf20Sopenharmony_ci	__le32	LUT_Data;	/*	2ch	|  Looup Table Data */
10258c2ecf20Sopenharmony_ci	__le32	reserved2[26];	/*	30h-97h	|  Reserved */
10268c2ecf20Sopenharmony_ci	__le16	PRICLEARIRQ;	/*	98h	|  Primary Clear Irq */
10278c2ecf20Sopenharmony_ci	__le16	SECCLEARIRQ;	/*	9ah	|  Secondary Clear Irq */
10288c2ecf20Sopenharmony_ci	__le16	PRISETIRQ;	/*	9ch	|  Primary Set Irq */
10298c2ecf20Sopenharmony_ci	__le16	SECSETIRQ;	/*	9eh	|  Secondary Set Irq */
10308c2ecf20Sopenharmony_ci	__le16	PRICLEARIRQMASK;/*	a0h	|  Primary Clear Irq Mask */
10318c2ecf20Sopenharmony_ci	__le16	SECCLEARIRQMASK;/*	a2h	|  Secondary Clear Irq Mask */
10328c2ecf20Sopenharmony_ci	__le16	PRISETIRQMASK;	/*	a4h	|  Primary Set Irq Mask */
10338c2ecf20Sopenharmony_ci	__le16	SECSETIRQMASK;	/*	a6h	|  Secondary Set Irq Mask */
10348c2ecf20Sopenharmony_ci	__le32	MAILBOX0;	/*	a8h	|  Scratchpad 0 */
10358c2ecf20Sopenharmony_ci	__le32	MAILBOX1;	/*	ach	|  Scratchpad 1 */
10368c2ecf20Sopenharmony_ci	__le32	MAILBOX2;	/*	b0h	|  Scratchpad 2 */
10378c2ecf20Sopenharmony_ci	__le32	MAILBOX3;	/*	b4h	|  Scratchpad 3 */
10388c2ecf20Sopenharmony_ci	__le32	MAILBOX4;	/*	b8h	|  Scratchpad 4 */
10398c2ecf20Sopenharmony_ci	__le32	MAILBOX5;	/*	bch	|  Scratchpad 5 */
10408c2ecf20Sopenharmony_ci	__le32	MAILBOX6;	/*	c0h	|  Scratchpad 6 */
10418c2ecf20Sopenharmony_ci	__le32	MAILBOX7;	/*	c4h	|  Scratchpad 7 */
10428c2ecf20Sopenharmony_ci	__le32	ROM_Setup_Data;	/*	c8h	|  Rom Setup and Data */
10438c2ecf20Sopenharmony_ci	__le32	ROM_Control_Addr;/*	cch	|  Rom Control and Address */
10448c2ecf20Sopenharmony_ci	__le32	reserved3[12];	/*	d0h-ffh	|  reserved */
10458c2ecf20Sopenharmony_ci	__le32	LUT[64];	/*    100h-1ffh	|  Lookup Table Entries */
10468c2ecf20Sopenharmony_ci};
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci#define Mailbox0	SaDbCSR.MAILBOX0
10498c2ecf20Sopenharmony_ci#define Mailbox1	SaDbCSR.MAILBOX1
10508c2ecf20Sopenharmony_ci#define Mailbox2	SaDbCSR.MAILBOX2
10518c2ecf20Sopenharmony_ci#define Mailbox3	SaDbCSR.MAILBOX3
10528c2ecf20Sopenharmony_ci#define Mailbox4	SaDbCSR.MAILBOX4
10538c2ecf20Sopenharmony_ci#define Mailbox5	SaDbCSR.MAILBOX5
10548c2ecf20Sopenharmony_ci#define Mailbox6	SaDbCSR.MAILBOX6
10558c2ecf20Sopenharmony_ci#define Mailbox7	SaDbCSR.MAILBOX7
10568c2ecf20Sopenharmony_ci
10578c2ecf20Sopenharmony_ci#define DoorbellReg_p SaDbCSR.PRISETIRQ
10588c2ecf20Sopenharmony_ci#define DoorbellReg_s SaDbCSR.SECSETIRQ
10598c2ecf20Sopenharmony_ci#define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ
10608c2ecf20Sopenharmony_ci
10618c2ecf20Sopenharmony_ci
10628c2ecf20Sopenharmony_ci#define	DOORBELL_0	0x0001
10638c2ecf20Sopenharmony_ci#define DOORBELL_1	0x0002
10648c2ecf20Sopenharmony_ci#define DOORBELL_2	0x0004
10658c2ecf20Sopenharmony_ci#define DOORBELL_3	0x0008
10668c2ecf20Sopenharmony_ci#define DOORBELL_4	0x0010
10678c2ecf20Sopenharmony_ci#define DOORBELL_5	0x0020
10688c2ecf20Sopenharmony_ci#define DOORBELL_6	0x0040
10698c2ecf20Sopenharmony_ci
10708c2ecf20Sopenharmony_ci
10718c2ecf20Sopenharmony_ci#define PrintfReady	DOORBELL_5
10728c2ecf20Sopenharmony_ci#define PrintfDone	DOORBELL_5
10738c2ecf20Sopenharmony_ci
10748c2ecf20Sopenharmony_cistruct sa_registers {
10758c2ecf20Sopenharmony_ci	struct sa_drawbridge_CSR	SaDbCSR;			/* 98h - c4h */
10768c2ecf20Sopenharmony_ci};
10778c2ecf20Sopenharmony_ci
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci#define SA_INIT_NUM_MSIXVECTORS		1
10808c2ecf20Sopenharmony_ci#define SA_MINIPORT_REVISION		SA_INIT_NUM_MSIXVECTORS
10818c2ecf20Sopenharmony_ci
10828c2ecf20Sopenharmony_ci#define sa_readw(AEP, CSR)		readl(&((AEP)->regs.sa->CSR))
10838c2ecf20Sopenharmony_ci#define sa_readl(AEP, CSR)		readl(&((AEP)->regs.sa->CSR))
10848c2ecf20Sopenharmony_ci#define sa_writew(AEP, CSR, value)	writew(value, &((AEP)->regs.sa->CSR))
10858c2ecf20Sopenharmony_ci#define sa_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.sa->CSR))
10868c2ecf20Sopenharmony_ci
10878c2ecf20Sopenharmony_ci/*
10888c2ecf20Sopenharmony_ci *	Rx Message Unit Registers
10898c2ecf20Sopenharmony_ci */
10908c2ecf20Sopenharmony_ci
10918c2ecf20Sopenharmony_cistruct rx_mu_registers {
10928c2ecf20Sopenharmony_ci			    /*	Local  | PCI*| Name */
10938c2ecf20Sopenharmony_ci	__le32	ARSR;	    /*	1300h  | 00h | APIC Register Select Register */
10948c2ecf20Sopenharmony_ci	__le32	reserved0;  /*	1304h  | 04h | Reserved */
10958c2ecf20Sopenharmony_ci	__le32	AWR;	    /*	1308h  | 08h | APIC Window Register */
10968c2ecf20Sopenharmony_ci	__le32	reserved1;  /*	130Ch  | 0Ch | Reserved */
10978c2ecf20Sopenharmony_ci	__le32	IMRx[2];    /*	1310h  | 10h | Inbound Message Registers */
10988c2ecf20Sopenharmony_ci	__le32	OMRx[2];    /*	1318h  | 18h | Outbound Message Registers */
10998c2ecf20Sopenharmony_ci	__le32	IDR;	    /*	1320h  | 20h | Inbound Doorbell Register */
11008c2ecf20Sopenharmony_ci	__le32	IISR;	    /*	1324h  | 24h | Inbound Interrupt
11018c2ecf20Sopenharmony_ci						Status Register */
11028c2ecf20Sopenharmony_ci	__le32	IIMR;	    /*	1328h  | 28h | Inbound Interrupt
11038c2ecf20Sopenharmony_ci						Mask Register */
11048c2ecf20Sopenharmony_ci	__le32	ODR;	    /*	132Ch  | 2Ch | Outbound Doorbell Register */
11058c2ecf20Sopenharmony_ci	__le32	OISR;	    /*	1330h  | 30h | Outbound Interrupt
11068c2ecf20Sopenharmony_ci						Status Register */
11078c2ecf20Sopenharmony_ci	__le32	OIMR;	    /*	1334h  | 34h | Outbound Interrupt
11088c2ecf20Sopenharmony_ci						Mask Register */
11098c2ecf20Sopenharmony_ci	__le32	reserved2;  /*	1338h  | 38h | Reserved */
11108c2ecf20Sopenharmony_ci	__le32	reserved3;  /*	133Ch  | 3Ch | Reserved */
11118c2ecf20Sopenharmony_ci	__le32	InboundQueue;/*	1340h  | 40h | Inbound Queue Port relative to firmware */
11128c2ecf20Sopenharmony_ci	__le32	OutboundQueue;/*1344h  | 44h | Outbound Queue Port relative to firmware */
11138c2ecf20Sopenharmony_ci			    /* * Must access through ATU Inbound
11148c2ecf20Sopenharmony_ci				 Translation Window */
11158c2ecf20Sopenharmony_ci};
11168c2ecf20Sopenharmony_ci
11178c2ecf20Sopenharmony_cistruct rx_inbound {
11188c2ecf20Sopenharmony_ci	__le32	Mailbox[8];
11198c2ecf20Sopenharmony_ci};
11208c2ecf20Sopenharmony_ci
11218c2ecf20Sopenharmony_ci#define	INBOUNDDOORBELL_0	0x00000001
11228c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_1	0x00000002
11238c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_2	0x00000004
11248c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_3	0x00000008
11258c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_4	0x00000010
11268c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_5	0x00000020
11278c2ecf20Sopenharmony_ci#define INBOUNDDOORBELL_6	0x00000040
11288c2ecf20Sopenharmony_ci
11298c2ecf20Sopenharmony_ci#define	OUTBOUNDDOORBELL_0	0x00000001
11308c2ecf20Sopenharmony_ci#define OUTBOUNDDOORBELL_1	0x00000002
11318c2ecf20Sopenharmony_ci#define OUTBOUNDDOORBELL_2	0x00000004
11328c2ecf20Sopenharmony_ci#define OUTBOUNDDOORBELL_3	0x00000008
11338c2ecf20Sopenharmony_ci#define OUTBOUNDDOORBELL_4	0x00000010
11348c2ecf20Sopenharmony_ci
11358c2ecf20Sopenharmony_ci#define InboundDoorbellReg	MUnit.IDR
11368c2ecf20Sopenharmony_ci#define OutboundDoorbellReg	MUnit.ODR
11378c2ecf20Sopenharmony_ci
11388c2ecf20Sopenharmony_cistruct rx_registers {
11398c2ecf20Sopenharmony_ci	struct rx_mu_registers		MUnit;		/* 1300h - 1347h */
11408c2ecf20Sopenharmony_ci	__le32				reserved1[2];	/* 1348h - 134ch */
11418c2ecf20Sopenharmony_ci	struct rx_inbound		IndexRegs;
11428c2ecf20Sopenharmony_ci};
11438c2ecf20Sopenharmony_ci
11448c2ecf20Sopenharmony_ci#define rx_readb(AEP, CSR)		readb(&((AEP)->regs.rx->CSR))
11458c2ecf20Sopenharmony_ci#define rx_readl(AEP, CSR)		readl(&((AEP)->regs.rx->CSR))
11468c2ecf20Sopenharmony_ci#define rx_writeb(AEP, CSR, value)	writeb(value, &((AEP)->regs.rx->CSR))
11478c2ecf20Sopenharmony_ci#define rx_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.rx->CSR))
11488c2ecf20Sopenharmony_ci
11498c2ecf20Sopenharmony_ci/*
11508c2ecf20Sopenharmony_ci *	Rkt Message Unit Registers (same as Rx, except a larger reserve region)
11518c2ecf20Sopenharmony_ci */
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_ci#define rkt_mu_registers rx_mu_registers
11548c2ecf20Sopenharmony_ci#define rkt_inbound rx_inbound
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_cistruct rkt_registers {
11578c2ecf20Sopenharmony_ci	struct rkt_mu_registers		MUnit;		 /* 1300h - 1347h */
11588c2ecf20Sopenharmony_ci	__le32				reserved1[1006]; /* 1348h - 22fch */
11598c2ecf20Sopenharmony_ci	struct rkt_inbound		IndexRegs;	 /* 2300h - */
11608c2ecf20Sopenharmony_ci};
11618c2ecf20Sopenharmony_ci
11628c2ecf20Sopenharmony_ci#define rkt_readb(AEP, CSR)		readb(&((AEP)->regs.rkt->CSR))
11638c2ecf20Sopenharmony_ci#define rkt_readl(AEP, CSR)		readl(&((AEP)->regs.rkt->CSR))
11648c2ecf20Sopenharmony_ci#define rkt_writeb(AEP, CSR, value)	writeb(value, &((AEP)->regs.rkt->CSR))
11658c2ecf20Sopenharmony_ci#define rkt_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.rkt->CSR))
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_ci/*
11688c2ecf20Sopenharmony_ci * PMC SRC message unit registers
11698c2ecf20Sopenharmony_ci */
11708c2ecf20Sopenharmony_ci
11718c2ecf20Sopenharmony_ci#define src_inbound rx_inbound
11728c2ecf20Sopenharmony_ci
11738c2ecf20Sopenharmony_cistruct src_mu_registers {
11748c2ecf20Sopenharmony_ci				/*  PCI*| Name */
11758c2ecf20Sopenharmony_ci	__le32	reserved0[6];	/*  00h | Reserved */
11768c2ecf20Sopenharmony_ci	__le32	IOAR[2];	/*  18h | IOA->host interrupt register */
11778c2ecf20Sopenharmony_ci	__le32	IDR;		/*  20h | Inbound Doorbell Register */
11788c2ecf20Sopenharmony_ci	__le32	IISR;		/*  24h | Inbound Int. Status Register */
11798c2ecf20Sopenharmony_ci	__le32	reserved1[3];	/*  28h | Reserved */
11808c2ecf20Sopenharmony_ci	__le32	OIMR;		/*  34h | Outbound Int. Mask Register */
11818c2ecf20Sopenharmony_ci	__le32	reserved2[25];  /*  38h | Reserved */
11828c2ecf20Sopenharmony_ci	__le32	ODR_R;		/*  9ch | Outbound Doorbell Read */
11838c2ecf20Sopenharmony_ci	__le32	ODR_C;		/*  a0h | Outbound Doorbell Clear */
11848c2ecf20Sopenharmony_ci	__le32	reserved3[3];	/*  a4h | Reserved */
11858c2ecf20Sopenharmony_ci	__le32	SCR0;		/*  b0h | Scratchpad 0 */
11868c2ecf20Sopenharmony_ci	__le32	reserved4[2];	/*  b4h | Reserved */
11878c2ecf20Sopenharmony_ci	__le32	OMR;		/*  bch | Outbound Message Register */
11888c2ecf20Sopenharmony_ci	__le32	IQ_L;		/*  c0h | Inbound Queue (Low address) */
11898c2ecf20Sopenharmony_ci	__le32	IQ_H;		/*  c4h | Inbound Queue (High address) */
11908c2ecf20Sopenharmony_ci	__le32	ODR_MSI;	/*  c8h | MSI register for sync./AIF */
11918c2ecf20Sopenharmony_ci	__le32  reserved5;	/*  cch | Reserved */
11928c2ecf20Sopenharmony_ci	__le32	IQN_L;		/*  d0h | Inbound (native cmd) low  */
11938c2ecf20Sopenharmony_ci	__le32	IQN_H;		/*  d4h | Inbound (native cmd) high */
11948c2ecf20Sopenharmony_ci};
11958c2ecf20Sopenharmony_ci
11968c2ecf20Sopenharmony_cistruct src_registers {
11978c2ecf20Sopenharmony_ci	struct src_mu_registers MUnit;	/* 00h - cbh */
11988c2ecf20Sopenharmony_ci	union {
11998c2ecf20Sopenharmony_ci		struct {
12008c2ecf20Sopenharmony_ci			__le32 reserved1[130786];	/* d8h - 7fc5fh */
12018c2ecf20Sopenharmony_ci			struct src_inbound IndexRegs;	/* 7fc60h */
12028c2ecf20Sopenharmony_ci		} tupelo;
12038c2ecf20Sopenharmony_ci		struct {
12048c2ecf20Sopenharmony_ci			__le32 reserved1[970];		/* d8h - fffh */
12058c2ecf20Sopenharmony_ci			struct src_inbound IndexRegs;	/* 1000h */
12068c2ecf20Sopenharmony_ci		} denali;
12078c2ecf20Sopenharmony_ci	} u;
12088c2ecf20Sopenharmony_ci};
12098c2ecf20Sopenharmony_ci
12108c2ecf20Sopenharmony_ci#define src_readb(AEP, CSR)		readb(&((AEP)->regs.src.bar0->CSR))
12118c2ecf20Sopenharmony_ci#define src_readl(AEP, CSR)		readl(&((AEP)->regs.src.bar0->CSR))
12128c2ecf20Sopenharmony_ci#define src_writeb(AEP, CSR, value)	writeb(value, \
12138c2ecf20Sopenharmony_ci						&((AEP)->regs.src.bar0->CSR))
12148c2ecf20Sopenharmony_ci#define src_writel(AEP, CSR, value)	writel(value, \
12158c2ecf20Sopenharmony_ci						&((AEP)->regs.src.bar0->CSR))
12168c2ecf20Sopenharmony_ci#if defined(writeq)
12178c2ecf20Sopenharmony_ci#define	src_writeq(AEP, CSR, value)	writeq(value, \
12188c2ecf20Sopenharmony_ci						&((AEP)->regs.src.bar0->CSR))
12198c2ecf20Sopenharmony_ci#endif
12208c2ecf20Sopenharmony_ci
12218c2ecf20Sopenharmony_ci#define SRC_ODR_SHIFT		12
12228c2ecf20Sopenharmony_ci#define SRC_IDR_SHIFT		9
12238c2ecf20Sopenharmony_ci#define SRC_MSI_READ_MASK	0x1000
12248c2ecf20Sopenharmony_ci
12258c2ecf20Sopenharmony_citypedef void (*fib_callback)(void *ctxt, struct fib *fibctx);
12268c2ecf20Sopenharmony_ci
12278c2ecf20Sopenharmony_cistruct aac_fib_context {
12288c2ecf20Sopenharmony_ci	s16			type;		// used for verification of structure
12298c2ecf20Sopenharmony_ci	s16			size;
12308c2ecf20Sopenharmony_ci	u32			unique;		// unique value representing this context
12318c2ecf20Sopenharmony_ci	ulong			jiffies;	// used for cleanup - dmb changed to ulong
12328c2ecf20Sopenharmony_ci	struct list_head	next;		// used to link context's into a linked list
12338c2ecf20Sopenharmony_ci	struct completion	completion;	// this is used to wait for the next fib to arrive.
12348c2ecf20Sopenharmony_ci	int			wait;		// Set to true when thread is in WaitForSingleObject
12358c2ecf20Sopenharmony_ci	unsigned long		count;		// total number of FIBs on FibList
12368c2ecf20Sopenharmony_ci	struct list_head	fib_list;	// this holds fibs and their attachd hw_fibs
12378c2ecf20Sopenharmony_ci};
12388c2ecf20Sopenharmony_ci
12398c2ecf20Sopenharmony_cistruct sense_data {
12408c2ecf20Sopenharmony_ci	u8 error_code;		/* 70h (current errors), 71h(deferred errors) */
12418c2ecf20Sopenharmony_ci	u8 valid:1;		/* A valid bit of one indicates that the information  */
12428c2ecf20Sopenharmony_ci				/* field contains valid information as defined in the
12438c2ecf20Sopenharmony_ci				 * SCSI-2 Standard.
12448c2ecf20Sopenharmony_ci				 */
12458c2ecf20Sopenharmony_ci	u8 segment_number;	/* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
12468c2ecf20Sopenharmony_ci	u8 sense_key:4;		/* Sense Key */
12478c2ecf20Sopenharmony_ci	u8 reserved:1;
12488c2ecf20Sopenharmony_ci	u8 ILI:1;		/* Incorrect Length Indicator */
12498c2ecf20Sopenharmony_ci	u8 EOM:1;		/* End Of Medium - reserved for random access devices */
12508c2ecf20Sopenharmony_ci	u8 filemark:1;		/* Filemark - reserved for random access devices */
12518c2ecf20Sopenharmony_ci
12528c2ecf20Sopenharmony_ci	u8 information[4];	/* for direct-access devices, contains the unsigned
12538c2ecf20Sopenharmony_ci				 * logical block address or residue associated with
12548c2ecf20Sopenharmony_ci				 * the sense key
12558c2ecf20Sopenharmony_ci				 */
12568c2ecf20Sopenharmony_ci	u8 add_sense_len;	/* number of additional sense bytes to follow this field */
12578c2ecf20Sopenharmony_ci	u8 cmnd_info[4];	/* not used */
12588c2ecf20Sopenharmony_ci	u8 ASC;			/* Additional Sense Code */
12598c2ecf20Sopenharmony_ci	u8 ASCQ;		/* Additional Sense Code Qualifier */
12608c2ecf20Sopenharmony_ci	u8 FRUC;		/* Field Replaceable Unit Code - not used */
12618c2ecf20Sopenharmony_ci	u8 bit_ptr:3;		/* indicates which byte of the CDB or parameter data
12628c2ecf20Sopenharmony_ci				 * was in error
12638c2ecf20Sopenharmony_ci				 */
12648c2ecf20Sopenharmony_ci	u8 BPV:1;		/* bit pointer valid (BPV): 1- indicates that
12658c2ecf20Sopenharmony_ci				 * the bit_ptr field has valid value
12668c2ecf20Sopenharmony_ci				 */
12678c2ecf20Sopenharmony_ci	u8 reserved2:2;
12688c2ecf20Sopenharmony_ci	u8 CD:1;		/* command data bit: 1- illegal parameter in CDB.
12698c2ecf20Sopenharmony_ci				 * 0- illegal parameter in data.
12708c2ecf20Sopenharmony_ci				 */
12718c2ecf20Sopenharmony_ci	u8 SKSV:1;
12728c2ecf20Sopenharmony_ci	u8 field_ptr[2];	/* byte of the CDB or parameter data in error */
12738c2ecf20Sopenharmony_ci};
12748c2ecf20Sopenharmony_ci
12758c2ecf20Sopenharmony_cistruct fsa_dev_info {
12768c2ecf20Sopenharmony_ci	u64		last;
12778c2ecf20Sopenharmony_ci	u64		size;
12788c2ecf20Sopenharmony_ci	u32		type;
12798c2ecf20Sopenharmony_ci	u32		config_waiting_on;
12808c2ecf20Sopenharmony_ci	unsigned long	config_waiting_stamp;
12818c2ecf20Sopenharmony_ci	u16		queue_depth;
12828c2ecf20Sopenharmony_ci	u8		config_needed;
12838c2ecf20Sopenharmony_ci	u8		valid;
12848c2ecf20Sopenharmony_ci	u8		ro;
12858c2ecf20Sopenharmony_ci	u8		locked;
12868c2ecf20Sopenharmony_ci	u8		deleted;
12878c2ecf20Sopenharmony_ci	char		devname[8];
12888c2ecf20Sopenharmony_ci	struct sense_data sense_data;
12898c2ecf20Sopenharmony_ci	u32		block_size;
12908c2ecf20Sopenharmony_ci	u8		identifier[16];
12918c2ecf20Sopenharmony_ci};
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_cistruct fib {
12948c2ecf20Sopenharmony_ci	void			*next;	/* this is used by the allocator */
12958c2ecf20Sopenharmony_ci	s16			type;
12968c2ecf20Sopenharmony_ci	s16			size;
12978c2ecf20Sopenharmony_ci	/*
12988c2ecf20Sopenharmony_ci	 *	The Adapter that this I/O is destined for.
12998c2ecf20Sopenharmony_ci	 */
13008c2ecf20Sopenharmony_ci	struct aac_dev		*dev;
13018c2ecf20Sopenharmony_ci	/*
13028c2ecf20Sopenharmony_ci	 *	This is the event the sendfib routine will wait on if the
13038c2ecf20Sopenharmony_ci	 *	caller did not pass one and this is synch io.
13048c2ecf20Sopenharmony_ci	 */
13058c2ecf20Sopenharmony_ci	struct completion	event_wait;
13068c2ecf20Sopenharmony_ci	spinlock_t		event_lock;
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_ci	u32			done;	/* gets set to 1 when fib is complete */
13098c2ecf20Sopenharmony_ci	fib_callback		callback;
13108c2ecf20Sopenharmony_ci	void			*callback_data;
13118c2ecf20Sopenharmony_ci	u32			flags; // u32 dmb was ulong
13128c2ecf20Sopenharmony_ci	/*
13138c2ecf20Sopenharmony_ci	 *	And for the internal issue/reply queues (we may be able
13148c2ecf20Sopenharmony_ci	 *	to merge these two)
13158c2ecf20Sopenharmony_ci	 */
13168c2ecf20Sopenharmony_ci	struct list_head	fiblink;
13178c2ecf20Sopenharmony_ci	void			*data;
13188c2ecf20Sopenharmony_ci	u32			vector_no;
13198c2ecf20Sopenharmony_ci	struct hw_fib		*hw_fib_va;	/* also used for native */
13208c2ecf20Sopenharmony_ci	dma_addr_t		hw_fib_pa;	/* physical address of hw_fib*/
13218c2ecf20Sopenharmony_ci	dma_addr_t		hw_sgl_pa;	/* extra sgl for native */
13228c2ecf20Sopenharmony_ci	dma_addr_t		hw_error_pa;	/* error buffer for native */
13238c2ecf20Sopenharmony_ci	u32			hbacmd_size;	/* cmd size for native */
13248c2ecf20Sopenharmony_ci};
13258c2ecf20Sopenharmony_ci
13268c2ecf20Sopenharmony_ci#define AAC_INIT			0
13278c2ecf20Sopenharmony_ci#define AAC_RESCAN			1
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci#define AAC_DEVTYPE_RAID_MEMBER	1
13308c2ecf20Sopenharmony_ci#define AAC_DEVTYPE_ARC_RAW		2
13318c2ecf20Sopenharmony_ci#define AAC_DEVTYPE_NATIVE_RAW		3
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_ci#define AAC_RESCAN_DELAY		(10 * HZ)
13348c2ecf20Sopenharmony_ci
13358c2ecf20Sopenharmony_cistruct aac_hba_map_info {
13368c2ecf20Sopenharmony_ci	__le32	rmw_nexus;		/* nexus for native HBA devices */
13378c2ecf20Sopenharmony_ci	u8		devtype;	/* device type */
13388c2ecf20Sopenharmony_ci	s8		reset_state;	/* 0 - no reset, 1..x - */
13398c2ecf20Sopenharmony_ci					/* after xth TM LUN reset */
13408c2ecf20Sopenharmony_ci	u16		qd_limit;
13418c2ecf20Sopenharmony_ci	u32		scan_counter;
13428c2ecf20Sopenharmony_ci	struct aac_ciss_identify_pd  *safw_identify_resp;
13438c2ecf20Sopenharmony_ci};
13448c2ecf20Sopenharmony_ci
13458c2ecf20Sopenharmony_ci/*
13468c2ecf20Sopenharmony_ci *	Adapter Information Block
13478c2ecf20Sopenharmony_ci *
13488c2ecf20Sopenharmony_ci *	This is returned by the RequestAdapterInfo block
13498c2ecf20Sopenharmony_ci */
13508c2ecf20Sopenharmony_ci
13518c2ecf20Sopenharmony_cistruct aac_adapter_info
13528c2ecf20Sopenharmony_ci{
13538c2ecf20Sopenharmony_ci	__le32	platform;
13548c2ecf20Sopenharmony_ci	__le32	cpu;
13558c2ecf20Sopenharmony_ci	__le32	subcpu;
13568c2ecf20Sopenharmony_ci	__le32	clock;
13578c2ecf20Sopenharmony_ci	__le32	execmem;
13588c2ecf20Sopenharmony_ci	__le32	buffermem;
13598c2ecf20Sopenharmony_ci	__le32	totalmem;
13608c2ecf20Sopenharmony_ci	__le32	kernelrev;
13618c2ecf20Sopenharmony_ci	__le32	kernelbuild;
13628c2ecf20Sopenharmony_ci	__le32	monitorrev;
13638c2ecf20Sopenharmony_ci	__le32	monitorbuild;
13648c2ecf20Sopenharmony_ci	__le32	hwrev;
13658c2ecf20Sopenharmony_ci	__le32	hwbuild;
13668c2ecf20Sopenharmony_ci	__le32	biosrev;
13678c2ecf20Sopenharmony_ci	__le32	biosbuild;
13688c2ecf20Sopenharmony_ci	__le32	cluster;
13698c2ecf20Sopenharmony_ci	__le32	clusterchannelmask;
13708c2ecf20Sopenharmony_ci	__le32	serial[2];
13718c2ecf20Sopenharmony_ci	__le32	battery;
13728c2ecf20Sopenharmony_ci	__le32	options;
13738c2ecf20Sopenharmony_ci	__le32	OEM;
13748c2ecf20Sopenharmony_ci};
13758c2ecf20Sopenharmony_ci
13768c2ecf20Sopenharmony_cistruct aac_supplement_adapter_info
13778c2ecf20Sopenharmony_ci{
13788c2ecf20Sopenharmony_ci	u8	adapter_type_text[17+1];
13798c2ecf20Sopenharmony_ci	u8	pad[2];
13808c2ecf20Sopenharmony_ci	__le32	flash_memory_byte_size;
13818c2ecf20Sopenharmony_ci	__le32	flash_image_id;
13828c2ecf20Sopenharmony_ci	__le32	max_number_ports;
13838c2ecf20Sopenharmony_ci	__le32	version;
13848c2ecf20Sopenharmony_ci	__le32	feature_bits;
13858c2ecf20Sopenharmony_ci	u8	slot_number;
13868c2ecf20Sopenharmony_ci	u8	reserved_pad0[3];
13878c2ecf20Sopenharmony_ci	u8	build_date[12];
13888c2ecf20Sopenharmony_ci	__le32	current_number_ports;
13898c2ecf20Sopenharmony_ci	struct {
13908c2ecf20Sopenharmony_ci		u8	assembly_pn[8];
13918c2ecf20Sopenharmony_ci		u8	fru_pn[8];
13928c2ecf20Sopenharmony_ci		u8	battery_fru_pn[8];
13938c2ecf20Sopenharmony_ci		u8	ec_version_string[8];
13948c2ecf20Sopenharmony_ci		u8	tsid[12];
13958c2ecf20Sopenharmony_ci	}	vpd_info;
13968c2ecf20Sopenharmony_ci	__le32	flash_firmware_revision;
13978c2ecf20Sopenharmony_ci	__le32	flash_firmware_build;
13988c2ecf20Sopenharmony_ci	__le32	raid_type_morph_options;
13998c2ecf20Sopenharmony_ci	__le32	flash_firmware_boot_revision;
14008c2ecf20Sopenharmony_ci	__le32	flash_firmware_boot_build;
14018c2ecf20Sopenharmony_ci	u8	mfg_pcba_serial_no[12];
14028c2ecf20Sopenharmony_ci	u8	mfg_wwn_name[8];
14038c2ecf20Sopenharmony_ci	__le32	supported_options2;
14048c2ecf20Sopenharmony_ci	__le32	struct_expansion;
14058c2ecf20Sopenharmony_ci	/* StructExpansion == 1 */
14068c2ecf20Sopenharmony_ci	__le32	feature_bits3;
14078c2ecf20Sopenharmony_ci	__le32	supported_performance_modes;
14088c2ecf20Sopenharmony_ci	u8	host_bus_type;		/* uses HOST_BUS_TYPE_xxx defines */
14098c2ecf20Sopenharmony_ci	u8	host_bus_width;		/* actual width in bits or links */
14108c2ecf20Sopenharmony_ci	u16	host_bus_speed;		/* actual bus speed/link rate in MHz */
14118c2ecf20Sopenharmony_ci	u8	max_rrc_drives;		/* max. number of ITP-RRC drives/pool */
14128c2ecf20Sopenharmony_ci	u8	max_disk_xtasks;	/* max. possible num of DiskX Tasks */
14138c2ecf20Sopenharmony_ci
14148c2ecf20Sopenharmony_ci	u8	cpld_ver_loaded;
14158c2ecf20Sopenharmony_ci	u8	cpld_ver_in_flash;
14168c2ecf20Sopenharmony_ci
14178c2ecf20Sopenharmony_ci	__le64	max_rrc_capacity;
14188c2ecf20Sopenharmony_ci	__le32	compiled_max_hist_log_level;
14198c2ecf20Sopenharmony_ci	u8	custom_board_name[12];
14208c2ecf20Sopenharmony_ci	u16	supported_cntlr_mode;	/* identify supported controller mode */
14218c2ecf20Sopenharmony_ci	u16	reserved_for_future16;
14228c2ecf20Sopenharmony_ci	__le32	supported_options3;	/* reserved for future options */
14238c2ecf20Sopenharmony_ci
14248c2ecf20Sopenharmony_ci	__le16	virt_device_bus;		/* virt. SCSI device for Thor */
14258c2ecf20Sopenharmony_ci	__le16	virt_device_target;
14268c2ecf20Sopenharmony_ci	__le16	virt_device_lun;
14278c2ecf20Sopenharmony_ci	__le16	unused;
14288c2ecf20Sopenharmony_ci	__le32	reserved_for_future_growth[68];
14298c2ecf20Sopenharmony_ci
14308c2ecf20Sopenharmony_ci};
14318c2ecf20Sopenharmony_ci#define AAC_FEATURE_FALCON	cpu_to_le32(0x00000010)
14328c2ecf20Sopenharmony_ci#define AAC_FEATURE_JBOD	cpu_to_le32(0x08000000)
14338c2ecf20Sopenharmony_ci/* SupportedOptions2 */
14348c2ecf20Sopenharmony_ci#define AAC_OPTION_MU_RESET		cpu_to_le32(0x00000001)
14358c2ecf20Sopenharmony_ci#define AAC_OPTION_IGNORE_RESET		cpu_to_le32(0x00000002)
14368c2ecf20Sopenharmony_ci#define AAC_OPTION_POWER_MANAGEMENT	cpu_to_le32(0x00000004)
14378c2ecf20Sopenharmony_ci#define AAC_OPTION_DOORBELL_RESET	cpu_to_le32(0x00004000)
14388c2ecf20Sopenharmony_ci/* 4KB sector size */
14398c2ecf20Sopenharmony_ci#define AAC_OPTION_VARIABLE_BLOCK_SIZE	cpu_to_le32(0x00040000)
14408c2ecf20Sopenharmony_ci/* 240 simple volume support */
14418c2ecf20Sopenharmony_ci#define AAC_OPTION_SUPPORTED_240_VOLUMES cpu_to_le32(0x10000000)
14428c2ecf20Sopenharmony_ci/*
14438c2ecf20Sopenharmony_ci * Supports FIB dump sync command send prior to IOP_RESET
14448c2ecf20Sopenharmony_ci */
14458c2ecf20Sopenharmony_ci#define AAC_OPTION_SUPPORTED3_IOP_RESET_FIB_DUMP	cpu_to_le32(0x00004000)
14468c2ecf20Sopenharmony_ci#define AAC_SIS_VERSION_V3	3
14478c2ecf20Sopenharmony_ci#define AAC_SIS_SLOT_UNKNOWN	0xFF
14488c2ecf20Sopenharmony_ci
14498c2ecf20Sopenharmony_ci#define GetBusInfo 0x00000009
14508c2ecf20Sopenharmony_cistruct aac_bus_info {
14518c2ecf20Sopenharmony_ci	__le32	Command;	/* VM_Ioctl */
14528c2ecf20Sopenharmony_ci	__le32	ObjType;	/* FT_DRIVE */
14538c2ecf20Sopenharmony_ci	__le32	MethodId;	/* 1 = SCSI Layer */
14548c2ecf20Sopenharmony_ci	__le32	ObjectId;	/* Handle */
14558c2ecf20Sopenharmony_ci	__le32	CtlCmd;		/* GetBusInfo */
14568c2ecf20Sopenharmony_ci};
14578c2ecf20Sopenharmony_ci
14588c2ecf20Sopenharmony_cistruct aac_bus_info_response {
14598c2ecf20Sopenharmony_ci	__le32	Status;		/* ST_OK */
14608c2ecf20Sopenharmony_ci	__le32	ObjType;
14618c2ecf20Sopenharmony_ci	__le32	MethodId;	/* unused */
14628c2ecf20Sopenharmony_ci	__le32	ObjectId;	/* unused */
14638c2ecf20Sopenharmony_ci	__le32	CtlCmd;		/* unused */
14648c2ecf20Sopenharmony_ci	__le32	ProbeComplete;
14658c2ecf20Sopenharmony_ci	__le32	BusCount;
14668c2ecf20Sopenharmony_ci	__le32	TargetsPerBus;
14678c2ecf20Sopenharmony_ci	u8	InitiatorBusId[10];
14688c2ecf20Sopenharmony_ci	u8	BusValid[10];
14698c2ecf20Sopenharmony_ci};
14708c2ecf20Sopenharmony_ci
14718c2ecf20Sopenharmony_ci/*
14728c2ecf20Sopenharmony_ci * Battery platforms
14738c2ecf20Sopenharmony_ci */
14748c2ecf20Sopenharmony_ci#define AAC_BAT_REQ_PRESENT	(1)
14758c2ecf20Sopenharmony_ci#define AAC_BAT_REQ_NOTPRESENT	(2)
14768c2ecf20Sopenharmony_ci#define AAC_BAT_OPT_PRESENT	(3)
14778c2ecf20Sopenharmony_ci#define AAC_BAT_OPT_NOTPRESENT	(4)
14788c2ecf20Sopenharmony_ci#define AAC_BAT_NOT_SUPPORTED	(5)
14798c2ecf20Sopenharmony_ci/*
14808c2ecf20Sopenharmony_ci * cpu types
14818c2ecf20Sopenharmony_ci */
14828c2ecf20Sopenharmony_ci#define AAC_CPU_SIMULATOR	(1)
14838c2ecf20Sopenharmony_ci#define AAC_CPU_I960		(2)
14848c2ecf20Sopenharmony_ci#define AAC_CPU_STRONGARM	(3)
14858c2ecf20Sopenharmony_ci
14868c2ecf20Sopenharmony_ci/*
14878c2ecf20Sopenharmony_ci * Supported Options
14888c2ecf20Sopenharmony_ci */
14898c2ecf20Sopenharmony_ci#define AAC_OPT_SNAPSHOT		cpu_to_le32(1)
14908c2ecf20Sopenharmony_ci#define AAC_OPT_CLUSTERS		cpu_to_le32(1<<1)
14918c2ecf20Sopenharmony_ci#define AAC_OPT_WRITE_CACHE		cpu_to_le32(1<<2)
14928c2ecf20Sopenharmony_ci#define AAC_OPT_64BIT_DATA		cpu_to_le32(1<<3)
14938c2ecf20Sopenharmony_ci#define AAC_OPT_HOST_TIME_FIB		cpu_to_le32(1<<4)
14948c2ecf20Sopenharmony_ci#define AAC_OPT_RAID50			cpu_to_le32(1<<5)
14958c2ecf20Sopenharmony_ci#define AAC_OPT_4GB_WINDOW		cpu_to_le32(1<<6)
14968c2ecf20Sopenharmony_ci#define AAC_OPT_SCSI_UPGRADEABLE	cpu_to_le32(1<<7)
14978c2ecf20Sopenharmony_ci#define AAC_OPT_SOFT_ERR_REPORT		cpu_to_le32(1<<8)
14988c2ecf20Sopenharmony_ci#define AAC_OPT_SUPPORTED_RECONDITION	cpu_to_le32(1<<9)
14998c2ecf20Sopenharmony_ci#define AAC_OPT_SGMAP_HOST64		cpu_to_le32(1<<10)
15008c2ecf20Sopenharmony_ci#define AAC_OPT_ALARM			cpu_to_le32(1<<11)
15018c2ecf20Sopenharmony_ci#define AAC_OPT_NONDASD			cpu_to_le32(1<<12)
15028c2ecf20Sopenharmony_ci#define AAC_OPT_SCSI_MANAGED		cpu_to_le32(1<<13)
15038c2ecf20Sopenharmony_ci#define AAC_OPT_RAID_SCSI_MODE		cpu_to_le32(1<<14)
15048c2ecf20Sopenharmony_ci#define AAC_OPT_SUPPLEMENT_ADAPTER_INFO	cpu_to_le32(1<<16)
15058c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM		cpu_to_le32(1<<17)
15068c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM_64		cpu_to_le32(1<<18)
15078c2ecf20Sopenharmony_ci#define AAC_OPT_EXTENDED		cpu_to_le32(1<<23)
15088c2ecf20Sopenharmony_ci#define AAC_OPT_NATIVE_HBA		cpu_to_le32(1<<25)
15098c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM_TYPE1		cpu_to_le32(1<<28)
15108c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM_TYPE2		cpu_to_le32(1<<29)
15118c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM_TYPE3		cpu_to_le32(1<<30)
15128c2ecf20Sopenharmony_ci#define AAC_OPT_NEW_COMM_TYPE4		cpu_to_le32(1<<31)
15138c2ecf20Sopenharmony_ci
15148c2ecf20Sopenharmony_ci#define AAC_COMM_PRODUCER		0
15158c2ecf20Sopenharmony_ci#define AAC_COMM_MESSAGE		1
15168c2ecf20Sopenharmony_ci#define AAC_COMM_MESSAGE_TYPE1		3
15178c2ecf20Sopenharmony_ci#define AAC_COMM_MESSAGE_TYPE2		4
15188c2ecf20Sopenharmony_ci#define AAC_COMM_MESSAGE_TYPE3		5
15198c2ecf20Sopenharmony_ci
15208c2ecf20Sopenharmony_ci#define AAC_EXTOPT_SA_FIRMWARE		cpu_to_le32(1<<1)
15218c2ecf20Sopenharmony_ci#define AAC_EXTOPT_SOFT_RESET		cpu_to_le32(1<<16)
15228c2ecf20Sopenharmony_ci
15238c2ecf20Sopenharmony_ci/* MSIX context */
15248c2ecf20Sopenharmony_cistruct aac_msix_ctx {
15258c2ecf20Sopenharmony_ci	int		vector_no;
15268c2ecf20Sopenharmony_ci	struct aac_dev	*dev;
15278c2ecf20Sopenharmony_ci};
15288c2ecf20Sopenharmony_ci
15298c2ecf20Sopenharmony_cistruct aac_dev
15308c2ecf20Sopenharmony_ci{
15318c2ecf20Sopenharmony_ci	struct list_head	entry;
15328c2ecf20Sopenharmony_ci	const char		*name;
15338c2ecf20Sopenharmony_ci	int			id;
15348c2ecf20Sopenharmony_ci
15358c2ecf20Sopenharmony_ci	/*
15368c2ecf20Sopenharmony_ci	 *	negotiated FIB settings
15378c2ecf20Sopenharmony_ci	 */
15388c2ecf20Sopenharmony_ci	unsigned int		max_fib_size;
15398c2ecf20Sopenharmony_ci	unsigned int		sg_tablesize;
15408c2ecf20Sopenharmony_ci	unsigned int		max_num_aif;
15418c2ecf20Sopenharmony_ci
15428c2ecf20Sopenharmony_ci	unsigned int		max_cmd_size;	/* max_fib_size or MAX_NATIVE */
15438c2ecf20Sopenharmony_ci
15448c2ecf20Sopenharmony_ci	/*
15458c2ecf20Sopenharmony_ci	 *	Map for 128 fib objects (64k)
15468c2ecf20Sopenharmony_ci	 */
15478c2ecf20Sopenharmony_ci	dma_addr_t		hw_fib_pa;	/* also used for native cmd */
15488c2ecf20Sopenharmony_ci	struct hw_fib		*hw_fib_va;	/* also used for native cmd */
15498c2ecf20Sopenharmony_ci	struct hw_fib		*aif_base_va;
15508c2ecf20Sopenharmony_ci	/*
15518c2ecf20Sopenharmony_ci	 *	Fib Headers
15528c2ecf20Sopenharmony_ci	 */
15538c2ecf20Sopenharmony_ci	struct fib              *fibs;
15548c2ecf20Sopenharmony_ci
15558c2ecf20Sopenharmony_ci	struct fib		*free_fib;
15568c2ecf20Sopenharmony_ci	spinlock_t		fib_lock;
15578c2ecf20Sopenharmony_ci
15588c2ecf20Sopenharmony_ci	struct mutex		ioctl_mutex;
15598c2ecf20Sopenharmony_ci	struct mutex		scan_mutex;
15608c2ecf20Sopenharmony_ci	struct aac_queue_block *queues;
15618c2ecf20Sopenharmony_ci	/*
15628c2ecf20Sopenharmony_ci	 *	The user API will use an IOCTL to register itself to receive
15638c2ecf20Sopenharmony_ci	 *	FIBs from the adapter.  The following list is used to keep
15648c2ecf20Sopenharmony_ci	 *	track of all the threads that have requested these FIBs.  The
15658c2ecf20Sopenharmony_ci	 *	mutex is used to synchronize access to all data associated
15668c2ecf20Sopenharmony_ci	 *	with the adapter fibs.
15678c2ecf20Sopenharmony_ci	 */
15688c2ecf20Sopenharmony_ci	struct list_head	fib_list;
15698c2ecf20Sopenharmony_ci
15708c2ecf20Sopenharmony_ci	struct adapter_ops	a_ops;
15718c2ecf20Sopenharmony_ci	unsigned long		fsrev;		/* Main driver's revision number */
15728c2ecf20Sopenharmony_ci
15738c2ecf20Sopenharmony_ci	resource_size_t		base_start;	/* main IO base */
15748c2ecf20Sopenharmony_ci	resource_size_t		dbg_base;	/* address of UART
15758c2ecf20Sopenharmony_ci						 * debug buffer */
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_ci	resource_size_t		base_size, dbg_size;	/* Size of
15788c2ecf20Sopenharmony_ci							 *  mapped in region */
15798c2ecf20Sopenharmony_ci	/*
15808c2ecf20Sopenharmony_ci	 * Holds initialization info
15818c2ecf20Sopenharmony_ci	 * to communicate with adapter
15828c2ecf20Sopenharmony_ci	 */
15838c2ecf20Sopenharmony_ci	union aac_init		*init;
15848c2ecf20Sopenharmony_ci	dma_addr_t		init_pa;	/* Holds physical address of the init struct */
15858c2ecf20Sopenharmony_ci	/* response queue (if AAC_COMM_MESSAGE_TYPE1) */
15868c2ecf20Sopenharmony_ci	__le32			*host_rrq;
15878c2ecf20Sopenharmony_ci	dma_addr_t		host_rrq_pa;	/* phys. address */
15888c2ecf20Sopenharmony_ci	/* index into rrq buffer */
15898c2ecf20Sopenharmony_ci	u32			host_rrq_idx[AAC_MAX_MSIX];
15908c2ecf20Sopenharmony_ci	atomic_t		rrq_outstanding[AAC_MAX_MSIX];
15918c2ecf20Sopenharmony_ci	u32			fibs_pushed_no;
15928c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;		/* Our PCI interface */
15938c2ecf20Sopenharmony_ci	/* pointer to buffer used for printf's from the adapter */
15948c2ecf20Sopenharmony_ci	void			*printfbuf;
15958c2ecf20Sopenharmony_ci	void			*comm_addr;	/* Base address of Comm area */
15968c2ecf20Sopenharmony_ci	dma_addr_t		comm_phys;	/* Physical Address of Comm area */
15978c2ecf20Sopenharmony_ci	size_t			comm_size;
15988c2ecf20Sopenharmony_ci
15998c2ecf20Sopenharmony_ci	struct Scsi_Host	*scsi_host_ptr;
16008c2ecf20Sopenharmony_ci	int			maximum_num_containers;
16018c2ecf20Sopenharmony_ci	int			maximum_num_physicals;
16028c2ecf20Sopenharmony_ci	int			maximum_num_channels;
16038c2ecf20Sopenharmony_ci	struct fsa_dev_info	*fsa_dev;
16048c2ecf20Sopenharmony_ci	struct task_struct	*thread;
16058c2ecf20Sopenharmony_ci	struct delayed_work	safw_rescan_work;
16068c2ecf20Sopenharmony_ci	struct delayed_work	src_reinit_aif_worker;
16078c2ecf20Sopenharmony_ci	int			cardtype;
16088c2ecf20Sopenharmony_ci	/*
16098c2ecf20Sopenharmony_ci	 *This lock will protect the two 32-bit
16108c2ecf20Sopenharmony_ci	 *writes to the Inbound Queue
16118c2ecf20Sopenharmony_ci	 */
16128c2ecf20Sopenharmony_ci	spinlock_t		iq_lock;
16138c2ecf20Sopenharmony_ci
16148c2ecf20Sopenharmony_ci	/*
16158c2ecf20Sopenharmony_ci	 *	The following is the device specific extension.
16168c2ecf20Sopenharmony_ci	 */
16178c2ecf20Sopenharmony_ci#ifndef AAC_MIN_FOOTPRINT_SIZE
16188c2ecf20Sopenharmony_ci#	define AAC_MIN_FOOTPRINT_SIZE 8192
16198c2ecf20Sopenharmony_ci#	define AAC_MIN_SRC_BAR0_SIZE 0x400000
16208c2ecf20Sopenharmony_ci#	define AAC_MIN_SRC_BAR1_SIZE 0x800
16218c2ecf20Sopenharmony_ci#	define AAC_MIN_SRCV_BAR0_SIZE 0x100000
16228c2ecf20Sopenharmony_ci#	define AAC_MIN_SRCV_BAR1_SIZE 0x400
16238c2ecf20Sopenharmony_ci#endif
16248c2ecf20Sopenharmony_ci	union
16258c2ecf20Sopenharmony_ci	{
16268c2ecf20Sopenharmony_ci		struct sa_registers __iomem *sa;
16278c2ecf20Sopenharmony_ci		struct rx_registers __iomem *rx;
16288c2ecf20Sopenharmony_ci		struct rkt_registers __iomem *rkt;
16298c2ecf20Sopenharmony_ci		struct {
16308c2ecf20Sopenharmony_ci			struct src_registers __iomem *bar0;
16318c2ecf20Sopenharmony_ci			char __iomem *bar1;
16328c2ecf20Sopenharmony_ci		} src;
16338c2ecf20Sopenharmony_ci	} regs;
16348c2ecf20Sopenharmony_ci	volatile void __iomem *base, *dbg_base_mapped;
16358c2ecf20Sopenharmony_ci	volatile struct rx_inbound __iomem *IndexRegs;
16368c2ecf20Sopenharmony_ci	u32			OIMR; /* Mask Register Cache */
16378c2ecf20Sopenharmony_ci	/*
16388c2ecf20Sopenharmony_ci	 *	AIF thread states
16398c2ecf20Sopenharmony_ci	 */
16408c2ecf20Sopenharmony_ci	u32			aif_thread;
16418c2ecf20Sopenharmony_ci	struct aac_adapter_info adapter_info;
16428c2ecf20Sopenharmony_ci	struct aac_supplement_adapter_info supplement_adapter_info;
16438c2ecf20Sopenharmony_ci	/* These are in adapter info but they are in the io flow so
16448c2ecf20Sopenharmony_ci	 * lets break them out so we don't have to do an AND to check them
16458c2ecf20Sopenharmony_ci	 */
16468c2ecf20Sopenharmony_ci	u8			nondasd_support;
16478c2ecf20Sopenharmony_ci	u8			jbod;
16488c2ecf20Sopenharmony_ci	u8			cache_protected;
16498c2ecf20Sopenharmony_ci	u8			dac_support;
16508c2ecf20Sopenharmony_ci	u8			needs_dac;
16518c2ecf20Sopenharmony_ci	u8			raid_scsi_mode;
16528c2ecf20Sopenharmony_ci	u8			comm_interface;
16538c2ecf20Sopenharmony_ci	u8			raw_io_interface;
16548c2ecf20Sopenharmony_ci	u8			raw_io_64;
16558c2ecf20Sopenharmony_ci	u8			printf_enabled;
16568c2ecf20Sopenharmony_ci	u8			in_reset;
16578c2ecf20Sopenharmony_ci	u8			in_soft_reset;
16588c2ecf20Sopenharmony_ci	u8			msi;
16598c2ecf20Sopenharmony_ci	u8			sa_firmware;
16608c2ecf20Sopenharmony_ci	int			management_fib_count;
16618c2ecf20Sopenharmony_ci	spinlock_t		manage_lock;
16628c2ecf20Sopenharmony_ci	spinlock_t		sync_lock;
16638c2ecf20Sopenharmony_ci	int			sync_mode;
16648c2ecf20Sopenharmony_ci	struct fib		*sync_fib;
16658c2ecf20Sopenharmony_ci	struct list_head	sync_fib_list;
16668c2ecf20Sopenharmony_ci	u32			doorbell_mask;
16678c2ecf20Sopenharmony_ci	u32			max_msix;	/* max. MSI-X vectors */
16688c2ecf20Sopenharmony_ci	u32			vector_cap;	/* MSI-X vector capab.*/
16698c2ecf20Sopenharmony_ci	int			msi_enabled;	/* MSI/MSI-X enabled */
16708c2ecf20Sopenharmony_ci	atomic_t		msix_counter;
16718c2ecf20Sopenharmony_ci	u32			scan_counter;
16728c2ecf20Sopenharmony_ci	struct msix_entry	msixentry[AAC_MAX_MSIX];
16738c2ecf20Sopenharmony_ci	struct aac_msix_ctx	aac_msix[AAC_MAX_MSIX]; /* context */
16748c2ecf20Sopenharmony_ci	struct aac_hba_map_info	hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS];
16758c2ecf20Sopenharmony_ci	struct aac_ciss_phys_luns_resp *safw_phys_luns;
16768c2ecf20Sopenharmony_ci	u8			adapter_shutdown;
16778c2ecf20Sopenharmony_ci	u32			handle_pci_error;
16788c2ecf20Sopenharmony_ci	bool			init_reset;
16798c2ecf20Sopenharmony_ci	u8			soft_reset_support;
16808c2ecf20Sopenharmony_ci};
16818c2ecf20Sopenharmony_ci
16828c2ecf20Sopenharmony_ci#define aac_adapter_interrupt(dev) \
16838c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_interrupt(dev)
16848c2ecf20Sopenharmony_ci
16858c2ecf20Sopenharmony_ci#define aac_adapter_notify(dev, event) \
16868c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_notify(dev, event)
16878c2ecf20Sopenharmony_ci
16888c2ecf20Sopenharmony_ci#define aac_adapter_disable_int(dev) \
16898c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_disable_int(dev)
16908c2ecf20Sopenharmony_ci
16918c2ecf20Sopenharmony_ci#define aac_adapter_enable_int(dev) \
16928c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_enable_int(dev)
16938c2ecf20Sopenharmony_ci
16948c2ecf20Sopenharmony_ci#define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \
16958c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4)
16968c2ecf20Sopenharmony_ci
16978c2ecf20Sopenharmony_ci#define aac_adapter_restart(dev, bled, reset_type) \
16988c2ecf20Sopenharmony_ci	((dev)->a_ops.adapter_restart(dev, bled, reset_type))
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_ci#define aac_adapter_start(dev) \
17018c2ecf20Sopenharmony_ci	((dev)->a_ops.adapter_start(dev))
17028c2ecf20Sopenharmony_ci
17038c2ecf20Sopenharmony_ci#define aac_adapter_ioremap(dev, size) \
17048c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_ioremap(dev, size)
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_ci#define aac_adapter_deliver(fib) \
17078c2ecf20Sopenharmony_ci	((fib)->dev)->a_ops.adapter_deliver(fib)
17088c2ecf20Sopenharmony_ci
17098c2ecf20Sopenharmony_ci#define aac_adapter_bounds(dev,cmd,lba) \
17108c2ecf20Sopenharmony_ci	dev->a_ops.adapter_bounds(dev,cmd,lba)
17118c2ecf20Sopenharmony_ci
17128c2ecf20Sopenharmony_ci#define aac_adapter_read(fib,cmd,lba,count) \
17138c2ecf20Sopenharmony_ci	((fib)->dev)->a_ops.adapter_read(fib,cmd,lba,count)
17148c2ecf20Sopenharmony_ci
17158c2ecf20Sopenharmony_ci#define aac_adapter_write(fib,cmd,lba,count,fua) \
17168c2ecf20Sopenharmony_ci	((fib)->dev)->a_ops.adapter_write(fib,cmd,lba,count,fua)
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_ci#define aac_adapter_scsi(fib,cmd) \
17198c2ecf20Sopenharmony_ci	((fib)->dev)->a_ops.adapter_scsi(fib,cmd)
17208c2ecf20Sopenharmony_ci
17218c2ecf20Sopenharmony_ci#define aac_adapter_comm(dev,comm) \
17228c2ecf20Sopenharmony_ci	(dev)->a_ops.adapter_comm(dev, comm)
17238c2ecf20Sopenharmony_ci
17248c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_TIMED_OUT		(0x00000001)
17258c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG			(0x00000002)
17268c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_WAIT			(0x00000004)
17278c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_FASTRESP		(0x00000008)
17288c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_NATIVE_HBA		(0x00000010)
17298c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_NATIVE_HBA_TMF	(0x00000020)
17308c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_SCSI_CMD	(0x00000040)
17318c2ecf20Sopenharmony_ci#define FIB_CONTEXT_FLAG_EH_RESET	(0x00000080)
17328c2ecf20Sopenharmony_ci
17338c2ecf20Sopenharmony_ci/*
17348c2ecf20Sopenharmony_ci *	Define the command values
17358c2ecf20Sopenharmony_ci */
17368c2ecf20Sopenharmony_ci
17378c2ecf20Sopenharmony_ci#define		Null			0
17388c2ecf20Sopenharmony_ci#define		GetAttributes		1
17398c2ecf20Sopenharmony_ci#define		SetAttributes		2
17408c2ecf20Sopenharmony_ci#define		Lookup			3
17418c2ecf20Sopenharmony_ci#define		ReadLink		4
17428c2ecf20Sopenharmony_ci#define		Read			5
17438c2ecf20Sopenharmony_ci#define		Write			6
17448c2ecf20Sopenharmony_ci#define		Create			7
17458c2ecf20Sopenharmony_ci#define		MakeDirectory		8
17468c2ecf20Sopenharmony_ci#define		SymbolicLink		9
17478c2ecf20Sopenharmony_ci#define		MakeNode		10
17488c2ecf20Sopenharmony_ci#define		Removex			11
17498c2ecf20Sopenharmony_ci#define		RemoveDirectoryx	12
17508c2ecf20Sopenharmony_ci#define		Rename			13
17518c2ecf20Sopenharmony_ci#define		Link			14
17528c2ecf20Sopenharmony_ci#define		ReadDirectory		15
17538c2ecf20Sopenharmony_ci#define		ReadDirectoryPlus	16
17548c2ecf20Sopenharmony_ci#define		FileSystemStatus	17
17558c2ecf20Sopenharmony_ci#define		FileSystemInfo		18
17568c2ecf20Sopenharmony_ci#define		PathConfigure		19
17578c2ecf20Sopenharmony_ci#define		Commit			20
17588c2ecf20Sopenharmony_ci#define		Mount			21
17598c2ecf20Sopenharmony_ci#define		UnMount			22
17608c2ecf20Sopenharmony_ci#define		Newfs			23
17618c2ecf20Sopenharmony_ci#define		FsCheck			24
17628c2ecf20Sopenharmony_ci#define		FsSync			25
17638c2ecf20Sopenharmony_ci#define		SimReadWrite		26
17648c2ecf20Sopenharmony_ci#define		SetFileSystemStatus	27
17658c2ecf20Sopenharmony_ci#define		BlockRead		28
17668c2ecf20Sopenharmony_ci#define		BlockWrite		29
17678c2ecf20Sopenharmony_ci#define		NvramIoctl		30
17688c2ecf20Sopenharmony_ci#define		FsSyncWait		31
17698c2ecf20Sopenharmony_ci#define		ClearArchiveBit		32
17708c2ecf20Sopenharmony_ci#define		SetAcl			33
17718c2ecf20Sopenharmony_ci#define		GetAcl			34
17728c2ecf20Sopenharmony_ci#define		AssignAcl		35
17738c2ecf20Sopenharmony_ci#define		FaultInsertion		36	/* Fault Insertion Command */
17748c2ecf20Sopenharmony_ci#define		CrazyCache		37	/* Crazycache */
17758c2ecf20Sopenharmony_ci
17768c2ecf20Sopenharmony_ci#define		MAX_FSACOMMAND_NUM	38
17778c2ecf20Sopenharmony_ci
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_ci/*
17808c2ecf20Sopenharmony_ci *	Define the status returns. These are very unixlike although
17818c2ecf20Sopenharmony_ci *	most are not in fact used
17828c2ecf20Sopenharmony_ci */
17838c2ecf20Sopenharmony_ci
17848c2ecf20Sopenharmony_ci#define		ST_OK		0
17858c2ecf20Sopenharmony_ci#define		ST_PERM		1
17868c2ecf20Sopenharmony_ci#define		ST_NOENT	2
17878c2ecf20Sopenharmony_ci#define		ST_IO		5
17888c2ecf20Sopenharmony_ci#define		ST_NXIO		6
17898c2ecf20Sopenharmony_ci#define		ST_E2BIG	7
17908c2ecf20Sopenharmony_ci#define		ST_MEDERR	8
17918c2ecf20Sopenharmony_ci#define		ST_ACCES	13
17928c2ecf20Sopenharmony_ci#define		ST_EXIST	17
17938c2ecf20Sopenharmony_ci#define		ST_XDEV		18
17948c2ecf20Sopenharmony_ci#define		ST_NODEV	19
17958c2ecf20Sopenharmony_ci#define		ST_NOTDIR	20
17968c2ecf20Sopenharmony_ci#define		ST_ISDIR	21
17978c2ecf20Sopenharmony_ci#define		ST_INVAL	22
17988c2ecf20Sopenharmony_ci#define		ST_FBIG		27
17998c2ecf20Sopenharmony_ci#define		ST_NOSPC	28
18008c2ecf20Sopenharmony_ci#define		ST_ROFS		30
18018c2ecf20Sopenharmony_ci#define		ST_MLINK	31
18028c2ecf20Sopenharmony_ci#define		ST_WOULDBLOCK	35
18038c2ecf20Sopenharmony_ci#define		ST_NAMETOOLONG	63
18048c2ecf20Sopenharmony_ci#define		ST_NOTEMPTY	66
18058c2ecf20Sopenharmony_ci#define		ST_DQUOT	69
18068c2ecf20Sopenharmony_ci#define		ST_STALE	70
18078c2ecf20Sopenharmony_ci#define		ST_REMOTE	71
18088c2ecf20Sopenharmony_ci#define		ST_NOT_READY	72
18098c2ecf20Sopenharmony_ci#define		ST_BADHANDLE	10001
18108c2ecf20Sopenharmony_ci#define		ST_NOT_SYNC	10002
18118c2ecf20Sopenharmony_ci#define		ST_BAD_COOKIE	10003
18128c2ecf20Sopenharmony_ci#define		ST_NOTSUPP	10004
18138c2ecf20Sopenharmony_ci#define		ST_TOOSMALL	10005
18148c2ecf20Sopenharmony_ci#define		ST_SERVERFAULT	10006
18158c2ecf20Sopenharmony_ci#define		ST_BADTYPE	10007
18168c2ecf20Sopenharmony_ci#define		ST_JUKEBOX	10008
18178c2ecf20Sopenharmony_ci#define		ST_NOTMOUNTED	10009
18188c2ecf20Sopenharmony_ci#define		ST_MAINTMODE	10010
18198c2ecf20Sopenharmony_ci#define		ST_STALEACL	10011
18208c2ecf20Sopenharmony_ci
18218c2ecf20Sopenharmony_ci/*
18228c2ecf20Sopenharmony_ci *	On writes how does the client want the data written.
18238c2ecf20Sopenharmony_ci */
18248c2ecf20Sopenharmony_ci
18258c2ecf20Sopenharmony_ci#define	CACHE_CSTABLE		1
18268c2ecf20Sopenharmony_ci#define CACHE_UNSTABLE		2
18278c2ecf20Sopenharmony_ci
18288c2ecf20Sopenharmony_ci/*
18298c2ecf20Sopenharmony_ci *	Lets the client know at which level the data was committed on
18308c2ecf20Sopenharmony_ci *	a write request
18318c2ecf20Sopenharmony_ci */
18328c2ecf20Sopenharmony_ci
18338c2ecf20Sopenharmony_ci#define	CMFILE_SYNCH_NVRAM	1
18348c2ecf20Sopenharmony_ci#define	CMDATA_SYNCH_NVRAM	2
18358c2ecf20Sopenharmony_ci#define	CMFILE_SYNCH		3
18368c2ecf20Sopenharmony_ci#define CMDATA_SYNCH		4
18378c2ecf20Sopenharmony_ci#define CMUNSTABLE		5
18388c2ecf20Sopenharmony_ci
18398c2ecf20Sopenharmony_ci#define	RIO_TYPE_WRITE 			0x0000
18408c2ecf20Sopenharmony_ci#define	RIO_TYPE_READ			0x0001
18418c2ecf20Sopenharmony_ci#define	RIO_SUREWRITE			0x0008
18428c2ecf20Sopenharmony_ci
18438c2ecf20Sopenharmony_ci#define RIO2_IO_TYPE			0x0003
18448c2ecf20Sopenharmony_ci#define RIO2_IO_TYPE_WRITE		0x0000
18458c2ecf20Sopenharmony_ci#define RIO2_IO_TYPE_READ		0x0001
18468c2ecf20Sopenharmony_ci#define RIO2_IO_TYPE_VERIFY		0x0002
18478c2ecf20Sopenharmony_ci#define RIO2_IO_ERROR			0x0004
18488c2ecf20Sopenharmony_ci#define RIO2_IO_SUREWRITE		0x0008
18498c2ecf20Sopenharmony_ci#define RIO2_SGL_CONFORMANT		0x0010
18508c2ecf20Sopenharmony_ci#define RIO2_SG_FORMAT			0xF000
18518c2ecf20Sopenharmony_ci#define RIO2_SG_FORMAT_ARC		0x0000
18528c2ecf20Sopenharmony_ci#define RIO2_SG_FORMAT_SRL		0x1000
18538c2ecf20Sopenharmony_ci#define RIO2_SG_FORMAT_IEEE1212		0x2000
18548c2ecf20Sopenharmony_ci
18558c2ecf20Sopenharmony_cistruct aac_read
18568c2ecf20Sopenharmony_ci{
18578c2ecf20Sopenharmony_ci	__le32		command;
18588c2ecf20Sopenharmony_ci	__le32		cid;
18598c2ecf20Sopenharmony_ci	__le32		block;
18608c2ecf20Sopenharmony_ci	__le32		count;
18618c2ecf20Sopenharmony_ci	struct sgmap	sg;	// Must be last in struct because it is variable
18628c2ecf20Sopenharmony_ci};
18638c2ecf20Sopenharmony_ci
18648c2ecf20Sopenharmony_cistruct aac_read64
18658c2ecf20Sopenharmony_ci{
18668c2ecf20Sopenharmony_ci	__le32		command;
18678c2ecf20Sopenharmony_ci	__le16		cid;
18688c2ecf20Sopenharmony_ci	__le16		sector_count;
18698c2ecf20Sopenharmony_ci	__le32		block;
18708c2ecf20Sopenharmony_ci	__le16		pad;
18718c2ecf20Sopenharmony_ci	__le16		flags;
18728c2ecf20Sopenharmony_ci	struct sgmap64	sg;	// Must be last in struct because it is variable
18738c2ecf20Sopenharmony_ci};
18748c2ecf20Sopenharmony_ci
18758c2ecf20Sopenharmony_cistruct aac_read_reply
18768c2ecf20Sopenharmony_ci{
18778c2ecf20Sopenharmony_ci	__le32		status;
18788c2ecf20Sopenharmony_ci	__le32		count;
18798c2ecf20Sopenharmony_ci};
18808c2ecf20Sopenharmony_ci
18818c2ecf20Sopenharmony_cistruct aac_write
18828c2ecf20Sopenharmony_ci{
18838c2ecf20Sopenharmony_ci	__le32		command;
18848c2ecf20Sopenharmony_ci	__le32		cid;
18858c2ecf20Sopenharmony_ci	__le32		block;
18868c2ecf20Sopenharmony_ci	__le32		count;
18878c2ecf20Sopenharmony_ci	__le32		stable;	// Not used
18888c2ecf20Sopenharmony_ci	struct sgmap	sg;	// Must be last in struct because it is variable
18898c2ecf20Sopenharmony_ci};
18908c2ecf20Sopenharmony_ci
18918c2ecf20Sopenharmony_cistruct aac_write64
18928c2ecf20Sopenharmony_ci{
18938c2ecf20Sopenharmony_ci	__le32		command;
18948c2ecf20Sopenharmony_ci	__le16		cid;
18958c2ecf20Sopenharmony_ci	__le16		sector_count;
18968c2ecf20Sopenharmony_ci	__le32		block;
18978c2ecf20Sopenharmony_ci	__le16		pad;
18988c2ecf20Sopenharmony_ci	__le16		flags;
18998c2ecf20Sopenharmony_ci	struct sgmap64	sg;	// Must be last in struct because it is variable
19008c2ecf20Sopenharmony_ci};
19018c2ecf20Sopenharmony_cistruct aac_write_reply
19028c2ecf20Sopenharmony_ci{
19038c2ecf20Sopenharmony_ci	__le32		status;
19048c2ecf20Sopenharmony_ci	__le32		count;
19058c2ecf20Sopenharmony_ci	__le32		committed;
19068c2ecf20Sopenharmony_ci};
19078c2ecf20Sopenharmony_ci
19088c2ecf20Sopenharmony_cistruct aac_raw_io
19098c2ecf20Sopenharmony_ci{
19108c2ecf20Sopenharmony_ci	__le32		block[2];
19118c2ecf20Sopenharmony_ci	__le32		count;
19128c2ecf20Sopenharmony_ci	__le16		cid;
19138c2ecf20Sopenharmony_ci	__le16		flags;		/* 00 W, 01 R */
19148c2ecf20Sopenharmony_ci	__le16		bpTotal;	/* reserved for F/W use */
19158c2ecf20Sopenharmony_ci	__le16		bpComplete;	/* reserved for F/W use */
19168c2ecf20Sopenharmony_ci	struct sgmapraw	sg;
19178c2ecf20Sopenharmony_ci};
19188c2ecf20Sopenharmony_ci
19198c2ecf20Sopenharmony_cistruct aac_raw_io2 {
19208c2ecf20Sopenharmony_ci	__le32		blockLow;
19218c2ecf20Sopenharmony_ci	__le32		blockHigh;
19228c2ecf20Sopenharmony_ci	__le32		byteCount;
19238c2ecf20Sopenharmony_ci	__le16		cid;
19248c2ecf20Sopenharmony_ci	__le16		flags;		/* RIO2 flags */
19258c2ecf20Sopenharmony_ci	__le32		sgeFirstSize;	/* size of first sge el. */
19268c2ecf20Sopenharmony_ci	__le32		sgeNominalSize;	/* size of 2nd sge el. (if conformant) */
19278c2ecf20Sopenharmony_ci	u8		sgeCnt;		/* only 8 bits required */
19288c2ecf20Sopenharmony_ci	u8		bpTotal;	/* reserved for F/W use */
19298c2ecf20Sopenharmony_ci	u8		bpComplete;	/* reserved for F/W use */
19308c2ecf20Sopenharmony_ci	u8		sgeFirstIndex;	/* reserved for F/W use */
19318c2ecf20Sopenharmony_ci	u8		unused[4];
19328c2ecf20Sopenharmony_ci	struct sge_ieee1212	sge[1];
19338c2ecf20Sopenharmony_ci};
19348c2ecf20Sopenharmony_ci
19358c2ecf20Sopenharmony_ci#define CT_FLUSH_CACHE 129
19368c2ecf20Sopenharmony_cistruct aac_synchronize {
19378c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
19388c2ecf20Sopenharmony_ci	__le32		type;		/* CT_FLUSH_CACHE */
19398c2ecf20Sopenharmony_ci	__le32		cid;
19408c2ecf20Sopenharmony_ci	__le32		parm1;
19418c2ecf20Sopenharmony_ci	__le32		parm2;
19428c2ecf20Sopenharmony_ci	__le32		parm3;
19438c2ecf20Sopenharmony_ci	__le32		parm4;
19448c2ecf20Sopenharmony_ci	__le32		count;	/* sizeof(((struct aac_synchronize_reply *)NULL)->data) */
19458c2ecf20Sopenharmony_ci};
19468c2ecf20Sopenharmony_ci
19478c2ecf20Sopenharmony_cistruct aac_synchronize_reply {
19488c2ecf20Sopenharmony_ci	__le32		dummy0;
19498c2ecf20Sopenharmony_ci	__le32		dummy1;
19508c2ecf20Sopenharmony_ci	__le32		status;	/* CT_OK */
19518c2ecf20Sopenharmony_ci	__le32		parm1;
19528c2ecf20Sopenharmony_ci	__le32		parm2;
19538c2ecf20Sopenharmony_ci	__le32		parm3;
19548c2ecf20Sopenharmony_ci	__le32		parm4;
19558c2ecf20Sopenharmony_ci	__le32		parm5;
19568c2ecf20Sopenharmony_ci	u8		data[16];
19578c2ecf20Sopenharmony_ci};
19588c2ecf20Sopenharmony_ci
19598c2ecf20Sopenharmony_ci#define CT_POWER_MANAGEMENT	245
19608c2ecf20Sopenharmony_ci#define CT_PM_START_UNIT	2
19618c2ecf20Sopenharmony_ci#define CT_PM_STOP_UNIT		3
19628c2ecf20Sopenharmony_ci#define CT_PM_UNIT_IMMEDIATE	1
19638c2ecf20Sopenharmony_cistruct aac_power_management {
19648c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
19658c2ecf20Sopenharmony_ci	__le32		type;		/* CT_POWER_MANAGEMENT */
19668c2ecf20Sopenharmony_ci	__le32		sub;		/* CT_PM_* */
19678c2ecf20Sopenharmony_ci	__le32		cid;
19688c2ecf20Sopenharmony_ci	__le32		parm;		/* CT_PM_sub_* */
19698c2ecf20Sopenharmony_ci};
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_ci#define CT_PAUSE_IO    65
19728c2ecf20Sopenharmony_ci#define CT_RELEASE_IO  66
19738c2ecf20Sopenharmony_cistruct aac_pause {
19748c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
19758c2ecf20Sopenharmony_ci	__le32		type;		/* CT_PAUSE_IO */
19768c2ecf20Sopenharmony_ci	__le32		timeout;	/* 10ms ticks */
19778c2ecf20Sopenharmony_ci	__le32		min;
19788c2ecf20Sopenharmony_ci	__le32		noRescan;
19798c2ecf20Sopenharmony_ci	__le32		parm3;
19808c2ecf20Sopenharmony_ci	__le32		parm4;
19818c2ecf20Sopenharmony_ci	__le32		count;	/* sizeof(((struct aac_pause_reply *)NULL)->data) */
19828c2ecf20Sopenharmony_ci};
19838c2ecf20Sopenharmony_ci
19848c2ecf20Sopenharmony_cistruct aac_srb
19858c2ecf20Sopenharmony_ci{
19868c2ecf20Sopenharmony_ci	__le32		function;
19878c2ecf20Sopenharmony_ci	__le32		channel;
19888c2ecf20Sopenharmony_ci	__le32		id;
19898c2ecf20Sopenharmony_ci	__le32		lun;
19908c2ecf20Sopenharmony_ci	__le32		timeout;
19918c2ecf20Sopenharmony_ci	__le32		flags;
19928c2ecf20Sopenharmony_ci	__le32		count;		// Data xfer size
19938c2ecf20Sopenharmony_ci	__le32		retry_limit;
19948c2ecf20Sopenharmony_ci	__le32		cdb_size;
19958c2ecf20Sopenharmony_ci	u8		cdb[16];
19968c2ecf20Sopenharmony_ci	struct	sgmap	sg;
19978c2ecf20Sopenharmony_ci};
19988c2ecf20Sopenharmony_ci
19998c2ecf20Sopenharmony_ci/*
20008c2ecf20Sopenharmony_ci * This and associated data structs are used by the
20018c2ecf20Sopenharmony_ci * ioctl caller and are in cpu order.
20028c2ecf20Sopenharmony_ci */
20038c2ecf20Sopenharmony_cistruct user_aac_srb
20048c2ecf20Sopenharmony_ci{
20058c2ecf20Sopenharmony_ci	u32		function;
20068c2ecf20Sopenharmony_ci	u32		channel;
20078c2ecf20Sopenharmony_ci	u32		id;
20088c2ecf20Sopenharmony_ci	u32		lun;
20098c2ecf20Sopenharmony_ci	u32		timeout;
20108c2ecf20Sopenharmony_ci	u32		flags;
20118c2ecf20Sopenharmony_ci	u32		count;		// Data xfer size
20128c2ecf20Sopenharmony_ci	u32		retry_limit;
20138c2ecf20Sopenharmony_ci	u32		cdb_size;
20148c2ecf20Sopenharmony_ci	u8		cdb[16];
20158c2ecf20Sopenharmony_ci	struct	user_sgmap	sg;
20168c2ecf20Sopenharmony_ci};
20178c2ecf20Sopenharmony_ci
20188c2ecf20Sopenharmony_ci#define		AAC_SENSE_BUFFERSIZE	 30
20198c2ecf20Sopenharmony_ci
20208c2ecf20Sopenharmony_cistruct aac_srb_reply
20218c2ecf20Sopenharmony_ci{
20228c2ecf20Sopenharmony_ci	__le32		status;
20238c2ecf20Sopenharmony_ci	__le32		srb_status;
20248c2ecf20Sopenharmony_ci	__le32		scsi_status;
20258c2ecf20Sopenharmony_ci	__le32		data_xfer_length;
20268c2ecf20Sopenharmony_ci	__le32		sense_data_size;
20278c2ecf20Sopenharmony_ci	u8		sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
20288c2ecf20Sopenharmony_ci};
20298c2ecf20Sopenharmony_ci
20308c2ecf20Sopenharmony_cistruct aac_srb_unit {
20318c2ecf20Sopenharmony_ci	struct aac_srb		srb;
20328c2ecf20Sopenharmony_ci	struct aac_srb_reply	srb_reply;
20338c2ecf20Sopenharmony_ci};
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_ci/*
20368c2ecf20Sopenharmony_ci * SRB Flags
20378c2ecf20Sopenharmony_ci */
20388c2ecf20Sopenharmony_ci#define		SRB_NoDataXfer		 0x0000
20398c2ecf20Sopenharmony_ci#define		SRB_DisableDisconnect	 0x0004
20408c2ecf20Sopenharmony_ci#define		SRB_DisableSynchTransfer 0x0008
20418c2ecf20Sopenharmony_ci#define		SRB_BypassFrozenQueue	 0x0010
20428c2ecf20Sopenharmony_ci#define		SRB_DisableAutosense	 0x0020
20438c2ecf20Sopenharmony_ci#define		SRB_DataIn		 0x0040
20448c2ecf20Sopenharmony_ci#define		SRB_DataOut		 0x0080
20458c2ecf20Sopenharmony_ci
20468c2ecf20Sopenharmony_ci/*
20478c2ecf20Sopenharmony_ci * SRB Functions - set in aac_srb->function
20488c2ecf20Sopenharmony_ci */
20498c2ecf20Sopenharmony_ci#define	SRBF_ExecuteScsi	0x0000
20508c2ecf20Sopenharmony_ci#define	SRBF_ClaimDevice	0x0001
20518c2ecf20Sopenharmony_ci#define	SRBF_IO_Control		0x0002
20528c2ecf20Sopenharmony_ci#define	SRBF_ReceiveEvent	0x0003
20538c2ecf20Sopenharmony_ci#define	SRBF_ReleaseQueue	0x0004
20548c2ecf20Sopenharmony_ci#define	SRBF_AttachDevice	0x0005
20558c2ecf20Sopenharmony_ci#define	SRBF_ReleaseDevice	0x0006
20568c2ecf20Sopenharmony_ci#define	SRBF_Shutdown		0x0007
20578c2ecf20Sopenharmony_ci#define	SRBF_Flush		0x0008
20588c2ecf20Sopenharmony_ci#define	SRBF_AbortCommand	0x0010
20598c2ecf20Sopenharmony_ci#define	SRBF_ReleaseRecovery	0x0011
20608c2ecf20Sopenharmony_ci#define	SRBF_ResetBus		0x0012
20618c2ecf20Sopenharmony_ci#define	SRBF_ResetDevice	0x0013
20628c2ecf20Sopenharmony_ci#define	SRBF_TerminateIO	0x0014
20638c2ecf20Sopenharmony_ci#define	SRBF_FlushQueue		0x0015
20648c2ecf20Sopenharmony_ci#define	SRBF_RemoveDevice	0x0016
20658c2ecf20Sopenharmony_ci#define	SRBF_DomainValidation	0x0017
20668c2ecf20Sopenharmony_ci
20678c2ecf20Sopenharmony_ci/*
20688c2ecf20Sopenharmony_ci * SRB SCSI Status - set in aac_srb->scsi_status
20698c2ecf20Sopenharmony_ci */
20708c2ecf20Sopenharmony_ci#define SRB_STATUS_PENDING                  0x00
20718c2ecf20Sopenharmony_ci#define SRB_STATUS_SUCCESS                  0x01
20728c2ecf20Sopenharmony_ci#define SRB_STATUS_ABORTED                  0x02
20738c2ecf20Sopenharmony_ci#define SRB_STATUS_ABORT_FAILED             0x03
20748c2ecf20Sopenharmony_ci#define SRB_STATUS_ERROR                    0x04
20758c2ecf20Sopenharmony_ci#define SRB_STATUS_BUSY                     0x05
20768c2ecf20Sopenharmony_ci#define SRB_STATUS_INVALID_REQUEST          0x06
20778c2ecf20Sopenharmony_ci#define SRB_STATUS_INVALID_PATH_ID          0x07
20788c2ecf20Sopenharmony_ci#define SRB_STATUS_NO_DEVICE                0x08
20798c2ecf20Sopenharmony_ci#define SRB_STATUS_TIMEOUT                  0x09
20808c2ecf20Sopenharmony_ci#define SRB_STATUS_SELECTION_TIMEOUT        0x0A
20818c2ecf20Sopenharmony_ci#define SRB_STATUS_COMMAND_TIMEOUT          0x0B
20828c2ecf20Sopenharmony_ci#define SRB_STATUS_MESSAGE_REJECTED         0x0D
20838c2ecf20Sopenharmony_ci#define SRB_STATUS_BUS_RESET                0x0E
20848c2ecf20Sopenharmony_ci#define SRB_STATUS_PARITY_ERROR             0x0F
20858c2ecf20Sopenharmony_ci#define SRB_STATUS_REQUEST_SENSE_FAILED     0x10
20868c2ecf20Sopenharmony_ci#define SRB_STATUS_NO_HBA                   0x11
20878c2ecf20Sopenharmony_ci#define SRB_STATUS_DATA_OVERRUN             0x12
20888c2ecf20Sopenharmony_ci#define SRB_STATUS_UNEXPECTED_BUS_FREE      0x13
20898c2ecf20Sopenharmony_ci#define SRB_STATUS_PHASE_SEQUENCE_FAILURE   0x14
20908c2ecf20Sopenharmony_ci#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH     0x15
20918c2ecf20Sopenharmony_ci#define SRB_STATUS_REQUEST_FLUSHED          0x16
20928c2ecf20Sopenharmony_ci#define SRB_STATUS_DELAYED_RETRY	    0x17
20938c2ecf20Sopenharmony_ci#define SRB_STATUS_INVALID_LUN              0x20
20948c2ecf20Sopenharmony_ci#define SRB_STATUS_INVALID_TARGET_ID        0x21
20958c2ecf20Sopenharmony_ci#define SRB_STATUS_BAD_FUNCTION             0x22
20968c2ecf20Sopenharmony_ci#define SRB_STATUS_ERROR_RECOVERY           0x23
20978c2ecf20Sopenharmony_ci#define SRB_STATUS_NOT_STARTED		    0x24
20988c2ecf20Sopenharmony_ci#define SRB_STATUS_NOT_IN_USE		    0x30
20998c2ecf20Sopenharmony_ci#define SRB_STATUS_FORCE_ABORT		    0x31
21008c2ecf20Sopenharmony_ci#define SRB_STATUS_DOMAIN_VALIDATION_FAIL   0x32
21018c2ecf20Sopenharmony_ci
21028c2ecf20Sopenharmony_ci/*
21038c2ecf20Sopenharmony_ci * Object-Server / Volume-Manager Dispatch Classes
21048c2ecf20Sopenharmony_ci */
21058c2ecf20Sopenharmony_ci
21068c2ecf20Sopenharmony_ci#define		VM_Null			0
21078c2ecf20Sopenharmony_ci#define		VM_NameServe		1
21088c2ecf20Sopenharmony_ci#define		VM_ContainerConfig	2
21098c2ecf20Sopenharmony_ci#define		VM_Ioctl		3
21108c2ecf20Sopenharmony_ci#define		VM_FilesystemIoctl	4
21118c2ecf20Sopenharmony_ci#define		VM_CloseAll		5
21128c2ecf20Sopenharmony_ci#define		VM_CtBlockRead		6
21138c2ecf20Sopenharmony_ci#define		VM_CtBlockWrite		7
21148c2ecf20Sopenharmony_ci#define		VM_SliceBlockRead	8	/* raw access to configured "storage objects" */
21158c2ecf20Sopenharmony_ci#define		VM_SliceBlockWrite	9
21168c2ecf20Sopenharmony_ci#define		VM_DriveBlockRead	10	/* raw access to physical devices */
21178c2ecf20Sopenharmony_ci#define		VM_DriveBlockWrite	11
21188c2ecf20Sopenharmony_ci#define		VM_EnclosureMgt		12	/* enclosure management */
21198c2ecf20Sopenharmony_ci#define		VM_Unused		13	/* used to be diskset management */
21208c2ecf20Sopenharmony_ci#define		VM_CtBlockVerify	14
21218c2ecf20Sopenharmony_ci#define		VM_CtPerf		15	/* performance test */
21228c2ecf20Sopenharmony_ci#define		VM_CtBlockRead64	16
21238c2ecf20Sopenharmony_ci#define		VM_CtBlockWrite64	17
21248c2ecf20Sopenharmony_ci#define		VM_CtBlockVerify64	18
21258c2ecf20Sopenharmony_ci#define		VM_CtHostRead64		19
21268c2ecf20Sopenharmony_ci#define		VM_CtHostWrite64	20
21278c2ecf20Sopenharmony_ci#define		VM_DrvErrTblLog		21
21288c2ecf20Sopenharmony_ci#define		VM_NameServe64		22
21298c2ecf20Sopenharmony_ci#define		VM_NameServeAllBlk	30
21308c2ecf20Sopenharmony_ci
21318c2ecf20Sopenharmony_ci#define		MAX_VMCOMMAND_NUM	23	/* used for sizing stats array - leave last */
21328c2ecf20Sopenharmony_ci
21338c2ecf20Sopenharmony_ci/*
21348c2ecf20Sopenharmony_ci *	Descriptive information (eg, vital stats)
21358c2ecf20Sopenharmony_ci *	that a content manager might report.  The
21368c2ecf20Sopenharmony_ci *	FileArray filesystem component is one example
21378c2ecf20Sopenharmony_ci *	of a content manager.  Raw mode might be
21388c2ecf20Sopenharmony_ci *	another.
21398c2ecf20Sopenharmony_ci */
21408c2ecf20Sopenharmony_ci
21418c2ecf20Sopenharmony_cistruct aac_fsinfo {
21428c2ecf20Sopenharmony_ci	__le32  fsTotalSize;	/* Consumed by fs, incl. metadata */
21438c2ecf20Sopenharmony_ci	__le32  fsBlockSize;
21448c2ecf20Sopenharmony_ci	__le32  fsFragSize;
21458c2ecf20Sopenharmony_ci	__le32  fsMaxExtendSize;
21468c2ecf20Sopenharmony_ci	__le32  fsSpaceUnits;
21478c2ecf20Sopenharmony_ci	__le32  fsMaxNumFiles;
21488c2ecf20Sopenharmony_ci	__le32  fsNumFreeFiles;
21498c2ecf20Sopenharmony_ci	__le32  fsInodeDensity;
21508c2ecf20Sopenharmony_ci};	/* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */
21518c2ecf20Sopenharmony_ci
21528c2ecf20Sopenharmony_cistruct  aac_blockdevinfo {
21538c2ecf20Sopenharmony_ci	__le32	block_size;
21548c2ecf20Sopenharmony_ci	__le32  logical_phys_map;
21558c2ecf20Sopenharmony_ci	u8	identifier[16];
21568c2ecf20Sopenharmony_ci};
21578c2ecf20Sopenharmony_ci
21588c2ecf20Sopenharmony_ciunion aac_contentinfo {
21598c2ecf20Sopenharmony_ci	struct	aac_fsinfo		filesys;
21608c2ecf20Sopenharmony_ci	struct	aac_blockdevinfo	bdevinfo;
21618c2ecf20Sopenharmony_ci};
21628c2ecf20Sopenharmony_ci
21638c2ecf20Sopenharmony_ci/*
21648c2ecf20Sopenharmony_ci *	Query for Container Configuration Status
21658c2ecf20Sopenharmony_ci */
21668c2ecf20Sopenharmony_ci
21678c2ecf20Sopenharmony_ci#define CT_GET_CONFIG_STATUS 147
21688c2ecf20Sopenharmony_cistruct aac_get_config_status {
21698c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
21708c2ecf20Sopenharmony_ci	__le32		type;		/* CT_GET_CONFIG_STATUS */
21718c2ecf20Sopenharmony_ci	__le32		parm1;
21728c2ecf20Sopenharmony_ci	__le32		parm2;
21738c2ecf20Sopenharmony_ci	__le32		parm3;
21748c2ecf20Sopenharmony_ci	__le32		parm4;
21758c2ecf20Sopenharmony_ci	__le32		parm5;
21768c2ecf20Sopenharmony_ci	__le32		count;	/* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
21778c2ecf20Sopenharmony_ci};
21788c2ecf20Sopenharmony_ci
21798c2ecf20Sopenharmony_ci#define CFACT_CONTINUE 0
21808c2ecf20Sopenharmony_ci#define CFACT_PAUSE    1
21818c2ecf20Sopenharmony_ci#define CFACT_ABORT    2
21828c2ecf20Sopenharmony_cistruct aac_get_config_status_resp {
21838c2ecf20Sopenharmony_ci	__le32		response; /* ST_OK */
21848c2ecf20Sopenharmony_ci	__le32		dummy0;
21858c2ecf20Sopenharmony_ci	__le32		status;	/* CT_OK */
21868c2ecf20Sopenharmony_ci	__le32		parm1;
21878c2ecf20Sopenharmony_ci	__le32		parm2;
21888c2ecf20Sopenharmony_ci	__le32		parm3;
21898c2ecf20Sopenharmony_ci	__le32		parm4;
21908c2ecf20Sopenharmony_ci	__le32		parm5;
21918c2ecf20Sopenharmony_ci	struct {
21928c2ecf20Sopenharmony_ci		__le32	action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
21938c2ecf20Sopenharmony_ci		__le16	flags;
21948c2ecf20Sopenharmony_ci		__le16	count;
21958c2ecf20Sopenharmony_ci	}		data;
21968c2ecf20Sopenharmony_ci};
21978c2ecf20Sopenharmony_ci
21988c2ecf20Sopenharmony_ci/*
21998c2ecf20Sopenharmony_ci *	Accept the configuration as-is
22008c2ecf20Sopenharmony_ci */
22018c2ecf20Sopenharmony_ci
22028c2ecf20Sopenharmony_ci#define CT_COMMIT_CONFIG 152
22038c2ecf20Sopenharmony_ci
22048c2ecf20Sopenharmony_cistruct aac_commit_config {
22058c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
22068c2ecf20Sopenharmony_ci	__le32		type;		/* CT_COMMIT_CONFIG */
22078c2ecf20Sopenharmony_ci};
22088c2ecf20Sopenharmony_ci
22098c2ecf20Sopenharmony_ci/*
22108c2ecf20Sopenharmony_ci *	Query for Container Configuration Status
22118c2ecf20Sopenharmony_ci */
22128c2ecf20Sopenharmony_ci
22138c2ecf20Sopenharmony_ci#define CT_GET_CONTAINER_COUNT 4
22148c2ecf20Sopenharmony_cistruct aac_get_container_count {
22158c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
22168c2ecf20Sopenharmony_ci	__le32		type;		/* CT_GET_CONTAINER_COUNT */
22178c2ecf20Sopenharmony_ci};
22188c2ecf20Sopenharmony_ci
22198c2ecf20Sopenharmony_cistruct aac_get_container_count_resp {
22208c2ecf20Sopenharmony_ci	__le32		response; /* ST_OK */
22218c2ecf20Sopenharmony_ci	__le32		dummy0;
22228c2ecf20Sopenharmony_ci	__le32		MaxContainers;
22238c2ecf20Sopenharmony_ci	__le32		ContainerSwitchEntries;
22248c2ecf20Sopenharmony_ci	__le32		MaxPartitions;
22258c2ecf20Sopenharmony_ci	__le32		MaxSimpleVolumes;
22268c2ecf20Sopenharmony_ci};
22278c2ecf20Sopenharmony_ci
22288c2ecf20Sopenharmony_ci
22298c2ecf20Sopenharmony_ci/*
22308c2ecf20Sopenharmony_ci *	Query for "mountable" objects, ie, objects that are typically
22318c2ecf20Sopenharmony_ci *	associated with a drive letter on the client (host) side.
22328c2ecf20Sopenharmony_ci */
22338c2ecf20Sopenharmony_ci
22348c2ecf20Sopenharmony_cistruct aac_mntent {
22358c2ecf20Sopenharmony_ci	__le32			oid;
22368c2ecf20Sopenharmony_ci	u8			name[16];	/* if applicable */
22378c2ecf20Sopenharmony_ci	struct creation_info	create_info;	/* if applicable */
22388c2ecf20Sopenharmony_ci	__le32			capacity;
22398c2ecf20Sopenharmony_ci	__le32			vol;		/* substrate structure */
22408c2ecf20Sopenharmony_ci	__le32			obj;		/* FT_FILESYS, etc. */
22418c2ecf20Sopenharmony_ci	__le32			state;		/* unready for mounting,
22428c2ecf20Sopenharmony_ci						   readonly, etc. */
22438c2ecf20Sopenharmony_ci	union aac_contentinfo	fileinfo;	/* Info specific to content
22448c2ecf20Sopenharmony_ci						   manager (eg, filesystem) */
22458c2ecf20Sopenharmony_ci	__le32			altoid;		/* != oid <==> snapshot or
22468c2ecf20Sopenharmony_ci						   broken mirror exists */
22478c2ecf20Sopenharmony_ci	__le32			capacityhigh;
22488c2ecf20Sopenharmony_ci};
22498c2ecf20Sopenharmony_ci
22508c2ecf20Sopenharmony_ci#define FSCS_NOTCLEAN	0x0001  /* fsck is necessary before mounting */
22518c2ecf20Sopenharmony_ci#define FSCS_READONLY	0x0002	/* possible result of broken mirror */
22528c2ecf20Sopenharmony_ci#define FSCS_HIDDEN	0x0004	/* should be ignored - set during a clear */
22538c2ecf20Sopenharmony_ci#define FSCS_NOT_READY	0x0008	/* Array spinning up to fulfil request */
22548c2ecf20Sopenharmony_ci
22558c2ecf20Sopenharmony_cistruct aac_query_mount {
22568c2ecf20Sopenharmony_ci	__le32		command;
22578c2ecf20Sopenharmony_ci	__le32		type;
22588c2ecf20Sopenharmony_ci	__le32		count;
22598c2ecf20Sopenharmony_ci};
22608c2ecf20Sopenharmony_ci
22618c2ecf20Sopenharmony_cistruct aac_mount {
22628c2ecf20Sopenharmony_ci	__le32		status;
22638c2ecf20Sopenharmony_ci	__le32		type;           /* should be same as that requested */
22648c2ecf20Sopenharmony_ci	__le32		count;
22658c2ecf20Sopenharmony_ci	struct aac_mntent mnt[1];
22668c2ecf20Sopenharmony_ci};
22678c2ecf20Sopenharmony_ci
22688c2ecf20Sopenharmony_ci#define CT_READ_NAME 130
22698c2ecf20Sopenharmony_cistruct aac_get_name {
22708c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
22718c2ecf20Sopenharmony_ci	__le32		type;		/* CT_READ_NAME */
22728c2ecf20Sopenharmony_ci	__le32		cid;
22738c2ecf20Sopenharmony_ci	__le32		parm1;
22748c2ecf20Sopenharmony_ci	__le32		parm2;
22758c2ecf20Sopenharmony_ci	__le32		parm3;
22768c2ecf20Sopenharmony_ci	__le32		parm4;
22778c2ecf20Sopenharmony_ci	__le32		count;	/* sizeof(((struct aac_get_name_resp *)NULL)->data) */
22788c2ecf20Sopenharmony_ci};
22798c2ecf20Sopenharmony_ci
22808c2ecf20Sopenharmony_cistruct aac_get_name_resp {
22818c2ecf20Sopenharmony_ci	__le32		dummy0;
22828c2ecf20Sopenharmony_ci	__le32		dummy1;
22838c2ecf20Sopenharmony_ci	__le32		status;	/* CT_OK */
22848c2ecf20Sopenharmony_ci	__le32		parm1;
22858c2ecf20Sopenharmony_ci	__le32		parm2;
22868c2ecf20Sopenharmony_ci	__le32		parm3;
22878c2ecf20Sopenharmony_ci	__le32		parm4;
22888c2ecf20Sopenharmony_ci	__le32		parm5;
22898c2ecf20Sopenharmony_ci	u8		data[17];
22908c2ecf20Sopenharmony_ci};
22918c2ecf20Sopenharmony_ci
22928c2ecf20Sopenharmony_ci#define CT_CID_TO_32BITS_UID 165
22938c2ecf20Sopenharmony_cistruct aac_get_serial {
22948c2ecf20Sopenharmony_ci	__le32		command;	/* VM_ContainerConfig */
22958c2ecf20Sopenharmony_ci	__le32		type;		/* CT_CID_TO_32BITS_UID */
22968c2ecf20Sopenharmony_ci	__le32		cid;
22978c2ecf20Sopenharmony_ci};
22988c2ecf20Sopenharmony_ci
22998c2ecf20Sopenharmony_cistruct aac_get_serial_resp {
23008c2ecf20Sopenharmony_ci	__le32		dummy0;
23018c2ecf20Sopenharmony_ci	__le32		dummy1;
23028c2ecf20Sopenharmony_ci	__le32		status;	/* CT_OK */
23038c2ecf20Sopenharmony_ci	__le32		uid;
23048c2ecf20Sopenharmony_ci};
23058c2ecf20Sopenharmony_ci
23068c2ecf20Sopenharmony_ci/*
23078c2ecf20Sopenharmony_ci * The following command is sent to shut down each container.
23088c2ecf20Sopenharmony_ci */
23098c2ecf20Sopenharmony_ci
23108c2ecf20Sopenharmony_cistruct aac_close {
23118c2ecf20Sopenharmony_ci	__le32	command;
23128c2ecf20Sopenharmony_ci	__le32	cid;
23138c2ecf20Sopenharmony_ci};
23148c2ecf20Sopenharmony_ci
23158c2ecf20Sopenharmony_cistruct aac_query_disk
23168c2ecf20Sopenharmony_ci{
23178c2ecf20Sopenharmony_ci	s32	cnum;
23188c2ecf20Sopenharmony_ci	s32	bus;
23198c2ecf20Sopenharmony_ci	s32	id;
23208c2ecf20Sopenharmony_ci	s32	lun;
23218c2ecf20Sopenharmony_ci	u32	valid;
23228c2ecf20Sopenharmony_ci	u32	locked;
23238c2ecf20Sopenharmony_ci	u32	deleted;
23248c2ecf20Sopenharmony_ci	s32	instance;
23258c2ecf20Sopenharmony_ci	s8	name[10];
23268c2ecf20Sopenharmony_ci	u32	unmapped;
23278c2ecf20Sopenharmony_ci};
23288c2ecf20Sopenharmony_ci
23298c2ecf20Sopenharmony_cistruct aac_delete_disk {
23308c2ecf20Sopenharmony_ci	u32	disknum;
23318c2ecf20Sopenharmony_ci	u32	cnum;
23328c2ecf20Sopenharmony_ci};
23338c2ecf20Sopenharmony_ci
23348c2ecf20Sopenharmony_cistruct fib_ioctl
23358c2ecf20Sopenharmony_ci{
23368c2ecf20Sopenharmony_ci	u32	fibctx;
23378c2ecf20Sopenharmony_ci	s32	wait;
23388c2ecf20Sopenharmony_ci	char	__user *fib;
23398c2ecf20Sopenharmony_ci};
23408c2ecf20Sopenharmony_ci
23418c2ecf20Sopenharmony_cistruct revision
23428c2ecf20Sopenharmony_ci{
23438c2ecf20Sopenharmony_ci	u32 compat;
23448c2ecf20Sopenharmony_ci	__le32 version;
23458c2ecf20Sopenharmony_ci	__le32 build;
23468c2ecf20Sopenharmony_ci};
23478c2ecf20Sopenharmony_ci
23488c2ecf20Sopenharmony_ci
23498c2ecf20Sopenharmony_ci/*
23508c2ecf20Sopenharmony_ci *	Ugly - non Linux like ioctl coding for back compat.
23518c2ecf20Sopenharmony_ci */
23528c2ecf20Sopenharmony_ci
23538c2ecf20Sopenharmony_ci#define CTL_CODE(function, method) (                 \
23548c2ecf20Sopenharmony_ci    (4<< 16) | ((function) << 2) | (method) \
23558c2ecf20Sopenharmony_ci)
23568c2ecf20Sopenharmony_ci
23578c2ecf20Sopenharmony_ci/*
23588c2ecf20Sopenharmony_ci *	Define the method codes for how buffers are passed for I/O and FS
23598c2ecf20Sopenharmony_ci *	controls
23608c2ecf20Sopenharmony_ci */
23618c2ecf20Sopenharmony_ci
23628c2ecf20Sopenharmony_ci#define METHOD_BUFFERED                 0
23638c2ecf20Sopenharmony_ci#define METHOD_NEITHER                  3
23648c2ecf20Sopenharmony_ci
23658c2ecf20Sopenharmony_ci/*
23668c2ecf20Sopenharmony_ci *	Filesystem ioctls
23678c2ecf20Sopenharmony_ci */
23688c2ecf20Sopenharmony_ci
23698c2ecf20Sopenharmony_ci#define FSACTL_SENDFIB				CTL_CODE(2050, METHOD_BUFFERED)
23708c2ecf20Sopenharmony_ci#define FSACTL_SEND_RAW_SRB			CTL_CODE(2067, METHOD_BUFFERED)
23718c2ecf20Sopenharmony_ci#define FSACTL_DELETE_DISK			0x163
23728c2ecf20Sopenharmony_ci#define FSACTL_QUERY_DISK			0x173
23738c2ecf20Sopenharmony_ci#define FSACTL_OPEN_GET_ADAPTER_FIB		CTL_CODE(2100, METHOD_BUFFERED)
23748c2ecf20Sopenharmony_ci#define FSACTL_GET_NEXT_ADAPTER_FIB		CTL_CODE(2101, METHOD_BUFFERED)
23758c2ecf20Sopenharmony_ci#define FSACTL_CLOSE_GET_ADAPTER_FIB		CTL_CODE(2102, METHOD_BUFFERED)
23768c2ecf20Sopenharmony_ci#define FSACTL_MINIPORT_REV_CHECK               CTL_CODE(2107, METHOD_BUFFERED)
23778c2ecf20Sopenharmony_ci#define FSACTL_GET_PCI_INFO			CTL_CODE(2119, METHOD_BUFFERED)
23788c2ecf20Sopenharmony_ci#define FSACTL_FORCE_DELETE_DISK		CTL_CODE(2120, METHOD_NEITHER)
23798c2ecf20Sopenharmony_ci#define FSACTL_GET_CONTAINERS			2131
23808c2ecf20Sopenharmony_ci#define FSACTL_SEND_LARGE_FIB			CTL_CODE(2138, METHOD_BUFFERED)
23818c2ecf20Sopenharmony_ci#define FSACTL_RESET_IOP			CTL_CODE(2140, METHOD_BUFFERED)
23828c2ecf20Sopenharmony_ci#define FSACTL_GET_HBA_INFO			CTL_CODE(2150, METHOD_BUFFERED)
23838c2ecf20Sopenharmony_ci/* flags defined for IOP & HW SOFT RESET */
23848c2ecf20Sopenharmony_ci#define HW_IOP_RESET				0x01
23858c2ecf20Sopenharmony_ci#define HW_SOFT_RESET				0x02
23868c2ecf20Sopenharmony_ci#define IOP_HWSOFT_RESET			(HW_IOP_RESET | HW_SOFT_RESET)
23878c2ecf20Sopenharmony_ci/* HW Soft Reset register offset */
23888c2ecf20Sopenharmony_ci#define IBW_SWR_OFFSET				0x4000
23898c2ecf20Sopenharmony_ci#define SOFT_RESET_TIME			60
23908c2ecf20Sopenharmony_ci
23918c2ecf20Sopenharmony_ci
23928c2ecf20Sopenharmony_ci
23938c2ecf20Sopenharmony_cistruct aac_common
23948c2ecf20Sopenharmony_ci{
23958c2ecf20Sopenharmony_ci	/*
23968c2ecf20Sopenharmony_ci	 *	If this value is set to 1 then interrupt moderation will occur
23978c2ecf20Sopenharmony_ci	 *	in the base commuication support.
23988c2ecf20Sopenharmony_ci	 */
23998c2ecf20Sopenharmony_ci	u32 irq_mod;
24008c2ecf20Sopenharmony_ci	u32 peak_fibs;
24018c2ecf20Sopenharmony_ci	u32 zero_fibs;
24028c2ecf20Sopenharmony_ci	u32 fib_timeouts;
24038c2ecf20Sopenharmony_ci	/*
24048c2ecf20Sopenharmony_ci	 *	Statistical counters in debug mode
24058c2ecf20Sopenharmony_ci	 */
24068c2ecf20Sopenharmony_ci#ifdef DBG
24078c2ecf20Sopenharmony_ci	u32 FibsSent;
24088c2ecf20Sopenharmony_ci	u32 FibRecved;
24098c2ecf20Sopenharmony_ci	u32 NativeSent;
24108c2ecf20Sopenharmony_ci	u32 NativeRecved;
24118c2ecf20Sopenharmony_ci	u32 NoResponseSent;
24128c2ecf20Sopenharmony_ci	u32 NoResponseRecved;
24138c2ecf20Sopenharmony_ci	u32 AsyncSent;
24148c2ecf20Sopenharmony_ci	u32 AsyncRecved;
24158c2ecf20Sopenharmony_ci	u32 NormalSent;
24168c2ecf20Sopenharmony_ci	u32 NormalRecved;
24178c2ecf20Sopenharmony_ci#endif
24188c2ecf20Sopenharmony_ci};
24198c2ecf20Sopenharmony_ci
24208c2ecf20Sopenharmony_ciextern struct aac_common aac_config;
24218c2ecf20Sopenharmony_ci
24228c2ecf20Sopenharmony_ci/*
24238c2ecf20Sopenharmony_ci * This is for management ioctl purpose only.
24248c2ecf20Sopenharmony_ci */
24258c2ecf20Sopenharmony_cistruct aac_hba_info {
24268c2ecf20Sopenharmony_ci
24278c2ecf20Sopenharmony_ci	u8	driver_name[50];
24288c2ecf20Sopenharmony_ci	u8	adapter_number;
24298c2ecf20Sopenharmony_ci	u8	system_io_bus_number;
24308c2ecf20Sopenharmony_ci	u8	device_number;
24318c2ecf20Sopenharmony_ci	u32	function_number;
24328c2ecf20Sopenharmony_ci	u32	vendor_id;
24338c2ecf20Sopenharmony_ci	u32	device_id;
24348c2ecf20Sopenharmony_ci	u32	sub_vendor_id;
24358c2ecf20Sopenharmony_ci	u32	sub_system_id;
24368c2ecf20Sopenharmony_ci	u32	mapped_base_address_size;
24378c2ecf20Sopenharmony_ci	u32	base_physical_address_high_part;
24388c2ecf20Sopenharmony_ci	u32	base_physical_address_low_part;
24398c2ecf20Sopenharmony_ci
24408c2ecf20Sopenharmony_ci	u32	max_command_size;
24418c2ecf20Sopenharmony_ci	u32	max_fib_size;
24428c2ecf20Sopenharmony_ci	u32	max_scatter_gather_from_os;
24438c2ecf20Sopenharmony_ci	u32	max_scatter_gather_to_fw;
24448c2ecf20Sopenharmony_ci	u32	max_outstanding_fibs;
24458c2ecf20Sopenharmony_ci
24468c2ecf20Sopenharmony_ci	u32	queue_start_threshold;
24478c2ecf20Sopenharmony_ci	u32	queue_dump_threshold;
24488c2ecf20Sopenharmony_ci	u32	max_io_size_queued;
24498c2ecf20Sopenharmony_ci	u32	outstanding_io;
24508c2ecf20Sopenharmony_ci
24518c2ecf20Sopenharmony_ci	u32	firmware_build_number;
24528c2ecf20Sopenharmony_ci	u32	bios_build_number;
24538c2ecf20Sopenharmony_ci	u32	driver_build_number;
24548c2ecf20Sopenharmony_ci	u32	serial_number_high_part;
24558c2ecf20Sopenharmony_ci	u32	serial_number_low_part;
24568c2ecf20Sopenharmony_ci	u32	supported_options;
24578c2ecf20Sopenharmony_ci	u32	feature_bits;
24588c2ecf20Sopenharmony_ci	u32	currentnumber_ports;
24598c2ecf20Sopenharmony_ci
24608c2ecf20Sopenharmony_ci	u8	new_comm_interface:1;
24618c2ecf20Sopenharmony_ci	u8	new_commands_supported:1;
24628c2ecf20Sopenharmony_ci	u8	disable_passthrough:1;
24638c2ecf20Sopenharmony_ci	u8	expose_non_dasd:1;
24648c2ecf20Sopenharmony_ci	u8	queue_allowed:1;
24658c2ecf20Sopenharmony_ci	u8	bled_check_enabled:1;
24668c2ecf20Sopenharmony_ci	u8	reserved1:1;
24678c2ecf20Sopenharmony_ci	u8	reserted2:1;
24688c2ecf20Sopenharmony_ci
24698c2ecf20Sopenharmony_ci	u32	reserved3[10];
24708c2ecf20Sopenharmony_ci
24718c2ecf20Sopenharmony_ci};
24728c2ecf20Sopenharmony_ci
24738c2ecf20Sopenharmony_ci/*
24748c2ecf20Sopenharmony_ci *	The following macro is used when sending and receiving FIBs. It is
24758c2ecf20Sopenharmony_ci *	only used for debugging.
24768c2ecf20Sopenharmony_ci */
24778c2ecf20Sopenharmony_ci
24788c2ecf20Sopenharmony_ci#ifdef DBG
24798c2ecf20Sopenharmony_ci#define	FIB_COUNTER_INCREMENT(counter)		(counter)++
24808c2ecf20Sopenharmony_ci#else
24818c2ecf20Sopenharmony_ci#define	FIB_COUNTER_INCREMENT(counter)
24828c2ecf20Sopenharmony_ci#endif
24838c2ecf20Sopenharmony_ci
24848c2ecf20Sopenharmony_ci/*
24858c2ecf20Sopenharmony_ci *	Adapter direct commands
24868c2ecf20Sopenharmony_ci *	Monitor/Kernel API
24878c2ecf20Sopenharmony_ci */
24888c2ecf20Sopenharmony_ci
24898c2ecf20Sopenharmony_ci#define	BREAKPOINT_REQUEST		0x00000004
24908c2ecf20Sopenharmony_ci#define	INIT_STRUCT_BASE_ADDRESS	0x00000005
24918c2ecf20Sopenharmony_ci#define READ_PERMANENT_PARAMETERS	0x0000000a
24928c2ecf20Sopenharmony_ci#define WRITE_PERMANENT_PARAMETERS	0x0000000b
24938c2ecf20Sopenharmony_ci#define HOST_CRASHING			0x0000000d
24948c2ecf20Sopenharmony_ci#define	SEND_SYNCHRONOUS_FIB		0x0000000c
24958c2ecf20Sopenharmony_ci#define COMMAND_POST_RESULTS		0x00000014
24968c2ecf20Sopenharmony_ci#define GET_ADAPTER_PROPERTIES		0x00000019
24978c2ecf20Sopenharmony_ci#define GET_DRIVER_BUFFER_PROPERTIES	0x00000023
24988c2ecf20Sopenharmony_ci#define RCV_TEMP_READINGS		0x00000025
24998c2ecf20Sopenharmony_ci#define GET_COMM_PREFERRED_SETTINGS	0x00000026
25008c2ecf20Sopenharmony_ci#define IOP_RESET_FW_FIB_DUMP		0x00000034
25018c2ecf20Sopenharmony_ci#define DROP_IO			0x00000035
25028c2ecf20Sopenharmony_ci#define IOP_RESET			0x00001000
25038c2ecf20Sopenharmony_ci#define IOP_RESET_ALWAYS		0x00001001
25048c2ecf20Sopenharmony_ci#define RE_INIT_ADAPTER		0x000000ee
25058c2ecf20Sopenharmony_ci
25068c2ecf20Sopenharmony_ci#define IOP_SRC_RESET_MASK		0x00000100
25078c2ecf20Sopenharmony_ci
25088c2ecf20Sopenharmony_ci/*
25098c2ecf20Sopenharmony_ci *	Adapter Status Register
25108c2ecf20Sopenharmony_ci *
25118c2ecf20Sopenharmony_ci *  Phase Staus mailbox is 32bits:
25128c2ecf20Sopenharmony_ci *	<31:16> = Phase Status
25138c2ecf20Sopenharmony_ci *	<15:0>  = Phase
25148c2ecf20Sopenharmony_ci *
25158c2ecf20Sopenharmony_ci *	The adapter reports is present state through the phase.  Only
25168c2ecf20Sopenharmony_ci *	a single phase should be ever be set.  Each phase can have multiple
25178c2ecf20Sopenharmony_ci *	phase status bits to provide more detailed information about the
25188c2ecf20Sopenharmony_ci *	state of the board.  Care should be taken to ensure that any phase
25198c2ecf20Sopenharmony_ci *	status bits that are set when changing the phase are also valid
25208c2ecf20Sopenharmony_ci *	for the new phase or be cleared out.  Adapter software (monitor,
25218c2ecf20Sopenharmony_ci *	iflash, kernel) is responsible for properly maintining the phase
25228c2ecf20Sopenharmony_ci *	status mailbox when it is running.
25238c2ecf20Sopenharmony_ci *
25248c2ecf20Sopenharmony_ci *	MONKER_API Phases
25258c2ecf20Sopenharmony_ci *
25268c2ecf20Sopenharmony_ci *	Phases are bit oriented.  It is NOT valid  to have multiple bits set
25278c2ecf20Sopenharmony_ci */
25288c2ecf20Sopenharmony_ci
25298c2ecf20Sopenharmony_ci#define	SELF_TEST_FAILED		0x00000004
25308c2ecf20Sopenharmony_ci#define	MONITOR_PANIC			0x00000020
25318c2ecf20Sopenharmony_ci#define	KERNEL_BOOTING			0x00000040
25328c2ecf20Sopenharmony_ci#define	KERNEL_UP_AND_RUNNING		0x00000080
25338c2ecf20Sopenharmony_ci#define	KERNEL_PANIC			0x00000100
25348c2ecf20Sopenharmony_ci#define	FLASH_UPD_PENDING		0x00002000
25358c2ecf20Sopenharmony_ci#define	FLASH_UPD_SUCCESS		0x00004000
25368c2ecf20Sopenharmony_ci#define	FLASH_UPD_FAILED		0x00008000
25378c2ecf20Sopenharmony_ci#define	INVALID_OMR			0xffffffff
25388c2ecf20Sopenharmony_ci#define	FWUPD_TIMEOUT			(5 * 60)
25398c2ecf20Sopenharmony_ci
25408c2ecf20Sopenharmony_ci/*
25418c2ecf20Sopenharmony_ci *	Doorbell bit defines
25428c2ecf20Sopenharmony_ci */
25438c2ecf20Sopenharmony_ci
25448c2ecf20Sopenharmony_ci#define DoorBellSyncCmdAvailable	(1<<0)	/* Host -> Adapter */
25458c2ecf20Sopenharmony_ci#define DoorBellPrintfDone		(1<<5)	/* Host -> Adapter */
25468c2ecf20Sopenharmony_ci#define DoorBellAdapterNormCmdReady	(1<<1)	/* Adapter -> Host */
25478c2ecf20Sopenharmony_ci#define DoorBellAdapterNormRespReady	(1<<2)	/* Adapter -> Host */
25488c2ecf20Sopenharmony_ci#define DoorBellAdapterNormCmdNotFull	(1<<3)	/* Adapter -> Host */
25498c2ecf20Sopenharmony_ci#define DoorBellAdapterNormRespNotFull	(1<<4)	/* Adapter -> Host */
25508c2ecf20Sopenharmony_ci#define DoorBellPrintfReady		(1<<5)	/* Adapter -> Host */
25518c2ecf20Sopenharmony_ci#define DoorBellAifPending		(1<<6)	/* Adapter -> Host */
25528c2ecf20Sopenharmony_ci
25538c2ecf20Sopenharmony_ci/* PMC specific outbound doorbell bits */
25548c2ecf20Sopenharmony_ci#define PmDoorBellResponseSent		(1<<1)	/* Adapter -> Host */
25558c2ecf20Sopenharmony_ci
25568c2ecf20Sopenharmony_ci/*
25578c2ecf20Sopenharmony_ci *	For FIB communication, we need all of the following things
25588c2ecf20Sopenharmony_ci *	to send back to the user.
25598c2ecf20Sopenharmony_ci */
25608c2ecf20Sopenharmony_ci
25618c2ecf20Sopenharmony_ci#define		AifCmdEventNotify	1	/* Notify of event */
25628c2ecf20Sopenharmony_ci#define			AifEnConfigChange	3	/* Adapter configuration change */
25638c2ecf20Sopenharmony_ci#define			AifEnContainerChange	4	/* Container configuration change */
25648c2ecf20Sopenharmony_ci#define			AifEnDeviceFailure	5	/* SCSI device failed */
25658c2ecf20Sopenharmony_ci#define			AifEnEnclosureManagement 13	/* EM_DRIVE_* */
25668c2ecf20Sopenharmony_ci#define				EM_DRIVE_INSERTION	31
25678c2ecf20Sopenharmony_ci#define				EM_DRIVE_REMOVAL	32
25688c2ecf20Sopenharmony_ci#define			EM_SES_DRIVE_INSERTION	33
25698c2ecf20Sopenharmony_ci#define			EM_SES_DRIVE_REMOVAL	26
25708c2ecf20Sopenharmony_ci#define			AifEnBatteryEvent	14	/* Change in Battery State */
25718c2ecf20Sopenharmony_ci#define			AifEnAddContainer	15	/* A new array was created */
25728c2ecf20Sopenharmony_ci#define			AifEnDeleteContainer	16	/* A container was deleted */
25738c2ecf20Sopenharmony_ci#define			AifEnExpEvent		23	/* Firmware Event Log */
25748c2ecf20Sopenharmony_ci#define			AifExeFirmwarePanic	3	/* Firmware Event Panic */
25758c2ecf20Sopenharmony_ci#define			AifHighPriority		3	/* Highest Priority Event */
25768c2ecf20Sopenharmony_ci#define			AifEnAddJBOD		30	/* JBOD created */
25778c2ecf20Sopenharmony_ci#define			AifEnDeleteJBOD		31	/* JBOD deleted */
25788c2ecf20Sopenharmony_ci
25798c2ecf20Sopenharmony_ci#define			AifBuManagerEvent		42 /* Bu management*/
25808c2ecf20Sopenharmony_ci#define			AifBuCacheDataLoss		10
25818c2ecf20Sopenharmony_ci#define			AifBuCacheDataRecover	11
25828c2ecf20Sopenharmony_ci
25838c2ecf20Sopenharmony_ci#define		AifCmdJobProgress	2	/* Progress report */
25848c2ecf20Sopenharmony_ci#define			AifJobCtrZero	101	/* Array Zero progress */
25858c2ecf20Sopenharmony_ci#define			AifJobStsSuccess 1	/* Job completes */
25868c2ecf20Sopenharmony_ci#define			AifJobStsRunning 102	/* Job running */
25878c2ecf20Sopenharmony_ci#define		AifCmdAPIReport		3	/* Report from other user of API */
25888c2ecf20Sopenharmony_ci#define		AifCmdDriverNotify	4	/* Notify host driver of event */
25898c2ecf20Sopenharmony_ci#define			AifDenMorphComplete 200	/* A morph operation completed */
25908c2ecf20Sopenharmony_ci#define			AifDenVolumeExtendComplete 201 /* A volume extend completed */
25918c2ecf20Sopenharmony_ci#define		AifReqJobList		100	/* Gets back complete job list */
25928c2ecf20Sopenharmony_ci#define		AifReqJobsForCtr	101	/* Gets back jobs for specific container */
25938c2ecf20Sopenharmony_ci#define		AifReqJobsForScsi	102	/* Gets back jobs for specific SCSI device */
25948c2ecf20Sopenharmony_ci#define		AifReqJobReport		103	/* Gets back a specific job report or list of them */
25958c2ecf20Sopenharmony_ci#define		AifReqTerminateJob	104	/* Terminates job */
25968c2ecf20Sopenharmony_ci#define		AifReqSuspendJob	105	/* Suspends a job */
25978c2ecf20Sopenharmony_ci#define		AifReqResumeJob		106	/* Resumes a job */
25988c2ecf20Sopenharmony_ci#define		AifReqSendAPIReport	107	/* API generic report requests */
25998c2ecf20Sopenharmony_ci#define		AifReqAPIJobStart	108	/* Start a job from the API */
26008c2ecf20Sopenharmony_ci#define		AifReqAPIJobUpdate	109	/* Update a job report from the API */
26018c2ecf20Sopenharmony_ci#define		AifReqAPIJobFinish	110	/* Finish a job from the API */
26028c2ecf20Sopenharmony_ci
26038c2ecf20Sopenharmony_ci/* PMC NEW COMM: Request the event data */
26048c2ecf20Sopenharmony_ci#define		AifReqEvent		200
26058c2ecf20Sopenharmony_ci#define		AifRawDeviceRemove	203	/* RAW device deleted */
26068c2ecf20Sopenharmony_ci#define		AifNativeDeviceAdd	204	/* native HBA device added */
26078c2ecf20Sopenharmony_ci#define		AifNativeDeviceRemove	205	/* native HBA device removed */
26088c2ecf20Sopenharmony_ci
26098c2ecf20Sopenharmony_ci
26108c2ecf20Sopenharmony_ci/*
26118c2ecf20Sopenharmony_ci *	Adapter Initiated FIB command structures. Start with the adapter
26128c2ecf20Sopenharmony_ci *	initiated FIBs that really come from the adapter, and get responded
26138c2ecf20Sopenharmony_ci *	to by the host.
26148c2ecf20Sopenharmony_ci */
26158c2ecf20Sopenharmony_ci
26168c2ecf20Sopenharmony_cistruct aac_aifcmd {
26178c2ecf20Sopenharmony_ci	__le32 command;		/* Tell host what type of notify this is */
26188c2ecf20Sopenharmony_ci	__le32 seqnum;		/* To allow ordering of reports (if necessary) */
26198c2ecf20Sopenharmony_ci	u8 data[1];		/* Undefined length (from kernel viewpoint) */
26208c2ecf20Sopenharmony_ci};
26218c2ecf20Sopenharmony_ci
26228c2ecf20Sopenharmony_ci/**
26238c2ecf20Sopenharmony_ci *	Convert capacity to cylinders
26248c2ecf20Sopenharmony_ci *	accounting for the fact capacity could be a 64 bit value
26258c2ecf20Sopenharmony_ci *
26268c2ecf20Sopenharmony_ci */
26278c2ecf20Sopenharmony_cistatic inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
26288c2ecf20Sopenharmony_ci{
26298c2ecf20Sopenharmony_ci	sector_div(capacity, divisor);
26308c2ecf20Sopenharmony_ci	return capacity;
26318c2ecf20Sopenharmony_ci}
26328c2ecf20Sopenharmony_ci
26338c2ecf20Sopenharmony_cistatic inline int aac_pci_offline(struct aac_dev *dev)
26348c2ecf20Sopenharmony_ci{
26358c2ecf20Sopenharmony_ci	return pci_channel_offline(dev->pdev) || dev->handle_pci_error;
26368c2ecf20Sopenharmony_ci}
26378c2ecf20Sopenharmony_ci
26388c2ecf20Sopenharmony_cistatic inline int aac_adapter_check_health(struct aac_dev *dev)
26398c2ecf20Sopenharmony_ci{
26408c2ecf20Sopenharmony_ci	if (unlikely(aac_pci_offline(dev)))
26418c2ecf20Sopenharmony_ci		return -1;
26428c2ecf20Sopenharmony_ci
26438c2ecf20Sopenharmony_ci	return (dev)->a_ops.adapter_check_health(dev);
26448c2ecf20Sopenharmony_ci}
26458c2ecf20Sopenharmony_ci
26468c2ecf20Sopenharmony_ci
26478c2ecf20Sopenharmony_ciint aac_scan_host(struct aac_dev *dev);
26488c2ecf20Sopenharmony_ci
26498c2ecf20Sopenharmony_cistatic inline void aac_schedule_safw_scan_worker(struct aac_dev *dev)
26508c2ecf20Sopenharmony_ci{
26518c2ecf20Sopenharmony_ci	schedule_delayed_work(&dev->safw_rescan_work, AAC_RESCAN_DELAY);
26528c2ecf20Sopenharmony_ci}
26538c2ecf20Sopenharmony_ci
26548c2ecf20Sopenharmony_cistatic inline void aac_schedule_src_reinit_aif_worker(struct aac_dev *dev)
26558c2ecf20Sopenharmony_ci{
26568c2ecf20Sopenharmony_ci	schedule_delayed_work(&dev->src_reinit_aif_worker, AAC_RESCAN_DELAY);
26578c2ecf20Sopenharmony_ci}
26588c2ecf20Sopenharmony_ci
26598c2ecf20Sopenharmony_cistatic inline void aac_safw_rescan_worker(struct work_struct *work)
26608c2ecf20Sopenharmony_ci{
26618c2ecf20Sopenharmony_ci	struct aac_dev *dev = container_of(to_delayed_work(work),
26628c2ecf20Sopenharmony_ci		struct aac_dev, safw_rescan_work);
26638c2ecf20Sopenharmony_ci
26648c2ecf20Sopenharmony_ci	wait_event(dev->scsi_host_ptr->host_wait,
26658c2ecf20Sopenharmony_ci		!scsi_host_in_recovery(dev->scsi_host_ptr));
26668c2ecf20Sopenharmony_ci
26678c2ecf20Sopenharmony_ci	aac_scan_host(dev);
26688c2ecf20Sopenharmony_ci}
26698c2ecf20Sopenharmony_ci
26708c2ecf20Sopenharmony_cistatic inline void aac_cancel_rescan_worker(struct aac_dev *dev)
26718c2ecf20Sopenharmony_ci{
26728c2ecf20Sopenharmony_ci	cancel_delayed_work_sync(&dev->safw_rescan_work);
26738c2ecf20Sopenharmony_ci	cancel_delayed_work_sync(&dev->src_reinit_aif_worker);
26748c2ecf20Sopenharmony_ci}
26758c2ecf20Sopenharmony_ci
26768c2ecf20Sopenharmony_ci/* SCp.phase values */
26778c2ecf20Sopenharmony_ci#define AAC_OWNER_MIDLEVEL	0x101
26788c2ecf20Sopenharmony_ci#define AAC_OWNER_LOWLEVEL	0x102
26798c2ecf20Sopenharmony_ci#define AAC_OWNER_ERROR_HANDLER	0x103
26808c2ecf20Sopenharmony_ci#define AAC_OWNER_FIRMWARE	0x106
26818c2ecf20Sopenharmony_ci
26828c2ecf20Sopenharmony_civoid aac_safw_rescan_worker(struct work_struct *work);
26838c2ecf20Sopenharmony_civoid aac_src_reinit_aif_worker(struct work_struct *work);
26848c2ecf20Sopenharmony_ciint aac_acquire_irq(struct aac_dev *dev);
26858c2ecf20Sopenharmony_civoid aac_free_irq(struct aac_dev *dev);
26868c2ecf20Sopenharmony_ciint aac_setup_safw_adapter(struct aac_dev *dev);
26878c2ecf20Sopenharmony_ciconst char *aac_driverinfo(struct Scsi_Host *);
26888c2ecf20Sopenharmony_civoid aac_fib_vector_assign(struct aac_dev *dev);
26898c2ecf20Sopenharmony_cistruct fib *aac_fib_alloc(struct aac_dev *dev);
26908c2ecf20Sopenharmony_cistruct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd);
26918c2ecf20Sopenharmony_ciint aac_fib_setup(struct aac_dev *dev);
26928c2ecf20Sopenharmony_civoid aac_fib_map_free(struct aac_dev *dev);
26938c2ecf20Sopenharmony_civoid aac_fib_free(struct fib * context);
26948c2ecf20Sopenharmony_civoid aac_fib_init(struct fib * context);
26958c2ecf20Sopenharmony_civoid aac_printf(struct aac_dev *dev, u32 val);
26968c2ecf20Sopenharmony_ciint aac_fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt);
26978c2ecf20Sopenharmony_ciint aac_hba_send(u8 command, struct fib *context,
26988c2ecf20Sopenharmony_ci		fib_callback callback, void *ctxt);
26998c2ecf20Sopenharmony_ciint aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
27008c2ecf20Sopenharmony_civoid aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
27018c2ecf20Sopenharmony_ciint aac_fib_complete(struct fib * context);
27028c2ecf20Sopenharmony_civoid aac_hba_callback(void *context, struct fib *fibptr);
27038c2ecf20Sopenharmony_ci#define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data)
27048c2ecf20Sopenharmony_cistruct aac_dev *aac_init_adapter(struct aac_dev *dev);
27058c2ecf20Sopenharmony_civoid aac_src_access_devreg(struct aac_dev *dev, int mode);
27068c2ecf20Sopenharmony_civoid aac_set_intx_mode(struct aac_dev *dev);
27078c2ecf20Sopenharmony_ciint aac_get_config_status(struct aac_dev *dev, int commit_flag);
27088c2ecf20Sopenharmony_ciint aac_get_containers(struct aac_dev *dev);
27098c2ecf20Sopenharmony_ciint aac_scsi_cmd(struct scsi_cmnd *cmd);
27108c2ecf20Sopenharmony_ciint aac_dev_ioctl(struct aac_dev *dev, unsigned int cmd, void __user *arg);
27118c2ecf20Sopenharmony_ci#ifndef shost_to_class
27128c2ecf20Sopenharmony_ci#define shost_to_class(shost) &shost->shost_dev
27138c2ecf20Sopenharmony_ci#endif
27148c2ecf20Sopenharmony_cissize_t aac_get_serial_number(struct device *dev, char *buf);
27158c2ecf20Sopenharmony_ciint aac_do_ioctl(struct aac_dev *dev, unsigned int cmd, void __user *arg);
27168c2ecf20Sopenharmony_ciint aac_rx_init(struct aac_dev *dev);
27178c2ecf20Sopenharmony_ciint aac_rkt_init(struct aac_dev *dev);
27188c2ecf20Sopenharmony_ciint aac_nark_init(struct aac_dev *dev);
27198c2ecf20Sopenharmony_ciint aac_sa_init(struct aac_dev *dev);
27208c2ecf20Sopenharmony_ciint aac_src_init(struct aac_dev *dev);
27218c2ecf20Sopenharmony_ciint aac_srcv_init(struct aac_dev *dev);
27228c2ecf20Sopenharmony_ciint aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify);
27238c2ecf20Sopenharmony_civoid aac_define_int_mode(struct aac_dev *dev);
27248c2ecf20Sopenharmony_ciunsigned int aac_response_normal(struct aac_queue * q);
27258c2ecf20Sopenharmony_ciunsigned int aac_command_normal(struct aac_queue * q);
27268c2ecf20Sopenharmony_ciunsigned int aac_intr_normal(struct aac_dev *dev, u32 Index,
27278c2ecf20Sopenharmony_ci			int isAif, int isFastResponse,
27288c2ecf20Sopenharmony_ci			struct hw_fib *aif_fib);
27298c2ecf20Sopenharmony_ciint aac_reset_adapter(struct aac_dev *dev, int forced, u8 reset_type);
27308c2ecf20Sopenharmony_ciint aac_check_health(struct aac_dev * dev);
27318c2ecf20Sopenharmony_ciint aac_command_thread(void *data);
27328c2ecf20Sopenharmony_ciint aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
27338c2ecf20Sopenharmony_ciint aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
27348c2ecf20Sopenharmony_cistruct aac_driver_ident* aac_get_driver_ident(int devtype);
27358c2ecf20Sopenharmony_ciint aac_get_adapter_info(struct aac_dev* dev);
27368c2ecf20Sopenharmony_ciint aac_send_shutdown(struct aac_dev *dev);
27378c2ecf20Sopenharmony_ciint aac_probe_container(struct aac_dev *dev, int cid);
27388c2ecf20Sopenharmony_ciint _aac_rx_init(struct aac_dev *dev);
27398c2ecf20Sopenharmony_ciint aac_rx_select_comm(struct aac_dev *dev, int comm);
27408c2ecf20Sopenharmony_ciint aac_rx_deliver_producer(struct fib * fib);
27418c2ecf20Sopenharmony_civoid aac_reinit_aif(struct aac_dev *aac, unsigned int index);
27428c2ecf20Sopenharmony_ci
27438c2ecf20Sopenharmony_cistatic inline int aac_is_src(struct aac_dev *dev)
27448c2ecf20Sopenharmony_ci{
27458c2ecf20Sopenharmony_ci	u16 device = dev->pdev->device;
27468c2ecf20Sopenharmony_ci
27478c2ecf20Sopenharmony_ci	if (device == PMC_DEVICE_S6 ||
27488c2ecf20Sopenharmony_ci		device == PMC_DEVICE_S7 ||
27498c2ecf20Sopenharmony_ci		device == PMC_DEVICE_S8)
27508c2ecf20Sopenharmony_ci		return 1;
27518c2ecf20Sopenharmony_ci	return 0;
27528c2ecf20Sopenharmony_ci}
27538c2ecf20Sopenharmony_ci
27548c2ecf20Sopenharmony_cistatic inline int aac_supports_2T(struct aac_dev *dev)
27558c2ecf20Sopenharmony_ci{
27568c2ecf20Sopenharmony_ci	return (dev->adapter_info.options & AAC_OPT_NEW_COMM_64);
27578c2ecf20Sopenharmony_ci}
27588c2ecf20Sopenharmony_ci
27598c2ecf20Sopenharmony_cichar * get_container_type(unsigned type);
27608c2ecf20Sopenharmony_ciextern int numacb;
27618c2ecf20Sopenharmony_ciextern char aac_driver_version[];
27628c2ecf20Sopenharmony_ciextern int startup_timeout;
27638c2ecf20Sopenharmony_ciextern int aif_timeout;
27648c2ecf20Sopenharmony_ciextern int expose_physicals;
27658c2ecf20Sopenharmony_ciextern int aac_reset_devices;
27668c2ecf20Sopenharmony_ciextern int aac_msi;
27678c2ecf20Sopenharmony_ciextern int aac_commit;
27688c2ecf20Sopenharmony_ciextern int update_interval;
27698c2ecf20Sopenharmony_ciextern int check_interval;
27708c2ecf20Sopenharmony_ciextern int aac_check_reset;
27718c2ecf20Sopenharmony_ciextern int aac_fib_dump;
27728c2ecf20Sopenharmony_ci#endif
2773