18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic qlcnic NIC Driver
48c2ecf20Sopenharmony_ci * Copyright (c) 2009-2013 QLogic Corporation
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __QLCNIC_HW_H
88c2ecf20Sopenharmony_ci#define __QLCNIC_HW_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/* Common registers in 83xx and 82xx */
118c2ecf20Sopenharmony_cienum qlcnic_regs {
128c2ecf20Sopenharmony_ci	QLCNIC_PEG_HALT_STATUS1 = 0,
138c2ecf20Sopenharmony_ci	QLCNIC_PEG_HALT_STATUS2,
148c2ecf20Sopenharmony_ci	QLCNIC_PEG_ALIVE_COUNTER,
158c2ecf20Sopenharmony_ci	QLCNIC_FLASH_LOCK_OWNER,
168c2ecf20Sopenharmony_ci	QLCNIC_FW_CAPABILITIES,
178c2ecf20Sopenharmony_ci	QLCNIC_CRB_DRV_ACTIVE,
188c2ecf20Sopenharmony_ci	QLCNIC_CRB_DEV_STATE,
198c2ecf20Sopenharmony_ci	QLCNIC_CRB_DRV_STATE,
208c2ecf20Sopenharmony_ci	QLCNIC_CRB_DRV_SCRATCH,
218c2ecf20Sopenharmony_ci	QLCNIC_CRB_DEV_PARTITION_INFO,
228c2ecf20Sopenharmony_ci	QLCNIC_CRB_DRV_IDC_VER,
238c2ecf20Sopenharmony_ci	QLCNIC_FW_VERSION_MAJOR,
248c2ecf20Sopenharmony_ci	QLCNIC_FW_VERSION_MINOR,
258c2ecf20Sopenharmony_ci	QLCNIC_FW_VERSION_SUB,
268c2ecf20Sopenharmony_ci	QLCNIC_CRB_DEV_NPAR_STATE,
278c2ecf20Sopenharmony_ci	QLCNIC_FW_IMG_VALID,
288c2ecf20Sopenharmony_ci	QLCNIC_CMDPEG_STATE,
298c2ecf20Sopenharmony_ci	QLCNIC_RCVPEG_STATE,
308c2ecf20Sopenharmony_ci	QLCNIC_ASIC_TEMP,
318c2ecf20Sopenharmony_ci	QLCNIC_FW_API,
328c2ecf20Sopenharmony_ci	QLCNIC_DRV_OP_MODE,
338c2ecf20Sopenharmony_ci	QLCNIC_FLASH_LOCK,
348c2ecf20Sopenharmony_ci	QLCNIC_FLASH_UNLOCK,
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* Read from an address offset from BAR0, existing registers */
388c2ecf20Sopenharmony_ci#define QLC_SHARED_REG_RD32(a, addr)			\
398c2ecf20Sopenharmony_ci	readl(((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* Write to an address offset from BAR0, existing registers */
428c2ecf20Sopenharmony_ci#define QLC_SHARED_REG_WR32(a, addr, value)		\
438c2ecf20Sopenharmony_ci	writel(value, ((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* Read from a direct address offset from BAR0, additional registers */
468c2ecf20Sopenharmony_ci#define QLCRDX(ahw, addr)	\
478c2ecf20Sopenharmony_ci	readl(((ahw)->pci_base0) + ((ahw)->ext_reg_tbl[addr]))
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* Write to a direct address offset from BAR0, additional registers */
508c2ecf20Sopenharmony_ci#define QLCWRX(ahw, addr, value)	\
518c2ecf20Sopenharmony_ci	writel(value, (((ahw)->pci_base0) + ((ahw)->ext_reg_tbl[addr])))
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_IP_ADDR		0x1
548c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIG_INTRPT		0x2
558c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CREATE_RX_CTX		0x7
568c2ecf20Sopenharmony_ci#define QLCNIC_CMD_DESTROY_RX_CTX		0x8
578c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CREATE_TX_CTX		0x9
588c2ecf20Sopenharmony_ci#define QLCNIC_CMD_DESTROY_TX_CTX		0xa
598c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_LRO		0xC
608c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_MAC_LEARNING	0xD
618c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_STATISTICS		0xF
628c2ecf20Sopenharmony_ci#define QLCNIC_CMD_INTRPT_TEST			0x11
638c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_MTU			0x12
648c2ecf20Sopenharmony_ci#define QLCNIC_CMD_READ_PHY			0x13
658c2ecf20Sopenharmony_ci#define QLCNIC_CMD_WRITE_PHY			0x14
668c2ecf20Sopenharmony_ci#define QLCNIC_CMD_READ_HW_REG			0x15
678c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_FLOW_CTL			0x16
688c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_FLOW_CTL			0x17
698c2ecf20Sopenharmony_ci#define QLCNIC_CMD_READ_MAX_MTU			0x18
708c2ecf20Sopenharmony_ci#define QLCNIC_CMD_READ_MAX_LRO			0x19
718c2ecf20Sopenharmony_ci#define QLCNIC_CMD_MAC_ADDRESS			0x1f
728c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_PCI_INFO			0x20
738c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_NIC_INFO			0x21
748c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_NIC_INFO			0x22
758c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_CAPABILITY	0x24
768c2ecf20Sopenharmony_ci#define QLCNIC_CMD_TOGGLE_ESWITCH		0x25
778c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_STATUS		0x26
788c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_PORTMIRRORING		0x27
798c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_ESWITCH		0x28
808c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_PORT_CONFIG	0x29
818c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_STATS		0x2a
828c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIG_PORT			0x2e
838c2ecf20Sopenharmony_ci#define QLCNIC_CMD_TEMP_SIZE			0x2f
848c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_TEMP_HDR			0x30
858c2ecf20Sopenharmony_ci#define QLCNIC_CMD_BC_EVENT_SETUP		0x31
868c2ecf20Sopenharmony_ci#define	QLCNIC_CMD_CONFIG_VPORT			0x32
878c2ecf20Sopenharmony_ci#define	QLCNIC_CMD_DCB_QUERY_CAP		0x34
888c2ecf20Sopenharmony_ci#define	QLCNIC_CMD_DCB_QUERY_PARAM		0x35
898c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_MAC_STATS		0x37
908c2ecf20Sopenharmony_ci#define QLCNIC_CMD_82XX_SET_DRV_VER		0x38
918c2ecf20Sopenharmony_ci#define QLCNIC_CMD_MQ_TX_CONFIG_INTR		0x39
928c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_LED_STATUS		0x3C
938c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_RSS		0x41
948c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIG_INTR_COAL		0x43
958c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_LED		0x44
968c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIG_MAC_VLAN		0x45
978c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_LINK_EVENT		0x48
988c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_MAC_RX_MODE	0x49
998c2ecf20Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_HW_LRO		0x4A
1008c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_INGRESS_ENCAP		0x4E
1018c2ecf20Sopenharmony_ci#define QLCNIC_CMD_INIT_NIC_FUNC		0x60
1028c2ecf20Sopenharmony_ci#define QLCNIC_CMD_STOP_NIC_FUNC		0x61
1038c2ecf20Sopenharmony_ci#define QLCNIC_CMD_IDC_ACK			0x63
1048c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_PORT_CONFIG		0x66
1058c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_PORT_CONFIG		0x67
1068c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_LINK_STATUS		0x68
1078c2ecf20Sopenharmony_ci#define QLCNIC_CMD_SET_LED_CONFIG		0x69
1088c2ecf20Sopenharmony_ci#define QLCNIC_CMD_GET_LED_CONFIG		0x6A
1098c2ecf20Sopenharmony_ci#define QLCNIC_CMD_83XX_SET_DRV_VER		0x6F
1108c2ecf20Sopenharmony_ci#define QLCNIC_CMD_ADD_RCV_RINGS		0x0B
1118c2ecf20Sopenharmony_ci#define QLCNIC_CMD_83XX_EXTEND_ISCSI_DUMP_CAP	0x37
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#define QLCNIC_INTRPT_INTX			1
1148c2ecf20Sopenharmony_ci#define QLCNIC_INTRPT_MSIX			3
1158c2ecf20Sopenharmony_ci#define QLCNIC_INTRPT_ADD			1
1168c2ecf20Sopenharmony_ci#define QLCNIC_INTRPT_DEL			2
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define QLCNIC_GET_CURRENT_MAC			1
1198c2ecf20Sopenharmony_ci#define QLCNIC_SET_STATION_MAC			2
1208c2ecf20Sopenharmony_ci#define QLCNIC_GET_DEFAULT_MAC			3
1218c2ecf20Sopenharmony_ci#define QLCNIC_GET_FAC_DEF_MAC			4
1228c2ecf20Sopenharmony_ci#define QLCNIC_SET_FAC_DEF_MAC			5
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define QLCNIC_MBX_LINK_EVENT		0x8001
1258c2ecf20Sopenharmony_ci#define QLCNIC_MBX_BC_EVENT		0x8002
1268c2ecf20Sopenharmony_ci#define QLCNIC_MBX_COMP_EVENT		0x8100
1278c2ecf20Sopenharmony_ci#define QLCNIC_MBX_REQUEST_EVENT	0x8101
1288c2ecf20Sopenharmony_ci#define QLCNIC_MBX_TIME_EXTEND_EVENT	0x8102
1298c2ecf20Sopenharmony_ci#define QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT	0x8110
1308c2ecf20Sopenharmony_ci#define QLCNIC_MBX_SFP_INSERT_EVENT	0x8130
1318c2ecf20Sopenharmony_ci#define QLCNIC_MBX_SFP_REMOVE_EVENT	0x8131
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistruct qlcnic_mailbox_metadata {
1348c2ecf20Sopenharmony_ci	u32 cmd;
1358c2ecf20Sopenharmony_ci	u32 in_args;
1368c2ecf20Sopenharmony_ci	u32 out_args;
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* Mailbox ownership */
1408c2ecf20Sopenharmony_ci#define QLCNIC_GET_OWNER(val)	((val) & (BIT_0 | BIT_1))
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#define QLCNIC_SET_OWNER        1
1438c2ecf20Sopenharmony_ci#define QLCNIC_CLR_OWNER        0
1448c2ecf20Sopenharmony_ci#define QLCNIC_MBX_TIMEOUT      5000
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#define QLCNIC_MBX_RSP_OK	1
1478c2ecf20Sopenharmony_ci#define QLCNIC_MBX_PORT_RSP_OK	0x1a
1488c2ecf20Sopenharmony_ci#define QLCNIC_MBX_ASYNC_EVENT	BIT_15
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* Set HW Tx ring limit for 82xx adapter. */
1518c2ecf20Sopenharmony_ci#define QLCNIC_MAX_HW_TX_RINGS		8
1528c2ecf20Sopenharmony_ci#define QLCNIC_MAX_HW_VNIC_TX_RINGS	4
1538c2ecf20Sopenharmony_ci#define QLCNIC_MAX_TX_RINGS		8
1548c2ecf20Sopenharmony_ci#define QLCNIC_MAX_SDS_RINGS		8
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistruct qlcnic_pci_info;
1578c2ecf20Sopenharmony_cistruct qlcnic_info;
1588c2ecf20Sopenharmony_cistruct qlcnic_cmd_args;
1598c2ecf20Sopenharmony_cistruct ethtool_stats;
1608c2ecf20Sopenharmony_cistruct pci_device_id;
1618c2ecf20Sopenharmony_cistruct qlcnic_host_sds_ring;
1628c2ecf20Sopenharmony_cistruct qlcnic_host_tx_ring;
1638c2ecf20Sopenharmony_cistruct qlcnic_hardware_context;
1648c2ecf20Sopenharmony_cistruct qlcnic_adapter;
1658c2ecf20Sopenharmony_cistruct qlcnic_fw_dump;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ciint qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong, int *);
1688c2ecf20Sopenharmony_ciint qlcnic_82xx_hw_write_wx_2M(struct qlcnic_adapter *, ulong, u32);
1698c2ecf20Sopenharmony_ciint qlcnic_82xx_config_hw_lro(struct qlcnic_adapter *adapter, int);
1708c2ecf20Sopenharmony_ciint qlcnic_82xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32);
1718c2ecf20Sopenharmony_ciint qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
1728c2ecf20Sopenharmony_ci			 struct net_device *netdev);
1738c2ecf20Sopenharmony_civoid qlcnic_82xx_get_beacon_state(struct qlcnic_adapter *);
1748c2ecf20Sopenharmony_civoid qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter,
1758c2ecf20Sopenharmony_ci			       u64 *uaddr, u16 vlan_id,
1768c2ecf20Sopenharmony_ci			       struct qlcnic_host_tx_ring *tx_ring);
1778c2ecf20Sopenharmony_ciint qlcnic_82xx_config_intr_coalesce(struct qlcnic_adapter *,
1788c2ecf20Sopenharmony_ci				     struct ethtool_coalesce *);
1798c2ecf20Sopenharmony_ciint qlcnic_82xx_set_rx_coalesce(struct qlcnic_adapter *);
1808c2ecf20Sopenharmony_ciint qlcnic_82xx_config_rss(struct qlcnic_adapter *adapter, int);
1818c2ecf20Sopenharmony_civoid qlcnic_82xx_config_ipaddr(struct qlcnic_adapter *adapter,
1828c2ecf20Sopenharmony_ci			       __be32, int);
1838c2ecf20Sopenharmony_ciint qlcnic_82xx_linkevent_request(struct qlcnic_adapter *adapter, int);
1848c2ecf20Sopenharmony_civoid qlcnic_82xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring);
1858c2ecf20Sopenharmony_ciint qlcnic_82xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8);
1868c2ecf20Sopenharmony_ciint qlcnic_82xx_set_lb_mode(struct qlcnic_adapter *, u8);
1878c2ecf20Sopenharmony_civoid qlcnic_82xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
1888c2ecf20Sopenharmony_civoid qlcnic_82xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
1898c2ecf20Sopenharmony_ciint qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
1908c2ecf20Sopenharmony_ci			  struct qlcnic_cmd_args *);
1918c2ecf20Sopenharmony_ciint qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *, int);
1928c2ecf20Sopenharmony_ciint qlcnic_82xx_config_intrpt(struct qlcnic_adapter *, u8);
1938c2ecf20Sopenharmony_ciint qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *);
1948c2ecf20Sopenharmony_ciint qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *,
1958c2ecf20Sopenharmony_ci				     struct qlcnic_host_tx_ring *tx_ring, int);
1968c2ecf20Sopenharmony_civoid qlcnic_82xx_fw_cmd_del_rx_ctx(struct qlcnic_adapter *);
1978c2ecf20Sopenharmony_civoid qlcnic_82xx_fw_cmd_del_tx_ctx(struct qlcnic_adapter *,
1988c2ecf20Sopenharmony_ci				   struct qlcnic_host_tx_ring *);
1998c2ecf20Sopenharmony_ciint qlcnic_82xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
2008c2ecf20Sopenharmony_ciint qlcnic_82xx_get_mac_address(struct qlcnic_adapter *, u8*, u8);
2018c2ecf20Sopenharmony_ciint qlcnic_82xx_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8);
2028c2ecf20Sopenharmony_ciint qlcnic_82xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *);
2038c2ecf20Sopenharmony_ciint qlcnic_82xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info*);
2048c2ecf20Sopenharmony_ciint qlcnic_82xx_alloc_mbx_args(struct qlcnic_cmd_args *,
2058c2ecf20Sopenharmony_ci			       struct qlcnic_adapter *, u32);
2068c2ecf20Sopenharmony_ciint qlcnic_82xx_hw_write_wx_2M(struct qlcnic_adapter *, ulong, u32);
2078c2ecf20Sopenharmony_ciint qlcnic_82xx_get_board_info(struct qlcnic_adapter *);
2088c2ecf20Sopenharmony_ciint qlcnic_82xx_config_led(struct qlcnic_adapter *, u32, u32);
2098c2ecf20Sopenharmony_civoid qlcnic_82xx_get_func_no(struct qlcnic_adapter *);
2108c2ecf20Sopenharmony_ciint qlcnic_82xx_api_lock(struct qlcnic_adapter *);
2118c2ecf20Sopenharmony_civoid qlcnic_82xx_api_unlock(struct qlcnic_adapter *);
2128c2ecf20Sopenharmony_civoid qlcnic_82xx_napi_enable(struct qlcnic_adapter *);
2138c2ecf20Sopenharmony_civoid qlcnic_82xx_napi_disable(struct qlcnic_adapter *);
2148c2ecf20Sopenharmony_civoid qlcnic_82xx_napi_del(struct qlcnic_adapter *);
2158c2ecf20Sopenharmony_ciint qlcnic_82xx_shutdown(struct pci_dev *);
2168c2ecf20Sopenharmony_ciint qlcnic_82xx_resume(struct qlcnic_adapter *);
2178c2ecf20Sopenharmony_civoid qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed);
2188c2ecf20Sopenharmony_civoid qlcnic_fw_poll_work(struct work_struct *work);
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ciu32 qlcnic_82xx_get_saved_state(void *, u32);
2218c2ecf20Sopenharmony_civoid qlcnic_82xx_set_saved_state(void *, u32, u32);
2228c2ecf20Sopenharmony_civoid qlcnic_82xx_cache_tmpl_hdr_values(struct qlcnic_fw_dump *);
2238c2ecf20Sopenharmony_ciu32 qlcnic_82xx_get_cap_size(void *, int);
2248c2ecf20Sopenharmony_civoid qlcnic_82xx_set_sys_info(void *, int, u32);
2258c2ecf20Sopenharmony_civoid qlcnic_82xx_store_cap_mask(void *, u32);
2268c2ecf20Sopenharmony_ci#endif				/* __QLCNIC_HW_H_ */
227