xref: /linux/drivers/net/ethernet/broadcom/bnxt/bnxt.h (revision b50ecc5aca4d18f1f0c4942f5c797bc85edef144)
1 /* Broadcom NetXtreme-C/E network driver.
2  *
3  * Copyright (c) 2014-2016 Broadcom Corporation
4  * Copyright (c) 2016-2018 Broadcom Limited
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation.
9  */
10 
11 #ifndef BNXT_H
12 #define BNXT_H
13 
14 #define DRV_MODULE_NAME		"bnxt_en"
15 
16 /* DO NOT CHANGE DRV_VER_* defines
17  * FIXME: Delete them
18  */
19 #define DRV_VER_MAJ	1
20 #define DRV_VER_MIN	10
21 #define DRV_VER_UPD	3
22 
23 #include <linux/ethtool.h>
24 #include <linux/interrupt.h>
25 #include <linux/rhashtable.h>
26 #include <linux/crash_dump.h>
27 #include <linux/auxiliary_bus.h>
28 #include <net/devlink.h>
29 #include <net/dst_metadata.h>
30 #include <net/xdp.h>
31 #include <linux/dim.h>
32 #include <linux/io-64-nonatomic-lo-hi.h>
33 #ifdef CONFIG_TEE_BNXT_FW
34 #include <linux/firmware/broadcom/tee_bnxt_fw.h>
35 #endif
36 
37 extern struct list_head bnxt_block_cb_list;
38 
39 struct page_pool;
40 
41 struct tx_bd {
42 	__le32 tx_bd_len_flags_type;
43 	#define TX_BD_TYPE					(0x3f << 0)
44 	 #define TX_BD_TYPE_SHORT_TX_BD				 (0x00 << 0)
45 	 #define TX_BD_TYPE_LONG_TX_BD				 (0x10 << 0)
46 	#define TX_BD_FLAGS_PACKET_END				(1 << 6)
47 	#define TX_BD_FLAGS_NO_CMPL				(1 << 7)
48 	#define TX_BD_FLAGS_BD_CNT				(0x1f << 8)
49 	 #define TX_BD_FLAGS_BD_CNT_SHIFT			 8
50 	#define TX_BD_FLAGS_LHINT				(3 << 13)
51 	 #define TX_BD_FLAGS_LHINT_SHIFT			 13
52 	 #define TX_BD_FLAGS_LHINT_512_AND_SMALLER		 (0 << 13)
53 	 #define TX_BD_FLAGS_LHINT_512_TO_1023			 (1 << 13)
54 	 #define TX_BD_FLAGS_LHINT_1024_TO_2047			 (2 << 13)
55 	 #define TX_BD_FLAGS_LHINT_2048_AND_LARGER		 (3 << 13)
56 	#define TX_BD_FLAGS_COAL_NOW				(1 << 15)
57 	#define TX_BD_LEN					(0xffff << 16)
58 	 #define TX_BD_LEN_SHIFT				 16
59 
60 	u32 tx_bd_opaque;
61 	__le64 tx_bd_haddr;
62 } __packed;
63 
64 #define TX_OPAQUE_IDX_MASK	0x0000ffff
65 #define TX_OPAQUE_BDS_MASK	0x00ff0000
66 #define TX_OPAQUE_BDS_SHIFT	16
67 #define TX_OPAQUE_RING_MASK	0xff000000
68 #define TX_OPAQUE_RING_SHIFT	24
69 
70 #define SET_TX_OPAQUE(bp, txr, idx, bds)				\
71 	(((txr)->tx_napi_idx << TX_OPAQUE_RING_SHIFT) |			\
72 	 ((bds) << TX_OPAQUE_BDS_SHIFT) | ((idx) & (bp)->tx_ring_mask))
73 
74 #define TX_OPAQUE_IDX(opq)	((opq) & TX_OPAQUE_IDX_MASK)
75 #define TX_OPAQUE_RING(opq)	(((opq) & TX_OPAQUE_RING_MASK) >>	\
76 				 TX_OPAQUE_RING_SHIFT)
77 #define TX_OPAQUE_BDS(opq)	(((opq) & TX_OPAQUE_BDS_MASK) >>	\
78 				 TX_OPAQUE_BDS_SHIFT)
79 #define TX_OPAQUE_PROD(bp, opq)	((TX_OPAQUE_IDX(opq) + TX_OPAQUE_BDS(opq)) &\
80 				 (bp)->tx_ring_mask)
81 
82 struct tx_bd_ext {
83 	__le32 tx_bd_hsize_lflags;
84 	#define TX_BD_FLAGS_TCP_UDP_CHKSUM			(1 << 0)
85 	#define TX_BD_FLAGS_IP_CKSUM				(1 << 1)
86 	#define TX_BD_FLAGS_NO_CRC				(1 << 2)
87 	#define TX_BD_FLAGS_STAMP				(1 << 3)
88 	#define TX_BD_FLAGS_T_IP_CHKSUM				(1 << 4)
89 	#define TX_BD_FLAGS_LSO					(1 << 5)
90 	#define TX_BD_FLAGS_IPID_FMT				(1 << 6)
91 	#define TX_BD_FLAGS_T_IPID				(1 << 7)
92 	#define TX_BD_HSIZE					(0xff << 16)
93 	 #define TX_BD_HSIZE_SHIFT				 16
94 
95 	__le32 tx_bd_mss;
96 	__le32 tx_bd_cfa_action;
97 	#define TX_BD_CFA_ACTION				(0xffff << 16)
98 	 #define TX_BD_CFA_ACTION_SHIFT				 16
99 
100 	__le32 tx_bd_cfa_meta;
101 	#define TX_BD_CFA_META_MASK                             0xfffffff
102 	#define TX_BD_CFA_META_VID_MASK                         0xfff
103 	#define TX_BD_CFA_META_PRI_MASK                         (0xf << 12)
104 	 #define TX_BD_CFA_META_PRI_SHIFT                        12
105 	#define TX_BD_CFA_META_TPID_MASK                        (3 << 16)
106 	 #define TX_BD_CFA_META_TPID_SHIFT                       16
107 	#define TX_BD_CFA_META_KEY                              (0xf << 28)
108 	 #define TX_BD_CFA_META_KEY_SHIFT			 28
109 	#define TX_BD_CFA_META_KEY_VLAN                         (1 << 28)
110 };
111 
112 #define BNXT_TX_PTP_IS_SET(lflags) ((lflags) & cpu_to_le32(TX_BD_FLAGS_STAMP))
113 
114 struct rx_bd {
115 	__le32 rx_bd_len_flags_type;
116 	#define RX_BD_TYPE					(0x3f << 0)
117 	 #define RX_BD_TYPE_RX_PACKET_BD			 0x4
118 	 #define RX_BD_TYPE_RX_BUFFER_BD			 0x5
119 	 #define RX_BD_TYPE_RX_AGG_BD				 0x6
120 	 #define RX_BD_TYPE_16B_BD_SIZE				 (0 << 4)
121 	 #define RX_BD_TYPE_32B_BD_SIZE				 (1 << 4)
122 	 #define RX_BD_TYPE_48B_BD_SIZE				 (2 << 4)
123 	 #define RX_BD_TYPE_64B_BD_SIZE				 (3 << 4)
124 	#define RX_BD_FLAGS_SOP					(1 << 6)
125 	#define RX_BD_FLAGS_EOP					(1 << 7)
126 	#define RX_BD_FLAGS_BUFFERS				(3 << 8)
127 	 #define RX_BD_FLAGS_1_BUFFER_PACKET			 (0 << 8)
128 	 #define RX_BD_FLAGS_2_BUFFER_PACKET			 (1 << 8)
129 	 #define RX_BD_FLAGS_3_BUFFER_PACKET			 (2 << 8)
130 	 #define RX_BD_FLAGS_4_BUFFER_PACKET			 (3 << 8)
131 	#define RX_BD_LEN					(0xffff << 16)
132 	 #define RX_BD_LEN_SHIFT				 16
133 
134 	u32 rx_bd_opaque;
135 	__le64 rx_bd_haddr;
136 };
137 
138 struct tx_cmp {
139 	__le32 tx_cmp_flags_type;
140 	#define CMP_TYPE					(0x3f << 0)
141 	 #define CMP_TYPE_TX_L2_CMP				 0
142 	 #define CMP_TYPE_TX_L2_COAL_CMP			 2
143 	 #define CMP_TYPE_TX_L2_PKT_TS_CMP			 4
144 	 #define CMP_TYPE_RX_L2_CMP				 17
145 	 #define CMP_TYPE_RX_AGG_CMP				 18
146 	 #define CMP_TYPE_RX_L2_TPA_START_CMP			 19
147 	 #define CMP_TYPE_RX_L2_TPA_END_CMP			 21
148 	 #define CMP_TYPE_RX_TPA_AGG_CMP			 22
149 	 #define CMP_TYPE_RX_L2_V3_CMP				 23
150 	 #define CMP_TYPE_RX_L2_TPA_START_V3_CMP		 25
151 	 #define CMP_TYPE_STATUS_CMP				 32
152 	 #define CMP_TYPE_REMOTE_DRIVER_REQ			 34
153 	 #define CMP_TYPE_REMOTE_DRIVER_RESP			 36
154 	 #define CMP_TYPE_ERROR_STATUS				 48
155 	 #define CMPL_BASE_TYPE_STAT_EJECT			 0x1aUL
156 	 #define CMPL_BASE_TYPE_HWRM_DONE			 0x20UL
157 	 #define CMPL_BASE_TYPE_HWRM_FWD_REQ			 0x22UL
158 	 #define CMPL_BASE_TYPE_HWRM_FWD_RESP			 0x24UL
159 	 #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT		 0x2eUL
160 
161 	#define TX_CMP_FLAGS_ERROR				(1 << 6)
162 	#define TX_CMP_FLAGS_PUSH				(1 << 7)
163 
164 	u32 tx_cmp_opaque;
165 	__le32 tx_cmp_errors_v;
166 	#define TX_CMP_V					(1 << 0)
167 	#define TX_CMP_ERRORS_BUFFER_ERROR			(7 << 1)
168 	 #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR		 0
169 	 #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT		 2
170 	 #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG	 4
171 	 #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS		 5
172 	 #define TX_CMP_ERRORS_ZERO_LENGTH_PKT			 (1 << 4)
173 	 #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN			 (1 << 5)
174 	 #define TX_CMP_ERRORS_DMA_ERROR			 (1 << 6)
175 	 #define TX_CMP_ERRORS_HINT_TOO_SHORT			 (1 << 7)
176 
177 	__le32 sq_cons_idx;
178 	#define TX_CMP_SQ_CONS_IDX_MASK				0x00ffffff
179 };
180 
181 #define TX_CMP_SQ_CONS_IDX(txcmp)					\
182 	(le32_to_cpu((txcmp)->sq_cons_idx) & TX_CMP_SQ_CONS_IDX_MASK)
183 
184 struct tx_ts_cmp {
185 	__le32 tx_ts_cmp_flags_type;
186 	#define TX_TS_CMP_FLAGS_ERROR				(1 << 6)
187 	#define TX_TS_CMP_FLAGS_TS_TYPE				(1 << 7)
188 	 #define TX_TS_CMP_FLAGS_TS_TYPE_PM			 (0 << 7)
189 	 #define TX_TS_CMP_FLAGS_TS_TYPE_PA			 (1 << 7)
190 	#define TX_TS_CMP_FLAGS_TS_FALLBACK			(1 << 8)
191 	#define TX_TS_CMP_TS_SUB_NS				(0xf << 12)
192 	#define TX_TS_CMP_TS_NS_MID				(0xffff << 16)
193 	#define TX_TS_CMP_TS_NS_MID_SFT				16
194 	u32 tx_ts_cmp_opaque;
195 	__le32 tx_ts_cmp_errors_v;
196 	#define TX_TS_CMP_V					(1 << 0)
197 	#define TX_TS_CMP_TS_INVALID_ERR			(1 << 10)
198 	__le32 tx_ts_cmp_ts_ns_lo;
199 };
200 
201 #define BNXT_GET_TX_TS_48B_NS(tscmp)					\
202 	(le32_to_cpu((tscmp)->tx_ts_cmp_ts_ns_lo) |			\
203 	 ((u64)(le32_to_cpu((tscmp)->tx_ts_cmp_flags_type) &		\
204 	  TX_TS_CMP_TS_NS_MID) << TX_TS_CMP_TS_NS_MID_SFT))
205 
206 #define BNXT_TX_TS_ERR(tscmp)						\
207 	(((tscmp)->tx_ts_cmp_flags_type & cpu_to_le32(TX_TS_CMP_FLAGS_ERROR)) &&\
208 	 ((tscmp)->tx_ts_cmp_errors_v & cpu_to_le32(TX_TS_CMP_TS_INVALID_ERR)))
209 
210 struct rx_cmp {
211 	__le32 rx_cmp_len_flags_type;
212 	#define RX_CMP_CMP_TYPE					(0x3f << 0)
213 	#define RX_CMP_FLAGS_ERROR				(1 << 6)
214 	#define RX_CMP_FLAGS_PLACEMENT				(7 << 7)
215 	#define RX_CMP_FLAGS_RSS_VALID				(1 << 10)
216 	#define RX_CMP_FLAGS_PKT_METADATA_PRESENT		(1 << 11)
217 	 #define RX_CMP_FLAGS_ITYPES_SHIFT			 12
218 	 #define RX_CMP_FLAGS_ITYPES_MASK			 0xf000
219 	 #define RX_CMP_FLAGS_ITYPE_UNKNOWN			 (0 << 12)
220 	 #define RX_CMP_FLAGS_ITYPE_IP				 (1 << 12)
221 	 #define RX_CMP_FLAGS_ITYPE_TCP				 (2 << 12)
222 	 #define RX_CMP_FLAGS_ITYPE_UDP				 (3 << 12)
223 	 #define RX_CMP_FLAGS_ITYPE_FCOE			 (4 << 12)
224 	 #define RX_CMP_FLAGS_ITYPE_ROCE			 (5 << 12)
225 	 #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS			 (8 << 12)
226 	 #define RX_CMP_FLAGS_ITYPE_PTP_W_TS			 (9 << 12)
227 	#define RX_CMP_LEN					(0xffff << 16)
228 	 #define RX_CMP_LEN_SHIFT				 16
229 
230 	u32 rx_cmp_opaque;
231 	__le32 rx_cmp_misc_v1;
232 	#define RX_CMP_V1					(1 << 0)
233 	#define RX_CMP_AGG_BUFS					(0x1f << 1)
234 	 #define RX_CMP_AGG_BUFS_SHIFT				 1
235 	#define RX_CMP_RSS_HASH_TYPE				(0x7f << 9)
236 	 #define RX_CMP_RSS_HASH_TYPE_SHIFT			 9
237 	#define RX_CMP_V3_RSS_EXT_OP_LEGACY			(0xf << 12)
238 	 #define RX_CMP_V3_RSS_EXT_OP_LEGACY_SHIFT		 12
239 	#define RX_CMP_V3_RSS_EXT_OP_NEW			(0xf << 8)
240 	 #define RX_CMP_V3_RSS_EXT_OP_NEW_SHIFT			 8
241 	#define RX_CMP_PAYLOAD_OFFSET				(0xff << 16)
242 	 #define RX_CMP_PAYLOAD_OFFSET_SHIFT			 16
243 	#define RX_CMP_SUB_NS_TS				(0xf << 16)
244 	 #define RX_CMP_SUB_NS_TS_SHIFT				 16
245 	#define RX_CMP_METADATA1				(0xf << 28)
246 	 #define RX_CMP_METADATA1_SHIFT				 28
247 	#define RX_CMP_METADATA1_TPID_SEL			(0x7 << 28)
248 	#define RX_CMP_METADATA1_TPID_8021Q			(0x1 << 28)
249 	#define RX_CMP_METADATA1_TPID_8021AD			(0x0 << 28)
250 	#define RX_CMP_METADATA1_VALID				(0x8 << 28)
251 
252 	__le32 rx_cmp_rss_hash;
253 };
254 
255 #define BNXT_PTP_RX_TS_VALID(flags)				\
256 	(((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS)
257 
258 #define BNXT_ALL_RX_TS_VALID(flags)				\
259 	!((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT)
260 
261 #define RX_CMP_HASH_VALID(rxcmp)				\
262 	((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
263 
264 #define RSS_PROFILE_ID_MASK	0x1f
265 
266 #define RX_CMP_HASH_TYPE(rxcmp)					\
267 	(((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
268 	  RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
269 
270 #define RX_CMP_V3_HASH_TYPE_LEGACY(rxcmp)				\
271 	((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_V3_RSS_EXT_OP_LEGACY) >>\
272 	 RX_CMP_V3_RSS_EXT_OP_LEGACY_SHIFT)
273 
274 #define RX_CMP_V3_HASH_TYPE_NEW(rxcmp)				\
275 	((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_V3_RSS_EXT_OP_NEW) >>\
276 	 RX_CMP_V3_RSS_EXT_OP_NEW_SHIFT)
277 
278 #define RX_CMP_V3_HASH_TYPE(bp, rxcmp)				\
279 	(((bp)->rss_cap & BNXT_RSS_CAP_RSS_TCAM) ?		\
280 	  RX_CMP_V3_HASH_TYPE_NEW(rxcmp) :			\
281 	  RX_CMP_V3_HASH_TYPE_LEGACY(rxcmp))
282 
283 #define EXT_OP_INNER_4		0x0
284 #define EXT_OP_OUTER_4		0x2
285 #define EXT_OP_INNFL_3		0x8
286 #define EXT_OP_OUTFL_3		0xa
287 
288 #define RX_CMP_VLAN_VALID(rxcmp)				\
289 	((rxcmp)->rx_cmp_misc_v1 & cpu_to_le32(RX_CMP_METADATA1_VALID))
290 
291 #define RX_CMP_VLAN_TPID_SEL(rxcmp)				\
292 	(le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_METADATA1_TPID_SEL)
293 
294 struct rx_cmp_ext {
295 	__le32 rx_cmp_flags2;
296 	#define RX_CMP_FLAGS2_IP_CS_CALC			0x1
297 	#define RX_CMP_FLAGS2_L4_CS_CALC			(0x1 << 1)
298 	#define RX_CMP_FLAGS2_T_IP_CS_CALC			(0x1 << 2)
299 	#define RX_CMP_FLAGS2_T_L4_CS_CALC			(0x1 << 3)
300 	#define RX_CMP_FLAGS2_META_FORMAT_VLAN			(0x1 << 4)
301 	__le32 rx_cmp_meta_data;
302 	#define RX_CMP_FLAGS2_METADATA_TCI_MASK			0xffff
303 	#define RX_CMP_FLAGS2_METADATA_VID_MASK			0xfff
304 	#define RX_CMP_FLAGS2_METADATA_TPID_MASK		0xffff0000
305 	 #define RX_CMP_FLAGS2_METADATA_TPID_SFT		 16
306 	__le32 rx_cmp_cfa_code_errors_v2;
307 	#define RX_CMP_V					(1 << 0)
308 	#define RX_CMPL_ERRORS_MASK				(0x7fff << 1)
309 	 #define RX_CMPL_ERRORS_SFT				 1
310 	#define RX_CMPL_ERRORS_BUFFER_ERROR_MASK		(0x7 << 1)
311 	 #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER		 (0x0 << 1)
312 	 #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT	 (0x1 << 1)
313 	 #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP	 (0x2 << 1)
314 	 #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT		 (0x3 << 1)
315 	#define RX_CMPL_ERRORS_IP_CS_ERROR			(0x1 << 4)
316 	#define RX_CMPL_ERRORS_L4_CS_ERROR			(0x1 << 5)
317 	#define RX_CMPL_ERRORS_T_IP_CS_ERROR			(0x1 << 6)
318 	#define RX_CMPL_ERRORS_T_L4_CS_ERROR			(0x1 << 7)
319 	#define RX_CMPL_ERRORS_CRC_ERROR			(0x1 << 8)
320 	#define RX_CMPL_ERRORS_T_PKT_ERROR_MASK			(0x7 << 9)
321 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR		 (0x0 << 9)
322 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	 (0x1 << 9)
323 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	 (0x2 << 9)
324 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR	 (0x3 << 9)
325 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	 (0x4 << 9)
326 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	 (0x5 << 9)
327 	 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL	 (0x6 << 9)
328 	#define RX_CMPL_ERRORS_PKT_ERROR_MASK			(0xf << 12)
329 	 #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR		 (0x0 << 12)
330 	 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION	 (0x1 << 12)
331 	 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN	 (0x2 << 12)
332 	 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL		 (0x3 << 12)
333 	 #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR	 (0x4 << 12)
334 	 #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	 (0x5 << 12)
335 	 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN	 (0x6 << 12)
336 	 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12)
337 	 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN	 (0x8 << 12)
338 
339 	#define RX_CMPL_CFA_CODE_MASK				(0xffff << 16)
340 	 #define RX_CMPL_CFA_CODE_SFT				 16
341 	#define RX_CMPL_METADATA0_TCI_MASK			(0xffff << 16)
342 	#define RX_CMPL_METADATA0_VID_MASK			(0x0fff << 16)
343 	 #define RX_CMPL_METADATA0_SFT				 16
344 
345 	__le32 rx_cmp_timestamp;
346 };
347 
348 #define RX_CMP_L2_ERRORS						\
349 	cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR)
350 
351 #define RX_CMP_L4_CS_BITS						\
352 	(cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC))
353 
354 #define RX_CMP_L4_CS_ERR_BITS						\
355 	(cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR))
356 
357 #define RX_CMP_L4_CS_OK(rxcmp1)						\
358 	    (((rxcmp1)->rx_cmp_flags2 &	RX_CMP_L4_CS_BITS) &&		\
359 	     !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS))
360 
361 #define RX_CMP_ENCAP(rxcmp1)						\
362 	    ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) &			\
363 	     RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3)
364 
365 #define RX_CMP_CFA_CODE(rxcmpl1)					\
366 	((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) &		\
367 	  RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT)
368 
369 #define RX_CMP_METADATA0_TCI(rxcmp1)					\
370 	((le32_to_cpu((rxcmp1)->rx_cmp_cfa_code_errors_v2) &		\
371 	  RX_CMPL_METADATA0_TCI_MASK) >> RX_CMPL_METADATA0_SFT)
372 
373 struct rx_agg_cmp {
374 	__le32 rx_agg_cmp_len_flags_type;
375 	#define RX_AGG_CMP_TYPE					(0x3f << 0)
376 	#define RX_AGG_CMP_LEN					(0xffff << 16)
377 	 #define RX_AGG_CMP_LEN_SHIFT				 16
378 	u32 rx_agg_cmp_opaque;
379 	__le32 rx_agg_cmp_v;
380 	#define RX_AGG_CMP_V					(1 << 0)
381 	#define RX_AGG_CMP_AGG_ID				(0xffff << 16)
382 	 #define RX_AGG_CMP_AGG_ID_SHIFT			 16
383 	__le32 rx_agg_cmp_unused;
384 };
385 
386 #define TPA_AGG_AGG_ID(rx_agg)				\
387 	((le32_to_cpu((rx_agg)->rx_agg_cmp_v) &		\
388 	 RX_AGG_CMP_AGG_ID) >> RX_AGG_CMP_AGG_ID_SHIFT)
389 
390 struct rx_tpa_start_cmp {
391 	__le32 rx_tpa_start_cmp_len_flags_type;
392 	#define RX_TPA_START_CMP_TYPE				(0x3f << 0)
393 	#define RX_TPA_START_CMP_FLAGS				(0x3ff << 6)
394 	 #define RX_TPA_START_CMP_FLAGS_SHIFT			 6
395 	#define RX_TPA_START_CMP_FLAGS_ERROR			(0x1 << 6)
396 	#define RX_TPA_START_CMP_FLAGS_PLACEMENT		(0x7 << 7)
397 	 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT		 7
398 	 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO		 (0x1 << 7)
399 	 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS		 (0x2 << 7)
400 	 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO	 (0x5 << 7)
401 	 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS	 (0x6 << 7)
402 	#define RX_TPA_START_CMP_FLAGS_RSS_VALID		(0x1 << 10)
403 	#define RX_TPA_START_CMP_FLAGS_TIMESTAMP		(0x1 << 11)
404 	#define RX_TPA_START_CMP_FLAGS_ITYPES			(0xf << 12)
405 	 #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT		 12
406 	 #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP		 (0x2 << 12)
407 	#define RX_TPA_START_CMP_LEN				(0xffff << 16)
408 	 #define RX_TPA_START_CMP_LEN_SHIFT			 16
409 
410 	u32 rx_tpa_start_cmp_opaque;
411 	__le32 rx_tpa_start_cmp_misc_v1;
412 	#define RX_TPA_START_CMP_V1				(0x1 << 0)
413 	#define RX_TPA_START_CMP_RSS_HASH_TYPE			(0x7f << 9)
414 	 #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT		 9
415 	#define RX_TPA_START_CMP_V3_RSS_HASH_TYPE		(0x1ff << 7)
416 	 #define RX_TPA_START_CMP_V3_RSS_HASH_TYPE_SHIFT	 7
417 	#define RX_TPA_START_CMP_AGG_ID				(0x7f << 25)
418 	 #define RX_TPA_START_CMP_AGG_ID_SHIFT			 25
419 	#define RX_TPA_START_CMP_AGG_ID_P5			(0xffff << 16)
420 	 #define RX_TPA_START_CMP_AGG_ID_SHIFT_P5		 16
421 	#define RX_TPA_START_CMP_METADATA1			(0xf << 28)
422 	 #define RX_TPA_START_CMP_METADATA1_SHIFT		 28
423 	#define RX_TPA_START_METADATA1_TPID_SEL			(0x7 << 28)
424 	#define RX_TPA_START_METADATA1_TPID_8021Q		(0x1 << 28)
425 	#define RX_TPA_START_METADATA1_TPID_8021AD		(0x0 << 28)
426 	#define RX_TPA_START_METADATA1_VALID			(0x8 << 28)
427 
428 	__le32 rx_tpa_start_cmp_rss_hash;
429 };
430 
431 #define TPA_START_HASH_VALID(rx_tpa_start)				\
432 	((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type &		\
433 	 cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
434 
435 #define TPA_START_HASH_TYPE(rx_tpa_start)				\
436 	(((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) &	\
437 	   RX_TPA_START_CMP_RSS_HASH_TYPE) >>				\
438 	  RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
439 
440 #define TPA_START_V3_HASH_TYPE(rx_tpa_start)				\
441 	(((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) &	\
442 	   RX_TPA_START_CMP_V3_RSS_HASH_TYPE) >>			\
443 	  RX_TPA_START_CMP_V3_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
444 
445 #define TPA_START_AGG_ID(rx_tpa_start)					\
446 	((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) &	\
447 	 RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT)
448 
449 #define TPA_START_AGG_ID_P5(rx_tpa_start)				\
450 	((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) &	\
451 	 RX_TPA_START_CMP_AGG_ID_P5) >> RX_TPA_START_CMP_AGG_ID_SHIFT_P5)
452 
453 #define TPA_START_ERROR(rx_tpa_start)					\
454 	((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type &		\
455 	 cpu_to_le32(RX_TPA_START_CMP_FLAGS_ERROR))
456 
457 #define TPA_START_VLAN_VALID(rx_tpa_start)				\
458 	((rx_tpa_start)->rx_tpa_start_cmp_misc_v1 &			\
459 	 cpu_to_le32(RX_TPA_START_METADATA1_VALID))
460 
461 #define TPA_START_VLAN_TPID_SEL(rx_tpa_start)				\
462 	(le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) &	\
463 	 RX_TPA_START_METADATA1_TPID_SEL)
464 
465 struct rx_tpa_start_cmp_ext {
466 	__le32 rx_tpa_start_cmp_flags2;
467 	#define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC		(0x1 << 0)
468 	#define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC		(0x1 << 1)
469 	#define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC		(0x1 << 2)
470 	#define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC		(0x1 << 3)
471 	#define RX_TPA_START_CMP_FLAGS2_IP_TYPE			(0x1 << 8)
472 	#define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_VALID		(0x1 << 9)
473 	#define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT		(0x3 << 10)
474 	 #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT_SHIFT	 10
475 	#define RX_TPA_START_CMP_V3_FLAGS2_T_IP_TYPE		(0x1 << 10)
476 	#define RX_TPA_START_CMP_V3_FLAGS2_AGG_GRO		(0x1 << 11)
477 	#define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL		(0xffff << 16)
478 	 #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_SHIFT	 16
479 
480 	__le32 rx_tpa_start_cmp_metadata;
481 	__le32 rx_tpa_start_cmp_cfa_code_v2;
482 	#define RX_TPA_START_CMP_V2				(0x1 << 0)
483 	#define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK	(0x7 << 1)
484 	 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT	 1
485 	 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER	 (0x0 << 1)
486 	 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
487 	 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_FLUSH	 (0x5 << 1)
488 	#define RX_TPA_START_CMP_CFA_CODE			(0xffff << 16)
489 	 #define RX_TPA_START_CMPL_CFA_CODE_SHIFT		 16
490 	#define RX_TPA_START_CMP_METADATA0_TCI_MASK		(0xffff << 16)
491 	#define RX_TPA_START_CMP_METADATA0_VID_MASK		(0x0fff << 16)
492 	 #define RX_TPA_START_CMP_METADATA0_SFT			 16
493 	__le32 rx_tpa_start_cmp_hdr_info;
494 };
495 
496 #define TPA_START_CFA_CODE(rx_tpa_start)				\
497 	((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) &	\
498 	 RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT)
499 
500 #define TPA_START_IS_IPV6(rx_tpa_start)				\
501 	(!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 &		\
502 	    cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE)))
503 
504 #define TPA_START_ERROR_CODE(rx_tpa_start)				\
505 	((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) &	\
506 	  RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK) >>			\
507 	 RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT)
508 
509 #define TPA_START_METADATA0_TCI(rx_tpa_start)				\
510 	((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) &	\
511 	  RX_TPA_START_CMP_METADATA0_TCI_MASK) >>			\
512 	 RX_TPA_START_CMP_METADATA0_SFT)
513 
514 struct rx_tpa_end_cmp {
515 	__le32 rx_tpa_end_cmp_len_flags_type;
516 	#define RX_TPA_END_CMP_TYPE				(0x3f << 0)
517 	#define RX_TPA_END_CMP_FLAGS				(0x3ff << 6)
518 	 #define RX_TPA_END_CMP_FLAGS_SHIFT			 6
519 	#define RX_TPA_END_CMP_FLAGS_PLACEMENT			(0x7 << 7)
520 	 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT		 7
521 	 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO		 (0x1 << 7)
522 	 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS		 (0x2 << 7)
523 	 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO	 (0x5 << 7)
524 	 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS		 (0x6 << 7)
525 	#define RX_TPA_END_CMP_FLAGS_RSS_VALID			(0x1 << 10)
526 	#define RX_TPA_END_CMP_FLAGS_ITYPES			(0xf << 12)
527 	 #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT		 12
528 	 #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP			 (0x2 << 12)
529 	#define RX_TPA_END_CMP_LEN				(0xffff << 16)
530 	 #define RX_TPA_END_CMP_LEN_SHIFT			 16
531 
532 	u32 rx_tpa_end_cmp_opaque;
533 	__le32 rx_tpa_end_cmp_misc_v1;
534 	#define RX_TPA_END_CMP_V1				(0x1 << 0)
535 	#define RX_TPA_END_CMP_AGG_BUFS				(0x3f << 1)
536 	 #define RX_TPA_END_CMP_AGG_BUFS_SHIFT			 1
537 	#define RX_TPA_END_CMP_TPA_SEGS				(0xff << 8)
538 	 #define RX_TPA_END_CMP_TPA_SEGS_SHIFT			 8
539 	#define RX_TPA_END_CMP_PAYLOAD_OFFSET			(0xff << 16)
540 	 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT		 16
541 	#define RX_TPA_END_CMP_AGG_ID				(0x7f << 25)
542 	 #define RX_TPA_END_CMP_AGG_ID_SHIFT			 25
543 	#define RX_TPA_END_CMP_AGG_ID_P5			(0xffff << 16)
544 	 #define RX_TPA_END_CMP_AGG_ID_SHIFT_P5			 16
545 
546 	__le32 rx_tpa_end_cmp_tsdelta;
547 	#define RX_TPA_END_GRO_TS				(0x1 << 31)
548 };
549 
550 #define TPA_END_AGG_ID(rx_tpa_end)					\
551 	((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) &		\
552 	 RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT)
553 
554 #define TPA_END_AGG_ID_P5(rx_tpa_end)					\
555 	((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) &		\
556 	 RX_TPA_END_CMP_AGG_ID_P5) >> RX_TPA_END_CMP_AGG_ID_SHIFT_P5)
557 
558 #define TPA_END_PAYLOAD_OFF(rx_tpa_end)					\
559 	((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) &		\
560 	 RX_TPA_END_CMP_PAYLOAD_OFFSET) >> RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT)
561 
562 #define TPA_END_AGG_BUFS(rx_tpa_end)					\
563 	((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) &		\
564 	 RX_TPA_END_CMP_AGG_BUFS) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT)
565 
566 #define TPA_END_TPA_SEGS(rx_tpa_end)					\
567 	((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) &		\
568 	 RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
569 
570 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO				\
571 	cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO &		\
572 		    RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS)
573 
574 #define TPA_END_GRO(rx_tpa_end)						\
575 	((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type &			\
576 	 RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO)
577 
578 #define TPA_END_GRO_TS(rx_tpa_end)					\
579 	(!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta &			\
580 	    cpu_to_le32(RX_TPA_END_GRO_TS)))
581 
582 struct rx_tpa_end_cmp_ext {
583 	__le32 rx_tpa_end_cmp_dup_acks;
584 	#define RX_TPA_END_CMP_TPA_DUP_ACKS			(0xf << 0)
585 	#define RX_TPA_END_CMP_PAYLOAD_OFFSET_P5		(0xff << 16)
586 	 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5		 16
587 	#define RX_TPA_END_CMP_AGG_BUFS_P5			(0xff << 24)
588 	 #define RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5		 24
589 
590 	__le32 rx_tpa_end_cmp_seg_len;
591 	#define RX_TPA_END_CMP_TPA_SEG_LEN			(0xffff << 0)
592 
593 	__le32 rx_tpa_end_cmp_errors_v2;
594 	#define RX_TPA_END_CMP_V2				(0x1 << 0)
595 	#define RX_TPA_END_CMP_ERRORS				(0x3 << 1)
596 	#define RX_TPA_END_CMP_ERRORS_P5			(0x7 << 1)
597 	#define RX_TPA_END_CMPL_ERRORS_SHIFT			 1
598 	 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER	 (0x0 << 1)
599 	 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NOT_ON_CHIP	 (0x2 << 1)
600 	 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT	 (0x3 << 1)
601 	 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_RSV_ERROR	 (0x4 << 1)
602 	 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_FLUSH	 (0x5 << 1)
603 
604 	u32 rx_tpa_end_cmp_start_opaque;
605 };
606 
607 #define TPA_END_ERRORS(rx_tpa_end_ext)					\
608 	((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 &			\
609 	 cpu_to_le32(RX_TPA_END_CMP_ERRORS))
610 
611 #define TPA_END_PAYLOAD_OFF_P5(rx_tpa_end_ext)				\
612 	((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) &	\
613 	 RX_TPA_END_CMP_PAYLOAD_OFFSET_P5) >>				\
614 	RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5)
615 
616 #define TPA_END_AGG_BUFS_P5(rx_tpa_end_ext)				\
617 	((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) &	\
618 	 RX_TPA_END_CMP_AGG_BUFS_P5) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5)
619 
620 #define EVENT_DATA1_RESET_NOTIFY_FATAL(data1)				\
621 	(((data1) &							\
622 	  ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\
623 	 ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL)
624 
625 #define EVENT_DATA1_RESET_NOTIFY_FW_ACTIVATION(data1)			\
626 	(((data1) &							\
627 	  ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\
628 	ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION)
629 
630 #define EVENT_DATA2_RESET_NOTIFY_FW_STATUS_CODE(data2)			\
631 	((data2) &							\
632 	ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK)
633 
634 #define EVENT_DATA1_RECOVERY_MASTER_FUNC(data1)				\
635 	!!((data1) &							\
636 	   ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC)
637 
638 #define EVENT_DATA1_RECOVERY_ENABLED(data1)				\
639 	!!((data1) &							\
640 	   ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED)
641 
642 #define BNXT_EVENT_ERROR_REPORT_TYPE(data1)				\
643 	(((data1) &							\
644 	  ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK) >>\
645 	 ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT)
646 
647 #define BNXT_EVENT_INVALID_SIGNAL_DATA(data2)				\
648 	(((data2) &							\
649 	  ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK) >>\
650 	 ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT)
651 
652 struct nqe_cn {
653 	__le16	type;
654 	#define NQ_CN_TYPE_MASK           0x3fUL
655 	#define NQ_CN_TYPE_SFT            0
656 	#define NQ_CN_TYPE_CQ_NOTIFICATION  0x30UL
657 	#define NQ_CN_TYPE_LAST            NQ_CN_TYPE_CQ_NOTIFICATION
658 	#define NQ_CN_TOGGLE_MASK         0xc0UL
659 	#define NQ_CN_TOGGLE_SFT          6
660 	__le16	reserved16;
661 	__le32	cq_handle_low;
662 	__le32	v;
663 	#define NQ_CN_V     0x1UL
664 	__le32	cq_handle_high;
665 };
666 
667 #define BNXT_NQ_HDL_IDX_MASK	0x00ffffff
668 #define BNXT_NQ_HDL_TYPE_MASK	0xff000000
669 #define BNXT_NQ_HDL_TYPE_SHIFT	24
670 #define BNXT_NQ_HDL_TYPE_RX	0x00
671 #define BNXT_NQ_HDL_TYPE_TX	0x01
672 
673 #define BNXT_NQ_HDL_IDX(hdl)	((hdl) & BNXT_NQ_HDL_IDX_MASK)
674 #define BNXT_NQ_HDL_TYPE(hdl)	(((hdl) & BNXT_NQ_HDL_TYPE_MASK) >>	\
675 				 BNXT_NQ_HDL_TYPE_SHIFT)
676 
677 #define BNXT_SET_NQ_HDL(cpr)						\
678 	(((cpr)->cp_ring_type << BNXT_NQ_HDL_TYPE_SHIFT) | (cpr)->cp_idx)
679 
680 #define NQE_CN_TYPE(type)	((type) & NQ_CN_TYPE_MASK)
681 #define NQE_CN_TOGGLE(type)	(((type) & NQ_CN_TOGGLE_MASK) >>	\
682 				 NQ_CN_TOGGLE_SFT)
683 
684 #define DB_IDX_MASK						0xffffff
685 #define DB_IDX_VALID						(0x1 << 26)
686 #define DB_IRQ_DIS						(0x1 << 27)
687 #define DB_KEY_TX						(0x0 << 28)
688 #define DB_KEY_RX						(0x1 << 28)
689 #define DB_KEY_CP						(0x2 << 28)
690 #define DB_KEY_ST						(0x3 << 28)
691 #define DB_KEY_TX_PUSH						(0x4 << 28)
692 #define DB_LONG_TX_PUSH						(0x2 << 24)
693 
694 #define BNXT_MIN_ROCE_CP_RINGS	2
695 #define BNXT_MIN_ROCE_STAT_CTXS	1
696 
697 /* 64-bit doorbell */
698 #define DBR_INDEX_MASK					0x0000000000ffffffULL
699 #define DBR_EPOCH_MASK					0x01000000UL
700 #define DBR_EPOCH_SFT					24
701 #define DBR_TOGGLE_MASK					0x06000000UL
702 #define DBR_TOGGLE_SFT					25
703 #define DBR_XID_MASK					0x000fffff00000000ULL
704 #define DBR_XID_SFT					32
705 #define DBR_PATH_L2					(0x1ULL << 56)
706 #define DBR_VALID					(0x1ULL << 58)
707 #define DBR_TYPE_SQ					(0x0ULL << 60)
708 #define DBR_TYPE_RQ					(0x1ULL << 60)
709 #define DBR_TYPE_SRQ					(0x2ULL << 60)
710 #define DBR_TYPE_SRQ_ARM				(0x3ULL << 60)
711 #define DBR_TYPE_CQ					(0x4ULL << 60)
712 #define DBR_TYPE_CQ_ARMSE				(0x5ULL << 60)
713 #define DBR_TYPE_CQ_ARMALL				(0x6ULL << 60)
714 #define DBR_TYPE_CQ_ARMENA				(0x7ULL << 60)
715 #define DBR_TYPE_SRQ_ARMENA				(0x8ULL << 60)
716 #define DBR_TYPE_CQ_CUTOFF_ACK				(0x9ULL << 60)
717 #define DBR_TYPE_NQ					(0xaULL << 60)
718 #define DBR_TYPE_NQ_ARM					(0xbULL << 60)
719 #define DBR_TYPE_NQ_MASK				(0xeULL << 60)
720 #define DBR_TYPE_NULL					(0xfULL << 60)
721 
722 #define DB_PF_OFFSET_P5					0x10000
723 #define DB_VF_OFFSET_P5					0x4000
724 
725 #define INVALID_HW_RING_ID	((u16)-1)
726 
727 /* The hardware supports certain page sizes.  Use the supported page sizes
728  * to allocate the rings.
729  */
730 #if (PAGE_SHIFT < 12)
731 #define BNXT_PAGE_SHIFT	12
732 #elif (PAGE_SHIFT <= 13)
733 #define BNXT_PAGE_SHIFT	PAGE_SHIFT
734 #elif (PAGE_SHIFT < 16)
735 #define BNXT_PAGE_SHIFT	13
736 #else
737 #define BNXT_PAGE_SHIFT	16
738 #endif
739 
740 #define BNXT_PAGE_SIZE	(1 << BNXT_PAGE_SHIFT)
741 
742 /* The RXBD length is 16-bit so we can only support page sizes < 64K */
743 #if (PAGE_SHIFT > 15)
744 #define BNXT_RX_PAGE_SHIFT 15
745 #else
746 #define BNXT_RX_PAGE_SHIFT PAGE_SHIFT
747 #endif
748 
749 #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
750 
751 #define BNXT_MAX_MTU		9500
752 
753 /* First RX buffer page in XDP multi-buf mode
754  *
755  * +-------------------------------------------------------------------------+
756  * | XDP_PACKET_HEADROOM | bp->rx_buf_use_size              | skb_shared_info|
757  * | (bp->rx_dma_offset) |                                  |                |
758  * +-------------------------------------------------------------------------+
759  */
760 #define BNXT_MAX_PAGE_MODE_MTU_SBUF \
761 	((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN -	\
762 	 XDP_PACKET_HEADROOM)
763 #define BNXT_MAX_PAGE_MODE_MTU	\
764 	(BNXT_MAX_PAGE_MODE_MTU_SBUF - \
765 	 SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)))
766 
767 #define BNXT_MIN_PKT_SIZE	52
768 
769 #define BNXT_DEFAULT_RX_RING_SIZE	511
770 #define BNXT_DEFAULT_TX_RING_SIZE	511
771 
772 #define MAX_TPA		64
773 #define MAX_TPA_P5	256
774 #define MAX_TPA_P5_MASK	(MAX_TPA_P5 - 1)
775 #define MAX_TPA_SEGS_P5	0x3f
776 
777 #if (BNXT_PAGE_SHIFT == 16)
778 #define MAX_RX_PAGES_AGG_ENA	1
779 #define MAX_RX_PAGES	4
780 #define MAX_RX_AGG_PAGES	4
781 #define MAX_TX_PAGES	1
782 #define MAX_CP_PAGES	16
783 #else
784 #define MAX_RX_PAGES_AGG_ENA	8
785 #define MAX_RX_PAGES	32
786 #define MAX_RX_AGG_PAGES	32
787 #define MAX_TX_PAGES	8
788 #define MAX_CP_PAGES	128
789 #endif
790 
791 #define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd))
792 #define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd))
793 #define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp))
794 
795 #define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT)
796 #define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
797 
798 #define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT)
799 
800 #define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT)
801 #define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
802 
803 #define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT)
804 
805 #define BNXT_MAX_RX_DESC_CNT		(RX_DESC_CNT * MAX_RX_PAGES - 1)
806 #define BNXT_MAX_RX_DESC_CNT_JUM_ENA	(RX_DESC_CNT * MAX_RX_PAGES_AGG_ENA - 1)
807 #define BNXT_MAX_RX_JUM_DESC_CNT	(RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
808 #define BNXT_MAX_TX_DESC_CNT		(TX_DESC_CNT * MAX_TX_PAGES - 1)
809 
810 /* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1.  We need one extra
811  * BD because the first TX BD is always a long BD.
812  */
813 #define BNXT_MIN_TX_DESC_CNT		(MAX_SKB_FRAGS + 2)
814 
815 #define RX_RING(bp, x)	(((x) & (bp)->rx_ring_mask) >> (BNXT_PAGE_SHIFT - 4))
816 #define RX_AGG_RING(bp, x)	(((x) & (bp)->rx_agg_ring_mask) >>	\
817 				 (BNXT_PAGE_SHIFT - 4))
818 #define RX_IDX(x)	((x) & (RX_DESC_CNT - 1))
819 
820 #define TX_RING(bp, x)	(((x) & (bp)->tx_ring_mask) >> (BNXT_PAGE_SHIFT - 4))
821 #define TX_IDX(x)	((x) & (TX_DESC_CNT - 1))
822 
823 #define CP_RING(x)	(((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
824 #define CP_IDX(x)	((x) & (CP_DESC_CNT - 1))
825 
826 #define TX_CMP_VALID(txcmp, raw_cons)					\
827 	(!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) ==	\
828 	 !((raw_cons) & bp->cp_bit))
829 
830 #define RX_CMP_VALID(rxcmp1, raw_cons)					\
831 	(!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
832 	 !((raw_cons) & bp->cp_bit))
833 
834 #define RX_AGG_CMP_VALID(agg, raw_cons)				\
835 	(!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) ==	\
836 	 !((raw_cons) & bp->cp_bit))
837 
838 #define NQ_CMP_VALID(nqcmp, raw_cons)				\
839 	(!!((nqcmp)->v & cpu_to_le32(NQ_CN_V)) == !((raw_cons) & bp->cp_bit))
840 
841 #define TX_CMP_TYPE(txcmp)					\
842 	(le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
843 
844 #define RX_CMP_TYPE(rxcmp)					\
845 	(le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE)
846 
847 #define RING_RX(bp, idx)	((idx) & (bp)->rx_ring_mask)
848 #define NEXT_RX(idx)		((idx) + 1)
849 
850 #define RING_RX_AGG(bp, idx)	((idx) & (bp)->rx_agg_ring_mask)
851 #define NEXT_RX_AGG(idx)	((idx) + 1)
852 
853 #define RING_TX(bp, idx)	((idx) & (bp)->tx_ring_mask)
854 #define NEXT_TX(idx)		((idx) + 1)
855 
856 #define ADV_RAW_CMP(idx, n)	((idx) + (n))
857 #define NEXT_RAW_CMP(idx)	ADV_RAW_CMP(idx, 1)
858 #define RING_CMP(idx)		((idx) & bp->cp_ring_mask)
859 #define NEXT_CMP(idx)		RING_CMP(ADV_RAW_CMP(idx, 1))
860 
861 #define DFLT_HWRM_CMD_TIMEOUT		500
862 
863 #define BNXT_RX_EVENT		1
864 #define BNXT_AGG_EVENT		2
865 #define BNXT_TX_EVENT		4
866 #define BNXT_REDIRECT_EVENT	8
867 #define BNXT_TX_CMP_EVENT	0x10
868 
869 struct bnxt_sw_tx_bd {
870 	union {
871 		struct sk_buff		*skb;
872 		struct xdp_frame	*xdpf;
873 	};
874 	DEFINE_DMA_UNMAP_ADDR(mapping);
875 	DEFINE_DMA_UNMAP_LEN(len);
876 	struct page		*page;
877 	u8			is_ts_pkt;
878 	u8			is_push;
879 	u8			action;
880 	unsigned short		nr_frags;
881 	union {
882 		u16			rx_prod;
883 		u16			txts_prod;
884 	};
885 };
886 
887 struct bnxt_sw_rx_bd {
888 	void			*data;
889 	u8			*data_ptr;
890 	dma_addr_t		mapping;
891 };
892 
893 struct bnxt_sw_rx_agg_bd {
894 	struct page		*page;
895 	unsigned int		offset;
896 	dma_addr_t		mapping;
897 };
898 
899 struct bnxt_ring_mem_info {
900 	int			nr_pages;
901 	int			page_size;
902 	u16			flags;
903 #define BNXT_RMEM_VALID_PTE_FLAG	1
904 #define BNXT_RMEM_RING_PTE_FLAG		2
905 #define BNXT_RMEM_USE_FULL_PAGE_FLAG	4
906 
907 	u16			depth;
908 	struct bnxt_ctx_mem_type	*ctx_mem;
909 
910 	void			**pg_arr;
911 	dma_addr_t		*dma_arr;
912 
913 	__le64			*pg_tbl;
914 	dma_addr_t		pg_tbl_map;
915 
916 	int			vmem_size;
917 	void			**vmem;
918 };
919 
920 struct bnxt_ring_struct {
921 	struct bnxt_ring_mem_info	ring_mem;
922 
923 	u16			fw_ring_id; /* Ring id filled by Chimp FW */
924 	union {
925 		u16		grp_idx;
926 		u16		map_idx; /* Used by cmpl rings */
927 	};
928 	u32			handle;
929 	u8			queue_id;
930 };
931 
932 struct tx_push_bd {
933 	__le32			doorbell;
934 	__le32			tx_bd_len_flags_type;
935 	u32			tx_bd_opaque;
936 	struct tx_bd_ext	txbd2;
937 };
938 
939 struct tx_push_buffer {
940 	struct tx_push_bd	push_bd;
941 	u32			data[25];
942 };
943 
944 struct bnxt_db_info {
945 	void __iomem		*doorbell;
946 	union {
947 		u64		db_key64;
948 		u32		db_key32;
949 	};
950 	u32			db_ring_mask;
951 	u32			db_epoch_mask;
952 	u8			db_epoch_shift;
953 };
954 
955 #define DB_EPOCH(db, idx)	(((idx) & (db)->db_epoch_mask) <<	\
956 				 ((db)->db_epoch_shift))
957 
958 #define DB_TOGGLE(tgl)		((tgl) << DBR_TOGGLE_SFT)
959 
960 #define DB_RING_IDX(db, idx)	(((idx) & (db)->db_ring_mask) |		\
961 				 DB_EPOCH(db, idx))
962 
963 struct bnxt_tx_ring_info {
964 	struct bnxt_napi	*bnapi;
965 	struct bnxt_cp_ring_info	*tx_cpr;
966 	u16			tx_prod;
967 	u16			tx_cons;
968 	u16			tx_hw_cons;
969 	u16			txq_index;
970 	u8			tx_napi_idx;
971 	u8			kick_pending;
972 	struct bnxt_db_info	tx_db;
973 
974 	struct tx_bd		*tx_desc_ring[MAX_TX_PAGES];
975 	struct bnxt_sw_tx_bd	*tx_buf_ring;
976 
977 	dma_addr_t		tx_desc_mapping[MAX_TX_PAGES];
978 
979 	struct tx_push_buffer	*tx_push;
980 	dma_addr_t		tx_push_mapping;
981 	__le64			data_mapping;
982 
983 #define BNXT_DEV_STATE_CLOSING	0x1
984 	u32			dev_state;
985 
986 	struct bnxt_ring_struct	tx_ring_struct;
987 	/* Synchronize simultaneous xdp_xmit on same ring */
988 	spinlock_t		xdp_tx_lock;
989 };
990 
991 #define BNXT_LEGACY_COAL_CMPL_PARAMS					\
992 	(RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MIN |		\
993 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MAX |		\
994 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_TIMER_RESET |		\
995 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_RING_IDLE |			\
996 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR |		\
997 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT | \
998 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR |		\
999 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT | \
1000 	 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_AGGR_INT)
1001 
1002 #define BNXT_COAL_CMPL_ENABLES						\
1003 	(RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR | \
1004 	 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_CMPL_AGGR_DMA_TMR | \
1005 	 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MAX | \
1006 	 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_AGGR_INT)
1007 
1008 #define BNXT_COAL_CMPL_MIN_TMR_ENABLE					\
1009 	RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MIN
1010 
1011 #define BNXT_COAL_CMPL_AGGR_TMR_DURING_INT_ENABLE			\
1012 	RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT
1013 
1014 struct bnxt_coal_cap {
1015 	u32			cmpl_params;
1016 	u32			nq_params;
1017 	u16			num_cmpl_dma_aggr_max;
1018 	u16			num_cmpl_dma_aggr_during_int_max;
1019 	u16			cmpl_aggr_dma_tmr_max;
1020 	u16			cmpl_aggr_dma_tmr_during_int_max;
1021 	u16			int_lat_tmr_min_max;
1022 	u16			int_lat_tmr_max_max;
1023 	u16			num_cmpl_aggr_int_max;
1024 	u16			timer_units;
1025 };
1026 
1027 struct bnxt_coal {
1028 	u16			coal_ticks;
1029 	u16			coal_ticks_irq;
1030 	u16			coal_bufs;
1031 	u16			coal_bufs_irq;
1032 			/* RING_IDLE enabled when coal ticks < idle_thresh  */
1033 	u16			idle_thresh;
1034 	u8			bufs_per_record;
1035 	u8			budget;
1036 	u16			flags;
1037 };
1038 
1039 struct bnxt_tpa_info {
1040 	void			*data;
1041 	u8			*data_ptr;
1042 	dma_addr_t		mapping;
1043 	u16			len;
1044 	unsigned short		gso_type;
1045 	u32			flags2;
1046 	u32			metadata;
1047 	enum pkt_hash_types	hash_type;
1048 	u32			rss_hash;
1049 	u32			hdr_info;
1050 
1051 #define BNXT_TPA_L4_SIZE(hdr_info)	\
1052 	(((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32)
1053 
1054 #define BNXT_TPA_INNER_L3_OFF(hdr_info)	\
1055 	(((hdr_info) >> 18) & 0x1ff)
1056 
1057 #define BNXT_TPA_INNER_L2_OFF(hdr_info)	\
1058 	(((hdr_info) >> 9) & 0x1ff)
1059 
1060 #define BNXT_TPA_OUTER_L3_OFF(hdr_info)	\
1061 	((hdr_info) & 0x1ff)
1062 
1063 	u16			cfa_code; /* cfa_code in TPA start compl */
1064 	u8			agg_count;
1065 	u8			vlan_valid:1;
1066 	u8			cfa_code_valid:1;
1067 	struct rx_agg_cmp	*agg_arr;
1068 };
1069 
1070 #define BNXT_AGG_IDX_BMAP_SIZE	(MAX_TPA_P5 / BITS_PER_LONG)
1071 
1072 struct bnxt_tpa_idx_map {
1073 	u16		agg_id_tbl[1024];
1074 	unsigned long	agg_idx_bmap[BNXT_AGG_IDX_BMAP_SIZE];
1075 };
1076 
1077 struct bnxt_rx_ring_info {
1078 	struct bnxt_napi	*bnapi;
1079 	struct bnxt_cp_ring_info	*rx_cpr;
1080 	u16			rx_prod;
1081 	u16			rx_agg_prod;
1082 	u16			rx_sw_agg_prod;
1083 	u16			rx_next_cons;
1084 	struct bnxt_db_info	rx_db;
1085 	struct bnxt_db_info	rx_agg_db;
1086 
1087 	struct bpf_prog		*xdp_prog;
1088 
1089 	struct rx_bd		*rx_desc_ring[MAX_RX_PAGES];
1090 	struct bnxt_sw_rx_bd	*rx_buf_ring;
1091 
1092 	struct rx_bd		*rx_agg_desc_ring[MAX_RX_AGG_PAGES];
1093 	struct bnxt_sw_rx_agg_bd	*rx_agg_ring;
1094 
1095 	unsigned long		*rx_agg_bmap;
1096 	u16			rx_agg_bmap_size;
1097 
1098 	dma_addr_t		rx_desc_mapping[MAX_RX_PAGES];
1099 	dma_addr_t		rx_agg_desc_mapping[MAX_RX_AGG_PAGES];
1100 
1101 	struct bnxt_tpa_info	*rx_tpa;
1102 	struct bnxt_tpa_idx_map *rx_tpa_idx_map;
1103 
1104 	struct bnxt_ring_struct	rx_ring_struct;
1105 	struct bnxt_ring_struct	rx_agg_ring_struct;
1106 	struct xdp_rxq_info	xdp_rxq;
1107 	struct page_pool	*page_pool;
1108 	struct page_pool	*head_pool;
1109 };
1110 
1111 struct bnxt_rx_sw_stats {
1112 	u64			rx_l4_csum_errors;
1113 	u64			rx_resets;
1114 	u64			rx_buf_errors;
1115 	u64			rx_oom_discards;
1116 	u64			rx_netpoll_discards;
1117 };
1118 
1119 struct bnxt_tx_sw_stats {
1120 	u64			tx_resets;
1121 };
1122 
1123 struct bnxt_cmn_sw_stats {
1124 	u64			missed_irqs;
1125 };
1126 
1127 struct bnxt_sw_stats {
1128 	struct bnxt_rx_sw_stats rx;
1129 	struct bnxt_tx_sw_stats tx;
1130 	struct bnxt_cmn_sw_stats cmn;
1131 };
1132 
1133 struct bnxt_total_ring_err_stats {
1134 	u64			rx_total_l4_csum_errors;
1135 	u64			rx_total_resets;
1136 	u64			rx_total_buf_errors;
1137 	u64			rx_total_oom_discards;
1138 	u64			rx_total_netpoll_discards;
1139 	u64			rx_total_ring_discards;
1140 	u64			tx_total_resets;
1141 	u64			tx_total_ring_discards;
1142 	u64			total_missed_irqs;
1143 };
1144 
1145 struct bnxt_stats_mem {
1146 	u64		*sw_stats;
1147 	u64		*hw_masks;
1148 	void		*hw_stats;
1149 	dma_addr_t	hw_stats_map;
1150 	int		len;
1151 };
1152 
1153 struct bnxt_cp_ring_info {
1154 	struct bnxt_napi	*bnapi;
1155 	u32			cp_raw_cons;
1156 	struct bnxt_db_info	cp_db;
1157 
1158 	u8			had_work_done:1;
1159 	u8			has_more_work:1;
1160 	u8			had_nqe_notify:1;
1161 	u8			toggle;
1162 
1163 	u8			cp_ring_type;
1164 	u8			cp_idx;
1165 
1166 	u32			last_cp_raw_cons;
1167 
1168 	struct bnxt_coal	rx_ring_coal;
1169 	u64			rx_packets;
1170 	u64			rx_bytes;
1171 	u64			event_ctr;
1172 
1173 	struct dim		dim;
1174 
1175 	union {
1176 		struct tx_cmp	**cp_desc_ring;
1177 		struct nqe_cn	**nq_desc_ring;
1178 	};
1179 
1180 	dma_addr_t		*cp_desc_mapping;
1181 
1182 	struct bnxt_stats_mem	stats;
1183 	u32			hw_stats_ctx_id;
1184 
1185 	struct bnxt_sw_stats	*sw_stats;
1186 
1187 	struct bnxt_ring_struct	cp_ring_struct;
1188 
1189 	int			cp_ring_count;
1190 	struct bnxt_cp_ring_info *cp_ring_arr;
1191 };
1192 
1193 #define BNXT_MAX_QUEUE		8
1194 #define BNXT_MAX_TXR_PER_NAPI	BNXT_MAX_QUEUE
1195 
1196 #define bnxt_for_each_napi_tx(iter, bnapi, txr)		\
1197 	for (iter = 0, txr = (bnapi)->tx_ring[0]; txr;	\
1198 	     txr = (iter < BNXT_MAX_TXR_PER_NAPI - 1) ?	\
1199 	     (bnapi)->tx_ring[++iter] : NULL)
1200 
1201 struct bnxt_napi {
1202 	struct napi_struct	napi;
1203 	struct bnxt		*bp;
1204 
1205 	int			index;
1206 	struct bnxt_cp_ring_info	cp_ring;
1207 	struct bnxt_rx_ring_info	*rx_ring;
1208 	struct bnxt_tx_ring_info	*tx_ring[BNXT_MAX_TXR_PER_NAPI];
1209 
1210 	void			(*tx_int)(struct bnxt *, struct bnxt_napi *,
1211 					  int budget);
1212 	u8			events;
1213 	u8			tx_fault:1;
1214 
1215 	u32			flags;
1216 #define BNXT_NAPI_FLAG_XDP	0x1
1217 
1218 	bool			in_reset;
1219 };
1220 
1221 /* "TxRx", 2 hypens, plus maximum integer */
1222 #define BNXT_IRQ_NAME_EXTRA	17
1223 
1224 struct bnxt_irq {
1225 	irq_handler_t	handler;
1226 	unsigned int	vector;
1227 	u8		requested:1;
1228 	u8		have_cpumask:1;
1229 	char		name[IFNAMSIZ + BNXT_IRQ_NAME_EXTRA];
1230 	cpumask_var_t	cpu_mask;
1231 };
1232 
1233 #define HWRM_RING_ALLOC_TX	0x1
1234 #define HWRM_RING_ALLOC_RX	0x2
1235 #define HWRM_RING_ALLOC_AGG	0x4
1236 #define HWRM_RING_ALLOC_CMPL	0x8
1237 #define HWRM_RING_ALLOC_NQ	0x10
1238 
1239 #define INVALID_STATS_CTX_ID	-1
1240 
1241 struct bnxt_ring_grp_info {
1242 	u16	fw_stats_ctx;
1243 	u16	fw_grp_id;
1244 	u16	rx_fw_ring_id;
1245 	u16	agg_fw_ring_id;
1246 	u16	cp_fw_ring_id;
1247 };
1248 
1249 #define BNXT_VNIC_DEFAULT	0
1250 #define BNXT_VNIC_NTUPLE	1
1251 
1252 struct bnxt_vnic_info {
1253 	u16		fw_vnic_id; /* returned by Chimp during alloc */
1254 #define BNXT_MAX_CTX_PER_VNIC	8
1255 	u16		fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC];
1256 	u16		fw_l2_ctx_id;
1257 	u16		mru;
1258 #define BNXT_MAX_UC_ADDRS	4
1259 	struct bnxt_l2_filter *l2_filters[BNXT_MAX_UC_ADDRS];
1260 				/* index 0 always dev_addr */
1261 	u16		uc_filter_count;
1262 	u8		*uc_list;
1263 
1264 	u16		*fw_grp_ids;
1265 	dma_addr_t	rss_table_dma_addr;
1266 	__le16		*rss_table;
1267 	dma_addr_t	rss_hash_key_dma_addr;
1268 	u64		*rss_hash_key;
1269 	int		rss_table_size;
1270 #define BNXT_RSS_TABLE_ENTRIES_P5	64
1271 #define BNXT_RSS_TABLE_SIZE_P5		(BNXT_RSS_TABLE_ENTRIES_P5 * 4)
1272 #define BNXT_RSS_TABLE_MAX_TBL_P5	8
1273 #define BNXT_MAX_RSS_TABLE_SIZE_P5				\
1274 	(BNXT_RSS_TABLE_SIZE_P5 * BNXT_RSS_TABLE_MAX_TBL_P5)
1275 #define BNXT_MAX_RSS_TABLE_ENTRIES_P5				\
1276 	(BNXT_RSS_TABLE_ENTRIES_P5 * BNXT_RSS_TABLE_MAX_TBL_P5)
1277 
1278 	u32		rx_mask;
1279 
1280 	u8		*mc_list;
1281 	int		mc_list_size;
1282 	int		mc_list_count;
1283 	dma_addr_t	mc_list_mapping;
1284 #define BNXT_MAX_MC_ADDRS	16
1285 
1286 	u32		flags;
1287 #define BNXT_VNIC_RSS_FLAG	1
1288 #define BNXT_VNIC_RFS_FLAG	2
1289 #define BNXT_VNIC_MCAST_FLAG	4
1290 #define BNXT_VNIC_UCAST_FLAG	8
1291 #define BNXT_VNIC_RFS_NEW_RSS_FLAG	0x10
1292 #define BNXT_VNIC_NTUPLE_FLAG		0x20
1293 #define BNXT_VNIC_RSSCTX_FLAG		0x40
1294 	struct ethtool_rxfh_context *rss_ctx;
1295 	u32		vnic_id;
1296 };
1297 
1298 struct bnxt_rss_ctx {
1299 	struct bnxt_vnic_info vnic;
1300 	u8	index;
1301 };
1302 
1303 #define BNXT_MAX_ETH_RSS_CTX	32
1304 #define BNXT_VNIC_ID_INVALID	0xffffffff
1305 
1306 struct bnxt_hw_rings {
1307 	int tx;
1308 	int rx;
1309 	int grp;
1310 	int cp;
1311 	int cp_p5;
1312 	int stat;
1313 	int vnic;
1314 	int rss_ctx;
1315 };
1316 
1317 struct bnxt_hw_resc {
1318 	u16	min_rsscos_ctxs;
1319 	u16	max_rsscos_ctxs;
1320 	u16	resv_rsscos_ctxs;
1321 	u16	min_cp_rings;
1322 	u16	max_cp_rings;
1323 	u16	resv_cp_rings;
1324 	u16	min_tx_rings;
1325 	u16	max_tx_rings;
1326 	u16	resv_tx_rings;
1327 	u16	max_tx_sch_inputs;
1328 	u16	min_rx_rings;
1329 	u16	max_rx_rings;
1330 	u16	resv_rx_rings;
1331 	u16	min_hw_ring_grps;
1332 	u16	max_hw_ring_grps;
1333 	u16	resv_hw_ring_grps;
1334 	u16	min_l2_ctxs;
1335 	u16	max_l2_ctxs;
1336 	u16	min_vnics;
1337 	u16	max_vnics;
1338 	u16	resv_vnics;
1339 	u16	min_stat_ctxs;
1340 	u16	max_stat_ctxs;
1341 	u16	resv_stat_ctxs;
1342 	u16	max_nqs;
1343 	u16	max_irqs;
1344 	u16	resv_irqs;
1345 	u32	max_encap_records;
1346 	u32	max_decap_records;
1347 	u32	max_tx_em_flows;
1348 	u32	max_tx_wm_flows;
1349 	u32	max_rx_em_flows;
1350 	u32	max_rx_wm_flows;
1351 };
1352 
1353 #if defined(CONFIG_BNXT_SRIOV)
1354 struct bnxt_vf_info {
1355 	u16	fw_fid;
1356 	u8	mac_addr[ETH_ALEN];	/* PF assigned MAC Address */
1357 	u8	vf_mac_addr[ETH_ALEN];	/* VF assigned MAC address, only
1358 					 * stored by PF.
1359 					 */
1360 	u16	vlan;
1361 	u16	func_qcfg_flags;
1362 	u32	flags;
1363 #define BNXT_VF_SPOOFCHK	0x2
1364 #define BNXT_VF_LINK_FORCED	0x4
1365 #define BNXT_VF_LINK_UP		0x8
1366 #define BNXT_VF_TRUST		0x10
1367 	u32	min_tx_rate;
1368 	u32	max_tx_rate;
1369 	void	*hwrm_cmd_req_addr;
1370 	dma_addr_t	hwrm_cmd_req_dma_addr;
1371 };
1372 #endif
1373 
1374 struct bnxt_pf_info {
1375 #define BNXT_FIRST_PF_FID	1
1376 #define BNXT_FIRST_VF_FID	128
1377 	u16	fw_fid;
1378 	u16	port_id;
1379 	u8	mac_addr[ETH_ALEN];
1380 	u32	first_vf_id;
1381 	u16	active_vfs;
1382 	u16	registered_vfs;
1383 	u16	max_vfs;
1384 	unsigned long	*vf_event_bmap;
1385 	u16	hwrm_cmd_req_pages;
1386 	u8	vf_resv_strategy;
1387 #define BNXT_VF_RESV_STRATEGY_MAXIMAL	0
1388 #define BNXT_VF_RESV_STRATEGY_MINIMAL	1
1389 #define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC	2
1390 	void			*hwrm_cmd_req_addr[4];
1391 	dma_addr_t		hwrm_cmd_req_dma_addr[4];
1392 	struct bnxt_vf_info	*vf;
1393 };
1394 
1395 struct bnxt_filter_base {
1396 	struct hlist_node	hash;
1397 	struct list_head	list;
1398 	__le64			filter_id;
1399 	u8			type;
1400 #define BNXT_FLTR_TYPE_NTUPLE	1
1401 #define BNXT_FLTR_TYPE_L2	2
1402 	u8			flags;
1403 #define BNXT_ACT_DROP		1
1404 #define BNXT_ACT_RING_DST	2
1405 #define BNXT_ACT_FUNC_DST	4
1406 #define BNXT_ACT_NO_AGING	8
1407 #define BNXT_ACT_RSS_CTX	0x10
1408 	u16			sw_id;
1409 	u16			rxq;
1410 	u16			fw_vnic_id;
1411 	u16			vf_idx;
1412 	unsigned long		state;
1413 #define BNXT_FLTR_VALID		0
1414 #define BNXT_FLTR_INSERTED	1
1415 #define BNXT_FLTR_FW_DELETED	2
1416 
1417 	struct rcu_head         rcu;
1418 };
1419 
1420 struct bnxt_flow_masks {
1421 	struct flow_dissector_key_ports ports;
1422 	struct flow_dissector_key_addrs addrs;
1423 };
1424 
1425 extern const struct bnxt_flow_masks BNXT_FLOW_MASK_NONE;
1426 extern const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL;
1427 extern const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL;
1428 
1429 struct bnxt_ntuple_filter {
1430 	/* base filter must be the first member */
1431 	struct bnxt_filter_base	base;
1432 	struct flow_keys	fkeys;
1433 	struct bnxt_flow_masks	fmasks;
1434 	struct bnxt_l2_filter	*l2_fltr;
1435 	u32			flow_id;
1436 };
1437 
1438 struct bnxt_l2_key {
1439 	union {
1440 		struct {
1441 			u8	dst_mac_addr[ETH_ALEN];
1442 			u16	vlan;
1443 		};
1444 		u32	filter_key;
1445 	};
1446 };
1447 
1448 struct bnxt_ipv4_tuple {
1449 	struct flow_dissector_key_ipv4_addrs v4addrs;
1450 	struct flow_dissector_key_ports ports;
1451 };
1452 
1453 struct bnxt_ipv6_tuple {
1454 	struct flow_dissector_key_ipv6_addrs v6addrs;
1455 	struct flow_dissector_key_ports ports;
1456 };
1457 
1458 #define BNXT_L2_KEY_SIZE	(sizeof(struct bnxt_l2_key) / 4)
1459 
1460 struct bnxt_l2_filter {
1461 	/* base filter must be the first member */
1462 	struct bnxt_filter_base	base;
1463 	struct bnxt_l2_key	l2_key;
1464 	atomic_t		refcnt;
1465 };
1466 
1467 /* Compat version of hwrm_port_phy_qcfg_output capped at 96 bytes.  The
1468  * first 95 bytes are identical to hwrm_port_phy_qcfg_output in bnxt_hsi.h.
1469  * The last valid byte in the compat version is different.
1470  */
1471 struct hwrm_port_phy_qcfg_output_compat {
1472 	__le16	error_code;
1473 	__le16	req_type;
1474 	__le16	seq_id;
1475 	__le16	resp_len;
1476 	u8	link;
1477 	u8	active_fec_signal_mode;
1478 	__le16	link_speed;
1479 	u8	duplex_cfg;
1480 	u8	pause;
1481 	__le16	support_speeds;
1482 	__le16	force_link_speed;
1483 	u8	auto_mode;
1484 	u8	auto_pause;
1485 	__le16	auto_link_speed;
1486 	__le16	auto_link_speed_mask;
1487 	u8	wirespeed;
1488 	u8	lpbk;
1489 	u8	force_pause;
1490 	u8	module_status;
1491 	__le32	preemphasis;
1492 	u8	phy_maj;
1493 	u8	phy_min;
1494 	u8	phy_bld;
1495 	u8	phy_type;
1496 	u8	media_type;
1497 	u8	xcvr_pkg_type;
1498 	u8	eee_config_phy_addr;
1499 	u8	parallel_detect;
1500 	__le16	link_partner_adv_speeds;
1501 	u8	link_partner_adv_auto_mode;
1502 	u8	link_partner_adv_pause;
1503 	__le16	adv_eee_link_speed_mask;
1504 	__le16	link_partner_adv_eee_link_speed_mask;
1505 	__le32	xcvr_identifier_type_tx_lpi_timer;
1506 	__le16	fec_cfg;
1507 	u8	duplex_state;
1508 	u8	option_flags;
1509 	char	phy_vendor_name[16];
1510 	char	phy_vendor_partnumber[16];
1511 	__le16	support_pam4_speeds;
1512 	__le16	force_pam4_link_speed;
1513 	__le16	auto_pam4_link_speed_mask;
1514 	u8	link_partner_pam4_adv_speeds;
1515 	u8	valid;
1516 };
1517 
1518 struct bnxt_link_info {
1519 	u8			phy_type;
1520 	u8			media_type;
1521 	u8			transceiver;
1522 	u8			phy_addr;
1523 	u8			phy_link_status;
1524 #define BNXT_LINK_NO_LINK	PORT_PHY_QCFG_RESP_LINK_NO_LINK
1525 #define BNXT_LINK_SIGNAL	PORT_PHY_QCFG_RESP_LINK_SIGNAL
1526 #define BNXT_LINK_LINK		PORT_PHY_QCFG_RESP_LINK_LINK
1527 	u8			wire_speed;
1528 	u8			phy_state;
1529 #define BNXT_PHY_STATE_ENABLED		0
1530 #define BNXT_PHY_STATE_DISABLED		1
1531 
1532 	u8			link_state;
1533 #define BNXT_LINK_STATE_UNKNOWN	0
1534 #define BNXT_LINK_STATE_DOWN	1
1535 #define BNXT_LINK_STATE_UP	2
1536 #define BNXT_LINK_IS_UP(bp)	((bp)->link_info.link_state == BNXT_LINK_STATE_UP)
1537 	u8			active_lanes;
1538 	u8			duplex;
1539 #define BNXT_LINK_DUPLEX_HALF	PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF
1540 #define BNXT_LINK_DUPLEX_FULL	PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL
1541 	u8			pause;
1542 #define BNXT_LINK_PAUSE_TX	PORT_PHY_QCFG_RESP_PAUSE_TX
1543 #define BNXT_LINK_PAUSE_RX	PORT_PHY_QCFG_RESP_PAUSE_RX
1544 #define BNXT_LINK_PAUSE_BOTH	(PORT_PHY_QCFG_RESP_PAUSE_RX | \
1545 				 PORT_PHY_QCFG_RESP_PAUSE_TX)
1546 	u8			lp_pause;
1547 	u8			auto_pause_setting;
1548 	u8			force_pause_setting;
1549 	u8			duplex_setting;
1550 	u8			auto_mode;
1551 #define BNXT_AUTO_MODE(mode)	((mode) > BNXT_LINK_AUTO_NONE && \
1552 				 (mode) <= BNXT_LINK_AUTO_MSK)
1553 #define BNXT_LINK_AUTO_NONE     PORT_PHY_QCFG_RESP_AUTO_MODE_NONE
1554 #define BNXT_LINK_AUTO_ALLSPDS	PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
1555 #define BNXT_LINK_AUTO_ONESPD	PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
1556 #define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
1557 #define BNXT_LINK_AUTO_MSK	PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
1558 #define PHY_VER_LEN		3
1559 	u8			phy_ver[PHY_VER_LEN];
1560 	u16			link_speed;
1561 #define BNXT_LINK_SPEED_100MB	PORT_PHY_QCFG_RESP_LINK_SPEED_100MB
1562 #define BNXT_LINK_SPEED_1GB	PORT_PHY_QCFG_RESP_LINK_SPEED_1GB
1563 #define BNXT_LINK_SPEED_2GB	PORT_PHY_QCFG_RESP_LINK_SPEED_2GB
1564 #define BNXT_LINK_SPEED_2_5GB	PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB
1565 #define BNXT_LINK_SPEED_10GB	PORT_PHY_QCFG_RESP_LINK_SPEED_10GB
1566 #define BNXT_LINK_SPEED_20GB	PORT_PHY_QCFG_RESP_LINK_SPEED_20GB
1567 #define BNXT_LINK_SPEED_25GB	PORT_PHY_QCFG_RESP_LINK_SPEED_25GB
1568 #define BNXT_LINK_SPEED_40GB	PORT_PHY_QCFG_RESP_LINK_SPEED_40GB
1569 #define BNXT_LINK_SPEED_50GB	PORT_PHY_QCFG_RESP_LINK_SPEED_50GB
1570 #define BNXT_LINK_SPEED_100GB	PORT_PHY_QCFG_RESP_LINK_SPEED_100GB
1571 #define BNXT_LINK_SPEED_200GB	PORT_PHY_QCFG_RESP_LINK_SPEED_200GB
1572 #define BNXT_LINK_SPEED_400GB	PORT_PHY_QCFG_RESP_LINK_SPEED_400GB
1573 	u16			support_speeds;
1574 	u16			support_pam4_speeds;
1575 	u16			support_speeds2;
1576 
1577 	u16			auto_link_speeds;	/* fw adv setting */
1578 #define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB
1579 #define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB
1580 #define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB
1581 #define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB
1582 #define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB
1583 #define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB
1584 #define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
1585 #define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
1586 #define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
1587 #define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB
1588 	u16			auto_pam4_link_speeds;
1589 #define BNXT_LINK_PAM4_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_50G
1590 #define BNXT_LINK_PAM4_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_100G
1591 #define BNXT_LINK_PAM4_SPEED_MSK_200GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_200G
1592 	u16			auto_link_speeds2;
1593 #define BNXT_LINK_SPEEDS2_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_1GB
1594 #define BNXT_LINK_SPEEDS2_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_10GB
1595 #define BNXT_LINK_SPEEDS2_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_25GB
1596 #define BNXT_LINK_SPEEDS2_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_40GB
1597 #define BNXT_LINK_SPEEDS2_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB
1598 #define BNXT_LINK_SPEEDS2_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB
1599 #define BNXT_LINK_SPEEDS2_MSK_50GB_PAM4	\
1600 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB_PAM4_56
1601 #define BNXT_LINK_SPEEDS2_MSK_100GB_PAM4	\
1602 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_56
1603 #define BNXT_LINK_SPEEDS2_MSK_200GB_PAM4	\
1604 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_56
1605 #define BNXT_LINK_SPEEDS2_MSK_400GB_PAM4	\
1606 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_56
1607 #define BNXT_LINK_SPEEDS2_MSK_100GB_PAM4_112	\
1608 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_112
1609 #define BNXT_LINK_SPEEDS2_MSK_200GB_PAM4_112	\
1610 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_112
1611 #define BNXT_LINK_SPEEDS2_MSK_400GB_PAM4_112	\
1612 	PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_112
1613 
1614 	u16			support_auto_speeds;
1615 	u16			support_pam4_auto_speeds;
1616 	u16			support_auto_speeds2;
1617 
1618 	u16			lp_auto_link_speeds;
1619 	u16			lp_auto_pam4_link_speeds;
1620 	u16			force_link_speed;
1621 	u16			force_pam4_link_speed;
1622 	u16			force_link_speed2;
1623 #define BNXT_LINK_SPEED_50GB_PAM4	\
1624 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB_PAM4_56
1625 #define BNXT_LINK_SPEED_100GB_PAM4	\
1626 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_56
1627 #define BNXT_LINK_SPEED_200GB_PAM4	\
1628 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_56
1629 #define BNXT_LINK_SPEED_400GB_PAM4	\
1630 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_56
1631 #define BNXT_LINK_SPEED_100GB_PAM4_112	\
1632 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_112
1633 #define BNXT_LINK_SPEED_200GB_PAM4_112	\
1634 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_112
1635 #define BNXT_LINK_SPEED_400GB_PAM4_112	\
1636 	PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_112
1637 
1638 	u32			preemphasis;
1639 	u8			module_status;
1640 	u8			active_fec_sig_mode;
1641 	u16			fec_cfg;
1642 #define BNXT_FEC_NONE		PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED
1643 #define BNXT_FEC_AUTONEG_CAP	PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_SUPPORTED
1644 #define BNXT_FEC_AUTONEG	PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED
1645 #define BNXT_FEC_ENC_BASE_R_CAP	\
1646 	PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_SUPPORTED
1647 #define BNXT_FEC_ENC_BASE_R	PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED
1648 #define BNXT_FEC_ENC_RS_CAP	\
1649 	PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_SUPPORTED
1650 #define BNXT_FEC_ENC_LLRS_CAP	\
1651 	(PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_SUPPORTED |	\
1652 	 PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_SUPPORTED)
1653 #define BNXT_FEC_ENC_RS		\
1654 	(PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED |	\
1655 	 PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_1XN_ENABLED |	\
1656 	 PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_IEEE_ENABLED)
1657 #define BNXT_FEC_ENC_LLRS	\
1658 	(PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_ENABLED |	\
1659 	 PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_ENABLED)
1660 
1661 	/* copy of requested setting from ethtool cmd */
1662 	u8			autoneg;
1663 #define BNXT_AUTONEG_SPEED		1
1664 #define BNXT_AUTONEG_FLOW_CTRL		2
1665 	u8			req_signal_mode;
1666 #define BNXT_SIG_MODE_NRZ	PORT_PHY_QCFG_RESP_SIGNAL_MODE_NRZ
1667 #define BNXT_SIG_MODE_PAM4	PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4
1668 #define BNXT_SIG_MODE_PAM4_112	PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4_112
1669 #define BNXT_SIG_MODE_MAX	(PORT_PHY_QCFG_RESP_SIGNAL_MODE_LAST + 1)
1670 	u8			req_duplex;
1671 	u8			req_flow_ctrl;
1672 	u16			req_link_speed;
1673 	u16			advertising;	/* user adv setting */
1674 	u16			advertising_pam4;
1675 	bool			force_link_chng;
1676 
1677 	bool			phy_retry;
1678 	unsigned long		phy_retry_expires;
1679 
1680 	/* a copy of phy_qcfg output used to report link
1681 	 * info to VF
1682 	 */
1683 	struct hwrm_port_phy_qcfg_output phy_qcfg_resp;
1684 };
1685 
1686 #define BNXT_FEC_RS544_ON					\
1687 	 (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_ENABLE |		\
1688 	  PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_ENABLE)
1689 
1690 #define BNXT_FEC_RS544_OFF					\
1691 	 (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_DISABLE |	\
1692 	  PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_DISABLE)
1693 
1694 #define BNXT_FEC_RS272_ON					\
1695 	 (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_ENABLE |		\
1696 	  PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_ENABLE)
1697 
1698 #define BNXT_FEC_RS272_OFF					\
1699 	 (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_DISABLE |	\
1700 	  PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_DISABLE)
1701 
1702 #define BNXT_PAM4_SUPPORTED(link_info)				\
1703 	((link_info)->support_pam4_speeds)
1704 
1705 #define BNXT_FEC_RS_ON(link_info)				\
1706 	(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE |		\
1707 	 PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE |		\
1708 	 (BNXT_PAM4_SUPPORTED(link_info) ?			\
1709 	  (BNXT_FEC_RS544_ON | BNXT_FEC_RS272_OFF) : 0))
1710 
1711 #define BNXT_FEC_LLRS_ON					\
1712 	(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE |		\
1713 	 PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE |		\
1714 	 BNXT_FEC_RS272_ON | BNXT_FEC_RS544_OFF)
1715 
1716 #define BNXT_FEC_RS_OFF(link_info)				\
1717 	(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_DISABLE |		\
1718 	 (BNXT_PAM4_SUPPORTED(link_info) ?			\
1719 	  (BNXT_FEC_RS544_OFF | BNXT_FEC_RS272_OFF) : 0))
1720 
1721 #define BNXT_FEC_BASE_R_ON(link_info)				\
1722 	(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_ENABLE |		\
1723 	 BNXT_FEC_RS_OFF(link_info))
1724 
1725 #define BNXT_FEC_ALL_OFF(link_info)				\
1726 	(PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE |		\
1727 	 BNXT_FEC_RS_OFF(link_info))
1728 
1729 struct bnxt_queue_info {
1730 	u8	queue_id;
1731 	u8	queue_profile;
1732 };
1733 
1734 #define BNXT_MAX_LED			4
1735 
1736 struct bnxt_led_info {
1737 	u8	led_id;
1738 	u8	led_type;
1739 	u8	led_group_id;
1740 	u8	unused;
1741 	__le16	led_state_caps;
1742 #define BNXT_LED_ALT_BLINK_CAP(x)	((x) &	\
1743 	cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED))
1744 
1745 	__le16	led_color_caps;
1746 };
1747 
1748 #define BNXT_MAX_TEST	8
1749 
1750 struct bnxt_test_info {
1751 	u8 offline_mask;
1752 	u16 timeout;
1753 	char string[BNXT_MAX_TEST][ETH_GSTRING_LEN];
1754 };
1755 
1756 #define CHIMP_REG_VIEW_ADDR				\
1757 	((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) ? 0x80000000 : 0xb1000000)
1758 
1759 #define BNXT_GRCPF_REG_CHIMP_COMM		0x0
1760 #define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER	0x100
1761 #define BNXT_GRCPF_REG_WINDOW_BASE_OUT		0x400
1762 
1763 #define BNXT_GRC_REG_STATUS_P5			0x520
1764 
1765 #define BNXT_GRCPF_REG_KONG_COMM		0xA00
1766 #define BNXT_GRCPF_REG_KONG_COMM_TRIGGER	0xB00
1767 
1768 #define BNXT_GRC_REG_CHIP_NUM			0x48
1769 #define BNXT_GRC_REG_BASE			0x260000
1770 
1771 #define BNXT_TS_REG_TIMESYNC_TS0_LOWER		0x640180c
1772 #define BNXT_TS_REG_TIMESYNC_TS0_UPPER		0x6401810
1773 
1774 #define BNXT_GRC_BASE_MASK			0xfffff000
1775 #define BNXT_GRC_OFFSET_MASK			0x00000ffc
1776 
1777 struct bnxt_tc_flow_stats {
1778 	u64		packets;
1779 	u64		bytes;
1780 };
1781 
1782 #ifdef CONFIG_BNXT_FLOWER_OFFLOAD
1783 struct bnxt_flower_indr_block_cb_priv {
1784 	struct net_device *tunnel_netdev;
1785 	struct bnxt *bp;
1786 	struct list_head list;
1787 };
1788 #endif
1789 
1790 struct bnxt_tc_info {
1791 	bool				enabled;
1792 
1793 	/* hash table to store TC offloaded flows */
1794 	struct rhashtable		flow_table;
1795 	struct rhashtable_params	flow_ht_params;
1796 
1797 	/* hash table to store L2 keys of TC flows */
1798 	struct rhashtable		l2_table;
1799 	struct rhashtable_params	l2_ht_params;
1800 	/* hash table to store L2 keys for TC tunnel decap */
1801 	struct rhashtable		decap_l2_table;
1802 	struct rhashtable_params	decap_l2_ht_params;
1803 	/* hash table to store tunnel decap entries */
1804 	struct rhashtable		decap_table;
1805 	struct rhashtable_params	decap_ht_params;
1806 	/* hash table to store tunnel encap entries */
1807 	struct rhashtable		encap_table;
1808 	struct rhashtable_params	encap_ht_params;
1809 
1810 	/* lock to atomically add/del an l2 node when a flow is
1811 	 * added or deleted.
1812 	 */
1813 	struct mutex			lock;
1814 
1815 	/* Fields used for batching stats query */
1816 	struct rhashtable_iter		iter;
1817 #define BNXT_FLOW_STATS_BATCH_MAX	10
1818 	struct bnxt_tc_stats_batch {
1819 		void			  *flow_node;
1820 		struct bnxt_tc_flow_stats hw_stats;
1821 	} stats_batch[BNXT_FLOW_STATS_BATCH_MAX];
1822 
1823 	/* Stat counter mask (width) */
1824 	u64				bytes_mask;
1825 	u64				packets_mask;
1826 };
1827 
1828 struct bnxt_vf_rep_stats {
1829 	u64			packets;
1830 	u64			bytes;
1831 	u64			dropped;
1832 };
1833 
1834 struct bnxt_vf_rep {
1835 	struct bnxt			*bp;
1836 	struct net_device		*dev;
1837 	struct metadata_dst		*dst;
1838 	u16				vf_idx;
1839 	u16				tx_cfa_action;
1840 	u16				rx_cfa_code;
1841 
1842 	struct bnxt_vf_rep_stats	rx_stats;
1843 	struct bnxt_vf_rep_stats	tx_stats;
1844 };
1845 
1846 #define PTU_PTE_VALID             0x1UL
1847 #define PTU_PTE_LAST              0x2UL
1848 #define PTU_PTE_NEXT_TO_LAST      0x4UL
1849 
1850 #define MAX_CTX_PAGES	(BNXT_PAGE_SIZE / 8)
1851 #define MAX_CTX_TOTAL_PAGES	(MAX_CTX_PAGES * MAX_CTX_PAGES)
1852 #define MAX_CTX_BYTES		((size_t)MAX_CTX_TOTAL_PAGES * BNXT_PAGE_SIZE)
1853 #define MAX_CTX_BYTES_MASK	(MAX_CTX_BYTES - 1)
1854 
1855 struct bnxt_ctx_pg_info {
1856 	u32		entries;
1857 	u32		nr_pages;
1858 	void		*ctx_pg_arr[MAX_CTX_PAGES];
1859 	dma_addr_t	ctx_dma_arr[MAX_CTX_PAGES];
1860 	struct bnxt_ring_mem_info ring_mem;
1861 	struct bnxt_ctx_pg_info **ctx_pg_tbl;
1862 };
1863 
1864 #define BNXT_MAX_TQM_SP_RINGS		1
1865 #define BNXT_MAX_TQM_FP_RINGS		8
1866 #define BNXT_MAX_TQM_RINGS		\
1867 	(BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_RINGS)
1868 
1869 #define BNXT_BACKING_STORE_CFG_LEGACY_LEN	256
1870 
1871 #define BNXT_SET_CTX_PAGE_ATTR(attr)					\
1872 do {									\
1873 	if (BNXT_PAGE_SIZE == 0x2000)					\
1874 		attr = FUNC_BACKING_STORE_CFG_REQ_SRQ_PG_SIZE_PG_8K;	\
1875 	else if (BNXT_PAGE_SIZE == 0x10000)				\
1876 		attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_64K;	\
1877 	else								\
1878 		attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_4K;	\
1879 } while (0)
1880 
1881 struct bnxt_ctx_mem_type {
1882 	u16	type;
1883 	u16	entry_size;
1884 	u32	flags;
1885 #define BNXT_CTX_MEM_TYPE_VALID FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_TYPE_VALID
1886 #define BNXT_CTX_MEM_FW_TRACE		\
1887 	FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_FW_DBG_TRACE
1888 #define BNXT_CTX_MEM_FW_BIN_TRACE	\
1889 	FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_FW_BIN_DBG_TRACE
1890 #define BNXT_CTX_MEM_PERSIST		\
1891 	FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_NEXT_BS_OFFSET
1892 
1893 	u32	instance_bmap;
1894 	u8	init_value;
1895 	u8	entry_multiple;
1896 	u16	init_offset;
1897 #define	BNXT_CTX_INIT_INVALID_OFFSET	0xffff
1898 	u32	max_entries;
1899 	u32	min_entries;
1900 	u8	last:1;
1901 	u8	mem_valid:1;
1902 	u8	split_entry_cnt;
1903 #define BNXT_MAX_SPLIT_ENTRY	4
1904 	union {
1905 		struct {
1906 			u32	qp_l2_entries;
1907 			u32	qp_qp1_entries;
1908 			u32	qp_fast_qpmd_entries;
1909 		};
1910 		u32	srq_l2_entries;
1911 		u32	cq_l2_entries;
1912 		u32	vnic_entries;
1913 		struct {
1914 			u32	mrav_av_entries;
1915 			u32	mrav_num_entries_units;
1916 		};
1917 		u32	split[BNXT_MAX_SPLIT_ENTRY];
1918 	};
1919 	struct bnxt_ctx_pg_info	*pg_info;
1920 };
1921 
1922 #define BNXT_CTX_MRAV_AV_SPLIT_ENTRY	0
1923 
1924 #define BNXT_CTX_QP	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_QP
1925 #define BNXT_CTX_SRQ	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRQ
1926 #define BNXT_CTX_CQ	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CQ
1927 #define BNXT_CTX_VNIC	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_VNIC
1928 #define BNXT_CTX_STAT	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_STAT
1929 #define BNXT_CTX_STQM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SP_TQM_RING
1930 #define BNXT_CTX_FTQM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_FP_TQM_RING
1931 #define BNXT_CTX_MRAV	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_MRAV
1932 #define BNXT_CTX_TIM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TIM
1933 #define BNXT_CTX_TCK	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TX_CK
1934 #define BNXT_CTX_RCK	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RX_CK
1935 #define BNXT_CTX_MTQM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_MP_TQM_RING
1936 #define BNXT_CTX_SQDBS	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SQ_DB_SHADOW
1937 #define BNXT_CTX_RQDBS	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RQ_DB_SHADOW
1938 #define BNXT_CTX_SRQDBS	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRQ_DB_SHADOW
1939 #define BNXT_CTX_CQDBS	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CQ_DB_SHADOW
1940 #define BNXT_CTX_TBLSC	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_TBL_SCOPE
1941 #define BNXT_CTX_XPAR	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_XID_PARTITION
1942 #define BNXT_CTX_SRT	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRT_TRACE
1943 #define BNXT_CTX_SRT2	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_SRT2_TRACE
1944 #define BNXT_CTX_CRT	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CRT_TRACE
1945 #define BNXT_CTX_CRT2	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CRT2_TRACE
1946 #define BNXT_CTX_RIGP0	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP0_TRACE
1947 #define BNXT_CTX_L2HWRM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_L2_HWRM_TRACE
1948 #define BNXT_CTX_REHWRM	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_ROCE_HWRM_TRACE
1949 #define BNXT_CTX_CA0	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA0_TRACE
1950 #define BNXT_CTX_CA1	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA1_TRACE
1951 #define BNXT_CTX_CA2	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_CA2_TRACE
1952 #define BNXT_CTX_RIGP1	FUNC_BACKING_STORE_QCAPS_V2_REQ_TYPE_RIGP1_TRACE
1953 
1954 #define BNXT_CTX_MAX	(BNXT_CTX_TIM + 1)
1955 #define BNXT_CTX_L2_MAX	(BNXT_CTX_FTQM + 1)
1956 #define BNXT_CTX_V2_MAX	(BNXT_CTX_RIGP1 + 1)
1957 #define BNXT_CTX_INV	((u16)-1)
1958 
1959 struct bnxt_ctx_mem_info {
1960 	u8	tqm_fp_rings_count;
1961 
1962 	u32	flags;
1963 	#define BNXT_CTX_FLAG_INITED	0x01
1964 	struct bnxt_ctx_mem_type	ctx_arr[BNXT_CTX_V2_MAX];
1965 };
1966 
1967 enum bnxt_health_severity {
1968 	SEVERITY_NORMAL = 0,
1969 	SEVERITY_WARNING,
1970 	SEVERITY_RECOVERABLE,
1971 	SEVERITY_FATAL,
1972 };
1973 
1974 enum bnxt_health_remedy {
1975 	REMEDY_DEVLINK_RECOVER,
1976 	REMEDY_POWER_CYCLE_DEVICE,
1977 	REMEDY_POWER_CYCLE_HOST,
1978 	REMEDY_FW_UPDATE,
1979 	REMEDY_HW_REPLACE,
1980 };
1981 
1982 struct bnxt_fw_health {
1983 	u32 flags;
1984 	u32 polling_dsecs;
1985 	u32 master_func_wait_dsecs;
1986 	u32 normal_func_wait_dsecs;
1987 	u32 post_reset_wait_dsecs;
1988 	u32 post_reset_max_wait_dsecs;
1989 	u32 regs[4];
1990 	u32 mapped_regs[4];
1991 #define BNXT_FW_HEALTH_REG		0
1992 #define BNXT_FW_HEARTBEAT_REG		1
1993 #define BNXT_FW_RESET_CNT_REG		2
1994 #define BNXT_FW_RESET_INPROG_REG	3
1995 	u32 fw_reset_inprog_reg_mask;
1996 	u32 last_fw_heartbeat;
1997 	u32 last_fw_reset_cnt;
1998 	u8 enabled:1;
1999 	u8 primary:1;
2000 	u8 status_reliable:1;
2001 	u8 resets_reliable:1;
2002 	u8 tmr_multiplier;
2003 	u8 tmr_counter;
2004 	u8 fw_reset_seq_cnt;
2005 	u32 fw_reset_seq_regs[16];
2006 	u32 fw_reset_seq_vals[16];
2007 	u32 fw_reset_seq_delay_msec[16];
2008 	u32 echo_req_data1;
2009 	u32 echo_req_data2;
2010 	struct devlink_health_reporter	*fw_reporter;
2011 	/* Protects severity and remedy */
2012 	struct mutex lock;
2013 	enum bnxt_health_severity severity;
2014 	enum bnxt_health_remedy remedy;
2015 	u32 arrests;
2016 	u32 discoveries;
2017 	u32 survivals;
2018 	u32 fatalities;
2019 	u32 diagnoses;
2020 };
2021 
2022 #define BNXT_FW_HEALTH_REG_TYPE_MASK	3
2023 #define BNXT_FW_HEALTH_REG_TYPE_CFG	0
2024 #define BNXT_FW_HEALTH_REG_TYPE_GRC	1
2025 #define BNXT_FW_HEALTH_REG_TYPE_BAR0	2
2026 #define BNXT_FW_HEALTH_REG_TYPE_BAR1	3
2027 
2028 #define BNXT_FW_HEALTH_REG_TYPE(reg)	((reg) & BNXT_FW_HEALTH_REG_TYPE_MASK)
2029 #define BNXT_FW_HEALTH_REG_OFF(reg)	((reg) & ~BNXT_FW_HEALTH_REG_TYPE_MASK)
2030 
2031 #define BNXT_FW_HEALTH_WIN_BASE		0x3000
2032 #define BNXT_FW_HEALTH_WIN_MAP_OFF	8
2033 
2034 #define BNXT_FW_HEALTH_WIN_OFF(reg)	(BNXT_FW_HEALTH_WIN_BASE +	\
2035 					 ((reg) & BNXT_GRC_OFFSET_MASK))
2036 
2037 #define BNXT_FW_STATUS_HEALTH_MSK	0xffff
2038 #define BNXT_FW_STATUS_HEALTHY		0x8000
2039 #define BNXT_FW_STATUS_SHUTDOWN		0x100000
2040 #define BNXT_FW_STATUS_RECOVERING	0x400000
2041 
2042 #define BNXT_FW_IS_HEALTHY(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) ==\
2043 					 BNXT_FW_STATUS_HEALTHY)
2044 
2045 #define BNXT_FW_IS_BOOTING(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) < \
2046 					 BNXT_FW_STATUS_HEALTHY)
2047 
2048 #define BNXT_FW_IS_ERR(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \
2049 					 BNXT_FW_STATUS_HEALTHY)
2050 
2051 #define BNXT_FW_IS_RECOVERING(sts)	(BNXT_FW_IS_ERR(sts) &&		       \
2052 					 ((sts) & BNXT_FW_STATUS_RECOVERING))
2053 
2054 #define BNXT_FW_RETRY			5
2055 #define BNXT_FW_IF_RETRY		10
2056 #define BNXT_FW_SLOT_RESET_RETRY	4
2057 
2058 struct bnxt_aux_priv {
2059 	struct auxiliary_device aux_dev;
2060 	struct bnxt_en_dev *edev;
2061 	int id;
2062 };
2063 
2064 enum board_idx {
2065 	BCM57301,
2066 	BCM57302,
2067 	BCM57304,
2068 	BCM57417_NPAR,
2069 	BCM58700,
2070 	BCM57311,
2071 	BCM57312,
2072 	BCM57402,
2073 	BCM57404,
2074 	BCM57406,
2075 	BCM57402_NPAR,
2076 	BCM57407,
2077 	BCM57412,
2078 	BCM57414,
2079 	BCM57416,
2080 	BCM57417,
2081 	BCM57412_NPAR,
2082 	BCM57314,
2083 	BCM57417_SFP,
2084 	BCM57416_SFP,
2085 	BCM57404_NPAR,
2086 	BCM57406_NPAR,
2087 	BCM57407_SFP,
2088 	BCM57407_NPAR,
2089 	BCM57414_NPAR,
2090 	BCM57416_NPAR,
2091 	BCM57452,
2092 	BCM57454,
2093 	BCM5745x_NPAR,
2094 	BCM57508,
2095 	BCM57504,
2096 	BCM57502,
2097 	BCM57508_NPAR,
2098 	BCM57504_NPAR,
2099 	BCM57502_NPAR,
2100 	BCM57608,
2101 	BCM57604,
2102 	BCM57602,
2103 	BCM57601,
2104 	BCM58802,
2105 	BCM58804,
2106 	BCM58808,
2107 	NETXTREME_E_VF,
2108 	NETXTREME_C_VF,
2109 	NETXTREME_S_VF,
2110 	NETXTREME_C_VF_HV,
2111 	NETXTREME_E_VF_HV,
2112 	NETXTREME_E_P5_VF,
2113 	NETXTREME_E_P5_VF_HV,
2114 	NETXTREME_E_P7_VF,
2115 };
2116 
2117 #define BNXT_TRACE_BUF_MAGIC_BYTE ((u8)0xbc)
2118 #define BNXT_TRACE_MAX 11
2119 
2120 struct bnxt_bs_trace_info {
2121 	u8 *magic_byte;
2122 	u32 last_offset;
2123 	u8 wrapped:1;
2124 	u16 ctx_type;
2125 	u16 trace_type;
2126 };
2127 
2128 static inline void bnxt_bs_trace_check_wrap(struct bnxt_bs_trace_info *bs_trace,
2129 					    u32 offset)
2130 {
2131 	if (!bs_trace->wrapped &&
2132 	    *bs_trace->magic_byte != BNXT_TRACE_BUF_MAGIC_BYTE)
2133 		bs_trace->wrapped = 1;
2134 	bs_trace->last_offset = offset;
2135 }
2136 
2137 struct bnxt {
2138 	void __iomem		*bar0;
2139 	void __iomem		*bar1;
2140 	void __iomem		*bar2;
2141 
2142 	u32			reg_base;
2143 	u16			chip_num;
2144 #define CHIP_NUM_57301		0x16c8
2145 #define CHIP_NUM_57302		0x16c9
2146 #define CHIP_NUM_57304		0x16ca
2147 #define CHIP_NUM_58700		0x16cd
2148 #define CHIP_NUM_57402		0x16d0
2149 #define CHIP_NUM_57404		0x16d1
2150 #define CHIP_NUM_57406		0x16d2
2151 #define CHIP_NUM_57407		0x16d5
2152 
2153 #define CHIP_NUM_57311		0x16ce
2154 #define CHIP_NUM_57312		0x16cf
2155 #define CHIP_NUM_57314		0x16df
2156 #define CHIP_NUM_57317		0x16e0
2157 #define CHIP_NUM_57412		0x16d6
2158 #define CHIP_NUM_57414		0x16d7
2159 #define CHIP_NUM_57416		0x16d8
2160 #define CHIP_NUM_57417		0x16d9
2161 #define CHIP_NUM_57412L		0x16da
2162 #define CHIP_NUM_57414L		0x16db
2163 
2164 #define CHIP_NUM_5745X		0xd730
2165 #define CHIP_NUM_57452		0xc452
2166 #define CHIP_NUM_57454		0xc454
2167 
2168 #define CHIP_NUM_57508		0x1750
2169 #define CHIP_NUM_57504		0x1751
2170 #define CHIP_NUM_57502		0x1752
2171 
2172 #define CHIP_NUM_57608		0x1760
2173 
2174 #define CHIP_NUM_58802		0xd802
2175 #define CHIP_NUM_58804		0xd804
2176 #define CHIP_NUM_58808		0xd808
2177 
2178 	u8			chip_rev;
2179 
2180 #define BNXT_CHIP_NUM_5730X(chip_num)		\
2181 	((chip_num) >= CHIP_NUM_57301 &&	\
2182 	 (chip_num) <= CHIP_NUM_57304)
2183 
2184 #define BNXT_CHIP_NUM_5740X(chip_num)		\
2185 	(((chip_num) >= CHIP_NUM_57402 &&	\
2186 	  (chip_num) <= CHIP_NUM_57406) ||	\
2187 	 (chip_num) == CHIP_NUM_57407)
2188 
2189 #define BNXT_CHIP_NUM_5731X(chip_num)		\
2190 	((chip_num) == CHIP_NUM_57311 ||	\
2191 	 (chip_num) == CHIP_NUM_57312 ||	\
2192 	 (chip_num) == CHIP_NUM_57314 ||	\
2193 	 (chip_num) == CHIP_NUM_57317)
2194 
2195 #define BNXT_CHIP_NUM_5741X(chip_num)		\
2196 	((chip_num) >= CHIP_NUM_57412 &&	\
2197 	 (chip_num) <= CHIP_NUM_57414L)
2198 
2199 #define BNXT_CHIP_NUM_58700(chip_num)		\
2200 	 ((chip_num) == CHIP_NUM_58700)
2201 
2202 #define BNXT_CHIP_NUM_5745X(chip_num)		\
2203 	((chip_num) == CHIP_NUM_5745X ||	\
2204 	 (chip_num) == CHIP_NUM_57452 ||	\
2205 	 (chip_num) == CHIP_NUM_57454)
2206 
2207 
2208 #define BNXT_CHIP_NUM_57X0X(chip_num)		\
2209 	(BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num))
2210 
2211 #define BNXT_CHIP_NUM_57X1X(chip_num)		\
2212 	(BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num))
2213 
2214 #define BNXT_CHIP_NUM_588XX(chip_num)		\
2215 	((chip_num) == CHIP_NUM_58802 ||	\
2216 	 (chip_num) == CHIP_NUM_58804 ||        \
2217 	 (chip_num) == CHIP_NUM_58808)
2218 
2219 #define BNXT_VPD_FLD_LEN	32
2220 	char			board_partno[BNXT_VPD_FLD_LEN];
2221 	char			board_serialno[BNXT_VPD_FLD_LEN];
2222 
2223 	struct net_device	*dev;
2224 	struct pci_dev		*pdev;
2225 
2226 	atomic_t		intr_sem;
2227 
2228 	u32			flags;
2229 	#define BNXT_FLAG_CHIP_P5_PLUS	0x1
2230 	#define BNXT_FLAG_VF		0x2
2231 	#define BNXT_FLAG_LRO		0x4
2232 #ifdef CONFIG_INET
2233 	#define BNXT_FLAG_GRO		0x8
2234 #else
2235 	/* Cannot support hardware GRO if CONFIG_INET is not set */
2236 	#define BNXT_FLAG_GRO		0x0
2237 #endif
2238 	#define BNXT_FLAG_TPA		(BNXT_FLAG_LRO | BNXT_FLAG_GRO)
2239 	#define BNXT_FLAG_JUMBO		0x10
2240 	#define BNXT_FLAG_STRIP_VLAN	0x20
2241 	#define BNXT_FLAG_AGG_RINGS	(BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
2242 					 BNXT_FLAG_LRO)
2243 	#define BNXT_FLAG_RFS		0x100
2244 	#define BNXT_FLAG_SHARED_RINGS	0x200
2245 	#define BNXT_FLAG_PORT_STATS	0x400
2246 	#define BNXT_FLAG_WOL_CAP	0x4000
2247 	#define BNXT_FLAG_ROCEV1_CAP	0x8000
2248 	#define BNXT_FLAG_ROCEV2_CAP	0x10000
2249 	#define BNXT_FLAG_ROCE_CAP	(BNXT_FLAG_ROCEV1_CAP |	\
2250 					 BNXT_FLAG_ROCEV2_CAP)
2251 	#define BNXT_FLAG_NO_AGG_RINGS	0x20000
2252 	#define BNXT_FLAG_RX_PAGE_MODE	0x40000
2253 	#define BNXT_FLAG_CHIP_P7	0x80000
2254 	#define BNXT_FLAG_MULTI_HOST	0x100000
2255 	#define BNXT_FLAG_DSN_VALID	0x200000
2256 	#define BNXT_FLAG_DOUBLE_DB	0x400000
2257 	#define BNXT_FLAG_UDP_GSO_CAP	0x800000
2258 	#define BNXT_FLAG_CHIP_NITRO_A0	0x1000000
2259 	#define BNXT_FLAG_DIM		0x2000000
2260 	#define BNXT_FLAG_ROCE_MIRROR_CAP	0x4000000
2261 	#define BNXT_FLAG_TX_COAL_CMPL	0x8000000
2262 	#define BNXT_FLAG_PORT_STATS_EXT	0x10000000
2263 
2264 	#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA |		\
2265 					    BNXT_FLAG_RFS |		\
2266 					    BNXT_FLAG_STRIP_VLAN)
2267 
2268 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
2269 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
2270 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
2271 #define BNXT_MH(bp)		((bp)->flags & BNXT_FLAG_MULTI_HOST)
2272 #define BNXT_SINGLE_PF(bp)	(BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
2273 #define BNXT_SH_PORT_CFG_OK(bp)	(BNXT_PF(bp) &&				\
2274 				 ((bp)->phy_flags & BNXT_PHY_FL_SHARED_PORT_CFG))
2275 #define BNXT_PHY_CFG_ABLE(bp)	((BNXT_SINGLE_PF(bp) ||			\
2276 				  BNXT_SH_PORT_CFG_OK(bp)) &&		\
2277 				 (bp)->link_info.phy_state == BNXT_PHY_STATE_ENABLED)
2278 #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
2279 #define BNXT_RX_PAGE_MODE(bp)	((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)
2280 #define BNXT_SUPPORTS_TPA(bp)	(!BNXT_CHIP_TYPE_NITRO_A0(bp) &&	\
2281 				 (!((bp)->flags & BNXT_FLAG_CHIP_P5_PLUS) ||\
2282 				  (bp)->max_tpa_v2) && !is_kdump_kernel())
2283 #define BNXT_RX_JUMBO_MODE(bp)	((bp)->flags & BNXT_FLAG_JUMBO)
2284 
2285 #define BNXT_CHIP_P7(bp)			\
2286 	((bp)->chip_num == CHIP_NUM_57608)
2287 
2288 #define BNXT_CHIP_P5(bp)			\
2289 	((bp)->chip_num == CHIP_NUM_57508 ||	\
2290 	 (bp)->chip_num == CHIP_NUM_57504 ||	\
2291 	 (bp)->chip_num == CHIP_NUM_57502)
2292 
2293 /* Chip class phase 5 */
2294 #define BNXT_CHIP_P5_PLUS(bp)			\
2295 	(BNXT_CHIP_P5(bp) || BNXT_CHIP_P7(bp))
2296 
2297 /* Chip class phase 4.x */
2298 #define BNXT_CHIP_P4(bp)			\
2299 	(BNXT_CHIP_NUM_57X1X((bp)->chip_num) ||	\
2300 	 BNXT_CHIP_NUM_5745X((bp)->chip_num) ||	\
2301 	 BNXT_CHIP_NUM_588XX((bp)->chip_num) ||	\
2302 	 (BNXT_CHIP_NUM_58700((bp)->chip_num) &&	\
2303 	  !BNXT_CHIP_TYPE_NITRO_A0(bp)))
2304 
2305 /* Chip class phase 3.x */
2306 #define BNXT_CHIP_P3(bp)			\
2307 	(BNXT_CHIP_NUM_57X0X((bp)->chip_num) ||	\
2308 	 BNXT_CHIP_TYPE_NITRO_A0(bp))
2309 
2310 #define BNXT_CHIP_P4_PLUS(bp)			\
2311 	(BNXT_CHIP_P4(bp) || BNXT_CHIP_P5_PLUS(bp))
2312 
2313 #define BNXT_CHIP_P5_AND_MINUS(bp)		\
2314 	(BNXT_CHIP_P3(bp) || BNXT_CHIP_P4(bp) || BNXT_CHIP_P5(bp))
2315 
2316 	struct bnxt_aux_priv	*aux_priv;
2317 	struct bnxt_en_dev	*edev;
2318 
2319 	struct bnxt_napi	**bnapi;
2320 
2321 	struct bnxt_rx_ring_info	*rx_ring;
2322 	struct bnxt_tx_ring_info	*tx_ring;
2323 	u16			*tx_ring_map;
2324 
2325 	struct sk_buff *	(*gro_func)(struct bnxt_tpa_info *, int, int,
2326 					    struct sk_buff *);
2327 
2328 	struct sk_buff *	(*rx_skb_func)(struct bnxt *,
2329 					       struct bnxt_rx_ring_info *,
2330 					       u16, void *, u8 *, dma_addr_t,
2331 					       unsigned int);
2332 
2333 	u16			max_tpa_v2;
2334 	u16			max_tpa;
2335 	u32			rx_buf_size;
2336 	u32			rx_buf_use_size;	/* useable size */
2337 	u16			rx_offset;
2338 	u16			rx_dma_offset;
2339 	enum dma_data_direction	rx_dir;
2340 	u32			rx_ring_size;
2341 	u32			rx_agg_ring_size;
2342 	u32			rx_copy_thresh;
2343 	u32			rx_ring_mask;
2344 	u32			rx_agg_ring_mask;
2345 	int			rx_nr_pages;
2346 	int			rx_agg_nr_pages;
2347 	int			rx_nr_rings;
2348 	int			rsscos_nr_ctxs;
2349 
2350 	u32			tx_ring_size;
2351 	u32			tx_ring_mask;
2352 	int			tx_nr_pages;
2353 	int			tx_nr_rings;
2354 	int			tx_nr_rings_per_tc;
2355 	int			tx_nr_rings_xdp;
2356 
2357 	int			tx_wake_thresh;
2358 	int			tx_push_thresh;
2359 	int			tx_push_size;
2360 
2361 	u32			cp_ring_size;
2362 	u32			cp_ring_mask;
2363 	u32			cp_bit;
2364 	int			cp_nr_pages;
2365 	int			cp_nr_rings;
2366 
2367 	/* grp_info indexed by completion ring index */
2368 	struct bnxt_ring_grp_info	*grp_info;
2369 	struct bnxt_vnic_info	*vnic_info;
2370 	u32			num_rss_ctx;
2371 	int			nr_vnics;
2372 	u32			*rss_indir_tbl;
2373 	u16			rss_indir_tbl_entries;
2374 	u32			rss_hash_cfg;
2375 	u32			rss_hash_delta;
2376 	u32			rss_cap;
2377 #define BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA	BIT(0)
2378 #define BNXT_RSS_CAP_UDP_RSS_CAP		BIT(1)
2379 #define BNXT_RSS_CAP_NEW_RSS_CAP		BIT(2)
2380 #define BNXT_RSS_CAP_RSS_TCAM			BIT(3)
2381 #define BNXT_RSS_CAP_AH_V4_RSS_CAP		BIT(4)
2382 #define BNXT_RSS_CAP_AH_V6_RSS_CAP		BIT(5)
2383 #define BNXT_RSS_CAP_ESP_V4_RSS_CAP		BIT(6)
2384 #define BNXT_RSS_CAP_ESP_V6_RSS_CAP		BIT(7)
2385 #define BNXT_RSS_CAP_MULTI_RSS_CTX		BIT(8)
2386 
2387 	u8			rss_hash_key[HW_HASH_KEY_SIZE];
2388 	u8			rss_hash_key_valid:1;
2389 	u8			rss_hash_key_updated:1;
2390 
2391 	u16			max_mtu;
2392 	u16			tso_max_segs;
2393 	u8			max_tc;
2394 	u8			max_lltc;	/* lossless TCs */
2395 	struct bnxt_queue_info	q_info[BNXT_MAX_QUEUE];
2396 	u8			tc_to_qidx[BNXT_MAX_QUEUE];
2397 	u8			q_ids[BNXT_MAX_QUEUE];
2398 	u8			max_q;
2399 	u8			num_tc;
2400 
2401 	unsigned int		current_interval;
2402 #define BNXT_TIMER_INTERVAL	HZ
2403 
2404 	struct timer_list	timer;
2405 
2406 	unsigned long		state;
2407 #define BNXT_STATE_OPEN		0
2408 #define BNXT_STATE_IN_SP_TASK	1
2409 #define BNXT_STATE_READ_STATS	2
2410 #define BNXT_STATE_FW_RESET_DET 3
2411 #define BNXT_STATE_IN_FW_RESET	4
2412 #define BNXT_STATE_ABORT_ERR	5
2413 #define BNXT_STATE_FW_FATAL_COND	6
2414 #define BNXT_STATE_DRV_REGISTERED	7
2415 #define BNXT_STATE_PCI_CHANNEL_IO_FROZEN	8
2416 #define BNXT_STATE_NAPI_DISABLED	9
2417 #define BNXT_STATE_L2_FILTER_RETRY	10
2418 #define BNXT_STATE_FW_ACTIVATE		11
2419 #define BNXT_STATE_RECOVER		12
2420 #define BNXT_STATE_FW_NON_FATAL_COND	13
2421 #define BNXT_STATE_FW_ACTIVATE_RESET	14
2422 #define BNXT_STATE_HALF_OPEN		15	/* For offline ethtool tests */
2423 
2424 #define BNXT_NO_FW_ACCESS(bp)					\
2425 	(test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) ||	\
2426 	 pci_channel_offline((bp)->pdev))
2427 
2428 	struct bnxt_irq	*irq_tbl;
2429 	int			total_irqs;
2430 	int			ulp_num_msix_want;
2431 	u8			mac_addr[ETH_ALEN];
2432 
2433 #ifdef CONFIG_BNXT_DCB
2434 	struct ieee_pfc		*ieee_pfc;
2435 	struct ieee_ets		*ieee_ets;
2436 	u8			dcbx_cap;
2437 	u8			default_pri;
2438 	u8			max_dscp_value;
2439 #endif /* CONFIG_BNXT_DCB */
2440 
2441 	u32			msg_enable;
2442 
2443 	u64			fw_cap;
2444 	#define BNXT_FW_CAP_SHORT_CMD			BIT_ULL(0)
2445 	#define BNXT_FW_CAP_LLDP_AGENT			BIT_ULL(1)
2446 	#define BNXT_FW_CAP_DCBX_AGENT			BIT_ULL(2)
2447 	#define BNXT_FW_CAP_NEW_RM			BIT_ULL(3)
2448 	#define BNXT_FW_CAP_IF_CHANGE			BIT_ULL(4)
2449 	#define BNXT_FW_CAP_ENABLE_RDMA_SRIOV           BIT_ULL(5)
2450 	#define BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED	BIT_ULL(6)
2451 	#define BNXT_FW_CAP_KONG_MB_CHNL		BIT_ULL(7)
2452 	#define BNXT_FW_CAP_OVS_64BIT_HANDLE		BIT_ULL(10)
2453 	#define BNXT_FW_CAP_TRUSTED_VF			BIT_ULL(11)
2454 	#define BNXT_FW_CAP_ERROR_RECOVERY		BIT_ULL(13)
2455 	#define BNXT_FW_CAP_PKG_VER			BIT_ULL(14)
2456 	#define BNXT_FW_CAP_CFA_ADV_FLOW		BIT_ULL(15)
2457 	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2	BIT_ULL(16)
2458 	#define BNXT_FW_CAP_PCIE_STATS_SUPPORTED	BIT_ULL(17)
2459 	#define BNXT_FW_CAP_EXT_STATS_SUPPORTED		BIT_ULL(18)
2460 	#define BNXT_FW_CAP_TX_TS_CMP			BIT_ULL(19)
2461 	#define BNXT_FW_CAP_ERR_RECOVER_RELOAD		BIT_ULL(20)
2462 	#define BNXT_FW_CAP_HOT_RESET			BIT_ULL(21)
2463 	#define BNXT_FW_CAP_PTP_RTC			BIT_ULL(22)
2464 	#define BNXT_FW_CAP_RX_ALL_PKT_TS		BIT_ULL(23)
2465 	#define BNXT_FW_CAP_VLAN_RX_STRIP		BIT_ULL(24)
2466 	#define BNXT_FW_CAP_VLAN_TX_INSERT		BIT_ULL(25)
2467 	#define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED	BIT_ULL(26)
2468 	#define BNXT_FW_CAP_LIVEPATCH			BIT_ULL(27)
2469 	#define BNXT_FW_CAP_PTP_PPS			BIT_ULL(28)
2470 	#define BNXT_FW_CAP_HOT_RESET_IF		BIT_ULL(29)
2471 	#define BNXT_FW_CAP_RING_MONITOR		BIT_ULL(30)
2472 	#define BNXT_FW_CAP_DBG_QCAPS			BIT_ULL(31)
2473 	#define BNXT_FW_CAP_PTP				BIT_ULL(32)
2474 	#define BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED	BIT_ULL(33)
2475 	#define BNXT_FW_CAP_DFLT_VLAN_TPID_PCP		BIT_ULL(34)
2476 	#define BNXT_FW_CAP_PRE_RESV_VNICS		BIT_ULL(35)
2477 	#define BNXT_FW_CAP_BACKING_STORE_V2		BIT_ULL(36)
2478 	#define BNXT_FW_CAP_VNIC_TUNNEL_TPA		BIT_ULL(37)
2479 	#define BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO	BIT_ULL(38)
2480 	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3	BIT_ULL(39)
2481 	#define BNXT_FW_CAP_VNIC_RE_FLUSH		BIT_ULL(40)
2482 
2483 	u32			fw_dbg_cap;
2484 
2485 #define BNXT_NEW_RM(bp)		((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
2486 #define BNXT_PTP_USE_RTC(bp)	(!BNXT_MH(bp) && \
2487 				 ((bp)->fw_cap & BNXT_FW_CAP_PTP_RTC))
2488 #define BNXT_SUPPORTS_NTUPLE_VNIC(bp)	\
2489 	(BNXT_PF(bp) && ((bp)->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3))
2490 
2491 #define BNXT_SUPPORTS_MULTI_RSS_CTX(bp)				\
2492 	(BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) &&	\
2493 	 ((bp)->rss_cap & BNXT_RSS_CAP_MULTI_RSS_CTX))
2494 #define BNXT_SUPPORTS_QUEUE_API(bp)				\
2495 	(BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) &&	\
2496 	 ((bp)->fw_cap & BNXT_FW_CAP_VNIC_RE_FLUSH))
2497 #define BNXT_RDMA_SRIOV_EN(bp)		\
2498 	((bp)->fw_cap & BNXT_FW_CAP_ENABLE_RDMA_SRIOV)
2499 #define BNXT_ROCE_VF_RESC_CAP(bp)	\
2500 	((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED)
2501 
2502 	u32			hwrm_spec_code;
2503 	u16			hwrm_cmd_seq;
2504 	u16                     hwrm_cmd_kong_seq;
2505 	struct dma_pool		*hwrm_dma_pool;
2506 	struct hlist_head	hwrm_pending_list;
2507 
2508 	struct rtnl_link_stats64	net_stats_prev;
2509 	struct bnxt_stats_mem	port_stats;
2510 	struct bnxt_stats_mem	rx_port_stats_ext;
2511 	struct bnxt_stats_mem	tx_port_stats_ext;
2512 	u16			fw_rx_stats_ext_size;
2513 	u16			fw_tx_stats_ext_size;
2514 	u16			hw_ring_stats_size;
2515 	u8			pri2cos_idx[8];
2516 	u8			pri2cos_valid;
2517 
2518 	struct bnxt_total_ring_err_stats ring_err_stats_prev;
2519 
2520 	u16			hwrm_max_req_len;
2521 	u16			hwrm_max_ext_req_len;
2522 	unsigned int		hwrm_cmd_timeout;
2523 	unsigned int		hwrm_cmd_max_timeout;
2524 	struct mutex		hwrm_cmd_lock;	/* serialize hwrm messages */
2525 	struct hwrm_ver_get_output	ver_resp;
2526 #define FW_VER_STR_LEN		32
2527 #define BC_HWRM_STR_LEN		21
2528 #define PHY_VER_STR_LEN         (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
2529 	char			fw_ver_str[FW_VER_STR_LEN];
2530 	char			hwrm_ver_supp[FW_VER_STR_LEN];
2531 	char			nvm_cfg_ver[FW_VER_STR_LEN];
2532 	u64			fw_ver_code;
2533 #define BNXT_FW_VER_CODE(maj, min, bld, rsv)			\
2534 	((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
2535 #define BNXT_FW_MAJ(bp)		((bp)->fw_ver_code >> 48)
2536 #define BNXT_FW_BLD(bp)		(((bp)->fw_ver_code >> 16) & 0xffff)
2537 
2538 	u16			vxlan_fw_dst_port_id;
2539 	u16			nge_fw_dst_port_id;
2540 	u16			vxlan_gpe_fw_dst_port_id;
2541 	__be16			vxlan_port;
2542 	__be16			nge_port;
2543 	__be16			vxlan_gpe_port;
2544 	u8			port_partition_type;
2545 	u8			port_count;
2546 	u16			br_mode;
2547 
2548 	struct bnxt_coal_cap	coal_cap;
2549 	struct bnxt_coal	rx_coal;
2550 	struct bnxt_coal	tx_coal;
2551 
2552 	u32			stats_coal_ticks;
2553 #define BNXT_DEF_STATS_COAL_TICKS	 1000000
2554 #define BNXT_MIN_STATS_COAL_TICKS	  250000
2555 #define BNXT_MAX_STATS_COAL_TICKS	 1000000
2556 
2557 	struct work_struct	sp_task;
2558 	unsigned long		sp_event;
2559 #define BNXT_RX_MASK_SP_EVENT		0
2560 #define BNXT_RX_NTP_FLTR_SP_EVENT	1
2561 #define BNXT_LINK_CHNG_SP_EVENT		2
2562 #define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT	3
2563 #define BNXT_RESET_TASK_SP_EVENT	6
2564 #define BNXT_RST_RING_SP_EVENT		7
2565 #define BNXT_HWRM_PF_UNLOAD_SP_EVENT	8
2566 #define BNXT_PERIODIC_STATS_SP_EVENT	9
2567 #define BNXT_HWRM_PORT_MODULE_SP_EVENT	10
2568 #define BNXT_RESET_TASK_SILENT_SP_EVENT	11
2569 #define BNXT_LINK_SPEED_CHNG_SP_EVENT	14
2570 #define BNXT_FLOW_STATS_SP_EVENT	15
2571 #define BNXT_UPDATE_PHY_SP_EVENT	16
2572 #define BNXT_RING_COAL_NOW_SP_EVENT	17
2573 #define BNXT_FW_RESET_NOTIFY_SP_EVENT	18
2574 #define BNXT_FW_EXCEPTION_SP_EVENT	19
2575 #define BNXT_LINK_CFG_CHANGE_SP_EVENT	21
2576 #define BNXT_THERMAL_THRESHOLD_SP_EVENT	22
2577 #define BNXT_FW_ECHO_REQUEST_SP_EVENT	23
2578 #define BNXT_RESTART_ULP_SP_EVENT	24
2579 
2580 	struct delayed_work	fw_reset_task;
2581 	int			fw_reset_state;
2582 #define BNXT_FW_RESET_STATE_POLL_VF	1
2583 #define BNXT_FW_RESET_STATE_RESET_FW	2
2584 #define BNXT_FW_RESET_STATE_ENABLE_DEV	3
2585 #define BNXT_FW_RESET_STATE_POLL_FW	4
2586 #define BNXT_FW_RESET_STATE_OPENING	5
2587 #define BNXT_FW_RESET_STATE_POLL_FW_DOWN	6
2588 
2589 	u16			fw_reset_min_dsecs;
2590 #define BNXT_DFLT_FW_RST_MIN_DSECS	20
2591 	u16			fw_reset_max_dsecs;
2592 #define BNXT_DFLT_FW_RST_MAX_DSECS	60
2593 	unsigned long		fw_reset_timestamp;
2594 
2595 	struct bnxt_fw_health	*fw_health;
2596 
2597 	struct bnxt_hw_resc	hw_resc;
2598 	struct bnxt_pf_info	pf;
2599 	struct bnxt_ctx_mem_info	*ctx;
2600 #ifdef CONFIG_BNXT_SRIOV
2601 	int			nr_vfs;
2602 	struct bnxt_vf_info	vf;
2603 	wait_queue_head_t	sriov_cfg_wait;
2604 	bool			sriov_cfg;
2605 #define BNXT_SRIOV_CFG_WAIT_TMO	msecs_to_jiffies(10000)
2606 #endif
2607 
2608 #if BITS_PER_LONG == 32
2609 	/* ensure atomic 64-bit doorbell writes on 32-bit systems. */
2610 	spinlock_t		db_lock;
2611 #endif
2612 	int			db_offset;	/* db_offset within db_size */
2613 	int			db_size;
2614 
2615 #define BNXT_NTP_FLTR_MAX_FLTR	4096
2616 #define BNXT_MAX_FLTR		(BNXT_NTP_FLTR_MAX_FLTR + BNXT_L2_FLTR_MAX_FLTR)
2617 #define BNXT_NTP_FLTR_HASH_SIZE	512
2618 #define BNXT_NTP_FLTR_HASH_MASK	(BNXT_NTP_FLTR_HASH_SIZE - 1)
2619 	struct hlist_head	ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE];
2620 	spinlock_t		ntp_fltr_lock;	/* for hash table add, del */
2621 
2622 	unsigned long		*ntp_fltr_bmap;
2623 	int			ntp_fltr_count;
2624 	int			max_fltr;
2625 
2626 #define BNXT_L2_FLTR_MAX_FLTR	1024
2627 #define BNXT_L2_FLTR_HASH_SIZE	32
2628 #define BNXT_L2_FLTR_HASH_MASK	(BNXT_L2_FLTR_HASH_SIZE - 1)
2629 	struct hlist_head	l2_fltr_hash_tbl[BNXT_L2_FLTR_HASH_SIZE];
2630 
2631 	u32			hash_seed;
2632 	u64			toeplitz_prefix;
2633 
2634 	struct list_head	usr_fltr_list;
2635 
2636 	/* To protect link related settings during link changes and
2637 	 * ethtool settings changes.
2638 	 */
2639 	struct mutex		link_lock;
2640 	struct bnxt_link_info	link_info;
2641 	struct ethtool_keee	eee;
2642 	u32			lpi_tmr_lo;
2643 	u32			lpi_tmr_hi;
2644 
2645 	/* copied from flags and flags2 in hwrm_port_phy_qcaps_output */
2646 	u32			phy_flags;
2647 #define BNXT_PHY_FL_EEE_CAP		PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED
2648 #define BNXT_PHY_FL_EXT_LPBK		PORT_PHY_QCAPS_RESP_FLAGS_EXTERNAL_LPBK_SUPPORTED
2649 #define BNXT_PHY_FL_AN_PHY_LPBK		PORT_PHY_QCAPS_RESP_FLAGS_AUTONEG_LPBK_SUPPORTED
2650 #define BNXT_PHY_FL_SHARED_PORT_CFG	PORT_PHY_QCAPS_RESP_FLAGS_SHARED_PHY_CFG_SUPPORTED
2651 #define BNXT_PHY_FL_PORT_STATS_NO_RESET	PORT_PHY_QCAPS_RESP_FLAGS_CUMULATIVE_COUNTERS_ON_RESET
2652 #define BNXT_PHY_FL_NO_PHY_LPBK		PORT_PHY_QCAPS_RESP_FLAGS_LOCAL_LPBK_NOT_SUPPORTED
2653 #define BNXT_PHY_FL_FW_MANAGED_LKDN	PORT_PHY_QCAPS_RESP_FLAGS_FW_MANAGED_LINK_DOWN
2654 #define BNXT_PHY_FL_NO_FCS		PORT_PHY_QCAPS_RESP_FLAGS_NO_FCS
2655 #define BNXT_PHY_FL_NO_PAUSE		(PORT_PHY_QCAPS_RESP_FLAGS2_PAUSE_UNSUPPORTED << 8)
2656 #define BNXT_PHY_FL_NO_PFC		(PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED << 8)
2657 #define BNXT_PHY_FL_BANK_SEL		(PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED << 8)
2658 #define BNXT_PHY_FL_SPEEDS2		(PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED << 8)
2659 
2660 	u8			num_tests;
2661 	struct bnxt_test_info	*test_info;
2662 
2663 	u8			wol_filter_id;
2664 	u8			wol;
2665 
2666 	u8			num_leds;
2667 	struct bnxt_led_info	leds[BNXT_MAX_LED];
2668 	u16			dump_flag;
2669 #define BNXT_DUMP_LIVE		0
2670 #define BNXT_DUMP_CRASH		1
2671 #define BNXT_DUMP_DRIVER	2
2672 
2673 	struct bpf_prog		*xdp_prog;
2674 
2675 	struct bnxt_ptp_cfg	*ptp_cfg;
2676 	u8			ptp_all_rx_tstamp;
2677 
2678 	/* devlink interface and vf-rep structs */
2679 	struct devlink		*dl;
2680 	struct devlink_port	dl_port;
2681 	enum devlink_eswitch_mode eswitch_mode;
2682 	struct bnxt_vf_rep	**vf_reps; /* array of vf-rep ptrs */
2683 	u16			*cfa_code_map; /* cfa_code -> vf_idx map */
2684 	u8			dsn[8];
2685 	struct bnxt_tc_info	*tc_info;
2686 	struct list_head	tc_indr_block_list;
2687 	struct dentry		*debugfs_pdev;
2688 #ifdef CONFIG_BNXT_HWMON
2689 	struct device		*hwmon_dev;
2690 	u8			warn_thresh_temp;
2691 	u8			crit_thresh_temp;
2692 	u8			fatal_thresh_temp;
2693 	u8			shutdown_thresh_temp;
2694 #endif
2695 	u32			thermal_threshold_type;
2696 	enum board_idx		board_idx;
2697 
2698 	struct bnxt_ctx_pg_info	*fw_crash_mem;
2699 	u32			fw_crash_len;
2700 	struct bnxt_bs_trace_info bs_trace[BNXT_TRACE_MAX];
2701 };
2702 
2703 #define BNXT_NUM_RX_RING_STATS			8
2704 #define BNXT_NUM_TX_RING_STATS			8
2705 #define BNXT_NUM_TPA_RING_STATS			4
2706 #define BNXT_NUM_TPA_RING_STATS_P5		5
2707 #define BNXT_NUM_TPA_RING_STATS_P7		6
2708 
2709 #define BNXT_RING_STATS_SIZE_P5					\
2710 	((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS +	\
2711 	  BNXT_NUM_TPA_RING_STATS_P5) * 8)
2712 
2713 #define BNXT_RING_STATS_SIZE_P7					\
2714 	((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS +	\
2715 	  BNXT_NUM_TPA_RING_STATS_P7) * 8)
2716 
2717 #define BNXT_GET_RING_STATS64(sw, counter)		\
2718 	(*((sw) + offsetof(struct ctx_hw_stats, counter) / 8))
2719 
2720 #define BNXT_GET_RX_PORT_STATS64(sw, counter)		\
2721 	(*((sw) + offsetof(struct rx_port_stats, counter) / 8))
2722 
2723 #define BNXT_GET_TX_PORT_STATS64(sw, counter)		\
2724 	(*((sw) + offsetof(struct tx_port_stats, counter) / 8))
2725 
2726 #define BNXT_PORT_STATS_SIZE				\
2727 	(sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024)
2728 
2729 #define BNXT_TX_PORT_STATS_BYTE_OFFSET			\
2730 	(sizeof(struct rx_port_stats) + 512)
2731 
2732 #define BNXT_RX_STATS_OFFSET(counter)			\
2733 	(offsetof(struct rx_port_stats, counter) / 8)
2734 
2735 #define BNXT_TX_STATS_OFFSET(counter)			\
2736 	((offsetof(struct tx_port_stats, counter) +	\
2737 	  BNXT_TX_PORT_STATS_BYTE_OFFSET) / 8)
2738 
2739 #define BNXT_RX_STATS_EXT_OFFSET(counter)		\
2740 	(offsetof(struct rx_port_stats_ext, counter) / 8)
2741 
2742 #define BNXT_RX_STATS_EXT_NUM_LEGACY                   \
2743 	BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks)
2744 
2745 #define BNXT_TX_STATS_EXT_OFFSET(counter)		\
2746 	(offsetof(struct tx_port_stats_ext, counter) / 8)
2747 
2748 #define BNXT_HW_FEATURE_VLAN_ALL_RX				\
2749 	(NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX)
2750 #define BNXT_HW_FEATURE_VLAN_ALL_TX				\
2751 	(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX)
2752 
2753 #define I2C_DEV_ADDR_A0				0xa0
2754 #define I2C_DEV_ADDR_A2				0xa2
2755 #define SFF_DIAG_SUPPORT_OFFSET			0x5c
2756 #define SFF_MODULE_ID_SFP			0x3
2757 #define SFF_MODULE_ID_QSFP			0xc
2758 #define SFF_MODULE_ID_QSFP_PLUS			0xd
2759 #define SFF_MODULE_ID_QSFP28			0x11
2760 #define BNXT_MAX_PHY_I2C_RESP_SIZE		64
2761 
2762 static inline u32 bnxt_tx_avail(struct bnxt *bp,
2763 				const struct bnxt_tx_ring_info *txr)
2764 {
2765 	u32 used = READ_ONCE(txr->tx_prod) - READ_ONCE(txr->tx_cons);
2766 
2767 	return bp->tx_ring_size - (used & bp->tx_ring_mask);
2768 }
2769 
2770 static inline void bnxt_writeq(struct bnxt *bp, u64 val,
2771 			       volatile void __iomem *addr)
2772 {
2773 #if BITS_PER_LONG == 32
2774 	spin_lock(&bp->db_lock);
2775 	lo_hi_writeq(val, addr);
2776 	spin_unlock(&bp->db_lock);
2777 #else
2778 	writeq(val, addr);
2779 #endif
2780 }
2781 
2782 static inline void bnxt_writeq_relaxed(struct bnxt *bp, u64 val,
2783 				       volatile void __iomem *addr)
2784 {
2785 #if BITS_PER_LONG == 32
2786 	spin_lock(&bp->db_lock);
2787 	lo_hi_writeq_relaxed(val, addr);
2788 	spin_unlock(&bp->db_lock);
2789 #else
2790 	writeq_relaxed(val, addr);
2791 #endif
2792 }
2793 
2794 /* For TX and RX ring doorbells with no ordering guarantee*/
2795 static inline void bnxt_db_write_relaxed(struct bnxt *bp,
2796 					 struct bnxt_db_info *db, u32 idx)
2797 {
2798 	if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
2799 		bnxt_writeq_relaxed(bp, db->db_key64 | DB_RING_IDX(db, idx),
2800 				    db->doorbell);
2801 	} else {
2802 		u32 db_val = db->db_key32 | DB_RING_IDX(db, idx);
2803 
2804 		writel_relaxed(db_val, db->doorbell);
2805 		if (bp->flags & BNXT_FLAG_DOUBLE_DB)
2806 			writel_relaxed(db_val, db->doorbell);
2807 	}
2808 }
2809 
2810 /* For TX and RX ring doorbells */
2811 static inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db,
2812 				 u32 idx)
2813 {
2814 	if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
2815 		bnxt_writeq(bp, db->db_key64 | DB_RING_IDX(db, idx),
2816 			    db->doorbell);
2817 	} else {
2818 		u32 db_val = db->db_key32 | DB_RING_IDX(db, idx);
2819 
2820 		writel(db_val, db->doorbell);
2821 		if (bp->flags & BNXT_FLAG_DOUBLE_DB)
2822 			writel(db_val, db->doorbell);
2823 	}
2824 }
2825 
2826 /* Must hold rtnl_lock */
2827 static inline bool bnxt_sriov_cfg(struct bnxt *bp)
2828 {
2829 #if defined(CONFIG_BNXT_SRIOV)
2830 	return BNXT_PF(bp) && (bp->pf.active_vfs || bp->sriov_cfg);
2831 #else
2832 	return false;
2833 #endif
2834 }
2835 
2836 extern const u16 bnxt_bstore_to_trace[];
2837 extern const u16 bnxt_lhint_arr[];
2838 
2839 int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
2840 		       u16 prod, gfp_t gfp);
2841 void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data);
2842 u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx);
2843 bool bnxt_bs_trace_avail(struct bnxt *bp, u16 type);
2844 void bnxt_set_tpa_flags(struct bnxt *bp);
2845 void bnxt_set_ring_params(struct bnxt *);
2846 int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
2847 void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr);
2848 void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr);
2849 int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap,
2850 			    int bmap_size, bool async_only);
2851 int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp);
2852 void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr);
2853 struct bnxt_l2_filter *bnxt_alloc_new_l2_filter(struct bnxt *bp,
2854 						struct bnxt_l2_key *key,
2855 						u16 flags);
2856 int bnxt_hwrm_l2_filter_free(struct bnxt *bp, struct bnxt_l2_filter *fltr);
2857 int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr);
2858 int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
2859 				     struct bnxt_ntuple_filter *fltr);
2860 int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
2861 				      struct bnxt_ntuple_filter *fltr);
2862 int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2863 			   u32 tpa_flags);
2864 void bnxt_fill_ipv6_mask(__be32 mask[4]);
2865 void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp,
2866 				 struct ethtool_rxfh_context *rss_ctx);
2867 int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
2868 int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic);
2869 int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2870 			 unsigned int start_rx_ring_idx,
2871 			 unsigned int nr_rings);
2872 int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
2873 int bnxt_nq_rings_in_use(struct bnxt *bp);
2874 int bnxt_hwrm_set_coal(struct bnxt *);
2875 size_t bnxt_copy_ctx_mem(struct bnxt *bp, struct bnxt_ctx_mem_type *ctxm,
2876 			 void *buf, size_t offset);
2877 void bnxt_free_ctx_mem(struct bnxt *bp, bool force);
2878 int bnxt_num_tx_to_cp(struct bnxt *bp, int tx);
2879 unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
2880 unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);
2881 unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
2882 unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
2883 int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init);
2884 void bnxt_tx_disable(struct bnxt *bp);
2885 void bnxt_tx_enable(struct bnxt *bp);
2886 void bnxt_sched_reset_txr(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
2887 			  u16 curr);
2888 void bnxt_report_link(struct bnxt *bp);
2889 int bnxt_update_link(struct bnxt *bp, bool chng_link_state);
2890 int bnxt_hwrm_set_pause(struct bnxt *);
2891 int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
2892 int bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset);
2893 int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
2894 int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
2895 int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);
2896 int bnxt_hwrm_func_qcaps(struct bnxt *bp);
2897 int bnxt_hwrm_fw_set_time(struct bnxt *);
2898 int bnxt_hwrm_vnic_update(struct bnxt *bp, struct bnxt_vnic_info *vnic,
2899 			  u8 valid);
2900 int bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic);
2901 int __bnxt_setup_vnic_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic);
2902 void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
2903 			  bool all);
2904 int bnxt_open_nic(struct bnxt *, bool, bool);
2905 int bnxt_half_open_nic(struct bnxt *bp);
2906 void bnxt_half_close_nic(struct bnxt *bp);
2907 void bnxt_reenable_sriov(struct bnxt *bp);
2908 void bnxt_close_nic(struct bnxt *, bool, bool);
2909 void bnxt_get_ring_err_stats(struct bnxt *bp,
2910 			     struct bnxt_total_ring_err_stats *stats);
2911 bool bnxt_rfs_capable(struct bnxt *bp, bool new_rss_ctx);
2912 int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
2913 			 u32 *reg_buf);
2914 void bnxt_fw_exception(struct bnxt *bp);
2915 void bnxt_fw_reset(struct bnxt *bp);
2916 int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
2917 		     int tx_xdp);
2918 int bnxt_fw_init_one(struct bnxt *bp);
2919 bool bnxt_hwrm_reset_permitted(struct bnxt *bp);
2920 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
2921 struct bnxt_ntuple_filter *bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp,
2922 				struct bnxt_ntuple_filter *fltr, u32 idx);
2923 u32 bnxt_get_ntp_filter_idx(struct bnxt *bp, struct flow_keys *fkeys,
2924 			    const struct sk_buff *skb);
2925 int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr,
2926 			   u32 idx);
2927 void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr);
2928 int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
2929 int bnxt_restore_pf_fw_resources(struct bnxt *bp);
2930 int bnxt_get_port_parent_id(struct net_device *dev,
2931 			    struct netdev_phys_item_id *ppid);
2932 void bnxt_dim_work(struct work_struct *work);
2933 int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
2934 void bnxt_print_device_info(struct bnxt *bp);
2935 #endif
2936