162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * QLogic qlcnic NIC Driver
462306a36Sopenharmony_ci * Copyright (c) 2009-2013 QLogic Corporation
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef __QLCNIC_HW_H
862306a36Sopenharmony_ci#define __QLCNIC_HW_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* Common registers in 83xx and 82xx */
1162306a36Sopenharmony_cienum qlcnic_regs {
1262306a36Sopenharmony_ci	QLCNIC_PEG_HALT_STATUS1 = 0,
1362306a36Sopenharmony_ci	QLCNIC_PEG_HALT_STATUS2,
1462306a36Sopenharmony_ci	QLCNIC_PEG_ALIVE_COUNTER,
1562306a36Sopenharmony_ci	QLCNIC_FLASH_LOCK_OWNER,
1662306a36Sopenharmony_ci	QLCNIC_FW_CAPABILITIES,
1762306a36Sopenharmony_ci	QLCNIC_CRB_DRV_ACTIVE,
1862306a36Sopenharmony_ci	QLCNIC_CRB_DEV_STATE,
1962306a36Sopenharmony_ci	QLCNIC_CRB_DRV_STATE,
2062306a36Sopenharmony_ci	QLCNIC_CRB_DRV_SCRATCH,
2162306a36Sopenharmony_ci	QLCNIC_CRB_DEV_PARTITION_INFO,
2262306a36Sopenharmony_ci	QLCNIC_CRB_DRV_IDC_VER,
2362306a36Sopenharmony_ci	QLCNIC_FW_VERSION_MAJOR,
2462306a36Sopenharmony_ci	QLCNIC_FW_VERSION_MINOR,
2562306a36Sopenharmony_ci	QLCNIC_FW_VERSION_SUB,
2662306a36Sopenharmony_ci	QLCNIC_CRB_DEV_NPAR_STATE,
2762306a36Sopenharmony_ci	QLCNIC_FW_IMG_VALID,
2862306a36Sopenharmony_ci	QLCNIC_CMDPEG_STATE,
2962306a36Sopenharmony_ci	QLCNIC_RCVPEG_STATE,
3062306a36Sopenharmony_ci	QLCNIC_ASIC_TEMP,
3162306a36Sopenharmony_ci	QLCNIC_FW_API,
3262306a36Sopenharmony_ci	QLCNIC_DRV_OP_MODE,
3362306a36Sopenharmony_ci	QLCNIC_FLASH_LOCK,
3462306a36Sopenharmony_ci	QLCNIC_FLASH_UNLOCK,
3562306a36Sopenharmony_ci};
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/* Read from an address offset from BAR0, existing registers */
3862306a36Sopenharmony_ci#define QLC_SHARED_REG_RD32(a, addr)			\
3962306a36Sopenharmony_ci	readl(((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* Write to an address offset from BAR0, existing registers */
4262306a36Sopenharmony_ci#define QLC_SHARED_REG_WR32(a, addr, value)		\
4362306a36Sopenharmony_ci	writel(value, ((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* Read from a direct address offset from BAR0, additional registers */
4662306a36Sopenharmony_ci#define QLCRDX(ahw, addr)	\
4762306a36Sopenharmony_ci	readl(((ahw)->pci_base0) + ((ahw)->ext_reg_tbl[addr]))
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* Write to a direct address offset from BAR0, additional registers */
5062306a36Sopenharmony_ci#define QLCWRX(ahw, addr, value)	\
5162306a36Sopenharmony_ci	writel(value, (((ahw)->pci_base0) + ((ahw)->ext_reg_tbl[addr])))
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_IP_ADDR		0x1
5462306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIG_INTRPT		0x2
5562306a36Sopenharmony_ci#define QLCNIC_CMD_CREATE_RX_CTX		0x7
5662306a36Sopenharmony_ci#define QLCNIC_CMD_DESTROY_RX_CTX		0x8
5762306a36Sopenharmony_ci#define QLCNIC_CMD_CREATE_TX_CTX		0x9
5862306a36Sopenharmony_ci#define QLCNIC_CMD_DESTROY_TX_CTX		0xa
5962306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_LRO		0xC
6062306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_MAC_LEARNING	0xD
6162306a36Sopenharmony_ci#define QLCNIC_CMD_GET_STATISTICS		0xF
6262306a36Sopenharmony_ci#define QLCNIC_CMD_INTRPT_TEST			0x11
6362306a36Sopenharmony_ci#define QLCNIC_CMD_SET_MTU			0x12
6462306a36Sopenharmony_ci#define QLCNIC_CMD_READ_PHY			0x13
6562306a36Sopenharmony_ci#define QLCNIC_CMD_WRITE_PHY			0x14
6662306a36Sopenharmony_ci#define QLCNIC_CMD_READ_HW_REG			0x15
6762306a36Sopenharmony_ci#define QLCNIC_CMD_GET_FLOW_CTL			0x16
6862306a36Sopenharmony_ci#define QLCNIC_CMD_SET_FLOW_CTL			0x17
6962306a36Sopenharmony_ci#define QLCNIC_CMD_READ_MAX_MTU			0x18
7062306a36Sopenharmony_ci#define QLCNIC_CMD_READ_MAX_LRO			0x19
7162306a36Sopenharmony_ci#define QLCNIC_CMD_MAC_ADDRESS			0x1f
7262306a36Sopenharmony_ci#define QLCNIC_CMD_GET_PCI_INFO			0x20
7362306a36Sopenharmony_ci#define QLCNIC_CMD_GET_NIC_INFO			0x21
7462306a36Sopenharmony_ci#define QLCNIC_CMD_SET_NIC_INFO			0x22
7562306a36Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_CAPABILITY	0x24
7662306a36Sopenharmony_ci#define QLCNIC_CMD_TOGGLE_ESWITCH		0x25
7762306a36Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_STATUS		0x26
7862306a36Sopenharmony_ci#define QLCNIC_CMD_SET_PORTMIRRORING		0x27
7962306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_ESWITCH		0x28
8062306a36Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_PORT_CONFIG	0x29
8162306a36Sopenharmony_ci#define QLCNIC_CMD_GET_ESWITCH_STATS		0x2a
8262306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIG_PORT			0x2e
8362306a36Sopenharmony_ci#define QLCNIC_CMD_TEMP_SIZE			0x2f
8462306a36Sopenharmony_ci#define QLCNIC_CMD_GET_TEMP_HDR			0x30
8562306a36Sopenharmony_ci#define QLCNIC_CMD_BC_EVENT_SETUP		0x31
8662306a36Sopenharmony_ci#define	QLCNIC_CMD_CONFIG_VPORT			0x32
8762306a36Sopenharmony_ci#define	QLCNIC_CMD_DCB_QUERY_CAP		0x34
8862306a36Sopenharmony_ci#define	QLCNIC_CMD_DCB_QUERY_PARAM		0x35
8962306a36Sopenharmony_ci#define QLCNIC_CMD_GET_MAC_STATS		0x37
9062306a36Sopenharmony_ci#define QLCNIC_CMD_82XX_SET_DRV_VER		0x38
9162306a36Sopenharmony_ci#define QLCNIC_CMD_MQ_TX_CONFIG_INTR		0x39
9262306a36Sopenharmony_ci#define QLCNIC_CMD_GET_LED_STATUS		0x3C
9362306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_RSS		0x41
9462306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIG_INTR_COAL		0x43
9562306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_LED		0x44
9662306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIG_MAC_VLAN		0x45
9762306a36Sopenharmony_ci#define QLCNIC_CMD_GET_LINK_EVENT		0x48
9862306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_MAC_RX_MODE	0x49
9962306a36Sopenharmony_ci#define QLCNIC_CMD_CONFIGURE_HW_LRO		0x4A
10062306a36Sopenharmony_ci#define QLCNIC_CMD_SET_INGRESS_ENCAP		0x4E
10162306a36Sopenharmony_ci#define QLCNIC_CMD_INIT_NIC_FUNC		0x60
10262306a36Sopenharmony_ci#define QLCNIC_CMD_STOP_NIC_FUNC		0x61
10362306a36Sopenharmony_ci#define QLCNIC_CMD_IDC_ACK			0x63
10462306a36Sopenharmony_ci#define QLCNIC_CMD_SET_PORT_CONFIG		0x66
10562306a36Sopenharmony_ci#define QLCNIC_CMD_GET_PORT_CONFIG		0x67
10662306a36Sopenharmony_ci#define QLCNIC_CMD_GET_LINK_STATUS		0x68
10762306a36Sopenharmony_ci#define QLCNIC_CMD_SET_LED_CONFIG		0x69
10862306a36Sopenharmony_ci#define QLCNIC_CMD_GET_LED_CONFIG		0x6A
10962306a36Sopenharmony_ci#define QLCNIC_CMD_83XX_SET_DRV_VER		0x6F
11062306a36Sopenharmony_ci#define QLCNIC_CMD_ADD_RCV_RINGS		0x0B
11162306a36Sopenharmony_ci#define QLCNIC_CMD_83XX_EXTEND_ISCSI_DUMP_CAP	0x37
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#define QLCNIC_INTRPT_INTX			1
11462306a36Sopenharmony_ci#define QLCNIC_INTRPT_MSIX			3
11562306a36Sopenharmony_ci#define QLCNIC_INTRPT_ADD			1
11662306a36Sopenharmony_ci#define QLCNIC_INTRPT_DEL			2
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci#define QLCNIC_GET_CURRENT_MAC			1
11962306a36Sopenharmony_ci#define QLCNIC_SET_STATION_MAC			2
12062306a36Sopenharmony_ci#define QLCNIC_GET_DEFAULT_MAC			3
12162306a36Sopenharmony_ci#define QLCNIC_GET_FAC_DEF_MAC			4
12262306a36Sopenharmony_ci#define QLCNIC_SET_FAC_DEF_MAC			5
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define QLCNIC_MBX_LINK_EVENT		0x8001
12562306a36Sopenharmony_ci#define QLCNIC_MBX_BC_EVENT		0x8002
12662306a36Sopenharmony_ci#define QLCNIC_MBX_COMP_EVENT		0x8100
12762306a36Sopenharmony_ci#define QLCNIC_MBX_REQUEST_EVENT	0x8101
12862306a36Sopenharmony_ci#define QLCNIC_MBX_TIME_EXTEND_EVENT	0x8102
12962306a36Sopenharmony_ci#define QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT	0x8110
13062306a36Sopenharmony_ci#define QLCNIC_MBX_SFP_INSERT_EVENT	0x8130
13162306a36Sopenharmony_ci#define QLCNIC_MBX_SFP_REMOVE_EVENT	0x8131
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_cistruct qlcnic_mailbox_metadata {
13462306a36Sopenharmony_ci	u32 cmd;
13562306a36Sopenharmony_ci	u32 in_args;
13662306a36Sopenharmony_ci	u32 out_args;
13762306a36Sopenharmony_ci};
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/* Mailbox ownership */
14062306a36Sopenharmony_ci#define QLCNIC_GET_OWNER(val)	((val) & (BIT_0 | BIT_1))
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define QLCNIC_SET_OWNER        1
14362306a36Sopenharmony_ci#define QLCNIC_CLR_OWNER        0
14462306a36Sopenharmony_ci#define QLCNIC_MBX_TIMEOUT      5000
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define QLCNIC_MBX_RSP_OK	1
14762306a36Sopenharmony_ci#define QLCNIC_MBX_PORT_RSP_OK	0x1a
14862306a36Sopenharmony_ci#define QLCNIC_MBX_ASYNC_EVENT	BIT_15
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci/* Set HW Tx ring limit for 82xx adapter. */
15162306a36Sopenharmony_ci#define QLCNIC_MAX_HW_TX_RINGS		8
15262306a36Sopenharmony_ci#define QLCNIC_MAX_HW_VNIC_TX_RINGS	4
15362306a36Sopenharmony_ci#define QLCNIC_MAX_TX_RINGS		8
15462306a36Sopenharmony_ci#define QLCNIC_MAX_SDS_RINGS		8
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_cistruct qlcnic_pci_info;
15762306a36Sopenharmony_cistruct qlcnic_info;
15862306a36Sopenharmony_cistruct qlcnic_cmd_args;
15962306a36Sopenharmony_cistruct ethtool_stats;
16062306a36Sopenharmony_cistruct pci_device_id;
16162306a36Sopenharmony_cistruct qlcnic_host_sds_ring;
16262306a36Sopenharmony_cistruct qlcnic_host_tx_ring;
16362306a36Sopenharmony_cistruct qlcnic_hardware_context;
16462306a36Sopenharmony_cistruct qlcnic_adapter;
16562306a36Sopenharmony_cistruct qlcnic_fw_dump;
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ciint qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong, int *);
16862306a36Sopenharmony_ciint qlcnic_82xx_hw_write_wx_2M(struct qlcnic_adapter *, ulong, u32);
16962306a36Sopenharmony_ciint qlcnic_82xx_config_hw_lro(struct qlcnic_adapter *adapter, int);
17062306a36Sopenharmony_ciint qlcnic_82xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32);
17162306a36Sopenharmony_ciint qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
17262306a36Sopenharmony_ci			 struct net_device *netdev);
17362306a36Sopenharmony_civoid qlcnic_82xx_get_beacon_state(struct qlcnic_adapter *);
17462306a36Sopenharmony_civoid qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter,
17562306a36Sopenharmony_ci			       u64 *uaddr, u16 vlan_id,
17662306a36Sopenharmony_ci			       struct qlcnic_host_tx_ring *tx_ring);
17762306a36Sopenharmony_ciint qlcnic_82xx_config_intr_coalesce(struct qlcnic_adapter *,
17862306a36Sopenharmony_ci				     struct ethtool_coalesce *);
17962306a36Sopenharmony_ciint qlcnic_82xx_set_rx_coalesce(struct qlcnic_adapter *);
18062306a36Sopenharmony_ciint qlcnic_82xx_config_rss(struct qlcnic_adapter *adapter, int);
18162306a36Sopenharmony_civoid qlcnic_82xx_config_ipaddr(struct qlcnic_adapter *adapter,
18262306a36Sopenharmony_ci			       __be32, int);
18362306a36Sopenharmony_ciint qlcnic_82xx_linkevent_request(struct qlcnic_adapter *adapter, int);
18462306a36Sopenharmony_civoid qlcnic_82xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring);
18562306a36Sopenharmony_ciint qlcnic_82xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8);
18662306a36Sopenharmony_ciint qlcnic_82xx_set_lb_mode(struct qlcnic_adapter *, u8);
18762306a36Sopenharmony_civoid qlcnic_82xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
18862306a36Sopenharmony_civoid qlcnic_82xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
18962306a36Sopenharmony_ciint qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
19062306a36Sopenharmony_ci			  struct qlcnic_cmd_args *);
19162306a36Sopenharmony_ciint qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *, int);
19262306a36Sopenharmony_ciint qlcnic_82xx_config_intrpt(struct qlcnic_adapter *, u8);
19362306a36Sopenharmony_ciint qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *);
19462306a36Sopenharmony_ciint qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *,
19562306a36Sopenharmony_ci				     struct qlcnic_host_tx_ring *tx_ring, int);
19662306a36Sopenharmony_civoid qlcnic_82xx_fw_cmd_del_rx_ctx(struct qlcnic_adapter *);
19762306a36Sopenharmony_civoid qlcnic_82xx_fw_cmd_del_tx_ctx(struct qlcnic_adapter *,
19862306a36Sopenharmony_ci				   struct qlcnic_host_tx_ring *);
19962306a36Sopenharmony_ciint qlcnic_82xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
20062306a36Sopenharmony_ciint qlcnic_82xx_get_mac_address(struct qlcnic_adapter *, u8*, u8);
20162306a36Sopenharmony_ciint qlcnic_82xx_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8);
20262306a36Sopenharmony_ciint qlcnic_82xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *);
20362306a36Sopenharmony_ciint qlcnic_82xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info*);
20462306a36Sopenharmony_ciint qlcnic_82xx_alloc_mbx_args(struct qlcnic_cmd_args *,
20562306a36Sopenharmony_ci			       struct qlcnic_adapter *, u32);
20662306a36Sopenharmony_ciint qlcnic_82xx_get_board_info(struct qlcnic_adapter *);
20762306a36Sopenharmony_ciint qlcnic_82xx_config_led(struct qlcnic_adapter *, u32, u32);
20862306a36Sopenharmony_civoid qlcnic_82xx_get_func_no(struct qlcnic_adapter *);
20962306a36Sopenharmony_ciint qlcnic_82xx_api_lock(struct qlcnic_adapter *);
21062306a36Sopenharmony_civoid qlcnic_82xx_api_unlock(struct qlcnic_adapter *);
21162306a36Sopenharmony_civoid qlcnic_82xx_napi_enable(struct qlcnic_adapter *);
21262306a36Sopenharmony_civoid qlcnic_82xx_napi_disable(struct qlcnic_adapter *);
21362306a36Sopenharmony_civoid qlcnic_82xx_napi_del(struct qlcnic_adapter *);
21462306a36Sopenharmony_ciint qlcnic_82xx_shutdown(struct pci_dev *);
21562306a36Sopenharmony_ciint qlcnic_82xx_resume(struct qlcnic_adapter *);
21662306a36Sopenharmony_civoid qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed);
21762306a36Sopenharmony_civoid qlcnic_fw_poll_work(struct work_struct *work);
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ciu32 qlcnic_82xx_get_saved_state(void *, u32);
22062306a36Sopenharmony_civoid qlcnic_82xx_set_saved_state(void *, u32, u32);
22162306a36Sopenharmony_civoid qlcnic_82xx_cache_tmpl_hdr_values(struct qlcnic_fw_dump *);
22262306a36Sopenharmony_ciu32 qlcnic_82xx_get_cap_size(void *, int);
22362306a36Sopenharmony_civoid qlcnic_82xx_set_sys_info(void *, int, u32);
22462306a36Sopenharmony_civoid qlcnic_82xx_store_cap_mask(void *, u32);
22562306a36Sopenharmony_ci#endif				/* __QLCNIC_HW_H_ */
226