18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic Fibre Channel HBA Driver
48c2ecf20Sopenharmony_ci * Copyright (c)  2003-2014 QLogic Corporation
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#ifndef __QLA_DEF_H
78c2ecf20Sopenharmony_ci#define __QLA_DEF_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/kernel.h>
108c2ecf20Sopenharmony_ci#include <linux/init.h>
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci#include <linux/module.h>
138c2ecf20Sopenharmony_ci#include <linux/list.h>
148c2ecf20Sopenharmony_ci#include <linux/pci.h>
158c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
168c2ecf20Sopenharmony_ci#include <linux/sched.h>
178c2ecf20Sopenharmony_ci#include <linux/slab.h>
188c2ecf20Sopenharmony_ci#include <linux/dmapool.h>
198c2ecf20Sopenharmony_ci#include <linux/mempool.h>
208c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
218c2ecf20Sopenharmony_ci#include <linux/completion.h>
228c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
238c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
248c2ecf20Sopenharmony_ci#include <linux/firmware.h>
258c2ecf20Sopenharmony_ci#include <linux/aer.h>
268c2ecf20Sopenharmony_ci#include <linux/mutex.h>
278c2ecf20Sopenharmony_ci#include <linux/btree.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
308c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
318c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
328c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h>
338c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_fc.h>
348c2ecf20Sopenharmony_ci#include <scsi/scsi_bsg_fc.h>
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include <uapi/scsi/fc/fc_els.h>
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* Big endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
398c2ecf20Sopenharmony_citypedef struct {
408c2ecf20Sopenharmony_ci	uint8_t domain;
418c2ecf20Sopenharmony_ci	uint8_t area;
428c2ecf20Sopenharmony_ci	uint8_t al_pa;
438c2ecf20Sopenharmony_ci} be_id_t;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* Little endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
468c2ecf20Sopenharmony_citypedef struct {
478c2ecf20Sopenharmony_ci	uint8_t al_pa;
488c2ecf20Sopenharmony_ci	uint8_t area;
498c2ecf20Sopenharmony_ci	uint8_t domain;
508c2ecf20Sopenharmony_ci} le_id_t;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#include "qla_bsg.h"
538c2ecf20Sopenharmony_ci#include "qla_dsd.h"
548c2ecf20Sopenharmony_ci#include "qla_nx.h"
558c2ecf20Sopenharmony_ci#include "qla_nx2.h"
568c2ecf20Sopenharmony_ci#include "qla_nvme.h"
578c2ecf20Sopenharmony_ci#define QLA2XXX_DRIVER_NAME	"qla2xxx"
588c2ecf20Sopenharmony_ci#define QLA2XXX_APIDEV		"ql2xapidev"
598c2ecf20Sopenharmony_ci#define QLA2XXX_MANUFACTURER	"QLogic Corporation"
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/*
628c2ecf20Sopenharmony_ci * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
638c2ecf20Sopenharmony_ci * but that's fine as we don't look at the last 24 ones for
648c2ecf20Sopenharmony_ci * ISP2100 HBAs.
658c2ecf20Sopenharmony_ci */
668c2ecf20Sopenharmony_ci#define MAILBOX_REGISTER_COUNT_2100	8
678c2ecf20Sopenharmony_ci#define MAILBOX_REGISTER_COUNT_2200	24
688c2ecf20Sopenharmony_ci#define MAILBOX_REGISTER_COUNT		32
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define QLA2200A_RISC_ROM_VER	4
718c2ecf20Sopenharmony_ci#define FPM_2300		6
728c2ecf20Sopenharmony_ci#define FPM_2310		7
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#include "qla_settings.h"
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define MODE_DUAL (MODE_TARGET | MODE_INITIATOR)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/*
798c2ecf20Sopenharmony_ci * Data bit definitions
808c2ecf20Sopenharmony_ci */
818c2ecf20Sopenharmony_ci#define BIT_0	0x1
828c2ecf20Sopenharmony_ci#define BIT_1	0x2
838c2ecf20Sopenharmony_ci#define BIT_2	0x4
848c2ecf20Sopenharmony_ci#define BIT_3	0x8
858c2ecf20Sopenharmony_ci#define BIT_4	0x10
868c2ecf20Sopenharmony_ci#define BIT_5	0x20
878c2ecf20Sopenharmony_ci#define BIT_6	0x40
888c2ecf20Sopenharmony_ci#define BIT_7	0x80
898c2ecf20Sopenharmony_ci#define BIT_8	0x100
908c2ecf20Sopenharmony_ci#define BIT_9	0x200
918c2ecf20Sopenharmony_ci#define BIT_10	0x400
928c2ecf20Sopenharmony_ci#define BIT_11	0x800
938c2ecf20Sopenharmony_ci#define BIT_12	0x1000
948c2ecf20Sopenharmony_ci#define BIT_13	0x2000
958c2ecf20Sopenharmony_ci#define BIT_14	0x4000
968c2ecf20Sopenharmony_ci#define BIT_15	0x8000
978c2ecf20Sopenharmony_ci#define BIT_16	0x10000
988c2ecf20Sopenharmony_ci#define BIT_17	0x20000
998c2ecf20Sopenharmony_ci#define BIT_18	0x40000
1008c2ecf20Sopenharmony_ci#define BIT_19	0x80000
1018c2ecf20Sopenharmony_ci#define BIT_20	0x100000
1028c2ecf20Sopenharmony_ci#define BIT_21	0x200000
1038c2ecf20Sopenharmony_ci#define BIT_22	0x400000
1048c2ecf20Sopenharmony_ci#define BIT_23	0x800000
1058c2ecf20Sopenharmony_ci#define BIT_24	0x1000000
1068c2ecf20Sopenharmony_ci#define BIT_25	0x2000000
1078c2ecf20Sopenharmony_ci#define BIT_26	0x4000000
1088c2ecf20Sopenharmony_ci#define BIT_27	0x8000000
1098c2ecf20Sopenharmony_ci#define BIT_28	0x10000000
1108c2ecf20Sopenharmony_ci#define BIT_29	0x20000000
1118c2ecf20Sopenharmony_ci#define BIT_30	0x40000000
1128c2ecf20Sopenharmony_ci#define BIT_31	0x80000000
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define LSB(x)	((uint8_t)(x))
1158c2ecf20Sopenharmony_ci#define MSB(x)	((uint8_t)((uint16_t)(x) >> 8))
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define LSW(x)	((uint16_t)(x))
1188c2ecf20Sopenharmony_ci#define MSW(x)	((uint16_t)((uint32_t)(x) >> 16))
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define LSD(x)	((uint32_t)((uint64_t)(x)))
1218c2ecf20Sopenharmony_ci#define MSD(x)	((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cistatic inline uint32_t make_handle(uint16_t x, uint16_t y)
1248c2ecf20Sopenharmony_ci{
1258c2ecf20Sopenharmony_ci	return ((uint32_t)x << 16) | y;
1268c2ecf20Sopenharmony_ci}
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/*
1298c2ecf20Sopenharmony_ci * I/O register
1308c2ecf20Sopenharmony_ci*/
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistatic inline u8 rd_reg_byte(const volatile u8 __iomem *addr)
1338c2ecf20Sopenharmony_ci{
1348c2ecf20Sopenharmony_ci	return readb(addr);
1358c2ecf20Sopenharmony_ci}
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistatic inline u16 rd_reg_word(const volatile __le16 __iomem *addr)
1388c2ecf20Sopenharmony_ci{
1398c2ecf20Sopenharmony_ci	return readw(addr);
1408c2ecf20Sopenharmony_ci}
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic inline u32 rd_reg_dword(const volatile __le32 __iomem *addr)
1438c2ecf20Sopenharmony_ci{
1448c2ecf20Sopenharmony_ci	return readl(addr);
1458c2ecf20Sopenharmony_ci}
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cistatic inline u8 rd_reg_byte_relaxed(const volatile u8 __iomem *addr)
1488c2ecf20Sopenharmony_ci{
1498c2ecf20Sopenharmony_ci	return readb_relaxed(addr);
1508c2ecf20Sopenharmony_ci}
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic inline u16 rd_reg_word_relaxed(const volatile __le16 __iomem *addr)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	return readw_relaxed(addr);
1558c2ecf20Sopenharmony_ci}
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistatic inline u32 rd_reg_dword_relaxed(const volatile __le32 __iomem *addr)
1588c2ecf20Sopenharmony_ci{
1598c2ecf20Sopenharmony_ci	return readl_relaxed(addr);
1608c2ecf20Sopenharmony_ci}
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic inline void wrt_reg_byte(volatile u8 __iomem *addr, u8 data)
1638c2ecf20Sopenharmony_ci{
1648c2ecf20Sopenharmony_ci	return writeb(data, addr);
1658c2ecf20Sopenharmony_ci}
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistatic inline void wrt_reg_word(volatile __le16 __iomem *addr, u16 data)
1688c2ecf20Sopenharmony_ci{
1698c2ecf20Sopenharmony_ci	return writew(data, addr);
1708c2ecf20Sopenharmony_ci}
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_cistatic inline void wrt_reg_dword(volatile __le32 __iomem *addr, u32 data)
1738c2ecf20Sopenharmony_ci{
1748c2ecf20Sopenharmony_ci	return writel(data, addr);
1758c2ecf20Sopenharmony_ci}
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/*
1788c2ecf20Sopenharmony_ci * ISP83XX specific remote register addresses
1798c2ecf20Sopenharmony_ci */
1808c2ecf20Sopenharmony_ci#define QLA83XX_LED_PORT0			0x00201320
1818c2ecf20Sopenharmony_ci#define QLA83XX_LED_PORT1			0x00201328
1828c2ecf20Sopenharmony_ci#define QLA83XX_IDC_DEV_STATE		0x22102384
1838c2ecf20Sopenharmony_ci#define QLA83XX_IDC_MAJOR_VERSION	0x22102380
1848c2ecf20Sopenharmony_ci#define QLA83XX_IDC_MINOR_VERSION	0x22102398
1858c2ecf20Sopenharmony_ci#define QLA83XX_IDC_DRV_PRESENCE	0x22102388
1868c2ecf20Sopenharmony_ci#define QLA83XX_IDC_DRIVER_ACK		0x2210238c
1878c2ecf20Sopenharmony_ci#define QLA83XX_IDC_CONTROL			0x22102390
1888c2ecf20Sopenharmony_ci#define QLA83XX_IDC_AUDIT			0x22102394
1898c2ecf20Sopenharmony_ci#define QLA83XX_IDC_LOCK_RECOVERY	0x2210239c
1908c2ecf20Sopenharmony_ci#define QLA83XX_DRIVER_LOCKID		0x22102104
1918c2ecf20Sopenharmony_ci#define QLA83XX_DRIVER_LOCK			0x8111c028
1928c2ecf20Sopenharmony_ci#define QLA83XX_DRIVER_UNLOCK		0x8111c02c
1938c2ecf20Sopenharmony_ci#define QLA83XX_FLASH_LOCKID		0x22102100
1948c2ecf20Sopenharmony_ci#define QLA83XX_FLASH_LOCK			0x8111c010
1958c2ecf20Sopenharmony_ci#define QLA83XX_FLASH_UNLOCK		0x8111c014
1968c2ecf20Sopenharmony_ci#define QLA83XX_DEV_PARTINFO1		0x221023e0
1978c2ecf20Sopenharmony_ci#define QLA83XX_DEV_PARTINFO2		0x221023e4
1988c2ecf20Sopenharmony_ci#define QLA83XX_FW_HEARTBEAT		0x221020b0
1998c2ecf20Sopenharmony_ci#define QLA83XX_PEG_HALT_STATUS1	0x221020a8
2008c2ecf20Sopenharmony_ci#define QLA83XX_PEG_HALT_STATUS2	0x221020ac
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci/* 83XX: Macros defining 8200 AEN Reason codes */
2038c2ecf20Sopenharmony_ci#define IDC_DEVICE_STATE_CHANGE BIT_0
2048c2ecf20Sopenharmony_ci#define IDC_PEG_HALT_STATUS_CHANGE BIT_1
2058c2ecf20Sopenharmony_ci#define IDC_NIC_FW_REPORTED_FAILURE BIT_2
2068c2ecf20Sopenharmony_ci#define IDC_HEARTBEAT_FAILURE BIT_3
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/* 83XX: Macros defining 8200 AEN Error-levels */
2098c2ecf20Sopenharmony_ci#define ERR_LEVEL_NON_FATAL 0x1
2108c2ecf20Sopenharmony_ci#define ERR_LEVEL_RECOVERABLE_FATAL 0x2
2118c2ecf20Sopenharmony_ci#define ERR_LEVEL_UNRECOVERABLE_FATAL 0x4
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* 83XX: Macros for IDC Version */
2148c2ecf20Sopenharmony_ci#define QLA83XX_SUPP_IDC_MAJOR_VERSION 0x01
2158c2ecf20Sopenharmony_ci#define QLA83XX_SUPP_IDC_MINOR_VERSION 0x0
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci/* 83XX: Macros for scheduling dpc tasks */
2188c2ecf20Sopenharmony_ci#define QLA83XX_NIC_CORE_RESET 0x1
2198c2ecf20Sopenharmony_ci#define QLA83XX_IDC_STATE_HANDLER 0x2
2208c2ecf20Sopenharmony_ci#define QLA83XX_NIC_CORE_UNRECOVERABLE 0x3
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci/* 83XX: Macros for defining IDC-Control bits */
2238c2ecf20Sopenharmony_ci#define QLA83XX_IDC_RESET_DISABLED BIT_0
2248c2ecf20Sopenharmony_ci#define QLA83XX_IDC_GRACEFUL_RESET BIT_1
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/* 83XX: Macros for different timeouts */
2278c2ecf20Sopenharmony_ci#define QLA83XX_IDC_INITIALIZATION_TIMEOUT 30
2288c2ecf20Sopenharmony_ci#define QLA83XX_IDC_RESET_ACK_TIMEOUT 10
2298c2ecf20Sopenharmony_ci#define QLA83XX_MAX_LOCK_RECOVERY_WAIT (2 * HZ)
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/* 83XX: Macros for defining class in DEV-Partition Info register */
2328c2ecf20Sopenharmony_ci#define QLA83XX_CLASS_TYPE_NONE		0x0
2338c2ecf20Sopenharmony_ci#define QLA83XX_CLASS_TYPE_NIC		0x1
2348c2ecf20Sopenharmony_ci#define QLA83XX_CLASS_TYPE_FCOE		0x2
2358c2ecf20Sopenharmony_ci#define QLA83XX_CLASS_TYPE_ISCSI	0x3
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci/* 83XX: Macros for IDC Lock-Recovery stages */
2388c2ecf20Sopenharmony_ci#define IDC_LOCK_RECOVERY_STAGE1	0x1 /* Stage1: Intent for
2398c2ecf20Sopenharmony_ci					     * lock-recovery
2408c2ecf20Sopenharmony_ci					     */
2418c2ecf20Sopenharmony_ci#define IDC_LOCK_RECOVERY_STAGE2	0x2 /* Stage2: Perform lock-recovery */
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/* 83XX: Macros for IDC Audit type */
2448c2ecf20Sopenharmony_ci#define IDC_AUDIT_TIMESTAMP		0x0 /* IDC-AUDIT: Record timestamp of
2458c2ecf20Sopenharmony_ci					     * dev-state change to NEED-RESET
2468c2ecf20Sopenharmony_ci					     * or NEED-QUIESCENT
2478c2ecf20Sopenharmony_ci					     */
2488c2ecf20Sopenharmony_ci#define IDC_AUDIT_COMPLETION		0x1 /* IDC-AUDIT: Record duration of
2498c2ecf20Sopenharmony_ci					     * reset-recovery completion is
2508c2ecf20Sopenharmony_ci					     * second
2518c2ecf20Sopenharmony_ci					     */
2528c2ecf20Sopenharmony_ci/* ISP2031: Values for laser on/off */
2538c2ecf20Sopenharmony_ci#define PORT_0_2031	0x00201340
2548c2ecf20Sopenharmony_ci#define PORT_1_2031	0x00201350
2558c2ecf20Sopenharmony_ci#define LASER_ON_2031	0x01800100
2568c2ecf20Sopenharmony_ci#define LASER_OFF_2031	0x01800180
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci/*
2598c2ecf20Sopenharmony_ci * The ISP2312 v2 chip cannot access the FLASH/GPIO registers via MMIO in an
2608c2ecf20Sopenharmony_ci * 133Mhz slot.
2618c2ecf20Sopenharmony_ci */
2628c2ecf20Sopenharmony_ci#define RD_REG_WORD_PIO(addr)		(inw((unsigned long)addr))
2638c2ecf20Sopenharmony_ci#define WRT_REG_WORD_PIO(addr, data)	(outw(data, (unsigned long)addr))
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci/*
2668c2ecf20Sopenharmony_ci * Fibre Channel device definitions.
2678c2ecf20Sopenharmony_ci */
2688c2ecf20Sopenharmony_ci#define WWN_SIZE		8	/* Size of WWPN, WWN & WWNN */
2698c2ecf20Sopenharmony_ci#define MAX_FIBRE_DEVICES_2100	512
2708c2ecf20Sopenharmony_ci#define MAX_FIBRE_DEVICES_2400	2048
2718c2ecf20Sopenharmony_ci#define MAX_FIBRE_DEVICES_LOOP	128
2728c2ecf20Sopenharmony_ci#define MAX_FIBRE_DEVICES_MAX	MAX_FIBRE_DEVICES_2400
2738c2ecf20Sopenharmony_ci#define LOOPID_MAP_SIZE		(ha->max_fibre_devices)
2748c2ecf20Sopenharmony_ci#define MAX_FIBRE_LUNS  	0xFFFF
2758c2ecf20Sopenharmony_ci#define	MAX_HOST_COUNT		16
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci/*
2788c2ecf20Sopenharmony_ci * Host adapter default definitions.
2798c2ecf20Sopenharmony_ci */
2808c2ecf20Sopenharmony_ci#define MAX_BUSES		1  /* We only have one bus today */
2818c2ecf20Sopenharmony_ci#define MIN_LUNS		8
2828c2ecf20Sopenharmony_ci#define MAX_LUNS		MAX_FIBRE_LUNS
2838c2ecf20Sopenharmony_ci#define MAX_CMDS_PER_LUN	255
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci/*
2868c2ecf20Sopenharmony_ci * Fibre Channel device definitions.
2878c2ecf20Sopenharmony_ci */
2888c2ecf20Sopenharmony_ci#define SNS_LAST_LOOP_ID_2100	0xfe
2898c2ecf20Sopenharmony_ci#define SNS_LAST_LOOP_ID_2300	0x7ff
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci#define LAST_LOCAL_LOOP_ID	0x7d
2928c2ecf20Sopenharmony_ci#define SNS_FL_PORT		0x7e
2938c2ecf20Sopenharmony_ci#define FABRIC_CONTROLLER	0x7f
2948c2ecf20Sopenharmony_ci#define SIMPLE_NAME_SERVER	0x80
2958c2ecf20Sopenharmony_ci#define SNS_FIRST_LOOP_ID	0x81
2968c2ecf20Sopenharmony_ci#define MANAGEMENT_SERVER	0xfe
2978c2ecf20Sopenharmony_ci#define BROADCAST		0xff
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/*
3008c2ecf20Sopenharmony_ci * There is no correspondence between an N-PORT id and an AL_PA.  Therefore the
3018c2ecf20Sopenharmony_ci * valid range of an N-PORT id is 0 through 0x7ef.
3028c2ecf20Sopenharmony_ci */
3038c2ecf20Sopenharmony_ci#define NPH_LAST_HANDLE		0x7ee
3048c2ecf20Sopenharmony_ci#define NPH_MGMT_SERVER		0x7ef		/*  FFFFEF */
3058c2ecf20Sopenharmony_ci#define NPH_SNS			0x7fc		/*  FFFFFC */
3068c2ecf20Sopenharmony_ci#define NPH_FABRIC_CONTROLLER	0x7fd		/*  FFFFFD */
3078c2ecf20Sopenharmony_ci#define NPH_F_PORT		0x7fe		/*  FFFFFE */
3088c2ecf20Sopenharmony_ci#define NPH_IP_BROADCAST	0x7ff		/*  FFFFFF */
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci#define NPH_SNS_LID(ha)	(IS_FWI2_CAPABLE(ha) ? NPH_SNS : SIMPLE_NAME_SERVER)
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci#define MAX_CMDSZ	16		/* SCSI maximum CDB size. */
3138c2ecf20Sopenharmony_ci#include "qla_fw.h"
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_cistruct name_list_extended {
3168c2ecf20Sopenharmony_ci	struct get_name_list_extended *l;
3178c2ecf20Sopenharmony_ci	dma_addr_t		ldma;
3188c2ecf20Sopenharmony_ci	struct list_head	fcports;
3198c2ecf20Sopenharmony_ci	u32			size;
3208c2ecf20Sopenharmony_ci	u8			sent;
3218c2ecf20Sopenharmony_ci};
3228c2ecf20Sopenharmony_ci/*
3238c2ecf20Sopenharmony_ci * Timeout timer counts in seconds
3248c2ecf20Sopenharmony_ci */
3258c2ecf20Sopenharmony_ci#define PORT_RETRY_TIME			1
3268c2ecf20Sopenharmony_ci#define LOOP_DOWN_TIMEOUT		60
3278c2ecf20Sopenharmony_ci#define LOOP_DOWN_TIME			255	/* 240 */
3288c2ecf20Sopenharmony_ci#define	LOOP_DOWN_RESET			(LOOP_DOWN_TIME - 30)
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci#define DEFAULT_OUTSTANDING_COMMANDS	4096
3318c2ecf20Sopenharmony_ci#define MIN_OUTSTANDING_COMMANDS	128
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/* ISP request and response entry counts (37-65535) */
3348c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_CNT_2100		128	/* Number of request entries. */
3358c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_CNT_2200		2048	/* Number of request entries. */
3368c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_CNT_24XX		2048	/* Number of request entries. */
3378c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_CNT_83XX		8192	/* Number of request entries. */
3388c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_83XX		4096	/* Number of response entries.*/
3398c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_2100		64	/* Number of response entries.*/
3408c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_2300		512	/* Number of response entries.*/
3418c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_MQ		128	/* Number of response entries.*/
3428c2ecf20Sopenharmony_ci#define ATIO_ENTRY_CNT_24XX		4096	/* Number of ATIO entries. */
3438c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_FX00		256     /* Number of response entries.*/
3448c2ecf20Sopenharmony_ci#define FW_DEF_EXCHANGES_CNT 2048
3458c2ecf20Sopenharmony_ci#define FW_MAX_EXCHANGES_CNT (32 * 1024)
3468c2ecf20Sopenharmony_ci#define REDUCE_EXCHANGES_CNT  (8 * 1024)
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistruct req_que;
3498c2ecf20Sopenharmony_cistruct qla_tgt_sess;
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci/*
3528c2ecf20Sopenharmony_ci * SCSI Request Block
3538c2ecf20Sopenharmony_ci */
3548c2ecf20Sopenharmony_cistruct srb_cmd {
3558c2ecf20Sopenharmony_ci	struct scsi_cmnd *cmd;		/* Linux SCSI command pkt */
3568c2ecf20Sopenharmony_ci	uint32_t request_sense_length;
3578c2ecf20Sopenharmony_ci	uint32_t fw_sense_length;
3588c2ecf20Sopenharmony_ci	uint8_t *request_sense_ptr;
3598c2ecf20Sopenharmony_ci	struct ct6_dsd *ct6_ctx;
3608c2ecf20Sopenharmony_ci	struct crc_context *crc_ctx;
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci/*
3648c2ecf20Sopenharmony_ci * SRB flag definitions
3658c2ecf20Sopenharmony_ci */
3668c2ecf20Sopenharmony_ci#define SRB_DMA_VALID			BIT_0	/* Command sent to ISP */
3678c2ecf20Sopenharmony_ci#define SRB_FCP_CMND_DMA_VALID		BIT_12	/* DIF: DSD List valid */
3688c2ecf20Sopenharmony_ci#define SRB_CRC_CTX_DMA_VALID		BIT_2	/* DIF: context DMA valid */
3698c2ecf20Sopenharmony_ci#define SRB_CRC_PROT_DMA_VALID		BIT_4	/* DIF: prot DMA valid */
3708c2ecf20Sopenharmony_ci#define SRB_CRC_CTX_DSD_VALID		BIT_5	/* DIF: dsd_list valid */
3718c2ecf20Sopenharmony_ci#define SRB_WAKEUP_ON_COMP		BIT_6
3728c2ecf20Sopenharmony_ci#define SRB_DIF_BUNDL_DMA_VALID		BIT_7   /* DIF: DMA list valid */
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci/* To identify if a srb is of T10-CRC type. @sp => srb_t pointer */
3758c2ecf20Sopenharmony_ci#define IS_PROT_IO(sp)	(sp->flags & SRB_CRC_CTX_DSD_VALID)
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci/*
3788c2ecf20Sopenharmony_ci * 24 bit port ID type definition.
3798c2ecf20Sopenharmony_ci */
3808c2ecf20Sopenharmony_citypedef union {
3818c2ecf20Sopenharmony_ci	uint32_t b24 : 24;
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	struct {
3848c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN
3858c2ecf20Sopenharmony_ci		uint8_t domain;
3868c2ecf20Sopenharmony_ci		uint8_t area;
3878c2ecf20Sopenharmony_ci		uint8_t al_pa;
3888c2ecf20Sopenharmony_ci#elif defined(__LITTLE_ENDIAN)
3898c2ecf20Sopenharmony_ci		uint8_t al_pa;
3908c2ecf20Sopenharmony_ci		uint8_t area;
3918c2ecf20Sopenharmony_ci		uint8_t domain;
3928c2ecf20Sopenharmony_ci#else
3938c2ecf20Sopenharmony_ci#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
3948c2ecf20Sopenharmony_ci#endif
3958c2ecf20Sopenharmony_ci		uint8_t rsvd_1;
3968c2ecf20Sopenharmony_ci	} b;
3978c2ecf20Sopenharmony_ci} port_id_t;
3988c2ecf20Sopenharmony_ci#define INVALID_PORT_ID	0xFFFFFF
3998c2ecf20Sopenharmony_ci#define ISP_REG16_DISCONNECT 0xFFFF
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cistatic inline le_id_t be_id_to_le(be_id_t id)
4028c2ecf20Sopenharmony_ci{
4038c2ecf20Sopenharmony_ci	le_id_t res;
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci	res.domain = id.domain;
4068c2ecf20Sopenharmony_ci	res.area   = id.area;
4078c2ecf20Sopenharmony_ci	res.al_pa  = id.al_pa;
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	return res;
4108c2ecf20Sopenharmony_ci}
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistatic inline be_id_t le_id_to_be(le_id_t id)
4138c2ecf20Sopenharmony_ci{
4148c2ecf20Sopenharmony_ci	be_id_t res;
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	res.domain = id.domain;
4178c2ecf20Sopenharmony_ci	res.area   = id.area;
4188c2ecf20Sopenharmony_ci	res.al_pa  = id.al_pa;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	return res;
4218c2ecf20Sopenharmony_ci}
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_cistatic inline port_id_t be_to_port_id(be_id_t id)
4248c2ecf20Sopenharmony_ci{
4258c2ecf20Sopenharmony_ci	port_id_t res;
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	res.b.domain = id.domain;
4288c2ecf20Sopenharmony_ci	res.b.area   = id.area;
4298c2ecf20Sopenharmony_ci	res.b.al_pa  = id.al_pa;
4308c2ecf20Sopenharmony_ci	res.b.rsvd_1 = 0;
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	return res;
4338c2ecf20Sopenharmony_ci}
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_cistatic inline be_id_t port_id_to_be_id(port_id_t port_id)
4368c2ecf20Sopenharmony_ci{
4378c2ecf20Sopenharmony_ci	be_id_t res;
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci	res.domain = port_id.b.domain;
4408c2ecf20Sopenharmony_ci	res.area   = port_id.b.area;
4418c2ecf20Sopenharmony_ci	res.al_pa  = port_id.b.al_pa;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	return res;
4448c2ecf20Sopenharmony_ci}
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_cistruct els_logo_payload {
4478c2ecf20Sopenharmony_ci	uint8_t opcode;
4488c2ecf20Sopenharmony_ci	uint8_t rsvd[3];
4498c2ecf20Sopenharmony_ci	uint8_t s_id[3];
4508c2ecf20Sopenharmony_ci	uint8_t rsvd1[1];
4518c2ecf20Sopenharmony_ci	uint8_t wwpn[WWN_SIZE];
4528c2ecf20Sopenharmony_ci};
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistruct els_plogi_payload {
4558c2ecf20Sopenharmony_ci	uint8_t opcode;
4568c2ecf20Sopenharmony_ci	uint8_t rsvd[3];
4578c2ecf20Sopenharmony_ci	__be32	data[112 / 4];
4588c2ecf20Sopenharmony_ci};
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_cistruct ct_arg {
4618c2ecf20Sopenharmony_ci	void		*iocb;
4628c2ecf20Sopenharmony_ci	u16		nport_handle;
4638c2ecf20Sopenharmony_ci	dma_addr_t	req_dma;
4648c2ecf20Sopenharmony_ci	dma_addr_t	rsp_dma;
4658c2ecf20Sopenharmony_ci	u32		req_size;
4668c2ecf20Sopenharmony_ci	u32		rsp_size;
4678c2ecf20Sopenharmony_ci	u32		req_allocated_size;
4688c2ecf20Sopenharmony_ci	u32		rsp_allocated_size;
4698c2ecf20Sopenharmony_ci	void		*req;
4708c2ecf20Sopenharmony_ci	void		*rsp;
4718c2ecf20Sopenharmony_ci	port_id_t	id;
4728c2ecf20Sopenharmony_ci};
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci/*
4758c2ecf20Sopenharmony_ci * SRB extensions.
4768c2ecf20Sopenharmony_ci */
4778c2ecf20Sopenharmony_cistruct srb_iocb {
4788c2ecf20Sopenharmony_ci	union {
4798c2ecf20Sopenharmony_ci		struct {
4808c2ecf20Sopenharmony_ci			uint16_t flags;
4818c2ecf20Sopenharmony_ci#define SRB_LOGIN_RETRIED	BIT_0
4828c2ecf20Sopenharmony_ci#define SRB_LOGIN_COND_PLOGI	BIT_1
4838c2ecf20Sopenharmony_ci#define SRB_LOGIN_SKIP_PRLI	BIT_2
4848c2ecf20Sopenharmony_ci#define SRB_LOGIN_NVME_PRLI	BIT_3
4858c2ecf20Sopenharmony_ci#define SRB_LOGIN_PRLI_ONLY	BIT_4
4868c2ecf20Sopenharmony_ci			uint16_t data[2];
4878c2ecf20Sopenharmony_ci			u32 iop[2];
4888c2ecf20Sopenharmony_ci		} logio;
4898c2ecf20Sopenharmony_ci		struct {
4908c2ecf20Sopenharmony_ci#define ELS_DCMD_TIMEOUT 20
4918c2ecf20Sopenharmony_ci#define ELS_DCMD_LOGO 0x5
4928c2ecf20Sopenharmony_ci			uint32_t flags;
4938c2ecf20Sopenharmony_ci			uint32_t els_cmd;
4948c2ecf20Sopenharmony_ci			struct completion comp;
4958c2ecf20Sopenharmony_ci			struct els_logo_payload *els_logo_pyld;
4968c2ecf20Sopenharmony_ci			dma_addr_t els_logo_pyld_dma;
4978c2ecf20Sopenharmony_ci		} els_logo;
4988c2ecf20Sopenharmony_ci		struct els_plogi {
4998c2ecf20Sopenharmony_ci#define ELS_DCMD_PLOGI 0x3
5008c2ecf20Sopenharmony_ci			uint32_t flags;
5018c2ecf20Sopenharmony_ci			uint32_t els_cmd;
5028c2ecf20Sopenharmony_ci			struct completion comp;
5038c2ecf20Sopenharmony_ci			struct els_plogi_payload *els_plogi_pyld;
5048c2ecf20Sopenharmony_ci			struct els_plogi_payload *els_resp_pyld;
5058c2ecf20Sopenharmony_ci			u32 tx_size;
5068c2ecf20Sopenharmony_ci			u32 rx_size;
5078c2ecf20Sopenharmony_ci			dma_addr_t els_plogi_pyld_dma;
5088c2ecf20Sopenharmony_ci			dma_addr_t els_resp_pyld_dma;
5098c2ecf20Sopenharmony_ci			__le32	fw_status[3];
5108c2ecf20Sopenharmony_ci			__le16	comp_status;
5118c2ecf20Sopenharmony_ci			__le16	len;
5128c2ecf20Sopenharmony_ci		} els_plogi;
5138c2ecf20Sopenharmony_ci		struct {
5148c2ecf20Sopenharmony_ci			/*
5158c2ecf20Sopenharmony_ci			 * Values for flags field below are as
5168c2ecf20Sopenharmony_ci			 * defined in tsk_mgmt_entry struct
5178c2ecf20Sopenharmony_ci			 * for control_flags field in qla_fw.h.
5188c2ecf20Sopenharmony_ci			 */
5198c2ecf20Sopenharmony_ci			uint64_t lun;
5208c2ecf20Sopenharmony_ci			uint32_t flags;
5218c2ecf20Sopenharmony_ci			uint32_t data;
5228c2ecf20Sopenharmony_ci			struct completion comp;
5238c2ecf20Sopenharmony_ci			__le16 comp_status;
5248c2ecf20Sopenharmony_ci		} tmf;
5258c2ecf20Sopenharmony_ci		struct {
5268c2ecf20Sopenharmony_ci#define SRB_FXDISC_REQ_DMA_VALID	BIT_0
5278c2ecf20Sopenharmony_ci#define SRB_FXDISC_RESP_DMA_VALID	BIT_1
5288c2ecf20Sopenharmony_ci#define SRB_FXDISC_REQ_DWRD_VALID	BIT_2
5298c2ecf20Sopenharmony_ci#define SRB_FXDISC_RSP_DWRD_VALID	BIT_3
5308c2ecf20Sopenharmony_ci#define FXDISC_TIMEOUT 20
5318c2ecf20Sopenharmony_ci			uint8_t flags;
5328c2ecf20Sopenharmony_ci			uint32_t req_len;
5338c2ecf20Sopenharmony_ci			uint32_t rsp_len;
5348c2ecf20Sopenharmony_ci			void *req_addr;
5358c2ecf20Sopenharmony_ci			void *rsp_addr;
5368c2ecf20Sopenharmony_ci			dma_addr_t req_dma_handle;
5378c2ecf20Sopenharmony_ci			dma_addr_t rsp_dma_handle;
5388c2ecf20Sopenharmony_ci			__le32 adapter_id;
5398c2ecf20Sopenharmony_ci			__le32 adapter_id_hi;
5408c2ecf20Sopenharmony_ci			__le16 req_func_type;
5418c2ecf20Sopenharmony_ci			__le32 req_data;
5428c2ecf20Sopenharmony_ci			__le32 req_data_extra;
5438c2ecf20Sopenharmony_ci			__le32 result;
5448c2ecf20Sopenharmony_ci			__le32 seq_number;
5458c2ecf20Sopenharmony_ci			__le16 fw_flags;
5468c2ecf20Sopenharmony_ci			struct completion fxiocb_comp;
5478c2ecf20Sopenharmony_ci			__le32 reserved_0;
5488c2ecf20Sopenharmony_ci			uint8_t reserved_1;
5498c2ecf20Sopenharmony_ci		} fxiocb;
5508c2ecf20Sopenharmony_ci		struct {
5518c2ecf20Sopenharmony_ci			uint32_t cmd_hndl;
5528c2ecf20Sopenharmony_ci			__le16 comp_status;
5538c2ecf20Sopenharmony_ci			__le16 req_que_no;
5548c2ecf20Sopenharmony_ci			struct completion comp;
5558c2ecf20Sopenharmony_ci		} abt;
5568c2ecf20Sopenharmony_ci		struct ct_arg ctarg;
5578c2ecf20Sopenharmony_ci#define MAX_IOCB_MB_REG 28
5588c2ecf20Sopenharmony_ci#define SIZEOF_IOCB_MB_REG (MAX_IOCB_MB_REG * sizeof(uint16_t))
5598c2ecf20Sopenharmony_ci		struct {
5608c2ecf20Sopenharmony_ci			u16 in_mb[MAX_IOCB_MB_REG];	/* from FW */
5618c2ecf20Sopenharmony_ci			u16 out_mb[MAX_IOCB_MB_REG];	/* to FW */
5628c2ecf20Sopenharmony_ci			void *out, *in;
5638c2ecf20Sopenharmony_ci			dma_addr_t out_dma, in_dma;
5648c2ecf20Sopenharmony_ci			struct completion comp;
5658c2ecf20Sopenharmony_ci			int rc;
5668c2ecf20Sopenharmony_ci		} mbx;
5678c2ecf20Sopenharmony_ci		struct {
5688c2ecf20Sopenharmony_ci			struct imm_ntfy_from_isp *ntfy;
5698c2ecf20Sopenharmony_ci		} nack;
5708c2ecf20Sopenharmony_ci		struct {
5718c2ecf20Sopenharmony_ci			__le16 comp_status;
5728c2ecf20Sopenharmony_ci			__le16 rsp_pyld_len;
5738c2ecf20Sopenharmony_ci			uint8_t	aen_op;
5748c2ecf20Sopenharmony_ci			void *desc;
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci			/* These are only used with ls4 requests */
5778c2ecf20Sopenharmony_ci			int cmd_len;
5788c2ecf20Sopenharmony_ci			int rsp_len;
5798c2ecf20Sopenharmony_ci			dma_addr_t cmd_dma;
5808c2ecf20Sopenharmony_ci			dma_addr_t rsp_dma;
5818c2ecf20Sopenharmony_ci			enum nvmefc_fcp_datadir dir;
5828c2ecf20Sopenharmony_ci			uint32_t dl;
5838c2ecf20Sopenharmony_ci			uint32_t timeout_sec;
5848c2ecf20Sopenharmony_ci			struct	list_head   entry;
5858c2ecf20Sopenharmony_ci		} nvme;
5868c2ecf20Sopenharmony_ci		struct {
5878c2ecf20Sopenharmony_ci			u16 cmd;
5888c2ecf20Sopenharmony_ci			u16 vp_index;
5898c2ecf20Sopenharmony_ci		} ctrlvp;
5908c2ecf20Sopenharmony_ci	} u;
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci	struct timer_list timer;
5938c2ecf20Sopenharmony_ci	void (*timeout)(void *);
5948c2ecf20Sopenharmony_ci};
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci/* Values for srb_ctx type */
5978c2ecf20Sopenharmony_ci#define SRB_LOGIN_CMD	1
5988c2ecf20Sopenharmony_ci#define SRB_LOGOUT_CMD	2
5998c2ecf20Sopenharmony_ci#define SRB_ELS_CMD_RPT 3
6008c2ecf20Sopenharmony_ci#define SRB_ELS_CMD_HST 4
6018c2ecf20Sopenharmony_ci#define SRB_CT_CMD	5
6028c2ecf20Sopenharmony_ci#define SRB_ADISC_CMD	6
6038c2ecf20Sopenharmony_ci#define SRB_TM_CMD	7
6048c2ecf20Sopenharmony_ci#define SRB_SCSI_CMD	8
6058c2ecf20Sopenharmony_ci#define SRB_BIDI_CMD	9
6068c2ecf20Sopenharmony_ci#define SRB_FXIOCB_DCMD	10
6078c2ecf20Sopenharmony_ci#define SRB_FXIOCB_BCMD	11
6088c2ecf20Sopenharmony_ci#define SRB_ABT_CMD	12
6098c2ecf20Sopenharmony_ci#define SRB_ELS_DCMD	13
6108c2ecf20Sopenharmony_ci#define SRB_MB_IOCB	14
6118c2ecf20Sopenharmony_ci#define SRB_CT_PTHRU_CMD 15
6128c2ecf20Sopenharmony_ci#define SRB_NACK_PLOGI	16
6138c2ecf20Sopenharmony_ci#define SRB_NACK_PRLI	17
6148c2ecf20Sopenharmony_ci#define SRB_NACK_LOGO	18
6158c2ecf20Sopenharmony_ci#define SRB_NVME_CMD	19
6168c2ecf20Sopenharmony_ci#define SRB_NVME_LS	20
6178c2ecf20Sopenharmony_ci#define SRB_PRLI_CMD	21
6188c2ecf20Sopenharmony_ci#define SRB_CTRL_VP	22
6198c2ecf20Sopenharmony_ci#define SRB_PRLO_CMD	23
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_cienum {
6228c2ecf20Sopenharmony_ci	TYPE_SRB,
6238c2ecf20Sopenharmony_ci	TYPE_TGT_CMD,
6248c2ecf20Sopenharmony_ci	TYPE_TGT_TMCMD,		/* task management */
6258c2ecf20Sopenharmony_ci};
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_cistruct iocb_resource {
6288c2ecf20Sopenharmony_ci	u8 res_type;
6298c2ecf20Sopenharmony_ci	u8 pad;
6308c2ecf20Sopenharmony_ci	u16 iocb_cnt;
6318c2ecf20Sopenharmony_ci};
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_citypedef struct srb {
6348c2ecf20Sopenharmony_ci	/*
6358c2ecf20Sopenharmony_ci	 * Do not move cmd_type field, it needs to
6368c2ecf20Sopenharmony_ci	 * line up with qla_tgt_cmd->cmd_type
6378c2ecf20Sopenharmony_ci	 */
6388c2ecf20Sopenharmony_ci	uint8_t cmd_type;
6398c2ecf20Sopenharmony_ci	uint8_t pad[3];
6408c2ecf20Sopenharmony_ci	struct iocb_resource iores;
6418c2ecf20Sopenharmony_ci	struct kref cmd_kref;	/* need to migrate ref_count over to this */
6428c2ecf20Sopenharmony_ci	void *priv;
6438c2ecf20Sopenharmony_ci	struct fc_port *fcport;
6448c2ecf20Sopenharmony_ci	struct scsi_qla_host *vha;
6458c2ecf20Sopenharmony_ci	unsigned int start_timer:1;
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci	uint32_t handle;
6488c2ecf20Sopenharmony_ci	uint16_t flags;
6498c2ecf20Sopenharmony_ci	uint16_t type;
6508c2ecf20Sopenharmony_ci	const char *name;
6518c2ecf20Sopenharmony_ci	int iocbs;
6528c2ecf20Sopenharmony_ci	struct qla_qpair *qpair;
6538c2ecf20Sopenharmony_ci	struct srb *cmd_sp;
6548c2ecf20Sopenharmony_ci	struct list_head elem;
6558c2ecf20Sopenharmony_ci	u32 gen1;	/* scratch */
6568c2ecf20Sopenharmony_ci	u32 gen2;	/* scratch */
6578c2ecf20Sopenharmony_ci	int rc;
6588c2ecf20Sopenharmony_ci	int retry_count;
6598c2ecf20Sopenharmony_ci	struct completion *comp;
6608c2ecf20Sopenharmony_ci	union {
6618c2ecf20Sopenharmony_ci		struct srb_iocb iocb_cmd;
6628c2ecf20Sopenharmony_ci		struct bsg_job *bsg_job;
6638c2ecf20Sopenharmony_ci		struct srb_cmd scmd;
6648c2ecf20Sopenharmony_ci	} u;
6658c2ecf20Sopenharmony_ci	/*
6668c2ecf20Sopenharmony_ci	 * Report completion status @res and call sp_put(@sp). @res is
6678c2ecf20Sopenharmony_ci	 * an NVMe status code, a SCSI result (e.g. DID_OK << 16) or a
6688c2ecf20Sopenharmony_ci	 * QLA_* status value.
6698c2ecf20Sopenharmony_ci	 */
6708c2ecf20Sopenharmony_ci	void (*done)(struct srb *sp, int res);
6718c2ecf20Sopenharmony_ci	/* Stop the timer and free @sp. Only used by the FCP code. */
6728c2ecf20Sopenharmony_ci	void (*free)(struct srb *sp);
6738c2ecf20Sopenharmony_ci	/*
6748c2ecf20Sopenharmony_ci	 * Call nvme_private->fd->done() and free @sp. Only used by the NVMe
6758c2ecf20Sopenharmony_ci	 * code.
6768c2ecf20Sopenharmony_ci	 */
6778c2ecf20Sopenharmony_ci	void (*put_fn)(struct kref *kref);
6788c2ecf20Sopenharmony_ci} srb_t;
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci#define GET_CMD_SP(sp) (sp->u.scmd.cmd)
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci#define GET_CMD_SENSE_LEN(sp) \
6838c2ecf20Sopenharmony_ci	(sp->u.scmd.request_sense_length)
6848c2ecf20Sopenharmony_ci#define SET_CMD_SENSE_LEN(sp, len) \
6858c2ecf20Sopenharmony_ci	(sp->u.scmd.request_sense_length = len)
6868c2ecf20Sopenharmony_ci#define GET_CMD_SENSE_PTR(sp) \
6878c2ecf20Sopenharmony_ci	(sp->u.scmd.request_sense_ptr)
6888c2ecf20Sopenharmony_ci#define SET_CMD_SENSE_PTR(sp, ptr) \
6898c2ecf20Sopenharmony_ci	(sp->u.scmd.request_sense_ptr = ptr)
6908c2ecf20Sopenharmony_ci#define GET_FW_SENSE_LEN(sp) \
6918c2ecf20Sopenharmony_ci	(sp->u.scmd.fw_sense_length)
6928c2ecf20Sopenharmony_ci#define SET_FW_SENSE_LEN(sp, len) \
6938c2ecf20Sopenharmony_ci	(sp->u.scmd.fw_sense_length = len)
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_cistruct msg_echo_lb {
6968c2ecf20Sopenharmony_ci	dma_addr_t send_dma;
6978c2ecf20Sopenharmony_ci	dma_addr_t rcv_dma;
6988c2ecf20Sopenharmony_ci	uint16_t req_sg_cnt;
6998c2ecf20Sopenharmony_ci	uint16_t rsp_sg_cnt;
7008c2ecf20Sopenharmony_ci	uint16_t options;
7018c2ecf20Sopenharmony_ci	uint32_t transfer_size;
7028c2ecf20Sopenharmony_ci	uint32_t iteration_count;
7038c2ecf20Sopenharmony_ci};
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci/*
7068c2ecf20Sopenharmony_ci * ISP I/O Register Set structure definitions.
7078c2ecf20Sopenharmony_ci */
7088c2ecf20Sopenharmony_cistruct device_reg_2xxx {
7098c2ecf20Sopenharmony_ci	__le16	flash_address; 	/* Flash BIOS address */
7108c2ecf20Sopenharmony_ci	__le16	flash_data;		/* Flash BIOS data */
7118c2ecf20Sopenharmony_ci	__le16	unused_1[1];		/* Gap */
7128c2ecf20Sopenharmony_ci	__le16	ctrl_status;		/* Control/Status */
7138c2ecf20Sopenharmony_ci#define CSR_FLASH_64K_BANK	BIT_3	/* Flash upper 64K bank select */
7148c2ecf20Sopenharmony_ci#define CSR_FLASH_ENABLE	BIT_1	/* Flash BIOS Read/Write enable */
7158c2ecf20Sopenharmony_ci#define CSR_ISP_SOFT_RESET	BIT_0	/* ISP soft reset */
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci	__le16	ictrl;			/* Interrupt control */
7188c2ecf20Sopenharmony_ci#define ICR_EN_INT		BIT_15	/* ISP enable interrupts. */
7198c2ecf20Sopenharmony_ci#define ICR_EN_RISC		BIT_3	/* ISP enable RISC interrupts. */
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_ci	__le16	istatus;		/* Interrupt status */
7228c2ecf20Sopenharmony_ci#define ISR_RISC_INT		BIT_3	/* RISC interrupt */
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci	__le16	semaphore;		/* Semaphore */
7258c2ecf20Sopenharmony_ci	__le16	nvram;			/* NVRAM register. */
7268c2ecf20Sopenharmony_ci#define NVR_DESELECT		0
7278c2ecf20Sopenharmony_ci#define NVR_BUSY		BIT_15
7288c2ecf20Sopenharmony_ci#define NVR_WRT_ENABLE		BIT_14	/* Write enable */
7298c2ecf20Sopenharmony_ci#define NVR_PR_ENABLE		BIT_13	/* Protection register enable */
7308c2ecf20Sopenharmony_ci#define NVR_DATA_IN		BIT_3
7318c2ecf20Sopenharmony_ci#define NVR_DATA_OUT		BIT_2
7328c2ecf20Sopenharmony_ci#define NVR_SELECT		BIT_1
7338c2ecf20Sopenharmony_ci#define NVR_CLOCK		BIT_0
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci#define NVR_WAIT_CNT		20000
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci	union {
7388c2ecf20Sopenharmony_ci		struct {
7398c2ecf20Sopenharmony_ci			__le16	mailbox0;
7408c2ecf20Sopenharmony_ci			__le16	mailbox1;
7418c2ecf20Sopenharmony_ci			__le16	mailbox2;
7428c2ecf20Sopenharmony_ci			__le16	mailbox3;
7438c2ecf20Sopenharmony_ci			__le16	mailbox4;
7448c2ecf20Sopenharmony_ci			__le16	mailbox5;
7458c2ecf20Sopenharmony_ci			__le16	mailbox6;
7468c2ecf20Sopenharmony_ci			__le16	mailbox7;
7478c2ecf20Sopenharmony_ci			__le16	unused_2[59];	/* Gap */
7488c2ecf20Sopenharmony_ci		} __attribute__((packed)) isp2100;
7498c2ecf20Sopenharmony_ci		struct {
7508c2ecf20Sopenharmony_ci						/* Request Queue */
7518c2ecf20Sopenharmony_ci			__le16	req_q_in;	/*  In-Pointer */
7528c2ecf20Sopenharmony_ci			__le16	req_q_out;	/*  Out-Pointer */
7538c2ecf20Sopenharmony_ci						/* Response Queue */
7548c2ecf20Sopenharmony_ci			__le16	rsp_q_in;	/*  In-Pointer */
7558c2ecf20Sopenharmony_ci			__le16	rsp_q_out;	/*  Out-Pointer */
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_ci						/* RISC to Host Status */
7588c2ecf20Sopenharmony_ci			__le32	host_status;
7598c2ecf20Sopenharmony_ci#define HSR_RISC_INT		BIT_15	/* RISC interrupt */
7608c2ecf20Sopenharmony_ci#define HSR_RISC_PAUSED		BIT_8	/* RISC Paused */
7618c2ecf20Sopenharmony_ci
7628c2ecf20Sopenharmony_ci					/* Host to Host Semaphore */
7638c2ecf20Sopenharmony_ci			__le16	host_semaphore;
7648c2ecf20Sopenharmony_ci			__le16	unused_3[17];	/* Gap */
7658c2ecf20Sopenharmony_ci			__le16	mailbox0;
7668c2ecf20Sopenharmony_ci			__le16	mailbox1;
7678c2ecf20Sopenharmony_ci			__le16	mailbox2;
7688c2ecf20Sopenharmony_ci			__le16	mailbox3;
7698c2ecf20Sopenharmony_ci			__le16	mailbox4;
7708c2ecf20Sopenharmony_ci			__le16	mailbox5;
7718c2ecf20Sopenharmony_ci			__le16	mailbox6;
7728c2ecf20Sopenharmony_ci			__le16	mailbox7;
7738c2ecf20Sopenharmony_ci			__le16	mailbox8;
7748c2ecf20Sopenharmony_ci			__le16	mailbox9;
7758c2ecf20Sopenharmony_ci			__le16	mailbox10;
7768c2ecf20Sopenharmony_ci			__le16	mailbox11;
7778c2ecf20Sopenharmony_ci			__le16	mailbox12;
7788c2ecf20Sopenharmony_ci			__le16	mailbox13;
7798c2ecf20Sopenharmony_ci			__le16	mailbox14;
7808c2ecf20Sopenharmony_ci			__le16	mailbox15;
7818c2ecf20Sopenharmony_ci			__le16	mailbox16;
7828c2ecf20Sopenharmony_ci			__le16	mailbox17;
7838c2ecf20Sopenharmony_ci			__le16	mailbox18;
7848c2ecf20Sopenharmony_ci			__le16	mailbox19;
7858c2ecf20Sopenharmony_ci			__le16	mailbox20;
7868c2ecf20Sopenharmony_ci			__le16	mailbox21;
7878c2ecf20Sopenharmony_ci			__le16	mailbox22;
7888c2ecf20Sopenharmony_ci			__le16	mailbox23;
7898c2ecf20Sopenharmony_ci			__le16	mailbox24;
7908c2ecf20Sopenharmony_ci			__le16	mailbox25;
7918c2ecf20Sopenharmony_ci			__le16	mailbox26;
7928c2ecf20Sopenharmony_ci			__le16	mailbox27;
7938c2ecf20Sopenharmony_ci			__le16	mailbox28;
7948c2ecf20Sopenharmony_ci			__le16	mailbox29;
7958c2ecf20Sopenharmony_ci			__le16	mailbox30;
7968c2ecf20Sopenharmony_ci			__le16	mailbox31;
7978c2ecf20Sopenharmony_ci			__le16	fb_cmd;
7988c2ecf20Sopenharmony_ci			__le16	unused_4[10];	/* Gap */
7998c2ecf20Sopenharmony_ci		} __attribute__((packed)) isp2300;
8008c2ecf20Sopenharmony_ci	} u;
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_ci	__le16	fpm_diag_config;
8038c2ecf20Sopenharmony_ci	__le16	unused_5[0x4];		/* Gap */
8048c2ecf20Sopenharmony_ci	__le16	risc_hw;
8058c2ecf20Sopenharmony_ci	__le16	unused_5_1;		/* Gap */
8068c2ecf20Sopenharmony_ci	__le16	pcr;			/* Processor Control Register. */
8078c2ecf20Sopenharmony_ci	__le16	unused_6[0x5];		/* Gap */
8088c2ecf20Sopenharmony_ci	__le16	mctr;			/* Memory Configuration and Timing. */
8098c2ecf20Sopenharmony_ci	__le16	unused_7[0x3];		/* Gap */
8108c2ecf20Sopenharmony_ci	__le16	fb_cmd_2100;		/* Unused on 23XX */
8118c2ecf20Sopenharmony_ci	__le16	unused_8[0x3];		/* Gap */
8128c2ecf20Sopenharmony_ci	__le16	hccr;			/* Host command & control register. */
8138c2ecf20Sopenharmony_ci#define HCCR_HOST_INT		BIT_7	/* Host interrupt bit */
8148c2ecf20Sopenharmony_ci#define HCCR_RISC_PAUSE		BIT_5	/* Pause mode bit */
8158c2ecf20Sopenharmony_ci					/* HCCR commands */
8168c2ecf20Sopenharmony_ci#define HCCR_RESET_RISC		0x1000	/* Reset RISC */
8178c2ecf20Sopenharmony_ci#define HCCR_PAUSE_RISC		0x2000	/* Pause RISC */
8188c2ecf20Sopenharmony_ci#define HCCR_RELEASE_RISC	0x3000	/* Release RISC from reset. */
8198c2ecf20Sopenharmony_ci#define HCCR_SET_HOST_INT	0x5000	/* Set host interrupt */
8208c2ecf20Sopenharmony_ci#define HCCR_CLR_HOST_INT	0x6000	/* Clear HOST interrupt */
8218c2ecf20Sopenharmony_ci#define HCCR_CLR_RISC_INT	0x7000	/* Clear RISC interrupt */
8228c2ecf20Sopenharmony_ci#define	HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */
8238c2ecf20Sopenharmony_ci#define HCCR_ENABLE_PARITY	0xA000	/* Enable PARITY interrupt */
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci	__le16	unused_9[5];		/* Gap */
8268c2ecf20Sopenharmony_ci	__le16	gpiod;			/* GPIO Data register. */
8278c2ecf20Sopenharmony_ci	__le16	gpioe;			/* GPIO Enable register. */
8288c2ecf20Sopenharmony_ci#define GPIO_LED_MASK			0x00C0
8298c2ecf20Sopenharmony_ci#define GPIO_LED_GREEN_OFF_AMBER_OFF	0x0000
8308c2ecf20Sopenharmony_ci#define GPIO_LED_GREEN_ON_AMBER_OFF	0x0040
8318c2ecf20Sopenharmony_ci#define GPIO_LED_GREEN_OFF_AMBER_ON	0x0080
8328c2ecf20Sopenharmony_ci#define GPIO_LED_GREEN_ON_AMBER_ON	0x00C0
8338c2ecf20Sopenharmony_ci#define GPIO_LED_ALL_OFF		0x0000
8348c2ecf20Sopenharmony_ci#define GPIO_LED_RED_ON_OTHER_OFF	0x0001	/* isp2322 */
8358c2ecf20Sopenharmony_ci#define GPIO_LED_RGA_ON			0x00C1	/* isp2322: red green amber */
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci	union {
8388c2ecf20Sopenharmony_ci		struct {
8398c2ecf20Sopenharmony_ci			__le16	unused_10[8];	/* Gap */
8408c2ecf20Sopenharmony_ci			__le16	mailbox8;
8418c2ecf20Sopenharmony_ci			__le16	mailbox9;
8428c2ecf20Sopenharmony_ci			__le16	mailbox10;
8438c2ecf20Sopenharmony_ci			__le16	mailbox11;
8448c2ecf20Sopenharmony_ci			__le16	mailbox12;
8458c2ecf20Sopenharmony_ci			__le16	mailbox13;
8468c2ecf20Sopenharmony_ci			__le16	mailbox14;
8478c2ecf20Sopenharmony_ci			__le16	mailbox15;
8488c2ecf20Sopenharmony_ci			__le16	mailbox16;
8498c2ecf20Sopenharmony_ci			__le16	mailbox17;
8508c2ecf20Sopenharmony_ci			__le16	mailbox18;
8518c2ecf20Sopenharmony_ci			__le16	mailbox19;
8528c2ecf20Sopenharmony_ci			__le16	mailbox20;
8538c2ecf20Sopenharmony_ci			__le16	mailbox21;
8548c2ecf20Sopenharmony_ci			__le16	mailbox22;
8558c2ecf20Sopenharmony_ci			__le16	mailbox23;	/* Also probe reg. */
8568c2ecf20Sopenharmony_ci		} __attribute__((packed)) isp2200;
8578c2ecf20Sopenharmony_ci	} u_end;
8588c2ecf20Sopenharmony_ci};
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_cistruct device_reg_25xxmq {
8618c2ecf20Sopenharmony_ci	__le32	req_q_in;
8628c2ecf20Sopenharmony_ci	__le32	req_q_out;
8638c2ecf20Sopenharmony_ci	__le32	rsp_q_in;
8648c2ecf20Sopenharmony_ci	__le32	rsp_q_out;
8658c2ecf20Sopenharmony_ci	__le32	atio_q_in;
8668c2ecf20Sopenharmony_ci	__le32	atio_q_out;
8678c2ecf20Sopenharmony_ci};
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_cistruct device_reg_fx00 {
8718c2ecf20Sopenharmony_ci	__le32	mailbox0;		/* 00 */
8728c2ecf20Sopenharmony_ci	__le32	mailbox1;		/* 04 */
8738c2ecf20Sopenharmony_ci	__le32	mailbox2;		/* 08 */
8748c2ecf20Sopenharmony_ci	__le32	mailbox3;		/* 0C */
8758c2ecf20Sopenharmony_ci	__le32	mailbox4;		/* 10 */
8768c2ecf20Sopenharmony_ci	__le32	mailbox5;		/* 14 */
8778c2ecf20Sopenharmony_ci	__le32	mailbox6;		/* 18 */
8788c2ecf20Sopenharmony_ci	__le32	mailbox7;		/* 1C */
8798c2ecf20Sopenharmony_ci	__le32	mailbox8;		/* 20 */
8808c2ecf20Sopenharmony_ci	__le32	mailbox9;		/* 24 */
8818c2ecf20Sopenharmony_ci	__le32	mailbox10;		/* 28 */
8828c2ecf20Sopenharmony_ci	__le32	mailbox11;
8838c2ecf20Sopenharmony_ci	__le32	mailbox12;
8848c2ecf20Sopenharmony_ci	__le32	mailbox13;
8858c2ecf20Sopenharmony_ci	__le32	mailbox14;
8868c2ecf20Sopenharmony_ci	__le32	mailbox15;
8878c2ecf20Sopenharmony_ci	__le32	mailbox16;
8888c2ecf20Sopenharmony_ci	__le32	mailbox17;
8898c2ecf20Sopenharmony_ci	__le32	mailbox18;
8908c2ecf20Sopenharmony_ci	__le32	mailbox19;
8918c2ecf20Sopenharmony_ci	__le32	mailbox20;
8928c2ecf20Sopenharmony_ci	__le32	mailbox21;
8938c2ecf20Sopenharmony_ci	__le32	mailbox22;
8948c2ecf20Sopenharmony_ci	__le32	mailbox23;
8958c2ecf20Sopenharmony_ci	__le32	mailbox24;
8968c2ecf20Sopenharmony_ci	__le32	mailbox25;
8978c2ecf20Sopenharmony_ci	__le32	mailbox26;
8988c2ecf20Sopenharmony_ci	__le32	mailbox27;
8998c2ecf20Sopenharmony_ci	__le32	mailbox28;
9008c2ecf20Sopenharmony_ci	__le32	mailbox29;
9018c2ecf20Sopenharmony_ci	__le32	mailbox30;
9028c2ecf20Sopenharmony_ci	__le32	mailbox31;
9038c2ecf20Sopenharmony_ci	__le32	aenmailbox0;
9048c2ecf20Sopenharmony_ci	__le32	aenmailbox1;
9058c2ecf20Sopenharmony_ci	__le32	aenmailbox2;
9068c2ecf20Sopenharmony_ci	__le32	aenmailbox3;
9078c2ecf20Sopenharmony_ci	__le32	aenmailbox4;
9088c2ecf20Sopenharmony_ci	__le32	aenmailbox5;
9098c2ecf20Sopenharmony_ci	__le32	aenmailbox6;
9108c2ecf20Sopenharmony_ci	__le32	aenmailbox7;
9118c2ecf20Sopenharmony_ci	/* Request Queue. */
9128c2ecf20Sopenharmony_ci	__le32	req_q_in;		/* A0 - Request Queue In-Pointer */
9138c2ecf20Sopenharmony_ci	__le32	req_q_out;		/* A4 - Request Queue Out-Pointer */
9148c2ecf20Sopenharmony_ci	/* Response Queue. */
9158c2ecf20Sopenharmony_ci	__le32	rsp_q_in;		/* A8 - Response Queue In-Pointer */
9168c2ecf20Sopenharmony_ci	__le32	rsp_q_out;		/* AC - Response Queue Out-Pointer */
9178c2ecf20Sopenharmony_ci	/* Init values shadowed on FW Up Event */
9188c2ecf20Sopenharmony_ci	__le32	initval0;		/* B0 */
9198c2ecf20Sopenharmony_ci	__le32	initval1;		/* B4 */
9208c2ecf20Sopenharmony_ci	__le32	initval2;		/* B8 */
9218c2ecf20Sopenharmony_ci	__le32	initval3;		/* BC */
9228c2ecf20Sopenharmony_ci	__le32	initval4;		/* C0 */
9238c2ecf20Sopenharmony_ci	__le32	initval5;		/* C4 */
9248c2ecf20Sopenharmony_ci	__le32	initval6;		/* C8 */
9258c2ecf20Sopenharmony_ci	__le32	initval7;		/* CC */
9268c2ecf20Sopenharmony_ci	__le32	fwheartbeat;		/* D0 */
9278c2ecf20Sopenharmony_ci	__le32	pseudoaen;		/* D4 */
9288c2ecf20Sopenharmony_ci};
9298c2ecf20Sopenharmony_ci
9308c2ecf20Sopenharmony_ci
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_citypedef union {
9338c2ecf20Sopenharmony_ci		struct device_reg_2xxx isp;
9348c2ecf20Sopenharmony_ci		struct device_reg_24xx isp24;
9358c2ecf20Sopenharmony_ci		struct device_reg_25xxmq isp25mq;
9368c2ecf20Sopenharmony_ci		struct device_reg_82xx isp82;
9378c2ecf20Sopenharmony_ci		struct device_reg_fx00 ispfx00;
9388c2ecf20Sopenharmony_ci} __iomem device_reg_t;
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_ci#define ISP_REQ_Q_IN(ha, reg) \
9418c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9428c2ecf20Sopenharmony_ci	 &(reg)->u.isp2100.mailbox4 : \
9438c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.req_q_in)
9448c2ecf20Sopenharmony_ci#define ISP_REQ_Q_OUT(ha, reg) \
9458c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9468c2ecf20Sopenharmony_ci	 &(reg)->u.isp2100.mailbox4 : \
9478c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.req_q_out)
9488c2ecf20Sopenharmony_ci#define ISP_RSP_Q_IN(ha, reg) \
9498c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9508c2ecf20Sopenharmony_ci	 &(reg)->u.isp2100.mailbox5 : \
9518c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.rsp_q_in)
9528c2ecf20Sopenharmony_ci#define ISP_RSP_Q_OUT(ha, reg) \
9538c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9548c2ecf20Sopenharmony_ci	 &(reg)->u.isp2100.mailbox5 : \
9558c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.rsp_q_out)
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ci#define ISP_ATIO_Q_IN(vha) (vha->hw->tgt.atio_q_in)
9588c2ecf20Sopenharmony_ci#define ISP_ATIO_Q_OUT(vha) (vha->hw->tgt.atio_q_out)
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_ci#define MAILBOX_REG(ha, reg, num) \
9618c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9628c2ecf20Sopenharmony_ci	 (num < 8 ? \
9638c2ecf20Sopenharmony_ci	  &(reg)->u.isp2100.mailbox0 + (num) : \
9648c2ecf20Sopenharmony_ci	  &(reg)->u_end.isp2200.mailbox8 + (num) - 8) : \
9658c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.mailbox0 + (num))
9668c2ecf20Sopenharmony_ci#define RD_MAILBOX_REG(ha, reg, num) \
9678c2ecf20Sopenharmony_ci	rd_reg_word(MAILBOX_REG(ha, reg, num))
9688c2ecf20Sopenharmony_ci#define WRT_MAILBOX_REG(ha, reg, num, data) \
9698c2ecf20Sopenharmony_ci	wrt_reg_word(MAILBOX_REG(ha, reg, num), data)
9708c2ecf20Sopenharmony_ci
9718c2ecf20Sopenharmony_ci#define FB_CMD_REG(ha, reg) \
9728c2ecf20Sopenharmony_ci	(IS_QLA2100(ha) || IS_QLA2200(ha) ? \
9738c2ecf20Sopenharmony_ci	 &(reg)->fb_cmd_2100 : \
9748c2ecf20Sopenharmony_ci	 &(reg)->u.isp2300.fb_cmd)
9758c2ecf20Sopenharmony_ci#define RD_FB_CMD_REG(ha, reg) \
9768c2ecf20Sopenharmony_ci	rd_reg_word(FB_CMD_REG(ha, reg))
9778c2ecf20Sopenharmony_ci#define WRT_FB_CMD_REG(ha, reg, data) \
9788c2ecf20Sopenharmony_ci	wrt_reg_word(FB_CMD_REG(ha, reg), data)
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_citypedef struct {
9818c2ecf20Sopenharmony_ci	uint32_t	out_mb;		/* outbound from driver */
9828c2ecf20Sopenharmony_ci	uint32_t	in_mb;			/* Incoming from RISC */
9838c2ecf20Sopenharmony_ci	uint16_t	mb[MAILBOX_REGISTER_COUNT];
9848c2ecf20Sopenharmony_ci	long		buf_size;
9858c2ecf20Sopenharmony_ci	void		*bufp;
9868c2ecf20Sopenharmony_ci	uint32_t	tov;
9878c2ecf20Sopenharmony_ci	uint8_t		flags;
9888c2ecf20Sopenharmony_ci#define MBX_DMA_IN	BIT_0
9898c2ecf20Sopenharmony_ci#define	MBX_DMA_OUT	BIT_1
9908c2ecf20Sopenharmony_ci#define IOCTL_CMD	BIT_2
9918c2ecf20Sopenharmony_ci} mbx_cmd_t;
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_cistruct mbx_cmd_32 {
9948c2ecf20Sopenharmony_ci	uint32_t	out_mb;		/* outbound from driver */
9958c2ecf20Sopenharmony_ci	uint32_t	in_mb;			/* Incoming from RISC */
9968c2ecf20Sopenharmony_ci	uint32_t	mb[MAILBOX_REGISTER_COUNT];
9978c2ecf20Sopenharmony_ci	long		buf_size;
9988c2ecf20Sopenharmony_ci	void		*bufp;
9998c2ecf20Sopenharmony_ci	uint32_t	tov;
10008c2ecf20Sopenharmony_ci	uint8_t		flags;
10018c2ecf20Sopenharmony_ci#define MBX_DMA_IN	BIT_0
10028c2ecf20Sopenharmony_ci#define	MBX_DMA_OUT	BIT_1
10038c2ecf20Sopenharmony_ci#define IOCTL_CMD	BIT_2
10048c2ecf20Sopenharmony_ci};
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ci#define	MBX_TOV_SECONDS	30
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_ci/*
10108c2ecf20Sopenharmony_ci *  ISP product identification definitions in mailboxes after reset.
10118c2ecf20Sopenharmony_ci */
10128c2ecf20Sopenharmony_ci#define PROD_ID_1		0x4953
10138c2ecf20Sopenharmony_ci#define PROD_ID_2		0x0000
10148c2ecf20Sopenharmony_ci#define PROD_ID_2a		0x5020
10158c2ecf20Sopenharmony_ci#define PROD_ID_3		0x2020
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci/*
10188c2ecf20Sopenharmony_ci * ISP mailbox Self-Test status codes
10198c2ecf20Sopenharmony_ci */
10208c2ecf20Sopenharmony_ci#define MBS_FRM_ALIVE		0	/* Firmware Alive. */
10218c2ecf20Sopenharmony_ci#define MBS_CHKSUM_ERR		1	/* Checksum Error. */
10228c2ecf20Sopenharmony_ci#define MBS_BUSY		4	/* Busy. */
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ci/*
10258c2ecf20Sopenharmony_ci * ISP mailbox command complete status codes
10268c2ecf20Sopenharmony_ci */
10278c2ecf20Sopenharmony_ci#define MBS_COMMAND_COMPLETE		0x4000
10288c2ecf20Sopenharmony_ci#define MBS_INVALID_COMMAND		0x4001
10298c2ecf20Sopenharmony_ci#define MBS_HOST_INTERFACE_ERROR	0x4002
10308c2ecf20Sopenharmony_ci#define MBS_TEST_FAILED			0x4003
10318c2ecf20Sopenharmony_ci#define MBS_COMMAND_ERROR		0x4005
10328c2ecf20Sopenharmony_ci#define MBS_COMMAND_PARAMETER_ERROR	0x4006
10338c2ecf20Sopenharmony_ci#define MBS_PORT_ID_USED		0x4007
10348c2ecf20Sopenharmony_ci#define MBS_LOOP_ID_USED		0x4008
10358c2ecf20Sopenharmony_ci#define MBS_ALL_IDS_IN_USE		0x4009
10368c2ecf20Sopenharmony_ci#define MBS_NOT_LOGGED_IN		0x400A
10378c2ecf20Sopenharmony_ci#define MBS_LINK_DOWN_ERROR		0x400B
10388c2ecf20Sopenharmony_ci#define MBS_DIAG_ECHO_TEST_ERROR	0x400C
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_cistatic inline bool qla2xxx_is_valid_mbs(unsigned int mbs)
10418c2ecf20Sopenharmony_ci{
10428c2ecf20Sopenharmony_ci	return MBS_COMMAND_COMPLETE <= mbs && mbs <= MBS_DIAG_ECHO_TEST_ERROR;
10438c2ecf20Sopenharmony_ci}
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_ci/*
10468c2ecf20Sopenharmony_ci * ISP mailbox asynchronous event status codes
10478c2ecf20Sopenharmony_ci */
10488c2ecf20Sopenharmony_ci#define MBA_ASYNC_EVENT		0x8000	/* Asynchronous event. */
10498c2ecf20Sopenharmony_ci#define MBA_RESET		0x8001	/* Reset Detected. */
10508c2ecf20Sopenharmony_ci#define MBA_SYSTEM_ERR		0x8002	/* System Error. */
10518c2ecf20Sopenharmony_ci#define MBA_REQ_TRANSFER_ERR	0x8003	/* Request Transfer Error. */
10528c2ecf20Sopenharmony_ci#define MBA_RSP_TRANSFER_ERR	0x8004	/* Response Transfer Error. */
10538c2ecf20Sopenharmony_ci#define MBA_WAKEUP_THRES	0x8005	/* Request Queue Wake-up. */
10548c2ecf20Sopenharmony_ci#define MBA_LIP_OCCURRED	0x8010	/* Loop Initialization Procedure */
10558c2ecf20Sopenharmony_ci					/* occurred. */
10568c2ecf20Sopenharmony_ci#define MBA_LOOP_UP		0x8011	/* FC Loop UP. */
10578c2ecf20Sopenharmony_ci#define MBA_LOOP_DOWN		0x8012	/* FC Loop Down. */
10588c2ecf20Sopenharmony_ci#define MBA_LIP_RESET		0x8013	/* LIP reset occurred. */
10598c2ecf20Sopenharmony_ci#define MBA_PORT_UPDATE		0x8014	/* Port Database update. */
10608c2ecf20Sopenharmony_ci#define MBA_RSCN_UPDATE		0x8015	/* Register State Chg Notification. */
10618c2ecf20Sopenharmony_ci#define MBA_LIP_F8		0x8016	/* Received a LIP F8. */
10628c2ecf20Sopenharmony_ci#define MBA_LOOP_INIT_ERR	0x8017	/* Loop Initialization Error. */
10638c2ecf20Sopenharmony_ci#define MBA_FABRIC_AUTH_REQ	0x801b	/* Fabric Authentication Required. */
10648c2ecf20Sopenharmony_ci#define MBA_CONGN_NOTI_RECV	0x801e	/* Congestion Notification Received */
10658c2ecf20Sopenharmony_ci#define MBA_SCSI_COMPLETION	0x8020	/* SCSI Command Complete. */
10668c2ecf20Sopenharmony_ci#define MBA_CTIO_COMPLETION	0x8021	/* CTIO Complete. */
10678c2ecf20Sopenharmony_ci#define MBA_IP_COMPLETION	0x8022	/* IP Transmit Command Complete. */
10688c2ecf20Sopenharmony_ci#define MBA_IP_RECEIVE		0x8023	/* IP Received. */
10698c2ecf20Sopenharmony_ci#define MBA_IP_BROADCAST	0x8024	/* IP Broadcast Received. */
10708c2ecf20Sopenharmony_ci#define MBA_IP_LOW_WATER_MARK	0x8025	/* IP Low Water Mark reached. */
10718c2ecf20Sopenharmony_ci#define MBA_IP_RCV_BUFFER_EMPTY 0x8026	/* IP receive buffer queue empty. */
10728c2ecf20Sopenharmony_ci#define MBA_IP_HDR_DATA_SPLIT	0x8027	/* IP header/data splitting feature */
10738c2ecf20Sopenharmony_ci					/* used. */
10748c2ecf20Sopenharmony_ci#define MBA_TRACE_NOTIFICATION	0x8028	/* Trace/Diagnostic notification. */
10758c2ecf20Sopenharmony_ci#define MBA_POINT_TO_POINT	0x8030	/* Point to point mode. */
10768c2ecf20Sopenharmony_ci#define MBA_CMPLT_1_16BIT	0x8031	/* Completion 1 16bit IOSB. */
10778c2ecf20Sopenharmony_ci#define MBA_CMPLT_2_16BIT	0x8032	/* Completion 2 16bit IOSB. */
10788c2ecf20Sopenharmony_ci#define MBA_CMPLT_3_16BIT	0x8033	/* Completion 3 16bit IOSB. */
10798c2ecf20Sopenharmony_ci#define MBA_CMPLT_4_16BIT	0x8034	/* Completion 4 16bit IOSB. */
10808c2ecf20Sopenharmony_ci#define MBA_CMPLT_5_16BIT	0x8035	/* Completion 5 16bit IOSB. */
10818c2ecf20Sopenharmony_ci#define MBA_CHG_IN_CONNECTION	0x8036	/* Change in connection mode. */
10828c2ecf20Sopenharmony_ci#define MBA_RIO_RESPONSE	0x8040	/* RIO response queue update. */
10838c2ecf20Sopenharmony_ci#define MBA_ZIO_RESPONSE	0x8040	/* ZIO response queue update. */
10848c2ecf20Sopenharmony_ci#define MBA_CMPLT_2_32BIT	0x8042	/* Completion 2 32bit IOSB. */
10858c2ecf20Sopenharmony_ci#define MBA_BYPASS_NOTIFICATION	0x8043	/* Auto bypass notification. */
10868c2ecf20Sopenharmony_ci#define MBA_DISCARD_RND_FRAME	0x8048	/* discard RND frame due to error. */
10878c2ecf20Sopenharmony_ci#define MBA_REJECTED_FCP_CMD	0x8049	/* rejected FCP_CMD. */
10888c2ecf20Sopenharmony_ci#define MBA_FW_NOT_STARTED	0x8050	/* Firmware not started */
10898c2ecf20Sopenharmony_ci#define MBA_FW_STARTING		0x8051	/* Firmware starting */
10908c2ecf20Sopenharmony_ci#define MBA_FW_RESTART_CMPLT	0x8060	/* Firmware restart complete */
10918c2ecf20Sopenharmony_ci#define MBA_INIT_REQUIRED	0x8061	/* Initialization required */
10928c2ecf20Sopenharmony_ci#define MBA_SHUTDOWN_REQUESTED	0x8062	/* Shutdown Requested */
10938c2ecf20Sopenharmony_ci#define MBA_TEMPERATURE_ALERT	0x8070	/* Temperature Alert */
10948c2ecf20Sopenharmony_ci#define MBA_DPORT_DIAGNOSTICS	0x8080	/* D-port Diagnostics */
10958c2ecf20Sopenharmony_ci#define MBA_TRANS_INSERT	0x8130	/* Transceiver Insertion */
10968c2ecf20Sopenharmony_ci#define MBA_TRANS_REMOVE	0x8131	/* Transceiver Removal */
10978c2ecf20Sopenharmony_ci#define MBA_FW_INIT_FAILURE	0x8401	/* Firmware initialization failure */
10988c2ecf20Sopenharmony_ci#define MBA_MIRROR_LUN_CHANGE	0x8402	/* Mirror LUN State Change
10998c2ecf20Sopenharmony_ci					   Notification */
11008c2ecf20Sopenharmony_ci#define MBA_FW_POLL_STATE	0x8600  /* Firmware in poll diagnostic state */
11018c2ecf20Sopenharmony_ci#define MBA_FW_RESET_FCT	0x8502	/* Firmware reset factory defaults */
11028c2ecf20Sopenharmony_ci#define MBA_FW_INIT_INPROGRESS	0x8500	/* Firmware boot in progress */
11038c2ecf20Sopenharmony_ci/* 83XX FCoE specific */
11048c2ecf20Sopenharmony_ci#define MBA_IDC_AEN		0x8200  /* FCoE: NIC Core state change AEN */
11058c2ecf20Sopenharmony_ci
11068c2ecf20Sopenharmony_ci/* Interrupt type codes */
11078c2ecf20Sopenharmony_ci#define INTR_ROM_MB_SUCCESS		0x1
11088c2ecf20Sopenharmony_ci#define INTR_ROM_MB_FAILED		0x2
11098c2ecf20Sopenharmony_ci#define INTR_MB_SUCCESS			0x10
11108c2ecf20Sopenharmony_ci#define INTR_MB_FAILED			0x11
11118c2ecf20Sopenharmony_ci#define INTR_ASYNC_EVENT		0x12
11128c2ecf20Sopenharmony_ci#define INTR_RSP_QUE_UPDATE		0x13
11138c2ecf20Sopenharmony_ci#define INTR_RSP_QUE_UPDATE_83XX	0x14
11148c2ecf20Sopenharmony_ci#define INTR_ATIO_QUE_UPDATE		0x1C
11158c2ecf20Sopenharmony_ci#define INTR_ATIO_RSP_QUE_UPDATE	0x1D
11168c2ecf20Sopenharmony_ci#define INTR_ATIO_QUE_UPDATE_27XX	0x1E
11178c2ecf20Sopenharmony_ci
11188c2ecf20Sopenharmony_ci/* ISP mailbox loopback echo diagnostic error code */
11198c2ecf20Sopenharmony_ci#define MBS_LB_RESET	0x17
11208c2ecf20Sopenharmony_ci/*
11218c2ecf20Sopenharmony_ci * Firmware options 1, 2, 3.
11228c2ecf20Sopenharmony_ci */
11238c2ecf20Sopenharmony_ci#define FO1_AE_ON_LIPF8			BIT_0
11248c2ecf20Sopenharmony_ci#define FO1_AE_ALL_LIP_RESET		BIT_1
11258c2ecf20Sopenharmony_ci#define FO1_CTIO_RETRY			BIT_3
11268c2ecf20Sopenharmony_ci#define FO1_DISABLE_LIP_F7_SW		BIT_4
11278c2ecf20Sopenharmony_ci#define FO1_DISABLE_100MS_LOS_WAIT	BIT_5
11288c2ecf20Sopenharmony_ci#define FO1_DISABLE_GPIO6_7		BIT_6	/* LED bits */
11298c2ecf20Sopenharmony_ci#define FO1_AE_ON_LOOP_INIT_ERR		BIT_7
11308c2ecf20Sopenharmony_ci#define FO1_SET_EMPHASIS_SWING		BIT_8
11318c2ecf20Sopenharmony_ci#define FO1_AE_AUTO_BYPASS		BIT_9
11328c2ecf20Sopenharmony_ci#define FO1_ENABLE_PURE_IOCB		BIT_10
11338c2ecf20Sopenharmony_ci#define FO1_AE_PLOGI_RJT		BIT_11
11348c2ecf20Sopenharmony_ci#define FO1_ENABLE_ABORT_SEQUENCE	BIT_12
11358c2ecf20Sopenharmony_ci#define FO1_AE_QUEUE_FULL		BIT_13
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_ci#define FO2_ENABLE_ATIO_TYPE_3		BIT_0
11388c2ecf20Sopenharmony_ci#define FO2_REV_LOOPBACK		BIT_1
11398c2ecf20Sopenharmony_ci
11408c2ecf20Sopenharmony_ci#define FO3_ENABLE_EMERG_IOCB		BIT_0
11418c2ecf20Sopenharmony_ci#define FO3_AE_RND_ERROR		BIT_1
11428c2ecf20Sopenharmony_ci
11438c2ecf20Sopenharmony_ci/* 24XX additional firmware options */
11448c2ecf20Sopenharmony_ci#define ADD_FO_COUNT			3
11458c2ecf20Sopenharmony_ci#define ADD_FO1_DISABLE_GPIO_LED_CTRL	BIT_6	/* LED bits */
11468c2ecf20Sopenharmony_ci#define ADD_FO1_ENABLE_PUREX_IOCB	BIT_10
11478c2ecf20Sopenharmony_ci
11488c2ecf20Sopenharmony_ci#define ADD_FO2_ENABLE_SEL_CLS2		BIT_5
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_ci#define ADD_FO3_NO_ABT_ON_LINK_DOWN	BIT_14
11518c2ecf20Sopenharmony_ci
11528c2ecf20Sopenharmony_ci/*
11538c2ecf20Sopenharmony_ci * ISP mailbox commands
11548c2ecf20Sopenharmony_ci */
11558c2ecf20Sopenharmony_ci#define MBC_LOAD_RAM			1	/* Load RAM. */
11568c2ecf20Sopenharmony_ci#define MBC_EXECUTE_FIRMWARE		2	/* Execute firmware. */
11578c2ecf20Sopenharmony_ci#define MBC_READ_RAM_WORD		5	/* Read RAM word. */
11588c2ecf20Sopenharmony_ci#define MBC_MAILBOX_REGISTER_TEST	6	/* Wrap incoming mailboxes */
11598c2ecf20Sopenharmony_ci#define MBC_VERIFY_CHECKSUM		7	/* Verify checksum. */
11608c2ecf20Sopenharmony_ci#define MBC_GET_FIRMWARE_VERSION	8	/* Get firmware revision. */
11618c2ecf20Sopenharmony_ci#define MBC_LOAD_RISC_RAM		9	/* Load RAM command. */
11628c2ecf20Sopenharmony_ci#define MBC_DUMP_RISC_RAM		0xa	/* Dump RAM command. */
11638c2ecf20Sopenharmony_ci#define MBC_SECURE_FLASH_UPDATE		0xa	/* Secure Flash Update(28xx) */
11648c2ecf20Sopenharmony_ci#define MBC_LOAD_RISC_RAM_EXTENDED	0xb	/* Load RAM extended. */
11658c2ecf20Sopenharmony_ci#define MBC_DUMP_RISC_RAM_EXTENDED	0xc	/* Dump RAM extended. */
11668c2ecf20Sopenharmony_ci#define MBC_WRITE_RAM_WORD_EXTENDED	0xd	/* Write RAM word extended */
11678c2ecf20Sopenharmony_ci#define MBC_READ_RAM_EXTENDED		0xf	/* Read RAM extended. */
11688c2ecf20Sopenharmony_ci#define MBC_IOCB_COMMAND		0x12	/* Execute IOCB command. */
11698c2ecf20Sopenharmony_ci#define MBC_STOP_FIRMWARE		0x14	/* Stop firmware. */
11708c2ecf20Sopenharmony_ci#define MBC_ABORT_COMMAND		0x15	/* Abort IOCB command. */
11718c2ecf20Sopenharmony_ci#define MBC_ABORT_DEVICE		0x16	/* Abort device (ID/LUN). */
11728c2ecf20Sopenharmony_ci#define MBC_ABORT_TARGET		0x17	/* Abort target (ID). */
11738c2ecf20Sopenharmony_ci#define MBC_RESET			0x18	/* Reset. */
11748c2ecf20Sopenharmony_ci#define MBC_GET_ADAPTER_LOOP_ID		0x20	/* Get loop id of ISP2200. */
11758c2ecf20Sopenharmony_ci#define MBC_GET_SET_ZIO_THRESHOLD	0x21	/* Get/SET ZIO THRESHOLD. */
11768c2ecf20Sopenharmony_ci#define MBC_GET_RETRY_COUNT		0x22	/* Get f/w retry cnt/delay. */
11778c2ecf20Sopenharmony_ci#define MBC_DISABLE_VI			0x24	/* Disable VI operation. */
11788c2ecf20Sopenharmony_ci#define MBC_ENABLE_VI			0x25	/* Enable VI operation. */
11798c2ecf20Sopenharmony_ci#define MBC_GET_FIRMWARE_OPTION		0x28	/* Get Firmware Options. */
11808c2ecf20Sopenharmony_ci#define MBC_GET_MEM_OFFLOAD_CNTRL_STAT	0x34	/* Memory Offload ctrl/Stat*/
11818c2ecf20Sopenharmony_ci#define MBC_SET_FIRMWARE_OPTION		0x38	/* Set Firmware Options. */
11828c2ecf20Sopenharmony_ci#define MBC_SET_GET_FC_LED_CONFIG	0x3b	/* Set/Get FC LED config */
11838c2ecf20Sopenharmony_ci#define MBC_LOOP_PORT_BYPASS		0x40	/* Loop Port Bypass. */
11848c2ecf20Sopenharmony_ci#define MBC_LOOP_PORT_ENABLE		0x41	/* Loop Port Enable. */
11858c2ecf20Sopenharmony_ci#define MBC_GET_RESOURCE_COUNTS		0x42	/* Get Resource Counts. */
11868c2ecf20Sopenharmony_ci#define MBC_NON_PARTICIPATE		0x43	/* Non-Participating Mode. */
11878c2ecf20Sopenharmony_ci#define MBC_DIAGNOSTIC_ECHO		0x44	/* Diagnostic echo. */
11888c2ecf20Sopenharmony_ci#define MBC_DIAGNOSTIC_LOOP_BACK	0x45	/* Diagnostic loop back. */
11898c2ecf20Sopenharmony_ci#define MBC_ONLINE_SELF_TEST		0x46	/* Online self-test. */
11908c2ecf20Sopenharmony_ci#define MBC_ENHANCED_GET_PORT_DATABASE	0x47	/* Get port database + login */
11918c2ecf20Sopenharmony_ci#define MBC_CONFIGURE_VF		0x4b	/* Configure VFs */
11928c2ecf20Sopenharmony_ci#define MBC_RESET_LINK_STATUS		0x52	/* Reset Link Error Status */
11938c2ecf20Sopenharmony_ci#define MBC_IOCB_COMMAND_A64		0x54	/* Execute IOCB command (64) */
11948c2ecf20Sopenharmony_ci#define MBC_PORT_LOGOUT			0x56	/* Port Logout request */
11958c2ecf20Sopenharmony_ci#define MBC_SEND_RNID_ELS		0x57	/* Send RNID ELS request */
11968c2ecf20Sopenharmony_ci#define MBC_SET_RNID_PARAMS		0x59	/* Set RNID parameters */
11978c2ecf20Sopenharmony_ci#define MBC_GET_RNID_PARAMS		0x5a	/* Get RNID parameters */
11988c2ecf20Sopenharmony_ci#define MBC_DATA_RATE			0x5d	/* Data Rate */
11998c2ecf20Sopenharmony_ci#define MBC_INITIALIZE_FIRMWARE		0x60	/* Initialize firmware */
12008c2ecf20Sopenharmony_ci#define MBC_INITIATE_LIP		0x62	/* Initiate Loop */
12018c2ecf20Sopenharmony_ci						/* Initialization Procedure */
12028c2ecf20Sopenharmony_ci#define MBC_GET_FC_AL_POSITION_MAP	0x63	/* Get FC_AL Position Map. */
12038c2ecf20Sopenharmony_ci#define MBC_GET_PORT_DATABASE		0x64	/* Get Port Database. */
12048c2ecf20Sopenharmony_ci#define MBC_CLEAR_ACA			0x65	/* Clear ACA. */
12058c2ecf20Sopenharmony_ci#define MBC_TARGET_RESET		0x66	/* Target Reset. */
12068c2ecf20Sopenharmony_ci#define MBC_CLEAR_TASK_SET		0x67	/* Clear Task Set. */
12078c2ecf20Sopenharmony_ci#define MBC_ABORT_TASK_SET		0x68	/* Abort Task Set. */
12088c2ecf20Sopenharmony_ci#define MBC_GET_FIRMWARE_STATE		0x69	/* Get firmware state. */
12098c2ecf20Sopenharmony_ci#define MBC_GET_PORT_NAME		0x6a	/* Get port name. */
12108c2ecf20Sopenharmony_ci#define MBC_GET_LINK_STATUS		0x6b	/* Get port link status. */
12118c2ecf20Sopenharmony_ci#define MBC_LIP_RESET			0x6c	/* LIP reset. */
12128c2ecf20Sopenharmony_ci#define MBC_SEND_SNS_COMMAND		0x6e	/* Send Simple Name Server */
12138c2ecf20Sopenharmony_ci						/* commandd. */
12148c2ecf20Sopenharmony_ci#define MBC_LOGIN_FABRIC_PORT		0x6f	/* Login fabric port. */
12158c2ecf20Sopenharmony_ci#define MBC_SEND_CHANGE_REQUEST		0x70	/* Send Change Request. */
12168c2ecf20Sopenharmony_ci#define MBC_LOGOUT_FABRIC_PORT		0x71	/* Logout fabric port. */
12178c2ecf20Sopenharmony_ci#define MBC_LIP_FULL_LOGIN		0x72	/* Full login LIP. */
12188c2ecf20Sopenharmony_ci#define MBC_LOGIN_LOOP_PORT		0x74	/* Login Loop Port. */
12198c2ecf20Sopenharmony_ci#define MBC_PORT_NODE_NAME_LIST		0x75	/* Get port/node name list. */
12208c2ecf20Sopenharmony_ci#define MBC_INITIALIZE_RECEIVE_QUEUE	0x77	/* Initialize receive queue */
12218c2ecf20Sopenharmony_ci#define MBC_UNLOAD_IP			0x79	/* Shutdown IP */
12228c2ecf20Sopenharmony_ci#define MBC_GET_ID_LIST			0x7C	/* Get Port ID list. */
12238c2ecf20Sopenharmony_ci#define MBC_SEND_LFA_COMMAND		0x7D	/* Send Loop Fabric Address */
12248c2ecf20Sopenharmony_ci#define MBC_LUN_RESET			0x7E	/* Send LUN reset */
12258c2ecf20Sopenharmony_ci
12268c2ecf20Sopenharmony_ci/*
12278c2ecf20Sopenharmony_ci * all the Mt. Rainier mailbox command codes that clash with FC/FCoE ones
12288c2ecf20Sopenharmony_ci * should be defined with MBC_MR_*
12298c2ecf20Sopenharmony_ci */
12308c2ecf20Sopenharmony_ci#define MBC_MR_DRV_SHUTDOWN		0x6A
12318c2ecf20Sopenharmony_ci
12328c2ecf20Sopenharmony_ci/*
12338c2ecf20Sopenharmony_ci * ISP24xx mailbox commands
12348c2ecf20Sopenharmony_ci */
12358c2ecf20Sopenharmony_ci#define MBC_WRITE_SERDES		0x3	/* Write serdes word. */
12368c2ecf20Sopenharmony_ci#define MBC_READ_SERDES			0x4	/* Read serdes word. */
12378c2ecf20Sopenharmony_ci#define MBC_LOAD_DUMP_MPI_RAM		0x5	/* Load/Dump MPI RAM. */
12388c2ecf20Sopenharmony_ci#define MBC_SERDES_PARAMS		0x10	/* Serdes Tx Parameters. */
12398c2ecf20Sopenharmony_ci#define MBC_GET_IOCB_STATUS		0x12	/* Get IOCB status command. */
12408c2ecf20Sopenharmony_ci#define MBC_PORT_PARAMS			0x1A	/* Port iDMA Parameters. */
12418c2ecf20Sopenharmony_ci#define MBC_GET_TIMEOUT_PARAMS		0x22	/* Get FW timeouts. */
12428c2ecf20Sopenharmony_ci#define MBC_TRACE_CONTROL		0x27	/* Trace control command. */
12438c2ecf20Sopenharmony_ci#define MBC_GEN_SYSTEM_ERROR		0x2a	/* Generate System Error. */
12448c2ecf20Sopenharmony_ci#define MBC_WRITE_SFP			0x30	/* Write SFP Data. */
12458c2ecf20Sopenharmony_ci#define MBC_READ_SFP			0x31	/* Read SFP Data. */
12468c2ecf20Sopenharmony_ci#define MBC_SET_TIMEOUT_PARAMS		0x32	/* Set FW timeouts. */
12478c2ecf20Sopenharmony_ci#define MBC_DPORT_DIAGNOSTICS		0x47	/* D-Port Diagnostics */
12488c2ecf20Sopenharmony_ci#define MBC_MID_INITIALIZE_FIRMWARE	0x48	/* MID Initialize firmware. */
12498c2ecf20Sopenharmony_ci#define MBC_MID_GET_VP_DATABASE		0x49	/* MID Get VP Database. */
12508c2ecf20Sopenharmony_ci#define MBC_MID_GET_VP_ENTRY		0x4a	/* MID Get VP Entry. */
12518c2ecf20Sopenharmony_ci#define MBC_HOST_MEMORY_COPY		0x53	/* Host Memory Copy. */
12528c2ecf20Sopenharmony_ci#define MBC_SEND_RNFT_ELS		0x5e	/* Send RNFT ELS request */
12538c2ecf20Sopenharmony_ci#define MBC_GET_LINK_PRIV_STATS		0x6d	/* Get link & private data. */
12548c2ecf20Sopenharmony_ci#define MBC_LINK_INITIALIZATION		0x72	/* Do link initialization. */
12558c2ecf20Sopenharmony_ci#define MBC_SET_VENDOR_ID		0x76	/* Set Vendor ID. */
12568c2ecf20Sopenharmony_ci#define MBC_PORT_RESET			0x120	/* Port Reset */
12578c2ecf20Sopenharmony_ci#define MBC_SET_PORT_CONFIG		0x122	/* Set port configuration */
12588c2ecf20Sopenharmony_ci#define MBC_GET_PORT_CONFIG		0x123	/* Get port configuration */
12598c2ecf20Sopenharmony_ci
12608c2ecf20Sopenharmony_ci/*
12618c2ecf20Sopenharmony_ci * ISP81xx mailbox commands
12628c2ecf20Sopenharmony_ci */
12638c2ecf20Sopenharmony_ci#define MBC_WRITE_MPI_REGISTER		0x01    /* Write MPI Register. */
12648c2ecf20Sopenharmony_ci
12658c2ecf20Sopenharmony_ci/*
12668c2ecf20Sopenharmony_ci * ISP8044 mailbox commands
12678c2ecf20Sopenharmony_ci */
12688c2ecf20Sopenharmony_ci#define MBC_SET_GET_ETH_SERDES_REG	0x150
12698c2ecf20Sopenharmony_ci#define HCS_WRITE_SERDES		0x3
12708c2ecf20Sopenharmony_ci#define HCS_READ_SERDES			0x4
12718c2ecf20Sopenharmony_ci
12728c2ecf20Sopenharmony_ci/* Firmware return data sizes */
12738c2ecf20Sopenharmony_ci#define FCAL_MAP_SIZE	128
12748c2ecf20Sopenharmony_ci
12758c2ecf20Sopenharmony_ci/* Mailbox bit definitions for out_mb and in_mb */
12768c2ecf20Sopenharmony_ci#define	MBX_31		BIT_31
12778c2ecf20Sopenharmony_ci#define	MBX_30		BIT_30
12788c2ecf20Sopenharmony_ci#define	MBX_29		BIT_29
12798c2ecf20Sopenharmony_ci#define	MBX_28		BIT_28
12808c2ecf20Sopenharmony_ci#define	MBX_27		BIT_27
12818c2ecf20Sopenharmony_ci#define	MBX_26		BIT_26
12828c2ecf20Sopenharmony_ci#define	MBX_25		BIT_25
12838c2ecf20Sopenharmony_ci#define	MBX_24		BIT_24
12848c2ecf20Sopenharmony_ci#define	MBX_23		BIT_23
12858c2ecf20Sopenharmony_ci#define	MBX_22		BIT_22
12868c2ecf20Sopenharmony_ci#define	MBX_21		BIT_21
12878c2ecf20Sopenharmony_ci#define	MBX_20		BIT_20
12888c2ecf20Sopenharmony_ci#define	MBX_19		BIT_19
12898c2ecf20Sopenharmony_ci#define	MBX_18		BIT_18
12908c2ecf20Sopenharmony_ci#define	MBX_17		BIT_17
12918c2ecf20Sopenharmony_ci#define	MBX_16		BIT_16
12928c2ecf20Sopenharmony_ci#define	MBX_15		BIT_15
12938c2ecf20Sopenharmony_ci#define	MBX_14		BIT_14
12948c2ecf20Sopenharmony_ci#define	MBX_13		BIT_13
12958c2ecf20Sopenharmony_ci#define	MBX_12		BIT_12
12968c2ecf20Sopenharmony_ci#define	MBX_11		BIT_11
12978c2ecf20Sopenharmony_ci#define	MBX_10		BIT_10
12988c2ecf20Sopenharmony_ci#define	MBX_9		BIT_9
12998c2ecf20Sopenharmony_ci#define	MBX_8		BIT_8
13008c2ecf20Sopenharmony_ci#define	MBX_7		BIT_7
13018c2ecf20Sopenharmony_ci#define	MBX_6		BIT_6
13028c2ecf20Sopenharmony_ci#define	MBX_5		BIT_5
13038c2ecf20Sopenharmony_ci#define	MBX_4		BIT_4
13048c2ecf20Sopenharmony_ci#define	MBX_3		BIT_3
13058c2ecf20Sopenharmony_ci#define	MBX_2		BIT_2
13068c2ecf20Sopenharmony_ci#define	MBX_1		BIT_1
13078c2ecf20Sopenharmony_ci#define	MBX_0		BIT_0
13088c2ecf20Sopenharmony_ci
13098c2ecf20Sopenharmony_ci#define RNID_TYPE_ELS_CMD	0x5
13108c2ecf20Sopenharmony_ci#define RNID_TYPE_PORT_LOGIN	0x7
13118c2ecf20Sopenharmony_ci#define RNID_BUFFER_CREDITS	0x8
13128c2ecf20Sopenharmony_ci#define RNID_TYPE_SET_VERSION	0x9
13138c2ecf20Sopenharmony_ci#define RNID_TYPE_ASIC_TEMP	0xC
13148c2ecf20Sopenharmony_ci
13158c2ecf20Sopenharmony_ci#define ELS_CMD_MAP_SIZE	32
13168c2ecf20Sopenharmony_ci
13178c2ecf20Sopenharmony_ci/*
13188c2ecf20Sopenharmony_ci * Firmware state codes from get firmware state mailbox command
13198c2ecf20Sopenharmony_ci */
13208c2ecf20Sopenharmony_ci#define FSTATE_CONFIG_WAIT      0
13218c2ecf20Sopenharmony_ci#define FSTATE_WAIT_AL_PA       1
13228c2ecf20Sopenharmony_ci#define FSTATE_WAIT_LOGIN       2
13238c2ecf20Sopenharmony_ci#define FSTATE_READY            3
13248c2ecf20Sopenharmony_ci#define FSTATE_LOSS_OF_SYNC     4
13258c2ecf20Sopenharmony_ci#define FSTATE_ERROR            5
13268c2ecf20Sopenharmony_ci#define FSTATE_REINIT           6
13278c2ecf20Sopenharmony_ci#define FSTATE_NON_PART         7
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci#define FSTATE_CONFIG_CORRECT      0
13308c2ecf20Sopenharmony_ci#define FSTATE_P2P_RCV_LIP         1
13318c2ecf20Sopenharmony_ci#define FSTATE_P2P_CHOOSE_LOOP     2
13328c2ecf20Sopenharmony_ci#define FSTATE_P2P_RCV_UNIDEN_LIP  3
13338c2ecf20Sopenharmony_ci#define FSTATE_FATAL_ERROR         4
13348c2ecf20Sopenharmony_ci#define FSTATE_LOOP_BACK_CONN      5
13358c2ecf20Sopenharmony_ci
13368c2ecf20Sopenharmony_ci#define QLA27XX_IMG_STATUS_VER_MAJOR   0x01
13378c2ecf20Sopenharmony_ci#define QLA27XX_IMG_STATUS_VER_MINOR    0x00
13388c2ecf20Sopenharmony_ci#define QLA27XX_IMG_STATUS_SIGN   0xFACEFADE
13398c2ecf20Sopenharmony_ci#define QLA28XX_IMG_STATUS_SIGN    0xFACEFADF
13408c2ecf20Sopenharmony_ci#define QLA28XX_IMG_STATUS_SIGN		0xFACEFADF
13418c2ecf20Sopenharmony_ci#define QLA28XX_AUX_IMG_STATUS_SIGN	0xFACEFAED
13428c2ecf20Sopenharmony_ci#define QLA27XX_DEFAULT_IMAGE		0
13438c2ecf20Sopenharmony_ci#define QLA27XX_PRIMARY_IMAGE  1
13448c2ecf20Sopenharmony_ci#define QLA27XX_SECONDARY_IMAGE    2
13458c2ecf20Sopenharmony_ci
13468c2ecf20Sopenharmony_ci/*
13478c2ecf20Sopenharmony_ci * Port Database structure definition
13488c2ecf20Sopenharmony_ci * Little endian except where noted.
13498c2ecf20Sopenharmony_ci */
13508c2ecf20Sopenharmony_ci#define	PORT_DATABASE_SIZE	128	/* bytes */
13518c2ecf20Sopenharmony_citypedef struct {
13528c2ecf20Sopenharmony_ci	uint8_t options;
13538c2ecf20Sopenharmony_ci	uint8_t control;
13548c2ecf20Sopenharmony_ci	uint8_t master_state;
13558c2ecf20Sopenharmony_ci	uint8_t slave_state;
13568c2ecf20Sopenharmony_ci	uint8_t reserved[2];
13578c2ecf20Sopenharmony_ci	uint8_t hard_address;
13588c2ecf20Sopenharmony_ci	uint8_t reserved_1;
13598c2ecf20Sopenharmony_ci	uint8_t port_id[4];
13608c2ecf20Sopenharmony_ci	uint8_t node_name[WWN_SIZE];
13618c2ecf20Sopenharmony_ci	uint8_t port_name[WWN_SIZE];
13628c2ecf20Sopenharmony_ci	__le16	execution_throttle;
13638c2ecf20Sopenharmony_ci	uint16_t execution_count;
13648c2ecf20Sopenharmony_ci	uint8_t reset_count;
13658c2ecf20Sopenharmony_ci	uint8_t reserved_2;
13668c2ecf20Sopenharmony_ci	uint16_t resource_allocation;
13678c2ecf20Sopenharmony_ci	uint16_t current_allocation;
13688c2ecf20Sopenharmony_ci	uint16_t queue_head;
13698c2ecf20Sopenharmony_ci	uint16_t queue_tail;
13708c2ecf20Sopenharmony_ci	uint16_t transmit_execution_list_next;
13718c2ecf20Sopenharmony_ci	uint16_t transmit_execution_list_previous;
13728c2ecf20Sopenharmony_ci	uint16_t common_features;
13738c2ecf20Sopenharmony_ci	uint16_t total_concurrent_sequences;
13748c2ecf20Sopenharmony_ci	uint16_t RO_by_information_category;
13758c2ecf20Sopenharmony_ci	uint8_t recipient;
13768c2ecf20Sopenharmony_ci	uint8_t initiator;
13778c2ecf20Sopenharmony_ci	uint16_t receive_data_size;
13788c2ecf20Sopenharmony_ci	uint16_t concurrent_sequences;
13798c2ecf20Sopenharmony_ci	uint16_t open_sequences_per_exchange;
13808c2ecf20Sopenharmony_ci	uint16_t lun_abort_flags;
13818c2ecf20Sopenharmony_ci	uint16_t lun_stop_flags;
13828c2ecf20Sopenharmony_ci	uint16_t stop_queue_head;
13838c2ecf20Sopenharmony_ci	uint16_t stop_queue_tail;
13848c2ecf20Sopenharmony_ci	uint16_t port_retry_timer;
13858c2ecf20Sopenharmony_ci	uint16_t next_sequence_id;
13868c2ecf20Sopenharmony_ci	uint16_t frame_count;
13878c2ecf20Sopenharmony_ci	uint16_t PRLI_payload_length;
13888c2ecf20Sopenharmony_ci	uint8_t prli_svc_param_word_0[2];	/* Big endian */
13898c2ecf20Sopenharmony_ci						/* Bits 15-0 of word 0 */
13908c2ecf20Sopenharmony_ci	uint8_t prli_svc_param_word_3[2];	/* Big endian */
13918c2ecf20Sopenharmony_ci						/* Bits 15-0 of word 3 */
13928c2ecf20Sopenharmony_ci	uint16_t loop_id;
13938c2ecf20Sopenharmony_ci	uint16_t extended_lun_info_list_pointer;
13948c2ecf20Sopenharmony_ci	uint16_t extended_lun_stop_list_pointer;
13958c2ecf20Sopenharmony_ci} port_database_t;
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_ci/*
13988c2ecf20Sopenharmony_ci * Port database slave/master states
13998c2ecf20Sopenharmony_ci */
14008c2ecf20Sopenharmony_ci#define PD_STATE_DISCOVERY			0
14018c2ecf20Sopenharmony_ci#define PD_STATE_WAIT_DISCOVERY_ACK		1
14028c2ecf20Sopenharmony_ci#define PD_STATE_PORT_LOGIN			2
14038c2ecf20Sopenharmony_ci#define PD_STATE_WAIT_PORT_LOGIN_ACK		3
14048c2ecf20Sopenharmony_ci#define PD_STATE_PROCESS_LOGIN			4
14058c2ecf20Sopenharmony_ci#define PD_STATE_WAIT_PROCESS_LOGIN_ACK		5
14068c2ecf20Sopenharmony_ci#define PD_STATE_PORT_LOGGED_IN			6
14078c2ecf20Sopenharmony_ci#define PD_STATE_PORT_UNAVAILABLE		7
14088c2ecf20Sopenharmony_ci#define PD_STATE_PROCESS_LOGOUT			8
14098c2ecf20Sopenharmony_ci#define PD_STATE_WAIT_PROCESS_LOGOUT_ACK	9
14108c2ecf20Sopenharmony_ci#define PD_STATE_PORT_LOGOUT			10
14118c2ecf20Sopenharmony_ci#define PD_STATE_WAIT_PORT_LOGOUT_ACK		11
14128c2ecf20Sopenharmony_ci
14138c2ecf20Sopenharmony_ci
14148c2ecf20Sopenharmony_ci#define QLA_ZIO_MODE_6		(BIT_2 | BIT_1)
14158c2ecf20Sopenharmony_ci#define QLA_ZIO_DISABLED	0
14168c2ecf20Sopenharmony_ci#define QLA_ZIO_DEFAULT_TIMER	2
14178c2ecf20Sopenharmony_ci
14188c2ecf20Sopenharmony_ci/*
14198c2ecf20Sopenharmony_ci * ISP Initialization Control Block.
14208c2ecf20Sopenharmony_ci * Little endian except where noted.
14218c2ecf20Sopenharmony_ci */
14228c2ecf20Sopenharmony_ci#define	ICB_VERSION 1
14238c2ecf20Sopenharmony_citypedef struct {
14248c2ecf20Sopenharmony_ci	uint8_t  version;
14258c2ecf20Sopenharmony_ci	uint8_t  reserved_1;
14268c2ecf20Sopenharmony_ci
14278c2ecf20Sopenharmony_ci	/*
14288c2ecf20Sopenharmony_ci	 * LSB BIT 0  = Enable Hard Loop Id
14298c2ecf20Sopenharmony_ci	 * LSB BIT 1  = Enable Fairness
14308c2ecf20Sopenharmony_ci	 * LSB BIT 2  = Enable Full-Duplex
14318c2ecf20Sopenharmony_ci	 * LSB BIT 3  = Enable Fast Posting
14328c2ecf20Sopenharmony_ci	 * LSB BIT 4  = Enable Target Mode
14338c2ecf20Sopenharmony_ci	 * LSB BIT 5  = Disable Initiator Mode
14348c2ecf20Sopenharmony_ci	 * LSB BIT 6  = Enable ADISC
14358c2ecf20Sopenharmony_ci	 * LSB BIT 7  = Enable Target Inquiry Data
14368c2ecf20Sopenharmony_ci	 *
14378c2ecf20Sopenharmony_ci	 * MSB BIT 0  = Enable PDBC Notify
14388c2ecf20Sopenharmony_ci	 * MSB BIT 1  = Non Participating LIP
14398c2ecf20Sopenharmony_ci	 * MSB BIT 2  = Descending Loop ID Search
14408c2ecf20Sopenharmony_ci	 * MSB BIT 3  = Acquire Loop ID in LIPA
14418c2ecf20Sopenharmony_ci	 * MSB BIT 4  = Stop PortQ on Full Status
14428c2ecf20Sopenharmony_ci	 * MSB BIT 5  = Full Login after LIP
14438c2ecf20Sopenharmony_ci	 * MSB BIT 6  = Node Name Option
14448c2ecf20Sopenharmony_ci	 * MSB BIT 7  = Ext IFWCB enable bit
14458c2ecf20Sopenharmony_ci	 */
14468c2ecf20Sopenharmony_ci	uint8_t  firmware_options[2];
14478c2ecf20Sopenharmony_ci
14488c2ecf20Sopenharmony_ci	__le16	frame_payload_size;
14498c2ecf20Sopenharmony_ci	__le16	max_iocb_allocation;
14508c2ecf20Sopenharmony_ci	__le16	execution_throttle;
14518c2ecf20Sopenharmony_ci	uint8_t  retry_count;
14528c2ecf20Sopenharmony_ci	uint8_t	 retry_delay;			/* unused */
14538c2ecf20Sopenharmony_ci	uint8_t	 port_name[WWN_SIZE];		/* Big endian. */
14548c2ecf20Sopenharmony_ci	uint16_t hard_address;
14558c2ecf20Sopenharmony_ci	uint8_t	 inquiry_data;
14568c2ecf20Sopenharmony_ci	uint8_t	 login_timeout;
14578c2ecf20Sopenharmony_ci	uint8_t	 node_name[WWN_SIZE];		/* Big endian. */
14588c2ecf20Sopenharmony_ci
14598c2ecf20Sopenharmony_ci	__le16	request_q_outpointer;
14608c2ecf20Sopenharmony_ci	__le16	response_q_inpointer;
14618c2ecf20Sopenharmony_ci	__le16	request_q_length;
14628c2ecf20Sopenharmony_ci	__le16	response_q_length;
14638c2ecf20Sopenharmony_ci	__le64  request_q_address __packed;
14648c2ecf20Sopenharmony_ci	__le64  response_q_address __packed;
14658c2ecf20Sopenharmony_ci
14668c2ecf20Sopenharmony_ci	__le16	lun_enables;
14678c2ecf20Sopenharmony_ci	uint8_t  command_resource_count;
14688c2ecf20Sopenharmony_ci	uint8_t  immediate_notify_resource_count;
14698c2ecf20Sopenharmony_ci	__le16	timeout;
14708c2ecf20Sopenharmony_ci	uint8_t  reserved_2[2];
14718c2ecf20Sopenharmony_ci
14728c2ecf20Sopenharmony_ci	/*
14738c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Timer Operation mode bit 0
14748c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Timer Operation mode bit 1
14758c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Timer Operation mode bit 2
14768c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Timer Operation mode bit 3
14778c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Init Config Mode bit 0
14788c2ecf20Sopenharmony_ci	 * LSB BIT 5 = Init Config Mode bit 1
14798c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Init Config Mode bit 2
14808c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Enable Non part on LIHA failure
14818c2ecf20Sopenharmony_ci	 *
14828c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Enable class 2
14838c2ecf20Sopenharmony_ci	 * MSB BIT 1 = Enable ACK0
14848c2ecf20Sopenharmony_ci	 * MSB BIT 2 =
14858c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
14868c2ecf20Sopenharmony_ci	 * MSB BIT 4 = FC Tape Enable
14878c2ecf20Sopenharmony_ci	 * MSB BIT 5 = Enable FC Confirm
14888c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Enable command queuing in target mode
14898c2ecf20Sopenharmony_ci	 * MSB BIT 7 = No Logo On Link Down
14908c2ecf20Sopenharmony_ci	 */
14918c2ecf20Sopenharmony_ci	uint8_t	 add_firmware_options[2];
14928c2ecf20Sopenharmony_ci
14938c2ecf20Sopenharmony_ci	uint8_t	 response_accumulation_timer;
14948c2ecf20Sopenharmony_ci	uint8_t	 interrupt_delay_timer;
14958c2ecf20Sopenharmony_ci
14968c2ecf20Sopenharmony_ci	/*
14978c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Enable Read xfr_rdy
14988c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Soft ID only
14998c2ecf20Sopenharmony_ci	 * LSB BIT 2 =
15008c2ecf20Sopenharmony_ci	 * LSB BIT 3 =
15018c2ecf20Sopenharmony_ci	 * LSB BIT 4 = FCP RSP Payload [0]
15028c2ecf20Sopenharmony_ci	 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
15038c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Enable Out-of-Order frame handling
15048c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
15058c2ecf20Sopenharmony_ci	 *
15068c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Sbus enable - 2300
15078c2ecf20Sopenharmony_ci	 * MSB BIT 1 =
15088c2ecf20Sopenharmony_ci	 * MSB BIT 2 =
15098c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
15108c2ecf20Sopenharmony_ci	 * MSB BIT 4 = LED mode
15118c2ecf20Sopenharmony_ci	 * MSB BIT 5 = enable 50 ohm termination
15128c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Data Rate (2300 only)
15138c2ecf20Sopenharmony_ci	 * MSB BIT 7 = Data Rate (2300 only)
15148c2ecf20Sopenharmony_ci	 */
15158c2ecf20Sopenharmony_ci	uint8_t	 special_options[2];
15168c2ecf20Sopenharmony_ci
15178c2ecf20Sopenharmony_ci	uint8_t  reserved_3[26];
15188c2ecf20Sopenharmony_ci} init_cb_t;
15198c2ecf20Sopenharmony_ci
15208c2ecf20Sopenharmony_ci/* Special Features Control Block */
15218c2ecf20Sopenharmony_cistruct init_sf_cb {
15228c2ecf20Sopenharmony_ci	uint8_t	format;
15238c2ecf20Sopenharmony_ci	uint8_t	reserved0;
15248c2ecf20Sopenharmony_ci	/*
15258c2ecf20Sopenharmony_ci	 * BIT 15-14 = Reserved
15268c2ecf20Sopenharmony_ci	 * BIT_13 = SAN Congestion Management (1 - Enabled, 0 - Disabled)
15278c2ecf20Sopenharmony_ci	 * BIT_12 = Remote Write Optimization (1 - Enabled, 0 - Disabled)
15288c2ecf20Sopenharmony_ci	 * BIT 11-0 = Reserved
15298c2ecf20Sopenharmony_ci	 */
15308c2ecf20Sopenharmony_ci	uint16_t flags;
15318c2ecf20Sopenharmony_ci	uint8_t	reserved1[32];
15328c2ecf20Sopenharmony_ci	uint16_t discard_OHRB_timeout_value;
15338c2ecf20Sopenharmony_ci	uint16_t remote_write_opt_queue_num;
15348c2ecf20Sopenharmony_ci	uint8_t	reserved2[40];
15358c2ecf20Sopenharmony_ci	uint8_t scm_related_parameter[16];
15368c2ecf20Sopenharmony_ci	uint8_t reserved3[32];
15378c2ecf20Sopenharmony_ci};
15388c2ecf20Sopenharmony_ci
15398c2ecf20Sopenharmony_ci/*
15408c2ecf20Sopenharmony_ci * Get Link Status mailbox command return buffer.
15418c2ecf20Sopenharmony_ci */
15428c2ecf20Sopenharmony_ci#define GLSO_SEND_RPS	BIT_0
15438c2ecf20Sopenharmony_ci#define GLSO_USE_DID	BIT_3
15448c2ecf20Sopenharmony_ci
15458c2ecf20Sopenharmony_cistruct link_statistics {
15468c2ecf20Sopenharmony_ci	__le32 link_fail_cnt;
15478c2ecf20Sopenharmony_ci	__le32 loss_sync_cnt;
15488c2ecf20Sopenharmony_ci	__le32 loss_sig_cnt;
15498c2ecf20Sopenharmony_ci	__le32 prim_seq_err_cnt;
15508c2ecf20Sopenharmony_ci	__le32 inval_xmit_word_cnt;
15518c2ecf20Sopenharmony_ci	__le32 inval_crc_cnt;
15528c2ecf20Sopenharmony_ci	__le32 lip_cnt;
15538c2ecf20Sopenharmony_ci	__le32 link_up_cnt;
15548c2ecf20Sopenharmony_ci	__le32 link_down_loop_init_tmo;
15558c2ecf20Sopenharmony_ci	__le32 link_down_los;
15568c2ecf20Sopenharmony_ci	__le32 link_down_loss_rcv_clk;
15578c2ecf20Sopenharmony_ci	uint32_t reserved0[5];
15588c2ecf20Sopenharmony_ci	__le32 port_cfg_chg;
15598c2ecf20Sopenharmony_ci	uint32_t reserved1[11];
15608c2ecf20Sopenharmony_ci	__le32 rsp_q_full;
15618c2ecf20Sopenharmony_ci	__le32 atio_q_full;
15628c2ecf20Sopenharmony_ci	__le32 drop_ae;
15638c2ecf20Sopenharmony_ci	__le32 els_proto_err;
15648c2ecf20Sopenharmony_ci	__le32 reserved2;
15658c2ecf20Sopenharmony_ci	__le32 tx_frames;
15668c2ecf20Sopenharmony_ci	__le32 rx_frames;
15678c2ecf20Sopenharmony_ci	__le32 discarded_frames;
15688c2ecf20Sopenharmony_ci	__le32 dropped_frames;
15698c2ecf20Sopenharmony_ci	uint32_t reserved3;
15708c2ecf20Sopenharmony_ci	__le32 nos_rcvd;
15718c2ecf20Sopenharmony_ci	uint32_t reserved4[4];
15728c2ecf20Sopenharmony_ci	__le32 tx_prjt;
15738c2ecf20Sopenharmony_ci	__le32 rcv_exfail;
15748c2ecf20Sopenharmony_ci	__le32 rcv_abts;
15758c2ecf20Sopenharmony_ci	__le32 seq_frm_miss;
15768c2ecf20Sopenharmony_ci	__le32 corr_err;
15778c2ecf20Sopenharmony_ci	__le32 mb_rqst;
15788c2ecf20Sopenharmony_ci	__le32 nport_full;
15798c2ecf20Sopenharmony_ci	__le32 eofa;
15808c2ecf20Sopenharmony_ci	uint32_t reserved5;
15818c2ecf20Sopenharmony_ci	__le64 fpm_recv_word_cnt;
15828c2ecf20Sopenharmony_ci	__le64 fpm_disc_word_cnt;
15838c2ecf20Sopenharmony_ci	__le64 fpm_xmit_word_cnt;
15848c2ecf20Sopenharmony_ci	uint32_t reserved6[70];
15858c2ecf20Sopenharmony_ci};
15868c2ecf20Sopenharmony_ci
15878c2ecf20Sopenharmony_ci/*
15888c2ecf20Sopenharmony_ci * NVRAM Command values.
15898c2ecf20Sopenharmony_ci */
15908c2ecf20Sopenharmony_ci#define NV_START_BIT            BIT_2
15918c2ecf20Sopenharmony_ci#define NV_WRITE_OP             (BIT_26+BIT_24)
15928c2ecf20Sopenharmony_ci#define NV_READ_OP              (BIT_26+BIT_25)
15938c2ecf20Sopenharmony_ci#define NV_ERASE_OP             (BIT_26+BIT_25+BIT_24)
15948c2ecf20Sopenharmony_ci#define NV_MASK_OP              (BIT_26+BIT_25+BIT_24)
15958c2ecf20Sopenharmony_ci#define NV_DELAY_COUNT          10
15968c2ecf20Sopenharmony_ci
15978c2ecf20Sopenharmony_ci/*
15988c2ecf20Sopenharmony_ci * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
15998c2ecf20Sopenharmony_ci */
16008c2ecf20Sopenharmony_citypedef struct {
16018c2ecf20Sopenharmony_ci	/*
16028c2ecf20Sopenharmony_ci	 * NVRAM header
16038c2ecf20Sopenharmony_ci	 */
16048c2ecf20Sopenharmony_ci	uint8_t	id[4];
16058c2ecf20Sopenharmony_ci	uint8_t	nvram_version;
16068c2ecf20Sopenharmony_ci	uint8_t	reserved_0;
16078c2ecf20Sopenharmony_ci
16088c2ecf20Sopenharmony_ci	/*
16098c2ecf20Sopenharmony_ci	 * NVRAM RISC parameter block
16108c2ecf20Sopenharmony_ci	 */
16118c2ecf20Sopenharmony_ci	uint8_t	parameter_block_version;
16128c2ecf20Sopenharmony_ci	uint8_t	reserved_1;
16138c2ecf20Sopenharmony_ci
16148c2ecf20Sopenharmony_ci	/*
16158c2ecf20Sopenharmony_ci	 * LSB BIT 0  = Enable Hard Loop Id
16168c2ecf20Sopenharmony_ci	 * LSB BIT 1  = Enable Fairness
16178c2ecf20Sopenharmony_ci	 * LSB BIT 2  = Enable Full-Duplex
16188c2ecf20Sopenharmony_ci	 * LSB BIT 3  = Enable Fast Posting
16198c2ecf20Sopenharmony_ci	 * LSB BIT 4  = Enable Target Mode
16208c2ecf20Sopenharmony_ci	 * LSB BIT 5  = Disable Initiator Mode
16218c2ecf20Sopenharmony_ci	 * LSB BIT 6  = Enable ADISC
16228c2ecf20Sopenharmony_ci	 * LSB BIT 7  = Enable Target Inquiry Data
16238c2ecf20Sopenharmony_ci	 *
16248c2ecf20Sopenharmony_ci	 * MSB BIT 0  = Enable PDBC Notify
16258c2ecf20Sopenharmony_ci	 * MSB BIT 1  = Non Participating LIP
16268c2ecf20Sopenharmony_ci	 * MSB BIT 2  = Descending Loop ID Search
16278c2ecf20Sopenharmony_ci	 * MSB BIT 3  = Acquire Loop ID in LIPA
16288c2ecf20Sopenharmony_ci	 * MSB BIT 4  = Stop PortQ on Full Status
16298c2ecf20Sopenharmony_ci	 * MSB BIT 5  = Full Login after LIP
16308c2ecf20Sopenharmony_ci	 * MSB BIT 6  = Node Name Option
16318c2ecf20Sopenharmony_ci	 * MSB BIT 7  = Ext IFWCB enable bit
16328c2ecf20Sopenharmony_ci	 */
16338c2ecf20Sopenharmony_ci	uint8_t	 firmware_options[2];
16348c2ecf20Sopenharmony_ci
16358c2ecf20Sopenharmony_ci	__le16	frame_payload_size;
16368c2ecf20Sopenharmony_ci	__le16	max_iocb_allocation;
16378c2ecf20Sopenharmony_ci	__le16	execution_throttle;
16388c2ecf20Sopenharmony_ci	uint8_t	 retry_count;
16398c2ecf20Sopenharmony_ci	uint8_t	 retry_delay;			/* unused */
16408c2ecf20Sopenharmony_ci	uint8_t	 port_name[WWN_SIZE];		/* Big endian. */
16418c2ecf20Sopenharmony_ci	uint16_t hard_address;
16428c2ecf20Sopenharmony_ci	uint8_t	 inquiry_data;
16438c2ecf20Sopenharmony_ci	uint8_t	 login_timeout;
16448c2ecf20Sopenharmony_ci	uint8_t	 node_name[WWN_SIZE];		/* Big endian. */
16458c2ecf20Sopenharmony_ci
16468c2ecf20Sopenharmony_ci	/*
16478c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Timer Operation mode bit 0
16488c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Timer Operation mode bit 1
16498c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Timer Operation mode bit 2
16508c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Timer Operation mode bit 3
16518c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Init Config Mode bit 0
16528c2ecf20Sopenharmony_ci	 * LSB BIT 5 = Init Config Mode bit 1
16538c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Init Config Mode bit 2
16548c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Enable Non part on LIHA failure
16558c2ecf20Sopenharmony_ci	 *
16568c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Enable class 2
16578c2ecf20Sopenharmony_ci	 * MSB BIT 1 = Enable ACK0
16588c2ecf20Sopenharmony_ci	 * MSB BIT 2 =
16598c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
16608c2ecf20Sopenharmony_ci	 * MSB BIT 4 = FC Tape Enable
16618c2ecf20Sopenharmony_ci	 * MSB BIT 5 = Enable FC Confirm
16628c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Enable command queuing in target mode
16638c2ecf20Sopenharmony_ci	 * MSB BIT 7 = No Logo On Link Down
16648c2ecf20Sopenharmony_ci	 */
16658c2ecf20Sopenharmony_ci	uint8_t	 add_firmware_options[2];
16668c2ecf20Sopenharmony_ci
16678c2ecf20Sopenharmony_ci	uint8_t	 response_accumulation_timer;
16688c2ecf20Sopenharmony_ci	uint8_t	 interrupt_delay_timer;
16698c2ecf20Sopenharmony_ci
16708c2ecf20Sopenharmony_ci	/*
16718c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Enable Read xfr_rdy
16728c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Soft ID only
16738c2ecf20Sopenharmony_ci	 * LSB BIT 2 =
16748c2ecf20Sopenharmony_ci	 * LSB BIT 3 =
16758c2ecf20Sopenharmony_ci	 * LSB BIT 4 = FCP RSP Payload [0]
16768c2ecf20Sopenharmony_ci	 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
16778c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Enable Out-of-Order frame handling
16788c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
16798c2ecf20Sopenharmony_ci	 *
16808c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Sbus enable - 2300
16818c2ecf20Sopenharmony_ci	 * MSB BIT 1 =
16828c2ecf20Sopenharmony_ci	 * MSB BIT 2 =
16838c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
16848c2ecf20Sopenharmony_ci	 * MSB BIT 4 = LED mode
16858c2ecf20Sopenharmony_ci	 * MSB BIT 5 = enable 50 ohm termination
16868c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Data Rate (2300 only)
16878c2ecf20Sopenharmony_ci	 * MSB BIT 7 = Data Rate (2300 only)
16888c2ecf20Sopenharmony_ci	 */
16898c2ecf20Sopenharmony_ci	uint8_t	 special_options[2];
16908c2ecf20Sopenharmony_ci
16918c2ecf20Sopenharmony_ci	/* Reserved for expanded RISC parameter block */
16928c2ecf20Sopenharmony_ci	uint8_t reserved_2[22];
16938c2ecf20Sopenharmony_ci
16948c2ecf20Sopenharmony_ci	/*
16958c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Tx Sensitivity 1G bit 0
16968c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Tx Sensitivity 1G bit 1
16978c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Tx Sensitivity 1G bit 2
16988c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Tx Sensitivity 1G bit 3
16998c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Rx Sensitivity 1G bit 0
17008c2ecf20Sopenharmony_ci	 * LSB BIT 5 = Rx Sensitivity 1G bit 1
17018c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Rx Sensitivity 1G bit 2
17028c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Rx Sensitivity 1G bit 3
17038c2ecf20Sopenharmony_ci	 *
17048c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Tx Sensitivity 2G bit 0
17058c2ecf20Sopenharmony_ci	 * MSB BIT 1 = Tx Sensitivity 2G bit 1
17068c2ecf20Sopenharmony_ci	 * MSB BIT 2 = Tx Sensitivity 2G bit 2
17078c2ecf20Sopenharmony_ci	 * MSB BIT 3 = Tx Sensitivity 2G bit 3
17088c2ecf20Sopenharmony_ci	 * MSB BIT 4 = Rx Sensitivity 2G bit 0
17098c2ecf20Sopenharmony_ci	 * MSB BIT 5 = Rx Sensitivity 2G bit 1
17108c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Rx Sensitivity 2G bit 2
17118c2ecf20Sopenharmony_ci	 * MSB BIT 7 = Rx Sensitivity 2G bit 3
17128c2ecf20Sopenharmony_ci	 *
17138c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Output Swing 1G bit 0
17148c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Output Swing 1G bit 1
17158c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Output Swing 1G bit 2
17168c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Output Emphasis 1G bit 0
17178c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Output Emphasis 1G bit 1
17188c2ecf20Sopenharmony_ci	 * LSB BIT 5 = Output Swing 2G bit 0
17198c2ecf20Sopenharmony_ci	 * LSB BIT 6 = Output Swing 2G bit 1
17208c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Output Swing 2G bit 2
17218c2ecf20Sopenharmony_ci	 *
17228c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Output Emphasis 2G bit 0
17238c2ecf20Sopenharmony_ci	 * MSB BIT 1 = Output Emphasis 2G bit 1
17248c2ecf20Sopenharmony_ci	 * MSB BIT 2 = Output Enable
17258c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
17268c2ecf20Sopenharmony_ci	 * MSB BIT 4 =
17278c2ecf20Sopenharmony_ci	 * MSB BIT 5 =
17288c2ecf20Sopenharmony_ci	 * MSB BIT 6 =
17298c2ecf20Sopenharmony_ci	 * MSB BIT 7 =
17308c2ecf20Sopenharmony_ci	 */
17318c2ecf20Sopenharmony_ci	uint8_t seriallink_options[4];
17328c2ecf20Sopenharmony_ci
17338c2ecf20Sopenharmony_ci	/*
17348c2ecf20Sopenharmony_ci	 * NVRAM host parameter block
17358c2ecf20Sopenharmony_ci	 *
17368c2ecf20Sopenharmony_ci	 * LSB BIT 0 = Enable spinup delay
17378c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Disable BIOS
17388c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Enable Memory Map BIOS
17398c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Enable Selectable Boot
17408c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Disable RISC code load
17418c2ecf20Sopenharmony_ci	 * LSB BIT 5 = Set cache line size 1
17428c2ecf20Sopenharmony_ci	 * LSB BIT 6 = PCI Parity Disable
17438c2ecf20Sopenharmony_ci	 * LSB BIT 7 = Enable extended logging
17448c2ecf20Sopenharmony_ci	 *
17458c2ecf20Sopenharmony_ci	 * MSB BIT 0 = Enable 64bit addressing
17468c2ecf20Sopenharmony_ci	 * MSB BIT 1 = Enable lip reset
17478c2ecf20Sopenharmony_ci	 * MSB BIT 2 = Enable lip full login
17488c2ecf20Sopenharmony_ci	 * MSB BIT 3 = Enable target reset
17498c2ecf20Sopenharmony_ci	 * MSB BIT 4 = Enable database storage
17508c2ecf20Sopenharmony_ci	 * MSB BIT 5 = Enable cache flush read
17518c2ecf20Sopenharmony_ci	 * MSB BIT 6 = Enable database load
17528c2ecf20Sopenharmony_ci	 * MSB BIT 7 = Enable alternate WWN
17538c2ecf20Sopenharmony_ci	 */
17548c2ecf20Sopenharmony_ci	uint8_t host_p[2];
17558c2ecf20Sopenharmony_ci
17568c2ecf20Sopenharmony_ci	uint8_t boot_node_name[WWN_SIZE];
17578c2ecf20Sopenharmony_ci	uint8_t boot_lun_number;
17588c2ecf20Sopenharmony_ci	uint8_t reset_delay;
17598c2ecf20Sopenharmony_ci	uint8_t port_down_retry_count;
17608c2ecf20Sopenharmony_ci	uint8_t boot_id_number;
17618c2ecf20Sopenharmony_ci	__le16	max_luns_per_target;
17628c2ecf20Sopenharmony_ci	uint8_t fcode_boot_port_name[WWN_SIZE];
17638c2ecf20Sopenharmony_ci	uint8_t alternate_port_name[WWN_SIZE];
17648c2ecf20Sopenharmony_ci	uint8_t alternate_node_name[WWN_SIZE];
17658c2ecf20Sopenharmony_ci
17668c2ecf20Sopenharmony_ci	/*
17678c2ecf20Sopenharmony_ci	 * BIT 0 = Selective Login
17688c2ecf20Sopenharmony_ci	 * BIT 1 = Alt-Boot Enable
17698c2ecf20Sopenharmony_ci	 * BIT 2 =
17708c2ecf20Sopenharmony_ci	 * BIT 3 = Boot Order List
17718c2ecf20Sopenharmony_ci	 * BIT 4 =
17728c2ecf20Sopenharmony_ci	 * BIT 5 = Selective LUN
17738c2ecf20Sopenharmony_ci	 * BIT 6 =
17748c2ecf20Sopenharmony_ci	 * BIT 7 = unused
17758c2ecf20Sopenharmony_ci	 */
17768c2ecf20Sopenharmony_ci	uint8_t efi_parameters;
17778c2ecf20Sopenharmony_ci
17788c2ecf20Sopenharmony_ci	uint8_t link_down_timeout;
17798c2ecf20Sopenharmony_ci
17808c2ecf20Sopenharmony_ci	uint8_t adapter_id[16];
17818c2ecf20Sopenharmony_ci
17828c2ecf20Sopenharmony_ci	uint8_t alt1_boot_node_name[WWN_SIZE];
17838c2ecf20Sopenharmony_ci	uint16_t alt1_boot_lun_number;
17848c2ecf20Sopenharmony_ci	uint8_t alt2_boot_node_name[WWN_SIZE];
17858c2ecf20Sopenharmony_ci	uint16_t alt2_boot_lun_number;
17868c2ecf20Sopenharmony_ci	uint8_t alt3_boot_node_name[WWN_SIZE];
17878c2ecf20Sopenharmony_ci	uint16_t alt3_boot_lun_number;
17888c2ecf20Sopenharmony_ci	uint8_t alt4_boot_node_name[WWN_SIZE];
17898c2ecf20Sopenharmony_ci	uint16_t alt4_boot_lun_number;
17908c2ecf20Sopenharmony_ci	uint8_t alt5_boot_node_name[WWN_SIZE];
17918c2ecf20Sopenharmony_ci	uint16_t alt5_boot_lun_number;
17928c2ecf20Sopenharmony_ci	uint8_t alt6_boot_node_name[WWN_SIZE];
17938c2ecf20Sopenharmony_ci	uint16_t alt6_boot_lun_number;
17948c2ecf20Sopenharmony_ci	uint8_t alt7_boot_node_name[WWN_SIZE];
17958c2ecf20Sopenharmony_ci	uint16_t alt7_boot_lun_number;
17968c2ecf20Sopenharmony_ci
17978c2ecf20Sopenharmony_ci	uint8_t reserved_3[2];
17988c2ecf20Sopenharmony_ci
17998c2ecf20Sopenharmony_ci	/* Offset 200-215 : Model Number */
18008c2ecf20Sopenharmony_ci	uint8_t model_number[16];
18018c2ecf20Sopenharmony_ci
18028c2ecf20Sopenharmony_ci	/* OEM related items */
18038c2ecf20Sopenharmony_ci	uint8_t oem_specific[16];
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_ci	/*
18068c2ecf20Sopenharmony_ci	 * NVRAM Adapter Features offset 232-239
18078c2ecf20Sopenharmony_ci	 *
18088c2ecf20Sopenharmony_ci	 * LSB BIT 0 = External GBIC
18098c2ecf20Sopenharmony_ci	 * LSB BIT 1 = Risc RAM parity
18108c2ecf20Sopenharmony_ci	 * LSB BIT 2 = Buffer Plus Module
18118c2ecf20Sopenharmony_ci	 * LSB BIT 3 = Multi Chip Adapter
18128c2ecf20Sopenharmony_ci	 * LSB BIT 4 = Internal connector
18138c2ecf20Sopenharmony_ci	 * LSB BIT 5 =
18148c2ecf20Sopenharmony_ci	 * LSB BIT 6 =
18158c2ecf20Sopenharmony_ci	 * LSB BIT 7 =
18168c2ecf20Sopenharmony_ci	 *
18178c2ecf20Sopenharmony_ci	 * MSB BIT 0 =
18188c2ecf20Sopenharmony_ci	 * MSB BIT 1 =
18198c2ecf20Sopenharmony_ci	 * MSB BIT 2 =
18208c2ecf20Sopenharmony_ci	 * MSB BIT 3 =
18218c2ecf20Sopenharmony_ci	 * MSB BIT 4 =
18228c2ecf20Sopenharmony_ci	 * MSB BIT 5 =
18238c2ecf20Sopenharmony_ci	 * MSB BIT 6 =
18248c2ecf20Sopenharmony_ci	 * MSB BIT 7 =
18258c2ecf20Sopenharmony_ci	 */
18268c2ecf20Sopenharmony_ci	uint8_t	adapter_features[2];
18278c2ecf20Sopenharmony_ci
18288c2ecf20Sopenharmony_ci	uint8_t reserved_4[16];
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	/* Subsystem vendor ID for ISP2200 */
18318c2ecf20Sopenharmony_ci	uint16_t subsystem_vendor_id_2200;
18328c2ecf20Sopenharmony_ci
18338c2ecf20Sopenharmony_ci	/* Subsystem device ID for ISP2200 */
18348c2ecf20Sopenharmony_ci	uint16_t subsystem_device_id_2200;
18358c2ecf20Sopenharmony_ci
18368c2ecf20Sopenharmony_ci	uint8_t	 reserved_5;
18378c2ecf20Sopenharmony_ci	uint8_t	 checksum;
18388c2ecf20Sopenharmony_ci} nvram_t;
18398c2ecf20Sopenharmony_ci
18408c2ecf20Sopenharmony_ci/*
18418c2ecf20Sopenharmony_ci * ISP queue - response queue entry definition.
18428c2ecf20Sopenharmony_ci */
18438c2ecf20Sopenharmony_citypedef struct {
18448c2ecf20Sopenharmony_ci	uint8_t		entry_type;		/* Entry type. */
18458c2ecf20Sopenharmony_ci	uint8_t		entry_count;		/* Entry count. */
18468c2ecf20Sopenharmony_ci	uint8_t		sys_define;		/* System defined. */
18478c2ecf20Sopenharmony_ci	uint8_t		entry_status;		/* Entry Status. */
18488c2ecf20Sopenharmony_ci	uint32_t	handle;			/* System defined handle */
18498c2ecf20Sopenharmony_ci	uint8_t		data[52];
18508c2ecf20Sopenharmony_ci	uint32_t	signature;
18518c2ecf20Sopenharmony_ci#define RESPONSE_PROCESSED	0xDEADDEAD	/* Signature */
18528c2ecf20Sopenharmony_ci} response_t;
18538c2ecf20Sopenharmony_ci
18548c2ecf20Sopenharmony_ci/*
18558c2ecf20Sopenharmony_ci * ISP queue - ATIO queue entry definition.
18568c2ecf20Sopenharmony_ci */
18578c2ecf20Sopenharmony_cistruct atio {
18588c2ecf20Sopenharmony_ci	uint8_t		entry_type;		/* Entry type. */
18598c2ecf20Sopenharmony_ci	uint8_t		entry_count;		/* Entry count. */
18608c2ecf20Sopenharmony_ci	__le16		attr_n_length;
18618c2ecf20Sopenharmony_ci	uint8_t		data[56];
18628c2ecf20Sopenharmony_ci	uint32_t	signature;
18638c2ecf20Sopenharmony_ci#define ATIO_PROCESSED 0xDEADDEAD		/* Signature */
18648c2ecf20Sopenharmony_ci};
18658c2ecf20Sopenharmony_ci
18668c2ecf20Sopenharmony_citypedef union {
18678c2ecf20Sopenharmony_ci	__le16	extended;
18688c2ecf20Sopenharmony_ci	struct {
18698c2ecf20Sopenharmony_ci		uint8_t reserved;
18708c2ecf20Sopenharmony_ci		uint8_t standard;
18718c2ecf20Sopenharmony_ci	} id;
18728c2ecf20Sopenharmony_ci} target_id_t;
18738c2ecf20Sopenharmony_ci
18748c2ecf20Sopenharmony_ci#define SET_TARGET_ID(ha, to, from)			\
18758c2ecf20Sopenharmony_cido {							\
18768c2ecf20Sopenharmony_ci	if (HAS_EXTENDED_IDS(ha))			\
18778c2ecf20Sopenharmony_ci		to.extended = cpu_to_le16(from);	\
18788c2ecf20Sopenharmony_ci	else						\
18798c2ecf20Sopenharmony_ci		to.id.standard = (uint8_t)from;		\
18808c2ecf20Sopenharmony_ci} while (0)
18818c2ecf20Sopenharmony_ci
18828c2ecf20Sopenharmony_ci/*
18838c2ecf20Sopenharmony_ci * ISP queue - command entry structure definition.
18848c2ecf20Sopenharmony_ci */
18858c2ecf20Sopenharmony_ci#define COMMAND_TYPE	0x11		/* Command entry */
18868c2ecf20Sopenharmony_citypedef struct {
18878c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
18888c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
18898c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
18908c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
18918c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
18928c2ecf20Sopenharmony_ci	target_id_t target;		/* SCSI ID */
18938c2ecf20Sopenharmony_ci	__le16	lun;			/* SCSI LUN */
18948c2ecf20Sopenharmony_ci	__le16	control_flags;		/* Control flags. */
18958c2ecf20Sopenharmony_ci#define CF_WRITE	BIT_6
18968c2ecf20Sopenharmony_ci#define CF_READ		BIT_5
18978c2ecf20Sopenharmony_ci#define CF_SIMPLE_TAG	BIT_3
18988c2ecf20Sopenharmony_ci#define CF_ORDERED_TAG	BIT_2
18998c2ecf20Sopenharmony_ci#define CF_HEAD_TAG	BIT_1
19008c2ecf20Sopenharmony_ci	uint16_t reserved_1;
19018c2ecf20Sopenharmony_ci	__le16	timeout;		/* Command timeout. */
19028c2ecf20Sopenharmony_ci	__le16	dseg_count;		/* Data segment count. */
19038c2ecf20Sopenharmony_ci	uint8_t scsi_cdb[MAX_CMDSZ]; 	/* SCSI command words. */
19048c2ecf20Sopenharmony_ci	__le32	byte_count;		/* Total byte count. */
19058c2ecf20Sopenharmony_ci	union {
19068c2ecf20Sopenharmony_ci		struct dsd32 dsd32[3];
19078c2ecf20Sopenharmony_ci		struct dsd64 dsd64[2];
19088c2ecf20Sopenharmony_ci	};
19098c2ecf20Sopenharmony_ci} cmd_entry_t;
19108c2ecf20Sopenharmony_ci
19118c2ecf20Sopenharmony_ci/*
19128c2ecf20Sopenharmony_ci * ISP queue - 64-Bit addressing, command entry structure definition.
19138c2ecf20Sopenharmony_ci */
19148c2ecf20Sopenharmony_ci#define COMMAND_A64_TYPE	0x19	/* Command A64 entry */
19158c2ecf20Sopenharmony_citypedef struct {
19168c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
19178c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
19188c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
19198c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
19208c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
19218c2ecf20Sopenharmony_ci	target_id_t target;		/* SCSI ID */
19228c2ecf20Sopenharmony_ci	__le16	lun;			/* SCSI LUN */
19238c2ecf20Sopenharmony_ci	__le16	control_flags;		/* Control flags. */
19248c2ecf20Sopenharmony_ci	uint16_t reserved_1;
19258c2ecf20Sopenharmony_ci	__le16	timeout;		/* Command timeout. */
19268c2ecf20Sopenharmony_ci	__le16	dseg_count;		/* Data segment count. */
19278c2ecf20Sopenharmony_ci	uint8_t scsi_cdb[MAX_CMDSZ];	/* SCSI command words. */
19288c2ecf20Sopenharmony_ci	uint32_t byte_count;		/* Total byte count. */
19298c2ecf20Sopenharmony_ci	struct dsd64 dsd[2];
19308c2ecf20Sopenharmony_ci} cmd_a64_entry_t, request_t;
19318c2ecf20Sopenharmony_ci
19328c2ecf20Sopenharmony_ci/*
19338c2ecf20Sopenharmony_ci * ISP queue - continuation entry structure definition.
19348c2ecf20Sopenharmony_ci */
19358c2ecf20Sopenharmony_ci#define CONTINUE_TYPE		0x02	/* Continuation entry. */
19368c2ecf20Sopenharmony_citypedef struct {
19378c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
19388c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
19398c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
19408c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
19418c2ecf20Sopenharmony_ci	uint32_t reserved;
19428c2ecf20Sopenharmony_ci	struct dsd32 dsd[7];
19438c2ecf20Sopenharmony_ci} cont_entry_t;
19448c2ecf20Sopenharmony_ci
19458c2ecf20Sopenharmony_ci/*
19468c2ecf20Sopenharmony_ci * ISP queue - 64-Bit addressing, continuation entry structure definition.
19478c2ecf20Sopenharmony_ci */
19488c2ecf20Sopenharmony_ci#define CONTINUE_A64_TYPE	0x0A	/* Continuation A64 entry. */
19498c2ecf20Sopenharmony_citypedef struct {
19508c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
19518c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
19528c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
19538c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
19548c2ecf20Sopenharmony_ci	struct dsd64 dsd[5];
19558c2ecf20Sopenharmony_ci} cont_a64_entry_t;
19568c2ecf20Sopenharmony_ci
19578c2ecf20Sopenharmony_ci#define PO_MODE_DIF_INSERT	0
19588c2ecf20Sopenharmony_ci#define PO_MODE_DIF_REMOVE	1
19598c2ecf20Sopenharmony_ci#define PO_MODE_DIF_PASS	2
19608c2ecf20Sopenharmony_ci#define PO_MODE_DIF_REPLACE	3
19618c2ecf20Sopenharmony_ci#define PO_MODE_DIF_TCP_CKSUM	6
19628c2ecf20Sopenharmony_ci#define PO_ENABLE_INCR_GUARD_SEED	BIT_3
19638c2ecf20Sopenharmony_ci#define PO_DISABLE_GUARD_CHECK	BIT_4
19648c2ecf20Sopenharmony_ci#define PO_DISABLE_INCR_REF_TAG	BIT_5
19658c2ecf20Sopenharmony_ci#define PO_DIS_HEADER_MODE	BIT_7
19668c2ecf20Sopenharmony_ci#define PO_ENABLE_DIF_BUNDLING	BIT_8
19678c2ecf20Sopenharmony_ci#define PO_DIS_FRAME_MODE	BIT_9
19688c2ecf20Sopenharmony_ci#define PO_DIS_VALD_APP_ESC	BIT_10 /* Dis validation for escape tag/ffffh */
19698c2ecf20Sopenharmony_ci#define PO_DIS_VALD_APP_REF_ESC BIT_11
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_ci#define PO_DIS_APP_TAG_REPL	BIT_12 /* disable REG Tag replacement */
19728c2ecf20Sopenharmony_ci#define PO_DIS_REF_TAG_REPL	BIT_13
19738c2ecf20Sopenharmony_ci#define PO_DIS_APP_TAG_VALD	BIT_14 /* disable REF Tag validation */
19748c2ecf20Sopenharmony_ci#define PO_DIS_REF_TAG_VALD	BIT_15
19758c2ecf20Sopenharmony_ci
19768c2ecf20Sopenharmony_ci/*
19778c2ecf20Sopenharmony_ci * ISP queue - 64-Bit addressing, continuation crc entry structure definition.
19788c2ecf20Sopenharmony_ci */
19798c2ecf20Sopenharmony_cistruct crc_context {
19808c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
19818c2ecf20Sopenharmony_ci	__le32 ref_tag;
19828c2ecf20Sopenharmony_ci	__le16 app_tag;
19838c2ecf20Sopenharmony_ci	uint8_t ref_tag_mask[4];	/* Validation/Replacement Mask*/
19848c2ecf20Sopenharmony_ci	uint8_t app_tag_mask[2];	/* Validation/Replacement Mask*/
19858c2ecf20Sopenharmony_ci	__le16 guard_seed;		/* Initial Guard Seed */
19868c2ecf20Sopenharmony_ci	__le16 prot_opts;		/* Requested Data Protection Mode */
19878c2ecf20Sopenharmony_ci	__le16 blk_size;		/* Data size in bytes */
19888c2ecf20Sopenharmony_ci	__le16	runt_blk_guard;	/* Guard value for runt block (tape
19898c2ecf20Sopenharmony_ci					 * only) */
19908c2ecf20Sopenharmony_ci	__le32 byte_count;		/* Total byte count/ total data
19918c2ecf20Sopenharmony_ci					 * transfer count */
19928c2ecf20Sopenharmony_ci	union {
19938c2ecf20Sopenharmony_ci		struct {
19948c2ecf20Sopenharmony_ci			uint32_t	reserved_1;
19958c2ecf20Sopenharmony_ci			uint16_t	reserved_2;
19968c2ecf20Sopenharmony_ci			uint16_t	reserved_3;
19978c2ecf20Sopenharmony_ci			uint32_t	reserved_4;
19988c2ecf20Sopenharmony_ci			struct dsd64	data_dsd[1];
19998c2ecf20Sopenharmony_ci			uint32_t	reserved_5[2];
20008c2ecf20Sopenharmony_ci			uint32_t	reserved_6;
20018c2ecf20Sopenharmony_ci		} nobundling;
20028c2ecf20Sopenharmony_ci		struct {
20038c2ecf20Sopenharmony_ci			__le32	dif_byte_count;	/* Total DIF byte
20048c2ecf20Sopenharmony_ci							 * count */
20058c2ecf20Sopenharmony_ci			uint16_t	reserved_1;
20068c2ecf20Sopenharmony_ci			__le16	dseg_count;	/* Data segment count */
20078c2ecf20Sopenharmony_ci			uint32_t	reserved_2;
20088c2ecf20Sopenharmony_ci			struct dsd64	data_dsd[1];
20098c2ecf20Sopenharmony_ci			struct dsd64	dif_dsd;
20108c2ecf20Sopenharmony_ci		} bundling;
20118c2ecf20Sopenharmony_ci	} u;
20128c2ecf20Sopenharmony_ci
20138c2ecf20Sopenharmony_ci	struct fcp_cmnd	fcp_cmnd;
20148c2ecf20Sopenharmony_ci	dma_addr_t	crc_ctx_dma;
20158c2ecf20Sopenharmony_ci	/* List of DMA context transfers */
20168c2ecf20Sopenharmony_ci	struct list_head dsd_list;
20178c2ecf20Sopenharmony_ci
20188c2ecf20Sopenharmony_ci	/* List of DIF Bundling context DMA address */
20198c2ecf20Sopenharmony_ci	struct list_head ldif_dsd_list;
20208c2ecf20Sopenharmony_ci	u8 no_ldif_dsd;
20218c2ecf20Sopenharmony_ci
20228c2ecf20Sopenharmony_ci	struct list_head ldif_dma_hndl_list;
20238c2ecf20Sopenharmony_ci	u32 dif_bundl_len;
20248c2ecf20Sopenharmony_ci	u8 no_dif_bundl;
20258c2ecf20Sopenharmony_ci	/* This structure should not exceed 512 bytes */
20268c2ecf20Sopenharmony_ci};
20278c2ecf20Sopenharmony_ci
20288c2ecf20Sopenharmony_ci#define CRC_CONTEXT_LEN_FW	(offsetof(struct crc_context, fcp_cmnd.lun))
20298c2ecf20Sopenharmony_ci#define CRC_CONTEXT_FCPCMND_OFF	(offsetof(struct crc_context, fcp_cmnd.lun))
20308c2ecf20Sopenharmony_ci
20318c2ecf20Sopenharmony_ci/*
20328c2ecf20Sopenharmony_ci * ISP queue - status entry structure definition.
20338c2ecf20Sopenharmony_ci */
20348c2ecf20Sopenharmony_ci#define	STATUS_TYPE	0x03		/* Status entry. */
20358c2ecf20Sopenharmony_citypedef struct {
20368c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
20378c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
20388c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
20398c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
20408c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
20418c2ecf20Sopenharmony_ci	__le16	scsi_status;		/* SCSI status. */
20428c2ecf20Sopenharmony_ci	__le16	comp_status;		/* Completion status. */
20438c2ecf20Sopenharmony_ci	__le16	state_flags;		/* State flags. */
20448c2ecf20Sopenharmony_ci	__le16	status_flags;		/* Status flags. */
20458c2ecf20Sopenharmony_ci	__le16	rsp_info_len;		/* Response Info Length. */
20468c2ecf20Sopenharmony_ci	__le16	req_sense_length;	/* Request sense data length. */
20478c2ecf20Sopenharmony_ci	__le32	residual_length;	/* Residual transfer length. */
20488c2ecf20Sopenharmony_ci	uint8_t rsp_info[8];		/* FCP response information. */
20498c2ecf20Sopenharmony_ci	uint8_t req_sense_data[32];	/* Request sense data. */
20508c2ecf20Sopenharmony_ci} sts_entry_t;
20518c2ecf20Sopenharmony_ci
20528c2ecf20Sopenharmony_ci/*
20538c2ecf20Sopenharmony_ci * Status entry entry status
20548c2ecf20Sopenharmony_ci */
20558c2ecf20Sopenharmony_ci#define RF_RQ_DMA_ERROR	BIT_6		/* Request Queue DMA error. */
20568c2ecf20Sopenharmony_ci#define RF_INV_E_ORDER	BIT_5		/* Invalid entry order. */
20578c2ecf20Sopenharmony_ci#define RF_INV_E_COUNT	BIT_4		/* Invalid entry count. */
20588c2ecf20Sopenharmony_ci#define RF_INV_E_PARAM	BIT_3		/* Invalid entry parameter. */
20598c2ecf20Sopenharmony_ci#define RF_INV_E_TYPE	BIT_2		/* Invalid entry type. */
20608c2ecf20Sopenharmony_ci#define RF_BUSY		BIT_1		/* Busy */
20618c2ecf20Sopenharmony_ci#define RF_MASK		(RF_RQ_DMA_ERROR | RF_INV_E_ORDER | RF_INV_E_COUNT | \
20628c2ecf20Sopenharmony_ci			 RF_INV_E_PARAM | RF_INV_E_TYPE | RF_BUSY)
20638c2ecf20Sopenharmony_ci#define RF_MASK_24XX	(RF_INV_E_ORDER | RF_INV_E_COUNT | RF_INV_E_PARAM | \
20648c2ecf20Sopenharmony_ci			 RF_INV_E_TYPE)
20658c2ecf20Sopenharmony_ci
20668c2ecf20Sopenharmony_ci/*
20678c2ecf20Sopenharmony_ci * Status entry SCSI status bit definitions.
20688c2ecf20Sopenharmony_ci */
20698c2ecf20Sopenharmony_ci#define SS_MASK				0xfff	/* Reserved bits BIT_12-BIT_15*/
20708c2ecf20Sopenharmony_ci#define SS_RESIDUAL_UNDER		BIT_11
20718c2ecf20Sopenharmony_ci#define SS_RESIDUAL_OVER		BIT_10
20728c2ecf20Sopenharmony_ci#define SS_SENSE_LEN_VALID		BIT_9
20738c2ecf20Sopenharmony_ci#define SS_RESPONSE_INFO_LEN_VALID	BIT_8
20748c2ecf20Sopenharmony_ci#define SS_SCSI_STATUS_BYTE	0xff
20758c2ecf20Sopenharmony_ci
20768c2ecf20Sopenharmony_ci#define SS_RESERVE_CONFLICT		(BIT_4 | BIT_3)
20778c2ecf20Sopenharmony_ci#define SS_BUSY_CONDITION		BIT_3
20788c2ecf20Sopenharmony_ci#define SS_CONDITION_MET		BIT_2
20798c2ecf20Sopenharmony_ci#define SS_CHECK_CONDITION		BIT_1
20808c2ecf20Sopenharmony_ci
20818c2ecf20Sopenharmony_ci/*
20828c2ecf20Sopenharmony_ci * Status entry completion status
20838c2ecf20Sopenharmony_ci */
20848c2ecf20Sopenharmony_ci#define CS_COMPLETE		0x0	/* No errors */
20858c2ecf20Sopenharmony_ci#define CS_INCOMPLETE		0x1	/* Incomplete transfer of cmd. */
20868c2ecf20Sopenharmony_ci#define CS_DMA			0x2	/* A DMA direction error. */
20878c2ecf20Sopenharmony_ci#define CS_TRANSPORT		0x3	/* Transport error. */
20888c2ecf20Sopenharmony_ci#define CS_RESET		0x4	/* SCSI bus reset occurred */
20898c2ecf20Sopenharmony_ci#define CS_ABORTED		0x5	/* System aborted command. */
20908c2ecf20Sopenharmony_ci#define CS_TIMEOUT		0x6	/* Timeout error. */
20918c2ecf20Sopenharmony_ci#define CS_DATA_OVERRUN		0x7	/* Data overrun. */
20928c2ecf20Sopenharmony_ci#define CS_DIF_ERROR		0xC	/* DIF error detected  */
20938c2ecf20Sopenharmony_ci
20948c2ecf20Sopenharmony_ci#define CS_DATA_UNDERRUN	0x15	/* Data Underrun. */
20958c2ecf20Sopenharmony_ci#define CS_QUEUE_FULL		0x1C	/* Queue Full. */
20968c2ecf20Sopenharmony_ci#define CS_PORT_UNAVAILABLE	0x28	/* Port unavailable */
20978c2ecf20Sopenharmony_ci					/* (selection timeout) */
20988c2ecf20Sopenharmony_ci#define CS_PORT_LOGGED_OUT	0x29	/* Port Logged Out */
20998c2ecf20Sopenharmony_ci#define CS_PORT_CONFIG_CHG	0x2A	/* Port Configuration Changed */
21008c2ecf20Sopenharmony_ci#define CS_PORT_BUSY		0x2B	/* Port Busy */
21018c2ecf20Sopenharmony_ci#define CS_COMPLETE_CHKCOND	0x30	/* Error? */
21028c2ecf20Sopenharmony_ci#define CS_IOCB_ERROR		0x31	/* Generic error for IOCB request
21038c2ecf20Sopenharmony_ci					   failure */
21048c2ecf20Sopenharmony_ci#define CS_BAD_PAYLOAD		0x80	/* Driver defined */
21058c2ecf20Sopenharmony_ci#define CS_UNKNOWN		0x81	/* Driver defined */
21068c2ecf20Sopenharmony_ci#define CS_RETRY		0x82	/* Driver defined */
21078c2ecf20Sopenharmony_ci#define CS_LOOP_DOWN_ABORT	0x83	/* Driver defined */
21088c2ecf20Sopenharmony_ci
21098c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_OVERRUN			0x700
21108c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_WR_OVERRUN			0x707
21118c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_OVERRUN_WR_UNDERRUN		0x715
21128c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_UNDERRUN			0x1500
21138c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_UNDERRUN_WR_OVERRUN		0x1507
21148c2ecf20Sopenharmony_ci#define CS_BIDIR_RD_WR_UNDERRUN			0x1515
21158c2ecf20Sopenharmony_ci#define CS_BIDIR_DMA				0x200
21168c2ecf20Sopenharmony_ci/*
21178c2ecf20Sopenharmony_ci * Status entry status flags
21188c2ecf20Sopenharmony_ci */
21198c2ecf20Sopenharmony_ci#define SF_ABTS_TERMINATED	BIT_10
21208c2ecf20Sopenharmony_ci#define SF_LOGOUT_SENT		BIT_13
21218c2ecf20Sopenharmony_ci
21228c2ecf20Sopenharmony_ci/*
21238c2ecf20Sopenharmony_ci * ISP queue - status continuation entry structure definition.
21248c2ecf20Sopenharmony_ci */
21258c2ecf20Sopenharmony_ci#define	STATUS_CONT_TYPE	0x10	/* Status continuation entry. */
21268c2ecf20Sopenharmony_citypedef struct {
21278c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
21288c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
21298c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
21308c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
21318c2ecf20Sopenharmony_ci	uint8_t data[60];		/* data */
21328c2ecf20Sopenharmony_ci} sts_cont_entry_t;
21338c2ecf20Sopenharmony_ci
21348c2ecf20Sopenharmony_ci/*
21358c2ecf20Sopenharmony_ci * ISP queue -	RIO Type 1 status entry (32 bit I/O entry handles)
21368c2ecf20Sopenharmony_ci *		structure definition.
21378c2ecf20Sopenharmony_ci */
21388c2ecf20Sopenharmony_ci#define	STATUS_TYPE_21 0x21		/* Status entry. */
21398c2ecf20Sopenharmony_citypedef struct {
21408c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
21418c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
21428c2ecf20Sopenharmony_ci	uint8_t handle_count;		/* Handle count. */
21438c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
21448c2ecf20Sopenharmony_ci	uint32_t handle[15];		/* System handles. */
21458c2ecf20Sopenharmony_ci} sts21_entry_t;
21468c2ecf20Sopenharmony_ci
21478c2ecf20Sopenharmony_ci/*
21488c2ecf20Sopenharmony_ci * ISP queue -	RIO Type 2 status entry (16 bit I/O entry handles)
21498c2ecf20Sopenharmony_ci *		structure definition.
21508c2ecf20Sopenharmony_ci */
21518c2ecf20Sopenharmony_ci#define	STATUS_TYPE_22	0x22		/* Status entry. */
21528c2ecf20Sopenharmony_citypedef struct {
21538c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
21548c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
21558c2ecf20Sopenharmony_ci	uint8_t handle_count;		/* Handle count. */
21568c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
21578c2ecf20Sopenharmony_ci	uint16_t handle[30];		/* System handles. */
21588c2ecf20Sopenharmony_ci} sts22_entry_t;
21598c2ecf20Sopenharmony_ci
21608c2ecf20Sopenharmony_ci/*
21618c2ecf20Sopenharmony_ci * ISP queue - marker entry structure definition.
21628c2ecf20Sopenharmony_ci */
21638c2ecf20Sopenharmony_ci#define MARKER_TYPE	0x04		/* Marker entry. */
21648c2ecf20Sopenharmony_citypedef struct {
21658c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
21668c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
21678c2ecf20Sopenharmony_ci	uint8_t handle_count;		/* Handle count. */
21688c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
21698c2ecf20Sopenharmony_ci	uint32_t sys_define_2;		/* System defined. */
21708c2ecf20Sopenharmony_ci	target_id_t target;		/* SCSI ID */
21718c2ecf20Sopenharmony_ci	uint8_t modifier;		/* Modifier (7-0). */
21728c2ecf20Sopenharmony_ci#define MK_SYNC_ID_LUN	0		/* Synchronize ID/LUN */
21738c2ecf20Sopenharmony_ci#define MK_SYNC_ID	1		/* Synchronize ID */
21748c2ecf20Sopenharmony_ci#define MK_SYNC_ALL	2		/* Synchronize all ID/LUN */
21758c2ecf20Sopenharmony_ci#define MK_SYNC_LIP	3		/* Synchronize all ID/LUN, */
21768c2ecf20Sopenharmony_ci					/* clear port changed, */
21778c2ecf20Sopenharmony_ci					/* use sequence number. */
21788c2ecf20Sopenharmony_ci	uint8_t reserved_1;
21798c2ecf20Sopenharmony_ci	__le16	sequence_number;	/* Sequence number of event */
21808c2ecf20Sopenharmony_ci	__le16	lun;			/* SCSI LUN */
21818c2ecf20Sopenharmony_ci	uint8_t reserved_2[48];
21828c2ecf20Sopenharmony_ci} mrk_entry_t;
21838c2ecf20Sopenharmony_ci
21848c2ecf20Sopenharmony_ci/*
21858c2ecf20Sopenharmony_ci * ISP queue - Management Server entry structure definition.
21868c2ecf20Sopenharmony_ci */
21878c2ecf20Sopenharmony_ci#define MS_IOCB_TYPE		0x29	/* Management Server IOCB entry */
21888c2ecf20Sopenharmony_citypedef struct {
21898c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
21908c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
21918c2ecf20Sopenharmony_ci	uint8_t handle_count;		/* Handle count. */
21928c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
21938c2ecf20Sopenharmony_ci	uint32_t handle1;		/* System handle. */
21948c2ecf20Sopenharmony_ci	target_id_t loop_id;
21958c2ecf20Sopenharmony_ci	__le16	status;
21968c2ecf20Sopenharmony_ci	__le16	control_flags;		/* Control flags. */
21978c2ecf20Sopenharmony_ci	uint16_t reserved2;
21988c2ecf20Sopenharmony_ci	__le16	timeout;
21998c2ecf20Sopenharmony_ci	__le16	cmd_dsd_count;
22008c2ecf20Sopenharmony_ci	__le16	total_dsd_count;
22018c2ecf20Sopenharmony_ci	uint8_t type;
22028c2ecf20Sopenharmony_ci	uint8_t r_ctl;
22038c2ecf20Sopenharmony_ci	__le16	rx_id;
22048c2ecf20Sopenharmony_ci	uint16_t reserved3;
22058c2ecf20Sopenharmony_ci	uint32_t handle2;
22068c2ecf20Sopenharmony_ci	__le32	rsp_bytecount;
22078c2ecf20Sopenharmony_ci	__le32	req_bytecount;
22088c2ecf20Sopenharmony_ci	struct dsd64 req_dsd;
22098c2ecf20Sopenharmony_ci	struct dsd64 rsp_dsd;
22108c2ecf20Sopenharmony_ci} ms_iocb_entry_t;
22118c2ecf20Sopenharmony_ci
22128c2ecf20Sopenharmony_ci#define SCM_EDC_ACC_RECEIVED		BIT_6
22138c2ecf20Sopenharmony_ci#define SCM_RDF_ACC_RECEIVED		BIT_7
22148c2ecf20Sopenharmony_ci
22158c2ecf20Sopenharmony_ci/*
22168c2ecf20Sopenharmony_ci * ISP queue - Mailbox Command entry structure definition.
22178c2ecf20Sopenharmony_ci */
22188c2ecf20Sopenharmony_ci#define MBX_IOCB_TYPE	0x39
22198c2ecf20Sopenharmony_cistruct mbx_entry {
22208c2ecf20Sopenharmony_ci	uint8_t entry_type;
22218c2ecf20Sopenharmony_ci	uint8_t entry_count;
22228c2ecf20Sopenharmony_ci	uint8_t sys_define1;
22238c2ecf20Sopenharmony_ci	/* Use sys_define1 for source type */
22248c2ecf20Sopenharmony_ci#define SOURCE_SCSI	0x00
22258c2ecf20Sopenharmony_ci#define SOURCE_IP	0x01
22268c2ecf20Sopenharmony_ci#define SOURCE_VI	0x02
22278c2ecf20Sopenharmony_ci#define SOURCE_SCTP	0x03
22288c2ecf20Sopenharmony_ci#define SOURCE_MP	0x04
22298c2ecf20Sopenharmony_ci#define SOURCE_MPIOCTL	0x05
22308c2ecf20Sopenharmony_ci#define SOURCE_ASYNC_IOCB 0x07
22318c2ecf20Sopenharmony_ci
22328c2ecf20Sopenharmony_ci	uint8_t entry_status;
22338c2ecf20Sopenharmony_ci
22348c2ecf20Sopenharmony_ci	uint32_t handle;
22358c2ecf20Sopenharmony_ci	target_id_t loop_id;
22368c2ecf20Sopenharmony_ci
22378c2ecf20Sopenharmony_ci	__le16	status;
22388c2ecf20Sopenharmony_ci	__le16	state_flags;
22398c2ecf20Sopenharmony_ci	__le16	status_flags;
22408c2ecf20Sopenharmony_ci
22418c2ecf20Sopenharmony_ci	uint32_t sys_define2[2];
22428c2ecf20Sopenharmony_ci
22438c2ecf20Sopenharmony_ci	__le16	mb0;
22448c2ecf20Sopenharmony_ci	__le16	mb1;
22458c2ecf20Sopenharmony_ci	__le16	mb2;
22468c2ecf20Sopenharmony_ci	__le16	mb3;
22478c2ecf20Sopenharmony_ci	__le16	mb6;
22488c2ecf20Sopenharmony_ci	__le16	mb7;
22498c2ecf20Sopenharmony_ci	__le16	mb9;
22508c2ecf20Sopenharmony_ci	__le16	mb10;
22518c2ecf20Sopenharmony_ci	uint32_t reserved_2[2];
22528c2ecf20Sopenharmony_ci	uint8_t node_name[WWN_SIZE];
22538c2ecf20Sopenharmony_ci	uint8_t port_name[WWN_SIZE];
22548c2ecf20Sopenharmony_ci};
22558c2ecf20Sopenharmony_ci
22568c2ecf20Sopenharmony_ci#ifndef IMMED_NOTIFY_TYPE
22578c2ecf20Sopenharmony_ci#define IMMED_NOTIFY_TYPE 0x0D		/* Immediate notify entry. */
22588c2ecf20Sopenharmony_ci/*
22598c2ecf20Sopenharmony_ci * ISP queue -	immediate notify entry structure definition.
22608c2ecf20Sopenharmony_ci *		This is sent by the ISP to the Target driver.
22618c2ecf20Sopenharmony_ci *		This IOCB would have report of events sent by the
22628c2ecf20Sopenharmony_ci *		initiator, that needs to be handled by the target
22638c2ecf20Sopenharmony_ci *		driver immediately.
22648c2ecf20Sopenharmony_ci */
22658c2ecf20Sopenharmony_cistruct imm_ntfy_from_isp {
22668c2ecf20Sopenharmony_ci	uint8_t	 entry_type;		    /* Entry type. */
22678c2ecf20Sopenharmony_ci	uint8_t	 entry_count;		    /* Entry count. */
22688c2ecf20Sopenharmony_ci	uint8_t	 sys_define;		    /* System defined. */
22698c2ecf20Sopenharmony_ci	uint8_t	 entry_status;		    /* Entry Status. */
22708c2ecf20Sopenharmony_ci	union {
22718c2ecf20Sopenharmony_ci		struct {
22728c2ecf20Sopenharmony_ci			__le32	sys_define_2; /* System defined. */
22738c2ecf20Sopenharmony_ci			target_id_t target;
22748c2ecf20Sopenharmony_ci			__le16	lun;
22758c2ecf20Sopenharmony_ci			uint8_t  target_id;
22768c2ecf20Sopenharmony_ci			uint8_t  reserved_1;
22778c2ecf20Sopenharmony_ci			__le16	status_modifier;
22788c2ecf20Sopenharmony_ci			__le16	status;
22798c2ecf20Sopenharmony_ci			__le16	task_flags;
22808c2ecf20Sopenharmony_ci			__le16	seq_id;
22818c2ecf20Sopenharmony_ci			__le16	srr_rx_id;
22828c2ecf20Sopenharmony_ci			__le32	srr_rel_offs;
22838c2ecf20Sopenharmony_ci			__le16	srr_ui;
22848c2ecf20Sopenharmony_ci#define SRR_IU_DATA_IN	0x1
22858c2ecf20Sopenharmony_ci#define SRR_IU_DATA_OUT	0x5
22868c2ecf20Sopenharmony_ci#define SRR_IU_STATUS	0x7
22878c2ecf20Sopenharmony_ci			__le16	srr_ox_id;
22888c2ecf20Sopenharmony_ci			uint8_t reserved_2[28];
22898c2ecf20Sopenharmony_ci		} isp2x;
22908c2ecf20Sopenharmony_ci		struct {
22918c2ecf20Sopenharmony_ci			uint32_t reserved;
22928c2ecf20Sopenharmony_ci			__le16	nport_handle;
22938c2ecf20Sopenharmony_ci			uint16_t reserved_2;
22948c2ecf20Sopenharmony_ci			__le16	flags;
22958c2ecf20Sopenharmony_ci#define NOTIFY24XX_FLAGS_GLOBAL_TPRLO   BIT_1
22968c2ecf20Sopenharmony_ci#define NOTIFY24XX_FLAGS_PUREX_IOCB     BIT_0
22978c2ecf20Sopenharmony_ci			__le16	srr_rx_id;
22988c2ecf20Sopenharmony_ci			__le16	status;
22998c2ecf20Sopenharmony_ci			uint8_t  status_subcode;
23008c2ecf20Sopenharmony_ci			uint8_t  fw_handle;
23018c2ecf20Sopenharmony_ci			__le32	exchange_address;
23028c2ecf20Sopenharmony_ci			__le32	srr_rel_offs;
23038c2ecf20Sopenharmony_ci			__le16	srr_ui;
23048c2ecf20Sopenharmony_ci			__le16	srr_ox_id;
23058c2ecf20Sopenharmony_ci			union {
23068c2ecf20Sopenharmony_ci				struct {
23078c2ecf20Sopenharmony_ci					uint8_t node_name[8];
23088c2ecf20Sopenharmony_ci				} plogi; /* PLOGI/ADISC/PDISC */
23098c2ecf20Sopenharmony_ci				struct {
23108c2ecf20Sopenharmony_ci					/* PRLI word 3 bit 0-15 */
23118c2ecf20Sopenharmony_ci					__le16	wd3_lo;
23128c2ecf20Sopenharmony_ci					uint8_t resv0[6];
23138c2ecf20Sopenharmony_ci				} prli;
23148c2ecf20Sopenharmony_ci				struct {
23158c2ecf20Sopenharmony_ci					uint8_t port_id[3];
23168c2ecf20Sopenharmony_ci					uint8_t resv1;
23178c2ecf20Sopenharmony_ci					__le16	nport_handle;
23188c2ecf20Sopenharmony_ci					uint16_t resv2;
23198c2ecf20Sopenharmony_ci				} req_els;
23208c2ecf20Sopenharmony_ci			} u;
23218c2ecf20Sopenharmony_ci			uint8_t port_name[8];
23228c2ecf20Sopenharmony_ci			uint8_t resv3[3];
23238c2ecf20Sopenharmony_ci			uint8_t  vp_index;
23248c2ecf20Sopenharmony_ci			uint32_t reserved_5;
23258c2ecf20Sopenharmony_ci			uint8_t  port_id[3];
23268c2ecf20Sopenharmony_ci			uint8_t  reserved_6;
23278c2ecf20Sopenharmony_ci		} isp24;
23288c2ecf20Sopenharmony_ci	} u;
23298c2ecf20Sopenharmony_ci	uint16_t reserved_7;
23308c2ecf20Sopenharmony_ci	__le16	ox_id;
23318c2ecf20Sopenharmony_ci} __packed;
23328c2ecf20Sopenharmony_ci#endif
23338c2ecf20Sopenharmony_ci
23348c2ecf20Sopenharmony_ci/*
23358c2ecf20Sopenharmony_ci * ISP request and response queue entry sizes
23368c2ecf20Sopenharmony_ci */
23378c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_SIZE	(sizeof(response_t))
23388c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_SIZE	(sizeof(request_t))
23398c2ecf20Sopenharmony_ci
23408c2ecf20Sopenharmony_ci
23418c2ecf20Sopenharmony_ci
23428c2ecf20Sopenharmony_ci/*
23438c2ecf20Sopenharmony_ci * Switch info gathering structure.
23448c2ecf20Sopenharmony_ci */
23458c2ecf20Sopenharmony_citypedef struct {
23468c2ecf20Sopenharmony_ci	port_id_t d_id;
23478c2ecf20Sopenharmony_ci	uint8_t node_name[WWN_SIZE];
23488c2ecf20Sopenharmony_ci	uint8_t port_name[WWN_SIZE];
23498c2ecf20Sopenharmony_ci	uint8_t fabric_port_name[WWN_SIZE];
23508c2ecf20Sopenharmony_ci	uint16_t fp_speed;
23518c2ecf20Sopenharmony_ci	uint8_t fc4_type;
23528c2ecf20Sopenharmony_ci	uint8_t fc4_features;
23538c2ecf20Sopenharmony_ci} sw_info_t;
23548c2ecf20Sopenharmony_ci
23558c2ecf20Sopenharmony_ci/* FCP-4 types */
23568c2ecf20Sopenharmony_ci#define FC4_TYPE_FCP_SCSI	0x08
23578c2ecf20Sopenharmony_ci#define FC4_TYPE_NVME		0x28
23588c2ecf20Sopenharmony_ci#define FC4_TYPE_OTHER		0x0
23598c2ecf20Sopenharmony_ci#define FC4_TYPE_UNKNOWN	0xff
23608c2ecf20Sopenharmony_ci
23618c2ecf20Sopenharmony_ci/* mailbox command 4G & above */
23628c2ecf20Sopenharmony_cistruct mbx_24xx_entry {
23638c2ecf20Sopenharmony_ci	uint8_t		entry_type;
23648c2ecf20Sopenharmony_ci	uint8_t		entry_count;
23658c2ecf20Sopenharmony_ci	uint8_t		sys_define1;
23668c2ecf20Sopenharmony_ci	uint8_t		entry_status;
23678c2ecf20Sopenharmony_ci	uint32_t	handle;
23688c2ecf20Sopenharmony_ci	uint16_t	mb[28];
23698c2ecf20Sopenharmony_ci};
23708c2ecf20Sopenharmony_ci
23718c2ecf20Sopenharmony_ci#define IOCB_SIZE 64
23728c2ecf20Sopenharmony_ci
23738c2ecf20Sopenharmony_ci/*
23748c2ecf20Sopenharmony_ci * Fibre channel port type.
23758c2ecf20Sopenharmony_ci */
23768c2ecf20Sopenharmony_citypedef enum {
23778c2ecf20Sopenharmony_ci	FCT_UNKNOWN,
23788c2ecf20Sopenharmony_ci	FCT_RSCN,
23798c2ecf20Sopenharmony_ci	FCT_SWITCH,
23808c2ecf20Sopenharmony_ci	FCT_BROADCAST,
23818c2ecf20Sopenharmony_ci	FCT_INITIATOR,
23828c2ecf20Sopenharmony_ci	FCT_TARGET,
23838c2ecf20Sopenharmony_ci	FCT_NVME_INITIATOR = 0x10,
23848c2ecf20Sopenharmony_ci	FCT_NVME_TARGET = 0x20,
23858c2ecf20Sopenharmony_ci	FCT_NVME_DISCOVERY = 0x40,
23868c2ecf20Sopenharmony_ci	FCT_NVME = 0xf0,
23878c2ecf20Sopenharmony_ci} fc_port_type_t;
23888c2ecf20Sopenharmony_ci
23898c2ecf20Sopenharmony_cienum qla_sess_deletion {
23908c2ecf20Sopenharmony_ci	QLA_SESS_DELETION_NONE		= 0,
23918c2ecf20Sopenharmony_ci	QLA_SESS_DELETION_IN_PROGRESS,
23928c2ecf20Sopenharmony_ci	QLA_SESS_DELETED,
23938c2ecf20Sopenharmony_ci};
23948c2ecf20Sopenharmony_ci
23958c2ecf20Sopenharmony_cienum qlt_plogi_link_t {
23968c2ecf20Sopenharmony_ci	QLT_PLOGI_LINK_SAME_WWN,
23978c2ecf20Sopenharmony_ci	QLT_PLOGI_LINK_CONFLICT,
23988c2ecf20Sopenharmony_ci	QLT_PLOGI_LINK_MAX
23998c2ecf20Sopenharmony_ci};
24008c2ecf20Sopenharmony_ci
24018c2ecf20Sopenharmony_cistruct qlt_plogi_ack_t {
24028c2ecf20Sopenharmony_ci	struct list_head	list;
24038c2ecf20Sopenharmony_ci	struct imm_ntfy_from_isp iocb;
24048c2ecf20Sopenharmony_ci	port_id_t	id;
24058c2ecf20Sopenharmony_ci	int		ref_count;
24068c2ecf20Sopenharmony_ci	void		*fcport;
24078c2ecf20Sopenharmony_ci};
24088c2ecf20Sopenharmony_ci
24098c2ecf20Sopenharmony_cistruct ct_sns_desc {
24108c2ecf20Sopenharmony_ci	struct ct_sns_pkt	*ct_sns;
24118c2ecf20Sopenharmony_ci	dma_addr_t		ct_sns_dma;
24128c2ecf20Sopenharmony_ci};
24138c2ecf20Sopenharmony_ci
24148c2ecf20Sopenharmony_cienum discovery_state {
24158c2ecf20Sopenharmony_ci	DSC_DELETED,
24168c2ecf20Sopenharmony_ci	DSC_GNN_ID,
24178c2ecf20Sopenharmony_ci	DSC_GNL,
24188c2ecf20Sopenharmony_ci	DSC_LOGIN_PEND,
24198c2ecf20Sopenharmony_ci	DSC_LOGIN_FAILED,
24208c2ecf20Sopenharmony_ci	DSC_GPDB,
24218c2ecf20Sopenharmony_ci	DSC_UPD_FCPORT,
24228c2ecf20Sopenharmony_ci	DSC_LOGIN_COMPLETE,
24238c2ecf20Sopenharmony_ci	DSC_ADISC,
24248c2ecf20Sopenharmony_ci	DSC_DELETE_PEND,
24258c2ecf20Sopenharmony_ci};
24268c2ecf20Sopenharmony_ci
24278c2ecf20Sopenharmony_cienum login_state {	/* FW control Target side */
24288c2ecf20Sopenharmony_ci	DSC_LS_LLIOCB_SENT = 2,
24298c2ecf20Sopenharmony_ci	DSC_LS_PLOGI_PEND,
24308c2ecf20Sopenharmony_ci	DSC_LS_PLOGI_COMP,
24318c2ecf20Sopenharmony_ci	DSC_LS_PRLI_PEND,
24328c2ecf20Sopenharmony_ci	DSC_LS_PRLI_COMP,
24338c2ecf20Sopenharmony_ci	DSC_LS_PORT_UNAVAIL,
24348c2ecf20Sopenharmony_ci	DSC_LS_PRLO_PEND = 9,
24358c2ecf20Sopenharmony_ci	DSC_LS_LOGO_PEND,
24368c2ecf20Sopenharmony_ci};
24378c2ecf20Sopenharmony_ci
24388c2ecf20Sopenharmony_cienum rscn_addr_format {
24398c2ecf20Sopenharmony_ci	RSCN_PORT_ADDR,
24408c2ecf20Sopenharmony_ci	RSCN_AREA_ADDR,
24418c2ecf20Sopenharmony_ci	RSCN_DOM_ADDR,
24428c2ecf20Sopenharmony_ci	RSCN_FAB_ADDR,
24438c2ecf20Sopenharmony_ci};
24448c2ecf20Sopenharmony_ci
24458c2ecf20Sopenharmony_ci/*
24468c2ecf20Sopenharmony_ci * Fibre channel port structure.
24478c2ecf20Sopenharmony_ci */
24488c2ecf20Sopenharmony_citypedef struct fc_port {
24498c2ecf20Sopenharmony_ci	struct list_head list;
24508c2ecf20Sopenharmony_ci	struct scsi_qla_host *vha;
24518c2ecf20Sopenharmony_ci
24528c2ecf20Sopenharmony_ci	unsigned int conf_compl_supported:1;
24538c2ecf20Sopenharmony_ci	unsigned int deleted:2;
24548c2ecf20Sopenharmony_ci	unsigned int free_pending:1;
24558c2ecf20Sopenharmony_ci	unsigned int local:1;
24568c2ecf20Sopenharmony_ci	unsigned int logout_on_delete:1;
24578c2ecf20Sopenharmony_ci	unsigned int logo_ack_needed:1;
24588c2ecf20Sopenharmony_ci	unsigned int keep_nport_handle:1;
24598c2ecf20Sopenharmony_ci	unsigned int send_els_logo:1;
24608c2ecf20Sopenharmony_ci	unsigned int login_pause:1;
24618c2ecf20Sopenharmony_ci	unsigned int login_succ:1;
24628c2ecf20Sopenharmony_ci	unsigned int query:1;
24638c2ecf20Sopenharmony_ci	unsigned int id_changed:1;
24648c2ecf20Sopenharmony_ci	unsigned int scan_needed:1;
24658c2ecf20Sopenharmony_ci	unsigned int n2n_flag:1;
24668c2ecf20Sopenharmony_ci	unsigned int explicit_logout:1;
24678c2ecf20Sopenharmony_ci	unsigned int prli_pend_timer:1;
24688c2ecf20Sopenharmony_ci	uint8_t nvme_flag;
24698c2ecf20Sopenharmony_ci
24708c2ecf20Sopenharmony_ci	uint8_t node_name[WWN_SIZE];
24718c2ecf20Sopenharmony_ci	uint8_t port_name[WWN_SIZE];
24728c2ecf20Sopenharmony_ci	port_id_t d_id;
24738c2ecf20Sopenharmony_ci	uint16_t loop_id;
24748c2ecf20Sopenharmony_ci	uint16_t old_loop_id;
24758c2ecf20Sopenharmony_ci
24768c2ecf20Sopenharmony_ci	struct completion nvme_del_done;
24778c2ecf20Sopenharmony_ci	uint32_t nvme_prli_service_param;
24788c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_PI_CTRL	BIT_9
24798c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_SLER	BIT_8
24808c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_CONF       BIT_7
24818c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_INITIATOR  BIT_5
24828c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_TARGET     BIT_4
24838c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_DISCOVERY  BIT_3
24848c2ecf20Sopenharmony_ci#define NVME_PRLI_SP_FIRST_BURST	BIT_0
24858c2ecf20Sopenharmony_ci
24868c2ecf20Sopenharmony_ci	uint32_t nvme_first_burst_size;
24878c2ecf20Sopenharmony_ci#define NVME_FLAG_REGISTERED 4
24888c2ecf20Sopenharmony_ci#define NVME_FLAG_DELETING 2
24898c2ecf20Sopenharmony_ci#define NVME_FLAG_RESETTING 1
24908c2ecf20Sopenharmony_ci
24918c2ecf20Sopenharmony_ci	struct fc_port *conflict;
24928c2ecf20Sopenharmony_ci	unsigned char logout_completed;
24938c2ecf20Sopenharmony_ci	int generation;
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	struct se_session *se_sess;
24968c2ecf20Sopenharmony_ci	struct kref sess_kref;
24978c2ecf20Sopenharmony_ci	struct qla_tgt *tgt;
24988c2ecf20Sopenharmony_ci	unsigned long expires;
24998c2ecf20Sopenharmony_ci	struct list_head del_list_entry;
25008c2ecf20Sopenharmony_ci	struct work_struct free_work;
25018c2ecf20Sopenharmony_ci	struct work_struct reg_work;
25028c2ecf20Sopenharmony_ci	uint64_t jiffies_at_registration;
25038c2ecf20Sopenharmony_ci	unsigned long prli_expired;
25048c2ecf20Sopenharmony_ci	struct qlt_plogi_ack_t *plogi_link[QLT_PLOGI_LINK_MAX];
25058c2ecf20Sopenharmony_ci
25068c2ecf20Sopenharmony_ci	uint16_t tgt_id;
25078c2ecf20Sopenharmony_ci	uint16_t old_tgt_id;
25088c2ecf20Sopenharmony_ci	uint16_t sec_since_registration;
25098c2ecf20Sopenharmony_ci
25108c2ecf20Sopenharmony_ci	uint8_t fcp_prio;
25118c2ecf20Sopenharmony_ci
25128c2ecf20Sopenharmony_ci	uint8_t fabric_port_name[WWN_SIZE];
25138c2ecf20Sopenharmony_ci	uint16_t fp_speed;
25148c2ecf20Sopenharmony_ci
25158c2ecf20Sopenharmony_ci	fc_port_type_t port_type;
25168c2ecf20Sopenharmony_ci
25178c2ecf20Sopenharmony_ci	atomic_t state;
25188c2ecf20Sopenharmony_ci	uint32_t flags;
25198c2ecf20Sopenharmony_ci
25208c2ecf20Sopenharmony_ci	int login_retry;
25218c2ecf20Sopenharmony_ci
25228c2ecf20Sopenharmony_ci	struct fc_rport *rport, *drport;
25238c2ecf20Sopenharmony_ci	u32 supported_classes;
25248c2ecf20Sopenharmony_ci
25258c2ecf20Sopenharmony_ci	uint8_t fc4_type;
25268c2ecf20Sopenharmony_ci	uint8_t fc4_features;
25278c2ecf20Sopenharmony_ci	uint8_t scan_state;
25288c2ecf20Sopenharmony_ci
25298c2ecf20Sopenharmony_ci	unsigned long last_queue_full;
25308c2ecf20Sopenharmony_ci	unsigned long last_ramp_up;
25318c2ecf20Sopenharmony_ci
25328c2ecf20Sopenharmony_ci	uint16_t port_id;
25338c2ecf20Sopenharmony_ci
25348c2ecf20Sopenharmony_ci	struct nvme_fc_remote_port *nvme_remote_port;
25358c2ecf20Sopenharmony_ci
25368c2ecf20Sopenharmony_ci	unsigned long retry_delay_timestamp;
25378c2ecf20Sopenharmony_ci	struct qla_tgt_sess *tgt_session;
25388c2ecf20Sopenharmony_ci	struct ct_sns_desc ct_desc;
25398c2ecf20Sopenharmony_ci	enum discovery_state disc_state;
25408c2ecf20Sopenharmony_ci	atomic_t shadow_disc_state;
25418c2ecf20Sopenharmony_ci	enum discovery_state next_disc_state;
25428c2ecf20Sopenharmony_ci	enum login_state fw_login_state;
25438c2ecf20Sopenharmony_ci	unsigned long dm_login_expire;
25448c2ecf20Sopenharmony_ci	unsigned long plogi_nack_done_deadline;
25458c2ecf20Sopenharmony_ci
25468c2ecf20Sopenharmony_ci	u32 login_gen, last_login_gen;
25478c2ecf20Sopenharmony_ci	u32 rscn_gen, last_rscn_gen;
25488c2ecf20Sopenharmony_ci	u32 chip_reset;
25498c2ecf20Sopenharmony_ci	struct list_head gnl_entry;
25508c2ecf20Sopenharmony_ci	struct work_struct del_work;
25518c2ecf20Sopenharmony_ci	u8 iocb[IOCB_SIZE];
25528c2ecf20Sopenharmony_ci	u8 current_login_state;
25538c2ecf20Sopenharmony_ci	u8 last_login_state;
25548c2ecf20Sopenharmony_ci	u16 n2n_link_reset_cnt;
25558c2ecf20Sopenharmony_ci	u16 n2n_chip_reset;
25568c2ecf20Sopenharmony_ci
25578c2ecf20Sopenharmony_ci	struct dentry *dfs_rport_dir;
25588c2ecf20Sopenharmony_ci} fc_port_t;
25598c2ecf20Sopenharmony_ci
25608c2ecf20Sopenharmony_cienum {
25618c2ecf20Sopenharmony_ci	FC4_PRIORITY_NVME = 1,
25628c2ecf20Sopenharmony_ci	FC4_PRIORITY_FCP  = 2,
25638c2ecf20Sopenharmony_ci};
25648c2ecf20Sopenharmony_ci
25658c2ecf20Sopenharmony_ci#define QLA_FCPORT_SCAN		1
25668c2ecf20Sopenharmony_ci#define QLA_FCPORT_FOUND	2
25678c2ecf20Sopenharmony_ci
25688c2ecf20Sopenharmony_cistruct event_arg {
25698c2ecf20Sopenharmony_ci	fc_port_t		*fcport;
25708c2ecf20Sopenharmony_ci	srb_t			*sp;
25718c2ecf20Sopenharmony_ci	port_id_t		id;
25728c2ecf20Sopenharmony_ci	u16			data[2], rc;
25738c2ecf20Sopenharmony_ci	u8			port_name[WWN_SIZE];
25748c2ecf20Sopenharmony_ci	u32			iop[2];
25758c2ecf20Sopenharmony_ci};
25768c2ecf20Sopenharmony_ci
25778c2ecf20Sopenharmony_ci#include "qla_mr.h"
25788c2ecf20Sopenharmony_ci
25798c2ecf20Sopenharmony_ci/*
25808c2ecf20Sopenharmony_ci * Fibre channel port/lun states.
25818c2ecf20Sopenharmony_ci */
25828c2ecf20Sopenharmony_ci#define FCS_UNCONFIGURED	1
25838c2ecf20Sopenharmony_ci#define FCS_DEVICE_DEAD		2
25848c2ecf20Sopenharmony_ci#define FCS_DEVICE_LOST		3
25858c2ecf20Sopenharmony_ci#define FCS_ONLINE		4
25868c2ecf20Sopenharmony_ci
25878c2ecf20Sopenharmony_ciextern const char *const port_state_str[5];
25888c2ecf20Sopenharmony_ci
25898c2ecf20Sopenharmony_cistatic const char * const port_dstate_str[] = {
25908c2ecf20Sopenharmony_ci	"DELETED",
25918c2ecf20Sopenharmony_ci	"GNN_ID",
25928c2ecf20Sopenharmony_ci	"GNL",
25938c2ecf20Sopenharmony_ci	"LOGIN_PEND",
25948c2ecf20Sopenharmony_ci	"LOGIN_FAILED",
25958c2ecf20Sopenharmony_ci	"GPDB",
25968c2ecf20Sopenharmony_ci	"UPD_FCPORT",
25978c2ecf20Sopenharmony_ci	"LOGIN_COMPLETE",
25988c2ecf20Sopenharmony_ci	"ADISC",
25998c2ecf20Sopenharmony_ci	"DELETE_PEND"
26008c2ecf20Sopenharmony_ci};
26018c2ecf20Sopenharmony_ci
26028c2ecf20Sopenharmony_ci/*
26038c2ecf20Sopenharmony_ci * FC port flags.
26048c2ecf20Sopenharmony_ci */
26058c2ecf20Sopenharmony_ci#define FCF_FABRIC_DEVICE	BIT_0
26068c2ecf20Sopenharmony_ci#define FCF_LOGIN_NEEDED	BIT_1
26078c2ecf20Sopenharmony_ci#define FCF_FCP2_DEVICE		BIT_2
26088c2ecf20Sopenharmony_ci#define FCF_ASYNC_SENT		BIT_3
26098c2ecf20Sopenharmony_ci#define FCF_CONF_COMP_SUPPORTED BIT_4
26108c2ecf20Sopenharmony_ci#define FCF_ASYNC_ACTIVE	BIT_5
26118c2ecf20Sopenharmony_ci
26128c2ecf20Sopenharmony_ci/* No loop ID flag. */
26138c2ecf20Sopenharmony_ci#define FC_NO_LOOP_ID		0x1000
26148c2ecf20Sopenharmony_ci
26158c2ecf20Sopenharmony_ci/*
26168c2ecf20Sopenharmony_ci * FC-CT interface
26178c2ecf20Sopenharmony_ci *
26188c2ecf20Sopenharmony_ci * NOTE: All structures are big-endian in form.
26198c2ecf20Sopenharmony_ci */
26208c2ecf20Sopenharmony_ci
26218c2ecf20Sopenharmony_ci#define CT_REJECT_RESPONSE	0x8001
26228c2ecf20Sopenharmony_ci#define CT_ACCEPT_RESPONSE	0x8002
26238c2ecf20Sopenharmony_ci#define CT_REASON_INVALID_COMMAND_CODE		0x01
26248c2ecf20Sopenharmony_ci#define CT_REASON_CANNOT_PERFORM		0x09
26258c2ecf20Sopenharmony_ci#define CT_REASON_COMMAND_UNSUPPORTED		0x0b
26268c2ecf20Sopenharmony_ci#define CT_EXPL_ALREADY_REGISTERED		0x10
26278c2ecf20Sopenharmony_ci#define CT_EXPL_HBA_ATTR_NOT_REGISTERED		0x11
26288c2ecf20Sopenharmony_ci#define CT_EXPL_MULTIPLE_HBA_ATTR		0x12
26298c2ecf20Sopenharmony_ci#define CT_EXPL_INVALID_HBA_BLOCK_LENGTH	0x13
26308c2ecf20Sopenharmony_ci#define CT_EXPL_MISSING_REQ_HBA_ATTR		0x14
26318c2ecf20Sopenharmony_ci#define CT_EXPL_PORT_NOT_REGISTERED_		0x15
26328c2ecf20Sopenharmony_ci#define CT_EXPL_MISSING_HBA_ID_PORT_LIST	0x16
26338c2ecf20Sopenharmony_ci#define CT_EXPL_HBA_NOT_REGISTERED		0x17
26348c2ecf20Sopenharmony_ci#define CT_EXPL_PORT_ATTR_NOT_REGISTERED	0x20
26358c2ecf20Sopenharmony_ci#define CT_EXPL_PORT_NOT_REGISTERED		0x21
26368c2ecf20Sopenharmony_ci#define CT_EXPL_MULTIPLE_PORT_ATTR		0x22
26378c2ecf20Sopenharmony_ci#define CT_EXPL_INVALID_PORT_BLOCK_LENGTH	0x23
26388c2ecf20Sopenharmony_ci
26398c2ecf20Sopenharmony_ci#define NS_N_PORT_TYPE	0x01
26408c2ecf20Sopenharmony_ci#define NS_NL_PORT_TYPE	0x02
26418c2ecf20Sopenharmony_ci#define NS_NX_PORT_TYPE	0x7F
26428c2ecf20Sopenharmony_ci
26438c2ecf20Sopenharmony_ci#define	GA_NXT_CMD	0x100
26448c2ecf20Sopenharmony_ci#define	GA_NXT_REQ_SIZE	(16 + 4)
26458c2ecf20Sopenharmony_ci#define	GA_NXT_RSP_SIZE	(16 + 620)
26468c2ecf20Sopenharmony_ci
26478c2ecf20Sopenharmony_ci#define	GPN_FT_CMD	0x172
26488c2ecf20Sopenharmony_ci#define	GPN_FT_REQ_SIZE	(16 + 4)
26498c2ecf20Sopenharmony_ci#define	GNN_FT_CMD	0x173
26508c2ecf20Sopenharmony_ci#define	GNN_FT_REQ_SIZE	(16 + 4)
26518c2ecf20Sopenharmony_ci
26528c2ecf20Sopenharmony_ci#define	GID_PT_CMD	0x1A1
26538c2ecf20Sopenharmony_ci#define	GID_PT_REQ_SIZE	(16 + 4)
26548c2ecf20Sopenharmony_ci
26558c2ecf20Sopenharmony_ci#define	GPN_ID_CMD	0x112
26568c2ecf20Sopenharmony_ci#define	GPN_ID_REQ_SIZE	(16 + 4)
26578c2ecf20Sopenharmony_ci#define	GPN_ID_RSP_SIZE	(16 + 8)
26588c2ecf20Sopenharmony_ci
26598c2ecf20Sopenharmony_ci#define	GNN_ID_CMD	0x113
26608c2ecf20Sopenharmony_ci#define	GNN_ID_REQ_SIZE	(16 + 4)
26618c2ecf20Sopenharmony_ci#define	GNN_ID_RSP_SIZE	(16 + 8)
26628c2ecf20Sopenharmony_ci
26638c2ecf20Sopenharmony_ci#define	GFT_ID_CMD	0x117
26648c2ecf20Sopenharmony_ci#define	GFT_ID_REQ_SIZE	(16 + 4)
26658c2ecf20Sopenharmony_ci#define	GFT_ID_RSP_SIZE	(16 + 32)
26668c2ecf20Sopenharmony_ci
26678c2ecf20Sopenharmony_ci#define GID_PN_CMD 0x121
26688c2ecf20Sopenharmony_ci#define GID_PN_REQ_SIZE (16 + 8)
26698c2ecf20Sopenharmony_ci#define GID_PN_RSP_SIZE (16 + 4)
26708c2ecf20Sopenharmony_ci
26718c2ecf20Sopenharmony_ci#define	RFT_ID_CMD	0x217
26728c2ecf20Sopenharmony_ci#define	RFT_ID_REQ_SIZE	(16 + 4 + 32)
26738c2ecf20Sopenharmony_ci#define	RFT_ID_RSP_SIZE	16
26748c2ecf20Sopenharmony_ci
26758c2ecf20Sopenharmony_ci#define	RFF_ID_CMD	0x21F
26768c2ecf20Sopenharmony_ci#define	RFF_ID_REQ_SIZE	(16 + 4 + 2 + 1 + 1)
26778c2ecf20Sopenharmony_ci#define	RFF_ID_RSP_SIZE	16
26788c2ecf20Sopenharmony_ci
26798c2ecf20Sopenharmony_ci#define	RNN_ID_CMD	0x213
26808c2ecf20Sopenharmony_ci#define	RNN_ID_REQ_SIZE	(16 + 4 + 8)
26818c2ecf20Sopenharmony_ci#define	RNN_ID_RSP_SIZE	16
26828c2ecf20Sopenharmony_ci
26838c2ecf20Sopenharmony_ci#define	RSNN_NN_CMD	 0x239
26848c2ecf20Sopenharmony_ci#define	RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
26858c2ecf20Sopenharmony_ci#define	RSNN_NN_RSP_SIZE 16
26868c2ecf20Sopenharmony_ci
26878c2ecf20Sopenharmony_ci#define	GFPN_ID_CMD	0x11C
26888c2ecf20Sopenharmony_ci#define	GFPN_ID_REQ_SIZE (16 + 4)
26898c2ecf20Sopenharmony_ci#define	GFPN_ID_RSP_SIZE (16 + 8)
26908c2ecf20Sopenharmony_ci
26918c2ecf20Sopenharmony_ci#define	GPSC_CMD	0x127
26928c2ecf20Sopenharmony_ci#define	GPSC_REQ_SIZE	(16 + 8)
26938c2ecf20Sopenharmony_ci#define	GPSC_RSP_SIZE	(16 + 2 + 2)
26948c2ecf20Sopenharmony_ci
26958c2ecf20Sopenharmony_ci#define GFF_ID_CMD	0x011F
26968c2ecf20Sopenharmony_ci#define GFF_ID_REQ_SIZE	(16 + 4)
26978c2ecf20Sopenharmony_ci#define GFF_ID_RSP_SIZE (16 + 128)
26988c2ecf20Sopenharmony_ci
26998c2ecf20Sopenharmony_ci/*
27008c2ecf20Sopenharmony_ci * FDMI HBA attribute types.
27018c2ecf20Sopenharmony_ci */
27028c2ecf20Sopenharmony_ci#define FDMI1_HBA_ATTR_COUNT			9
27038c2ecf20Sopenharmony_ci#define FDMI2_HBA_ATTR_COUNT			17
27048c2ecf20Sopenharmony_ci
27058c2ecf20Sopenharmony_ci#define FDMI_HBA_NODE_NAME			0x1
27068c2ecf20Sopenharmony_ci#define FDMI_HBA_MANUFACTURER			0x2
27078c2ecf20Sopenharmony_ci#define FDMI_HBA_SERIAL_NUMBER			0x3
27088c2ecf20Sopenharmony_ci#define FDMI_HBA_MODEL				0x4
27098c2ecf20Sopenharmony_ci#define FDMI_HBA_MODEL_DESCRIPTION		0x5
27108c2ecf20Sopenharmony_ci#define FDMI_HBA_HARDWARE_VERSION		0x6
27118c2ecf20Sopenharmony_ci#define FDMI_HBA_DRIVER_VERSION			0x7
27128c2ecf20Sopenharmony_ci#define FDMI_HBA_OPTION_ROM_VERSION		0x8
27138c2ecf20Sopenharmony_ci#define FDMI_HBA_FIRMWARE_VERSION		0x9
27148c2ecf20Sopenharmony_ci#define FDMI_HBA_OS_NAME_AND_VERSION		0xa
27158c2ecf20Sopenharmony_ci#define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH	0xb
27168c2ecf20Sopenharmony_ci
27178c2ecf20Sopenharmony_ci#define FDMI_HBA_NODE_SYMBOLIC_NAME		0xc
27188c2ecf20Sopenharmony_ci#define FDMI_HBA_VENDOR_SPECIFIC_INFO		0xd
27198c2ecf20Sopenharmony_ci#define FDMI_HBA_NUM_PORTS			0xe
27208c2ecf20Sopenharmony_ci#define FDMI_HBA_FABRIC_NAME			0xf
27218c2ecf20Sopenharmony_ci#define FDMI_HBA_BOOT_BIOS_NAME			0x10
27228c2ecf20Sopenharmony_ci#define FDMI_HBA_VENDOR_IDENTIFIER		0xe0
27238c2ecf20Sopenharmony_ci
27248c2ecf20Sopenharmony_cistruct ct_fdmi_hba_attr {
27258c2ecf20Sopenharmony_ci	__be16	type;
27268c2ecf20Sopenharmony_ci	__be16	len;
27278c2ecf20Sopenharmony_ci	union {
27288c2ecf20Sopenharmony_ci		uint8_t node_name[WWN_SIZE];
27298c2ecf20Sopenharmony_ci		uint8_t manufacturer[64];
27308c2ecf20Sopenharmony_ci		uint8_t serial_num[32];
27318c2ecf20Sopenharmony_ci		uint8_t model[16+1];
27328c2ecf20Sopenharmony_ci		uint8_t model_desc[80];
27338c2ecf20Sopenharmony_ci		uint8_t hw_version[32];
27348c2ecf20Sopenharmony_ci		uint8_t driver_version[32];
27358c2ecf20Sopenharmony_ci		uint8_t orom_version[16];
27368c2ecf20Sopenharmony_ci		uint8_t fw_version[32];
27378c2ecf20Sopenharmony_ci		uint8_t os_version[128];
27388c2ecf20Sopenharmony_ci		__be32	 max_ct_len;
27398c2ecf20Sopenharmony_ci
27408c2ecf20Sopenharmony_ci		uint8_t sym_name[256];
27418c2ecf20Sopenharmony_ci		__be32	 vendor_specific_info;
27428c2ecf20Sopenharmony_ci		__be32	 num_ports;
27438c2ecf20Sopenharmony_ci		uint8_t fabric_name[WWN_SIZE];
27448c2ecf20Sopenharmony_ci		uint8_t bios_name[32];
27458c2ecf20Sopenharmony_ci		uint8_t vendor_identifier[8];
27468c2ecf20Sopenharmony_ci	} a;
27478c2ecf20Sopenharmony_ci};
27488c2ecf20Sopenharmony_ci
27498c2ecf20Sopenharmony_cistruct ct_fdmi1_hba_attributes {
27508c2ecf20Sopenharmony_ci	__be32	count;
27518c2ecf20Sopenharmony_ci	struct ct_fdmi_hba_attr entry[FDMI1_HBA_ATTR_COUNT];
27528c2ecf20Sopenharmony_ci};
27538c2ecf20Sopenharmony_ci
27548c2ecf20Sopenharmony_cistruct ct_fdmi2_hba_attributes {
27558c2ecf20Sopenharmony_ci	__be32	count;
27568c2ecf20Sopenharmony_ci	struct ct_fdmi_hba_attr entry[FDMI2_HBA_ATTR_COUNT];
27578c2ecf20Sopenharmony_ci};
27588c2ecf20Sopenharmony_ci
27598c2ecf20Sopenharmony_ci/*
27608c2ecf20Sopenharmony_ci * FDMI Port attribute types.
27618c2ecf20Sopenharmony_ci */
27628c2ecf20Sopenharmony_ci#define FDMI1_PORT_ATTR_COUNT		6
27638c2ecf20Sopenharmony_ci#define FDMI2_PORT_ATTR_COUNT		16
27648c2ecf20Sopenharmony_ci#define FDMI2_SMARTSAN_PORT_ATTR_COUNT	23
27658c2ecf20Sopenharmony_ci
27668c2ecf20Sopenharmony_ci#define FDMI_PORT_FC4_TYPES		0x1
27678c2ecf20Sopenharmony_ci#define FDMI_PORT_SUPPORT_SPEED		0x2
27688c2ecf20Sopenharmony_ci#define FDMI_PORT_CURRENT_SPEED		0x3
27698c2ecf20Sopenharmony_ci#define FDMI_PORT_MAX_FRAME_SIZE	0x4
27708c2ecf20Sopenharmony_ci#define FDMI_PORT_OS_DEVICE_NAME	0x5
27718c2ecf20Sopenharmony_ci#define FDMI_PORT_HOST_NAME		0x6
27728c2ecf20Sopenharmony_ci
27738c2ecf20Sopenharmony_ci#define FDMI_PORT_NODE_NAME		0x7
27748c2ecf20Sopenharmony_ci#define FDMI_PORT_NAME			0x8
27758c2ecf20Sopenharmony_ci#define FDMI_PORT_SYM_NAME		0x9
27768c2ecf20Sopenharmony_ci#define FDMI_PORT_TYPE			0xa
27778c2ecf20Sopenharmony_ci#define FDMI_PORT_SUPP_COS		0xb
27788c2ecf20Sopenharmony_ci#define FDMI_PORT_FABRIC_NAME		0xc
27798c2ecf20Sopenharmony_ci#define FDMI_PORT_FC4_TYPE		0xd
27808c2ecf20Sopenharmony_ci#define FDMI_PORT_STATE			0x101
27818c2ecf20Sopenharmony_ci#define FDMI_PORT_COUNT			0x102
27828c2ecf20Sopenharmony_ci#define FDMI_PORT_IDENTIFIER		0x103
27838c2ecf20Sopenharmony_ci
27848c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_SERVICE		0xF100
27858c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_GUID		0xF101
27868c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_VERSION		0xF102
27878c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_PROD_NAME		0xF103
27888c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_PORT_INFO		0xF104
27898c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_QOS_SUPPORT	0xF105
27908c2ecf20Sopenharmony_ci#define FDMI_SMARTSAN_SECURITY_SUPPORT	0xF106
27918c2ecf20Sopenharmony_ci
27928c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_1GB		0x1
27938c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_2GB		0x2
27948c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_10GB		0x4
27958c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_4GB		0x8
27968c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_8GB		0x10
27978c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_16GB		0x20
27988c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_32GB		0x40
27998c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_20GB		0x80
28008c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_40GB		0x100
28018c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_128GB		0x200
28028c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_64GB		0x400
28038c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_256GB		0x800
28048c2ecf20Sopenharmony_ci#define FDMI_PORT_SPEED_UNKNOWN		0x8000
28058c2ecf20Sopenharmony_ci
28068c2ecf20Sopenharmony_ci#define FC_CLASS_2	0x04
28078c2ecf20Sopenharmony_ci#define FC_CLASS_3	0x08
28088c2ecf20Sopenharmony_ci#define FC_CLASS_2_3	0x0C
28098c2ecf20Sopenharmony_ci
28108c2ecf20Sopenharmony_cistruct ct_fdmi_port_attr {
28118c2ecf20Sopenharmony_ci	__be16	type;
28128c2ecf20Sopenharmony_ci	__be16	len;
28138c2ecf20Sopenharmony_ci	union {
28148c2ecf20Sopenharmony_ci		uint8_t fc4_types[32];
28158c2ecf20Sopenharmony_ci		__be32	sup_speed;
28168c2ecf20Sopenharmony_ci		__be32	cur_speed;
28178c2ecf20Sopenharmony_ci		__be32	max_frame_size;
28188c2ecf20Sopenharmony_ci		uint8_t os_dev_name[32];
28198c2ecf20Sopenharmony_ci		uint8_t host_name[256];
28208c2ecf20Sopenharmony_ci
28218c2ecf20Sopenharmony_ci		uint8_t node_name[WWN_SIZE];
28228c2ecf20Sopenharmony_ci		uint8_t port_name[WWN_SIZE];
28238c2ecf20Sopenharmony_ci		uint8_t port_sym_name[128];
28248c2ecf20Sopenharmony_ci		__be32	port_type;
28258c2ecf20Sopenharmony_ci		__be32	port_supported_cos;
28268c2ecf20Sopenharmony_ci		uint8_t fabric_name[WWN_SIZE];
28278c2ecf20Sopenharmony_ci		uint8_t port_fc4_type[32];
28288c2ecf20Sopenharmony_ci		__be32	 port_state;
28298c2ecf20Sopenharmony_ci		__be32	 num_ports;
28308c2ecf20Sopenharmony_ci		__be32	 port_id;
28318c2ecf20Sopenharmony_ci
28328c2ecf20Sopenharmony_ci		uint8_t smartsan_service[24];
28338c2ecf20Sopenharmony_ci		uint8_t smartsan_guid[16];
28348c2ecf20Sopenharmony_ci		uint8_t smartsan_version[24];
28358c2ecf20Sopenharmony_ci		uint8_t smartsan_prod_name[16];
28368c2ecf20Sopenharmony_ci		__be32	 smartsan_port_info;
28378c2ecf20Sopenharmony_ci		__be32	 smartsan_qos_support;
28388c2ecf20Sopenharmony_ci		__be32	 smartsan_security_support;
28398c2ecf20Sopenharmony_ci	} a;
28408c2ecf20Sopenharmony_ci};
28418c2ecf20Sopenharmony_ci
28428c2ecf20Sopenharmony_cistruct ct_fdmi1_port_attributes {
28438c2ecf20Sopenharmony_ci	__be32	 count;
28448c2ecf20Sopenharmony_ci	struct ct_fdmi_port_attr entry[FDMI1_PORT_ATTR_COUNT];
28458c2ecf20Sopenharmony_ci};
28468c2ecf20Sopenharmony_ci
28478c2ecf20Sopenharmony_cistruct ct_fdmi2_port_attributes {
28488c2ecf20Sopenharmony_ci	__be32	count;
28498c2ecf20Sopenharmony_ci	struct ct_fdmi_port_attr entry[FDMI2_PORT_ATTR_COUNT];
28508c2ecf20Sopenharmony_ci};
28518c2ecf20Sopenharmony_ci
28528c2ecf20Sopenharmony_ci#define FDMI_ATTR_TYPELEN(obj) \
28538c2ecf20Sopenharmony_ci	(sizeof((obj)->type) + sizeof((obj)->len))
28548c2ecf20Sopenharmony_ci
28558c2ecf20Sopenharmony_ci#define FDMI_ATTR_ALIGNMENT(len) \
28568c2ecf20Sopenharmony_ci	(4 - ((len) & 3))
28578c2ecf20Sopenharmony_ci
28588c2ecf20Sopenharmony_ci/* FDMI register call options */
28598c2ecf20Sopenharmony_ci#define CALLOPT_FDMI1		0
28608c2ecf20Sopenharmony_ci#define CALLOPT_FDMI2		1
28618c2ecf20Sopenharmony_ci#define CALLOPT_FDMI2_SMARTSAN	2
28628c2ecf20Sopenharmony_ci
28638c2ecf20Sopenharmony_ci/* FDMI definitions. */
28648c2ecf20Sopenharmony_ci#define GRHL_CMD	0x100
28658c2ecf20Sopenharmony_ci#define GHAT_CMD	0x101
28668c2ecf20Sopenharmony_ci#define GRPL_CMD	0x102
28678c2ecf20Sopenharmony_ci#define GPAT_CMD	0x110
28688c2ecf20Sopenharmony_ci
28698c2ecf20Sopenharmony_ci#define RHBA_CMD	0x200
28708c2ecf20Sopenharmony_ci#define RHBA_RSP_SIZE	16
28718c2ecf20Sopenharmony_ci
28728c2ecf20Sopenharmony_ci#define RHAT_CMD	0x201
28738c2ecf20Sopenharmony_ci
28748c2ecf20Sopenharmony_ci#define RPRT_CMD	0x210
28758c2ecf20Sopenharmony_ci#define RPRT_RSP_SIZE	24
28768c2ecf20Sopenharmony_ci
28778c2ecf20Sopenharmony_ci#define RPA_CMD		0x211
28788c2ecf20Sopenharmony_ci#define RPA_RSP_SIZE	16
28798c2ecf20Sopenharmony_ci#define SMARTSAN_RPA_RSP_SIZE	24
28808c2ecf20Sopenharmony_ci
28818c2ecf20Sopenharmony_ci#define DHBA_CMD	0x300
28828c2ecf20Sopenharmony_ci#define DHBA_REQ_SIZE	(16 + 8)
28838c2ecf20Sopenharmony_ci#define DHBA_RSP_SIZE	16
28848c2ecf20Sopenharmony_ci
28858c2ecf20Sopenharmony_ci#define DHAT_CMD	0x301
28868c2ecf20Sopenharmony_ci#define DPRT_CMD	0x310
28878c2ecf20Sopenharmony_ci#define DPA_CMD		0x311
28888c2ecf20Sopenharmony_ci
28898c2ecf20Sopenharmony_ci/* CT command header -- request/response common fields */
28908c2ecf20Sopenharmony_cistruct ct_cmd_hdr {
28918c2ecf20Sopenharmony_ci	uint8_t revision;
28928c2ecf20Sopenharmony_ci	uint8_t in_id[3];
28938c2ecf20Sopenharmony_ci	uint8_t gs_type;
28948c2ecf20Sopenharmony_ci	uint8_t gs_subtype;
28958c2ecf20Sopenharmony_ci	uint8_t options;
28968c2ecf20Sopenharmony_ci	uint8_t reserved;
28978c2ecf20Sopenharmony_ci};
28988c2ecf20Sopenharmony_ci
28998c2ecf20Sopenharmony_ci/* CT command request */
29008c2ecf20Sopenharmony_cistruct ct_sns_req {
29018c2ecf20Sopenharmony_ci	struct ct_cmd_hdr header;
29028c2ecf20Sopenharmony_ci	__be16	command;
29038c2ecf20Sopenharmony_ci	__be16	max_rsp_size;
29048c2ecf20Sopenharmony_ci	uint8_t fragment_id;
29058c2ecf20Sopenharmony_ci	uint8_t reserved[3];
29068c2ecf20Sopenharmony_ci
29078c2ecf20Sopenharmony_ci	union {
29088c2ecf20Sopenharmony_ci		/* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
29098c2ecf20Sopenharmony_ci		struct {
29108c2ecf20Sopenharmony_ci			uint8_t reserved;
29118c2ecf20Sopenharmony_ci			be_id_t port_id;
29128c2ecf20Sopenharmony_ci		} port_id;
29138c2ecf20Sopenharmony_ci
29148c2ecf20Sopenharmony_ci		struct {
29158c2ecf20Sopenharmony_ci			uint8_t reserved;
29168c2ecf20Sopenharmony_ci			uint8_t domain;
29178c2ecf20Sopenharmony_ci			uint8_t area;
29188c2ecf20Sopenharmony_ci			uint8_t port_type;
29198c2ecf20Sopenharmony_ci		} gpn_ft;
29208c2ecf20Sopenharmony_ci
29218c2ecf20Sopenharmony_ci		struct {
29228c2ecf20Sopenharmony_ci			uint8_t port_type;
29238c2ecf20Sopenharmony_ci			uint8_t domain;
29248c2ecf20Sopenharmony_ci			uint8_t area;
29258c2ecf20Sopenharmony_ci			uint8_t reserved;
29268c2ecf20Sopenharmony_ci		} gid_pt;
29278c2ecf20Sopenharmony_ci
29288c2ecf20Sopenharmony_ci		struct {
29298c2ecf20Sopenharmony_ci			uint8_t reserved;
29308c2ecf20Sopenharmony_ci			be_id_t port_id;
29318c2ecf20Sopenharmony_ci			uint8_t fc4_types[32];
29328c2ecf20Sopenharmony_ci		} rft_id;
29338c2ecf20Sopenharmony_ci
29348c2ecf20Sopenharmony_ci		struct {
29358c2ecf20Sopenharmony_ci			uint8_t reserved;
29368c2ecf20Sopenharmony_ci			be_id_t port_id;
29378c2ecf20Sopenharmony_ci			uint16_t reserved2;
29388c2ecf20Sopenharmony_ci			uint8_t fc4_feature;
29398c2ecf20Sopenharmony_ci			uint8_t fc4_type;
29408c2ecf20Sopenharmony_ci		} rff_id;
29418c2ecf20Sopenharmony_ci
29428c2ecf20Sopenharmony_ci		struct {
29438c2ecf20Sopenharmony_ci			uint8_t reserved;
29448c2ecf20Sopenharmony_ci			be_id_t port_id;
29458c2ecf20Sopenharmony_ci			uint8_t node_name[8];
29468c2ecf20Sopenharmony_ci		} rnn_id;
29478c2ecf20Sopenharmony_ci
29488c2ecf20Sopenharmony_ci		struct {
29498c2ecf20Sopenharmony_ci			uint8_t node_name[8];
29508c2ecf20Sopenharmony_ci			uint8_t name_len;
29518c2ecf20Sopenharmony_ci			uint8_t sym_node_name[255];
29528c2ecf20Sopenharmony_ci		} rsnn_nn;
29538c2ecf20Sopenharmony_ci
29548c2ecf20Sopenharmony_ci		struct {
29558c2ecf20Sopenharmony_ci			uint8_t hba_identifier[8];
29568c2ecf20Sopenharmony_ci		} ghat;
29578c2ecf20Sopenharmony_ci
29588c2ecf20Sopenharmony_ci		struct {
29598c2ecf20Sopenharmony_ci			uint8_t hba_identifier[8];
29608c2ecf20Sopenharmony_ci			__be32	entry_count;
29618c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29628c2ecf20Sopenharmony_ci			struct ct_fdmi2_hba_attributes attrs;
29638c2ecf20Sopenharmony_ci		} rhba;
29648c2ecf20Sopenharmony_ci
29658c2ecf20Sopenharmony_ci		struct {
29668c2ecf20Sopenharmony_ci			uint8_t hba_identifier[8];
29678c2ecf20Sopenharmony_ci			struct ct_fdmi1_hba_attributes attrs;
29688c2ecf20Sopenharmony_ci		} rhat;
29698c2ecf20Sopenharmony_ci
29708c2ecf20Sopenharmony_ci		struct {
29718c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29728c2ecf20Sopenharmony_ci			struct ct_fdmi2_port_attributes attrs;
29738c2ecf20Sopenharmony_ci		} rpa;
29748c2ecf20Sopenharmony_ci
29758c2ecf20Sopenharmony_ci		struct {
29768c2ecf20Sopenharmony_ci			uint8_t hba_identifier[8];
29778c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29788c2ecf20Sopenharmony_ci			struct ct_fdmi2_port_attributes attrs;
29798c2ecf20Sopenharmony_ci		} rprt;
29808c2ecf20Sopenharmony_ci
29818c2ecf20Sopenharmony_ci		struct {
29828c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29838c2ecf20Sopenharmony_ci		} dhba;
29848c2ecf20Sopenharmony_ci
29858c2ecf20Sopenharmony_ci		struct {
29868c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29878c2ecf20Sopenharmony_ci		} dhat;
29888c2ecf20Sopenharmony_ci
29898c2ecf20Sopenharmony_ci		struct {
29908c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29918c2ecf20Sopenharmony_ci		} dprt;
29928c2ecf20Sopenharmony_ci
29938c2ecf20Sopenharmony_ci		struct {
29948c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29958c2ecf20Sopenharmony_ci		} dpa;
29968c2ecf20Sopenharmony_ci
29978c2ecf20Sopenharmony_ci		struct {
29988c2ecf20Sopenharmony_ci			uint8_t port_name[8];
29998c2ecf20Sopenharmony_ci		} gpsc;
30008c2ecf20Sopenharmony_ci
30018c2ecf20Sopenharmony_ci		struct {
30028c2ecf20Sopenharmony_ci			uint8_t reserved;
30038c2ecf20Sopenharmony_ci			uint8_t port_id[3];
30048c2ecf20Sopenharmony_ci		} gff_id;
30058c2ecf20Sopenharmony_ci
30068c2ecf20Sopenharmony_ci		struct {
30078c2ecf20Sopenharmony_ci			uint8_t port_name[8];
30088c2ecf20Sopenharmony_ci		} gid_pn;
30098c2ecf20Sopenharmony_ci	} req;
30108c2ecf20Sopenharmony_ci};
30118c2ecf20Sopenharmony_ci
30128c2ecf20Sopenharmony_ci/* CT command response header */
30138c2ecf20Sopenharmony_cistruct ct_rsp_hdr {
30148c2ecf20Sopenharmony_ci	struct ct_cmd_hdr header;
30158c2ecf20Sopenharmony_ci	__be16	response;
30168c2ecf20Sopenharmony_ci	uint16_t residual;
30178c2ecf20Sopenharmony_ci	uint8_t fragment_id;
30188c2ecf20Sopenharmony_ci	uint8_t reason_code;
30198c2ecf20Sopenharmony_ci	uint8_t explanation_code;
30208c2ecf20Sopenharmony_ci	uint8_t vendor_unique;
30218c2ecf20Sopenharmony_ci};
30228c2ecf20Sopenharmony_ci
30238c2ecf20Sopenharmony_cistruct ct_sns_gid_pt_data {
30248c2ecf20Sopenharmony_ci	uint8_t control_byte;
30258c2ecf20Sopenharmony_ci	be_id_t port_id;
30268c2ecf20Sopenharmony_ci};
30278c2ecf20Sopenharmony_ci
30288c2ecf20Sopenharmony_ci/* It's the same for both GPN_FT and GNN_FT */
30298c2ecf20Sopenharmony_cistruct ct_sns_gpnft_rsp {
30308c2ecf20Sopenharmony_ci	struct {
30318c2ecf20Sopenharmony_ci		struct ct_cmd_hdr header;
30328c2ecf20Sopenharmony_ci		uint16_t response;
30338c2ecf20Sopenharmony_ci		uint16_t residual;
30348c2ecf20Sopenharmony_ci		uint8_t fragment_id;
30358c2ecf20Sopenharmony_ci		uint8_t reason_code;
30368c2ecf20Sopenharmony_ci		uint8_t explanation_code;
30378c2ecf20Sopenharmony_ci		uint8_t vendor_unique;
30388c2ecf20Sopenharmony_ci	};
30398c2ecf20Sopenharmony_ci	/* Assume the largest number of targets for the union */
30408c2ecf20Sopenharmony_ci	struct ct_sns_gpn_ft_data {
30418c2ecf20Sopenharmony_ci		u8 control_byte;
30428c2ecf20Sopenharmony_ci		u8 port_id[3];
30438c2ecf20Sopenharmony_ci		u32 reserved;
30448c2ecf20Sopenharmony_ci		u8 port_name[8];
30458c2ecf20Sopenharmony_ci	} entries[1];
30468c2ecf20Sopenharmony_ci};
30478c2ecf20Sopenharmony_ci
30488c2ecf20Sopenharmony_ci/* CT command response */
30498c2ecf20Sopenharmony_cistruct ct_sns_rsp {
30508c2ecf20Sopenharmony_ci	struct ct_rsp_hdr header;
30518c2ecf20Sopenharmony_ci
30528c2ecf20Sopenharmony_ci	union {
30538c2ecf20Sopenharmony_ci		struct {
30548c2ecf20Sopenharmony_ci			uint8_t port_type;
30558c2ecf20Sopenharmony_ci			be_id_t port_id;
30568c2ecf20Sopenharmony_ci			uint8_t port_name[8];
30578c2ecf20Sopenharmony_ci			uint8_t sym_port_name_len;
30588c2ecf20Sopenharmony_ci			uint8_t sym_port_name[255];
30598c2ecf20Sopenharmony_ci			uint8_t node_name[8];
30608c2ecf20Sopenharmony_ci			uint8_t sym_node_name_len;
30618c2ecf20Sopenharmony_ci			uint8_t sym_node_name[255];
30628c2ecf20Sopenharmony_ci			uint8_t init_proc_assoc[8];
30638c2ecf20Sopenharmony_ci			uint8_t node_ip_addr[16];
30648c2ecf20Sopenharmony_ci			uint8_t class_of_service[4];
30658c2ecf20Sopenharmony_ci			uint8_t fc4_types[32];
30668c2ecf20Sopenharmony_ci			uint8_t ip_address[16];
30678c2ecf20Sopenharmony_ci			uint8_t fabric_port_name[8];
30688c2ecf20Sopenharmony_ci			uint8_t reserved;
30698c2ecf20Sopenharmony_ci			uint8_t hard_address[3];
30708c2ecf20Sopenharmony_ci		} ga_nxt;
30718c2ecf20Sopenharmony_ci
30728c2ecf20Sopenharmony_ci		struct {
30738c2ecf20Sopenharmony_ci			/* Assume the largest number of targets for the union */
30748c2ecf20Sopenharmony_ci			struct ct_sns_gid_pt_data
30758c2ecf20Sopenharmony_ci			    entries[MAX_FIBRE_DEVICES_MAX];
30768c2ecf20Sopenharmony_ci		} gid_pt;
30778c2ecf20Sopenharmony_ci
30788c2ecf20Sopenharmony_ci		struct {
30798c2ecf20Sopenharmony_ci			uint8_t port_name[8];
30808c2ecf20Sopenharmony_ci		} gpn_id;
30818c2ecf20Sopenharmony_ci
30828c2ecf20Sopenharmony_ci		struct {
30838c2ecf20Sopenharmony_ci			uint8_t node_name[8];
30848c2ecf20Sopenharmony_ci		} gnn_id;
30858c2ecf20Sopenharmony_ci
30868c2ecf20Sopenharmony_ci		struct {
30878c2ecf20Sopenharmony_ci			uint8_t fc4_types[32];
30888c2ecf20Sopenharmony_ci		} gft_id;
30898c2ecf20Sopenharmony_ci
30908c2ecf20Sopenharmony_ci		struct {
30918c2ecf20Sopenharmony_ci			uint32_t entry_count;
30928c2ecf20Sopenharmony_ci			uint8_t port_name[8];
30938c2ecf20Sopenharmony_ci			struct ct_fdmi1_hba_attributes attrs;
30948c2ecf20Sopenharmony_ci		} ghat;
30958c2ecf20Sopenharmony_ci
30968c2ecf20Sopenharmony_ci		struct {
30978c2ecf20Sopenharmony_ci			uint8_t port_name[8];
30988c2ecf20Sopenharmony_ci		} gfpn_id;
30998c2ecf20Sopenharmony_ci
31008c2ecf20Sopenharmony_ci		struct {
31018c2ecf20Sopenharmony_ci			__be16	speeds;
31028c2ecf20Sopenharmony_ci			__be16	speed;
31038c2ecf20Sopenharmony_ci		} gpsc;
31048c2ecf20Sopenharmony_ci
31058c2ecf20Sopenharmony_ci#define GFF_FCP_SCSI_OFFSET	7
31068c2ecf20Sopenharmony_ci#define GFF_NVME_OFFSET		23 /* type = 28h */
31078c2ecf20Sopenharmony_ci		struct {
31088c2ecf20Sopenharmony_ci			uint8_t fc4_features[128];
31098c2ecf20Sopenharmony_ci		} gff_id;
31108c2ecf20Sopenharmony_ci		struct {
31118c2ecf20Sopenharmony_ci			uint8_t reserved;
31128c2ecf20Sopenharmony_ci			uint8_t port_id[3];
31138c2ecf20Sopenharmony_ci		} gid_pn;
31148c2ecf20Sopenharmony_ci	} rsp;
31158c2ecf20Sopenharmony_ci};
31168c2ecf20Sopenharmony_ci
31178c2ecf20Sopenharmony_cistruct ct_sns_pkt {
31188c2ecf20Sopenharmony_ci	union {
31198c2ecf20Sopenharmony_ci		struct ct_sns_req req;
31208c2ecf20Sopenharmony_ci		struct ct_sns_rsp rsp;
31218c2ecf20Sopenharmony_ci	} p;
31228c2ecf20Sopenharmony_ci};
31238c2ecf20Sopenharmony_ci
31248c2ecf20Sopenharmony_cistruct ct_sns_gpnft_pkt {
31258c2ecf20Sopenharmony_ci	union {
31268c2ecf20Sopenharmony_ci		struct ct_sns_req req;
31278c2ecf20Sopenharmony_ci		struct ct_sns_gpnft_rsp rsp;
31288c2ecf20Sopenharmony_ci	} p;
31298c2ecf20Sopenharmony_ci};
31308c2ecf20Sopenharmony_ci
31318c2ecf20Sopenharmony_cienum scan_flags_t {
31328c2ecf20Sopenharmony_ci	SF_SCANNING = BIT_0,
31338c2ecf20Sopenharmony_ci	SF_QUEUED = BIT_1,
31348c2ecf20Sopenharmony_ci};
31358c2ecf20Sopenharmony_ci
31368c2ecf20Sopenharmony_cienum fc4type_t {
31378c2ecf20Sopenharmony_ci	FS_FC4TYPE_FCP	= BIT_0,
31388c2ecf20Sopenharmony_ci	FS_FC4TYPE_NVME	= BIT_1,
31398c2ecf20Sopenharmony_ci	FS_FCP_IS_N2N = BIT_7,
31408c2ecf20Sopenharmony_ci};
31418c2ecf20Sopenharmony_ci
31428c2ecf20Sopenharmony_cistruct fab_scan_rp {
31438c2ecf20Sopenharmony_ci	port_id_t id;
31448c2ecf20Sopenharmony_ci	enum fc4type_t fc4type;
31458c2ecf20Sopenharmony_ci	u8 port_name[8];
31468c2ecf20Sopenharmony_ci	u8 node_name[8];
31478c2ecf20Sopenharmony_ci};
31488c2ecf20Sopenharmony_ci
31498c2ecf20Sopenharmony_cistruct fab_scan {
31508c2ecf20Sopenharmony_ci	struct fab_scan_rp *l;
31518c2ecf20Sopenharmony_ci	u32 size;
31528c2ecf20Sopenharmony_ci	u16 scan_retry;
31538c2ecf20Sopenharmony_ci#define MAX_SCAN_RETRIES 5
31548c2ecf20Sopenharmony_ci	enum scan_flags_t scan_flags;
31558c2ecf20Sopenharmony_ci	struct delayed_work scan_work;
31568c2ecf20Sopenharmony_ci};
31578c2ecf20Sopenharmony_ci
31588c2ecf20Sopenharmony_ci/*
31598c2ecf20Sopenharmony_ci * SNS command structures -- for 2200 compatibility.
31608c2ecf20Sopenharmony_ci */
31618c2ecf20Sopenharmony_ci#define	RFT_ID_SNS_SCMD_LEN	22
31628c2ecf20Sopenharmony_ci#define	RFT_ID_SNS_CMD_SIZE	60
31638c2ecf20Sopenharmony_ci#define	RFT_ID_SNS_DATA_SIZE	16
31648c2ecf20Sopenharmony_ci
31658c2ecf20Sopenharmony_ci#define	RNN_ID_SNS_SCMD_LEN	10
31668c2ecf20Sopenharmony_ci#define	RNN_ID_SNS_CMD_SIZE	36
31678c2ecf20Sopenharmony_ci#define	RNN_ID_SNS_DATA_SIZE	16
31688c2ecf20Sopenharmony_ci
31698c2ecf20Sopenharmony_ci#define	GA_NXT_SNS_SCMD_LEN	6
31708c2ecf20Sopenharmony_ci#define	GA_NXT_SNS_CMD_SIZE	28
31718c2ecf20Sopenharmony_ci#define	GA_NXT_SNS_DATA_SIZE	(620 + 16)
31728c2ecf20Sopenharmony_ci
31738c2ecf20Sopenharmony_ci#define	GID_PT_SNS_SCMD_LEN	6
31748c2ecf20Sopenharmony_ci#define	GID_PT_SNS_CMD_SIZE	28
31758c2ecf20Sopenharmony_ci/*
31768c2ecf20Sopenharmony_ci * Assume MAX_FIBRE_DEVICES_2100 as these defines are only used with older
31778c2ecf20Sopenharmony_ci * adapters.
31788c2ecf20Sopenharmony_ci */
31798c2ecf20Sopenharmony_ci#define	GID_PT_SNS_DATA_SIZE	(MAX_FIBRE_DEVICES_2100 * 4 + 16)
31808c2ecf20Sopenharmony_ci
31818c2ecf20Sopenharmony_ci#define	GPN_ID_SNS_SCMD_LEN	6
31828c2ecf20Sopenharmony_ci#define	GPN_ID_SNS_CMD_SIZE	28
31838c2ecf20Sopenharmony_ci#define	GPN_ID_SNS_DATA_SIZE	(8 + 16)
31848c2ecf20Sopenharmony_ci
31858c2ecf20Sopenharmony_ci#define	GNN_ID_SNS_SCMD_LEN	6
31868c2ecf20Sopenharmony_ci#define	GNN_ID_SNS_CMD_SIZE	28
31878c2ecf20Sopenharmony_ci#define	GNN_ID_SNS_DATA_SIZE	(8 + 16)
31888c2ecf20Sopenharmony_ci
31898c2ecf20Sopenharmony_cistruct sns_cmd_pkt {
31908c2ecf20Sopenharmony_ci	union {
31918c2ecf20Sopenharmony_ci		struct {
31928c2ecf20Sopenharmony_ci			__le16	buffer_length;
31938c2ecf20Sopenharmony_ci			__le16	reserved_1;
31948c2ecf20Sopenharmony_ci			__le64	buffer_address __packed;
31958c2ecf20Sopenharmony_ci			__le16	subcommand_length;
31968c2ecf20Sopenharmony_ci			__le16	reserved_2;
31978c2ecf20Sopenharmony_ci			__le16	subcommand;
31988c2ecf20Sopenharmony_ci			__le16	size;
31998c2ecf20Sopenharmony_ci			uint32_t reserved_3;
32008c2ecf20Sopenharmony_ci			uint8_t param[36];
32018c2ecf20Sopenharmony_ci		} cmd;
32028c2ecf20Sopenharmony_ci
32038c2ecf20Sopenharmony_ci		uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
32048c2ecf20Sopenharmony_ci		uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
32058c2ecf20Sopenharmony_ci		uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
32068c2ecf20Sopenharmony_ci		uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
32078c2ecf20Sopenharmony_ci		uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
32088c2ecf20Sopenharmony_ci		uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
32098c2ecf20Sopenharmony_ci	} p;
32108c2ecf20Sopenharmony_ci};
32118c2ecf20Sopenharmony_ci
32128c2ecf20Sopenharmony_cistruct fw_blob {
32138c2ecf20Sopenharmony_ci	char *name;
32148c2ecf20Sopenharmony_ci	uint32_t segs[4];
32158c2ecf20Sopenharmony_ci	const struct firmware *fw;
32168c2ecf20Sopenharmony_ci};
32178c2ecf20Sopenharmony_ci
32188c2ecf20Sopenharmony_ci/* Return data from MBC_GET_ID_LIST call. */
32198c2ecf20Sopenharmony_cistruct gid_list_info {
32208c2ecf20Sopenharmony_ci	uint8_t	al_pa;
32218c2ecf20Sopenharmony_ci	uint8_t	area;
32228c2ecf20Sopenharmony_ci	uint8_t	domain;
32238c2ecf20Sopenharmony_ci	uint8_t	loop_id_2100;	/* ISP2100/ISP2200 -- 4 bytes. */
32248c2ecf20Sopenharmony_ci	__le16	loop_id;	/* ISP23XX         -- 6 bytes. */
32258c2ecf20Sopenharmony_ci	uint16_t reserved_1;	/* ISP24XX         -- 8 bytes. */
32268c2ecf20Sopenharmony_ci};
32278c2ecf20Sopenharmony_ci
32288c2ecf20Sopenharmony_ci/* NPIV */
32298c2ecf20Sopenharmony_citypedef struct vport_info {
32308c2ecf20Sopenharmony_ci	uint8_t		port_name[WWN_SIZE];
32318c2ecf20Sopenharmony_ci	uint8_t		node_name[WWN_SIZE];
32328c2ecf20Sopenharmony_ci	int		vp_id;
32338c2ecf20Sopenharmony_ci	uint16_t	loop_id;
32348c2ecf20Sopenharmony_ci	unsigned long	host_no;
32358c2ecf20Sopenharmony_ci	uint8_t		port_id[3];
32368c2ecf20Sopenharmony_ci	int		loop_state;
32378c2ecf20Sopenharmony_ci} vport_info_t;
32388c2ecf20Sopenharmony_ci
32398c2ecf20Sopenharmony_citypedef struct vport_params {
32408c2ecf20Sopenharmony_ci	uint8_t 	port_name[WWN_SIZE];
32418c2ecf20Sopenharmony_ci	uint8_t 	node_name[WWN_SIZE];
32428c2ecf20Sopenharmony_ci	uint32_t 	options;
32438c2ecf20Sopenharmony_ci#define	VP_OPTS_RETRY_ENABLE	BIT_0
32448c2ecf20Sopenharmony_ci#define	VP_OPTS_VP_DISABLE	BIT_1
32458c2ecf20Sopenharmony_ci} vport_params_t;
32468c2ecf20Sopenharmony_ci
32478c2ecf20Sopenharmony_ci/* NPIV - return codes of VP create and modify */
32488c2ecf20Sopenharmony_ci#define VP_RET_CODE_OK			0
32498c2ecf20Sopenharmony_ci#define VP_RET_CODE_FATAL		1
32508c2ecf20Sopenharmony_ci#define VP_RET_CODE_WRONG_ID		2
32518c2ecf20Sopenharmony_ci#define VP_RET_CODE_WWPN		3
32528c2ecf20Sopenharmony_ci#define VP_RET_CODE_RESOURCES		4
32538c2ecf20Sopenharmony_ci#define VP_RET_CODE_NO_MEM		5
32548c2ecf20Sopenharmony_ci#define VP_RET_CODE_NOT_FOUND		6
32558c2ecf20Sopenharmony_ci
32568c2ecf20Sopenharmony_cistruct qla_hw_data;
32578c2ecf20Sopenharmony_cistruct rsp_que;
32588c2ecf20Sopenharmony_ci/*
32598c2ecf20Sopenharmony_ci * ISP operations
32608c2ecf20Sopenharmony_ci */
32618c2ecf20Sopenharmony_cistruct isp_operations {
32628c2ecf20Sopenharmony_ci
32638c2ecf20Sopenharmony_ci	int (*pci_config) (struct scsi_qla_host *);
32648c2ecf20Sopenharmony_ci	int (*reset_chip)(struct scsi_qla_host *);
32658c2ecf20Sopenharmony_ci	int (*chip_diag) (struct scsi_qla_host *);
32668c2ecf20Sopenharmony_ci	void (*config_rings) (struct scsi_qla_host *);
32678c2ecf20Sopenharmony_ci	int (*reset_adapter)(struct scsi_qla_host *);
32688c2ecf20Sopenharmony_ci	int (*nvram_config) (struct scsi_qla_host *);
32698c2ecf20Sopenharmony_ci	void (*update_fw_options) (struct scsi_qla_host *);
32708c2ecf20Sopenharmony_ci	int (*load_risc) (struct scsi_qla_host *, uint32_t *);
32718c2ecf20Sopenharmony_ci
32728c2ecf20Sopenharmony_ci	char * (*pci_info_str)(struct scsi_qla_host *, char *, size_t);
32738c2ecf20Sopenharmony_ci	char * (*fw_version_str)(struct scsi_qla_host *, char *, size_t);
32748c2ecf20Sopenharmony_ci
32758c2ecf20Sopenharmony_ci	irq_handler_t intr_handler;
32768c2ecf20Sopenharmony_ci	void (*enable_intrs) (struct qla_hw_data *);
32778c2ecf20Sopenharmony_ci	void (*disable_intrs) (struct qla_hw_data *);
32788c2ecf20Sopenharmony_ci
32798c2ecf20Sopenharmony_ci	int (*abort_command) (srb_t *);
32808c2ecf20Sopenharmony_ci	int (*target_reset) (struct fc_port *, uint64_t, int);
32818c2ecf20Sopenharmony_ci	int (*lun_reset) (struct fc_port *, uint64_t, int);
32828c2ecf20Sopenharmony_ci	int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
32838c2ecf20Sopenharmony_ci		uint8_t, uint8_t, uint16_t *, uint8_t);
32848c2ecf20Sopenharmony_ci	int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
32858c2ecf20Sopenharmony_ci	    uint8_t, uint8_t);
32868c2ecf20Sopenharmony_ci
32878c2ecf20Sopenharmony_ci	uint16_t (*calc_req_entries) (uint16_t);
32888c2ecf20Sopenharmony_ci	void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
32898c2ecf20Sopenharmony_ci	void *(*prep_ms_iocb) (struct scsi_qla_host *, struct ct_arg *);
32908c2ecf20Sopenharmony_ci	void *(*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t,
32918c2ecf20Sopenharmony_ci	    uint32_t);
32928c2ecf20Sopenharmony_ci
32938c2ecf20Sopenharmony_ci	uint8_t *(*read_nvram)(struct scsi_qla_host *, void *,
32948c2ecf20Sopenharmony_ci		uint32_t, uint32_t);
32958c2ecf20Sopenharmony_ci	int (*write_nvram)(struct scsi_qla_host *, void *, uint32_t,
32968c2ecf20Sopenharmony_ci		uint32_t);
32978c2ecf20Sopenharmony_ci
32988c2ecf20Sopenharmony_ci	void (*fw_dump)(struct scsi_qla_host *vha);
32998c2ecf20Sopenharmony_ci	void (*mpi_fw_dump)(struct scsi_qla_host *, int);
33008c2ecf20Sopenharmony_ci
33018c2ecf20Sopenharmony_ci	int (*beacon_on) (struct scsi_qla_host *);
33028c2ecf20Sopenharmony_ci	int (*beacon_off) (struct scsi_qla_host *);
33038c2ecf20Sopenharmony_ci	void (*beacon_blink) (struct scsi_qla_host *);
33048c2ecf20Sopenharmony_ci
33058c2ecf20Sopenharmony_ci	void *(*read_optrom)(struct scsi_qla_host *, void *,
33068c2ecf20Sopenharmony_ci		uint32_t, uint32_t);
33078c2ecf20Sopenharmony_ci	int (*write_optrom)(struct scsi_qla_host *, void *, uint32_t,
33088c2ecf20Sopenharmony_ci		uint32_t);
33098c2ecf20Sopenharmony_ci
33108c2ecf20Sopenharmony_ci	int (*get_flash_version) (struct scsi_qla_host *, void *);
33118c2ecf20Sopenharmony_ci	int (*start_scsi) (srb_t *);
33128c2ecf20Sopenharmony_ci	int (*start_scsi_mq) (srb_t *);
33138c2ecf20Sopenharmony_ci	int (*abort_isp) (struct scsi_qla_host *);
33148c2ecf20Sopenharmony_ci	int (*iospace_config)(struct qla_hw_data *);
33158c2ecf20Sopenharmony_ci	int (*initialize_adapter)(struct scsi_qla_host *);
33168c2ecf20Sopenharmony_ci};
33178c2ecf20Sopenharmony_ci
33188c2ecf20Sopenharmony_ci/* MSI-X Support *************************************************************/
33198c2ecf20Sopenharmony_ci
33208c2ecf20Sopenharmony_ci#define QLA_MSIX_CHIP_REV_24XX	3
33218c2ecf20Sopenharmony_ci#define QLA_MSIX_FW_MODE(m)	(((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
33228c2ecf20Sopenharmony_ci#define QLA_MSIX_FW_MODE_1(m)	(QLA_MSIX_FW_MODE(m) == 1)
33238c2ecf20Sopenharmony_ci
33248c2ecf20Sopenharmony_ci#define QLA_BASE_VECTORS	2 /* default + RSP */
33258c2ecf20Sopenharmony_ci#define QLA_MSIX_RSP_Q			0x01
33268c2ecf20Sopenharmony_ci#define QLA_ATIO_VECTOR		0x02
33278c2ecf20Sopenharmony_ci#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q	0x03
33288c2ecf20Sopenharmony_ci#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS	0x04
33298c2ecf20Sopenharmony_ci
33308c2ecf20Sopenharmony_ci#define QLA_MIDX_DEFAULT	0
33318c2ecf20Sopenharmony_ci#define QLA_MIDX_RSP_Q		1
33328c2ecf20Sopenharmony_ci#define QLA_PCI_MSIX_CONTROL	0xa2
33338c2ecf20Sopenharmony_ci#define QLA_83XX_PCI_MSIX_CONTROL	0x92
33348c2ecf20Sopenharmony_ci
33358c2ecf20Sopenharmony_cistruct scsi_qla_host;
33368c2ecf20Sopenharmony_ci
33378c2ecf20Sopenharmony_ci
33388c2ecf20Sopenharmony_ci#define QLA83XX_RSPQ_MSIX_ENTRY_NUMBER 1 /* refer to qla83xx_msix_entries */
33398c2ecf20Sopenharmony_ci
33408c2ecf20Sopenharmony_cistruct qla_msix_entry {
33418c2ecf20Sopenharmony_ci	int have_irq;
33428c2ecf20Sopenharmony_ci	int in_use;
33438c2ecf20Sopenharmony_ci	uint32_t vector;
33448c2ecf20Sopenharmony_ci	uint16_t entry;
33458c2ecf20Sopenharmony_ci	char name[30];
33468c2ecf20Sopenharmony_ci	void *handle;
33478c2ecf20Sopenharmony_ci	int cpuid;
33488c2ecf20Sopenharmony_ci};
33498c2ecf20Sopenharmony_ci
33508c2ecf20Sopenharmony_ci#define	WATCH_INTERVAL		1       /* number of seconds */
33518c2ecf20Sopenharmony_ci
33528c2ecf20Sopenharmony_ci/* Work events.  */
33538c2ecf20Sopenharmony_cienum qla_work_type {
33548c2ecf20Sopenharmony_ci	QLA_EVT_AEN,
33558c2ecf20Sopenharmony_ci	QLA_EVT_IDC_ACK,
33568c2ecf20Sopenharmony_ci	QLA_EVT_ASYNC_LOGIN,
33578c2ecf20Sopenharmony_ci	QLA_EVT_ASYNC_LOGOUT,
33588c2ecf20Sopenharmony_ci	QLA_EVT_ASYNC_ADISC,
33598c2ecf20Sopenharmony_ci	QLA_EVT_UEVENT,
33608c2ecf20Sopenharmony_ci	QLA_EVT_AENFX,
33618c2ecf20Sopenharmony_ci	QLA_EVT_GPNID,
33628c2ecf20Sopenharmony_ci	QLA_EVT_UNMAP,
33638c2ecf20Sopenharmony_ci	QLA_EVT_NEW_SESS,
33648c2ecf20Sopenharmony_ci	QLA_EVT_GPDB,
33658c2ecf20Sopenharmony_ci	QLA_EVT_PRLI,
33668c2ecf20Sopenharmony_ci	QLA_EVT_GPSC,
33678c2ecf20Sopenharmony_ci	QLA_EVT_GNL,
33688c2ecf20Sopenharmony_ci	QLA_EVT_NACK,
33698c2ecf20Sopenharmony_ci	QLA_EVT_RELOGIN,
33708c2ecf20Sopenharmony_ci	QLA_EVT_ASYNC_PRLO,
33718c2ecf20Sopenharmony_ci	QLA_EVT_ASYNC_PRLO_DONE,
33728c2ecf20Sopenharmony_ci	QLA_EVT_GPNFT,
33738c2ecf20Sopenharmony_ci	QLA_EVT_GPNFT_DONE,
33748c2ecf20Sopenharmony_ci	QLA_EVT_GNNFT_DONE,
33758c2ecf20Sopenharmony_ci	QLA_EVT_GNNID,
33768c2ecf20Sopenharmony_ci	QLA_EVT_GFPNID,
33778c2ecf20Sopenharmony_ci	QLA_EVT_SP_RETRY,
33788c2ecf20Sopenharmony_ci	QLA_EVT_IIDMA,
33798c2ecf20Sopenharmony_ci	QLA_EVT_ELS_PLOGI,
33808c2ecf20Sopenharmony_ci};
33818c2ecf20Sopenharmony_ci
33828c2ecf20Sopenharmony_ci
33838c2ecf20Sopenharmony_cistruct qla_work_evt {
33848c2ecf20Sopenharmony_ci	struct list_head	list;
33858c2ecf20Sopenharmony_ci	enum qla_work_type	type;
33868c2ecf20Sopenharmony_ci	u32			flags;
33878c2ecf20Sopenharmony_ci#define QLA_EVT_FLAG_FREE	0x1
33888c2ecf20Sopenharmony_ci
33898c2ecf20Sopenharmony_ci	union {
33908c2ecf20Sopenharmony_ci		struct {
33918c2ecf20Sopenharmony_ci			enum fc_host_event_code code;
33928c2ecf20Sopenharmony_ci			u32 data;
33938c2ecf20Sopenharmony_ci		} aen;
33948c2ecf20Sopenharmony_ci		struct {
33958c2ecf20Sopenharmony_ci#define QLA_IDC_ACK_REGS	7
33968c2ecf20Sopenharmony_ci			uint16_t mb[QLA_IDC_ACK_REGS];
33978c2ecf20Sopenharmony_ci		} idc_ack;
33988c2ecf20Sopenharmony_ci		struct {
33998c2ecf20Sopenharmony_ci			struct fc_port *fcport;
34008c2ecf20Sopenharmony_ci#define QLA_LOGIO_LOGIN_RETRIED	BIT_0
34018c2ecf20Sopenharmony_ci			u16 data[2];
34028c2ecf20Sopenharmony_ci		} logio;
34038c2ecf20Sopenharmony_ci		struct {
34048c2ecf20Sopenharmony_ci			u32 code;
34058c2ecf20Sopenharmony_ci#define QLA_UEVENT_CODE_FW_DUMP	0
34068c2ecf20Sopenharmony_ci		} uevent;
34078c2ecf20Sopenharmony_ci		struct {
34088c2ecf20Sopenharmony_ci			uint32_t        evtcode;
34098c2ecf20Sopenharmony_ci			uint32_t        mbx[8];
34108c2ecf20Sopenharmony_ci			uint32_t        count;
34118c2ecf20Sopenharmony_ci		} aenfx;
34128c2ecf20Sopenharmony_ci		struct {
34138c2ecf20Sopenharmony_ci			srb_t *sp;
34148c2ecf20Sopenharmony_ci		} iosb;
34158c2ecf20Sopenharmony_ci		struct {
34168c2ecf20Sopenharmony_ci			port_id_t id;
34178c2ecf20Sopenharmony_ci		} gpnid;
34188c2ecf20Sopenharmony_ci		struct {
34198c2ecf20Sopenharmony_ci			port_id_t id;
34208c2ecf20Sopenharmony_ci			u8 port_name[8];
34218c2ecf20Sopenharmony_ci			u8 node_name[8];
34228c2ecf20Sopenharmony_ci			void *pla;
34238c2ecf20Sopenharmony_ci			u8 fc4_type;
34248c2ecf20Sopenharmony_ci		} new_sess;
34258c2ecf20Sopenharmony_ci		struct { /*Get PDB, Get Speed, update fcport, gnl, gidpn */
34268c2ecf20Sopenharmony_ci			fc_port_t *fcport;
34278c2ecf20Sopenharmony_ci			u8 opt;
34288c2ecf20Sopenharmony_ci		} fcport;
34298c2ecf20Sopenharmony_ci		struct {
34308c2ecf20Sopenharmony_ci			fc_port_t *fcport;
34318c2ecf20Sopenharmony_ci			u8 iocb[IOCB_SIZE];
34328c2ecf20Sopenharmony_ci			int type;
34338c2ecf20Sopenharmony_ci		} nack;
34348c2ecf20Sopenharmony_ci		struct {
34358c2ecf20Sopenharmony_ci			u8 fc4_type;
34368c2ecf20Sopenharmony_ci			srb_t *sp;
34378c2ecf20Sopenharmony_ci		} gpnft;
34388c2ecf20Sopenharmony_ci	 } u;
34398c2ecf20Sopenharmony_ci};
34408c2ecf20Sopenharmony_ci
34418c2ecf20Sopenharmony_cistruct qla_chip_state_84xx {
34428c2ecf20Sopenharmony_ci	struct list_head list;
34438c2ecf20Sopenharmony_ci	struct kref kref;
34448c2ecf20Sopenharmony_ci
34458c2ecf20Sopenharmony_ci	void *bus;
34468c2ecf20Sopenharmony_ci	spinlock_t access_lock;
34478c2ecf20Sopenharmony_ci	struct mutex fw_update_mutex;
34488c2ecf20Sopenharmony_ci	uint32_t fw_update;
34498c2ecf20Sopenharmony_ci	uint32_t op_fw_version;
34508c2ecf20Sopenharmony_ci	uint32_t op_fw_size;
34518c2ecf20Sopenharmony_ci	uint32_t op_fw_seq_size;
34528c2ecf20Sopenharmony_ci	uint32_t diag_fw_version;
34538c2ecf20Sopenharmony_ci	uint32_t gold_fw_version;
34548c2ecf20Sopenharmony_ci};
34558c2ecf20Sopenharmony_ci
34568c2ecf20Sopenharmony_cistruct qla_dif_statistics {
34578c2ecf20Sopenharmony_ci	uint64_t dif_input_bytes;
34588c2ecf20Sopenharmony_ci	uint64_t dif_output_bytes;
34598c2ecf20Sopenharmony_ci	uint64_t dif_input_requests;
34608c2ecf20Sopenharmony_ci	uint64_t dif_output_requests;
34618c2ecf20Sopenharmony_ci	uint32_t dif_guard_err;
34628c2ecf20Sopenharmony_ci	uint32_t dif_ref_tag_err;
34638c2ecf20Sopenharmony_ci	uint32_t dif_app_tag_err;
34648c2ecf20Sopenharmony_ci};
34658c2ecf20Sopenharmony_ci
34668c2ecf20Sopenharmony_cistruct qla_statistics {
34678c2ecf20Sopenharmony_ci	uint32_t total_isp_aborts;
34688c2ecf20Sopenharmony_ci	uint64_t input_bytes;
34698c2ecf20Sopenharmony_ci	uint64_t output_bytes;
34708c2ecf20Sopenharmony_ci	uint64_t input_requests;
34718c2ecf20Sopenharmony_ci	uint64_t output_requests;
34728c2ecf20Sopenharmony_ci	uint32_t control_requests;
34738c2ecf20Sopenharmony_ci
34748c2ecf20Sopenharmony_ci	uint64_t jiffies_at_last_reset;
34758c2ecf20Sopenharmony_ci	uint32_t stat_max_pend_cmds;
34768c2ecf20Sopenharmony_ci	uint32_t stat_max_qfull_cmds_alloc;
34778c2ecf20Sopenharmony_ci	uint32_t stat_max_qfull_cmds_dropped;
34788c2ecf20Sopenharmony_ci
34798c2ecf20Sopenharmony_ci	struct qla_dif_statistics qla_dif_stats;
34808c2ecf20Sopenharmony_ci};
34818c2ecf20Sopenharmony_ci
34828c2ecf20Sopenharmony_cistruct bidi_statistics {
34838c2ecf20Sopenharmony_ci	unsigned long long io_count;
34848c2ecf20Sopenharmony_ci	unsigned long long transfer_bytes;
34858c2ecf20Sopenharmony_ci};
34868c2ecf20Sopenharmony_ci
34878c2ecf20Sopenharmony_cistruct qla_tc_param {
34888c2ecf20Sopenharmony_ci	struct scsi_qla_host *vha;
34898c2ecf20Sopenharmony_ci	uint32_t blk_sz;
34908c2ecf20Sopenharmony_ci	uint32_t bufflen;
34918c2ecf20Sopenharmony_ci	struct scatterlist *sg;
34928c2ecf20Sopenharmony_ci	struct scatterlist *prot_sg;
34938c2ecf20Sopenharmony_ci	struct crc_context *ctx;
34948c2ecf20Sopenharmony_ci	uint8_t *ctx_dsd_alloced;
34958c2ecf20Sopenharmony_ci};
34968c2ecf20Sopenharmony_ci
34978c2ecf20Sopenharmony_ci/* Multi queue support */
34988c2ecf20Sopenharmony_ci#define MBC_INITIALIZE_MULTIQ 0x1f
34998c2ecf20Sopenharmony_ci#define QLA_QUE_PAGE 0X1000
35008c2ecf20Sopenharmony_ci#define QLA_MQ_SIZE 32
35018c2ecf20Sopenharmony_ci#define QLA_MAX_QUEUES 256
35028c2ecf20Sopenharmony_ci#define ISP_QUE_REG(ha, id) \
35038c2ecf20Sopenharmony_ci	((ha->mqenable || IS_QLA83XX(ha) || \
35048c2ecf20Sopenharmony_ci	  IS_QLA27XX(ha) || IS_QLA28XX(ha)) ? \
35058c2ecf20Sopenharmony_ci	 ((void __iomem *)ha->mqiobase + (QLA_QUE_PAGE * id)) :\
35068c2ecf20Sopenharmony_ci	 ((void __iomem *)ha->iobase))
35078c2ecf20Sopenharmony_ci#define QLA_REQ_QUE_ID(tag) \
35088c2ecf20Sopenharmony_ci	((tag < QLA_MAX_QUEUES && tag > 0) ? tag : 0)
35098c2ecf20Sopenharmony_ci#define QLA_DEFAULT_QUE_QOS 5
35108c2ecf20Sopenharmony_ci#define QLA_PRECONFIG_VPORTS 32
35118c2ecf20Sopenharmony_ci#define QLA_MAX_VPORTS_QLA24XX	128
35128c2ecf20Sopenharmony_ci#define QLA_MAX_VPORTS_QLA25XX	256
35138c2ecf20Sopenharmony_ci
35148c2ecf20Sopenharmony_cistruct qla_tgt_counters {
35158c2ecf20Sopenharmony_ci	uint64_t qla_core_sbt_cmd;
35168c2ecf20Sopenharmony_ci	uint64_t core_qla_que_buf;
35178c2ecf20Sopenharmony_ci	uint64_t qla_core_ret_ctio;
35188c2ecf20Sopenharmony_ci	uint64_t core_qla_snd_status;
35198c2ecf20Sopenharmony_ci	uint64_t qla_core_ret_sta_ctio;
35208c2ecf20Sopenharmony_ci	uint64_t core_qla_free_cmd;
35218c2ecf20Sopenharmony_ci	uint64_t num_q_full_sent;
35228c2ecf20Sopenharmony_ci	uint64_t num_alloc_iocb_failed;
35238c2ecf20Sopenharmony_ci	uint64_t num_term_xchg_sent;
35248c2ecf20Sopenharmony_ci};
35258c2ecf20Sopenharmony_ci
35268c2ecf20Sopenharmony_cistruct qla_counters {
35278c2ecf20Sopenharmony_ci	uint64_t input_bytes;
35288c2ecf20Sopenharmony_ci	uint64_t input_requests;
35298c2ecf20Sopenharmony_ci	uint64_t output_bytes;
35308c2ecf20Sopenharmony_ci	uint64_t output_requests;
35318c2ecf20Sopenharmony_ci
35328c2ecf20Sopenharmony_ci};
35338c2ecf20Sopenharmony_ci
35348c2ecf20Sopenharmony_cistruct qla_qpair;
35358c2ecf20Sopenharmony_ci
35368c2ecf20Sopenharmony_ci/* Response queue data structure */
35378c2ecf20Sopenharmony_cistruct rsp_que {
35388c2ecf20Sopenharmony_ci	dma_addr_t  dma;
35398c2ecf20Sopenharmony_ci	response_t *ring;
35408c2ecf20Sopenharmony_ci	response_t *ring_ptr;
35418c2ecf20Sopenharmony_ci	__le32	__iomem *rsp_q_in;	/* FWI2-capable only. */
35428c2ecf20Sopenharmony_ci	__le32	__iomem *rsp_q_out;
35438c2ecf20Sopenharmony_ci	uint16_t  ring_index;
35448c2ecf20Sopenharmony_ci	uint16_t  out_ptr;
35458c2ecf20Sopenharmony_ci	uint16_t  *in_ptr;		/* queue shadow in index */
35468c2ecf20Sopenharmony_ci	uint16_t  length;
35478c2ecf20Sopenharmony_ci	uint16_t  options;
35488c2ecf20Sopenharmony_ci	uint16_t  rid;
35498c2ecf20Sopenharmony_ci	uint16_t  id;
35508c2ecf20Sopenharmony_ci	uint16_t  vp_idx;
35518c2ecf20Sopenharmony_ci	struct qla_hw_data *hw;
35528c2ecf20Sopenharmony_ci	struct qla_msix_entry *msix;
35538c2ecf20Sopenharmony_ci	struct req_que *req;
35548c2ecf20Sopenharmony_ci	srb_t *status_srb; /* status continuation entry */
35558c2ecf20Sopenharmony_ci	struct qla_qpair *qpair;
35568c2ecf20Sopenharmony_ci
35578c2ecf20Sopenharmony_ci	dma_addr_t  dma_fx00;
35588c2ecf20Sopenharmony_ci	response_t *ring_fx00;
35598c2ecf20Sopenharmony_ci	uint16_t  length_fx00;
35608c2ecf20Sopenharmony_ci	uint8_t rsp_pkt[REQUEST_ENTRY_SIZE];
35618c2ecf20Sopenharmony_ci};
35628c2ecf20Sopenharmony_ci
35638c2ecf20Sopenharmony_ci/* Request queue data structure */
35648c2ecf20Sopenharmony_cistruct req_que {
35658c2ecf20Sopenharmony_ci	dma_addr_t  dma;
35668c2ecf20Sopenharmony_ci	request_t *ring;
35678c2ecf20Sopenharmony_ci	request_t *ring_ptr;
35688c2ecf20Sopenharmony_ci	__le32	__iomem *req_q_in;	/* FWI2-capable only. */
35698c2ecf20Sopenharmony_ci	__le32	__iomem *req_q_out;
35708c2ecf20Sopenharmony_ci	uint16_t  ring_index;
35718c2ecf20Sopenharmony_ci	uint16_t  in_ptr;
35728c2ecf20Sopenharmony_ci	uint16_t  *out_ptr;		/* queue shadow out index */
35738c2ecf20Sopenharmony_ci	uint16_t  cnt;
35748c2ecf20Sopenharmony_ci	uint16_t  length;
35758c2ecf20Sopenharmony_ci	uint16_t  options;
35768c2ecf20Sopenharmony_ci	uint16_t  rid;
35778c2ecf20Sopenharmony_ci	uint16_t  id;
35788c2ecf20Sopenharmony_ci	uint16_t  qos;
35798c2ecf20Sopenharmony_ci	uint16_t  vp_idx;
35808c2ecf20Sopenharmony_ci	struct rsp_que *rsp;
35818c2ecf20Sopenharmony_ci	srb_t **outstanding_cmds;
35828c2ecf20Sopenharmony_ci	uint32_t current_outstanding_cmd;
35838c2ecf20Sopenharmony_ci	uint16_t num_outstanding_cmds;
35848c2ecf20Sopenharmony_ci	int max_q_depth;
35858c2ecf20Sopenharmony_ci
35868c2ecf20Sopenharmony_ci	dma_addr_t  dma_fx00;
35878c2ecf20Sopenharmony_ci	request_t *ring_fx00;
35888c2ecf20Sopenharmony_ci	uint16_t  length_fx00;
35898c2ecf20Sopenharmony_ci	uint8_t req_pkt[REQUEST_ENTRY_SIZE];
35908c2ecf20Sopenharmony_ci};
35918c2ecf20Sopenharmony_ci
35928c2ecf20Sopenharmony_cistruct qla_fw_resources {
35938c2ecf20Sopenharmony_ci	u16 iocbs_total;
35948c2ecf20Sopenharmony_ci	u16 iocbs_limit;
35958c2ecf20Sopenharmony_ci	u16 iocbs_qp_limit;
35968c2ecf20Sopenharmony_ci	u16 iocbs_used;
35978c2ecf20Sopenharmony_ci};
35988c2ecf20Sopenharmony_ci
35998c2ecf20Sopenharmony_ci#define QLA_IOCB_PCT_LIMIT 95
36008c2ecf20Sopenharmony_ci
36018c2ecf20Sopenharmony_ci/*Queue pair data structure */
36028c2ecf20Sopenharmony_cistruct qla_qpair {
36038c2ecf20Sopenharmony_ci	spinlock_t qp_lock;
36048c2ecf20Sopenharmony_ci	atomic_t ref_count;
36058c2ecf20Sopenharmony_ci	uint32_t lun_cnt;
36068c2ecf20Sopenharmony_ci	/*
36078c2ecf20Sopenharmony_ci	 * For qpair 0, qp_lock_ptr will point at hardware_lock due to
36088c2ecf20Sopenharmony_ci	 * legacy code. For other Qpair(s), it will point at qp_lock.
36098c2ecf20Sopenharmony_ci	 */
36108c2ecf20Sopenharmony_ci	spinlock_t *qp_lock_ptr;
36118c2ecf20Sopenharmony_ci	struct scsi_qla_host *vha;
36128c2ecf20Sopenharmony_ci	u32 chip_reset;
36138c2ecf20Sopenharmony_ci
36148c2ecf20Sopenharmony_ci	/* distill these fields down to 'online=0/1'
36158c2ecf20Sopenharmony_ci	 * ha->flags.eeh_busy
36168c2ecf20Sopenharmony_ci	 * ha->flags.pci_channel_io_perm_failure
36178c2ecf20Sopenharmony_ci	 * base_vha->loop_state
36188c2ecf20Sopenharmony_ci	 */
36198c2ecf20Sopenharmony_ci	uint32_t online:1;
36208c2ecf20Sopenharmony_ci	/* move vha->flags.difdix_supported here */
36218c2ecf20Sopenharmony_ci	uint32_t difdix_supported:1;
36228c2ecf20Sopenharmony_ci	uint32_t delete_in_progress:1;
36238c2ecf20Sopenharmony_ci	uint32_t fw_started:1;
36248c2ecf20Sopenharmony_ci	uint32_t enable_class_2:1;
36258c2ecf20Sopenharmony_ci	uint32_t enable_explicit_conf:1;
36268c2ecf20Sopenharmony_ci	uint32_t use_shadow_reg:1;
36278c2ecf20Sopenharmony_ci	uint32_t rcv_intr:1;
36288c2ecf20Sopenharmony_ci
36298c2ecf20Sopenharmony_ci	uint16_t id;			/* qp number used with FW */
36308c2ecf20Sopenharmony_ci	uint16_t vp_idx;		/* vport ID */
36318c2ecf20Sopenharmony_ci	mempool_t *srb_mempool;
36328c2ecf20Sopenharmony_ci
36338c2ecf20Sopenharmony_ci	struct pci_dev  *pdev;
36348c2ecf20Sopenharmony_ci	void (*reqq_start_iocbs)(struct qla_qpair *);
36358c2ecf20Sopenharmony_ci
36368c2ecf20Sopenharmony_ci	/* to do: New driver: move queues to here instead of pointers */
36378c2ecf20Sopenharmony_ci	struct req_que *req;
36388c2ecf20Sopenharmony_ci	struct rsp_que *rsp;
36398c2ecf20Sopenharmony_ci	struct atio_que *atio;
36408c2ecf20Sopenharmony_ci	struct qla_msix_entry *msix; /* point to &ha->msix_entries[x] */
36418c2ecf20Sopenharmony_ci	struct qla_hw_data *hw;
36428c2ecf20Sopenharmony_ci	struct work_struct q_work;
36438c2ecf20Sopenharmony_ci	struct qla_counters counters;
36448c2ecf20Sopenharmony_ci
36458c2ecf20Sopenharmony_ci	struct list_head qp_list_elem; /* vha->qp_list */
36468c2ecf20Sopenharmony_ci	struct list_head hints_list;
36478c2ecf20Sopenharmony_ci
36488c2ecf20Sopenharmony_ci	uint16_t retry_term_cnt;
36498c2ecf20Sopenharmony_ci	__le32	retry_term_exchg_addr;
36508c2ecf20Sopenharmony_ci	uint64_t retry_term_jiff;
36518c2ecf20Sopenharmony_ci	struct qla_tgt_counters tgt_counters;
36528c2ecf20Sopenharmony_ci	uint16_t cpuid;
36538c2ecf20Sopenharmony_ci	struct qla_fw_resources fwres ____cacheline_aligned;
36548c2ecf20Sopenharmony_ci};
36558c2ecf20Sopenharmony_ci
36568c2ecf20Sopenharmony_ci/* Place holder for FW buffer parameters */
36578c2ecf20Sopenharmony_cistruct qlfc_fw {
36588c2ecf20Sopenharmony_ci	void *fw_buf;
36598c2ecf20Sopenharmony_ci	dma_addr_t fw_dma;
36608c2ecf20Sopenharmony_ci	uint32_t len;
36618c2ecf20Sopenharmony_ci};
36628c2ecf20Sopenharmony_ci
36638c2ecf20Sopenharmony_cistruct rdp_req_payload {
36648c2ecf20Sopenharmony_ci	uint32_t	els_request;
36658c2ecf20Sopenharmony_ci	uint32_t	desc_list_len;
36668c2ecf20Sopenharmony_ci
36678c2ecf20Sopenharmony_ci	/* NPIV descriptor */
36688c2ecf20Sopenharmony_ci	struct {
36698c2ecf20Sopenharmony_ci		uint32_t desc_tag;
36708c2ecf20Sopenharmony_ci		uint32_t desc_len;
36718c2ecf20Sopenharmony_ci		uint8_t  reserved;
36728c2ecf20Sopenharmony_ci		uint8_t  nport_id[3];
36738c2ecf20Sopenharmony_ci	} npiv_desc;
36748c2ecf20Sopenharmony_ci};
36758c2ecf20Sopenharmony_ci
36768c2ecf20Sopenharmony_cistruct rdp_rsp_payload {
36778c2ecf20Sopenharmony_ci	struct {
36788c2ecf20Sopenharmony_ci		__be32	cmd;
36798c2ecf20Sopenharmony_ci		__be32	len;
36808c2ecf20Sopenharmony_ci	} hdr;
36818c2ecf20Sopenharmony_ci
36828c2ecf20Sopenharmony_ci	/* LS Request Info descriptor */
36838c2ecf20Sopenharmony_ci	struct {
36848c2ecf20Sopenharmony_ci		__be32	desc_tag;
36858c2ecf20Sopenharmony_ci		__be32	desc_len;
36868c2ecf20Sopenharmony_ci		__be32	req_payload_word_0;
36878c2ecf20Sopenharmony_ci	} ls_req_info_desc;
36888c2ecf20Sopenharmony_ci
36898c2ecf20Sopenharmony_ci	/* LS Request Info descriptor */
36908c2ecf20Sopenharmony_ci	struct {
36918c2ecf20Sopenharmony_ci		__be32	desc_tag;
36928c2ecf20Sopenharmony_ci		__be32	desc_len;
36938c2ecf20Sopenharmony_ci		__be32	req_payload_word_0;
36948c2ecf20Sopenharmony_ci	} ls_req_info_desc2;
36958c2ecf20Sopenharmony_ci
36968c2ecf20Sopenharmony_ci	/* SFP diagnostic param descriptor */
36978c2ecf20Sopenharmony_ci	struct {
36988c2ecf20Sopenharmony_ci		__be32	desc_tag;
36998c2ecf20Sopenharmony_ci		__be32	desc_len;
37008c2ecf20Sopenharmony_ci		__be16	temperature;
37018c2ecf20Sopenharmony_ci		__be16	vcc;
37028c2ecf20Sopenharmony_ci		__be16	tx_bias;
37038c2ecf20Sopenharmony_ci		__be16	tx_power;
37048c2ecf20Sopenharmony_ci		__be16	rx_power;
37058c2ecf20Sopenharmony_ci		__be16	sfp_flags;
37068c2ecf20Sopenharmony_ci	} sfp_diag_desc;
37078c2ecf20Sopenharmony_ci
37088c2ecf20Sopenharmony_ci	/* Port Speed Descriptor */
37098c2ecf20Sopenharmony_ci	struct {
37108c2ecf20Sopenharmony_ci		__be32	desc_tag;
37118c2ecf20Sopenharmony_ci		__be32	desc_len;
37128c2ecf20Sopenharmony_ci		__be16	speed_capab;
37138c2ecf20Sopenharmony_ci		__be16	operating_speed;
37148c2ecf20Sopenharmony_ci	} port_speed_desc;
37158c2ecf20Sopenharmony_ci
37168c2ecf20Sopenharmony_ci	/* Link Error Status Descriptor */
37178c2ecf20Sopenharmony_ci	struct {
37188c2ecf20Sopenharmony_ci		__be32	desc_tag;
37198c2ecf20Sopenharmony_ci		__be32	desc_len;
37208c2ecf20Sopenharmony_ci		__be32	link_fail_cnt;
37218c2ecf20Sopenharmony_ci		__be32	loss_sync_cnt;
37228c2ecf20Sopenharmony_ci		__be32	loss_sig_cnt;
37238c2ecf20Sopenharmony_ci		__be32	prim_seq_err_cnt;
37248c2ecf20Sopenharmony_ci		__be32	inval_xmit_word_cnt;
37258c2ecf20Sopenharmony_ci		__be32	inval_crc_cnt;
37268c2ecf20Sopenharmony_ci		uint8_t  pn_port_phy_type;
37278c2ecf20Sopenharmony_ci		uint8_t  reserved[3];
37288c2ecf20Sopenharmony_ci	} ls_err_desc;
37298c2ecf20Sopenharmony_ci
37308c2ecf20Sopenharmony_ci	/* Port name description with diag param */
37318c2ecf20Sopenharmony_ci	struct {
37328c2ecf20Sopenharmony_ci		__be32	desc_tag;
37338c2ecf20Sopenharmony_ci		__be32	desc_len;
37348c2ecf20Sopenharmony_ci		uint8_t WWNN[WWN_SIZE];
37358c2ecf20Sopenharmony_ci		uint8_t WWPN[WWN_SIZE];
37368c2ecf20Sopenharmony_ci	} port_name_diag_desc;
37378c2ecf20Sopenharmony_ci
37388c2ecf20Sopenharmony_ci	/* Port Name desc for Direct attached Fx_Port or Nx_Port */
37398c2ecf20Sopenharmony_ci	struct {
37408c2ecf20Sopenharmony_ci		__be32	desc_tag;
37418c2ecf20Sopenharmony_ci		__be32	desc_len;
37428c2ecf20Sopenharmony_ci		uint8_t WWNN[WWN_SIZE];
37438c2ecf20Sopenharmony_ci		uint8_t WWPN[WWN_SIZE];
37448c2ecf20Sopenharmony_ci	} port_name_direct_desc;
37458c2ecf20Sopenharmony_ci
37468c2ecf20Sopenharmony_ci	/* Buffer Credit descriptor */
37478c2ecf20Sopenharmony_ci	struct {
37488c2ecf20Sopenharmony_ci		__be32	desc_tag;
37498c2ecf20Sopenharmony_ci		__be32	desc_len;
37508c2ecf20Sopenharmony_ci		__be32	fcport_b2b;
37518c2ecf20Sopenharmony_ci		__be32	attached_fcport_b2b;
37528c2ecf20Sopenharmony_ci		__be32	fcport_rtt;
37538c2ecf20Sopenharmony_ci	} buffer_credit_desc;
37548c2ecf20Sopenharmony_ci
37558c2ecf20Sopenharmony_ci	/* Optical Element Data Descriptor */
37568c2ecf20Sopenharmony_ci	struct {
37578c2ecf20Sopenharmony_ci		__be32	desc_tag;
37588c2ecf20Sopenharmony_ci		__be32	desc_len;
37598c2ecf20Sopenharmony_ci		__be16	high_alarm;
37608c2ecf20Sopenharmony_ci		__be16	low_alarm;
37618c2ecf20Sopenharmony_ci		__be16	high_warn;
37628c2ecf20Sopenharmony_ci		__be16	low_warn;
37638c2ecf20Sopenharmony_ci		__be32	element_flags;
37648c2ecf20Sopenharmony_ci	} optical_elmt_desc[5];
37658c2ecf20Sopenharmony_ci
37668c2ecf20Sopenharmony_ci	/* Optical Product Data Descriptor */
37678c2ecf20Sopenharmony_ci	struct {
37688c2ecf20Sopenharmony_ci		__be32	desc_tag;
37698c2ecf20Sopenharmony_ci		__be32	desc_len;
37708c2ecf20Sopenharmony_ci		uint8_t  vendor_name[16];
37718c2ecf20Sopenharmony_ci		uint8_t  part_number[16];
37728c2ecf20Sopenharmony_ci		uint8_t  serial_number[16];
37738c2ecf20Sopenharmony_ci		uint8_t  revision[4];
37748c2ecf20Sopenharmony_ci		uint8_t  date[8];
37758c2ecf20Sopenharmony_ci	} optical_prod_desc;
37768c2ecf20Sopenharmony_ci};
37778c2ecf20Sopenharmony_ci
37788c2ecf20Sopenharmony_ci#define RDP_DESC_LEN(obj) \
37798c2ecf20Sopenharmony_ci	(sizeof(obj) - sizeof((obj).desc_tag) - sizeof((obj).desc_len))
37808c2ecf20Sopenharmony_ci
37818c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_1GB		BIT_15
37828c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_2GB		BIT_14
37838c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_4GB		BIT_13
37848c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_10GB		BIT_12
37858c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_8GB		BIT_11
37868c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_16GB		BIT_10
37878c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_32GB		BIT_9
37888c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_64GB             BIT_8
37898c2ecf20Sopenharmony_ci#define RDP_PORT_SPEED_UNKNOWN		BIT_0
37908c2ecf20Sopenharmony_ci
37918c2ecf20Sopenharmony_cistruct scsi_qlt_host {
37928c2ecf20Sopenharmony_ci	void *target_lport_ptr;
37938c2ecf20Sopenharmony_ci	struct mutex tgt_mutex;
37948c2ecf20Sopenharmony_ci	struct mutex tgt_host_action_mutex;
37958c2ecf20Sopenharmony_ci	struct qla_tgt *qla_tgt;
37968c2ecf20Sopenharmony_ci};
37978c2ecf20Sopenharmony_ci
37988c2ecf20Sopenharmony_cistruct qlt_hw_data {
37998c2ecf20Sopenharmony_ci	/* Protected by hw lock */
38008c2ecf20Sopenharmony_ci	uint32_t node_name_set:1;
38018c2ecf20Sopenharmony_ci
38028c2ecf20Sopenharmony_ci	dma_addr_t atio_dma;	/* Physical address. */
38038c2ecf20Sopenharmony_ci	struct atio *atio_ring;	/* Base virtual address */
38048c2ecf20Sopenharmony_ci	struct atio *atio_ring_ptr;	/* Current address. */
38058c2ecf20Sopenharmony_ci	uint16_t atio_ring_index; /* Current index. */
38068c2ecf20Sopenharmony_ci	uint16_t atio_q_length;
38078c2ecf20Sopenharmony_ci	__le32 __iomem *atio_q_in;
38088c2ecf20Sopenharmony_ci	__le32 __iomem *atio_q_out;
38098c2ecf20Sopenharmony_ci
38108c2ecf20Sopenharmony_ci	struct qla_tgt_func_tmpl *tgt_ops;
38118c2ecf20Sopenharmony_ci	struct qla_tgt_vp_map *tgt_vp_map;
38128c2ecf20Sopenharmony_ci
38138c2ecf20Sopenharmony_ci	int saved_set;
38148c2ecf20Sopenharmony_ci	__le16	saved_exchange_count;
38158c2ecf20Sopenharmony_ci	__le32	saved_firmware_options_1;
38168c2ecf20Sopenharmony_ci	__le32	saved_firmware_options_2;
38178c2ecf20Sopenharmony_ci	__le32	saved_firmware_options_3;
38188c2ecf20Sopenharmony_ci	uint8_t saved_firmware_options[2];
38198c2ecf20Sopenharmony_ci	uint8_t saved_add_firmware_options[2];
38208c2ecf20Sopenharmony_ci
38218c2ecf20Sopenharmony_ci	uint8_t tgt_node_name[WWN_SIZE];
38228c2ecf20Sopenharmony_ci
38238c2ecf20Sopenharmony_ci	struct dentry *dfs_tgt_sess;
38248c2ecf20Sopenharmony_ci	struct dentry *dfs_tgt_port_database;
38258c2ecf20Sopenharmony_ci	struct dentry *dfs_naqp;
38268c2ecf20Sopenharmony_ci
38278c2ecf20Sopenharmony_ci	struct list_head q_full_list;
38288c2ecf20Sopenharmony_ci	uint32_t num_pend_cmds;
38298c2ecf20Sopenharmony_ci	uint32_t num_qfull_cmds_alloc;
38308c2ecf20Sopenharmony_ci	uint32_t num_qfull_cmds_dropped;
38318c2ecf20Sopenharmony_ci	spinlock_t q_full_lock;
38328c2ecf20Sopenharmony_ci	uint32_t leak_exchg_thresh_hold;
38338c2ecf20Sopenharmony_ci	spinlock_t sess_lock;
38348c2ecf20Sopenharmony_ci	int num_act_qpairs;
38358c2ecf20Sopenharmony_ci#define DEFAULT_NAQP 2
38368c2ecf20Sopenharmony_ci	spinlock_t atio_lock ____cacheline_aligned;
38378c2ecf20Sopenharmony_ci	struct btree_head32 host_map;
38388c2ecf20Sopenharmony_ci};
38398c2ecf20Sopenharmony_ci
38408c2ecf20Sopenharmony_ci#define MAX_QFULL_CMDS_ALLOC	8192
38418c2ecf20Sopenharmony_ci#define Q_FULL_THRESH_HOLD_PERCENT 90
38428c2ecf20Sopenharmony_ci#define Q_FULL_THRESH_HOLD(ha) \
38438c2ecf20Sopenharmony_ci	((ha->cur_fw_xcb_count/100) * Q_FULL_THRESH_HOLD_PERCENT)
38448c2ecf20Sopenharmony_ci
38458c2ecf20Sopenharmony_ci#define LEAK_EXCHG_THRESH_HOLD_PERCENT 75	/* 75 percent */
38468c2ecf20Sopenharmony_ci
38478c2ecf20Sopenharmony_cistruct qla_hw_data_stat {
38488c2ecf20Sopenharmony_ci	u32 num_fw_dump;
38498c2ecf20Sopenharmony_ci	u32 num_mpi_reset;
38508c2ecf20Sopenharmony_ci};
38518c2ecf20Sopenharmony_ci
38528c2ecf20Sopenharmony_ci/* refer to pcie_do_recovery reference */
38538c2ecf20Sopenharmony_citypedef enum {
38548c2ecf20Sopenharmony_ci	QLA_PCI_RESUME,
38558c2ecf20Sopenharmony_ci	QLA_PCI_ERR_DETECTED,
38568c2ecf20Sopenharmony_ci	QLA_PCI_MMIO_ENABLED,
38578c2ecf20Sopenharmony_ci	QLA_PCI_SLOT_RESET,
38588c2ecf20Sopenharmony_ci} pci_error_state_t;
38598c2ecf20Sopenharmony_ci/*
38608c2ecf20Sopenharmony_ci * Qlogic host adapter specific data structure.
38618c2ecf20Sopenharmony_ci*/
38628c2ecf20Sopenharmony_cistruct qla_hw_data {
38638c2ecf20Sopenharmony_ci	struct pci_dev  *pdev;
38648c2ecf20Sopenharmony_ci	/* SRB cache. */
38658c2ecf20Sopenharmony_ci#define SRB_MIN_REQ     128
38668c2ecf20Sopenharmony_ci	mempool_t       *srb_mempool;
38678c2ecf20Sopenharmony_ci	u8 port_name[WWN_SIZE];
38688c2ecf20Sopenharmony_ci
38698c2ecf20Sopenharmony_ci	volatile struct {
38708c2ecf20Sopenharmony_ci		uint32_t	mbox_int		:1;
38718c2ecf20Sopenharmony_ci		uint32_t	mbox_busy		:1;
38728c2ecf20Sopenharmony_ci		uint32_t	disable_risc_code_load	:1;
38738c2ecf20Sopenharmony_ci		uint32_t	enable_64bit_addressing	:1;
38748c2ecf20Sopenharmony_ci		uint32_t	enable_lip_reset	:1;
38758c2ecf20Sopenharmony_ci		uint32_t	enable_target_reset	:1;
38768c2ecf20Sopenharmony_ci		uint32_t	enable_lip_full_login	:1;
38778c2ecf20Sopenharmony_ci		uint32_t	enable_led_scheme	:1;
38788c2ecf20Sopenharmony_ci
38798c2ecf20Sopenharmony_ci		uint32_t	msi_enabled		:1;
38808c2ecf20Sopenharmony_ci		uint32_t	msix_enabled		:1;
38818c2ecf20Sopenharmony_ci		uint32_t	disable_serdes		:1;
38828c2ecf20Sopenharmony_ci		uint32_t	gpsc_supported		:1;
38838c2ecf20Sopenharmony_ci		uint32_t	npiv_supported		:1;
38848c2ecf20Sopenharmony_ci		uint32_t	pci_channel_io_perm_failure	:1;
38858c2ecf20Sopenharmony_ci		uint32_t	fce_enabled		:1;
38868c2ecf20Sopenharmony_ci		uint32_t	fac_supported		:1;
38878c2ecf20Sopenharmony_ci
38888c2ecf20Sopenharmony_ci		uint32_t	chip_reset_done		:1;
38898c2ecf20Sopenharmony_ci		uint32_t	running_gold_fw		:1;
38908c2ecf20Sopenharmony_ci		uint32_t	eeh_busy		:1;
38918c2ecf20Sopenharmony_ci		uint32_t	disable_msix_handshake	:1;
38928c2ecf20Sopenharmony_ci		uint32_t	fcp_prio_enabled	:1;
38938c2ecf20Sopenharmony_ci		uint32_t	isp82xx_fw_hung:1;
38948c2ecf20Sopenharmony_ci		uint32_t	nic_core_hung:1;
38958c2ecf20Sopenharmony_ci
38968c2ecf20Sopenharmony_ci		uint32_t	quiesce_owner:1;
38978c2ecf20Sopenharmony_ci		uint32_t	nic_core_reset_hdlr_active:1;
38988c2ecf20Sopenharmony_ci		uint32_t	nic_core_reset_owner:1;
38998c2ecf20Sopenharmony_ci		uint32_t	isp82xx_no_md_cap:1;
39008c2ecf20Sopenharmony_ci		uint32_t	host_shutting_down:1;
39018c2ecf20Sopenharmony_ci		uint32_t	idc_compl_status:1;
39028c2ecf20Sopenharmony_ci		uint32_t        mr_reset_hdlr_active:1;
39038c2ecf20Sopenharmony_ci		uint32_t        mr_intr_valid:1;
39048c2ecf20Sopenharmony_ci
39058c2ecf20Sopenharmony_ci		uint32_t        dport_enabled:1;
39068c2ecf20Sopenharmony_ci		uint32_t	fawwpn_enabled:1;
39078c2ecf20Sopenharmony_ci		uint32_t	exlogins_enabled:1;
39088c2ecf20Sopenharmony_ci		uint32_t	exchoffld_enabled:1;
39098c2ecf20Sopenharmony_ci
39108c2ecf20Sopenharmony_ci		uint32_t	lip_ae:1;
39118c2ecf20Sopenharmony_ci		uint32_t	n2n_ae:1;
39128c2ecf20Sopenharmony_ci		uint32_t	fw_started:1;
39138c2ecf20Sopenharmony_ci		uint32_t	fw_init_done:1;
39148c2ecf20Sopenharmony_ci
39158c2ecf20Sopenharmony_ci		uint32_t	lr_detected:1;
39168c2ecf20Sopenharmony_ci
39178c2ecf20Sopenharmony_ci		uint32_t	rida_fmt2:1;
39188c2ecf20Sopenharmony_ci		uint32_t	purge_mbox:1;
39198c2ecf20Sopenharmony_ci		uint32_t        n2n_bigger:1;
39208c2ecf20Sopenharmony_ci		uint32_t	secure_adapter:1;
39218c2ecf20Sopenharmony_ci		uint32_t	secure_fw:1;
39228c2ecf20Sopenharmony_ci				/* Supported by Adapter */
39238c2ecf20Sopenharmony_ci		uint32_t	scm_supported_a:1;
39248c2ecf20Sopenharmony_ci				/* Supported by Firmware */
39258c2ecf20Sopenharmony_ci		uint32_t	scm_supported_f:1;
39268c2ecf20Sopenharmony_ci				/* Enabled in Driver */
39278c2ecf20Sopenharmony_ci		uint32_t	scm_enabled:1;
39288c2ecf20Sopenharmony_ci		uint32_t	plogi_template_valid:1;
39298c2ecf20Sopenharmony_ci	} flags;
39308c2ecf20Sopenharmony_ci
39318c2ecf20Sopenharmony_ci	uint16_t max_exchg;
39328c2ecf20Sopenharmony_ci	uint16_t lr_distance;	/* 32G & above */
39338c2ecf20Sopenharmony_ci#define LR_DISTANCE_5K  1
39348c2ecf20Sopenharmony_ci#define LR_DISTANCE_10K 0
39358c2ecf20Sopenharmony_ci
39368c2ecf20Sopenharmony_ci	/* This spinlock is used to protect "io transactions", you must
39378c2ecf20Sopenharmony_ci	* acquire it before doing any IO to the card, eg with RD_REG*() and
39388c2ecf20Sopenharmony_ci	* WRT_REG*() for the duration of your entire commandtransaction.
39398c2ecf20Sopenharmony_ci	*
39408c2ecf20Sopenharmony_ci	* This spinlock is of lower priority than the io request lock.
39418c2ecf20Sopenharmony_ci	*/
39428c2ecf20Sopenharmony_ci
39438c2ecf20Sopenharmony_ci	spinlock_t	hardware_lock ____cacheline_aligned;
39448c2ecf20Sopenharmony_ci	int		bars;
39458c2ecf20Sopenharmony_ci	int		mem_only;
39468c2ecf20Sopenharmony_ci	device_reg_t *iobase;           /* Base I/O address */
39478c2ecf20Sopenharmony_ci	resource_size_t pio_address;
39488c2ecf20Sopenharmony_ci
39498c2ecf20Sopenharmony_ci#define MIN_IOBASE_LEN          0x100
39508c2ecf20Sopenharmony_ci	dma_addr_t		bar0_hdl;
39518c2ecf20Sopenharmony_ci
39528c2ecf20Sopenharmony_ci	void __iomem *cregbase;
39538c2ecf20Sopenharmony_ci	dma_addr_t		bar2_hdl;
39548c2ecf20Sopenharmony_ci#define BAR0_LEN_FX00			(1024 * 1024)
39558c2ecf20Sopenharmony_ci#define BAR2_LEN_FX00			(128 * 1024)
39568c2ecf20Sopenharmony_ci
39578c2ecf20Sopenharmony_ci	uint32_t		rqstq_intr_code;
39588c2ecf20Sopenharmony_ci	uint32_t		mbx_intr_code;
39598c2ecf20Sopenharmony_ci	uint32_t		req_que_len;
39608c2ecf20Sopenharmony_ci	uint32_t		rsp_que_len;
39618c2ecf20Sopenharmony_ci	uint32_t		req_que_off;
39628c2ecf20Sopenharmony_ci	uint32_t		rsp_que_off;
39638c2ecf20Sopenharmony_ci
39648c2ecf20Sopenharmony_ci	/* Multi queue data structs */
39658c2ecf20Sopenharmony_ci	device_reg_t *mqiobase;
39668c2ecf20Sopenharmony_ci	device_reg_t *msixbase;
39678c2ecf20Sopenharmony_ci	uint16_t        msix_count;
39688c2ecf20Sopenharmony_ci	uint8_t         mqenable;
39698c2ecf20Sopenharmony_ci	struct req_que **req_q_map;
39708c2ecf20Sopenharmony_ci	struct rsp_que **rsp_q_map;
39718c2ecf20Sopenharmony_ci	struct qla_qpair **queue_pair_map;
39728c2ecf20Sopenharmony_ci	unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
39738c2ecf20Sopenharmony_ci	unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
39748c2ecf20Sopenharmony_ci	unsigned long qpair_qid_map[(QLA_MAX_QUEUES / 8)
39758c2ecf20Sopenharmony_ci		/ sizeof(unsigned long)];
39768c2ecf20Sopenharmony_ci	uint8_t 	max_req_queues;
39778c2ecf20Sopenharmony_ci	uint8_t 	max_rsp_queues;
39788c2ecf20Sopenharmony_ci	uint8_t		max_qpairs;
39798c2ecf20Sopenharmony_ci	uint8_t		num_qpairs;
39808c2ecf20Sopenharmony_ci	struct qla_qpair *base_qpair;
39818c2ecf20Sopenharmony_ci	struct qla_npiv_entry *npiv_info;
39828c2ecf20Sopenharmony_ci	uint16_t	nvram_npiv_size;
39838c2ecf20Sopenharmony_ci
39848c2ecf20Sopenharmony_ci	uint16_t        switch_cap;
39858c2ecf20Sopenharmony_ci#define FLOGI_SEQ_DEL           BIT_8
39868c2ecf20Sopenharmony_ci#define FLOGI_MID_SUPPORT       BIT_10
39878c2ecf20Sopenharmony_ci#define FLOGI_VSAN_SUPPORT      BIT_12
39888c2ecf20Sopenharmony_ci#define FLOGI_SP_SUPPORT        BIT_13
39898c2ecf20Sopenharmony_ci
39908c2ecf20Sopenharmony_ci	uint8_t		port_no;		/* Physical port of adapter */
39918c2ecf20Sopenharmony_ci	uint8_t		exch_starvation;
39928c2ecf20Sopenharmony_ci
39938c2ecf20Sopenharmony_ci	/* Timeout timers. */
39948c2ecf20Sopenharmony_ci	uint8_t 	loop_down_abort_time;    /* port down timer */
39958c2ecf20Sopenharmony_ci	atomic_t	loop_down_timer;         /* loop down timer */
39968c2ecf20Sopenharmony_ci	uint8_t		link_down_timeout;       /* link down timeout */
39978c2ecf20Sopenharmony_ci	uint16_t	max_loop_id;
39988c2ecf20Sopenharmony_ci	uint16_t	max_fibre_devices;	/* Maximum number of targets */
39998c2ecf20Sopenharmony_ci
40008c2ecf20Sopenharmony_ci	uint16_t	fb_rev;
40018c2ecf20Sopenharmony_ci	uint16_t	min_external_loopid;    /* First external loop Id */
40028c2ecf20Sopenharmony_ci
40038c2ecf20Sopenharmony_ci#define PORT_SPEED_UNKNOWN 0xFFFF
40048c2ecf20Sopenharmony_ci#define PORT_SPEED_1GB  0x00
40058c2ecf20Sopenharmony_ci#define PORT_SPEED_2GB  0x01
40068c2ecf20Sopenharmony_ci#define PORT_SPEED_AUTO 0x02
40078c2ecf20Sopenharmony_ci#define PORT_SPEED_4GB  0x03
40088c2ecf20Sopenharmony_ci#define PORT_SPEED_8GB  0x04
40098c2ecf20Sopenharmony_ci#define PORT_SPEED_16GB 0x05
40108c2ecf20Sopenharmony_ci#define PORT_SPEED_32GB 0x06
40118c2ecf20Sopenharmony_ci#define PORT_SPEED_64GB 0x07
40128c2ecf20Sopenharmony_ci#define PORT_SPEED_10GB	0x13
40138c2ecf20Sopenharmony_ci	uint16_t	link_data_rate;         /* F/W operating speed */
40148c2ecf20Sopenharmony_ci	uint16_t	set_data_rate;		/* Set by user */
40158c2ecf20Sopenharmony_ci
40168c2ecf20Sopenharmony_ci	uint8_t		current_topology;
40178c2ecf20Sopenharmony_ci	uint8_t		prev_topology;
40188c2ecf20Sopenharmony_ci#define ISP_CFG_NL	1
40198c2ecf20Sopenharmony_ci#define ISP_CFG_N	2
40208c2ecf20Sopenharmony_ci#define ISP_CFG_FL	4
40218c2ecf20Sopenharmony_ci#define ISP_CFG_F	8
40228c2ecf20Sopenharmony_ci
40238c2ecf20Sopenharmony_ci	uint8_t		operating_mode;         /* F/W operating mode */
40248c2ecf20Sopenharmony_ci#define LOOP      0
40258c2ecf20Sopenharmony_ci#define P2P       1
40268c2ecf20Sopenharmony_ci#define LOOP_P2P  2
40278c2ecf20Sopenharmony_ci#define P2P_LOOP  3
40288c2ecf20Sopenharmony_ci	uint8_t		interrupts_on;
40298c2ecf20Sopenharmony_ci	uint32_t	isp_abort_cnt;
40308c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2532    0x2532
40318c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8432    0x8432
40328c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8001	0x8001
40338c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8031	0x8031
40348c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2031	0x2031
40358c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2071	0x2071
40368c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2271	0x2271
40378c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2261	0x2261
40388c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2061	0x2061
40398c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2081	0x2081
40408c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2089	0x2089
40418c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2281	0x2281
40428c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP2289	0x2289
40438c2ecf20Sopenharmony_ci
40448c2ecf20Sopenharmony_ci	uint32_t	isp_type;
40458c2ecf20Sopenharmony_ci#define DT_ISP2100                      BIT_0
40468c2ecf20Sopenharmony_ci#define DT_ISP2200                      BIT_1
40478c2ecf20Sopenharmony_ci#define DT_ISP2300                      BIT_2
40488c2ecf20Sopenharmony_ci#define DT_ISP2312                      BIT_3
40498c2ecf20Sopenharmony_ci#define DT_ISP2322                      BIT_4
40508c2ecf20Sopenharmony_ci#define DT_ISP6312                      BIT_5
40518c2ecf20Sopenharmony_ci#define DT_ISP6322                      BIT_6
40528c2ecf20Sopenharmony_ci#define DT_ISP2422                      BIT_7
40538c2ecf20Sopenharmony_ci#define DT_ISP2432                      BIT_8
40548c2ecf20Sopenharmony_ci#define DT_ISP5422                      BIT_9
40558c2ecf20Sopenharmony_ci#define DT_ISP5432                      BIT_10
40568c2ecf20Sopenharmony_ci#define DT_ISP2532                      BIT_11
40578c2ecf20Sopenharmony_ci#define DT_ISP8432                      BIT_12
40588c2ecf20Sopenharmony_ci#define DT_ISP8001			BIT_13
40598c2ecf20Sopenharmony_ci#define DT_ISP8021			BIT_14
40608c2ecf20Sopenharmony_ci#define DT_ISP2031			BIT_15
40618c2ecf20Sopenharmony_ci#define DT_ISP8031			BIT_16
40628c2ecf20Sopenharmony_ci#define DT_ISPFX00			BIT_17
40638c2ecf20Sopenharmony_ci#define DT_ISP8044			BIT_18
40648c2ecf20Sopenharmony_ci#define DT_ISP2071			BIT_19
40658c2ecf20Sopenharmony_ci#define DT_ISP2271			BIT_20
40668c2ecf20Sopenharmony_ci#define DT_ISP2261			BIT_21
40678c2ecf20Sopenharmony_ci#define DT_ISP2061			BIT_22
40688c2ecf20Sopenharmony_ci#define DT_ISP2081			BIT_23
40698c2ecf20Sopenharmony_ci#define DT_ISP2089			BIT_24
40708c2ecf20Sopenharmony_ci#define DT_ISP2281			BIT_25
40718c2ecf20Sopenharmony_ci#define DT_ISP2289			BIT_26
40728c2ecf20Sopenharmony_ci#define DT_ISP_LAST			(DT_ISP2289 << 1)
40738c2ecf20Sopenharmony_ci
40748c2ecf20Sopenharmony_ci	uint32_t	device_type;
40758c2ecf20Sopenharmony_ci#define DT_T10_PI                       BIT_25
40768c2ecf20Sopenharmony_ci#define DT_IIDMA                        BIT_26
40778c2ecf20Sopenharmony_ci#define DT_FWI2                         BIT_27
40788c2ecf20Sopenharmony_ci#define DT_ZIO_SUPPORTED                BIT_28
40798c2ecf20Sopenharmony_ci#define DT_OEM_001                      BIT_29
40808c2ecf20Sopenharmony_ci#define DT_ISP2200A                     BIT_30
40818c2ecf20Sopenharmony_ci#define DT_EXTENDED_IDS                 BIT_31
40828c2ecf20Sopenharmony_ci
40838c2ecf20Sopenharmony_ci#define DT_MASK(ha)     ((ha)->isp_type & (DT_ISP_LAST - 1))
40848c2ecf20Sopenharmony_ci#define IS_QLA2100(ha)  (DT_MASK(ha) & DT_ISP2100)
40858c2ecf20Sopenharmony_ci#define IS_QLA2200(ha)  (DT_MASK(ha) & DT_ISP2200)
40868c2ecf20Sopenharmony_ci#define IS_QLA2300(ha)  (DT_MASK(ha) & DT_ISP2300)
40878c2ecf20Sopenharmony_ci#define IS_QLA2312(ha)  (DT_MASK(ha) & DT_ISP2312)
40888c2ecf20Sopenharmony_ci#define IS_QLA2322(ha)  (DT_MASK(ha) & DT_ISP2322)
40898c2ecf20Sopenharmony_ci#define IS_QLA6312(ha)  (DT_MASK(ha) & DT_ISP6312)
40908c2ecf20Sopenharmony_ci#define IS_QLA6322(ha)  (DT_MASK(ha) & DT_ISP6322)
40918c2ecf20Sopenharmony_ci#define IS_QLA2422(ha)  (DT_MASK(ha) & DT_ISP2422)
40928c2ecf20Sopenharmony_ci#define IS_QLA2432(ha)  (DT_MASK(ha) & DT_ISP2432)
40938c2ecf20Sopenharmony_ci#define IS_QLA5422(ha)  (DT_MASK(ha) & DT_ISP5422)
40948c2ecf20Sopenharmony_ci#define IS_QLA5432(ha)  (DT_MASK(ha) & DT_ISP5432)
40958c2ecf20Sopenharmony_ci#define IS_QLA2532(ha)  (DT_MASK(ha) & DT_ISP2532)
40968c2ecf20Sopenharmony_ci#define IS_QLA8432(ha)  (DT_MASK(ha) & DT_ISP8432)
40978c2ecf20Sopenharmony_ci#define IS_QLA8001(ha)	(DT_MASK(ha) & DT_ISP8001)
40988c2ecf20Sopenharmony_ci#define IS_QLA81XX(ha)	(IS_QLA8001(ha))
40998c2ecf20Sopenharmony_ci#define IS_QLA82XX(ha)	(DT_MASK(ha) & DT_ISP8021)
41008c2ecf20Sopenharmony_ci#define IS_QLA8044(ha)  (DT_MASK(ha) & DT_ISP8044)
41018c2ecf20Sopenharmony_ci#define IS_QLA2031(ha)	(DT_MASK(ha) & DT_ISP2031)
41028c2ecf20Sopenharmony_ci#define IS_QLA8031(ha)	(DT_MASK(ha) & DT_ISP8031)
41038c2ecf20Sopenharmony_ci#define IS_QLAFX00(ha)	(DT_MASK(ha) & DT_ISPFX00)
41048c2ecf20Sopenharmony_ci#define IS_QLA2071(ha)	(DT_MASK(ha) & DT_ISP2071)
41058c2ecf20Sopenharmony_ci#define IS_QLA2271(ha)	(DT_MASK(ha) & DT_ISP2271)
41068c2ecf20Sopenharmony_ci#define IS_QLA2261(ha)	(DT_MASK(ha) & DT_ISP2261)
41078c2ecf20Sopenharmony_ci#define IS_QLA2081(ha)	(DT_MASK(ha) & DT_ISP2081)
41088c2ecf20Sopenharmony_ci#define IS_QLA2281(ha)	(DT_MASK(ha) & DT_ISP2281)
41098c2ecf20Sopenharmony_ci
41108c2ecf20Sopenharmony_ci#define IS_QLA23XX(ha)  (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
41118c2ecf20Sopenharmony_ci			IS_QLA6312(ha) || IS_QLA6322(ha))
41128c2ecf20Sopenharmony_ci#define IS_QLA24XX(ha)  (IS_QLA2422(ha) || IS_QLA2432(ha))
41138c2ecf20Sopenharmony_ci#define IS_QLA54XX(ha)  (IS_QLA5422(ha) || IS_QLA5432(ha))
41148c2ecf20Sopenharmony_ci#define IS_QLA25XX(ha)  (IS_QLA2532(ha))
41158c2ecf20Sopenharmony_ci#define IS_QLA83XX(ha)	(IS_QLA2031(ha) || IS_QLA8031(ha))
41168c2ecf20Sopenharmony_ci#define IS_QLA84XX(ha)  (IS_QLA8432(ha))
41178c2ecf20Sopenharmony_ci#define IS_QLA27XX(ha)  (IS_QLA2071(ha) || IS_QLA2271(ha) || IS_QLA2261(ha))
41188c2ecf20Sopenharmony_ci#define IS_QLA28XX(ha)	(IS_QLA2081(ha) || IS_QLA2281(ha))
41198c2ecf20Sopenharmony_ci#define IS_QLA24XX_TYPE(ha)     (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
41208c2ecf20Sopenharmony_ci				IS_QLA84XX(ha))
41218c2ecf20Sopenharmony_ci#define IS_CNA_CAPABLE(ha)	(IS_QLA81XX(ha) || IS_QLA82XX(ha) || \
41228c2ecf20Sopenharmony_ci				IS_QLA8031(ha) || IS_QLA8044(ha))
41238c2ecf20Sopenharmony_ci#define IS_P3P_TYPE(ha)		(IS_QLA82XX(ha) || IS_QLA8044(ha))
41248c2ecf20Sopenharmony_ci#define IS_QLA2XXX_MIDTYPE(ha)	(IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
41258c2ecf20Sopenharmony_ci				IS_QLA25XX(ha) || IS_QLA81XX(ha) || \
41268c2ecf20Sopenharmony_ci				IS_QLA82XX(ha) || IS_QLA83XX(ha) || \
41278c2ecf20Sopenharmony_ci				IS_QLA8044(ha) || IS_QLA27XX(ha) || \
41288c2ecf20Sopenharmony_ci				IS_QLA28XX(ha))
41298c2ecf20Sopenharmony_ci#define IS_MSIX_NACK_CAPABLE(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha) || \
41308c2ecf20Sopenharmony_ci				IS_QLA27XX(ha) || IS_QLA28XX(ha))
41318c2ecf20Sopenharmony_ci#define IS_NOPOLLING_TYPE(ha)	(IS_QLA81XX(ha) && (ha)->flags.msix_enabled)
41328c2ecf20Sopenharmony_ci#define IS_FAC_REQUIRED(ha)	(IS_QLA81XX(ha) || IS_QLA83XX(ha) || \
41338c2ecf20Sopenharmony_ci				IS_QLA27XX(ha) || IS_QLA28XX(ha))
41348c2ecf20Sopenharmony_ci#define IS_NOCACHE_VPD_TYPE(ha)	(IS_QLA81XX(ha) || IS_QLA83XX(ha) || \
41358c2ecf20Sopenharmony_ci				IS_QLA27XX(ha) || IS_QLA28XX(ha))
41368c2ecf20Sopenharmony_ci#define IS_ALOGIO_CAPABLE(ha)	(IS_QLA23XX(ha) || IS_FWI2_CAPABLE(ha))
41378c2ecf20Sopenharmony_ci
41388c2ecf20Sopenharmony_ci#define IS_T10_PI_CAPABLE(ha)   ((ha)->device_type & DT_T10_PI)
41398c2ecf20Sopenharmony_ci#define IS_IIDMA_CAPABLE(ha)    ((ha)->device_type & DT_IIDMA)
41408c2ecf20Sopenharmony_ci#define IS_FWI2_CAPABLE(ha)     ((ha)->device_type & DT_FWI2)
41418c2ecf20Sopenharmony_ci#define IS_ZIO_SUPPORTED(ha)    ((ha)->device_type & DT_ZIO_SUPPORTED)
41428c2ecf20Sopenharmony_ci#define IS_OEM_001(ha)          ((ha)->device_type & DT_OEM_001)
41438c2ecf20Sopenharmony_ci#define HAS_EXTENDED_IDS(ha)    ((ha)->device_type & DT_EXTENDED_IDS)
41448c2ecf20Sopenharmony_ci#define IS_CT6_SUPPORTED(ha)	((ha)->device_type & DT_CT6_SUPPORTED)
41458c2ecf20Sopenharmony_ci#define IS_MQUE_CAPABLE(ha)	(IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
41468c2ecf20Sopenharmony_ci				 IS_QLA28XX(ha))
41478c2ecf20Sopenharmony_ci#define IS_BIDI_CAPABLE(ha) \
41488c2ecf20Sopenharmony_ci    (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
41498c2ecf20Sopenharmony_ci/* Bit 21 of fw_attributes decides the MCTP capabilities */
41508c2ecf20Sopenharmony_ci#define IS_MCTP_CAPABLE(ha)	(IS_QLA2031(ha) && \
41518c2ecf20Sopenharmony_ci				((ha)->fw_attributes_ext[0] & BIT_0))
41528c2ecf20Sopenharmony_ci#define IS_PI_UNINIT_CAPABLE(ha)	(IS_QLA83XX(ha) || IS_QLA27XX(ha))
41538c2ecf20Sopenharmony_ci#define IS_PI_IPGUARD_CAPABLE(ha)	(IS_QLA83XX(ha) || IS_QLA27XX(ha))
41548c2ecf20Sopenharmony_ci#define IS_PI_DIFB_DIX0_CAPABLE(ha)	(0)
41558c2ecf20Sopenharmony_ci#define IS_PI_SPLIT_DET_CAPABLE_HBA(ha)	(IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
41568c2ecf20Sopenharmony_ci					IS_QLA28XX(ha))
41578c2ecf20Sopenharmony_ci#define IS_PI_SPLIT_DET_CAPABLE(ha)	(IS_PI_SPLIT_DET_CAPABLE_HBA(ha) && \
41588c2ecf20Sopenharmony_ci    (((ha)->fw_attributes_h << 16 | (ha)->fw_attributes) & BIT_22))
41598c2ecf20Sopenharmony_ci#define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
41608c2ecf20Sopenharmony_ci				IS_QLA28XX(ha))
41618c2ecf20Sopenharmony_ci#define IS_TGT_MODE_CAPABLE(ha)	(ha->tgt.atio_q_length)
41628c2ecf20Sopenharmony_ci#define IS_SHADOW_REG_CAPABLE(ha)  (IS_QLA27XX(ha) || IS_QLA28XX(ha))
41638c2ecf20Sopenharmony_ci#define IS_DPORT_CAPABLE(ha)  (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
41648c2ecf20Sopenharmony_ci				IS_QLA28XX(ha))
41658c2ecf20Sopenharmony_ci#define IS_FAWWN_CAPABLE(ha)	(IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
41668c2ecf20Sopenharmony_ci				IS_QLA28XX(ha))
41678c2ecf20Sopenharmony_ci#define IS_EXCHG_OFFLD_CAPABLE(ha) \
41688c2ecf20Sopenharmony_ci	(IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
41698c2ecf20Sopenharmony_ci#define IS_EXLOGIN_OFFLD_CAPABLE(ha) \
41708c2ecf20Sopenharmony_ci	(IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || \
41718c2ecf20Sopenharmony_ci	 IS_QLA27XX(ha) || IS_QLA28XX(ha))
41728c2ecf20Sopenharmony_ci#define USE_ASYNC_SCAN(ha) (IS_QLA25XX(ha) || IS_QLA81XX(ha) ||\
41738c2ecf20Sopenharmony_ci	IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
41748c2ecf20Sopenharmony_ci
41758c2ecf20Sopenharmony_ci#define IS_ZIO_THRESHOLD_CAPABLE(ha) \
41768c2ecf20Sopenharmony_ci	((IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&\
41778c2ecf20Sopenharmony_ci	 (ha->zio_mode == QLA_ZIO_MODE_6))
41788c2ecf20Sopenharmony_ci
41798c2ecf20Sopenharmony_ci	/* HBA serial number */
41808c2ecf20Sopenharmony_ci	uint8_t		serial0;
41818c2ecf20Sopenharmony_ci	uint8_t		serial1;
41828c2ecf20Sopenharmony_ci	uint8_t		serial2;
41838c2ecf20Sopenharmony_ci
41848c2ecf20Sopenharmony_ci	/* NVRAM configuration data */
41858c2ecf20Sopenharmony_ci#define MAX_NVRAM_SIZE  4096
41868c2ecf20Sopenharmony_ci#define VPD_OFFSET      (MAX_NVRAM_SIZE / 2)
41878c2ecf20Sopenharmony_ci	uint16_t	nvram_size;
41888c2ecf20Sopenharmony_ci	uint16_t	nvram_base;
41898c2ecf20Sopenharmony_ci	void		*nvram;
41908c2ecf20Sopenharmony_ci	uint16_t	vpd_size;
41918c2ecf20Sopenharmony_ci	uint16_t	vpd_base;
41928c2ecf20Sopenharmony_ci	void		*vpd;
41938c2ecf20Sopenharmony_ci
41948c2ecf20Sopenharmony_ci	uint16_t	loop_reset_delay;
41958c2ecf20Sopenharmony_ci	uint8_t		retry_count;
41968c2ecf20Sopenharmony_ci	uint8_t		login_timeout;
41978c2ecf20Sopenharmony_ci	uint16_t	r_a_tov;
41988c2ecf20Sopenharmony_ci	int		port_down_retry_count;
41998c2ecf20Sopenharmony_ci	uint8_t		mbx_count;
42008c2ecf20Sopenharmony_ci	uint8_t		aen_mbx_count;
42018c2ecf20Sopenharmony_ci	atomic_t	num_pend_mbx_stage1;
42028c2ecf20Sopenharmony_ci	atomic_t	num_pend_mbx_stage2;
42038c2ecf20Sopenharmony_ci	uint16_t	frame_payload_size;
42048c2ecf20Sopenharmony_ci
42058c2ecf20Sopenharmony_ci	uint32_t	login_retry_count;
42068c2ecf20Sopenharmony_ci	/* SNS command interfaces. */
42078c2ecf20Sopenharmony_ci	ms_iocb_entry_t		*ms_iocb;
42088c2ecf20Sopenharmony_ci	dma_addr_t		ms_iocb_dma;
42098c2ecf20Sopenharmony_ci	struct ct_sns_pkt	*ct_sns;
42108c2ecf20Sopenharmony_ci	dma_addr_t		ct_sns_dma;
42118c2ecf20Sopenharmony_ci	/* SNS command interfaces for 2200. */
42128c2ecf20Sopenharmony_ci	struct sns_cmd_pkt	*sns_cmd;
42138c2ecf20Sopenharmony_ci	dma_addr_t		sns_cmd_dma;
42148c2ecf20Sopenharmony_ci
42158c2ecf20Sopenharmony_ci#define SFP_DEV_SIZE    512
42168c2ecf20Sopenharmony_ci#define SFP_BLOCK_SIZE  64
42178c2ecf20Sopenharmony_ci#define SFP_RTDI_LEN	SFP_BLOCK_SIZE
42188c2ecf20Sopenharmony_ci
42198c2ecf20Sopenharmony_ci	void		*sfp_data;
42208c2ecf20Sopenharmony_ci	dma_addr_t	sfp_data_dma;
42218c2ecf20Sopenharmony_ci
42228c2ecf20Sopenharmony_ci	struct qla_flt_header *flt;
42238c2ecf20Sopenharmony_ci	dma_addr_t	flt_dma;
42248c2ecf20Sopenharmony_ci
42258c2ecf20Sopenharmony_ci#define XGMAC_DATA_SIZE	4096
42268c2ecf20Sopenharmony_ci	void		*xgmac_data;
42278c2ecf20Sopenharmony_ci	dma_addr_t	xgmac_data_dma;
42288c2ecf20Sopenharmony_ci
42298c2ecf20Sopenharmony_ci#define DCBX_TLV_DATA_SIZE 4096
42308c2ecf20Sopenharmony_ci	void		*dcbx_tlv;
42318c2ecf20Sopenharmony_ci	dma_addr_t	dcbx_tlv_dma;
42328c2ecf20Sopenharmony_ci
42338c2ecf20Sopenharmony_ci	struct task_struct	*dpc_thread;
42348c2ecf20Sopenharmony_ci	uint8_t dpc_active;                  /* DPC routine is active */
42358c2ecf20Sopenharmony_ci
42368c2ecf20Sopenharmony_ci	dma_addr_t	gid_list_dma;
42378c2ecf20Sopenharmony_ci	struct gid_list_info *gid_list;
42388c2ecf20Sopenharmony_ci	int		gid_list_info_size;
42398c2ecf20Sopenharmony_ci
42408c2ecf20Sopenharmony_ci	/* Small DMA pool allocations -- maximum 256 bytes in length. */
42418c2ecf20Sopenharmony_ci#define DMA_POOL_SIZE   256
42428c2ecf20Sopenharmony_ci	struct dma_pool *s_dma_pool;
42438c2ecf20Sopenharmony_ci
42448c2ecf20Sopenharmony_ci	dma_addr_t	init_cb_dma;
42458c2ecf20Sopenharmony_ci	init_cb_t	*init_cb;
42468c2ecf20Sopenharmony_ci	int		init_cb_size;
42478c2ecf20Sopenharmony_ci	dma_addr_t	ex_init_cb_dma;
42488c2ecf20Sopenharmony_ci	struct ex_init_cb_81xx *ex_init_cb;
42498c2ecf20Sopenharmony_ci	dma_addr_t	sf_init_cb_dma;
42508c2ecf20Sopenharmony_ci	struct init_sf_cb *sf_init_cb;
42518c2ecf20Sopenharmony_ci
42528c2ecf20Sopenharmony_ci	void		*scm_fpin_els_buff;
42538c2ecf20Sopenharmony_ci	uint64_t	scm_fpin_els_buff_size;
42548c2ecf20Sopenharmony_ci	bool		scm_fpin_valid;
42558c2ecf20Sopenharmony_ci	bool		scm_fpin_payload_size;
42568c2ecf20Sopenharmony_ci
42578c2ecf20Sopenharmony_ci	void		*async_pd;
42588c2ecf20Sopenharmony_ci	dma_addr_t	async_pd_dma;
42598c2ecf20Sopenharmony_ci
42608c2ecf20Sopenharmony_ci#define ENABLE_EXTENDED_LOGIN	BIT_7
42618c2ecf20Sopenharmony_ci
42628c2ecf20Sopenharmony_ci	/* Extended Logins  */
42638c2ecf20Sopenharmony_ci	void		*exlogin_buf;
42648c2ecf20Sopenharmony_ci	dma_addr_t	exlogin_buf_dma;
42658c2ecf20Sopenharmony_ci	uint32_t	exlogin_size;
42668c2ecf20Sopenharmony_ci
42678c2ecf20Sopenharmony_ci#define ENABLE_EXCHANGE_OFFLD	BIT_2
42688c2ecf20Sopenharmony_ci
42698c2ecf20Sopenharmony_ci	/* Exchange Offload */
42708c2ecf20Sopenharmony_ci	void		*exchoffld_buf;
42718c2ecf20Sopenharmony_ci	dma_addr_t	exchoffld_buf_dma;
42728c2ecf20Sopenharmony_ci	int		exchoffld_size;
42738c2ecf20Sopenharmony_ci	int 		exchoffld_count;
42748c2ecf20Sopenharmony_ci
42758c2ecf20Sopenharmony_ci	/* n2n */
42768c2ecf20Sopenharmony_ci	struct fc_els_flogi plogi_els_payld;
42778c2ecf20Sopenharmony_ci#define LOGIN_TEMPLATE_SIZE (sizeof(struct fc_els_flogi) - 4)
42788c2ecf20Sopenharmony_ci
42798c2ecf20Sopenharmony_ci	void            *swl;
42808c2ecf20Sopenharmony_ci
42818c2ecf20Sopenharmony_ci	/* These are used by mailbox operations. */
42828c2ecf20Sopenharmony_ci	uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
42838c2ecf20Sopenharmony_ci	uint32_t mailbox_out32[MAILBOX_REGISTER_COUNT];
42848c2ecf20Sopenharmony_ci	uint32_t aenmb[AEN_MAILBOX_REGISTER_COUNT_FX00];
42858c2ecf20Sopenharmony_ci
42868c2ecf20Sopenharmony_ci	mbx_cmd_t	*mcp;
42878c2ecf20Sopenharmony_ci	struct mbx_cmd_32	*mcp32;
42888c2ecf20Sopenharmony_ci
42898c2ecf20Sopenharmony_ci	unsigned long	mbx_cmd_flags;
42908c2ecf20Sopenharmony_ci#define MBX_INTERRUPT		1
42918c2ecf20Sopenharmony_ci#define MBX_INTR_WAIT		2
42928c2ecf20Sopenharmony_ci#define MBX_UPDATE_FLASH_ACTIVE	3
42938c2ecf20Sopenharmony_ci
42948c2ecf20Sopenharmony_ci	struct mutex vport_lock;        /* Virtual port synchronization */
42958c2ecf20Sopenharmony_ci	spinlock_t vport_slock; /* order is hardware_lock, then vport_slock */
42968c2ecf20Sopenharmony_ci	struct mutex mq_lock;        /* multi-queue synchronization */
42978c2ecf20Sopenharmony_ci	struct completion mbx_cmd_comp; /* Serialize mbx access */
42988c2ecf20Sopenharmony_ci	struct completion mbx_intr_comp;  /* Used for completion notification */
42998c2ecf20Sopenharmony_ci	struct completion dcbx_comp;	/* For set port config notification */
43008c2ecf20Sopenharmony_ci	struct completion lb_portup_comp; /* Used to wait for link up during
43018c2ecf20Sopenharmony_ci					   * loopback */
43028c2ecf20Sopenharmony_ci#define DCBX_COMP_TIMEOUT	20
43038c2ecf20Sopenharmony_ci#define LB_PORTUP_COMP_TIMEOUT	10
43048c2ecf20Sopenharmony_ci
43058c2ecf20Sopenharmony_ci	int notify_dcbx_comp;
43068c2ecf20Sopenharmony_ci	int notify_lb_portup_comp;
43078c2ecf20Sopenharmony_ci	struct mutex selflogin_lock;
43088c2ecf20Sopenharmony_ci
43098c2ecf20Sopenharmony_ci	/* Basic firmware related information. */
43108c2ecf20Sopenharmony_ci	uint16_t	fw_major_version;
43118c2ecf20Sopenharmony_ci	uint16_t	fw_minor_version;
43128c2ecf20Sopenharmony_ci	uint16_t	fw_subminor_version;
43138c2ecf20Sopenharmony_ci	uint16_t	fw_attributes;
43148c2ecf20Sopenharmony_ci	uint16_t	fw_attributes_h;
43158c2ecf20Sopenharmony_ci#define FW_ATTR_H_NVME_FBURST 	BIT_1
43168c2ecf20Sopenharmony_ci#define FW_ATTR_H_NVME		BIT_10
43178c2ecf20Sopenharmony_ci#define FW_ATTR_H_NVME_UPDATED  BIT_14
43188c2ecf20Sopenharmony_ci
43198c2ecf20Sopenharmony_ci	/* About firmware SCM support */
43208c2ecf20Sopenharmony_ci#define FW_ATTR_EXT0_SCM_SUPPORTED	BIT_12
43218c2ecf20Sopenharmony_ci	/* Brocade fabric attached */
43228c2ecf20Sopenharmony_ci#define FW_ATTR_EXT0_SCM_BROCADE	0x00001000
43238c2ecf20Sopenharmony_ci	/* Cisco fabric attached */
43248c2ecf20Sopenharmony_ci#define FW_ATTR_EXT0_SCM_CISCO		0x00002000
43258c2ecf20Sopenharmony_ci#define FW_ATTR_EXT0_NVME2	BIT_13
43268c2ecf20Sopenharmony_ci	uint16_t	fw_attributes_ext[2];
43278c2ecf20Sopenharmony_ci	uint32_t	fw_memory_size;
43288c2ecf20Sopenharmony_ci	uint32_t	fw_transfer_size;
43298c2ecf20Sopenharmony_ci	uint32_t	fw_srisc_address;
43308c2ecf20Sopenharmony_ci#define RISC_START_ADDRESS_2100 0x1000
43318c2ecf20Sopenharmony_ci#define RISC_START_ADDRESS_2300 0x800
43328c2ecf20Sopenharmony_ci#define RISC_START_ADDRESS_2400 0x100000
43338c2ecf20Sopenharmony_ci
43348c2ecf20Sopenharmony_ci	uint16_t	orig_fw_tgt_xcb_count;
43358c2ecf20Sopenharmony_ci	uint16_t	cur_fw_tgt_xcb_count;
43368c2ecf20Sopenharmony_ci	uint16_t	orig_fw_xcb_count;
43378c2ecf20Sopenharmony_ci	uint16_t	cur_fw_xcb_count;
43388c2ecf20Sopenharmony_ci	uint16_t	orig_fw_iocb_count;
43398c2ecf20Sopenharmony_ci	uint16_t	cur_fw_iocb_count;
43408c2ecf20Sopenharmony_ci	uint16_t	fw_max_fcf_count;
43418c2ecf20Sopenharmony_ci
43428c2ecf20Sopenharmony_ci	uint32_t	fw_shared_ram_start;
43438c2ecf20Sopenharmony_ci	uint32_t	fw_shared_ram_end;
43448c2ecf20Sopenharmony_ci	uint32_t	fw_ddr_ram_start;
43458c2ecf20Sopenharmony_ci	uint32_t	fw_ddr_ram_end;
43468c2ecf20Sopenharmony_ci
43478c2ecf20Sopenharmony_ci	uint16_t	fw_options[16];         /* slots: 1,2,3,10,11 */
43488c2ecf20Sopenharmony_ci	uint8_t		fw_seriallink_options[4];
43498c2ecf20Sopenharmony_ci	__le16		fw_seriallink_options24[4];
43508c2ecf20Sopenharmony_ci
43518c2ecf20Sopenharmony_ci	uint8_t		serdes_version[3];
43528c2ecf20Sopenharmony_ci	uint8_t		mpi_version[3];
43538c2ecf20Sopenharmony_ci	uint32_t	mpi_capabilities;
43548c2ecf20Sopenharmony_ci	uint8_t		phy_version[3];
43558c2ecf20Sopenharmony_ci	uint8_t		pep_version[3];
43568c2ecf20Sopenharmony_ci
43578c2ecf20Sopenharmony_ci	/* Firmware dump template */
43588c2ecf20Sopenharmony_ci	struct fwdt {
43598c2ecf20Sopenharmony_ci		void *template;
43608c2ecf20Sopenharmony_ci		ulong length;
43618c2ecf20Sopenharmony_ci		ulong dump_size;
43628c2ecf20Sopenharmony_ci	} fwdt[2];
43638c2ecf20Sopenharmony_ci	struct qla2xxx_fw_dump *fw_dump;
43648c2ecf20Sopenharmony_ci	uint32_t	fw_dump_len;
43658c2ecf20Sopenharmony_ci	u32		fw_dump_alloc_len;
43668c2ecf20Sopenharmony_ci	bool		fw_dumped;
43678c2ecf20Sopenharmony_ci	unsigned long	fw_dump_cap_flags;
43688c2ecf20Sopenharmony_ci#define RISC_PAUSE_CMPL		0
43698c2ecf20Sopenharmony_ci#define DMA_SHUTDOWN_CMPL	1
43708c2ecf20Sopenharmony_ci#define ISP_RESET_CMPL		2
43718c2ecf20Sopenharmony_ci#define RISC_RDY_AFT_RESET	3
43728c2ecf20Sopenharmony_ci#define RISC_SRAM_DUMP_CMPL	4
43738c2ecf20Sopenharmony_ci#define RISC_EXT_MEM_DUMP_CMPL	5
43748c2ecf20Sopenharmony_ci#define ISP_MBX_RDY		6
43758c2ecf20Sopenharmony_ci#define ISP_SOFT_RESET_CMPL	7
43768c2ecf20Sopenharmony_ci	int		fw_dump_reading;
43778c2ecf20Sopenharmony_ci	void		*mpi_fw_dump;
43788c2ecf20Sopenharmony_ci	u32		mpi_fw_dump_len;
43798c2ecf20Sopenharmony_ci	unsigned int	mpi_fw_dump_reading:1;
43808c2ecf20Sopenharmony_ci	unsigned int	mpi_fw_dumped:1;
43818c2ecf20Sopenharmony_ci	int		prev_minidump_failed;
43828c2ecf20Sopenharmony_ci	dma_addr_t	eft_dma;
43838c2ecf20Sopenharmony_ci	void		*eft;
43848c2ecf20Sopenharmony_ci/* Current size of mctp dump is 0x086064 bytes */
43858c2ecf20Sopenharmony_ci#define MCTP_DUMP_SIZE  0x086064
43868c2ecf20Sopenharmony_ci	dma_addr_t	mctp_dump_dma;
43878c2ecf20Sopenharmony_ci	void		*mctp_dump;
43888c2ecf20Sopenharmony_ci	int		mctp_dumped;
43898c2ecf20Sopenharmony_ci	int		mctp_dump_reading;
43908c2ecf20Sopenharmony_ci	uint32_t	chain_offset;
43918c2ecf20Sopenharmony_ci	struct dentry *dfs_dir;
43928c2ecf20Sopenharmony_ci	struct dentry *dfs_fce;
43938c2ecf20Sopenharmony_ci	struct dentry *dfs_tgt_counters;
43948c2ecf20Sopenharmony_ci	struct dentry *dfs_fw_resource_cnt;
43958c2ecf20Sopenharmony_ci
43968c2ecf20Sopenharmony_ci	dma_addr_t	fce_dma;
43978c2ecf20Sopenharmony_ci	void		*fce;
43988c2ecf20Sopenharmony_ci	uint32_t	fce_bufs;
43998c2ecf20Sopenharmony_ci	uint16_t	fce_mb[8];
44008c2ecf20Sopenharmony_ci	uint64_t	fce_wr, fce_rd;
44018c2ecf20Sopenharmony_ci	struct mutex	fce_mutex;
44028c2ecf20Sopenharmony_ci
44038c2ecf20Sopenharmony_ci	uint32_t	pci_attr;
44048c2ecf20Sopenharmony_ci	uint16_t	chip_revision;
44058c2ecf20Sopenharmony_ci
44068c2ecf20Sopenharmony_ci	uint16_t	product_id[4];
44078c2ecf20Sopenharmony_ci
44088c2ecf20Sopenharmony_ci	uint8_t		model_number[16+1];
44098c2ecf20Sopenharmony_ci	char		model_desc[80];
44108c2ecf20Sopenharmony_ci	uint8_t		adapter_id[16+1];
44118c2ecf20Sopenharmony_ci
44128c2ecf20Sopenharmony_ci	/* Option ROM information. */
44138c2ecf20Sopenharmony_ci	char		*optrom_buffer;
44148c2ecf20Sopenharmony_ci	uint32_t	optrom_size;
44158c2ecf20Sopenharmony_ci	int		optrom_state;
44168c2ecf20Sopenharmony_ci#define QLA_SWAITING	0
44178c2ecf20Sopenharmony_ci#define QLA_SREADING	1
44188c2ecf20Sopenharmony_ci#define QLA_SWRITING	2
44198c2ecf20Sopenharmony_ci	uint32_t	optrom_region_start;
44208c2ecf20Sopenharmony_ci	uint32_t	optrom_region_size;
44218c2ecf20Sopenharmony_ci	struct mutex	optrom_mutex;
44228c2ecf20Sopenharmony_ci
44238c2ecf20Sopenharmony_ci/* PCI expansion ROM image information. */
44248c2ecf20Sopenharmony_ci#define ROM_CODE_TYPE_BIOS	0
44258c2ecf20Sopenharmony_ci#define ROM_CODE_TYPE_FCODE	1
44268c2ecf20Sopenharmony_ci#define ROM_CODE_TYPE_EFI	3
44278c2ecf20Sopenharmony_ci	uint8_t 	bios_revision[2];
44288c2ecf20Sopenharmony_ci	uint8_t 	efi_revision[2];
44298c2ecf20Sopenharmony_ci	uint8_t 	fcode_revision[16];
44308c2ecf20Sopenharmony_ci	uint32_t	fw_revision[4];
44318c2ecf20Sopenharmony_ci
44328c2ecf20Sopenharmony_ci	uint32_t	gold_fw_version[4];
44338c2ecf20Sopenharmony_ci
44348c2ecf20Sopenharmony_ci	/* Offsets for flash/nvram access (set to ~0 if not used). */
44358c2ecf20Sopenharmony_ci	uint32_t	flash_conf_off;
44368c2ecf20Sopenharmony_ci	uint32_t	flash_data_off;
44378c2ecf20Sopenharmony_ci	uint32_t	nvram_conf_off;
44388c2ecf20Sopenharmony_ci	uint32_t	nvram_data_off;
44398c2ecf20Sopenharmony_ci
44408c2ecf20Sopenharmony_ci	uint32_t	fdt_wrt_disable;
44418c2ecf20Sopenharmony_ci	uint32_t	fdt_wrt_enable;
44428c2ecf20Sopenharmony_ci	uint32_t	fdt_erase_cmd;
44438c2ecf20Sopenharmony_ci	uint32_t	fdt_block_size;
44448c2ecf20Sopenharmony_ci	uint32_t	fdt_unprotect_sec_cmd;
44458c2ecf20Sopenharmony_ci	uint32_t	fdt_protect_sec_cmd;
44468c2ecf20Sopenharmony_ci	uint32_t	fdt_wrt_sts_reg_cmd;
44478c2ecf20Sopenharmony_ci
44488c2ecf20Sopenharmony_ci	struct {
44498c2ecf20Sopenharmony_ci		uint32_t	flt_region_flt;
44508c2ecf20Sopenharmony_ci		uint32_t	flt_region_fdt;
44518c2ecf20Sopenharmony_ci		uint32_t	flt_region_boot;
44528c2ecf20Sopenharmony_ci		uint32_t	flt_region_boot_sec;
44538c2ecf20Sopenharmony_ci		uint32_t	flt_region_fw;
44548c2ecf20Sopenharmony_ci		uint32_t	flt_region_fw_sec;
44558c2ecf20Sopenharmony_ci		uint32_t	flt_region_vpd_nvram;
44568c2ecf20Sopenharmony_ci		uint32_t	flt_region_vpd_nvram_sec;
44578c2ecf20Sopenharmony_ci		uint32_t	flt_region_vpd;
44588c2ecf20Sopenharmony_ci		uint32_t	flt_region_vpd_sec;
44598c2ecf20Sopenharmony_ci		uint32_t	flt_region_nvram;
44608c2ecf20Sopenharmony_ci		uint32_t	flt_region_nvram_sec;
44618c2ecf20Sopenharmony_ci		uint32_t	flt_region_npiv_conf;
44628c2ecf20Sopenharmony_ci		uint32_t	flt_region_gold_fw;
44638c2ecf20Sopenharmony_ci		uint32_t	flt_region_fcp_prio;
44648c2ecf20Sopenharmony_ci		uint32_t	flt_region_bootload;
44658c2ecf20Sopenharmony_ci		uint32_t	flt_region_img_status_pri;
44668c2ecf20Sopenharmony_ci		uint32_t	flt_region_img_status_sec;
44678c2ecf20Sopenharmony_ci		uint32_t	flt_region_aux_img_status_pri;
44688c2ecf20Sopenharmony_ci		uint32_t	flt_region_aux_img_status_sec;
44698c2ecf20Sopenharmony_ci	};
44708c2ecf20Sopenharmony_ci	uint8_t         active_image;
44718c2ecf20Sopenharmony_ci
44728c2ecf20Sopenharmony_ci	/* Needed for BEACON */
44738c2ecf20Sopenharmony_ci	uint16_t        beacon_blink_led;
44748c2ecf20Sopenharmony_ci	uint8_t         beacon_color_state;
44758c2ecf20Sopenharmony_ci#define QLA_LED_GRN_ON		0x01
44768c2ecf20Sopenharmony_ci#define QLA_LED_YLW_ON		0x02
44778c2ecf20Sopenharmony_ci#define QLA_LED_ABR_ON		0x04
44788c2ecf20Sopenharmony_ci#define QLA_LED_ALL_ON		0x07	/* yellow, green, amber. */
44798c2ecf20Sopenharmony_ci					/* ISP2322: red, green, amber. */
44808c2ecf20Sopenharmony_ci	uint16_t        zio_mode;
44818c2ecf20Sopenharmony_ci	uint16_t        zio_timer;
44828c2ecf20Sopenharmony_ci
44838c2ecf20Sopenharmony_ci	struct qla_msix_entry *msix_entries;
44848c2ecf20Sopenharmony_ci
44858c2ecf20Sopenharmony_ci	struct list_head        vp_list;        /* list of VP */
44868c2ecf20Sopenharmony_ci	unsigned long   vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
44878c2ecf20Sopenharmony_ci			sizeof(unsigned long)];
44888c2ecf20Sopenharmony_ci	uint16_t        num_vhosts;     /* number of vports created */
44898c2ecf20Sopenharmony_ci	uint16_t        num_vsans;      /* number of vsan created */
44908c2ecf20Sopenharmony_ci	uint16_t        max_npiv_vports;        /* 63 or 125 per topoloty */
44918c2ecf20Sopenharmony_ci	int             cur_vport_count;
44928c2ecf20Sopenharmony_ci
44938c2ecf20Sopenharmony_ci	struct qla_chip_state_84xx *cs84xx;
44948c2ecf20Sopenharmony_ci	struct isp_operations *isp_ops;
44958c2ecf20Sopenharmony_ci	struct workqueue_struct *wq;
44968c2ecf20Sopenharmony_ci	struct qlfc_fw fw_buf;
44978c2ecf20Sopenharmony_ci
44988c2ecf20Sopenharmony_ci	/* FCP_CMND priority support */
44998c2ecf20Sopenharmony_ci	struct qla_fcp_prio_cfg *fcp_prio_cfg;
45008c2ecf20Sopenharmony_ci
45018c2ecf20Sopenharmony_ci	struct dma_pool *dl_dma_pool;
45028c2ecf20Sopenharmony_ci#define DSD_LIST_DMA_POOL_SIZE  512
45038c2ecf20Sopenharmony_ci
45048c2ecf20Sopenharmony_ci	struct dma_pool *fcp_cmnd_dma_pool;
45058c2ecf20Sopenharmony_ci	mempool_t       *ctx_mempool;
45068c2ecf20Sopenharmony_ci#define FCP_CMND_DMA_POOL_SIZE 512
45078c2ecf20Sopenharmony_ci
45088c2ecf20Sopenharmony_ci	void __iomem	*nx_pcibase;		/* Base I/O address */
45098c2ecf20Sopenharmony_ci	void __iomem	*nxdb_rd_ptr;		/* Doorbell read pointer */
45108c2ecf20Sopenharmony_ci	void __iomem	*nxdb_wr_ptr;		/* Door bell write pointer */
45118c2ecf20Sopenharmony_ci
45128c2ecf20Sopenharmony_ci	uint32_t	crb_win;
45138c2ecf20Sopenharmony_ci	uint32_t	curr_window;
45148c2ecf20Sopenharmony_ci	uint32_t	ddr_mn_window;
45158c2ecf20Sopenharmony_ci	unsigned long	mn_win_crb;
45168c2ecf20Sopenharmony_ci	unsigned long	ms_win_crb;
45178c2ecf20Sopenharmony_ci	int		qdr_sn_window;
45188c2ecf20Sopenharmony_ci	uint32_t	fcoe_dev_init_timeout;
45198c2ecf20Sopenharmony_ci	uint32_t	fcoe_reset_timeout;
45208c2ecf20Sopenharmony_ci	rwlock_t	hw_lock;
45218c2ecf20Sopenharmony_ci	uint16_t	portnum;		/* port number */
45228c2ecf20Sopenharmony_ci	int		link_width;
45238c2ecf20Sopenharmony_ci	struct fw_blob	*hablob;
45248c2ecf20Sopenharmony_ci	struct qla82xx_legacy_intr_set nx_legacy_intr;
45258c2ecf20Sopenharmony_ci
45268c2ecf20Sopenharmony_ci	uint16_t	gbl_dsd_inuse;
45278c2ecf20Sopenharmony_ci	uint16_t	gbl_dsd_avail;
45288c2ecf20Sopenharmony_ci	struct list_head gbl_dsd_list;
45298c2ecf20Sopenharmony_ci#define NUM_DSD_CHAIN 4096
45308c2ecf20Sopenharmony_ci
45318c2ecf20Sopenharmony_ci	uint8_t fw_type;
45328c2ecf20Sopenharmony_ci	uint32_t file_prd_off;	/* File firmware product offset */
45338c2ecf20Sopenharmony_ci
45348c2ecf20Sopenharmony_ci	uint32_t	md_template_size;
45358c2ecf20Sopenharmony_ci	void		*md_tmplt_hdr;
45368c2ecf20Sopenharmony_ci	dma_addr_t      md_tmplt_hdr_dma;
45378c2ecf20Sopenharmony_ci	void            *md_dump;
45388c2ecf20Sopenharmony_ci	uint32_t	md_dump_size;
45398c2ecf20Sopenharmony_ci
45408c2ecf20Sopenharmony_ci	void		*loop_id_map;
45418c2ecf20Sopenharmony_ci
45428c2ecf20Sopenharmony_ci	/* QLA83XX IDC specific fields */
45438c2ecf20Sopenharmony_ci	uint32_t	idc_audit_ts;
45448c2ecf20Sopenharmony_ci	uint32_t	idc_extend_tmo;
45458c2ecf20Sopenharmony_ci
45468c2ecf20Sopenharmony_ci	/* DPC low-priority workqueue */
45478c2ecf20Sopenharmony_ci	struct workqueue_struct *dpc_lp_wq;
45488c2ecf20Sopenharmony_ci	struct work_struct idc_aen;
45498c2ecf20Sopenharmony_ci	/* DPC high-priority workqueue */
45508c2ecf20Sopenharmony_ci	struct workqueue_struct *dpc_hp_wq;
45518c2ecf20Sopenharmony_ci	struct work_struct nic_core_reset;
45528c2ecf20Sopenharmony_ci	struct work_struct idc_state_handler;
45538c2ecf20Sopenharmony_ci	struct work_struct nic_core_unrecoverable;
45548c2ecf20Sopenharmony_ci	struct work_struct board_disable;
45558c2ecf20Sopenharmony_ci
45568c2ecf20Sopenharmony_ci	struct mr_data_fx00 mr;
45578c2ecf20Sopenharmony_ci	uint32_t chip_reset;
45588c2ecf20Sopenharmony_ci
45598c2ecf20Sopenharmony_ci	struct qlt_hw_data tgt;
45608c2ecf20Sopenharmony_ci	int	allow_cna_fw_dump;
45618c2ecf20Sopenharmony_ci	uint32_t fw_ability_mask;
45628c2ecf20Sopenharmony_ci	uint16_t min_supported_speed;
45638c2ecf20Sopenharmony_ci	uint16_t max_supported_speed;
45648c2ecf20Sopenharmony_ci
45658c2ecf20Sopenharmony_ci	/* DMA pool for the DIF bundling buffers */
45668c2ecf20Sopenharmony_ci	struct dma_pool *dif_bundl_pool;
45678c2ecf20Sopenharmony_ci	#define DIF_BUNDLING_DMA_POOL_SIZE  1024
45688c2ecf20Sopenharmony_ci	struct {
45698c2ecf20Sopenharmony_ci		struct {
45708c2ecf20Sopenharmony_ci			struct list_head head;
45718c2ecf20Sopenharmony_ci			uint count;
45728c2ecf20Sopenharmony_ci		} good;
45738c2ecf20Sopenharmony_ci		struct {
45748c2ecf20Sopenharmony_ci			struct list_head head;
45758c2ecf20Sopenharmony_ci			uint count;
45768c2ecf20Sopenharmony_ci		} unusable;
45778c2ecf20Sopenharmony_ci	} pool;
45788c2ecf20Sopenharmony_ci
45798c2ecf20Sopenharmony_ci	unsigned long long dif_bundle_crossed_pages;
45808c2ecf20Sopenharmony_ci	unsigned long long dif_bundle_reads;
45818c2ecf20Sopenharmony_ci	unsigned long long dif_bundle_writes;
45828c2ecf20Sopenharmony_ci	unsigned long long dif_bundle_kallocs;
45838c2ecf20Sopenharmony_ci	unsigned long long dif_bundle_dma_allocs;
45848c2ecf20Sopenharmony_ci
45858c2ecf20Sopenharmony_ci	atomic_t        nvme_active_aen_cnt;
45868c2ecf20Sopenharmony_ci	uint16_t        nvme_last_rptd_aen;             /* Last recorded aen count */
45878c2ecf20Sopenharmony_ci
45888c2ecf20Sopenharmony_ci	uint8_t fc4_type_priority;
45898c2ecf20Sopenharmony_ci
45908c2ecf20Sopenharmony_ci	atomic_t zio_threshold;
45918c2ecf20Sopenharmony_ci	uint16_t last_zio_threshold;
45928c2ecf20Sopenharmony_ci
45938c2ecf20Sopenharmony_ci#define DEFAULT_ZIO_THRESHOLD 5
45948c2ecf20Sopenharmony_ci
45958c2ecf20Sopenharmony_ci	struct qla_hw_data_stat stat;
45968c2ecf20Sopenharmony_ci	pci_error_state_t pci_error_state;
45978c2ecf20Sopenharmony_ci};
45988c2ecf20Sopenharmony_ci
45998c2ecf20Sopenharmony_cistruct active_regions {
46008c2ecf20Sopenharmony_ci	uint8_t global;
46018c2ecf20Sopenharmony_ci	struct {
46028c2ecf20Sopenharmony_ci		uint8_t board_config;
46038c2ecf20Sopenharmony_ci		uint8_t vpd_nvram;
46048c2ecf20Sopenharmony_ci		uint8_t npiv_config_0_1;
46058c2ecf20Sopenharmony_ci		uint8_t npiv_config_2_3;
46068c2ecf20Sopenharmony_ci	} aux;
46078c2ecf20Sopenharmony_ci};
46088c2ecf20Sopenharmony_ci
46098c2ecf20Sopenharmony_ci#define FW_ABILITY_MAX_SPEED_MASK	0xFUL
46108c2ecf20Sopenharmony_ci#define FW_ABILITY_MAX_SPEED_16G	0x0
46118c2ecf20Sopenharmony_ci#define FW_ABILITY_MAX_SPEED_32G	0x1
46128c2ecf20Sopenharmony_ci#define FW_ABILITY_MAX_SPEED(ha)	\
46138c2ecf20Sopenharmony_ci	(ha->fw_ability_mask & FW_ABILITY_MAX_SPEED_MASK)
46148c2ecf20Sopenharmony_ci
46158c2ecf20Sopenharmony_ci#define QLA_GET_DATA_RATE	0
46168c2ecf20Sopenharmony_ci#define QLA_SET_DATA_RATE_NOLR	1
46178c2ecf20Sopenharmony_ci#define QLA_SET_DATA_RATE_LR	2 /* Set speed and initiate LR */
46188c2ecf20Sopenharmony_ci
46198c2ecf20Sopenharmony_ci#define QLA_DEFAULT_PAYLOAD_SIZE	64
46208c2ecf20Sopenharmony_ci/*
46218c2ecf20Sopenharmony_ci * This item might be allocated with a size > sizeof(struct purex_item).
46228c2ecf20Sopenharmony_ci * The "size" variable gives the size of the payload (which
46238c2ecf20Sopenharmony_ci * is variable) starting at "iocb".
46248c2ecf20Sopenharmony_ci */
46258c2ecf20Sopenharmony_cistruct purex_item {
46268c2ecf20Sopenharmony_ci	struct list_head list;
46278c2ecf20Sopenharmony_ci	struct scsi_qla_host *vha;
46288c2ecf20Sopenharmony_ci	void (*process_item)(struct scsi_qla_host *vha,
46298c2ecf20Sopenharmony_ci			     struct purex_item *pkt);
46308c2ecf20Sopenharmony_ci	atomic_t in_use;
46318c2ecf20Sopenharmony_ci	uint16_t size;
46328c2ecf20Sopenharmony_ci	struct {
46338c2ecf20Sopenharmony_ci		uint8_t iocb[64];
46348c2ecf20Sopenharmony_ci	} iocb;
46358c2ecf20Sopenharmony_ci};
46368c2ecf20Sopenharmony_ci
46378c2ecf20Sopenharmony_ci#define SCM_FLAG_RDF_REJECT		0x00
46388c2ecf20Sopenharmony_ci#define SCM_FLAG_RDF_COMPLETED		0x01
46398c2ecf20Sopenharmony_ci
46408c2ecf20Sopenharmony_ci#define QLA_CON_PRIMITIVE_RECEIVED	0x1
46418c2ecf20Sopenharmony_ci#define QLA_CONGESTION_ARB_WARNING	0x1
46428c2ecf20Sopenharmony_ci#define QLA_CONGESTION_ARB_ALARM	0X2
46438c2ecf20Sopenharmony_ci
46448c2ecf20Sopenharmony_ci/*
46458c2ecf20Sopenharmony_ci * Qlogic scsi host structure
46468c2ecf20Sopenharmony_ci */
46478c2ecf20Sopenharmony_citypedef struct scsi_qla_host {
46488c2ecf20Sopenharmony_ci	struct list_head list;
46498c2ecf20Sopenharmony_ci	struct list_head vp_fcports;	/* list of fcports */
46508c2ecf20Sopenharmony_ci	struct list_head work_list;
46518c2ecf20Sopenharmony_ci	spinlock_t work_lock;
46528c2ecf20Sopenharmony_ci	struct work_struct iocb_work;
46538c2ecf20Sopenharmony_ci
46548c2ecf20Sopenharmony_ci	/* Commonly used flags and state information. */
46558c2ecf20Sopenharmony_ci	struct Scsi_Host *host;
46568c2ecf20Sopenharmony_ci	unsigned long	host_no;
46578c2ecf20Sopenharmony_ci	uint8_t		host_str[16];
46588c2ecf20Sopenharmony_ci
46598c2ecf20Sopenharmony_ci	volatile struct {
46608c2ecf20Sopenharmony_ci		uint32_t	init_done		:1;
46618c2ecf20Sopenharmony_ci		uint32_t	online			:1;
46628c2ecf20Sopenharmony_ci		uint32_t	reset_active		:1;
46638c2ecf20Sopenharmony_ci
46648c2ecf20Sopenharmony_ci		uint32_t	management_server_logged_in :1;
46658c2ecf20Sopenharmony_ci		uint32_t	process_response_queue	:1;
46668c2ecf20Sopenharmony_ci		uint32_t	difdix_supported:1;
46678c2ecf20Sopenharmony_ci		uint32_t	delete_progress:1;
46688c2ecf20Sopenharmony_ci
46698c2ecf20Sopenharmony_ci		uint32_t	fw_tgt_reported:1;
46708c2ecf20Sopenharmony_ci		uint32_t	bbcr_enable:1;
46718c2ecf20Sopenharmony_ci		uint32_t	qpairs_available:1;
46728c2ecf20Sopenharmony_ci		uint32_t	qpairs_req_created:1;
46738c2ecf20Sopenharmony_ci		uint32_t	qpairs_rsp_created:1;
46748c2ecf20Sopenharmony_ci		uint32_t	nvme_enabled:1;
46758c2ecf20Sopenharmony_ci		uint32_t        nvme_first_burst:1;
46768c2ecf20Sopenharmony_ci		uint32_t        nvme2_enabled:1;
46778c2ecf20Sopenharmony_ci	} flags;
46788c2ecf20Sopenharmony_ci
46798c2ecf20Sopenharmony_ci	atomic_t	loop_state;
46808c2ecf20Sopenharmony_ci#define LOOP_TIMEOUT	1
46818c2ecf20Sopenharmony_ci#define LOOP_DOWN	2
46828c2ecf20Sopenharmony_ci#define LOOP_UP		3
46838c2ecf20Sopenharmony_ci#define LOOP_UPDATE	4
46848c2ecf20Sopenharmony_ci#define LOOP_READY	5
46858c2ecf20Sopenharmony_ci#define LOOP_DEAD	6
46868c2ecf20Sopenharmony_ci
46878c2ecf20Sopenharmony_ci	unsigned long   relogin_jif;
46888c2ecf20Sopenharmony_ci	unsigned long   dpc_flags;
46898c2ecf20Sopenharmony_ci#define RESET_MARKER_NEEDED	0	/* Send marker to ISP. */
46908c2ecf20Sopenharmony_ci#define RESET_ACTIVE		1
46918c2ecf20Sopenharmony_ci#define ISP_ABORT_NEEDED	2	/* Initiate ISP abort. */
46928c2ecf20Sopenharmony_ci#define ABORT_ISP_ACTIVE	3	/* ISP abort in progress. */
46938c2ecf20Sopenharmony_ci#define LOOP_RESYNC_NEEDED	4	/* Device Resync needed. */
46948c2ecf20Sopenharmony_ci#define LOOP_RESYNC_ACTIVE	5
46958c2ecf20Sopenharmony_ci#define LOCAL_LOOP_UPDATE	6	/* Perform a local loop update. */
46968c2ecf20Sopenharmony_ci#define RSCN_UPDATE		7	/* Perform an RSCN update. */
46978c2ecf20Sopenharmony_ci#define RELOGIN_NEEDED		8
46988c2ecf20Sopenharmony_ci#define REGISTER_FC4_NEEDED	9	/* SNS FC4 registration required. */
46998c2ecf20Sopenharmony_ci#define ISP_ABORT_RETRY		10	/* ISP aborted. */
47008c2ecf20Sopenharmony_ci#define BEACON_BLINK_NEEDED	11
47018c2ecf20Sopenharmony_ci#define REGISTER_FDMI_NEEDED	12
47028c2ecf20Sopenharmony_ci#define FCPORT_UPDATE_NEEDED	13
47038c2ecf20Sopenharmony_ci#define VP_DPC_NEEDED		14	/* wake up for VP dpc handling */
47048c2ecf20Sopenharmony_ci#define UNLOADING		15
47058c2ecf20Sopenharmony_ci#define NPIV_CONFIG_NEEDED	16
47068c2ecf20Sopenharmony_ci#define ISP_UNRECOVERABLE	17
47078c2ecf20Sopenharmony_ci#define FCOE_CTX_RESET_NEEDED	18	/* Initiate FCoE context reset */
47088c2ecf20Sopenharmony_ci#define MPI_RESET_NEEDED	19	/* Initiate MPI FW reset */
47098c2ecf20Sopenharmony_ci#define ISP_QUIESCE_NEEDED	20	/* Driver need some quiescence */
47108c2ecf20Sopenharmony_ci#define N2N_LINK_RESET		21
47118c2ecf20Sopenharmony_ci#define PORT_UPDATE_NEEDED	22
47128c2ecf20Sopenharmony_ci#define FX00_RESET_RECOVERY	23
47138c2ecf20Sopenharmony_ci#define FX00_TARGET_SCAN	24
47148c2ecf20Sopenharmony_ci#define FX00_CRITEMP_RECOVERY	25
47158c2ecf20Sopenharmony_ci#define FX00_HOST_INFO_RESEND	26
47168c2ecf20Sopenharmony_ci#define QPAIR_ONLINE_CHECK_NEEDED	27
47178c2ecf20Sopenharmony_ci#define DO_EEH_RECOVERY		28
47188c2ecf20Sopenharmony_ci#define DETECT_SFP_CHANGE	29
47198c2ecf20Sopenharmony_ci#define N2N_LOGIN_NEEDED	30
47208c2ecf20Sopenharmony_ci#define IOCB_WORK_ACTIVE	31
47218c2ecf20Sopenharmony_ci#define SET_ZIO_THRESHOLD_NEEDED 32
47228c2ecf20Sopenharmony_ci#define ISP_ABORT_TO_ROM	33
47238c2ecf20Sopenharmony_ci#define VPORT_DELETE		34
47248c2ecf20Sopenharmony_ci
47258c2ecf20Sopenharmony_ci#define PROCESS_PUREX_IOCB	63
47268c2ecf20Sopenharmony_ci
47278c2ecf20Sopenharmony_ci	unsigned long	pci_flags;
47288c2ecf20Sopenharmony_ci#define PFLG_DISCONNECTED	0	/* PCI device removed */
47298c2ecf20Sopenharmony_ci#define PFLG_DRIVER_REMOVING	1	/* PCI driver .remove */
47308c2ecf20Sopenharmony_ci#define PFLG_DRIVER_PROBING	2	/* PCI driver .probe */
47318c2ecf20Sopenharmony_ci
47328c2ecf20Sopenharmony_ci	uint32_t	device_flags;
47338c2ecf20Sopenharmony_ci#define SWITCH_FOUND		BIT_0
47348c2ecf20Sopenharmony_ci#define DFLG_NO_CABLE		BIT_1
47358c2ecf20Sopenharmony_ci#define DFLG_DEV_FAILED		BIT_5
47368c2ecf20Sopenharmony_ci
47378c2ecf20Sopenharmony_ci	/* ISP configuration data. */
47388c2ecf20Sopenharmony_ci	uint16_t	loop_id;		/* Host adapter loop id */
47398c2ecf20Sopenharmony_ci	uint16_t        self_login_loop_id;     /* host adapter loop id
47408c2ecf20Sopenharmony_ci						 * get it on self login
47418c2ecf20Sopenharmony_ci						 */
47428c2ecf20Sopenharmony_ci	fc_port_t       bidir_fcport;		/* fcport used for bidir cmnds
47438c2ecf20Sopenharmony_ci						 * no need of allocating it for
47448c2ecf20Sopenharmony_ci						 * each command
47458c2ecf20Sopenharmony_ci						 */
47468c2ecf20Sopenharmony_ci
47478c2ecf20Sopenharmony_ci	port_id_t	d_id;			/* Host adapter port id */
47488c2ecf20Sopenharmony_ci	uint8_t		marker_needed;
47498c2ecf20Sopenharmony_ci	uint16_t	mgmt_svr_loop_id;
47508c2ecf20Sopenharmony_ci
47518c2ecf20Sopenharmony_ci
47528c2ecf20Sopenharmony_ci
47538c2ecf20Sopenharmony_ci	/* Timeout timers. */
47548c2ecf20Sopenharmony_ci	uint8_t         loop_down_abort_time;    /* port down timer */
47558c2ecf20Sopenharmony_ci	atomic_t        loop_down_timer;         /* loop down timer */
47568c2ecf20Sopenharmony_ci	uint8_t         link_down_timeout;       /* link down timeout */
47578c2ecf20Sopenharmony_ci
47588c2ecf20Sopenharmony_ci	uint32_t        timer_active;
47598c2ecf20Sopenharmony_ci	struct timer_list        timer;
47608c2ecf20Sopenharmony_ci
47618c2ecf20Sopenharmony_ci	uint8_t		node_name[WWN_SIZE];
47628c2ecf20Sopenharmony_ci	uint8_t		port_name[WWN_SIZE];
47638c2ecf20Sopenharmony_ci	uint8_t		fabric_node_name[WWN_SIZE];
47648c2ecf20Sopenharmony_ci	uint8_t		fabric_port_name[WWN_SIZE];
47658c2ecf20Sopenharmony_ci
47668c2ecf20Sopenharmony_ci	struct		nvme_fc_local_port *nvme_local_port;
47678c2ecf20Sopenharmony_ci	struct completion nvme_del_done;
47688c2ecf20Sopenharmony_ci
47698c2ecf20Sopenharmony_ci	uint16_t	fcoe_vlan_id;
47708c2ecf20Sopenharmony_ci	uint16_t	fcoe_fcf_idx;
47718c2ecf20Sopenharmony_ci	uint8_t		fcoe_vn_port_mac[6];
47728c2ecf20Sopenharmony_ci
47738c2ecf20Sopenharmony_ci	/* list of commands waiting on workqueue */
47748c2ecf20Sopenharmony_ci	struct list_head	qla_cmd_list;
47758c2ecf20Sopenharmony_ci	struct list_head	qla_sess_op_cmd_list;
47768c2ecf20Sopenharmony_ci	struct list_head	unknown_atio_list;
47778c2ecf20Sopenharmony_ci	spinlock_t		cmd_list_lock;
47788c2ecf20Sopenharmony_ci	struct delayed_work	unknown_atio_work;
47798c2ecf20Sopenharmony_ci
47808c2ecf20Sopenharmony_ci	/* Counter to detect races between ELS and RSCN events */
47818c2ecf20Sopenharmony_ci	atomic_t		generation_tick;
47828c2ecf20Sopenharmony_ci	/* Time when global fcport update has been scheduled */
47838c2ecf20Sopenharmony_ci	int			total_fcport_update_gen;
47848c2ecf20Sopenharmony_ci	/* List of pending LOGOs, protected by tgt_mutex */
47858c2ecf20Sopenharmony_ci	struct list_head	logo_list;
47868c2ecf20Sopenharmony_ci	/* List of pending PLOGI acks, protected by hw lock */
47878c2ecf20Sopenharmony_ci	struct list_head	plogi_ack_list;
47888c2ecf20Sopenharmony_ci
47898c2ecf20Sopenharmony_ci	struct list_head	qp_list;
47908c2ecf20Sopenharmony_ci
47918c2ecf20Sopenharmony_ci	uint32_t	vp_abort_cnt;
47928c2ecf20Sopenharmony_ci
47938c2ecf20Sopenharmony_ci	struct fc_vport	*fc_vport;	/* holds fc_vport * for each vport */
47948c2ecf20Sopenharmony_ci	uint16_t        vp_idx;		/* vport ID */
47958c2ecf20Sopenharmony_ci	struct qla_qpair *qpair;	/* base qpair */
47968c2ecf20Sopenharmony_ci
47978c2ecf20Sopenharmony_ci	unsigned long		vp_flags;
47988c2ecf20Sopenharmony_ci#define VP_IDX_ACQUIRED		0	/* bit no 0 */
47998c2ecf20Sopenharmony_ci#define VP_CREATE_NEEDED	1
48008c2ecf20Sopenharmony_ci#define VP_BIND_NEEDED		2
48018c2ecf20Sopenharmony_ci#define VP_DELETE_NEEDED	3
48028c2ecf20Sopenharmony_ci#define VP_SCR_NEEDED		4	/* State Change Request registration */
48038c2ecf20Sopenharmony_ci#define VP_CONFIG_OK		5	/* Flag to cfg VP, if FW is ready */
48048c2ecf20Sopenharmony_ci	atomic_t 		vp_state;
48058c2ecf20Sopenharmony_ci#define VP_OFFLINE		0
48068c2ecf20Sopenharmony_ci#define VP_ACTIVE		1
48078c2ecf20Sopenharmony_ci#define VP_FAILED		2
48088c2ecf20Sopenharmony_ci// #define VP_DISABLE		3
48098c2ecf20Sopenharmony_ci	uint16_t 	vp_err_state;
48108c2ecf20Sopenharmony_ci	uint16_t	vp_prev_err_state;
48118c2ecf20Sopenharmony_ci#define VP_ERR_UNKWN		0
48128c2ecf20Sopenharmony_ci#define VP_ERR_PORTDWN		1
48138c2ecf20Sopenharmony_ci#define VP_ERR_FAB_UNSUPPORTED	2
48148c2ecf20Sopenharmony_ci#define VP_ERR_FAB_NORESOURCES	3
48158c2ecf20Sopenharmony_ci#define VP_ERR_FAB_LOGOUT	4
48168c2ecf20Sopenharmony_ci#define VP_ERR_ADAP_NORESOURCES	5
48178c2ecf20Sopenharmony_ci	struct qla_hw_data *hw;
48188c2ecf20Sopenharmony_ci	struct scsi_qlt_host vha_tgt;
48198c2ecf20Sopenharmony_ci	struct req_que *req;
48208c2ecf20Sopenharmony_ci	int		fw_heartbeat_counter;
48218c2ecf20Sopenharmony_ci	int		seconds_since_last_heartbeat;
48228c2ecf20Sopenharmony_ci	struct fc_host_statistics fc_host_stat;
48238c2ecf20Sopenharmony_ci	struct qla_statistics qla_stats;
48248c2ecf20Sopenharmony_ci	struct bidi_statistics bidi_stats;
48258c2ecf20Sopenharmony_ci	atomic_t	vref_count;
48268c2ecf20Sopenharmony_ci	struct qla8044_reset_template reset_tmplt;
48278c2ecf20Sopenharmony_ci	uint16_t	bbcr;
48288c2ecf20Sopenharmony_ci
48298c2ecf20Sopenharmony_ci	uint16_t u_ql2xexchoffld;
48308c2ecf20Sopenharmony_ci	uint16_t u_ql2xiniexchg;
48318c2ecf20Sopenharmony_ci	uint16_t qlini_mode;
48328c2ecf20Sopenharmony_ci	uint16_t ql2xexchoffld;
48338c2ecf20Sopenharmony_ci	uint16_t ql2xiniexchg;
48348c2ecf20Sopenharmony_ci
48358c2ecf20Sopenharmony_ci	struct dentry *dfs_rport_root;
48368c2ecf20Sopenharmony_ci
48378c2ecf20Sopenharmony_ci	struct purex_list {
48388c2ecf20Sopenharmony_ci		struct list_head head;
48398c2ecf20Sopenharmony_ci		spinlock_t lock;
48408c2ecf20Sopenharmony_ci	} purex_list;
48418c2ecf20Sopenharmony_ci	struct purex_item default_item;
48428c2ecf20Sopenharmony_ci
48438c2ecf20Sopenharmony_ci	struct name_list_extended gnl;
48448c2ecf20Sopenharmony_ci	/* Count of active session/fcport */
48458c2ecf20Sopenharmony_ci	int fcport_count;
48468c2ecf20Sopenharmony_ci	wait_queue_head_t fcport_waitQ;
48478c2ecf20Sopenharmony_ci	wait_queue_head_t vref_waitq;
48488c2ecf20Sopenharmony_ci	uint8_t min_supported_speed;
48498c2ecf20Sopenharmony_ci	uint8_t n2n_node_name[WWN_SIZE];
48508c2ecf20Sopenharmony_ci	uint8_t n2n_port_name[WWN_SIZE];
48518c2ecf20Sopenharmony_ci	uint16_t	n2n_id;
48528c2ecf20Sopenharmony_ci	__le16 dport_data[4];
48538c2ecf20Sopenharmony_ci	struct list_head gpnid_list;
48548c2ecf20Sopenharmony_ci	struct fab_scan scan;
48558c2ecf20Sopenharmony_ci	uint8_t	scm_fabric_connection_flags;
48568c2ecf20Sopenharmony_ci
48578c2ecf20Sopenharmony_ci	unsigned int irq_offset;
48588c2ecf20Sopenharmony_ci} scsi_qla_host_t;
48598c2ecf20Sopenharmony_ci
48608c2ecf20Sopenharmony_cistruct qla27xx_image_status {
48618c2ecf20Sopenharmony_ci	uint8_t image_status_mask;
48628c2ecf20Sopenharmony_ci	__le16	generation;
48638c2ecf20Sopenharmony_ci	uint8_t ver_major;
48648c2ecf20Sopenharmony_ci	uint8_t ver_minor;
48658c2ecf20Sopenharmony_ci	uint8_t bitmap;		/* 28xx only */
48668c2ecf20Sopenharmony_ci	uint8_t reserved[2];
48678c2ecf20Sopenharmony_ci	__le32	checksum;
48688c2ecf20Sopenharmony_ci	__le32	signature;
48698c2ecf20Sopenharmony_ci} __packed;
48708c2ecf20Sopenharmony_ci
48718c2ecf20Sopenharmony_ci/* 28xx aux image status bimap values */
48728c2ecf20Sopenharmony_ci#define QLA28XX_AUX_IMG_BOARD_CONFIG		BIT_0
48738c2ecf20Sopenharmony_ci#define QLA28XX_AUX_IMG_VPD_NVRAM		BIT_1
48748c2ecf20Sopenharmony_ci#define QLA28XX_AUX_IMG_NPIV_CONFIG_0_1		BIT_2
48758c2ecf20Sopenharmony_ci#define QLA28XX_AUX_IMG_NPIV_CONFIG_2_3		BIT_3
48768c2ecf20Sopenharmony_ci
48778c2ecf20Sopenharmony_ci#define SET_VP_IDX	1
48788c2ecf20Sopenharmony_ci#define SET_AL_PA	2
48798c2ecf20Sopenharmony_ci#define RESET_VP_IDX	3
48808c2ecf20Sopenharmony_ci#define RESET_AL_PA	4
48818c2ecf20Sopenharmony_cistruct qla_tgt_vp_map {
48828c2ecf20Sopenharmony_ci	uint8_t	idx;
48838c2ecf20Sopenharmony_ci	scsi_qla_host_t *vha;
48848c2ecf20Sopenharmony_ci};
48858c2ecf20Sopenharmony_ci
48868c2ecf20Sopenharmony_cistruct qla2_sgx {
48878c2ecf20Sopenharmony_ci	dma_addr_t		dma_addr;	/* OUT */
48888c2ecf20Sopenharmony_ci	uint32_t		dma_len;	/* OUT */
48898c2ecf20Sopenharmony_ci
48908c2ecf20Sopenharmony_ci	uint32_t		tot_bytes;	/* IN */
48918c2ecf20Sopenharmony_ci	struct scatterlist	*cur_sg;	/* IN */
48928c2ecf20Sopenharmony_ci
48938c2ecf20Sopenharmony_ci	/* for book keeping, bzero on initial invocation */
48948c2ecf20Sopenharmony_ci	uint32_t		bytes_consumed;
48958c2ecf20Sopenharmony_ci	uint32_t		num_bytes;
48968c2ecf20Sopenharmony_ci	uint32_t		tot_partial;
48978c2ecf20Sopenharmony_ci
48988c2ecf20Sopenharmony_ci	/* for debugging */
48998c2ecf20Sopenharmony_ci	uint32_t		num_sg;
49008c2ecf20Sopenharmony_ci	srb_t			*sp;
49018c2ecf20Sopenharmony_ci};
49028c2ecf20Sopenharmony_ci
49038c2ecf20Sopenharmony_ci#define QLA_FW_STARTED(_ha) {			\
49048c2ecf20Sopenharmony_ci	int i;					\
49058c2ecf20Sopenharmony_ci	_ha->flags.fw_started = 1;		\
49068c2ecf20Sopenharmony_ci	_ha->base_qpair->fw_started = 1;	\
49078c2ecf20Sopenharmony_ci	for (i = 0; i < _ha->max_qpairs; i++) {	\
49088c2ecf20Sopenharmony_ci	if (_ha->queue_pair_map[i])	\
49098c2ecf20Sopenharmony_ci	_ha->queue_pair_map[i]->fw_started = 1;	\
49108c2ecf20Sopenharmony_ci	}					\
49118c2ecf20Sopenharmony_ci}
49128c2ecf20Sopenharmony_ci
49138c2ecf20Sopenharmony_ci#define QLA_FW_STOPPED(_ha) {			\
49148c2ecf20Sopenharmony_ci	int i;					\
49158c2ecf20Sopenharmony_ci	_ha->flags.fw_started = 0;		\
49168c2ecf20Sopenharmony_ci	_ha->base_qpair->fw_started = 0;	\
49178c2ecf20Sopenharmony_ci	for (i = 0; i < _ha->max_qpairs; i++) {	\
49188c2ecf20Sopenharmony_ci	if (_ha->queue_pair_map[i])	\
49198c2ecf20Sopenharmony_ci	_ha->queue_pair_map[i]->fw_started = 0;	\
49208c2ecf20Sopenharmony_ci	}					\
49218c2ecf20Sopenharmony_ci}
49228c2ecf20Sopenharmony_ci
49238c2ecf20Sopenharmony_ci
49248c2ecf20Sopenharmony_ci#define SFUB_CHECKSUM_SIZE	4
49258c2ecf20Sopenharmony_ci
49268c2ecf20Sopenharmony_cistruct secure_flash_update_block {
49278c2ecf20Sopenharmony_ci	uint32_t	block_info;
49288c2ecf20Sopenharmony_ci	uint32_t	signature_lo;
49298c2ecf20Sopenharmony_ci	uint32_t	signature_hi;
49308c2ecf20Sopenharmony_ci	uint32_t	signature_upper[0x3e];
49318c2ecf20Sopenharmony_ci};
49328c2ecf20Sopenharmony_ci
49338c2ecf20Sopenharmony_cistruct secure_flash_update_block_pk {
49348c2ecf20Sopenharmony_ci	uint32_t	block_info;
49358c2ecf20Sopenharmony_ci	uint32_t	signature_lo;
49368c2ecf20Sopenharmony_ci	uint32_t	signature_hi;
49378c2ecf20Sopenharmony_ci	uint32_t	signature_upper[0x3e];
49388c2ecf20Sopenharmony_ci	uint32_t	public_key[0x41];
49398c2ecf20Sopenharmony_ci};
49408c2ecf20Sopenharmony_ci
49418c2ecf20Sopenharmony_ci/*
49428c2ecf20Sopenharmony_ci * Macros to help code, maintain, etc.
49438c2ecf20Sopenharmony_ci */
49448c2ecf20Sopenharmony_ci#define LOOP_TRANSITION(ha) \
49458c2ecf20Sopenharmony_ci	(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
49468c2ecf20Sopenharmony_ci	 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
49478c2ecf20Sopenharmony_ci	 atomic_read(&ha->loop_state) == LOOP_DOWN)
49488c2ecf20Sopenharmony_ci
49498c2ecf20Sopenharmony_ci#define STATE_TRANSITION(ha) \
49508c2ecf20Sopenharmony_ci		(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
49518c2ecf20Sopenharmony_ci			 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
49528c2ecf20Sopenharmony_ci
49538c2ecf20Sopenharmony_ci#define QLA_VHA_MARK_BUSY(__vha, __bail) do {		\
49548c2ecf20Sopenharmony_ci	atomic_inc(&__vha->vref_count);			\
49558c2ecf20Sopenharmony_ci	mb();						\
49568c2ecf20Sopenharmony_ci	if (__vha->flags.delete_progress) {		\
49578c2ecf20Sopenharmony_ci		atomic_dec(&__vha->vref_count);		\
49588c2ecf20Sopenharmony_ci		wake_up(&__vha->vref_waitq);		\
49598c2ecf20Sopenharmony_ci		__bail = 1;				\
49608c2ecf20Sopenharmony_ci	} else {					\
49618c2ecf20Sopenharmony_ci		__bail = 0;				\
49628c2ecf20Sopenharmony_ci	}						\
49638c2ecf20Sopenharmony_ci} while (0)
49648c2ecf20Sopenharmony_ci
49658c2ecf20Sopenharmony_ci#define QLA_VHA_MARK_NOT_BUSY(__vha) do {		\
49668c2ecf20Sopenharmony_ci	atomic_dec(&__vha->vref_count);			\
49678c2ecf20Sopenharmony_ci	wake_up(&__vha->vref_waitq);			\
49688c2ecf20Sopenharmony_ci} while (0)						\
49698c2ecf20Sopenharmony_ci
49708c2ecf20Sopenharmony_ci#define QLA_QPAIR_MARK_BUSY(__qpair, __bail) do {	\
49718c2ecf20Sopenharmony_ci	atomic_inc(&__qpair->ref_count);		\
49728c2ecf20Sopenharmony_ci	mb();						\
49738c2ecf20Sopenharmony_ci	if (__qpair->delete_in_progress) {		\
49748c2ecf20Sopenharmony_ci		atomic_dec(&__qpair->ref_count);	\
49758c2ecf20Sopenharmony_ci		__bail = 1;				\
49768c2ecf20Sopenharmony_ci	} else {					\
49778c2ecf20Sopenharmony_ci	       __bail = 0;				\
49788c2ecf20Sopenharmony_ci	}						\
49798c2ecf20Sopenharmony_ci} while (0)
49808c2ecf20Sopenharmony_ci
49818c2ecf20Sopenharmony_ci#define QLA_QPAIR_MARK_NOT_BUSY(__qpair)		\
49828c2ecf20Sopenharmony_ci	atomic_dec(&__qpair->ref_count);		\
49838c2ecf20Sopenharmony_ci
49848c2ecf20Sopenharmony_ci
49858c2ecf20Sopenharmony_ci#define QLA_ENA_CONF(_ha) {\
49868c2ecf20Sopenharmony_ci    int i;\
49878c2ecf20Sopenharmony_ci    _ha->base_qpair->enable_explicit_conf = 1;	\
49888c2ecf20Sopenharmony_ci    for (i = 0; i < _ha->max_qpairs; i++) {	\
49898c2ecf20Sopenharmony_ci	if (_ha->queue_pair_map[i])		\
49908c2ecf20Sopenharmony_ci	    _ha->queue_pair_map[i]->enable_explicit_conf = 1; \
49918c2ecf20Sopenharmony_ci    }						\
49928c2ecf20Sopenharmony_ci}
49938c2ecf20Sopenharmony_ci
49948c2ecf20Sopenharmony_ci#define QLA_DIS_CONF(_ha) {\
49958c2ecf20Sopenharmony_ci    int i;\
49968c2ecf20Sopenharmony_ci    _ha->base_qpair->enable_explicit_conf = 0;	\
49978c2ecf20Sopenharmony_ci    for (i = 0; i < _ha->max_qpairs; i++) {	\
49988c2ecf20Sopenharmony_ci	if (_ha->queue_pair_map[i])		\
49998c2ecf20Sopenharmony_ci	    _ha->queue_pair_map[i]->enable_explicit_conf = 0; \
50008c2ecf20Sopenharmony_ci    }						\
50018c2ecf20Sopenharmony_ci}
50028c2ecf20Sopenharmony_ci
50038c2ecf20Sopenharmony_ci/*
50048c2ecf20Sopenharmony_ci * qla2x00 local function return status codes
50058c2ecf20Sopenharmony_ci */
50068c2ecf20Sopenharmony_ci#define MBS_MASK		0x3fff
50078c2ecf20Sopenharmony_ci
50088c2ecf20Sopenharmony_ci#define QLA_SUCCESS		(MBS_COMMAND_COMPLETE & MBS_MASK)
50098c2ecf20Sopenharmony_ci#define QLA_INVALID_COMMAND	(MBS_INVALID_COMMAND & MBS_MASK)
50108c2ecf20Sopenharmony_ci#define QLA_INTERFACE_ERROR	(MBS_HOST_INTERFACE_ERROR & MBS_MASK)
50118c2ecf20Sopenharmony_ci#define QLA_TEST_FAILED		(MBS_TEST_FAILED & MBS_MASK)
50128c2ecf20Sopenharmony_ci#define QLA_COMMAND_ERROR	(MBS_COMMAND_ERROR & MBS_MASK)
50138c2ecf20Sopenharmony_ci#define QLA_PARAMETER_ERROR	(MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
50148c2ecf20Sopenharmony_ci#define QLA_PORT_ID_USED	(MBS_PORT_ID_USED & MBS_MASK)
50158c2ecf20Sopenharmony_ci#define QLA_LOOP_ID_USED	(MBS_LOOP_ID_USED & MBS_MASK)
50168c2ecf20Sopenharmony_ci#define QLA_ALL_IDS_IN_USE	(MBS_ALL_IDS_IN_USE & MBS_MASK)
50178c2ecf20Sopenharmony_ci#define QLA_NOT_LOGGED_IN	(MBS_NOT_LOGGED_IN & MBS_MASK)
50188c2ecf20Sopenharmony_ci
50198c2ecf20Sopenharmony_ci#define QLA_FUNCTION_TIMEOUT		0x100
50208c2ecf20Sopenharmony_ci#define QLA_FUNCTION_PARAMETER_ERROR	0x101
50218c2ecf20Sopenharmony_ci#define QLA_FUNCTION_FAILED		0x102
50228c2ecf20Sopenharmony_ci#define QLA_MEMORY_ALLOC_FAILED		0x103
50238c2ecf20Sopenharmony_ci#define QLA_LOCK_TIMEOUT		0x104
50248c2ecf20Sopenharmony_ci#define QLA_ABORTED			0x105
50258c2ecf20Sopenharmony_ci#define QLA_SUSPENDED			0x106
50268c2ecf20Sopenharmony_ci#define QLA_BUSY			0x107
50278c2ecf20Sopenharmony_ci#define QLA_ALREADY_REGISTERED		0x109
50288c2ecf20Sopenharmony_ci#define QLA_OS_TIMER_EXPIRED		0x10a
50298c2ecf20Sopenharmony_ci
50308c2ecf20Sopenharmony_ci#define NVRAM_DELAY()		udelay(10)
50318c2ecf20Sopenharmony_ci
50328c2ecf20Sopenharmony_ci/*
50338c2ecf20Sopenharmony_ci * Flash support definitions
50348c2ecf20Sopenharmony_ci */
50358c2ecf20Sopenharmony_ci#define OPTROM_SIZE_2300	0x20000
50368c2ecf20Sopenharmony_ci#define OPTROM_SIZE_2322	0x100000
50378c2ecf20Sopenharmony_ci#define OPTROM_SIZE_24XX	0x100000
50388c2ecf20Sopenharmony_ci#define OPTROM_SIZE_25XX	0x200000
50398c2ecf20Sopenharmony_ci#define OPTROM_SIZE_81XX	0x400000
50408c2ecf20Sopenharmony_ci#define OPTROM_SIZE_82XX	0x800000
50418c2ecf20Sopenharmony_ci#define OPTROM_SIZE_83XX	0x1000000
50428c2ecf20Sopenharmony_ci#define OPTROM_SIZE_28XX	0x2000000
50438c2ecf20Sopenharmony_ci
50448c2ecf20Sopenharmony_ci#define OPTROM_BURST_SIZE	0x1000
50458c2ecf20Sopenharmony_ci#define OPTROM_BURST_DWORDS	(OPTROM_BURST_SIZE / 4)
50468c2ecf20Sopenharmony_ci
50478c2ecf20Sopenharmony_ci#define	QLA_DSDS_PER_IOCB	37
50488c2ecf20Sopenharmony_ci
50498c2ecf20Sopenharmony_ci#define CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)
50508c2ecf20Sopenharmony_ci
50518c2ecf20Sopenharmony_ci#define QLA_SG_ALL	1024
50528c2ecf20Sopenharmony_ci
50538c2ecf20Sopenharmony_cienum nexus_wait_type {
50548c2ecf20Sopenharmony_ci	WAIT_HOST = 0,
50558c2ecf20Sopenharmony_ci	WAIT_TARGET,
50568c2ecf20Sopenharmony_ci	WAIT_LUN,
50578c2ecf20Sopenharmony_ci};
50588c2ecf20Sopenharmony_ci
50598c2ecf20Sopenharmony_ci/* Refer to SNIA SFF 8247 */
50608c2ecf20Sopenharmony_cistruct sff_8247_a0 {
50618c2ecf20Sopenharmony_ci	u8 txid;	/* transceiver id */
50628c2ecf20Sopenharmony_ci	u8 ext_txid;
50638c2ecf20Sopenharmony_ci	u8 connector;
50648c2ecf20Sopenharmony_ci	/* compliance code */
50658c2ecf20Sopenharmony_ci	u8 eth_infi_cc3;	/* ethernet, inifiband */
50668c2ecf20Sopenharmony_ci	u8 sonet_cc4[2];
50678c2ecf20Sopenharmony_ci	u8 eth_cc6;
50688c2ecf20Sopenharmony_ci	/* link length */
50698c2ecf20Sopenharmony_ci#define FC_LL_VL BIT_7	/* very long */
50708c2ecf20Sopenharmony_ci#define FC_LL_S  BIT_6	/* Short */
50718c2ecf20Sopenharmony_ci#define FC_LL_I  BIT_5	/* Intermidiate*/
50728c2ecf20Sopenharmony_ci#define FC_LL_L  BIT_4	/* Long */
50738c2ecf20Sopenharmony_ci#define FC_LL_M  BIT_3	/* Medium */
50748c2ecf20Sopenharmony_ci#define FC_LL_SA BIT_2	/* ShortWave laser */
50758c2ecf20Sopenharmony_ci#define FC_LL_LC BIT_1	/* LongWave laser */
50768c2ecf20Sopenharmony_ci#define FC_LL_EL BIT_0	/* Electrical inter enclosure */
50778c2ecf20Sopenharmony_ci	u8 fc_ll_cc7;
50788c2ecf20Sopenharmony_ci	/* FC technology */
50798c2ecf20Sopenharmony_ci#define FC_TEC_EL BIT_7	/* Electrical inter enclosure */
50808c2ecf20Sopenharmony_ci#define FC_TEC_SN BIT_6	/* short wave w/o OFC */
50818c2ecf20Sopenharmony_ci#define FC_TEC_SL BIT_5	/* short wave with OFC */
50828c2ecf20Sopenharmony_ci#define FC_TEC_LL BIT_4	/* Longwave Laser */
50838c2ecf20Sopenharmony_ci#define FC_TEC_ACT BIT_3	/* Active cable */
50848c2ecf20Sopenharmony_ci#define FC_TEC_PAS BIT_2	/* Passive cable */
50858c2ecf20Sopenharmony_ci	u8 fc_tec_cc8;
50868c2ecf20Sopenharmony_ci	/* Transmission Media */
50878c2ecf20Sopenharmony_ci#define FC_MED_TW BIT_7	/* Twin Ax */
50888c2ecf20Sopenharmony_ci#define FC_MED_TP BIT_6	/* Twited Pair */
50898c2ecf20Sopenharmony_ci#define FC_MED_MI BIT_5	/* Min Coax */
50908c2ecf20Sopenharmony_ci#define FC_MED_TV BIT_4	/* Video Coax */
50918c2ecf20Sopenharmony_ci#define FC_MED_M6 BIT_3	/* Multimode, 62.5um */
50928c2ecf20Sopenharmony_ci#define FC_MED_M5 BIT_2	/* Multimode, 50um */
50938c2ecf20Sopenharmony_ci#define FC_MED_SM BIT_0	/* Single Mode */
50948c2ecf20Sopenharmony_ci	u8 fc_med_cc9;
50958c2ecf20Sopenharmony_ci	/* speed FC_SP_12: 12*100M = 1200 MB/s */
50968c2ecf20Sopenharmony_ci#define FC_SP_12 BIT_7
50978c2ecf20Sopenharmony_ci#define FC_SP_8  BIT_6
50988c2ecf20Sopenharmony_ci#define FC_SP_16 BIT_5
50998c2ecf20Sopenharmony_ci#define FC_SP_4  BIT_4
51008c2ecf20Sopenharmony_ci#define FC_SP_32 BIT_3
51018c2ecf20Sopenharmony_ci#define FC_SP_2  BIT_2
51028c2ecf20Sopenharmony_ci#define FC_SP_1  BIT_0
51038c2ecf20Sopenharmony_ci	u8 fc_sp_cc10;
51048c2ecf20Sopenharmony_ci	u8 encode;
51058c2ecf20Sopenharmony_ci	u8 bitrate;
51068c2ecf20Sopenharmony_ci	u8 rate_id;
51078c2ecf20Sopenharmony_ci	u8 length_km;		/* offset 14/eh */
51088c2ecf20Sopenharmony_ci	u8 length_100m;
51098c2ecf20Sopenharmony_ci	u8 length_50um_10m;
51108c2ecf20Sopenharmony_ci	u8 length_62um_10m;
51118c2ecf20Sopenharmony_ci	u8 length_om4_10m;
51128c2ecf20Sopenharmony_ci	u8 length_om3_10m;
51138c2ecf20Sopenharmony_ci#define SFF_VEN_NAME_LEN 16
51148c2ecf20Sopenharmony_ci	u8 vendor_name[SFF_VEN_NAME_LEN];	/* offset 20/14h */
51158c2ecf20Sopenharmony_ci	u8 tx_compat;
51168c2ecf20Sopenharmony_ci	u8 vendor_oui[3];
51178c2ecf20Sopenharmony_ci#define SFF_PART_NAME_LEN 16
51188c2ecf20Sopenharmony_ci	u8 vendor_pn[SFF_PART_NAME_LEN];	/* part number */
51198c2ecf20Sopenharmony_ci	u8 vendor_rev[4];
51208c2ecf20Sopenharmony_ci	u8 wavelength[2];
51218c2ecf20Sopenharmony_ci	u8 resv;
51228c2ecf20Sopenharmony_ci	u8 cc_base;
51238c2ecf20Sopenharmony_ci	u8 options[2];	/* offset 64 */
51248c2ecf20Sopenharmony_ci	u8 br_max;
51258c2ecf20Sopenharmony_ci	u8 br_min;
51268c2ecf20Sopenharmony_ci	u8 vendor_sn[16];
51278c2ecf20Sopenharmony_ci	u8 date_code[8];
51288c2ecf20Sopenharmony_ci	u8 diag;
51298c2ecf20Sopenharmony_ci	u8 enh_options;
51308c2ecf20Sopenharmony_ci	u8 sff_revision;
51318c2ecf20Sopenharmony_ci	u8 cc_ext;
51328c2ecf20Sopenharmony_ci	u8 vendor_specific[32];
51338c2ecf20Sopenharmony_ci	u8 resv2[128];
51348c2ecf20Sopenharmony_ci};
51358c2ecf20Sopenharmony_ci
51368c2ecf20Sopenharmony_ci/* BPM -- Buffer Plus Management support. */
51378c2ecf20Sopenharmony_ci#define IS_BPM_CAPABLE(ha) \
51388c2ecf20Sopenharmony_ci	(IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || \
51398c2ecf20Sopenharmony_ci	 IS_QLA27XX(ha) || IS_QLA28XX(ha))
51408c2ecf20Sopenharmony_ci#define IS_BPM_RANGE_CAPABLE(ha) \
51418c2ecf20Sopenharmony_ci	(IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
51428c2ecf20Sopenharmony_ci#define IS_BPM_ENABLED(vha) \
51438c2ecf20Sopenharmony_ci	(ql2xautodetectsfp && !vha->vp_idx && IS_BPM_CAPABLE(vha->hw))
51448c2ecf20Sopenharmony_ci
51458c2ecf20Sopenharmony_ci#define FLASH_SEMAPHORE_REGISTER_ADDR   0x00101016
51468c2ecf20Sopenharmony_ci
51478c2ecf20Sopenharmony_ci#define USER_CTRL_IRQ(_ha) (ql2xuctrlirq && QLA_TGT_MODE_ENABLED() && \
51488c2ecf20Sopenharmony_ci	(IS_QLA27XX(_ha) || IS_QLA28XX(_ha) || IS_QLA83XX(_ha)))
51498c2ecf20Sopenharmony_ci
51508c2ecf20Sopenharmony_ci#define SAVE_TOPO(_ha) { \
51518c2ecf20Sopenharmony_ci	if (_ha->current_topology)				\
51528c2ecf20Sopenharmony_ci		_ha->prev_topology = _ha->current_topology;     \
51538c2ecf20Sopenharmony_ci}
51548c2ecf20Sopenharmony_ci
51558c2ecf20Sopenharmony_ci#define N2N_TOPO(ha) \
51568c2ecf20Sopenharmony_ci	((ha->prev_topology == ISP_CFG_N && !ha->current_topology) || \
51578c2ecf20Sopenharmony_ci	 ha->current_topology == ISP_CFG_N || \
51588c2ecf20Sopenharmony_ci	 !ha->current_topology)
51598c2ecf20Sopenharmony_ci
51608c2ecf20Sopenharmony_ci#define QLA_N2N_WAIT_TIME	5 /* 2 * ra_tov(n2n) + 1 */
51618c2ecf20Sopenharmony_ci
51628c2ecf20Sopenharmony_ci#define NVME_TYPE(fcport) \
51638c2ecf20Sopenharmony_ci	(fcport->fc4_type & FS_FC4TYPE_NVME) \
51648c2ecf20Sopenharmony_ci
51658c2ecf20Sopenharmony_ci#define FCP_TYPE(fcport) \
51668c2ecf20Sopenharmony_ci	(fcport->fc4_type & FS_FC4TYPE_FCP) \
51678c2ecf20Sopenharmony_ci
51688c2ecf20Sopenharmony_ci#define NVME_ONLY_TARGET(fcport) \
51698c2ecf20Sopenharmony_ci	(NVME_TYPE(fcport) && !FCP_TYPE(fcport))  \
51708c2ecf20Sopenharmony_ci
51718c2ecf20Sopenharmony_ci#define NVME_FCP_TARGET(fcport) \
51728c2ecf20Sopenharmony_ci	(FCP_TYPE(fcport) && NVME_TYPE(fcport)) \
51738c2ecf20Sopenharmony_ci
51748c2ecf20Sopenharmony_ci#define NVME_TARGET(ha, fcport) \
51758c2ecf20Sopenharmony_ci	((NVME_FCP_TARGET(fcport) && \
51768c2ecf20Sopenharmony_ci	(ha->fc4_type_priority == FC4_PRIORITY_NVME)) || \
51778c2ecf20Sopenharmony_ci	NVME_ONLY_TARGET(fcport)) \
51788c2ecf20Sopenharmony_ci
51798c2ecf20Sopenharmony_ci#define PRLI_PHASE(_cls) \
51808c2ecf20Sopenharmony_ci	((_cls == DSC_LS_PRLI_PEND) || (_cls == DSC_LS_PRLI_COMP))
51818c2ecf20Sopenharmony_ci
51828c2ecf20Sopenharmony_ci#include "qla_target.h"
51838c2ecf20Sopenharmony_ci#include "qla_gbl.h"
51848c2ecf20Sopenharmony_ci#include "qla_dbg.h"
51858c2ecf20Sopenharmony_ci#include "qla_inline.h"
51868c2ecf20Sopenharmony_ci
51878c2ecf20Sopenharmony_ci#define IS_SESSION_DELETED(_fcport) (_fcport->disc_state == DSC_DELETE_PEND || \
51888c2ecf20Sopenharmony_ci				      _fcport->disc_state == DSC_DELETED)
51898c2ecf20Sopenharmony_ci
51908c2ecf20Sopenharmony_ci#endif
5191