xref: /dpdk/drivers/net/qede/base/ecore.h (revision d459b04329750ed7087d93406b831ee8e4a5a0e4)
13126df22SRasesh Mody /* SPDX-License-Identifier: BSD-3-Clause
29adde217SRasesh Mody  * Copyright (c) 2016 - 2018 Cavium Inc.
3ec94dbc5SRasesh Mody  * All rights reserved.
49adde217SRasesh Mody  * www.cavium.com
5ec94dbc5SRasesh Mody  */
6ec94dbc5SRasesh Mody 
7ec94dbc5SRasesh Mody #ifndef __ECORE_H
8ec94dbc5SRasesh Mody #define __ECORE_H
9ec94dbc5SRasesh Mody 
1048e8d239SRasesh Mody /* @DPDK */
1148e8d239SRasesh Mody #include <sys/stat.h>
1248e8d239SRasesh Mody #include <fcntl.h>
1348e8d239SRasesh Mody #include <unistd.h>
1448e8d239SRasesh Mody 
1548e8d239SRasesh Mody #define CONFIG_ECORE_BINARY_FW
167d178e9eSRasesh Mody #undef CONFIG_ECORE_ZIPPED_FW
1748e8d239SRasesh Mody 
1848e8d239SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
1948e8d239SRasesh Mody #include <zlib.h>
2048e8d239SRasesh Mody #endif
2148e8d239SRasesh Mody 
223eed444aSRasesh Mody #include "ecore_status.h"
23ec94dbc5SRasesh Mody #include "ecore_hsi_common.h"
24c018d2b4SRasesh Mody #include "ecore_hsi_debug_tools.h"
25c018d2b4SRasesh Mody #include "ecore_hsi_init_func.h"
26c018d2b4SRasesh Mody #include "ecore_hsi_init_tool.h"
27519438f7SRasesh Mody #include "ecore_hsi_func_common.h"
28ec94dbc5SRasesh Mody #include "ecore_proto_if.h"
29ec94dbc5SRasesh Mody #include "mcp_public.h"
30ec94dbc5SRasesh Mody 
310b6bf70dSRasesh Mody #define ECORE_MAJOR_VERSION		8
323b307c55SRasesh Mody #define ECORE_MINOR_VERSION		40
3358bb1ee4SRasesh Mody #define ECORE_REVISION_VERSION		26
3417d207d5SRasesh Mody #define ECORE_ENGINEERING_VERSION	0
350b6bf70dSRasesh Mody 
360b6bf70dSRasesh Mody #define ECORE_VERSION							\
370b6bf70dSRasesh Mody 	((ECORE_MAJOR_VERSION << 24) | (ECORE_MINOR_VERSION << 16) |	\
380b6bf70dSRasesh Mody 	 (ECORE_REVISION_VERSION << 8) | ECORE_ENGINEERING_VERSION)
390b6bf70dSRasesh Mody 
400b6bf70dSRasesh Mody #define STORM_FW_VERSION						\
410b6bf70dSRasesh Mody 	((FW_MAJOR_VERSION << 24) | (FW_MINOR_VERSION << 16) |	\
420b6bf70dSRasesh Mody 	 (FW_REVISION_VERSION << 8) | FW_ENGINEERING_VERSION)
430b6bf70dSRasesh Mody 
4476d37490SRasesh Mody #define IS_ECORE_PACING(p_hwfn)	\
4576d37490SRasesh Mody 	(!!(p_hwfn->b_en_pacing))
4676d37490SRasesh Mody 
4747a06aafSRasesh Mody #define MAX_HWFNS_PER_DEVICE	2
4822d07d93SRasesh Mody #define NAME_SIZE 128 /* @DPDK */
49ec94dbc5SRasesh Mody #define ECORE_WFQ_UNIT	100
50ec94dbc5SRasesh Mody #include "../qede_logs.h" /* @DPDK */
51ec94dbc5SRasesh Mody 
5222d07d93SRasesh Mody #define ISCSI_BDQ_ID(_port_id) (_port_id)
5322d07d93SRasesh Mody #define FCOE_BDQ_ID(_port_id) (_port_id + 2)
54ec94dbc5SRasesh Mody /* Constants */
55ec94dbc5SRasesh Mody #define ECORE_WID_SIZE		(1024)
566844eac8SRasesh Mody #define ECORE_MIN_WIDS		(4)
57ec94dbc5SRasesh Mody 
58ec94dbc5SRasesh Mody /* Configurable */
59ec94dbc5SRasesh Mody #define ECORE_PF_DEMS_SIZE	(4)
60ec94dbc5SRasesh Mody 
61ec94dbc5SRasesh Mody /* cau states */
62ec94dbc5SRasesh Mody enum ecore_coalescing_mode {
63ec94dbc5SRasesh Mody 	ECORE_COAL_MODE_DISABLE,
64ec94dbc5SRasesh Mody 	ECORE_COAL_MODE_ENABLE
65ec94dbc5SRasesh Mody };
66ec94dbc5SRasesh Mody 
67ec94dbc5SRasesh Mody enum ecore_nvm_cmd {
68ec94dbc5SRasesh Mody 	ECORE_PUT_FILE_BEGIN = DRV_MSG_CODE_NVM_PUT_FILE_BEGIN,
69ec94dbc5SRasesh Mody 	ECORE_PUT_FILE_DATA = DRV_MSG_CODE_NVM_PUT_FILE_DATA,
70ec94dbc5SRasesh Mody 	ECORE_NVM_READ_NVRAM = DRV_MSG_CODE_NVM_READ_NVRAM,
71ec94dbc5SRasesh Mody 	ECORE_NVM_WRITE_NVRAM = DRV_MSG_CODE_NVM_WRITE_NVRAM,
72ec94dbc5SRasesh Mody 	ECORE_NVM_DEL_FILE = DRV_MSG_CODE_NVM_DEL_FILE,
732292589aSRasesh Mody 	ECORE_EXT_PHY_FW_UPGRADE = DRV_MSG_CODE_EXT_PHY_FW_UPGRADE,
74ec94dbc5SRasesh Mody 	ECORE_NVM_SET_SECURE_MODE = DRV_MSG_CODE_SET_SECURE_MODE,
75ec94dbc5SRasesh Mody 	ECORE_PHY_RAW_READ = DRV_MSG_CODE_PHY_RAW_READ,
76ec94dbc5SRasesh Mody 	ECORE_PHY_RAW_WRITE = DRV_MSG_CODE_PHY_RAW_WRITE,
77ec94dbc5SRasesh Mody 	ECORE_PHY_CORE_READ = DRV_MSG_CODE_PHY_CORE_READ,
78ec94dbc5SRasesh Mody 	ECORE_PHY_CORE_WRITE = DRV_MSG_CODE_PHY_CORE_WRITE,
79ec94dbc5SRasesh Mody 	ECORE_GET_MCP_NVM_RESP = 0xFFFFFF00
80ec94dbc5SRasesh Mody };
81ec94dbc5SRasesh Mody 
82ec94dbc5SRasesh Mody #ifndef LINUX_REMOVE
83ec94dbc5SRasesh Mody #if !defined(CONFIG_ECORE_L2)
84ec94dbc5SRasesh Mody #define CONFIG_ECORE_L2
8586a2265eSRasesh Mody #define CONFIG_ECORE_SRIOV
86ec94dbc5SRasesh Mody #endif
87ec94dbc5SRasesh Mody #endif
88ec94dbc5SRasesh Mody 
89ec94dbc5SRasesh Mody /* helpers */
90ec94dbc5SRasesh Mody #ifndef __EXTRACT__LINUX__
91ec94dbc5SRasesh Mody #define MASK_FIELD(_name, _value)					\
92ec94dbc5SRasesh Mody 		((_value) &= (_name##_MASK))
93ec94dbc5SRasesh Mody 
94ec94dbc5SRasesh Mody #define FIELD_VALUE(_name, _value)					\
95ec94dbc5SRasesh Mody 		((_value & _name##_MASK) << _name##_SHIFT)
96ec94dbc5SRasesh Mody 
97ec94dbc5SRasesh Mody #define SET_FIELD(value, name, flag)					\
98ec94dbc5SRasesh Mody do {									\
99ec94dbc5SRasesh Mody 	(value) &= ~(name##_MASK << name##_SHIFT);			\
100830aba26SRasesh Mody 	(value) |= ((((u64)flag) & (u64)name##_MASK) << (name##_SHIFT));\
101ec94dbc5SRasesh Mody } while (0)
102ec94dbc5SRasesh Mody 
103ec94dbc5SRasesh Mody #define GET_FIELD(value, name)						\
104ec94dbc5SRasesh Mody 	(((value) >> (name##_SHIFT)) & name##_MASK)
105ec94dbc5SRasesh Mody 
10604b00049SRasesh Mody #define GET_MFW_FIELD(name, field)				\
10704b00049SRasesh Mody 	(((name) & (field ## _MASK)) >> (field ## _OFFSET))
1088a20e270SRasesh Mody 
10904b00049SRasesh Mody #define SET_MFW_FIELD(name, field, value)				\
1108a20e270SRasesh Mody do {									\
11104b00049SRasesh Mody 	(name) &= ~((field ## _MASK));		\
11204b00049SRasesh Mody 	(name) |= (((value) << (field ## _OFFSET)) & (field ## _MASK));	\
1138a20e270SRasesh Mody } while (0)
11404b00049SRasesh Mody #endif
1158a20e270SRasesh Mody 
DB_ADDR(u32 cid,u32 DEMS)116ec94dbc5SRasesh Mody static OSAL_INLINE u32 DB_ADDR(u32 cid, u32 DEMS)
117ec94dbc5SRasesh Mody {
118ec94dbc5SRasesh Mody 	u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
119ec94dbc5SRasesh Mody 		      (cid * ECORE_PF_DEMS_SIZE);
120ec94dbc5SRasesh Mody 
121ec94dbc5SRasesh Mody 	return db_addr;
122ec94dbc5SRasesh Mody }
123ec94dbc5SRasesh Mody 
DB_ADDR_VF(u32 cid,u32 DEMS)12486a2265eSRasesh Mody static OSAL_INLINE u32 DB_ADDR_VF(u32 cid, u32 DEMS)
12586a2265eSRasesh Mody {
12686a2265eSRasesh Mody 	u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
12786a2265eSRasesh Mody 		      FIELD_VALUE(DB_LEGACY_ADDR_ICID, cid);
12886a2265eSRasesh Mody 
12986a2265eSRasesh Mody 	return db_addr;
13086a2265eSRasesh Mody }
13186a2265eSRasesh Mody 
132ec94dbc5SRasesh Mody #define ALIGNED_TYPE_SIZE(type_name, p_hwfn)				  \
133ec94dbc5SRasesh Mody 	((sizeof(type_name) + (u32)(1 << (p_hwfn->p_dev->cache_shift)) - 1) & \
134ec94dbc5SRasesh Mody 	 ~((1 << (p_hwfn->p_dev->cache_shift)) - 1))
135ec94dbc5SRasesh Mody 
1369455b556SRasesh Mody #ifndef LINUX_REMOVE
137ec94dbc5SRasesh Mody #ifndef U64_HI
138ec94dbc5SRasesh Mody #define U64_HI(val) ((u32)(((u64)(val))  >> 32))
139ec94dbc5SRasesh Mody #endif
140ec94dbc5SRasesh Mody 
141ec94dbc5SRasesh Mody #ifndef U64_LO
142ec94dbc5SRasesh Mody #define U64_LO(val) ((u32)(((u64)(val)) & 0xffffffff))
143ec94dbc5SRasesh Mody #endif
1449455b556SRasesh Mody #endif
145ec94dbc5SRasesh Mody 
146ec94dbc5SRasesh Mody #ifndef __EXTRACT__LINUX__
147ec94dbc5SRasesh Mody enum DP_LEVEL {
148ec94dbc5SRasesh Mody 	ECORE_LEVEL_VERBOSE	= 0x0,
149ec94dbc5SRasesh Mody 	ECORE_LEVEL_INFO	= 0x1,
150ec94dbc5SRasesh Mody 	ECORE_LEVEL_NOTICE	= 0x2,
151ec94dbc5SRasesh Mody 	ECORE_LEVEL_ERR		= 0x3,
152ec94dbc5SRasesh Mody };
153ec94dbc5SRasesh Mody 
154ec94dbc5SRasesh Mody #define ECORE_LOG_LEVEL_SHIFT	(30)
155ec94dbc5SRasesh Mody #define ECORE_LOG_VERBOSE_MASK	(0x3fffffff)
156ec94dbc5SRasesh Mody #define ECORE_LOG_INFO_MASK	(0x40000000)
157ec94dbc5SRasesh Mody #define ECORE_LOG_NOTICE_MASK	(0x80000000)
158ec94dbc5SRasesh Mody 
159ec94dbc5SRasesh Mody enum DP_MODULE {
160ec94dbc5SRasesh Mody #ifndef LINUX_REMOVE
161ec94dbc5SRasesh Mody 	ECORE_MSG_DRV		= 0x0001,
162ec94dbc5SRasesh Mody 	ECORE_MSG_PROBE		= 0x0002,
163ec94dbc5SRasesh Mody 	ECORE_MSG_LINK		= 0x0004,
164ec94dbc5SRasesh Mody 	ECORE_MSG_TIMER		= 0x0008,
165ec94dbc5SRasesh Mody 	ECORE_MSG_IFDOWN	= 0x0010,
166ec94dbc5SRasesh Mody 	ECORE_MSG_IFUP		= 0x0020,
167ec94dbc5SRasesh Mody 	ECORE_MSG_RX_ERR	= 0x0040,
168ec94dbc5SRasesh Mody 	ECORE_MSG_TX_ERR	= 0x0080,
169ec94dbc5SRasesh Mody 	ECORE_MSG_TX_QUEUED	= 0x0100,
170ec94dbc5SRasesh Mody 	ECORE_MSG_INTR		= 0x0200,
171ec94dbc5SRasesh Mody 	ECORE_MSG_TX_DONE	= 0x0400,
172ec94dbc5SRasesh Mody 	ECORE_MSG_RX_STATUS	= 0x0800,
173ec94dbc5SRasesh Mody 	ECORE_MSG_PKTDATA	= 0x1000,
174ec94dbc5SRasesh Mody 	ECORE_MSG_HW		= 0x2000,
175ec94dbc5SRasesh Mody 	ECORE_MSG_WOL		= 0x4000,
176ec94dbc5SRasesh Mody #endif
177ec94dbc5SRasesh Mody 	ECORE_MSG_SPQ		= 0x10000,
178ec94dbc5SRasesh Mody 	ECORE_MSG_STATS		= 0x20000,
179ec94dbc5SRasesh Mody 	ECORE_MSG_DCB		= 0x40000,
180ec94dbc5SRasesh Mody 	ECORE_MSG_IOV		= 0x80000,
181ec94dbc5SRasesh Mody 	ECORE_MSG_SP		= 0x100000,
182ec94dbc5SRasesh Mody 	ECORE_MSG_STORAGE	= 0x200000,
18322d07d93SRasesh Mody 	ECORE_MSG_OOO		= 0x200000,
184ec94dbc5SRasesh Mody 	ECORE_MSG_CXT		= 0x800000,
18522d07d93SRasesh Mody 	ECORE_MSG_LL2		= 0x1000000,
186ec94dbc5SRasesh Mody 	ECORE_MSG_ILT		= 0x2000000,
18722d07d93SRasesh Mody 	ECORE_MSG_RDMA		= 0x4000000,
188ec94dbc5SRasesh Mody 	ECORE_MSG_DEBUG		= 0x8000000,
189ec94dbc5SRasesh Mody 	/* to be added...up to 0x8000000 */
190ec94dbc5SRasesh Mody };
191ec94dbc5SRasesh Mody #endif
192ec94dbc5SRasesh Mody 
193ec94dbc5SRasesh Mody #define for_each_hwfn(p_dev, i)	for (i = 0; i < p_dev->num_hwfns; i++)
194ec94dbc5SRasesh Mody 
195ec94dbc5SRasesh Mody #define D_TRINE(val, cond1, cond2, true1, true2, def) \
196ec94dbc5SRasesh Mody 	(val == (cond1) ? true1 : \
197ec94dbc5SRasesh Mody 	 (val == (cond2) ? true2 : def))
198ec94dbc5SRasesh Mody 
199ec94dbc5SRasesh Mody /* forward */
200ec94dbc5SRasesh Mody struct ecore_ptt_pool;
201ec94dbc5SRasesh Mody struct ecore_spq;
202ec94dbc5SRasesh Mody struct ecore_sb_info;
203ec94dbc5SRasesh Mody struct ecore_sb_attn_info;
204ec94dbc5SRasesh Mody struct ecore_cxt_mngr;
205ec94dbc5SRasesh Mody struct ecore_dma_mem;
206ec94dbc5SRasesh Mody struct ecore_sb_sp_info;
20722d07d93SRasesh Mody struct ecore_ll2_info;
208eb8e81adSRasesh Mody struct ecore_l2_info;
209ec94dbc5SRasesh Mody struct ecore_igu_info;
210ec94dbc5SRasesh Mody struct ecore_mcp_info;
21126ae839dSRasesh Mody struct ecore_dcbx_info;
2123eed444aSRasesh Mody struct ecore_llh_info;
213ec94dbc5SRasesh Mody 
214ec94dbc5SRasesh Mody struct ecore_rt_data {
215ec94dbc5SRasesh Mody 	u32	*init_val;
216ec94dbc5SRasesh Mody 	bool	*b_valid;
217ec94dbc5SRasesh Mody };
218ec94dbc5SRasesh Mody 
219ec94dbc5SRasesh Mody enum ecore_tunn_mode {
220ec94dbc5SRasesh Mody 	ECORE_MODE_L2GENEVE_TUNN,
221ec94dbc5SRasesh Mody 	ECORE_MODE_IPGENEVE_TUNN,
222ec94dbc5SRasesh Mody 	ECORE_MODE_L2GRE_TUNN,
223ec94dbc5SRasesh Mody 	ECORE_MODE_IPGRE_TUNN,
224ec94dbc5SRasesh Mody 	ECORE_MODE_VXLAN_TUNN,
225ec94dbc5SRasesh Mody };
226ec94dbc5SRasesh Mody 
227ec94dbc5SRasesh Mody enum ecore_tunn_clss {
228ec94dbc5SRasesh Mody 	ECORE_TUNN_CLSS_MAC_VLAN,
229ec94dbc5SRasesh Mody 	ECORE_TUNN_CLSS_MAC_VNI,
230ec94dbc5SRasesh Mody 	ECORE_TUNN_CLSS_INNER_MAC_VLAN,
231ec94dbc5SRasesh Mody 	ECORE_TUNN_CLSS_INNER_MAC_VNI,
23222d07d93SRasesh Mody 	ECORE_TUNN_CLSS_MAC_VLAN_DUAL_STAGE,
233ec94dbc5SRasesh Mody 	MAX_ECORE_TUNN_CLSS,
234ec94dbc5SRasesh Mody };
235ec94dbc5SRasesh Mody 
236adce1f86SRasesh Mody struct ecore_tunn_update_type {
237adce1f86SRasesh Mody 	bool b_update_mode;
238adce1f86SRasesh Mody 	bool b_mode_enabled;
239adce1f86SRasesh Mody 	enum ecore_tunn_clss tun_cls;
240ec94dbc5SRasesh Mody };
241ec94dbc5SRasesh Mody 
242adce1f86SRasesh Mody struct ecore_tunn_update_udp_port {
243adce1f86SRasesh Mody 	bool b_update_port;
244adce1f86SRasesh Mody 	u16 port;
245adce1f86SRasesh Mody };
246adce1f86SRasesh Mody 
247adce1f86SRasesh Mody struct ecore_tunnel_info {
248adce1f86SRasesh Mody 	struct ecore_tunn_update_type vxlan;
249adce1f86SRasesh Mody 	struct ecore_tunn_update_type l2_geneve;
250adce1f86SRasesh Mody 	struct ecore_tunn_update_type ip_geneve;
251adce1f86SRasesh Mody 	struct ecore_tunn_update_type l2_gre;
252adce1f86SRasesh Mody 	struct ecore_tunn_update_type ip_gre;
253adce1f86SRasesh Mody 
254adce1f86SRasesh Mody 	struct ecore_tunn_update_udp_port vxlan_port;
255adce1f86SRasesh Mody 	struct ecore_tunn_update_udp_port geneve_port;
256adce1f86SRasesh Mody 
257adce1f86SRasesh Mody 	bool b_update_rx_cls;
258adce1f86SRasesh Mody 	bool b_update_tx_cls;
259ec94dbc5SRasesh Mody };
260ec94dbc5SRasesh Mody 
261ec94dbc5SRasesh Mody /* The PCI personality is not quite synonymous to protocol ID:
262ec94dbc5SRasesh Mody  * 1. All personalities need CORE connections
26322d07d93SRasesh Mody  * 2. The Ethernet personality may support also the RoCE/iWARP protocol
264ec94dbc5SRasesh Mody  */
265ec94dbc5SRasesh Mody enum ecore_pci_personality {
266ec94dbc5SRasesh Mody 	ECORE_PCI_ETH,
26722d07d93SRasesh Mody 	ECORE_PCI_FCOE,
26822d07d93SRasesh Mody 	ECORE_PCI_ISCSI,
26922d07d93SRasesh Mody 	ECORE_PCI_ETH_ROCE,
270bdf4267dSRasesh Mody 	ECORE_PCI_ETH_IWARP,
271bdf4267dSRasesh Mody 	ECORE_PCI_ETH_RDMA,
272ec94dbc5SRasesh Mody 	ECORE_PCI_DEFAULT /* default in shmem */
273ec94dbc5SRasesh Mody };
274ec94dbc5SRasesh Mody 
275ec94dbc5SRasesh Mody /* All VFs are symmetric, all counters are PF + all VFs */
276ec94dbc5SRasesh Mody struct ecore_qm_iids {
277ec94dbc5SRasesh Mody 	u32 cids;
278ec94dbc5SRasesh Mody 	u32 vf_cids;
279ec94dbc5SRasesh Mody 	u32 tids;
280ec94dbc5SRasesh Mody };
281ec94dbc5SRasesh Mody 
282ec94dbc5SRasesh Mody #define MAX_PF_PER_PORT 8
283ec94dbc5SRasesh Mody 
284ec94dbc5SRasesh Mody /* HW / FW resources, output of features supported below, most information
285ec94dbc5SRasesh Mody  * is received from MFW.
286ec94dbc5SRasesh Mody  */
28722d07d93SRasesh Mody enum ecore_resources {
288ec94dbc5SRasesh Mody 	ECORE_L2_QUEUE,
289ec94dbc5SRasesh Mody 	ECORE_VPORT,
290ec94dbc5SRasesh Mody 	ECORE_RSS_ENG,
291ec94dbc5SRasesh Mody 	ECORE_PQ,
292ec94dbc5SRasesh Mody 	ECORE_RL,
293ec94dbc5SRasesh Mody 	ECORE_MAC,
294ec94dbc5SRasesh Mody 	ECORE_VLAN,
29522d07d93SRasesh Mody 	ECORE_RDMA_CNQ_RAM,
296ec94dbc5SRasesh Mody 	ECORE_ILT,
29722d07d93SRasesh Mody 	ECORE_LL2_QUEUE,
298ec94dbc5SRasesh Mody 	ECORE_CMDQS_CQS,
29922d07d93SRasesh Mody 	ECORE_RDMA_STATS_QUEUE,
300619618b9SRasesh Mody 	ECORE_BDQ,
3016e4fcea9SRasesh Mody 
3026e4fcea9SRasesh Mody 	/* This is needed only internally for matching against the IGU.
3036e4fcea9SRasesh Mody 	 * In case of legacy MFW, would be set to `0'.
3046e4fcea9SRasesh Mody 	 */
3056e4fcea9SRasesh Mody 	ECORE_SB,
3066e4fcea9SRasesh Mody 
3076e4fcea9SRasesh Mody 	ECORE_MAX_RESC,
308ec94dbc5SRasesh Mody };
309ec94dbc5SRasesh Mody 
310ec94dbc5SRasesh Mody /* Features that require resources, given as input to the resource management
311ec94dbc5SRasesh Mody  * algorithm, the output are the resources above
312ec94dbc5SRasesh Mody  */
31322d07d93SRasesh Mody enum ecore_feature {
314ec94dbc5SRasesh Mody 	ECORE_PF_L2_QUE,
315ec94dbc5SRasesh Mody 	ECORE_PF_TC,
316ec94dbc5SRasesh Mody 	ECORE_VF,
317ec94dbc5SRasesh Mody 	ECORE_EXTRA_VF_QUE,
318ec94dbc5SRasesh Mody 	ECORE_VMQ,
31922d07d93SRasesh Mody 	ECORE_RDMA_CNQ,
32022d07d93SRasesh Mody 	ECORE_ISCSI_CQ,
32122d07d93SRasesh Mody 	ECORE_FCOE_CQ,
322d9237ae2SRasesh Mody 	ECORE_VF_L2_QUE,
323ec94dbc5SRasesh Mody 	ECORE_MAX_FEATURES,
324ec94dbc5SRasesh Mody };
325ec94dbc5SRasesh Mody 
32622d07d93SRasesh Mody enum ecore_port_mode {
327ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_2X40G,
328ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_2X50G,
329ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_1X100G,
330ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_4X10G_F,
331ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_4X10G_E,
332ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_4X20G,
333ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_1X40G,
334ec94dbc5SRasesh Mody 	ECORE_PORT_MODE_DE_2X25G,
33522d07d93SRasesh Mody 	ECORE_PORT_MODE_DE_1X25G,
33622d07d93SRasesh Mody 	ECORE_PORT_MODE_DE_4X25G,
3370b46a4e6SRasesh Mody 	ECORE_PORT_MODE_DE_2X10G,
338ec94dbc5SRasesh Mody };
339ec94dbc5SRasesh Mody 
340ec94dbc5SRasesh Mody enum ecore_dev_cap {
341ec94dbc5SRasesh Mody 	ECORE_DEV_CAP_ETH,
34222d07d93SRasesh Mody 	ECORE_DEV_CAP_FCOE,
34322d07d93SRasesh Mody 	ECORE_DEV_CAP_ISCSI,
34422d07d93SRasesh Mody 	ECORE_DEV_CAP_ROCE,
34522d07d93SRasesh Mody 	ECORE_DEV_CAP_IWARP
346ec94dbc5SRasesh Mody };
347ec94dbc5SRasesh Mody 
348ec94dbc5SRasesh Mody #ifndef __EXTRACT__LINUX__
349ec94dbc5SRasesh Mody enum ecore_hw_err_type {
350ec94dbc5SRasesh Mody 	ECORE_HW_ERR_FAN_FAIL,
351ec94dbc5SRasesh Mody 	ECORE_HW_ERR_MFW_RESP_FAIL,
352ec94dbc5SRasesh Mody 	ECORE_HW_ERR_HW_ATTN,
353ec94dbc5SRasesh Mody 	ECORE_HW_ERR_DMAE_FAIL,
354ec94dbc5SRasesh Mody 	ECORE_HW_ERR_RAMROD_FAIL,
355ec94dbc5SRasesh Mody 	ECORE_HW_ERR_FW_ASSERT,
356ec94dbc5SRasesh Mody };
357ec94dbc5SRasesh Mody #endif
358ec94dbc5SRasesh Mody 
359e916697fSRasesh Mody enum ecore_db_rec_exec {
360e916697fSRasesh Mody 	DB_REC_DRY_RUN,
361e916697fSRasesh Mody 	DB_REC_REAL_DEAL,
362e916697fSRasesh Mody 	DB_REC_ONCE,
363e916697fSRasesh Mody };
364e916697fSRasesh Mody 
365ec94dbc5SRasesh Mody struct ecore_hw_info {
366ec94dbc5SRasesh Mody 	/* PCI personality */
367ec94dbc5SRasesh Mody 	enum ecore_pci_personality personality;
368bdf4267dSRasesh Mody #define ECORE_IS_RDMA_PERSONALITY(dev) \
369bdf4267dSRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_ETH_ROCE || \
370bdf4267dSRasesh Mody 	 (dev)->hw_info.personality == ECORE_PCI_ETH_IWARP || \
371bdf4267dSRasesh Mody 	 (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
372bdf4267dSRasesh Mody #define ECORE_IS_ROCE_PERSONALITY(dev) \
373bdf4267dSRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_ETH_ROCE || \
374bdf4267dSRasesh Mody 	 (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
375bdf4267dSRasesh Mody #define ECORE_IS_IWARP_PERSONALITY(dev) \
376bdf4267dSRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_ETH_IWARP || \
377bdf4267dSRasesh Mody 	 (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
378bdf4267dSRasesh Mody #define ECORE_IS_L2_PERSONALITY(dev) \
379bdf4267dSRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_ETH || \
380bdf4267dSRasesh Mody 	 ECORE_IS_RDMA_PERSONALITY(dev))
381955770f2SRasesh Mody #define ECORE_IS_FCOE_PERSONALITY(dev) \
382955770f2SRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_FCOE)
383955770f2SRasesh Mody #define ECORE_IS_ISCSI_PERSONALITY(dev) \
384955770f2SRasesh Mody 	((dev)->hw_info.personality == ECORE_PCI_ISCSI)
385ec94dbc5SRasesh Mody 
386ec94dbc5SRasesh Mody 	/* Resource Allocation scheme results */
387ec94dbc5SRasesh Mody 	u32 resc_start[ECORE_MAX_RESC];
388ec94dbc5SRasesh Mody 	u32 resc_num[ECORE_MAX_RESC];
389ec94dbc5SRasesh Mody 	u32 feat_num[ECORE_MAX_FEATURES];
390ec94dbc5SRasesh Mody 
391ec94dbc5SRasesh Mody 	#define RESC_START(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_start[resc])
392ec94dbc5SRasesh Mody 	#define RESC_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_num[resc])
393ec94dbc5SRasesh Mody 	#define RESC_END(_p_hwfn, resc) (RESC_START(_p_hwfn, resc) + \
394ec94dbc5SRasesh Mody 					 RESC_NUM(_p_hwfn, resc))
395ec94dbc5SRasesh Mody 	#define FEAT_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.feat_num[resc])
396ec94dbc5SRasesh Mody 
39722d07d93SRasesh Mody 	/* Amount of traffic classes HW supports */
39822d07d93SRasesh Mody 	u8 num_hw_tc;
39922d07d93SRasesh Mody 
40022d07d93SRasesh Mody /* Amount of TCs which should be active according to DCBx or upper layer driver
40122d07d93SRasesh Mody  * configuration
40222d07d93SRasesh Mody  */
40322d07d93SRasesh Mody 
40422d07d93SRasesh Mody 	u8 num_active_tc;
40522d07d93SRasesh Mody 
40622d07d93SRasesh Mody 	/* The traffic class used by PF for it's offloaded protocol */
407ec94dbc5SRasesh Mody 	u8 offload_tc;
408ec94dbc5SRasesh Mody 
409ec94dbc5SRasesh Mody 	u32 concrete_fid;
410ec94dbc5SRasesh Mody 	u16 opaque_fid;
411ec94dbc5SRasesh Mody 	u16 ovlan;
412ec94dbc5SRasesh Mody 	u32 part_num[4];
413ec94dbc5SRasesh Mody 
414ec94dbc5SRasesh Mody 	unsigned char hw_mac_addr[ETH_ALEN];
41522d07d93SRasesh Mody 	u64 node_wwn; /* For FCoE only */
41622d07d93SRasesh Mody 	u64 port_wwn; /* For FCoE only */
41722d07d93SRasesh Mody 
41822d07d93SRasesh Mody 	u16 num_iscsi_conns;
41922d07d93SRasesh Mody 	u16 num_fcoe_conns;
420ec94dbc5SRasesh Mody 
421ec94dbc5SRasesh Mody 	struct ecore_igu_info *p_igu_info;
422ec94dbc5SRasesh Mody 	/* Sriov */
423ec94dbc5SRasesh Mody 	u8 max_chains_per_vf;
424ec94dbc5SRasesh Mody 
425ec94dbc5SRasesh Mody 	u32 port_mode;
426ec94dbc5SRasesh Mody 	u32 hw_mode;
4275018f1fcSJoyce Kong 	u32 device_capabilities;
4283d1babcaSRasesh Mody 
4293d1babcaSRasesh Mody 	/* Default DCBX mode */
4303d1babcaSRasesh Mody 	u8 dcbx_mode;
4315c11b706SRasesh Mody 
4325c11b706SRasesh Mody 	u16 mtu;
433ec94dbc5SRasesh Mody };
434ec94dbc5SRasesh Mody 
435ec94dbc5SRasesh Mody /* maximun size of read/write commands (HW limit) */
436ec94dbc5SRasesh Mody #define DMAE_MAX_RW_SIZE	0x2000
437ec94dbc5SRasesh Mody 
438ec94dbc5SRasesh Mody struct ecore_dmae_info {
43978e7fcefSRasesh Mody 	/* Spinlock for synchronizing access to functions */
44078e7fcefSRasesh Mody 	osal_spinlock_t lock;
44178e7fcefSRasesh Mody 
44278e7fcefSRasesh Mody 	bool b_mem_ready;
443ec94dbc5SRasesh Mody 
444ec94dbc5SRasesh Mody 	u8 channel;
445ec94dbc5SRasesh Mody 
446ec94dbc5SRasesh Mody 	dma_addr_t completion_word_phys_addr;
447ec94dbc5SRasesh Mody 
448ec94dbc5SRasesh Mody 	/* The memory location where the DMAE writes the completion
449ec94dbc5SRasesh Mody 	 * value when an operation is finished on this context.
450ec94dbc5SRasesh Mody 	 */
451ec94dbc5SRasesh Mody 	u32 *p_completion_word;
452ec94dbc5SRasesh Mody 
453ec94dbc5SRasesh Mody 	dma_addr_t intermediate_buffer_phys_addr;
454ec94dbc5SRasesh Mody 
455ec94dbc5SRasesh Mody 	/* An intermediate buffer for DMAE operations that use virtual
456ec94dbc5SRasesh Mody 	 * addresses - data is DMA'd to/from this buffer and then
457ec94dbc5SRasesh Mody 	 * memcpy'd to/from the virtual address
458ec94dbc5SRasesh Mody 	 */
459ec94dbc5SRasesh Mody 	u32 *p_intermediate_buffer;
460ec94dbc5SRasesh Mody 
461ec94dbc5SRasesh Mody 	dma_addr_t dmae_cmd_phys_addr;
462ec94dbc5SRasesh Mody 	struct dmae_cmd *p_dmae_cmd;
463ec94dbc5SRasesh Mody };
464ec94dbc5SRasesh Mody 
465ec94dbc5SRasesh Mody struct ecore_wfq_data {
466ec94dbc5SRasesh Mody 	u32 default_min_speed; /* When wfq feature is not configured */
467ec94dbc5SRasesh Mody 	u32 min_speed; /* when feature is configured for any 1 vport */
468ec94dbc5SRasesh Mody 	bool configured;
469ec94dbc5SRasesh Mody };
470ec94dbc5SRasesh Mody 
4713b307c55SRasesh Mody #define OFLD_GRP_SIZE 4
4723b307c55SRasesh Mody 
473ec94dbc5SRasesh Mody struct ecore_qm_info {
474ec94dbc5SRasesh Mody 	struct init_qm_pq_params    *qm_pq_params;
475ec94dbc5SRasesh Mody 	struct init_qm_vport_params *qm_vport_params;
476ec94dbc5SRasesh Mody 	struct init_qm_port_params  *qm_port_params;
477ec94dbc5SRasesh Mody 	u16			start_pq;
478ec94dbc5SRasesh Mody 	u8			start_vport;
4795ef41193SRasesh Mody 	u16			pure_lb_pq;
4805ef41193SRasesh Mody 	u16			offload_pq;
4815ef41193SRasesh Mody 	u16			pure_ack_pq;
4825ef41193SRasesh Mody 	u16			ooo_pq;
4835ef41193SRasesh Mody 	u16			first_vf_pq;
4845ef41193SRasesh Mody 	u16			first_mcos_pq;
4855ef41193SRasesh Mody 	u16			first_rl_pq;
486ec94dbc5SRasesh Mody 	u16			num_pqs;
487ec94dbc5SRasesh Mody 	u16			num_vf_pqs;
488ec94dbc5SRasesh Mody 	u8			num_vports;
489ec94dbc5SRasesh Mody 	u8			max_phys_tcs_per_port;
4900e9c6de3SRasesh Mody 	u8			ooo_tc;
491ec94dbc5SRasesh Mody 	bool			pf_rl_en;
492ec94dbc5SRasesh Mody 	bool			pf_wfq_en;
493ec94dbc5SRasesh Mody 	bool			vport_rl_en;
494ec94dbc5SRasesh Mody 	bool			vport_wfq_en;
495ec94dbc5SRasesh Mody 	u8			pf_wfq;
496ec94dbc5SRasesh Mody 	u32			pf_rl;
497ec94dbc5SRasesh Mody 	struct ecore_wfq_data	*wfq_data;
49822d07d93SRasesh Mody 	u8			num_pf_rls;
499ec94dbc5SRasesh Mody };
500ec94dbc5SRasesh Mody 
501e916697fSRasesh Mody struct ecore_db_recovery_info {
502e916697fSRasesh Mody 	osal_list_t list;
503e916697fSRasesh Mody 	osal_spinlock_t lock;
504e916697fSRasesh Mody 	u32 db_recovery_counter;
505e916697fSRasesh Mody };
506e916697fSRasesh Mody 
507ec94dbc5SRasesh Mody struct storm_stats {
508ec94dbc5SRasesh Mody 	u32 address;
509ec94dbc5SRasesh Mody 	u32 len;
510ec94dbc5SRasesh Mody };
511ec94dbc5SRasesh Mody 
512ec94dbc5SRasesh Mody struct ecore_fw_data {
513ec94dbc5SRasesh Mody #ifdef CONFIG_ECORE_BINARY_FW
514ec94dbc5SRasesh Mody 	struct fw_ver_info *fw_ver_info;
515ec94dbc5SRasesh Mody #endif
516ec94dbc5SRasesh Mody 	const u8 *modes_tree_buf;
517ec94dbc5SRasesh Mody 	union init_op *init_ops;
518ec94dbc5SRasesh Mody 	const u32 *arr_data;
5193b307c55SRasesh Mody 	const u32 *fw_overlays;
5203b307c55SRasesh Mody 	u32 fw_overlays_len;
521ec94dbc5SRasesh Mody 	u32 init_ops_size;
522ec94dbc5SRasesh Mody };
523ec94dbc5SRasesh Mody 
52447af7019SRasesh Mody enum ecore_mf_mode_bit {
52547af7019SRasesh Mody 	/* Supports PF-classification based on tag */
52647af7019SRasesh Mody 	ECORE_MF_OVLAN_CLSS,
52747af7019SRasesh Mody 
52847af7019SRasesh Mody 	/* Supports PF-classification based on MAC */
52947af7019SRasesh Mody 	ECORE_MF_LLH_MAC_CLSS,
53047af7019SRasesh Mody 
53147af7019SRasesh Mody 	/* Supports PF-classification based on protocol type */
53247af7019SRasesh Mody 	ECORE_MF_LLH_PROTO_CLSS,
53347af7019SRasesh Mody 
53447af7019SRasesh Mody 	/* Requires a default PF to be set */
53547af7019SRasesh Mody 	ECORE_MF_NEED_DEF_PF,
53647af7019SRasesh Mody 
53747af7019SRasesh Mody 	/* Allow LL2 to multicast/broadcast */
53847af7019SRasesh Mody 	ECORE_MF_LL2_NON_UNICAST,
53947af7019SRasesh Mody 
54047af7019SRasesh Mody 	/* Allow Cross-PF [& child VFs] Tx-switching */
54147af7019SRasesh Mody 	ECORE_MF_INTER_PF_SWITCH,
54247af7019SRasesh Mody 
54347af7019SRasesh Mody 	/* TODO - if we ever re-utilize any of this logic, we can rename */
54447af7019SRasesh Mody 	ECORE_MF_UFP_SPECIFIC,
545a2dc43f3SRasesh Mody 
546a2dc43f3SRasesh Mody 	ECORE_MF_DISABLE_ARFS,
54736f45bceSRasesh Mody 
54836f45bceSRasesh Mody 	/* Use vlan for steering */
54936f45bceSRasesh Mody 	ECORE_MF_8021Q_TAGGING,
55036f45bceSRasesh Mody 
55136f45bceSRasesh Mody 	/* Use stag for steering */
55236f45bceSRasesh Mody 	ECORE_MF_8021AD_TAGGING,
553bf03492aSRasesh Mody 
554bf03492aSRasesh Mody 	/* Allow FIP discovery fallback */
555bf03492aSRasesh Mody 	ECORE_MF_FIP_SPECIAL,
55647af7019SRasesh Mody };
55747af7019SRasesh Mody 
55847af7019SRasesh Mody enum ecore_ufp_mode {
55947af7019SRasesh Mody 	ECORE_UFP_MODE_ETS,
56047af7019SRasesh Mody 	ECORE_UFP_MODE_VNIC_BW,
56147af7019SRasesh Mody };
56247af7019SRasesh Mody 
56347af7019SRasesh Mody enum ecore_ufp_pri_type {
56447af7019SRasesh Mody 	ECORE_UFP_PRI_OS,
56547af7019SRasesh Mody 	ECORE_UFP_PRI_VNIC
56647af7019SRasesh Mody };
56747af7019SRasesh Mody 
56847af7019SRasesh Mody struct ecore_ufp_info {
56947af7019SRasesh Mody 	enum ecore_ufp_pri_type pri_type;
57047af7019SRasesh Mody 	enum ecore_ufp_mode mode;
57147af7019SRasesh Mody 	u8 tc;
57247af7019SRasesh Mody };
57347af7019SRasesh Mody 
574c73d7da7SRasesh Mody enum BAR_ID {
575c73d7da7SRasesh Mody 	BAR_ID_0,	/* used for GRC */
576c73d7da7SRasesh Mody 	BAR_ID_1	/* Used for doorbells */
577c73d7da7SRasesh Mody };
578c73d7da7SRasesh Mody 
5792352f348SRasesh Mody struct ecore_nvm_image_info {
5802352f348SRasesh Mody 	u32				num_images;
5812352f348SRasesh Mody 	struct bist_nvm_image_att	*image_att;
5822352f348SRasesh Mody 	bool				valid;
5832352f348SRasesh Mody };
5842352f348SRasesh Mody 
585ec94dbc5SRasesh Mody struct ecore_hwfn {
586ec94dbc5SRasesh Mody 	struct ecore_dev		*p_dev;
587ec94dbc5SRasesh Mody 	u8				my_id;		/* ID inside the PF */
588ec94dbc5SRasesh Mody #define IS_LEAD_HWFN(edev)		(!((edev)->my_id))
589ec94dbc5SRasesh Mody 	u8				rel_pf_id;	/* Relative to engine*/
590ec94dbc5SRasesh Mody 	u8				abs_pf_id;
591ec94dbc5SRasesh Mody #define ECORE_PATH_ID(_p_hwfn) \
592c0845c33SRasesh Mody 	(ECORE_IS_BB((_p_hwfn)->p_dev) ? ((_p_hwfn)->abs_pf_id & 1) : 0)
593ec94dbc5SRasesh Mody 	u8				port_id;
594ec94dbc5SRasesh Mody 	bool				b_active;
595ec94dbc5SRasesh Mody 
596ec94dbc5SRasesh Mody 	u32				dp_module;
597ec94dbc5SRasesh Mody 	u8				dp_level;
598ec94dbc5SRasesh Mody 	char				name[NAME_SIZE];
599ec94dbc5SRasesh Mody 	void				*dp_ctx;
600ec94dbc5SRasesh Mody 
601ec94dbc5SRasesh Mody 	bool				first_on_engine;
602ec94dbc5SRasesh Mody 	bool				hw_init_done;
603ec94dbc5SRasesh Mody 
604ec94dbc5SRasesh Mody 	u8				num_funcs_on_engine;
60522d07d93SRasesh Mody 	u8				enabled_func_idx;
6063b307c55SRasesh Mody 	u8				num_funcs_on_port;
607ec94dbc5SRasesh Mody 
608ec94dbc5SRasesh Mody 	/* BAR access */
609ec94dbc5SRasesh Mody 	void OSAL_IOMEM			*regview;
610ec94dbc5SRasesh Mody 	void OSAL_IOMEM			*doorbells;
611ec94dbc5SRasesh Mody 	u64				db_phys_addr;
612ec94dbc5SRasesh Mody 	unsigned long			db_size;
613ec94dbc5SRasesh Mody 
614ec94dbc5SRasesh Mody 	/* PTT pool */
615ec94dbc5SRasesh Mody 	struct ecore_ptt_pool		*p_ptt_pool;
616ec94dbc5SRasesh Mody 
617ec94dbc5SRasesh Mody 	/* HW info */
618ec94dbc5SRasesh Mody 	struct ecore_hw_info		hw_info;
619ec94dbc5SRasesh Mody 
620ec94dbc5SRasesh Mody 	/* rt_array (for init-tool) */
621ec94dbc5SRasesh Mody 	struct ecore_rt_data		rt_data;
622ec94dbc5SRasesh Mody 
623ec94dbc5SRasesh Mody 	/* SPQ */
624ec94dbc5SRasesh Mody 	struct ecore_spq		*p_spq;
625ec94dbc5SRasesh Mody 
626ec94dbc5SRasesh Mody 	/* EQ */
627ec94dbc5SRasesh Mody 	struct ecore_eq			*p_eq;
628ec94dbc5SRasesh Mody 
629ec94dbc5SRasesh Mody 	/* Consolidate Q*/
630ec94dbc5SRasesh Mody 	struct ecore_consq		*p_consq;
631ec94dbc5SRasesh Mody 
632ec94dbc5SRasesh Mody 	/* Slow-Path definitions */
633ec94dbc5SRasesh Mody 	osal_dpc_t			sp_dpc;
634ec94dbc5SRasesh Mody 	bool				b_sp_dpc_enabled;
635ec94dbc5SRasesh Mody 
636ec94dbc5SRasesh Mody 	struct ecore_ptt		*p_main_ptt;
637ec94dbc5SRasesh Mody 	struct ecore_ptt		*p_dpc_ptt;
638ec94dbc5SRasesh Mody 
639ec94dbc5SRasesh Mody 	struct ecore_sb_sp_info		*p_sp_sb;
640ec94dbc5SRasesh Mody 	struct ecore_sb_attn_info	*p_sb_attn;
641ec94dbc5SRasesh Mody 
642ec94dbc5SRasesh Mody 	/* Protocol related */
64322d07d93SRasesh Mody 	bool				using_ll2;
64422d07d93SRasesh Mody 	struct ecore_ll2_info		*p_ll2_info;
645ec94dbc5SRasesh Mody 	struct ecore_ooo_info		*p_ooo_info;
64622d07d93SRasesh Mody 	struct ecore_iscsi_info		*p_iscsi_info;
64722d07d93SRasesh Mody 	struct ecore_fcoe_info		*p_fcoe_info;
64822d07d93SRasesh Mody 	struct ecore_rdma_info		*p_rdma_info;
649ec94dbc5SRasesh Mody 	struct ecore_pf_params		pf_params;
650ec94dbc5SRasesh Mody 
65122d07d93SRasesh Mody 	bool				b_rdma_enabled_in_prs;
65222d07d93SRasesh Mody 	u32				rdma_prs_search_reg;
65322d07d93SRasesh Mody 
654ec94dbc5SRasesh Mody 	struct ecore_cxt_mngr		*p_cxt_mngr;
655ec94dbc5SRasesh Mody 
656ec94dbc5SRasesh Mody 	/* Flag indicating whether interrupts are enabled or not*/
657ec94dbc5SRasesh Mody 	bool				b_int_enabled;
658ec94dbc5SRasesh Mody 	bool				b_int_requested;
659ec94dbc5SRasesh Mody 
660ec94dbc5SRasesh Mody 	/* True if the driver requests for the link */
661ec94dbc5SRasesh Mody 	bool				b_drv_link_init;
662ec94dbc5SRasesh Mody 
663ec94dbc5SRasesh Mody 	struct ecore_vf_iov		*vf_iov_info;
664ec94dbc5SRasesh Mody 	struct ecore_pf_iov		*pf_iov_info;
665ec94dbc5SRasesh Mody 	struct ecore_mcp_info		*mcp_info;
66626ae839dSRasesh Mody 	struct ecore_dcbx_info		*p_dcbx_info;
66747af7019SRasesh Mody 	struct ecore_ufp_info		ufp_info;
668ec94dbc5SRasesh Mody 
669ec94dbc5SRasesh Mody 	struct ecore_dmae_info		dmae_info;
670ec94dbc5SRasesh Mody 
671ec94dbc5SRasesh Mody 	/* QM init */
672ec94dbc5SRasesh Mody 	struct ecore_qm_info		qm_info;
673ec94dbc5SRasesh Mody 
674ec94dbc5SRasesh Mody #ifdef CONFIG_ECORE_ZIPPED_FW
67548e8d239SRasesh Mody 	/* Buffer for unzipping firmware data */
676ec94dbc5SRasesh Mody 	void *unzip_buf;
677ec94dbc5SRasesh Mody #endif
678ec94dbc5SRasesh Mody 
679ec94dbc5SRasesh Mody 	struct dbg_tools_data		dbg_info;
6803c361686SRasesh Mody 	void				*dbg_user_info;
681519438f7SRasesh Mody 	struct virt_mem_desc		dbg_arrays[MAX_BIN_DBG_BUFFER_TYPE];
682ec94dbc5SRasesh Mody 
683ec94dbc5SRasesh Mody 	struct z_stream_s		*stream;
684ec94dbc5SRasesh Mody 
685ec94dbc5SRasesh Mody 	/* PWM region specific data */
686ec94dbc5SRasesh Mody 	u32				dpi_size;
687ec94dbc5SRasesh Mody 	u32				dpi_count;
688ec94dbc5SRasesh Mody 	u32				dpi_start_offset; /* this is used to
689ec94dbc5SRasesh Mody 							   * calculate th
690ec94dbc5SRasesh Mody 							   * doorbell address
691ec94dbc5SRasesh Mody 							   */
69222d07d93SRasesh Mody 
69322d07d93SRasesh Mody 	/* If one of the following is set then EDPM shouldn't be used */
69422d07d93SRasesh Mody 	u8				dcbx_no_edpm;
69522d07d93SRasesh Mody 	u8				db_bar_no_edpm;
696eb8e81adSRasesh Mody 
697eb8e81adSRasesh Mody 	/* L2-related */
698eb8e81adSRasesh Mody 	struct ecore_l2_info		*p_l2_info;
69962207535SHarish Patil 
700e916697fSRasesh Mody 	/* Mechanism for recovering from doorbell drop */
701e916697fSRasesh Mody 	struct ecore_db_recovery_info	db_recovery_info;
702e916697fSRasesh Mody 
70376d37490SRasesh Mody 	/* Enable/disable pacing, if request to enable then
70476d37490SRasesh Mody 	 * IOV and mcos configuration will be skipped.
70576d37490SRasesh Mody 	 * this actually reflects the value requested in
70676d37490SRasesh Mody 	 * struct ecore_hw_prepare_params by ecore client.
70776d37490SRasesh Mody 	 */
70876d37490SRasesh Mody 	bool b_en_pacing;
70976d37490SRasesh Mody 
7102352f348SRasesh Mody 	/* Nvm images number and attributes */
7112352f348SRasesh Mody 	struct ecore_nvm_image_info     nvm_info;
7122352f348SRasesh Mody 
71358bb1ee4SRasesh Mody 	struct phys_mem_desc            *fw_overlay_mem;
71458bb1ee4SRasesh Mody 
71562207535SHarish Patil 	/* @DPDK */
71662207535SHarish Patil 	struct ecore_ptt		*p_arfs_ptt;
717*d459b043SManish Chopra 
718*d459b043SManish Chopra 	/* DPDK specific, not the part of vanilla ecore */
719*d459b043SManish Chopra 	osal_spinlock_t spq_lock;
720*d459b043SManish Chopra 	u32 iov_task_flags;
721ec94dbc5SRasesh Mody };
722ec94dbc5SRasesh Mody 
723ec94dbc5SRasesh Mody enum ecore_mf_mode {
724ec94dbc5SRasesh Mody 	ECORE_MF_DEFAULT,
725ec94dbc5SRasesh Mody 	ECORE_MF_OVLAN,
726ec94dbc5SRasesh Mody 	ECORE_MF_NPAR,
72747af7019SRasesh Mody 	ECORE_MF_UFP,
728ec94dbc5SRasesh Mody };
729ec94dbc5SRasesh Mody 
7302352f348SRasesh Mody enum ecore_dev_type {
7312352f348SRasesh Mody 	ECORE_DEV_TYPE_BB,
7322352f348SRasesh Mody 	ECORE_DEV_TYPE_AH,
7332352f348SRasesh Mody };
7342352f348SRasesh Mody 
73522d07d93SRasesh Mody /* @DPDK */
7362352f348SRasesh Mody enum ecore_dbg_features {
7372352f348SRasesh Mody 	DBG_FEATURE_GRC,
7382352f348SRasesh Mody 	DBG_FEATURE_IDLE_CHK,
7392352f348SRasesh Mody 	DBG_FEATURE_MCP_TRACE,
7402352f348SRasesh Mody 	DBG_FEATURE_REG_FIFO,
7412352f348SRasesh Mody 	DBG_FEATURE_IGU_FIFO,
7422352f348SRasesh Mody 	DBG_FEATURE_PROTECTION_OVERRIDE,
7432352f348SRasesh Mody 	DBG_FEATURE_FW_ASSERTS,
7442352f348SRasesh Mody 	DBG_FEATURE_ILT,
7452352f348SRasesh Mody 	DBG_FEATURE_NUM
7462352f348SRasesh Mody };
7472352f348SRasesh Mody 
74822d07d93SRasesh Mody struct ecore_dbg_feature {
74922d07d93SRasesh Mody 	u8				*dump_buf;
75022d07d93SRasesh Mody 	u32				buf_size;
75122d07d93SRasesh Mody 	u32				dumped_dwords;
75222d07d93SRasesh Mody };
75322d07d93SRasesh Mody 
7542352f348SRasesh Mody struct ecore_dbg_params {
7552352f348SRasesh Mody 	struct ecore_dbg_feature features[DBG_FEATURE_NUM];
7562352f348SRasesh Mody 	u8 engine_for_debug;
7572352f348SRasesh Mody 	bool print_data;
758dc8eba81SRasesh Mody };
759dc8eba81SRasesh Mody 
760ec94dbc5SRasesh Mody struct ecore_dev {
761ec94dbc5SRasesh Mody 	u32				dp_module;
762ec94dbc5SRasesh Mody 	u8				dp_level;
763ec94dbc5SRasesh Mody 	char				name[NAME_SIZE];
764ec94dbc5SRasesh Mody 	void				*dp_ctx;
765ec94dbc5SRasesh Mody 
766dc8eba81SRasesh Mody 	enum ecore_dev_type		type;
767ec94dbc5SRasesh Mody /* Translate type/revision combo into the proper conditions */
768ec94dbc5SRasesh Mody #define ECORE_IS_BB(dev)	((dev)->type == ECORE_DEV_TYPE_BB)
769c018d2b4SRasesh Mody #define ECORE_IS_BB_A0(dev)	(ECORE_IS_BB(dev) && CHIP_REV_IS_A0(dev))
770c018d2b4SRasesh Mody #ifndef ASIC_ONLY
771c018d2b4SRasesh Mody #define ECORE_IS_BB_B0(dev)	((ECORE_IS_BB(dev) && CHIP_REV_IS_B0(dev)) || \
772c018d2b4SRasesh Mody 				 (CHIP_REV_IS_TEDIBEAR(dev)))
773c018d2b4SRasesh Mody #else
774c018d2b4SRasesh Mody #define ECORE_IS_BB_B0(dev)	(ECORE_IS_BB(dev) && CHIP_REV_IS_B0(dev))
775c018d2b4SRasesh Mody #endif
776ec94dbc5SRasesh Mody #define ECORE_IS_AH(dev)	((dev)->type == ECORE_DEV_TYPE_AH)
777ec94dbc5SRasesh Mody #define ECORE_IS_K2(dev)	ECORE_IS_AH(dev)
778ec94dbc5SRasesh Mody 
779dc8eba81SRasesh Mody 	u16 vendor_id;
780dc8eba81SRasesh Mody 	u16 device_id;
7818bb13112SRasesh Mody #define ECORE_DEV_ID_MASK	0xff00
7828bb13112SRasesh Mody #define ECORE_DEV_ID_MASK_BB	0x1600
7838bb13112SRasesh Mody #define ECORE_DEV_ID_MASK_AH	0x8000
7848bb13112SRasesh Mody 
785ec94dbc5SRasesh Mody 	u16				chip_num;
786ec94dbc5SRasesh Mody #define CHIP_NUM_MASK			0xffff
7873b212853SRasesh Mody #define CHIP_NUM_SHIFT			0
788ec94dbc5SRasesh Mody 
7893b212853SRasesh Mody 	u8				chip_rev;
790ec94dbc5SRasesh Mody #define CHIP_REV_MASK			0xf
7913b212853SRasesh Mody #define CHIP_REV_SHIFT			0
792ec94dbc5SRasesh Mody #ifndef ASIC_ONLY
793ec94dbc5SRasesh Mody #define CHIP_REV_IS_TEDIBEAR(_p_dev)	((_p_dev)->chip_rev == 0x5)
794ec94dbc5SRasesh Mody #define CHIP_REV_IS_EMUL_A0(_p_dev)	((_p_dev)->chip_rev == 0xe)
795ec94dbc5SRasesh Mody #define CHIP_REV_IS_EMUL_B0(_p_dev)	((_p_dev)->chip_rev == 0xc)
7963b212853SRasesh Mody #define CHIP_REV_IS_EMUL(_p_dev) \
7973b212853SRasesh Mody 	(CHIP_REV_IS_EMUL_A0(_p_dev) || CHIP_REV_IS_EMUL_B0(_p_dev))
798ec94dbc5SRasesh Mody #define CHIP_REV_IS_FPGA_A0(_p_dev)	((_p_dev)->chip_rev == 0xf)
799ec94dbc5SRasesh Mody #define CHIP_REV_IS_FPGA_B0(_p_dev)	((_p_dev)->chip_rev == 0xd)
8003b212853SRasesh Mody #define CHIP_REV_IS_FPGA(_p_dev) \
8013b212853SRasesh Mody 	(CHIP_REV_IS_FPGA_A0(_p_dev) || CHIP_REV_IS_FPGA_B0(_p_dev))
802ec94dbc5SRasesh Mody #define CHIP_REV_IS_SLOW(_p_dev) \
803ec94dbc5SRasesh Mody 	(CHIP_REV_IS_EMUL(_p_dev) || CHIP_REV_IS_FPGA(_p_dev))
804ec94dbc5SRasesh Mody #define CHIP_REV_IS_A0(_p_dev) \
8053b212853SRasesh Mody 	(CHIP_REV_IS_EMUL_A0(_p_dev) || CHIP_REV_IS_FPGA_A0(_p_dev) || \
8063b212853SRasesh Mody 	 (!(_p_dev)->chip_rev && !(_p_dev)->chip_metal))
807ec94dbc5SRasesh Mody #define CHIP_REV_IS_B0(_p_dev) \
8083b212853SRasesh Mody 	(CHIP_REV_IS_EMUL_B0(_p_dev) || CHIP_REV_IS_FPGA_B0(_p_dev) || \
8093b212853SRasesh Mody 	 ((_p_dev)->chip_rev == 1 && !(_p_dev)->chip_metal))
81022d07d93SRasesh Mody #define CHIP_REV_IS_ASIC(_p_dev)	!CHIP_REV_IS_SLOW(_p_dev)
811ec94dbc5SRasesh Mody #else
8123b212853SRasesh Mody #define CHIP_REV_IS_A0(_p_dev) \
8133b212853SRasesh Mody 	(!(_p_dev)->chip_rev && !(_p_dev)->chip_metal)
8143b212853SRasesh Mody #define CHIP_REV_IS_B0(_p_dev) \
8153b212853SRasesh Mody 	((_p_dev)->chip_rev == 1 && !(_p_dev)->chip_metal)
816ec94dbc5SRasesh Mody #endif
817ec94dbc5SRasesh Mody 
8183b212853SRasesh Mody 	u8				chip_metal;
819ec94dbc5SRasesh Mody #define CHIP_METAL_MASK			0xff
8203b212853SRasesh Mody #define CHIP_METAL_SHIFT		0
821ec94dbc5SRasesh Mody 
8223b212853SRasesh Mody 	u8				chip_bond_id;
8233b212853SRasesh Mody #define CHIP_BOND_ID_MASK		0xff
824ec94dbc5SRasesh Mody #define CHIP_BOND_ID_SHIFT		0
825ec94dbc5SRasesh Mody 
826ec94dbc5SRasesh Mody 	u8				num_engines;
827dd7b6aadSRasesh Mody 	u8				num_ports;
828dd7b6aadSRasesh Mody 	u8				num_ports_in_engine;
829ec94dbc5SRasesh Mody 	u8				num_funcs_in_port;
830ec94dbc5SRasesh Mody 
831ec94dbc5SRasesh Mody 	u8				path_id;
83247af7019SRasesh Mody 
8335018f1fcSJoyce Kong 	u32				mf_bits;
834ec94dbc5SRasesh Mody 	enum ecore_mf_mode		mf_mode;
835ec94dbc5SRasesh Mody #define IS_MF_DEFAULT(_p_hwfn)	\
836ec94dbc5SRasesh Mody 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_DEFAULT)
83722d07d93SRasesh Mody #define IS_MF_SI(_p_hwfn)	\
83822d07d93SRasesh Mody 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_NPAR)
83922d07d93SRasesh Mody #define IS_MF_SD(_p_hwfn)	\
84022d07d93SRasesh Mody 	(((_p_hwfn)->p_dev)->mf_mode == ECORE_MF_OVLAN)
841ec94dbc5SRasesh Mody 
842ec94dbc5SRasesh Mody 	int				pcie_width;
843ec94dbc5SRasesh Mody 	int				pcie_speed;
844de5588afSRasesh Mody 
845ec94dbc5SRasesh Mody 	/* Add MF related configuration */
846ec94dbc5SRasesh Mody 	u8				mcp_rev;
847ec94dbc5SRasesh Mody 	u8				boot_mode;
848ec94dbc5SRasesh Mody 
849ec94dbc5SRasesh Mody 	u8				wol;
850ec94dbc5SRasesh Mody 
851ec94dbc5SRasesh Mody 	u32				int_mode;
852ec94dbc5SRasesh Mody 	enum ecore_coalescing_mode	int_coalescing_mode;
85322d07d93SRasesh Mody 	u16				rx_coalesce_usecs;
85422d07d93SRasesh Mody 	u16				tx_coalesce_usecs;
855ec94dbc5SRasesh Mody 
856ec94dbc5SRasesh Mody 	/* Start Bar offset of first hwfn */
857ec94dbc5SRasesh Mody 	void OSAL_IOMEM			*regview;
858ec94dbc5SRasesh Mody 	void OSAL_IOMEM			*doorbells;
859ec94dbc5SRasesh Mody 	u64				db_phys_addr;
860ec94dbc5SRasesh Mody 	unsigned long			db_size;
861ec94dbc5SRasesh Mody 
862ec94dbc5SRasesh Mody 	/* PCI */
863ec94dbc5SRasesh Mody 	u8				cache_shift;
864ec94dbc5SRasesh Mody 
865ec94dbc5SRasesh Mody 	/* Init */
8667ed1cd53SRasesh Mody 	const u32			*iro_arr;
8677ed1cd53SRasesh Mody #define IRO	((const struct iro *)p_hwfn->p_dev->iro_arr)
868ec94dbc5SRasesh Mody 
869ec94dbc5SRasesh Mody 	/* HW functions */
870ec94dbc5SRasesh Mody 	u8				num_hwfns;
871ec94dbc5SRasesh Mody 	struct ecore_hwfn		hwfns[MAX_HWFNS_PER_DEVICE];
8723eed444aSRasesh Mody #define ECORE_LEADING_HWFN(dev)		(&dev->hwfns[0])
873c0845c33SRasesh Mody #define ECORE_IS_CMT(dev)		((dev)->num_hwfns > 1)
874ec94dbc5SRasesh Mody 
8753eed444aSRasesh Mody 	/* Engine affinity */
8763eed444aSRasesh Mody 	u8				l2_affin_hint;
8773eed444aSRasesh Mody 	u8				fir_affin;
8783eed444aSRasesh Mody 	u8				iwarp_affin;
8793eed444aSRasesh Mody 	/* Macro for getting the engine-affinitized hwfn for FCoE/iSCSI/RoCE */
8803eed444aSRasesh Mody #define ECORE_FIR_AFFIN_HWFN(dev)	(&dev->hwfns[dev->fir_affin])
8813eed444aSRasesh Mody 	/* Macro for getting the engine-affinitized hwfn for iWARP */
8823eed444aSRasesh Mody #define ECORE_IWARP_AFFIN_HWFN(dev)	(&dev->hwfns[dev->iwarp_affin])
8833eed444aSRasesh Mody 	/* Generic macro for getting the engine-affinitized hwfn */
8843eed444aSRasesh Mody #define ECORE_AFFIN_HWFN(dev) \
8853eed444aSRasesh Mody 	(ECORE_IS_IWARP_PERSONALITY(ECORE_LEADING_HWFN(dev)) ? \
8863eed444aSRasesh Mody 	 ECORE_IWARP_AFFIN_HWFN(dev) : \
8873eed444aSRasesh Mody 	 ECORE_FIR_AFFIN_HWFN(dev))
8883eed444aSRasesh Mody 	/* Macro for getting the index (0/1) of the engine-affinitized hwfn */
8893eed444aSRasesh Mody #define ECORE_AFFIN_HWFN_IDX(dev) \
8903eed444aSRasesh Mody 	(IS_LEAD_HWFN(ECORE_AFFIN_HWFN(dev)) ? 0 : 1)
8913eed444aSRasesh Mody 
892ec94dbc5SRasesh Mody 	/* SRIOV */
89322d07d93SRasesh Mody 	struct ecore_hw_sriov_info	*p_iov_info;
89422d07d93SRasesh Mody #define IS_ECORE_SRIOV(p_dev)		(!!(p_dev)->p_iov_info)
895a7f3cac3SRasesh Mody 	struct ecore_tunnel_info	tunnel;
896ec94dbc5SRasesh Mody 	bool				b_is_vf;
897cb051eb2SRasesh Mody 	bool				b_dont_override_vf_msix;
898ec94dbc5SRasesh Mody 
899ec94dbc5SRasesh Mody 	u32				drv_type;
900ec94dbc5SRasesh Mody 
90122d07d93SRasesh Mody 	u32				rdma_max_sge;
90222d07d93SRasesh Mody 	u32				rdma_max_inline;
90322d07d93SRasesh Mody 	u32				rdma_max_srq_sge;
90422d07d93SRasesh Mody 
905ec94dbc5SRasesh Mody 	struct ecore_eth_stats		*reset_stats;
906ec94dbc5SRasesh Mody 	struct ecore_fw_data		*fw_data;
907ec94dbc5SRasesh Mody 
908ec94dbc5SRasesh Mody 	u32				mcp_nvm_resp;
909ec94dbc5SRasesh Mody 
910ec94dbc5SRasesh Mody 	/* Recovery */
911ec94dbc5SRasesh Mody 	bool				recov_in_prog;
912ec94dbc5SRasesh Mody 
91322d07d93SRasesh Mody /* Indicates whether should prevent attentions from being reasserted */
91422d07d93SRasesh Mody 
91522d07d93SRasesh Mody 	bool				attn_clr_en;
91622d07d93SRasesh Mody 
917301ea2d7SRasesh Mody 	/* Indicates whether allowing the MFW to collect a crash dump */
9183d5083f2SRasesh Mody 	bool				allow_mdump;
919301ea2d7SRasesh Mody 
92022d07d93SRasesh Mody 	/* Indicates if the reg_fifo is checked after any register access */
92122d07d93SRasesh Mody 	bool				chk_reg_fifo;
92222d07d93SRasesh Mody 
923ec94dbc5SRasesh Mody #ifndef ASIC_ONLY
924ec94dbc5SRasesh Mody 	bool				b_is_emul_full;
9253b307c55SRasesh Mody 	bool				b_is_emul_mac;
926ec94dbc5SRasesh Mody #endif
9273eed444aSRasesh Mody 	/* LLH info */
9283eed444aSRasesh Mody 	u8				ppfid_bitmap;
9293eed444aSRasesh Mody 	struct ecore_llh_info		*p_llh_info;
930ec94dbc5SRasesh Mody 
9313f11cf06SRasesh Mody 	/* Indicates whether this PF serves a storage target */
9323f11cf06SRasesh Mody 	bool				b_is_target;
9333f11cf06SRasesh Mody 
93448e8d239SRasesh Mody #ifdef CONFIG_ECORE_BINARY_FW /* @DPDK */
935ec94dbc5SRasesh Mody 	void				*firmware;
936ec94dbc5SRasesh Mody 	u64				fw_len;
93748e8d239SRasesh Mody #endif
9382352f348SRasesh Mody 	bool				disable_ilt_dump;
939ec94dbc5SRasesh Mody 
94022d07d93SRasesh Mody 	/* @DPDK */
94122d07d93SRasesh Mody 	struct ecore_dbg_feature	dbg_features[DBG_FEATURE_NUM];
9422352f348SRasesh Mody 	struct ecore_dbg_params		dbg_params;
9432352f348SRasesh Mody 	osal_mutex_t			dbg_lock;
94492c6786eSManish Chopra 
94592c6786eSManish Chopra 	/* DPDK specific ecore field */
94692c6786eSManish Chopra 	struct rte_pci_device		*pci_dev;
947ec94dbc5SRasesh Mody };
948ec94dbc5SRasesh Mody 
9493b307c55SRasesh Mody enum ecore_hsi_def_type {
9503b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_NUM_VFS,
9513b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_NUM_L2_QUEUES,
9523b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_NUM_PORTS,
9533b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_SB_PER_PATH,
9543b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_NUM_PFS,
9553b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_NUM_VPORTS,
9563b307c55SRasesh Mody 	ECORE_HSI_DEF_NUM_ETH_RSS_ENGINE,
9573b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_QM_TX_QUEUES,
9583b307c55SRasesh Mody 	ECORE_HSI_DEF_NUM_PXP_ILT_RECORDS,
9593b307c55SRasesh Mody 	ECORE_HSI_DEF_NUM_RDMA_STATISTIC_COUNTERS,
9603b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_QM_GLOBAL_RLS,
9613b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_PBF_CMD_LINES,
9623b307c55SRasesh Mody 	ECORE_HSI_DEF_MAX_BTB_BLOCKS,
9633b307c55SRasesh Mody 	ECORE_NUM_HSI_DEFS
9643b307c55SRasesh Mody };
9653b307c55SRasesh Mody 
9663b307c55SRasesh Mody u32 ecore_get_hsi_def_val(struct ecore_dev *p_dev,
9673b307c55SRasesh Mody 			  enum ecore_hsi_def_type type);
9683b307c55SRasesh Mody 
9693b307c55SRasesh Mody #define NUM_OF_VFS(dev) \
9703b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_NUM_VFS)
9713b307c55SRasesh Mody #define NUM_OF_L2_QUEUES(dev) \
9723b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_NUM_L2_QUEUES)
9733b307c55SRasesh Mody #define NUM_OF_PORTS(dev) \
9743b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_NUM_PORTS)
9753b307c55SRasesh Mody #define NUM_OF_SBS(dev) \
9763b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_SB_PER_PATH)
9773b307c55SRasesh Mody #define NUM_OF_ENG_PFS(dev) \
9783b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_NUM_PFS)
9793b307c55SRasesh Mody #define NUM_OF_VPORTS(dev) \
9803b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_NUM_VPORTS)
9813b307c55SRasesh Mody #define NUM_OF_RSS_ENGINES(dev) \
9823b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_NUM_ETH_RSS_ENGINE)
9833b307c55SRasesh Mody #define NUM_OF_QM_TX_QUEUES(dev) \
9843b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_QM_TX_QUEUES)
9853b307c55SRasesh Mody #define NUM_OF_PXP_ILT_RECORDS(dev) \
9863b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_NUM_PXP_ILT_RECORDS)
9873b307c55SRasesh Mody #define NUM_OF_RDMA_STATISTIC_COUNTERS(dev) \
9883b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_NUM_RDMA_STATISTIC_COUNTERS)
9893b307c55SRasesh Mody #define NUM_OF_QM_GLOBAL_RLS(dev) \
9903b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_QM_GLOBAL_RLS)
9913b307c55SRasesh Mody #define NUM_OF_PBF_CMD_LINES(dev) \
9923b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_PBF_CMD_LINES)
9933b307c55SRasesh Mody #define NUM_OF_BTB_BLOCKS(dev) \
9943b307c55SRasesh Mody 	ecore_get_hsi_def_val(dev, ECORE_HSI_DEF_MAX_BTB_BLOCKS)
995ec94dbc5SRasesh Mody 
996c68f27a2SRasesh Mody #define CRC8_TABLE_SIZE 256
997c68f27a2SRasesh Mody 
998ec94dbc5SRasesh Mody /**
999ec94dbc5SRasesh Mody  * @brief ecore_concrete_to_sw_fid - get the sw function id from
1000ec94dbc5SRasesh Mody  *        the concrete value.
1001ec94dbc5SRasesh Mody  *
1002ec94dbc5SRasesh Mody  * @param concrete_fid
1003ec94dbc5SRasesh Mody  *
1004ec94dbc5SRasesh Mody  * @return OSAL_INLINE u8
1005ec94dbc5SRasesh Mody  */
ecore_concrete_to_sw_fid(u32 concrete_fid)100630ecf673SRasesh Mody static OSAL_INLINE u8 ecore_concrete_to_sw_fid(u32 concrete_fid)
1007ec94dbc5SRasesh Mody {
1008ec94dbc5SRasesh Mody 	u8 vfid     = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID);
1009ec94dbc5SRasesh Mody 	u8 pfid     = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID);
1010ec94dbc5SRasesh Mody 	u8 vf_valid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFVALID);
1011ec94dbc5SRasesh Mody 	u8 sw_fid;
1012ec94dbc5SRasesh Mody 
1013ec94dbc5SRasesh Mody 	if (vf_valid)
1014ec94dbc5SRasesh Mody 		sw_fid = vfid + MAX_NUM_PFS;
1015ec94dbc5SRasesh Mody 	else
1016ec94dbc5SRasesh Mody 		sw_fid = pfid;
1017ec94dbc5SRasesh Mody 
1018ec94dbc5SRasesh Mody 	return sw_fid;
1019ec94dbc5SRasesh Mody }
1020ec94dbc5SRasesh Mody 
10219e004533SRasesh Mody #define PKT_LB_TC 9
1022ec94dbc5SRasesh Mody 
1023ec94dbc5SRasesh Mody int ecore_configure_vport_wfq(struct ecore_dev *p_dev, u16 vp_id, u32 rate);
1024ec94dbc5SRasesh Mody void ecore_configure_vp_wfq_on_link_change(struct ecore_dev *p_dev,
1025544927f9SRasesh Mody 					   struct ecore_ptt *p_ptt,
1026ec94dbc5SRasesh Mody 					   u32 min_pf_rate);
1027ec94dbc5SRasesh Mody 
1028ec94dbc5SRasesh Mody int ecore_configure_pf_max_bandwidth(struct ecore_dev *p_dev, u8 max_bw);
1029ec94dbc5SRasesh Mody int ecore_configure_pf_min_bandwidth(struct ecore_dev *p_dev, u8 min_bw);
1030ec94dbc5SRasesh Mody void ecore_clean_wfq_db(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
1031ec94dbc5SRasesh Mody int ecore_device_num_engines(struct ecore_dev *p_dev);
1032ec94dbc5SRasesh Mody int ecore_device_num_ports(struct ecore_dev *p_dev);
1033e0685050SRasesh Mody void ecore_set_fw_mac_addr(__le16 *fw_msb, __le16 *fw_mid, __le16 *fw_lsb,
1034e0685050SRasesh Mody 			   u8 *mac);
1035ec94dbc5SRasesh Mody 
10365ef41193SRasesh Mody /* Flags for indication of required queues */
10375ef41193SRasesh Mody #define PQ_FLAGS_RLS	(1 << 0)
10385ef41193SRasesh Mody #define PQ_FLAGS_MCOS	(1 << 1)
10395ef41193SRasesh Mody #define PQ_FLAGS_LB	(1 << 2)
10405ef41193SRasesh Mody #define PQ_FLAGS_OOO	(1 << 3)
10415ef41193SRasesh Mody #define PQ_FLAGS_ACK	(1 << 4)
10425ef41193SRasesh Mody #define PQ_FLAGS_OFLD	(1 << 5)
10435ef41193SRasesh Mody #define PQ_FLAGS_VFS	(1 << 6)
104476d37490SRasesh Mody #define PQ_FLAGS_LLT	(1 << 7)
10455ef41193SRasesh Mody 
10465ef41193SRasesh Mody /* physical queue index for cm context intialization */
10475ef41193SRasesh Mody u16 ecore_get_cm_pq_idx(struct ecore_hwfn *p_hwfn, u32 pq_flags);
10485ef41193SRasesh Mody u16 ecore_get_cm_pq_idx_mcos(struct ecore_hwfn *p_hwfn, u8 tc);
10495ef41193SRasesh Mody u16 ecore_get_cm_pq_idx_vf(struct ecore_hwfn *p_hwfn, u16 vf);
105076d37490SRasesh Mody u16 ecore_get_cm_pq_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl);
105176d37490SRasesh Mody 
105276d37490SRasesh Mody /* qm vport for rate limit configuration */
105376d37490SRasesh Mody u16 ecore_get_qm_vport_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl);
10545ef41193SRasesh Mody 
1055e916697fSRasesh Mody const char *ecore_hw_get_resc_name(enum ecore_resources res_id);
1056e916697fSRasesh Mody 
1057e916697fSRasesh Mody /* doorbell recovery mechanism */
1058e916697fSRasesh Mody void ecore_db_recovery_dp(struct ecore_hwfn *p_hwfn);
1059e916697fSRasesh Mody void ecore_db_recovery_execute(struct ecore_hwfn *p_hwfn,
1060e916697fSRasesh Mody 			       enum ecore_db_rec_exec);
1061e916697fSRasesh Mody 
1062f32557f9SRasesh Mody bool ecore_edpm_enabled(struct ecore_hwfn *p_hwfn);
1063f32557f9SRasesh Mody 
10645ef41193SRasesh Mody /* amount of resources used in qm init */
10655ef41193SRasesh Mody u8 ecore_init_qm_get_num_tcs(struct ecore_hwfn *p_hwfn);
10665ef41193SRasesh Mody u16 ecore_init_qm_get_num_vfs(struct ecore_hwfn *p_hwfn);
10675ef41193SRasesh Mody u16 ecore_init_qm_get_num_pf_rls(struct ecore_hwfn *p_hwfn);
10685ef41193SRasesh Mody u16 ecore_init_qm_get_num_vports(struct ecore_hwfn *p_hwfn);
10695ef41193SRasesh Mody u16 ecore_init_qm_get_num_pqs(struct ecore_hwfn *p_hwfn);
10705ef41193SRasesh Mody 
10713eed444aSRasesh Mody #define MFW_PORT(_p_hwfn)	((_p_hwfn)->abs_pf_id % \
10723eed444aSRasesh Mody 				 ecore_device_num_ports((_p_hwfn)->p_dev))
10733eed444aSRasesh Mody 
10743eed444aSRasesh Mody /* The PFID<->PPFID calculation is based on the relative index of a PF on its
10753eed444aSRasesh Mody  * port. In BB there is a bug in the LLH in which the PPFID is actually engine
10763eed444aSRasesh Mody  * based, and thus it equals the PFID.
10773eed444aSRasesh Mody  */
10783eed444aSRasesh Mody #define ECORE_PFID_BY_PPFID(_p_hwfn, abs_ppfid) \
10793eed444aSRasesh Mody 	(ECORE_IS_BB((_p_hwfn)->p_dev) ? \
10803eed444aSRasesh Mody 	 (abs_ppfid) : \
10813eed444aSRasesh Mody 	 (abs_ppfid) * (_p_hwfn)->p_dev->num_ports_in_engine + \
10823eed444aSRasesh Mody 	 MFW_PORT(_p_hwfn))
10833eed444aSRasesh Mody #define ECORE_PPFID_BY_PFID(_p_hwfn) \
10843eed444aSRasesh Mody 	(ECORE_IS_BB((_p_hwfn)->p_dev) ? \
10853eed444aSRasesh Mody 	 (_p_hwfn)->rel_pf_id : \
10863eed444aSRasesh Mody 	 (_p_hwfn)->rel_pf_id / (_p_hwfn)->p_dev->num_ports_in_engine)
10873eed444aSRasesh Mody 
10883eed444aSRasesh Mody enum _ecore_status_t ecore_all_ppfids_wr(struct ecore_hwfn *p_hwfn,
10893eed444aSRasesh Mody 					 struct ecore_ptt *p_ptt, u32 addr,
10903eed444aSRasesh Mody 					 u32 val);
10913eed444aSRasesh Mody 
10923eed444aSRasesh Mody /* Utility functions for dumping the content of the NIG LLH filters */
10933eed444aSRasesh Mody enum _ecore_status_t ecore_llh_dump_ppfid(struct ecore_dev *p_dev, u8 ppfid);
10943eed444aSRasesh Mody enum _ecore_status_t ecore_llh_dump_all(struct ecore_dev *p_dev);
1095ec94dbc5SRasesh Mody 
10962352f348SRasesh Mody /**
10972352f348SRasesh Mody  * @brief ecore_set_platform_str - Set the debug dump platform string.
10982352f348SRasesh Mody  * Write the ecore version and device's string to the given buffer.
10992352f348SRasesh Mody  *
11002352f348SRasesh Mody  * @param p_hwfn
11012352f348SRasesh Mody  * @param buf_str
11022352f348SRasesh Mody  * @param buf_size
11032352f348SRasesh Mody  */
11042352f348SRasesh Mody void ecore_set_platform_str(struct ecore_hwfn *p_hwfn,
11052352f348SRasesh Mody 			    char *buf_str, u32 buf_size);
11062352f348SRasesh Mody 
11073b307c55SRasesh Mody #define TSTORM_QZONE_START	PXP_VF_BAR0_START_SDM_ZONE_A
11083b307c55SRasesh Mody 
11093b307c55SRasesh Mody #define MSTORM_QZONE_START(dev) \
11103b307c55SRasesh Mody 	(TSTORM_QZONE_START + (TSTORM_QZONE_SIZE * NUM_OF_L2_QUEUES(dev)))
11113b307c55SRasesh Mody 
1112ec94dbc5SRasesh Mody #endif /* __ECORE_H */
1113