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_BSG_H
78c2ecf20Sopenharmony_ci#define __QLA_BSG_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/* BSG Vendor specific commands */
108c2ecf20Sopenharmony_ci#define QL_VND_LOOPBACK		0x01
118c2ecf20Sopenharmony_ci#define QL_VND_A84_RESET	0x02
128c2ecf20Sopenharmony_ci#define QL_VND_A84_UPDATE_FW	0x03
138c2ecf20Sopenharmony_ci#define QL_VND_A84_MGMT_CMD	0x04
148c2ecf20Sopenharmony_ci#define QL_VND_IIDMA		0x05
158c2ecf20Sopenharmony_ci#define QL_VND_FCP_PRIO_CFG_CMD	0x06
168c2ecf20Sopenharmony_ci#define QL_VND_READ_FLASH	0x07
178c2ecf20Sopenharmony_ci#define QL_VND_UPDATE_FLASH	0x08
188c2ecf20Sopenharmony_ci#define QL_VND_SET_FRU_VERSION	0x0B
198c2ecf20Sopenharmony_ci#define QL_VND_READ_FRU_STATUS	0x0C
208c2ecf20Sopenharmony_ci#define QL_VND_WRITE_FRU_STATUS	0x0D
218c2ecf20Sopenharmony_ci#define QL_VND_DIAG_IO_CMD	0x0A
228c2ecf20Sopenharmony_ci#define QL_VND_WRITE_I2C	0x10
238c2ecf20Sopenharmony_ci#define QL_VND_READ_I2C		0x11
248c2ecf20Sopenharmony_ci#define QL_VND_FX00_MGMT_CMD	0x12
258c2ecf20Sopenharmony_ci#define QL_VND_SERDES_OP	0x13
268c2ecf20Sopenharmony_ci#define	QL_VND_SERDES_OP_EX	0x14
278c2ecf20Sopenharmony_ci#define QL_VND_GET_FLASH_UPDATE_CAPS    0x15
288c2ecf20Sopenharmony_ci#define QL_VND_SET_FLASH_UPDATE_CAPS    0x16
298c2ecf20Sopenharmony_ci#define QL_VND_GET_BBCR_DATA    0x17
308c2ecf20Sopenharmony_ci#define QL_VND_GET_PRIV_STATS	0x18
318c2ecf20Sopenharmony_ci#define QL_VND_DPORT_DIAGNOSTICS	0x19
328c2ecf20Sopenharmony_ci#define QL_VND_GET_PRIV_STATS_EX	0x1A
338c2ecf20Sopenharmony_ci#define QL_VND_SS_GET_FLASH_IMAGE_STATUS	0x1E
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* BSG Vendor specific subcode returns */
368c2ecf20Sopenharmony_ci#define EXT_STATUS_OK			0
378c2ecf20Sopenharmony_ci#define EXT_STATUS_ERR			1
388c2ecf20Sopenharmony_ci#define EXT_STATUS_BUSY			2
398c2ecf20Sopenharmony_ci#define EXT_STATUS_INVALID_PARAM	6
408c2ecf20Sopenharmony_ci#define EXT_STATUS_DATA_OVERRUN		7
418c2ecf20Sopenharmony_ci#define EXT_STATUS_DATA_UNDERRUN	8
428c2ecf20Sopenharmony_ci#define EXT_STATUS_MAILBOX		11
438c2ecf20Sopenharmony_ci#define EXT_STATUS_NO_MEMORY		17
448c2ecf20Sopenharmony_ci#define EXT_STATUS_DEVICE_OFFLINE	22
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/*
478c2ecf20Sopenharmony_ci * To support bidirectional iocb
488c2ecf20Sopenharmony_ci * BSG Vendor specific returns
498c2ecf20Sopenharmony_ci */
508c2ecf20Sopenharmony_ci#define EXT_STATUS_NOT_SUPPORTED	27
518c2ecf20Sopenharmony_ci#define EXT_STATUS_INVALID_CFG		28
528c2ecf20Sopenharmony_ci#define EXT_STATUS_DMA_ERR		29
538c2ecf20Sopenharmony_ci#define EXT_STATUS_TIMEOUT		30
548c2ecf20Sopenharmony_ci#define EXT_STATUS_THREAD_FAILED	31
558c2ecf20Sopenharmony_ci#define EXT_STATUS_DATA_CMP_FAILED	32
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* BSG definations for interpreting CommandSent field */
588c2ecf20Sopenharmony_ci#define INT_DEF_LB_LOOPBACK_CMD         0
598c2ecf20Sopenharmony_ci#define INT_DEF_LB_ECHO_CMD             1
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Loopback related definations */
628c2ecf20Sopenharmony_ci#define INTERNAL_LOOPBACK		0xF1
638c2ecf20Sopenharmony_ci#define EXTERNAL_LOOPBACK		0xF2
648c2ecf20Sopenharmony_ci#define ENABLE_INTERNAL_LOOPBACK	0x02
658c2ecf20Sopenharmony_ci#define ENABLE_EXTERNAL_LOOPBACK	0x04
668c2ecf20Sopenharmony_ci#define INTERNAL_LOOPBACK_MASK		0x000E
678c2ecf20Sopenharmony_ci#define MAX_ELS_FRAME_PAYLOAD		252
688c2ecf20Sopenharmony_ci#define ELS_OPCODE_BYTE			0x10
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* BSG Vendor specific definations */
718c2ecf20Sopenharmony_ci#define A84_ISSUE_WRITE_TYPE_CMD        0
728c2ecf20Sopenharmony_ci#define A84_ISSUE_READ_TYPE_CMD         1
738c2ecf20Sopenharmony_ci#define A84_CLEANUP_CMD                 2
748c2ecf20Sopenharmony_ci#define A84_ISSUE_RESET_OP_FW           3
758c2ecf20Sopenharmony_ci#define A84_ISSUE_RESET_DIAG_FW         4
768c2ecf20Sopenharmony_ci#define A84_ISSUE_UPDATE_OPFW_CMD       5
778c2ecf20Sopenharmony_ci#define A84_ISSUE_UPDATE_DIAGFW_CMD     6
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistruct qla84_mgmt_param {
808c2ecf20Sopenharmony_ci	union {
818c2ecf20Sopenharmony_ci		struct {
828c2ecf20Sopenharmony_ci			uint32_t start_addr;
838c2ecf20Sopenharmony_ci		} mem; /* for QLA84_MGMT_READ/WRITE_MEM */
848c2ecf20Sopenharmony_ci		struct {
858c2ecf20Sopenharmony_ci			uint32_t id;
868c2ecf20Sopenharmony_ci#define QLA84_MGMT_CONFIG_ID_UIF        1
878c2ecf20Sopenharmony_ci#define QLA84_MGMT_CONFIG_ID_FCOE_COS   2
888c2ecf20Sopenharmony_ci#define QLA84_MGMT_CONFIG_ID_PAUSE      3
898c2ecf20Sopenharmony_ci#define QLA84_MGMT_CONFIG_ID_TIMEOUTS   4
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci		uint32_t param0;
928c2ecf20Sopenharmony_ci		uint32_t param1;
938c2ecf20Sopenharmony_ci	} config; /* for QLA84_MGMT_CHNG_CONFIG */
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	struct {
968c2ecf20Sopenharmony_ci		uint32_t type;
978c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_CONFIG_LOG_DATA         1 /* Get Config Log Data */
988c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_LOG_DATA                2 /* Get Log Data */
998c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_PORT_STAT               3 /* Get Port Statistics */
1008c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_LIF_STAT                4 /* Get LIF Statistics  */
1018c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_ASIC_STAT               5 /* Get ASIC Statistics */
1028c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_CONFIG_PARAMS           6 /* Get Config Parameters */
1038c2ecf20Sopenharmony_ci#define QLA84_MGMT_INFO_PANIC_LOG               7 /* Get Panic Log */
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci		uint32_t context;
1068c2ecf20Sopenharmony_ci/*
1078c2ecf20Sopenharmony_ci* context definitions for QLA84_MGMT_INFO_CONFIG_LOG_DATA
1088c2ecf20Sopenharmony_ci*/
1098c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_DEBUG_LOG                    0
1108c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_LEARN_LOG                    1
1118c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_FC_ACL_INGRESS_LOG           2
1128c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_FC_ACL_EGRESS_LOG            3
1138c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_ETHERNET_ACL_INGRESS_LOG     4
1148c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_ETHERNET_ACL_EGRESS_LOG      5
1158c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_MESSAGE_TRANSMIT_LOG         6
1168c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_MESSAGE_RECEIVE_LOG          7
1178c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_LINK_EVENT_LOG               8
1188c2ecf20Sopenharmony_ci#define IC_LOG_DATA_LOG_ID_DCX_LOG                      9
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/*
1218c2ecf20Sopenharmony_ci* context definitions for QLA84_MGMT_INFO_PORT_STAT
1228c2ecf20Sopenharmony_ci*/
1238c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_ETHERNET_PORT0   0
1248c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_ETHERNET_PORT1   1
1258c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_NSL_PORT0        2
1268c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_NSL_PORT1        3
1278c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_FC_PORT0         4
1288c2ecf20Sopenharmony_ci#define IC_PORT_STATISTICS_PORT_NUMBER_FC_PORT1         5
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/*
1328c2ecf20Sopenharmony_ci* context definitions for QLA84_MGMT_INFO_LIF_STAT
1338c2ecf20Sopenharmony_ci*/
1348c2ecf20Sopenharmony_ci#define IC_LIF_STATISTICS_LIF_NUMBER_ETHERNET_PORT0     0
1358c2ecf20Sopenharmony_ci#define IC_LIF_STATISTICS_LIF_NUMBER_ETHERNET_PORT1     1
1368c2ecf20Sopenharmony_ci#define IC_LIF_STATISTICS_LIF_NUMBER_FC_PORT0           2
1378c2ecf20Sopenharmony_ci#define IC_LIF_STATISTICS_LIF_NUMBER_FC_PORT1           3
1388c2ecf20Sopenharmony_ci#define IC_LIF_STATISTICS_LIF_NUMBER_CPU                6
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci		} info; /* for QLA84_MGMT_GET_INFO */
1418c2ecf20Sopenharmony_ci	} u;
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistruct qla84_msg_mgmt {
1458c2ecf20Sopenharmony_ci	uint16_t cmd;
1468c2ecf20Sopenharmony_ci#define QLA84_MGMT_READ_MEM     0x00
1478c2ecf20Sopenharmony_ci#define QLA84_MGMT_WRITE_MEM    0x01
1488c2ecf20Sopenharmony_ci#define QLA84_MGMT_CHNG_CONFIG  0x02
1498c2ecf20Sopenharmony_ci#define QLA84_MGMT_GET_INFO     0x03
1508c2ecf20Sopenharmony_ci	uint16_t rsrvd;
1518c2ecf20Sopenharmony_ci	struct qla84_mgmt_param mgmtp;/* parameters for cmd */
1528c2ecf20Sopenharmony_ci	uint32_t len; /* bytes in payload following this struct */
1538c2ecf20Sopenharmony_ci	uint8_t payload[0]; /* payload for cmd */
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistruct qla_bsg_a84_mgmt {
1578c2ecf20Sopenharmony_ci	struct qla84_msg_mgmt mgmt;
1588c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cistruct qla_scsi_addr {
1618c2ecf20Sopenharmony_ci	uint16_t bus;
1628c2ecf20Sopenharmony_ci	uint16_t target;
1638c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cistruct qla_ext_dest_addr {
1668c2ecf20Sopenharmony_ci	union {
1678c2ecf20Sopenharmony_ci		uint8_t wwnn[8];
1688c2ecf20Sopenharmony_ci		uint8_t wwpn[8];
1698c2ecf20Sopenharmony_ci		uint8_t id[4];
1708c2ecf20Sopenharmony_ci		struct qla_scsi_addr scsi_addr;
1718c2ecf20Sopenharmony_ci	} dest_addr;
1728c2ecf20Sopenharmony_ci	uint16_t dest_type;
1738c2ecf20Sopenharmony_ci#define	EXT_DEF_TYPE_WWPN	2
1748c2ecf20Sopenharmony_ci	uint16_t lun;
1758c2ecf20Sopenharmony_ci	uint16_t padding[2];
1768c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_cistruct qla_port_param {
1798c2ecf20Sopenharmony_ci	struct qla_ext_dest_addr fc_scsi_addr;
1808c2ecf20Sopenharmony_ci	uint16_t mode;
1818c2ecf20Sopenharmony_ci	uint16_t speed;
1828c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* FRU VPD */
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci#define MAX_FRU_SIZE	36
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistruct qla_field_address {
1908c2ecf20Sopenharmony_ci	uint16_t offset;
1918c2ecf20Sopenharmony_ci	uint16_t device;
1928c2ecf20Sopenharmony_ci	uint16_t option;
1938c2ecf20Sopenharmony_ci} __packed;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistruct qla_field_info {
1968c2ecf20Sopenharmony_ci	uint8_t version[MAX_FRU_SIZE];
1978c2ecf20Sopenharmony_ci} __packed;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistruct qla_image_version {
2008c2ecf20Sopenharmony_ci	struct qla_field_address field_address;
2018c2ecf20Sopenharmony_ci	struct qla_field_info field_info;
2028c2ecf20Sopenharmony_ci} __packed;
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistruct qla_image_version_list {
2058c2ecf20Sopenharmony_ci	uint32_t count;
2068c2ecf20Sopenharmony_ci	struct qla_image_version version[0];
2078c2ecf20Sopenharmony_ci} __packed;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct qla_status_reg {
2108c2ecf20Sopenharmony_ci	struct qla_field_address field_address;
2118c2ecf20Sopenharmony_ci	uint8_t status_reg;
2128c2ecf20Sopenharmony_ci	uint8_t reserved[7];
2138c2ecf20Sopenharmony_ci} __packed;
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cistruct qla_i2c_access {
2168c2ecf20Sopenharmony_ci	uint16_t device;
2178c2ecf20Sopenharmony_ci	uint16_t offset;
2188c2ecf20Sopenharmony_ci	uint16_t option;
2198c2ecf20Sopenharmony_ci	uint16_t length;
2208c2ecf20Sopenharmony_ci	uint8_t  buffer[0x40];
2218c2ecf20Sopenharmony_ci} __packed;
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/* 26xx serdes register interface */
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/* serdes reg commands */
2268c2ecf20Sopenharmony_ci#define INT_SC_SERDES_READ_REG		1
2278c2ecf20Sopenharmony_ci#define INT_SC_SERDES_WRITE_REG		2
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistruct qla_serdes_reg {
2308c2ecf20Sopenharmony_ci	uint16_t cmd;
2318c2ecf20Sopenharmony_ci	uint16_t addr;
2328c2ecf20Sopenharmony_ci	uint16_t val;
2338c2ecf20Sopenharmony_ci} __packed;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cistruct qla_serdes_reg_ex {
2368c2ecf20Sopenharmony_ci	uint16_t cmd;
2378c2ecf20Sopenharmony_ci	uint32_t addr;
2388c2ecf20Sopenharmony_ci	uint32_t val;
2398c2ecf20Sopenharmony_ci} __packed;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistruct qla_flash_update_caps {
2428c2ecf20Sopenharmony_ci	uint64_t  capabilities;
2438c2ecf20Sopenharmony_ci	uint32_t  outage_duration;
2448c2ecf20Sopenharmony_ci	uint8_t   reserved[20];
2458c2ecf20Sopenharmony_ci} __packed;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci/* BB_CR Status */
2488c2ecf20Sopenharmony_ci#define QLA_BBCR_STATUS_DISABLED       0
2498c2ecf20Sopenharmony_ci#define QLA_BBCR_STATUS_ENABLED        1
2508c2ecf20Sopenharmony_ci#define QLA_BBCR_STATUS_UNKNOWN        2
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci/* BB_CR State */
2538c2ecf20Sopenharmony_ci#define QLA_BBCR_STATE_OFFLINE         0
2548c2ecf20Sopenharmony_ci#define QLA_BBCR_STATE_ONLINE          1
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci/* BB_CR Offline Reason Code */
2578c2ecf20Sopenharmony_ci#define QLA_BBCR_REASON_PORT_SPEED     1
2588c2ecf20Sopenharmony_ci#define QLA_BBCR_REASON_PEER_PORT      2
2598c2ecf20Sopenharmony_ci#define QLA_BBCR_REASON_SWITCH         3
2608c2ecf20Sopenharmony_ci#define QLA_BBCR_REASON_LOGIN_REJECT   4
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistruct  qla_bbcr_data {
2638c2ecf20Sopenharmony_ci	uint8_t   status;         /* 1 - enabled, 0 - Disabled */
2648c2ecf20Sopenharmony_ci	uint8_t   state;          /* 1 - online, 0 - offline */
2658c2ecf20Sopenharmony_ci	uint8_t   configured_bbscn;       /* 0-15 */
2668c2ecf20Sopenharmony_ci	uint8_t   negotiated_bbscn;       /* 0-15 */
2678c2ecf20Sopenharmony_ci	uint8_t   offline_reason_code;
2688c2ecf20Sopenharmony_ci	uint16_t  mbx1;			/* Port state */
2698c2ecf20Sopenharmony_ci	uint8_t   reserved[9];
2708c2ecf20Sopenharmony_ci} __packed;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistruct qla_dport_diag {
2738c2ecf20Sopenharmony_ci	uint16_t options;
2748c2ecf20Sopenharmony_ci	uint32_t buf[16];
2758c2ecf20Sopenharmony_ci	uint8_t  unused[62];
2768c2ecf20Sopenharmony_ci} __packed;
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/* D_Port options */
2798c2ecf20Sopenharmony_ci#define QLA_DPORT_RESULT	0x0
2808c2ecf20Sopenharmony_ci#define QLA_DPORT_START		0x2
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/* active images in flash */
2838c2ecf20Sopenharmony_cistruct qla_active_regions {
2848c2ecf20Sopenharmony_ci	uint8_t global_image;
2858c2ecf20Sopenharmony_ci	uint8_t board_config;
2868c2ecf20Sopenharmony_ci	uint8_t vpd_nvram;
2878c2ecf20Sopenharmony_ci	uint8_t npiv_config_0_1;
2888c2ecf20Sopenharmony_ci	uint8_t npiv_config_2_3;
2898c2ecf20Sopenharmony_ci	uint8_t reserved[32];
2908c2ecf20Sopenharmony_ci} __packed;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci#endif
293