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_MR_H
78c2ecf20Sopenharmony_ci#define __QLA_MR_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "qla_dsd.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * The PCI VendorID and DeviceID for our board.
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISPF001		0xF001
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* FX00 specific definitions */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define FX00_COMMAND_TYPE_7	0x07	/* Command Type 7 entry for 7XXX */
198c2ecf20Sopenharmony_cistruct cmd_type_7_fx00 {
208c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
218c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
228c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
238c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
268c2ecf20Sopenharmony_ci	uint8_t reserved_0;
278c2ecf20Sopenharmony_ci	uint8_t port_path_ctrl;
288c2ecf20Sopenharmony_ci	uint16_t reserved_1;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	__le16 tgt_idx;		/* Target Idx. */
318c2ecf20Sopenharmony_ci	uint16_t timeout;		/* Command timeout. */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	__le16 dseg_count;		/* Data segment count. */
348c2ecf20Sopenharmony_ci	uint8_t	scsi_rsp_dsd_len;
358c2ecf20Sopenharmony_ci	uint8_t reserved_2;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	struct scsi_lun lun;		/* LUN (LE). */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	uint8_t cntrl_flags;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	uint8_t task_mgmt_flags;	/* Task management flags. */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	uint8_t task;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	uint8_t crn;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	uint8_t fcp_cdb[MAX_CMDSZ];	/* SCSI command words. */
488c2ecf20Sopenharmony_ci	__le32 byte_count;		/* Total byte count. */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	struct dsd64 dsd;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define	STATUS_TYPE_FX00	0x01		/* Status entry. */
548c2ecf20Sopenharmony_cistruct sts_entry_fx00 {
558c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
568c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
578c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
588c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
618c2ecf20Sopenharmony_ci	uint32_t reserved_3;		/* System handle. */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	__le16 comp_status;		/* Completion status. */
648c2ecf20Sopenharmony_ci	uint16_t reserved_0;		/* OX_ID used by the firmware. */
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	__le32 residual_len;		/* FW calc residual transfer length. */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	uint16_t reserved_1;
698c2ecf20Sopenharmony_ci	uint16_t state_flags;		/* State flags. */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	uint16_t reserved_2;
728c2ecf20Sopenharmony_ci	__le16 scsi_status;		/* SCSI status. */
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	uint32_t sense_len;		/* FCP SENSE length. */
758c2ecf20Sopenharmony_ci	uint8_t data[32];		/* FCP response/sense information. */
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define MAX_HANDLE_COUNT	15
808c2ecf20Sopenharmony_ci#define MULTI_STATUS_TYPE_FX00	0x0D
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistruct multi_sts_entry_fx00 {
838c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
848c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
858c2ecf20Sopenharmony_ci	uint8_t handle_count;
868c2ecf20Sopenharmony_ci	uint8_t entry_status;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	__le32 handles[MAX_HANDLE_COUNT];
898c2ecf20Sopenharmony_ci};
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define TSK_MGMT_IOCB_TYPE_FX00		0x05
928c2ecf20Sopenharmony_cistruct tsk_mgmt_entry_fx00 {
938c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
948c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
958c2ecf20Sopenharmony_ci	uint8_t sys_define;
968c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	uint32_t reserved_0;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	__le16 tgt_id;		/* Target Idx. */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	uint16_t reserved_1;
1058c2ecf20Sopenharmony_ci	uint16_t reserved_3;
1068c2ecf20Sopenharmony_ci	uint16_t reserved_4;
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	struct scsi_lun lun;		/* LUN (LE). */
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	__le32 control_flags;		/* Control Flags. */
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	uint8_t reserved_2[32];
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define	ABORT_IOCB_TYPE_FX00	0x08		/* Abort IOCB status. */
1178c2ecf20Sopenharmony_cistruct abort_iocb_entry_fx00 {
1188c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
1198c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
1208c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
1218c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
1248c2ecf20Sopenharmony_ci	__le32 reserved_0;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	__le16 tgt_id_sts;		/* Completion status. */
1278c2ecf20Sopenharmony_ci	__le16 options;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	uint32_t abort_handle;		/* System handle. */
1308c2ecf20Sopenharmony_ci	__le32 reserved_2;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	__le16 req_que_no;
1338c2ecf20Sopenharmony_ci	uint8_t reserved_1[38];
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define IOCTL_IOSB_TYPE_FX00	0x0C
1378c2ecf20Sopenharmony_cistruct ioctl_iocb_entry_fx00 {
1388c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
1398c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
1408c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System defined. */
1418c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
1448c2ecf20Sopenharmony_ci	uint32_t reserved_0;		/* System handle. */
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	uint16_t comp_func_num;
1478c2ecf20Sopenharmony_ci	__le16 fw_iotcl_flags;
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	__le32 dataword_r;		/* Data word returned */
1508c2ecf20Sopenharmony_ci	uint32_t adapid;		/* Adapter ID */
1518c2ecf20Sopenharmony_ci	uint32_t dataword_r_extra;
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	__le32 seq_no;
1548c2ecf20Sopenharmony_ci	uint8_t reserved_2[20];
1558c2ecf20Sopenharmony_ci	uint32_t residuallen;
1568c2ecf20Sopenharmony_ci	__le32 status;
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define STATUS_CONT_TYPE_FX00 0x04
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci#define FX00_IOCB_TYPE		0x0B
1628c2ecf20Sopenharmony_cistruct fxdisc_entry_fx00 {
1638c2ecf20Sopenharmony_ci	uint8_t entry_type;		/* Entry type. */
1648c2ecf20Sopenharmony_ci	uint8_t entry_count;		/* Entry count. */
1658c2ecf20Sopenharmony_ci	uint8_t sys_define;		/* System Defined. */
1668c2ecf20Sopenharmony_ci	uint8_t entry_status;		/* Entry Status. */
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	uint32_t handle;		/* System handle. */
1698c2ecf20Sopenharmony_ci	__le32 reserved_0;		/* System handle. */
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	__le16 func_num;
1728c2ecf20Sopenharmony_ci	__le16 req_xfrcnt;
1738c2ecf20Sopenharmony_ci	__le16 req_dsdcnt;
1748c2ecf20Sopenharmony_ci	__le16 rsp_xfrcnt;
1758c2ecf20Sopenharmony_ci	__le16 rsp_dsdcnt;
1768c2ecf20Sopenharmony_ci	uint8_t flags;
1778c2ecf20Sopenharmony_ci	uint8_t reserved_1;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	struct dsd64 dseg_rq;
1808c2ecf20Sopenharmony_ci	struct dsd64 dseg_rsp;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	__le32 dataword;
1838c2ecf20Sopenharmony_ci	__le32 adapid;
1848c2ecf20Sopenharmony_ci	__le32 adapid_hi;
1858c2ecf20Sopenharmony_ci	__le32 dataword_extra;
1868c2ecf20Sopenharmony_ci};
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cistruct qlafx00_tgt_node_info {
1898c2ecf20Sopenharmony_ci	uint8_t tgt_node_wwpn[WWN_SIZE];
1908c2ecf20Sopenharmony_ci	uint8_t tgt_node_wwnn[WWN_SIZE];
1918c2ecf20Sopenharmony_ci	uint32_t tgt_node_state;
1928c2ecf20Sopenharmony_ci	uint8_t reserved[128];
1938c2ecf20Sopenharmony_ci	uint32_t reserved_1[8];
1948c2ecf20Sopenharmony_ci	uint64_t reserved_2[4];
1958c2ecf20Sopenharmony_ci} __packed;
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci#define QLAFX00_TGT_NODE_INFO sizeof(struct qlafx00_tgt_node_info)
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define QLAFX00_LINK_STATUS_DOWN	0x10
2008c2ecf20Sopenharmony_ci#define QLAFX00_LINK_STATUS_UP		0x11
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci#define QLAFX00_PORT_SPEED_2G	0x2
2038c2ecf20Sopenharmony_ci#define QLAFX00_PORT_SPEED_4G	0x4
2048c2ecf20Sopenharmony_ci#define QLAFX00_PORT_SPEED_8G	0x8
2058c2ecf20Sopenharmony_ci#define QLAFX00_PORT_SPEED_10G	0xa
2068c2ecf20Sopenharmony_cistruct port_info_data {
2078c2ecf20Sopenharmony_ci	uint8_t         port_state;
2088c2ecf20Sopenharmony_ci	uint8_t         port_type;
2098c2ecf20Sopenharmony_ci	uint16_t        port_identifier;
2108c2ecf20Sopenharmony_ci	uint32_t        up_port_state;
2118c2ecf20Sopenharmony_ci	uint8_t         fw_ver_num[32];
2128c2ecf20Sopenharmony_ci	uint8_t         portal_attrib;
2138c2ecf20Sopenharmony_ci	uint16_t        host_option;
2148c2ecf20Sopenharmony_ci	uint8_t         reset_delay;
2158c2ecf20Sopenharmony_ci	uint8_t         pdwn_retry_cnt;
2168c2ecf20Sopenharmony_ci	uint16_t        max_luns2tgt;
2178c2ecf20Sopenharmony_ci	uint8_t         risc_ver;
2188c2ecf20Sopenharmony_ci	uint8_t         pconn_option;
2198c2ecf20Sopenharmony_ci	uint16_t        risc_option;
2208c2ecf20Sopenharmony_ci	uint16_t        max_frame_len;
2218c2ecf20Sopenharmony_ci	uint16_t        max_iocb_alloc;
2228c2ecf20Sopenharmony_ci	uint16_t        exec_throttle;
2238c2ecf20Sopenharmony_ci	uint8_t         retry_cnt;
2248c2ecf20Sopenharmony_ci	uint8_t         retry_delay;
2258c2ecf20Sopenharmony_ci	uint8_t         port_name[8];
2268c2ecf20Sopenharmony_ci	uint8_t         port_id[3];
2278c2ecf20Sopenharmony_ci	uint8_t         link_status;
2288c2ecf20Sopenharmony_ci	uint8_t         plink_rate;
2298c2ecf20Sopenharmony_ci	uint32_t        link_config;
2308c2ecf20Sopenharmony_ci	uint16_t        adap_haddr;
2318c2ecf20Sopenharmony_ci	uint8_t         tgt_disc;
2328c2ecf20Sopenharmony_ci	uint8_t         log_tout;
2338c2ecf20Sopenharmony_ci	uint8_t         node_name[8];
2348c2ecf20Sopenharmony_ci	uint16_t        erisc_opt1;
2358c2ecf20Sopenharmony_ci	uint8_t         resp_acc_tmr;
2368c2ecf20Sopenharmony_ci	uint8_t         intr_del_tmr;
2378c2ecf20Sopenharmony_ci	uint8_t         erisc_opt2;
2388c2ecf20Sopenharmony_ci	uint8_t         alt_port_name[8];
2398c2ecf20Sopenharmony_ci	uint8_t         alt_node_name[8];
2408c2ecf20Sopenharmony_ci	uint8_t         link_down_tout;
2418c2ecf20Sopenharmony_ci	uint8_t         conn_type;
2428c2ecf20Sopenharmony_ci	uint8_t         fc_fw_mode;
2438c2ecf20Sopenharmony_ci	uint32_t        uiReserved[48];
2448c2ecf20Sopenharmony_ci} __packed;
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/* OS Type Designations */
2478c2ecf20Sopenharmony_ci#define OS_TYPE_UNKNOWN             0
2488c2ecf20Sopenharmony_ci#define OS_TYPE_LINUX               2
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci/* Linux Info */
2518c2ecf20Sopenharmony_ci#define SYSNAME_LENGTH              128
2528c2ecf20Sopenharmony_ci#define NODENAME_LENGTH             64
2538c2ecf20Sopenharmony_ci#define RELEASE_LENGTH              64
2548c2ecf20Sopenharmony_ci#define VERSION_LENGTH              64
2558c2ecf20Sopenharmony_ci#define MACHINE_LENGTH              64
2568c2ecf20Sopenharmony_ci#define DOMNAME_LENGTH              64
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistruct host_system_info {
2598c2ecf20Sopenharmony_ci	uint32_t os_type;
2608c2ecf20Sopenharmony_ci	char    sysname[SYSNAME_LENGTH];
2618c2ecf20Sopenharmony_ci	char    nodename[NODENAME_LENGTH];
2628c2ecf20Sopenharmony_ci	char    release[RELEASE_LENGTH];
2638c2ecf20Sopenharmony_ci	char    version[VERSION_LENGTH];
2648c2ecf20Sopenharmony_ci	char    machine[MACHINE_LENGTH];
2658c2ecf20Sopenharmony_ci	char    domainname[DOMNAME_LENGTH];
2668c2ecf20Sopenharmony_ci	char    hostdriver[VERSION_LENGTH];
2678c2ecf20Sopenharmony_ci	uint32_t reserved[64];
2688c2ecf20Sopenharmony_ci} __packed;
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_cistruct register_host_info {
2718c2ecf20Sopenharmony_ci	struct host_system_info     hsi;	/* host system info */
2728c2ecf20Sopenharmony_ci	uint64_t        utc;			/* UTC (system time) */
2738c2ecf20Sopenharmony_ci	uint32_t        reserved[64];		/* future additions */
2748c2ecf20Sopenharmony_ci} __packed;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci#define QLAFX00_PORT_DATA_INFO (sizeof(struct port_info_data))
2788c2ecf20Sopenharmony_ci#define QLAFX00_TGT_NODE_LIST_SIZE (sizeof(uint32_t) * 32)
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistruct config_info_data {
2818c2ecf20Sopenharmony_ci	uint8_t		model_num[16];
2828c2ecf20Sopenharmony_ci	uint8_t		model_description[80];
2838c2ecf20Sopenharmony_ci	uint8_t		reserved0[160];
2848c2ecf20Sopenharmony_ci	uint8_t		symbolic_name[64];
2858c2ecf20Sopenharmony_ci	uint8_t		serial_num[32];
2868c2ecf20Sopenharmony_ci	uint8_t		hw_version[16];
2878c2ecf20Sopenharmony_ci	uint8_t		fw_version[16];
2888c2ecf20Sopenharmony_ci	uint8_t		uboot_version[16];
2898c2ecf20Sopenharmony_ci	uint8_t		fru_serial_num[32];
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	uint8_t		fc_port_count;
2928c2ecf20Sopenharmony_ci	uint8_t		iscsi_port_count;
2938c2ecf20Sopenharmony_ci	uint8_t		reserved1[2];
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci	uint8_t		mode;
2968c2ecf20Sopenharmony_ci	uint8_t		log_level;
2978c2ecf20Sopenharmony_ci	uint8_t		reserved2[2];
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	uint32_t	log_size;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	uint8_t		tgt_pres_mode;
3028c2ecf20Sopenharmony_ci	uint8_t		iqn_flags;
3038c2ecf20Sopenharmony_ci	uint8_t		lun_mapping;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	uint64_t	adapter_id;
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	uint32_t	cluster_key_len;
3088c2ecf20Sopenharmony_ci	uint8_t		cluster_key[16];
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci	uint64_t	cluster_master_id;
3118c2ecf20Sopenharmony_ci	uint64_t	cluster_slave_id;
3128c2ecf20Sopenharmony_ci	uint8_t		cluster_flags;
3138c2ecf20Sopenharmony_ci	uint32_t	enabled_capabilities;
3148c2ecf20Sopenharmony_ci	uint32_t	nominal_temp_value;
3158c2ecf20Sopenharmony_ci} __packed;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci#define FXDISC_GET_CONFIG_INFO		0x01
3188c2ecf20Sopenharmony_ci#define FXDISC_GET_PORT_INFO		0x02
3198c2ecf20Sopenharmony_ci#define FXDISC_GET_TGT_NODE_INFO	0x80
3208c2ecf20Sopenharmony_ci#define FXDISC_GET_TGT_NODE_LIST	0x81
3218c2ecf20Sopenharmony_ci#define FXDISC_REG_HOST_INFO		0x99
3228c2ecf20Sopenharmony_ci#define FXDISC_ABORT_IOCTL		0xff
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci#define QLAFX00_HBA_ICNTRL_REG		0x20B08
3258c2ecf20Sopenharmony_ci#define QLAFX00_ICR_ENB_MASK            0x80000000
3268c2ecf20Sopenharmony_ci#define QLAFX00_ICR_DIS_MASK            0x7fffffff
3278c2ecf20Sopenharmony_ci#define QLAFX00_HST_RST_REG		0x18264
3288c2ecf20Sopenharmony_ci#define QLAFX00_SOC_TEMP_REG		0x184C4
3298c2ecf20Sopenharmony_ci#define QLAFX00_HST_TO_HBA_REG		0x20A04
3308c2ecf20Sopenharmony_ci#define QLAFX00_HBA_TO_HOST_REG		0x21B70
3318c2ecf20Sopenharmony_ci#define QLAFX00_HST_INT_STS_BITS	0x7
3328c2ecf20Sopenharmony_ci#define QLAFX00_BAR1_BASE_ADDR_REG	0x40018
3338c2ecf20Sopenharmony_ci#define QLAFX00_PEX0_WIN0_BASE_ADDR_REG	0x41824
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci#define QLAFX00_INTR_MB_CMPLT		0x1
3368c2ecf20Sopenharmony_ci#define QLAFX00_INTR_RSP_CMPLT		0x2
3378c2ecf20Sopenharmony_ci#define QLAFX00_INTR_ASYNC_CMPLT	0x4
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci#define QLAFX00_MBA_SYSTEM_ERR		0x8002
3408c2ecf20Sopenharmony_ci#define QLAFX00_MBA_TEMP_OVER		0x8005
3418c2ecf20Sopenharmony_ci#define QLAFX00_MBA_TEMP_NORM		0x8006
3428c2ecf20Sopenharmony_ci#define	QLAFX00_MBA_TEMP_CRIT		0x8007
3438c2ecf20Sopenharmony_ci#define QLAFX00_MBA_LINK_UP		0x8011
3448c2ecf20Sopenharmony_ci#define QLAFX00_MBA_LINK_DOWN		0x8012
3458c2ecf20Sopenharmony_ci#define QLAFX00_MBA_PORT_UPDATE		0x8014
3468c2ecf20Sopenharmony_ci#define QLAFX00_MBA_SHUTDOWN_RQSTD	0x8062
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci#define SOC_SW_RST_CONTROL_REG_CORE0     0x0020800
3498c2ecf20Sopenharmony_ci#define SOC_FABRIC_RST_CONTROL_REG       0x0020840
3508c2ecf20Sopenharmony_ci#define SOC_FABRIC_CONTROL_REG           0x0020200
3518c2ecf20Sopenharmony_ci#define SOC_FABRIC_CONFIG_REG            0x0020204
3528c2ecf20Sopenharmony_ci#define SOC_PWR_MANAGEMENT_PWR_DOWN_REG  0x001820C
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci#define SOC_INTERRUPT_SOURCE_I_CONTROL_REG     0x0020B00
3558c2ecf20Sopenharmony_ci#define SOC_CORE_TIMER_REG                     0x0021850
3568c2ecf20Sopenharmony_ci#define SOC_IRQ_ACK_REG                        0x00218b4
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define CONTINUE_A64_TYPE_FX00	0x03	/* Continuation entry. */
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define QLAFX00_SET_HST_INTR(ha, value) \
3618c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HST_TO_HBA_REG, \
3628c2ecf20Sopenharmony_ci	value)
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci#define QLAFX00_CLR_HST_INTR(ha, value) \
3658c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG, \
3668c2ecf20Sopenharmony_ci	~value)
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci#define QLAFX00_RD_INTR_REG(ha) \
3698c2ecf20Sopenharmony_ci	rd_reg_dword((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG)
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci#define QLAFX00_CLR_INTR_REG(ha, value) \
3728c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG, \
3738c2ecf20Sopenharmony_ci	~value)
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci#define QLAFX00_SET_HBA_SOC_REG(ha, off, val)\
3768c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + off, val)
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci#define QLAFX00_GET_HBA_SOC_REG(ha, off)\
3798c2ecf20Sopenharmony_ci	rd_reg_dword((ha)->cregbase + off)
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#define QLAFX00_HBA_RST_REG(ha, val)\
3828c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HST_RST_REG, val)
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci#define QLAFX00_RD_ICNTRL_REG(ha) \
3858c2ecf20Sopenharmony_ci	rd_reg_dword((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG)
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci#define QLAFX00_ENABLE_ICNTRL_REG(ha) \
3888c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG, \
3898c2ecf20Sopenharmony_ci	(QLAFX00_GET_HBA_SOC_REG(ha, QLAFX00_HBA_ICNTRL_REG) | \
3908c2ecf20Sopenharmony_ci	 QLAFX00_ICR_ENB_MASK))
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define QLAFX00_DISABLE_ICNTRL_REG(ha) \
3938c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG, \
3948c2ecf20Sopenharmony_ci	(QLAFX00_GET_HBA_SOC_REG(ha, QLAFX00_HBA_ICNTRL_REG) & \
3958c2ecf20Sopenharmony_ci	 QLAFX00_ICR_DIS_MASK))
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci#define QLAFX00_RD_REG(ha, off) \
3988c2ecf20Sopenharmony_ci	rd_reg_dword((ha)->cregbase + off)
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci#define QLAFX00_WR_REG(ha, off, val) \
4018c2ecf20Sopenharmony_ci	wrt_reg_dword((ha)->cregbase + off, val)
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistruct qla_mt_iocb_rqst_fx00 {
4048c2ecf20Sopenharmony_ci	__le32 reserved_0;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	__le16 func_type;
4078c2ecf20Sopenharmony_ci	uint8_t flags;
4088c2ecf20Sopenharmony_ci	uint8_t reserved_1;
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci	__le32 dataword;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	__le32 adapid;
4138c2ecf20Sopenharmony_ci	__le32 adapid_hi;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	__le32 dataword_extra;
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci	__le16 req_len;
4188c2ecf20Sopenharmony_ci	__le16 reserved_2;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	__le16 rsp_len;
4218c2ecf20Sopenharmony_ci	__le16 reserved_3;
4228c2ecf20Sopenharmony_ci};
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistruct qla_mt_iocb_rsp_fx00 {
4258c2ecf20Sopenharmony_ci	uint32_t reserved_1;
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	uint16_t func_type;
4288c2ecf20Sopenharmony_ci	__le16 ioctl_flags;
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	__le32 ioctl_data;
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	uint32_t adapid;
4338c2ecf20Sopenharmony_ci	uint32_t adapid_hi;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	uint32_t reserved_2;
4368c2ecf20Sopenharmony_ci	__le32 seq_number;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	uint8_t reserved_3[20];
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	int32_t res_count;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	__le32 status;
4438c2ecf20Sopenharmony_ci};
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci#define MAILBOX_REGISTER_COUNT_FX00	16
4478c2ecf20Sopenharmony_ci#define AEN_MAILBOX_REGISTER_COUNT_FX00	8
4488c2ecf20Sopenharmony_ci#define MAX_FIBRE_DEVICES_FX00	512
4498c2ecf20Sopenharmony_ci#define MAX_LUNS_FX00		0x1024
4508c2ecf20Sopenharmony_ci#define MAX_TARGETS_FX00	MAX_ISA_DEVICES
4518c2ecf20Sopenharmony_ci#define REQUEST_ENTRY_CNT_FX00		512	/* Number of request entries. */
4528c2ecf20Sopenharmony_ci#define RESPONSE_ENTRY_CNT_FX00		256	/* Number of response entries.*/
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/*
4558c2ecf20Sopenharmony_ci * Firmware state codes for QLAFX00 adapters
4568c2ecf20Sopenharmony_ci */
4578c2ecf20Sopenharmony_ci#define FSTATE_FX00_CONFIG_WAIT     0x0000	/* Waiting for driver to issue
4588c2ecf20Sopenharmony_ci						 * Initialize FW Mbox cmd
4598c2ecf20Sopenharmony_ci						 */
4608c2ecf20Sopenharmony_ci#define FSTATE_FX00_INITIALIZED     0x1000	/* FW has been initialized by
4618c2ecf20Sopenharmony_ci						 * the driver
4628c2ecf20Sopenharmony_ci						 */
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci#define FX00_DEF_RATOV	10
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_cistruct mr_data_fx00 {
4678c2ecf20Sopenharmony_ci	uint8_t	symbolic_name[64];
4688c2ecf20Sopenharmony_ci	uint8_t	serial_num[32];
4698c2ecf20Sopenharmony_ci	uint8_t	hw_version[16];
4708c2ecf20Sopenharmony_ci	uint8_t	fw_version[16];
4718c2ecf20Sopenharmony_ci	uint8_t	uboot_version[16];
4728c2ecf20Sopenharmony_ci	uint8_t	fru_serial_num[32];
4738c2ecf20Sopenharmony_ci	fc_port_t       fcport;		/* fcport used for requests
4748c2ecf20Sopenharmony_ci					 * that are not linked
4758c2ecf20Sopenharmony_ci					 * to a particular target
4768c2ecf20Sopenharmony_ci					 */
4778c2ecf20Sopenharmony_ci	uint8_t fw_hbt_en;
4788c2ecf20Sopenharmony_ci	uint8_t fw_hbt_cnt;
4798c2ecf20Sopenharmony_ci	uint8_t fw_hbt_miss_cnt;
4808c2ecf20Sopenharmony_ci	uint32_t old_fw_hbt_cnt;
4818c2ecf20Sopenharmony_ci	uint16_t fw_reset_timer_tick;
4828c2ecf20Sopenharmony_ci	uint8_t fw_reset_timer_exp;
4838c2ecf20Sopenharmony_ci	uint16_t fw_critemp_timer_tick;
4848c2ecf20Sopenharmony_ci	uint32_t old_aenmbx0_state;
4858c2ecf20Sopenharmony_ci	uint32_t critical_temperature;
4868c2ecf20Sopenharmony_ci	bool extended_io_enabled;
4878c2ecf20Sopenharmony_ci	bool host_info_resend;
4888c2ecf20Sopenharmony_ci	uint8_t hinfo_resend_timer_tick;
4898c2ecf20Sopenharmony_ci};
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci#define QLAFX00_EXTENDED_IO_EN_MASK    0x20
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci/*
4948c2ecf20Sopenharmony_ci * SoC Junction Temperature is stored in
4958c2ecf20Sopenharmony_ci * bits 9:1 of SoC Junction Temperature Register
4968c2ecf20Sopenharmony_ci * in a firmware specific format format.
4978c2ecf20Sopenharmony_ci * To get the temperature in Celsius degrees
4988c2ecf20Sopenharmony_ci * the value from this bitfiled should be converted
4998c2ecf20Sopenharmony_ci * using this formula:
5008c2ecf20Sopenharmony_ci * Temperature (degrees C) = ((3,153,000 - (10,000 * X)) / 13,825)
5018c2ecf20Sopenharmony_ci * where X is the bit field value
5028c2ecf20Sopenharmony_ci * this macro reads the register, extracts the bitfield value,
5038c2ecf20Sopenharmony_ci * performs the calcualtions and returns temperature in Celsius
5048c2ecf20Sopenharmony_ci */
5058c2ecf20Sopenharmony_ci#define QLAFX00_GET_TEMPERATURE(ha) ((3153000 - (10000 * \
5068c2ecf20Sopenharmony_ci	((QLAFX00_RD_REG(ha, QLAFX00_SOC_TEMP_REG) & 0x3FE) >> 1))) / 13825)
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci#define QLAFX00_LOOP_DOWN_TIME		615     /* 600 */
5108c2ecf20Sopenharmony_ci#define QLAFX00_HEARTBEAT_INTERVAL	6	/* number of seconds */
5118c2ecf20Sopenharmony_ci#define QLAFX00_HEARTBEAT_MISS_CNT	3	/* number of miss */
5128c2ecf20Sopenharmony_ci#define QLAFX00_RESET_INTERVAL		120	/* number of seconds */
5138c2ecf20Sopenharmony_ci#define QLAFX00_MAX_RESET_INTERVAL	600	/* number of seconds */
5148c2ecf20Sopenharmony_ci#define QLAFX00_CRITEMP_INTERVAL	60	/* number of seconds */
5158c2ecf20Sopenharmony_ci#define QLAFX00_HINFO_RESEND_INTERVAL	60	/* number of seconds */
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci#define QLAFX00_CRITEMP_THRSHLD		80	/* Celsius degrees */
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci/* Max conncurrent IOs that can be queued */
5208c2ecf20Sopenharmony_ci#define QLAFX00_MAX_CANQUEUE		1024
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci/* IOCTL IOCB abort success */
5238c2ecf20Sopenharmony_ci#define QLAFX00_IOCTL_ICOB_ABORT_SUCCESS	0x68
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci#endif
526