blob: c61af57596c4b3199baa56d863a60f3bec6d5fe4 [file] [log] [blame]
Michael Chanc0c050c2015-10-22 16:01:17 -04001/* Broadcom NetXtreme-C/E network driver.
2 *
Michael Chan11f15ed2016-04-05 14:08:55 -04003 * Copyright (c) 2014-2016 Broadcom Corporation
Michael Chan894aa692018-01-17 03:21:03 -05004 * Copyright (c) 2016-2018 Broadcom Limited
Michael Chanc0c050c2015-10-22 16:01:17 -04005 *
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"
Michael Chan31d357c2018-10-14 07:02:37 -040015#define DRV_MODULE_VERSION "1.10.0"
Michael Chanc0c050c2015-10-22 16:01:17 -040016
Michael Chanc1935542015-12-27 18:19:28 -050017#define DRV_VER_MAJ 1
Michael Chan31d357c2018-10-14 07:02:37 -040018#define DRV_VER_MIN 10
19#define DRV_VER_UPD 0
Michael Chanc0c050c2015-10-22 16:01:17 -040020
Florian Westphal282ccf62017-03-29 17:17:31 +020021#include <linux/interrupt.h>
Sathya Perla2ae74082017-08-28 13:40:33 -040022#include <linux/rhashtable.h>
Michael Chand6295222019-05-22 19:12:56 -040023#include <linux/crash_dump.h>
Sathya Perla4ab0c6a2017-07-24 12:34:27 -040024#include <net/devlink.h>
Sathya Perlaee5c7fb2017-07-24 12:34:28 -040025#include <net/dst_metadata.h>
Jesper Dangaard Brouer96a86042018-01-03 11:25:44 +010026#include <net/xdp.h>
Tal Gilboa4f75da32019-01-10 17:33:17 +020027#include <linux/dim.h>
Florian Westphal282ccf62017-03-29 17:17:31 +020028
Andy Gospodarek322b87c2019-07-08 17:53:04 -040029struct page_pool;
30
Michael Chanc0c050c2015-10-22 16:01:17 -040031struct tx_bd {
32 __le32 tx_bd_len_flags_type;
33 #define TX_BD_TYPE (0x3f << 0)
34 #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0)
35 #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0)
36 #define TX_BD_FLAGS_PACKET_END (1 << 6)
37 #define TX_BD_FLAGS_NO_CMPL (1 << 7)
38 #define TX_BD_FLAGS_BD_CNT (0x1f << 8)
39 #define TX_BD_FLAGS_BD_CNT_SHIFT 8
40 #define TX_BD_FLAGS_LHINT (3 << 13)
41 #define TX_BD_FLAGS_LHINT_SHIFT 13
42 #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13)
43 #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13)
44 #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13)
45 #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13)
46 #define TX_BD_FLAGS_COAL_NOW (1 << 15)
47 #define TX_BD_LEN (0xffff << 16)
48 #define TX_BD_LEN_SHIFT 16
49
50 u32 tx_bd_opaque;
51 __le64 tx_bd_haddr;
52} __packed;
53
54struct tx_bd_ext {
55 __le32 tx_bd_hsize_lflags;
56 #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)
57 #define TX_BD_FLAGS_IP_CKSUM (1 << 1)
58 #define TX_BD_FLAGS_NO_CRC (1 << 2)
59 #define TX_BD_FLAGS_STAMP (1 << 3)
60 #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4)
61 #define TX_BD_FLAGS_LSO (1 << 5)
62 #define TX_BD_FLAGS_IPID_FMT (1 << 6)
63 #define TX_BD_FLAGS_T_IPID (1 << 7)
64 #define TX_BD_HSIZE (0xff << 16)
65 #define TX_BD_HSIZE_SHIFT 16
66
67 __le32 tx_bd_mss;
68 __le32 tx_bd_cfa_action;
69 #define TX_BD_CFA_ACTION (0xffff << 16)
70 #define TX_BD_CFA_ACTION_SHIFT 16
71
72 __le32 tx_bd_cfa_meta;
73 #define TX_BD_CFA_META_MASK 0xfffffff
74 #define TX_BD_CFA_META_VID_MASK 0xfff
75 #define TX_BD_CFA_META_PRI_MASK (0xf << 12)
76 #define TX_BD_CFA_META_PRI_SHIFT 12
77 #define TX_BD_CFA_META_TPID_MASK (3 << 16)
78 #define TX_BD_CFA_META_TPID_SHIFT 16
79 #define TX_BD_CFA_META_KEY (0xf << 28)
80 #define TX_BD_CFA_META_KEY_SHIFT 28
81 #define TX_BD_CFA_META_KEY_VLAN (1 << 28)
82};
83
84struct rx_bd {
85 __le32 rx_bd_len_flags_type;
86 #define RX_BD_TYPE (0x3f << 0)
87 #define RX_BD_TYPE_RX_PACKET_BD 0x4
88 #define RX_BD_TYPE_RX_BUFFER_BD 0x5
89 #define RX_BD_TYPE_RX_AGG_BD 0x6
90 #define RX_BD_TYPE_16B_BD_SIZE (0 << 4)
91 #define RX_BD_TYPE_32B_BD_SIZE (1 << 4)
92 #define RX_BD_TYPE_48B_BD_SIZE (2 << 4)
93 #define RX_BD_TYPE_64B_BD_SIZE (3 << 4)
94 #define RX_BD_FLAGS_SOP (1 << 6)
95 #define RX_BD_FLAGS_EOP (1 << 7)
96 #define RX_BD_FLAGS_BUFFERS (3 << 8)
97 #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8)
98 #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8)
99 #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8)
100 #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8)
101 #define RX_BD_LEN (0xffff << 16)
102 #define RX_BD_LEN_SHIFT 16
103
104 u32 rx_bd_opaque;
105 __le64 rx_bd_haddr;
106};
107
108struct tx_cmp {
109 __le32 tx_cmp_flags_type;
110 #define CMP_TYPE (0x3f << 0)
111 #define CMP_TYPE_TX_L2_CMP 0
112 #define CMP_TYPE_RX_L2_CMP 17
113 #define CMP_TYPE_RX_AGG_CMP 18
114 #define CMP_TYPE_RX_L2_TPA_START_CMP 19
115 #define CMP_TYPE_RX_L2_TPA_END_CMP 21
Michael Chan218a8a72019-07-29 06:10:19 -0400116 #define CMP_TYPE_RX_TPA_AGG_CMP 22
Michael Chanc0c050c2015-10-22 16:01:17 -0400117 #define CMP_TYPE_STATUS_CMP 32
118 #define CMP_TYPE_REMOTE_DRIVER_REQ 34
119 #define CMP_TYPE_REMOTE_DRIVER_RESP 36
120 #define CMP_TYPE_ERROR_STATUS 48
Michael Chan441cabb2016-09-19 03:58:02 -0400121 #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL
122 #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL
123 #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
124 #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL
125 #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL
Michael Chanc0c050c2015-10-22 16:01:17 -0400126
127 #define TX_CMP_FLAGS_ERROR (1 << 6)
128 #define TX_CMP_FLAGS_PUSH (1 << 7)
129
130 u32 tx_cmp_opaque;
131 __le32 tx_cmp_errors_v;
132 #define TX_CMP_V (1 << 0)
133 #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1)
134 #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0
135 #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2
136 #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4
137 #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5
138 #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4)
139 #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5)
140 #define TX_CMP_ERRORS_DMA_ERROR (1 << 6)
141 #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7)
142
143 __le32 tx_cmp_unsed_3;
144};
145
146struct rx_cmp {
147 __le32 rx_cmp_len_flags_type;
148 #define RX_CMP_CMP_TYPE (0x3f << 0)
149 #define RX_CMP_FLAGS_ERROR (1 << 6)
150 #define RX_CMP_FLAGS_PLACEMENT (7 << 7)
151 #define RX_CMP_FLAGS_RSS_VALID (1 << 10)
152 #define RX_CMP_FLAGS_UNUSED (1 << 11)
153 #define RX_CMP_FLAGS_ITYPES_SHIFT 12
154 #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
155 #define RX_CMP_FLAGS_ITYPE_IP (1 << 12)
156 #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12)
157 #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)
158 #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)
159 #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12)
160 #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)
161 #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)
162 #define RX_CMP_LEN (0xffff << 16)
163 #define RX_CMP_LEN_SHIFT 16
164
165 u32 rx_cmp_opaque;
166 __le32 rx_cmp_misc_v1;
167 #define RX_CMP_V1 (1 << 0)
168 #define RX_CMP_AGG_BUFS (0x1f << 1)
169 #define RX_CMP_AGG_BUFS_SHIFT 1
170 #define RX_CMP_RSS_HASH_TYPE (0x7f << 9)
171 #define RX_CMP_RSS_HASH_TYPE_SHIFT 9
172 #define RX_CMP_PAYLOAD_OFFSET (0xff << 16)
173 #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16
174
175 __le32 rx_cmp_rss_hash;
176};
177
178#define RX_CMP_HASH_VALID(rxcmp) \
179 ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
180
Michael Chan614388c2015-11-05 16:25:48 -0500181#define RSS_PROFILE_ID_MASK 0x1f
182
Michael Chanc0c050c2015-10-22 16:01:17 -0400183#define RX_CMP_HASH_TYPE(rxcmp) \
Michael Chan614388c2015-11-05 16:25:48 -0500184 (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
185 RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
Michael Chanc0c050c2015-10-22 16:01:17 -0400186
187struct rx_cmp_ext {
188 __le32 rx_cmp_flags2;
189 #define RX_CMP_FLAGS2_IP_CS_CALC 0x1
190 #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
191 #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
192 #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
193 #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4)
194 __le32 rx_cmp_meta_data;
Michael Chaned7bc6022018-03-09 23:46:06 -0500195 #define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff
Michael Chanc0c050c2015-10-22 16:01:17 -0400196 #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
197 #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000
198 #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16
199 __le32 rx_cmp_cfa_code_errors_v2;
200 #define RX_CMP_V (1 << 0)
201 #define RX_CMPL_ERRORS_MASK (0x7fff << 1)
202 #define RX_CMPL_ERRORS_SFT 1
203 #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1)
204 #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
205 #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1)
206 #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1)
207 #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
208 #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4)
209 #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5)
210 #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6)
211 #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7)
212 #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8)
213 #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9)
214 #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9)
215 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9)
216 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9)
217 #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9)
218 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9)
219 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9)
220 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9)
221 #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12)
222 #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12)
223 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12)
224 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12)
225 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12)
226 #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12)
227 #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12)
228 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12)
229 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12)
230 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12)
231
232 #define RX_CMPL_CFA_CODE_MASK (0xffff << 16)
233 #define RX_CMPL_CFA_CODE_SFT 16
234
235 __le32 rx_cmp_unused3;
236};
237
238#define RX_CMP_L2_ERRORS \
239 cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR)
240
241#define RX_CMP_L4_CS_BITS \
242 (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC))
243
244#define RX_CMP_L4_CS_ERR_BITS \
245 (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR))
246
247#define RX_CMP_L4_CS_OK(rxcmp1) \
248 (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \
249 !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS))
250
251#define RX_CMP_ENCAP(rxcmp1) \
252 ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \
253 RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3)
254
Sathya Perlaee5c7fb2017-07-24 12:34:28 -0400255#define RX_CMP_CFA_CODE(rxcmpl1) \
256 ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \
257 RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT)
258
Michael Chanc0c050c2015-10-22 16:01:17 -0400259struct rx_agg_cmp {
260 __le32 rx_agg_cmp_len_flags_type;
261 #define RX_AGG_CMP_TYPE (0x3f << 0)
262 #define RX_AGG_CMP_LEN (0xffff << 16)
263 #define RX_AGG_CMP_LEN_SHIFT 16
264 u32 rx_agg_cmp_opaque;
265 __le32 rx_agg_cmp_v;
266 #define RX_AGG_CMP_V (1 << 0)
Michael Chan218a8a72019-07-29 06:10:19 -0400267 #define RX_AGG_CMP_AGG_ID (0xffff << 16)
268 #define RX_AGG_CMP_AGG_ID_SHIFT 16
Michael Chanc0c050c2015-10-22 16:01:17 -0400269 __le32 rx_agg_cmp_unused;
270};
271
Michael Chan218a8a72019-07-29 06:10:19 -0400272#define TPA_AGG_AGG_ID(rx_agg) \
273 ((le32_to_cpu((rx_agg)->rx_agg_cmp_v) & \
274 RX_AGG_CMP_AGG_ID) >> RX_AGG_CMP_AGG_ID_SHIFT)
275
Michael Chanc0c050c2015-10-22 16:01:17 -0400276struct rx_tpa_start_cmp {
277 __le32 rx_tpa_start_cmp_len_flags_type;
278 #define RX_TPA_START_CMP_TYPE (0x3f << 0)
279 #define RX_TPA_START_CMP_FLAGS (0x3ff << 6)
280 #define RX_TPA_START_CMP_FLAGS_SHIFT 6
Michael Chan218a8a72019-07-29 06:10:19 -0400281 #define RX_TPA_START_CMP_FLAGS_ERROR (0x1 << 6)
Michael Chanc0c050c2015-10-22 16:01:17 -0400282 #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7)
283 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7
284 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
285 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
286 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
287 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
288 #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10)
Michael Chan218a8a72019-07-29 06:10:19 -0400289 #define RX_TPA_START_CMP_FLAGS_TIMESTAMP (0x1 << 11)
Michael Chanc0c050c2015-10-22 16:01:17 -0400290 #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12)
291 #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12
292 #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
293 #define RX_TPA_START_CMP_LEN (0xffff << 16)
294 #define RX_TPA_START_CMP_LEN_SHIFT 16
295
296 u32 rx_tpa_start_cmp_opaque;
297 __le32 rx_tpa_start_cmp_misc_v1;
298 #define RX_TPA_START_CMP_V1 (0x1 << 0)
299 #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9)
300 #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9
301 #define RX_TPA_START_CMP_AGG_ID (0x7f << 25)
302 #define RX_TPA_START_CMP_AGG_ID_SHIFT 25
Michael Chan218a8a72019-07-29 06:10:19 -0400303 #define RX_TPA_START_CMP_AGG_ID_P5 (0xffff << 16)
304 #define RX_TPA_START_CMP_AGG_ID_SHIFT_P5 16
Michael Chanc0c050c2015-10-22 16:01:17 -0400305
306 __le32 rx_tpa_start_cmp_rss_hash;
307};
308
309#define TPA_START_HASH_VALID(rx_tpa_start) \
310 ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \
311 cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
312
313#define TPA_START_HASH_TYPE(rx_tpa_start) \
Michael Chan614388c2015-11-05 16:25:48 -0500314 (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
315 RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
316 RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
Michael Chanc0c050c2015-10-22 16:01:17 -0400317
318#define TPA_START_AGG_ID(rx_tpa_start) \
319 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
320 RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT)
321
Michael Chan218a8a72019-07-29 06:10:19 -0400322#define TPA_START_AGG_ID_P5(rx_tpa_start) \
323 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
324 RX_TPA_START_CMP_AGG_ID_P5) >> RX_TPA_START_CMP_AGG_ID_SHIFT_P5)
325
326#define TPA_START_ERROR(rx_tpa_start) \
327 ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \
328 cpu_to_le32(RX_TPA_START_CMP_FLAGS_ERROR))
329
Michael Chanc0c050c2015-10-22 16:01:17 -0400330struct rx_tpa_start_cmp_ext {
331 __le32 rx_tpa_start_cmp_flags2;
332 #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0)
333 #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
334 #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
335 #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
Michael Chan94758f82016-06-13 02:25:35 -0400336 #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8)
Michael Chan218a8a72019-07-29 06:10:19 -0400337 #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_VALID (0x1 << 9)
338 #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT (0x3 << 10)
339 #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT_SHIFT 10
340 #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL (0xffff << 16)
341 #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_SHIFT 16
Michael Chanc0c050c2015-10-22 16:01:17 -0400342
343 __le32 rx_tpa_start_cmp_metadata;
344 __le32 rx_tpa_start_cmp_cfa_code_v2;
345 #define RX_TPA_START_CMP_V2 (0x1 << 0)
Michael Chan218a8a72019-07-29 06:10:19 -0400346 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK (0x7 << 1)
347 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT 1
348 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
349 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
350 #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1)
Michael Chanc0c050c2015-10-22 16:01:17 -0400351 #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16)
352 #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16
Michael Chan94758f82016-06-13 02:25:35 -0400353 __le32 rx_tpa_start_cmp_hdr_info;
Michael Chanc0c050c2015-10-22 16:01:17 -0400354};
355
Sathya Perlaee5c7fb2017-07-24 12:34:28 -0400356#define TPA_START_CFA_CODE(rx_tpa_start) \
357 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \
358 RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT)
359
Michael Chan50f011b2018-08-05 16:51:51 -0400360#define TPA_START_IS_IPV6(rx_tpa_start) \
361 (!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 & \
362 cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE)))
363
Michael Chan218a8a72019-07-29 06:10:19 -0400364#define TPA_START_ERROR_CODE(rx_tpa_start) \
365 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \
366 RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK) >> \
367 RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT)
368
Michael Chanc0c050c2015-10-22 16:01:17 -0400369struct rx_tpa_end_cmp {
370 __le32 rx_tpa_end_cmp_len_flags_type;
371 #define RX_TPA_END_CMP_TYPE (0x3f << 0)
372 #define RX_TPA_END_CMP_FLAGS (0x3ff << 6)
373 #define RX_TPA_END_CMP_FLAGS_SHIFT 6
374 #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7)
375 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7
376 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
377 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
378 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
379 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
380 #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10)
381 #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12)
382 #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12
383 #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
384 #define RX_TPA_END_CMP_LEN (0xffff << 16)
385 #define RX_TPA_END_CMP_LEN_SHIFT 16
386
387 u32 rx_tpa_end_cmp_opaque;
388 __le32 rx_tpa_end_cmp_misc_v1;
389 #define RX_TPA_END_CMP_V1 (0x1 << 0)
390 #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1)
391 #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1
392 #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8)
393 #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8
394 #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16)
395 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16
396 #define RX_TPA_END_CMP_AGG_ID (0x7f << 25)
397 #define RX_TPA_END_CMP_AGG_ID_SHIFT 25
Michael Chan218a8a72019-07-29 06:10:19 -0400398 #define RX_TPA_END_CMP_AGG_ID_P5 (0xffff << 16)
399 #define RX_TPA_END_CMP_AGG_ID_SHIFT_P5 16
Michael Chanc0c050c2015-10-22 16:01:17 -0400400
401 __le32 rx_tpa_end_cmp_tsdelta;
402 #define RX_TPA_END_GRO_TS (0x1 << 31)
403};
404
405#define TPA_END_AGG_ID(rx_tpa_end) \
406 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
407 RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT)
408
Michael Chan218a8a72019-07-29 06:10:19 -0400409#define TPA_END_AGG_ID_P5(rx_tpa_end) \
410 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
411 RX_TPA_END_CMP_AGG_ID_P5) >> RX_TPA_END_CMP_AGG_ID_SHIFT_P5)
412
413#define TPA_END_PAYLOAD_OFF(rx_tpa_end) \
414 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
415 RX_TPA_END_CMP_PAYLOAD_OFFSET) >> RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT)
416
417#define TPA_END_AGG_BUFS(rx_tpa_end) \
418 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
419 RX_TPA_END_CMP_AGG_BUFS) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT)
420
Michael Chanc0c050c2015-10-22 16:01:17 -0400421#define TPA_END_TPA_SEGS(rx_tpa_end) \
422 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
423 RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
424
425#define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \
426 cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \
427 RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS)
428
429#define TPA_END_GRO(rx_tpa_end) \
430 ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \
431 RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO)
432
433#define TPA_END_GRO_TS(rx_tpa_end) \
Michael Chana58a3e62016-07-01 18:46:20 -0400434 (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \
435 cpu_to_le32(RX_TPA_END_GRO_TS)))
Michael Chanc0c050c2015-10-22 16:01:17 -0400436
437struct rx_tpa_end_cmp_ext {
438 __le32 rx_tpa_end_cmp_dup_acks;
439 #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0)
Michael Chan218a8a72019-07-29 06:10:19 -0400440 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_P5 (0xff << 16)
441 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5 16
442 #define RX_TPA_END_CMP_AGG_BUFS_P5 (0xff << 24)
443 #define RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5 24
Michael Chanc0c050c2015-10-22 16:01:17 -0400444
445 __le32 rx_tpa_end_cmp_seg_len;
446 #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0)
447
448 __le32 rx_tpa_end_cmp_errors_v2;
449 #define RX_TPA_END_CMP_V2 (0x1 << 0)
Michael Chan69c149e2017-06-23 14:01:00 -0400450 #define RX_TPA_END_CMP_ERRORS (0x3 << 1)
Michael Chan218a8a72019-07-29 06:10:19 -0400451 #define RX_TPA_END_CMP_ERRORS_P5 (0x7 << 1)
Michael Chanc0c050c2015-10-22 16:01:17 -0400452 #define RX_TPA_END_CMPL_ERRORS_SHIFT 1
Michael Chan218a8a72019-07-29 06:10:19 -0400453 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
454 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1)
455 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
456 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_RSV_ERROR (0x4 << 1)
457 #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1)
Michael Chanc0c050c2015-10-22 16:01:17 -0400458
459 u32 rx_tpa_end_cmp_start_opaque;
460};
461
Michael Chan69c149e2017-06-23 14:01:00 -0400462#define TPA_END_ERRORS(rx_tpa_end_ext) \
463 ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \
464 cpu_to_le32(RX_TPA_END_CMP_ERRORS))
465
Michael Chan218a8a72019-07-29 06:10:19 -0400466#define TPA_END_PAYLOAD_OFF_P5(rx_tpa_end_ext) \
467 ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \
468 RX_TPA_END_CMP_PAYLOAD_OFFSET_P5) >> \
469 RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5)
470
471#define TPA_END_AGG_BUFS_P5(rx_tpa_end_ext) \
472 ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \
473 RX_TPA_END_CMP_AGG_BUFS_P5) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5)
474
Michael Chane38287b2018-10-14 07:02:45 -0400475struct nqe_cn {
476 __le16 type;
477 #define NQ_CN_TYPE_MASK 0x3fUL
478 #define NQ_CN_TYPE_SFT 0
479 #define NQ_CN_TYPE_CQ_NOTIFICATION 0x30UL
480 #define NQ_CN_TYPE_LAST NQ_CN_TYPE_CQ_NOTIFICATION
481 __le16 reserved16;
482 __le32 cq_handle_low;
483 __le32 v;
484 #define NQ_CN_V 0x1UL
485 __le32 cq_handle_high;
486};
487
Michael Chanc0c050c2015-10-22 16:01:17 -0400488#define DB_IDX_MASK 0xffffff
489#define DB_IDX_VALID (0x1 << 26)
490#define DB_IRQ_DIS (0x1 << 27)
491#define DB_KEY_TX (0x0 << 28)
492#define DB_KEY_RX (0x1 << 28)
493#define DB_KEY_CP (0x2 << 28)
494#define DB_KEY_ST (0x3 << 28)
495#define DB_KEY_TX_PUSH (0x4 << 28)
496#define DB_LONG_TX_PUSH (0x2 << 24)
497
Michael Chane4060d32016-12-07 00:26:19 -0500498#define BNXT_MIN_ROCE_CP_RINGS 2
499#define BNXT_MIN_ROCE_STAT_CTXS 1
500
Michael Chane38287b2018-10-14 07:02:45 -0400501/* 64-bit doorbell */
502#define DBR_INDEX_MASK 0x0000000000ffffffULL
503#define DBR_XID_MASK 0x000fffff00000000ULL
504#define DBR_XID_SFT 32
505#define DBR_PATH_L2 (0x1ULL << 56)
506#define DBR_TYPE_SQ (0x0ULL << 60)
507#define DBR_TYPE_RQ (0x1ULL << 60)
508#define DBR_TYPE_SRQ (0x2ULL << 60)
509#define DBR_TYPE_SRQ_ARM (0x3ULL << 60)
510#define DBR_TYPE_CQ (0x4ULL << 60)
511#define DBR_TYPE_CQ_ARMSE (0x5ULL << 60)
512#define DBR_TYPE_CQ_ARMALL (0x6ULL << 60)
513#define DBR_TYPE_CQ_ARMENA (0x7ULL << 60)
514#define DBR_TYPE_SRQ_ARMENA (0x8ULL << 60)
515#define DBR_TYPE_CQ_CUTOFF_ACK (0x9ULL << 60)
516#define DBR_TYPE_NQ (0xaULL << 60)
517#define DBR_TYPE_NQ_ARM (0xbULL << 60)
518#define DBR_TYPE_NULL (0xfULL << 60)
519
Michael Chanc0c050c2015-10-22 16:01:17 -0400520#define INVALID_HW_RING_ID ((u16)-1)
521
Michael Chanc0c050c2015-10-22 16:01:17 -0400522/* The hardware supports certain page sizes. Use the supported page sizes
523 * to allocate the rings.
524 */
525#if (PAGE_SHIFT < 12)
526#define BNXT_PAGE_SHIFT 12
527#elif (PAGE_SHIFT <= 13)
528#define BNXT_PAGE_SHIFT PAGE_SHIFT
529#elif (PAGE_SHIFT < 16)
530#define BNXT_PAGE_SHIFT 13
531#else
532#define BNXT_PAGE_SHIFT 16
533#endif
534
535#define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT)
536
Michael Chan2839f282016-04-25 02:30:50 -0400537/* The RXBD length is 16-bit so we can only support page sizes < 64K */
538#if (PAGE_SHIFT > 15)
539#define BNXT_RX_PAGE_SHIFT 15
540#else
541#define BNXT_RX_PAGE_SHIFT PAGE_SHIFT
542#endif
543
544#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
545
Michael Chanc61fb992017-02-06 16:55:36 -0500546#define BNXT_MAX_MTU 9500
547#define BNXT_MAX_PAGE_MODE_MTU \
Michael Chanc6d30e82017-02-06 16:55:42 -0500548 ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \
549 XDP_PACKET_HEADROOM)
Michael Chanc61fb992017-02-06 16:55:36 -0500550
Michael Chan4ffcd582016-09-19 03:58:07 -0400551#define BNXT_MIN_PKT_SIZE 52
Michael Chanc0c050c2015-10-22 16:01:17 -0400552
Michael Chan51dd55b2016-02-10 17:33:50 -0500553#define BNXT_DEFAULT_RX_RING_SIZE 511
554#define BNXT_DEFAULT_TX_RING_SIZE 511
Michael Chanc0c050c2015-10-22 16:01:17 -0400555
556#define MAX_TPA 64
Michael Chan79632e92019-07-29 06:10:21 -0400557#define MAX_TPA_P5 256
Michael Chanec4d8e72019-07-29 06:10:26 -0400558#define MAX_TPA_P5_MASK (MAX_TPA_P5 - 1)
Michael Chan79632e92019-07-29 06:10:21 -0400559#define MAX_TPA_SEGS_P5 0x3f
Michael Chanc0c050c2015-10-22 16:01:17 -0400560
Michael Chand0a42d62016-05-15 03:04:46 -0400561#if (BNXT_PAGE_SHIFT == 16)
562#define MAX_RX_PAGES 1
563#define MAX_RX_AGG_PAGES 4
564#define MAX_TX_PAGES 1
565#define MAX_CP_PAGES 8
566#else
Michael Chanc0c050c2015-10-22 16:01:17 -0400567#define MAX_RX_PAGES 8
568#define MAX_RX_AGG_PAGES 32
569#define MAX_TX_PAGES 8
570#define MAX_CP_PAGES 64
Michael Chand0a42d62016-05-15 03:04:46 -0400571#endif
Michael Chanc0c050c2015-10-22 16:01:17 -0400572
573#define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd))
574#define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd))
575#define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp))
576
577#define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT)
578#define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
579
580#define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT)
581
582#define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT)
583#define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
584
585#define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT)
586
587#define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1)
588#define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
589#define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1)
590
591#define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
592#define RX_IDX(x) ((x) & (RX_DESC_CNT - 1))
593
594#define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
595#define TX_IDX(x) ((x) & (TX_DESC_CNT - 1))
596
597#define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
598#define CP_IDX(x) ((x) & (CP_DESC_CNT - 1))
599
600#define TX_CMP_VALID(txcmp, raw_cons) \
601 (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \
602 !((raw_cons) & bp->cp_bit))
603
604#define RX_CMP_VALID(rxcmp1, raw_cons) \
605 (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
606 !((raw_cons) & bp->cp_bit))
607
608#define RX_AGG_CMP_VALID(agg, raw_cons) \
609 (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \
610 !((raw_cons) & bp->cp_bit))
611
Michael Chan0fcec982018-10-14 07:02:58 -0400612#define NQ_CMP_VALID(nqcmp, raw_cons) \
613 (!!((nqcmp)->v & cpu_to_le32(NQ_CN_V)) == !((raw_cons) & bp->cp_bit))
614
Michael Chanc0c050c2015-10-22 16:01:17 -0400615#define TX_CMP_TYPE(txcmp) \
616 (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
617
618#define RX_CMP_TYPE(rxcmp) \
619 (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE)
620
621#define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask)
622
623#define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask)
624
625#define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask)
626
627#define ADV_RAW_CMP(idx, n) ((idx) + (n))
628#define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
629#define RING_CMP(idx) ((idx) & bp->cp_ring_mask)
630#define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
631
Michael Chane6ef2692016-03-28 19:46:05 -0400632#define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
Deepak Khungare605db82017-05-29 19:06:04 -0400633#define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input)
Michael Chanff4fe812016-02-26 04:00:04 -0500634#define DFLT_HWRM_CMD_TIMEOUT 500
635#define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
Michael Chanc0c050c2015-10-22 16:01:17 -0400636#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
637#define HWRM_RESP_ERR_CODE_MASK 0xffff
Michael Chana8643e12016-02-26 04:00:05 -0500638#define HWRM_RESP_LEN_OFFSET 4
Michael Chanc0c050c2015-10-22 16:01:17 -0400639#define HWRM_RESP_LEN_MASK 0xffff0000
640#define HWRM_RESP_LEN_SFT 16
641#define HWRM_RESP_VALID_MASK 0xff000000
642#define BNXT_HWRM_REQ_MAX_SIZE 128
643#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
644 BNXT_HWRM_REQ_MAX_SIZE)
Andy Gospodarek9751e8e2018-04-26 17:44:39 -0400645#define HWRM_SHORT_MIN_TIMEOUT 3
646#define HWRM_SHORT_MAX_TIMEOUT 10
647#define HWRM_SHORT_TIMEOUT_COUNTER 5
648
649#define HWRM_MIN_TIMEOUT 25
650#define HWRM_MAX_TIMEOUT 40
Michael Chanc0c050c2015-10-22 16:01:17 -0400651
Michael Chancc559c12018-05-08 03:18:38 -0400652#define HWRM_TOTAL_TIMEOUT(n) (((n) <= HWRM_SHORT_TIMEOUT_COUNTER) ? \
653 ((n) * HWRM_SHORT_MIN_TIMEOUT) : \
654 (HWRM_SHORT_TIMEOUT_COUNTER * HWRM_SHORT_MIN_TIMEOUT + \
655 ((n) - HWRM_SHORT_TIMEOUT_COUNTER) * HWRM_MIN_TIMEOUT))
656
Michael Chan0000b812019-02-20 19:07:32 -0500657#define HWRM_VALID_BIT_DELAY_USEC 150
Michael Chancc559c12018-05-08 03:18:38 -0400658
Venkat Duvvuru760b6d32018-12-20 03:38:48 -0500659#define BNXT_HWRM_CHNL_CHIMP 0
660#define BNXT_HWRM_CHNL_KONG 1
661
Andy Gospodarekf18c2b72019-07-08 17:53:03 -0400662#define BNXT_RX_EVENT 1
663#define BNXT_AGG_EVENT 2
664#define BNXT_TX_EVENT 4
665#define BNXT_REDIRECT_EVENT 8
Michael Chan4e5dbbda2017-02-06 16:55:37 -0500666
Michael Chanc0c050c2015-10-22 16:01:17 -0400667struct bnxt_sw_tx_bd {
Andy Gospodarekf18c2b72019-07-08 17:53:03 -0400668 union {
669 struct sk_buff *skb;
670 struct xdp_frame *xdpf;
671 };
Michael Chanc0c050c2015-10-22 16:01:17 -0400672 DEFINE_DMA_UNMAP_ADDR(mapping);
Andy Gospodarekf18c2b72019-07-08 17:53:03 -0400673 DEFINE_DMA_UNMAP_LEN(len);
Michael Chanc0c050c2015-10-22 16:01:17 -0400674 u8 is_gso;
675 u8 is_push;
Michael Chanc1ba92a2019-07-08 17:53:02 -0400676 u8 action;
Michael Chan38413402017-02-06 16:55:43 -0500677 union {
678 unsigned short nr_frags;
679 u16 rx_prod;
680 };
Michael Chanc0c050c2015-10-22 16:01:17 -0400681};
682
683struct bnxt_sw_rx_bd {
Michael Chan6bb19472017-02-06 16:55:32 -0500684 void *data;
685 u8 *data_ptr;
Michael Chan11cd1192017-02-06 16:55:33 -0500686 dma_addr_t mapping;
Michael Chanc0c050c2015-10-22 16:01:17 -0400687};
688
689struct bnxt_sw_rx_agg_bd {
690 struct page *page;
Michael Chan89d0a062016-04-25 02:30:51 -0400691 unsigned int offset;
Michael Chanc0c050c2015-10-22 16:01:17 -0400692 dma_addr_t mapping;
693};
694
Michael Chan6fe19882018-10-14 07:02:41 -0400695struct bnxt_ring_mem_info {
Michael Chanc0c050c2015-10-22 16:01:17 -0400696 int nr_pages;
697 int page_size;
Michael Chan4f49b2b2018-12-20 03:38:49 -0500698 u16 flags;
Michael Chan66cca202018-10-14 07:02:42 -0400699#define BNXT_RMEM_VALID_PTE_FLAG 1
700#define BNXT_RMEM_RING_PTE_FLAG 2
Michael Chan4f49b2b2018-12-20 03:38:49 -0500701#define BNXT_RMEM_USE_FULL_PAGE_FLAG 4
702
703 u16 depth;
Michael Chan66cca202018-10-14 07:02:42 -0400704
Michael Chanc0c050c2015-10-22 16:01:17 -0400705 void **pg_arr;
706 dma_addr_t *dma_arr;
707
708 __le64 *pg_tbl;
709 dma_addr_t pg_tbl_map;
710
711 int vmem_size;
712 void **vmem;
Michael Chan6fe19882018-10-14 07:02:41 -0400713};
714
715struct bnxt_ring_struct {
716 struct bnxt_ring_mem_info ring_mem;
Michael Chanc0c050c2015-10-22 16:01:17 -0400717
718 u16 fw_ring_id; /* Ring id filled by Chimp FW */
Michael Chan9899bb52018-03-31 13:54:16 -0400719 union {
720 u16 grp_idx;
721 u16 map_idx; /* Used by cmpl rings */
722 };
Michael Chan23aefdd2018-10-14 07:02:51 -0400723 u32 handle;
Michael Chanc0c050c2015-10-22 16:01:17 -0400724 u8 queue_id;
725};
726
727struct tx_push_bd {
728 __le32 doorbell;
Michael Chan4419dbe2016-02-10 17:33:49 -0500729 __le32 tx_bd_len_flags_type;
730 u32 tx_bd_opaque;
Michael Chanc0c050c2015-10-22 16:01:17 -0400731 struct tx_bd_ext txbd2;
732};
733
Michael Chan4419dbe2016-02-10 17:33:49 -0500734struct tx_push_buffer {
735 struct tx_push_bd push_bd;
736 u32 data[25];
737};
738
Michael Chan697197e2018-10-14 07:02:46 -0400739struct bnxt_db_info {
740 void __iomem *doorbell;
741 union {
742 u64 db_key64;
743 u32 db_key32;
744 };
745};
746
Michael Chanc0c050c2015-10-22 16:01:17 -0400747struct bnxt_tx_ring_info {
Michael Chanb6ab4b02016-01-02 23:44:59 -0500748 struct bnxt_napi *bnapi;
Michael Chanc0c050c2015-10-22 16:01:17 -0400749 u16 tx_prod;
750 u16 tx_cons;
Michael Chana960dec2017-02-06 16:55:39 -0500751 u16 txq_index;
Michael Chan697197e2018-10-14 07:02:46 -0400752 struct bnxt_db_info tx_db;
Michael Chanc0c050c2015-10-22 16:01:17 -0400753
754 struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
755 struct bnxt_sw_tx_bd *tx_buf_ring;
756
757 dma_addr_t tx_desc_mapping[MAX_TX_PAGES];
758
Michael Chan4419dbe2016-02-10 17:33:49 -0500759 struct tx_push_buffer *tx_push;
Michael Chanc0c050c2015-10-22 16:01:17 -0400760 dma_addr_t tx_push_mapping;
Michael Chan4419dbe2016-02-10 17:33:49 -0500761 __le64 data_mapping;
Michael Chanc0c050c2015-10-22 16:01:17 -0400762
763#define BNXT_DEV_STATE_CLOSING 0x1
764 u32 dev_state;
765
766 struct bnxt_ring_struct tx_ring_struct;
767};
768
Michael Chan74706af2018-10-14 07:02:40 -0400769#define BNXT_LEGACY_COAL_CMPL_PARAMS \
770 (RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MIN | \
771 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MAX | \
772 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_TIMER_RESET | \
773 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_RING_IDLE | \
774 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR | \
775 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT | \
776 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR | \
777 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT | \
778 RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_AGGR_INT)
779
780#define BNXT_COAL_CMPL_ENABLES \
781 (RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR | \
782 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_CMPL_AGGR_DMA_TMR | \
783 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MAX | \
784 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_AGGR_INT)
785
786#define BNXT_COAL_CMPL_MIN_TMR_ENABLE \
787 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MIN
788
789#define BNXT_COAL_CMPL_AGGR_TMR_DURING_INT_ENABLE \
790 RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT
791
792struct bnxt_coal_cap {
793 u32 cmpl_params;
794 u32 nq_params;
795 u16 num_cmpl_dma_aggr_max;
796 u16 num_cmpl_dma_aggr_during_int_max;
797 u16 cmpl_aggr_dma_tmr_max;
798 u16 cmpl_aggr_dma_tmr_during_int_max;
799 u16 int_lat_tmr_min_max;
800 u16 int_lat_tmr_max_max;
801 u16 num_cmpl_aggr_int_max;
802 u16 timer_units;
803};
804
Andy Gospodarek6a8788f2018-01-09 16:06:20 -0500805struct bnxt_coal {
806 u16 coal_ticks;
807 u16 coal_ticks_irq;
808 u16 coal_bufs;
809 u16 coal_bufs_irq;
810 /* RING_IDLE enabled when coal ticks < idle_thresh */
811 u16 idle_thresh;
812 u8 bufs_per_record;
813 u8 budget;
814};
815
Michael Chanc0c050c2015-10-22 16:01:17 -0400816struct bnxt_tpa_info {
Michael Chan6bb19472017-02-06 16:55:32 -0500817 void *data;
818 u8 *data_ptr;
Michael Chanc0c050c2015-10-22 16:01:17 -0400819 dma_addr_t mapping;
820 u16 len;
821 unsigned short gso_type;
822 u32 flags2;
823 u32 metadata;
824 enum pkt_hash_types hash_type;
825 u32 rss_hash;
Michael Chan94758f82016-06-13 02:25:35 -0400826 u32 hdr_info;
827
828#define BNXT_TPA_L4_SIZE(hdr_info) \
829 (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32)
830
831#define BNXT_TPA_INNER_L3_OFF(hdr_info) \
832 (((hdr_info) >> 18) & 0x1ff)
833
834#define BNXT_TPA_INNER_L2_OFF(hdr_info) \
835 (((hdr_info) >> 9) & 0x1ff)
836
837#define BNXT_TPA_OUTER_L3_OFF(hdr_info) \
838 ((hdr_info) & 0x1ff)
Sathya Perla4ab0c6a2017-07-24 12:34:27 -0400839
840 u16 cfa_code; /* cfa_code in TPA start compl */
Michael Chan79632e92019-07-29 06:10:21 -0400841 u8 agg_count;
842 struct rx_agg_cmp *agg_arr;
Michael Chanc0c050c2015-10-22 16:01:17 -0400843};
844
Michael Chanec4d8e72019-07-29 06:10:26 -0400845#define BNXT_AGG_IDX_BMAP_SIZE (MAX_TPA_P5 / BITS_PER_LONG)
846
847struct bnxt_tpa_idx_map {
848 u16 agg_id_tbl[1024];
849 unsigned long agg_idx_bmap[BNXT_AGG_IDX_BMAP_SIZE];
850};
851
Michael Chanc0c050c2015-10-22 16:01:17 -0400852struct bnxt_rx_ring_info {
Michael Chanb6ab4b02016-01-02 23:44:59 -0500853 struct bnxt_napi *bnapi;
Michael Chanc0c050c2015-10-22 16:01:17 -0400854 u16 rx_prod;
855 u16 rx_agg_prod;
856 u16 rx_sw_agg_prod;
Michael Chan376a5b82016-05-10 19:17:59 -0400857 u16 rx_next_cons;
Michael Chan697197e2018-10-14 07:02:46 -0400858 struct bnxt_db_info rx_db;
859 struct bnxt_db_info rx_agg_db;
Michael Chanc0c050c2015-10-22 16:01:17 -0400860
Michael Chanc6d30e82017-02-06 16:55:42 -0500861 struct bpf_prog *xdp_prog;
862
Michael Chanc0c050c2015-10-22 16:01:17 -0400863 struct rx_bd *rx_desc_ring[MAX_RX_PAGES];
864 struct bnxt_sw_rx_bd *rx_buf_ring;
865
866 struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES];
867 struct bnxt_sw_rx_agg_bd *rx_agg_ring;
868
869 unsigned long *rx_agg_bmap;
870 u16 rx_agg_bmap_size;
871
Michael Chan89d0a062016-04-25 02:30:51 -0400872 struct page *rx_page;
873 unsigned int rx_page_offset;
874
Michael Chanc0c050c2015-10-22 16:01:17 -0400875 dma_addr_t rx_desc_mapping[MAX_RX_PAGES];
876 dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES];
877
878 struct bnxt_tpa_info *rx_tpa;
Michael Chanec4d8e72019-07-29 06:10:26 -0400879 struct bnxt_tpa_idx_map *rx_tpa_idx_map;
Michael Chanc0c050c2015-10-22 16:01:17 -0400880
881 struct bnxt_ring_struct rx_ring_struct;
882 struct bnxt_ring_struct rx_agg_ring_struct;
Jesper Dangaard Brouer96a86042018-01-03 11:25:44 +0100883 struct xdp_rxq_info xdp_rxq;
Andy Gospodarek322b87c2019-07-08 17:53:04 -0400884 struct page_pool *page_pool;
Michael Chanc0c050c2015-10-22 16:01:17 -0400885};
886
887struct bnxt_cp_ring_info {
Michael Chan50e3ab72018-10-14 07:02:49 -0400888 struct bnxt_napi *bnapi;
Michael Chanc0c050c2015-10-22 16:01:17 -0400889 u32 cp_raw_cons;
Michael Chan697197e2018-10-14 07:02:46 -0400890 struct bnxt_db_info cp_db;
Michael Chanc0c050c2015-10-22 16:01:17 -0400891
Michael Chan3675b922018-10-14 07:02:57 -0400892 u8 had_work_done:1;
Michael Chan0fcec982018-10-14 07:02:58 -0400893 u8 has_more_work:1;
Michael Chan3675b922018-10-14 07:02:57 -0400894
Michael Chanffd77622018-11-15 03:25:40 -0500895 u32 last_cp_raw_cons;
896
Andy Gospodarek6a8788f2018-01-09 16:06:20 -0500897 struct bnxt_coal rx_ring_coal;
898 u64 rx_packets;
899 u64 rx_bytes;
900 u64 event_ctr;
901
Tal Gilboa8960b382019-01-31 16:44:48 +0200902 struct dim dim;
Andy Gospodarek6a8788f2018-01-09 16:06:20 -0500903
Michael Chane38287b2018-10-14 07:02:45 -0400904 union {
905 struct tx_cmp *cp_desc_ring[MAX_CP_PAGES];
906 struct nqe_cn *nq_desc_ring[MAX_CP_PAGES];
907 };
Michael Chanc0c050c2015-10-22 16:01:17 -0400908
909 dma_addr_t cp_desc_mapping[MAX_CP_PAGES];
910
911 struct ctx_hw_stats *hw_stats;
912 dma_addr_t hw_stats_map;
913 u32 hw_stats_ctx_id;
914 u64 rx_l4_csum_errors;
Michael Chan83eb5c52018-11-15 03:25:41 -0500915 u64 missed_irqs;
Michael Chanc0c050c2015-10-22 16:01:17 -0400916
917 struct bnxt_ring_struct cp_ring_struct;
Michael Chane38287b2018-10-14 07:02:45 -0400918
919 struct bnxt_cp_ring_info *cp_ring_arr[2];
Michael Chan50e3ab72018-10-14 07:02:49 -0400920#define BNXT_RX_HDL 0
921#define BNXT_TX_HDL 1
Michael Chanc0c050c2015-10-22 16:01:17 -0400922};
923
924struct bnxt_napi {
925 struct napi_struct napi;
926 struct bnxt *bp;
927
928 int index;
929 struct bnxt_cp_ring_info cp_ring;
Michael Chanb6ab4b02016-01-02 23:44:59 -0500930 struct bnxt_rx_ring_info *rx_ring;
931 struct bnxt_tx_ring_info *tx_ring;
Michael Chanc0c050c2015-10-22 16:01:17 -0400932
Michael Chanfa3e93e2017-02-06 16:55:41 -0500933 void (*tx_int)(struct bnxt *, struct bnxt_napi *,
934 int);
Michael Chan3675b922018-10-14 07:02:57 -0400935 int tx_pkts;
936 u8 events;
937
Michael Chanfa3e93e2017-02-06 16:55:41 -0500938 u32 flags;
939#define BNXT_NAPI_FLAG_XDP 0x1
940
Michael Chanfa7e2812016-05-10 19:18:00 -0400941 bool in_reset;
Michael Chanc0c050c2015-10-22 16:01:17 -0400942};
943
Michael Chanc0c050c2015-10-22 16:01:17 -0400944struct bnxt_irq {
945 irq_handler_t handler;
946 unsigned int vector;
Vasundhara Volam56f0fd82017-08-28 13:40:27 -0400947 u8 requested:1;
948 u8 have_cpumask:1;
Michael Chanc0c050c2015-10-22 16:01:17 -0400949 char name[IFNAMSIZ + 2];
Vasundhara Volam56f0fd82017-08-28 13:40:27 -0400950 cpumask_var_t cpu_mask;
Michael Chanc0c050c2015-10-22 16:01:17 -0400951};
952
953#define HWRM_RING_ALLOC_TX 0x1
954#define HWRM_RING_ALLOC_RX 0x2
955#define HWRM_RING_ALLOC_AGG 0x4
956#define HWRM_RING_ALLOC_CMPL 0x8
Michael Chan697197e2018-10-14 07:02:46 -0400957#define HWRM_RING_ALLOC_NQ 0x10
Michael Chanc0c050c2015-10-22 16:01:17 -0400958
959#define INVALID_STATS_CTX_ID -1
960
Michael Chanc0c050c2015-10-22 16:01:17 -0400961struct bnxt_ring_grp_info {
962 u16 fw_stats_ctx;
963 u16 fw_grp_id;
964 u16 rx_fw_ring_id;
965 u16 agg_fw_ring_id;
966 u16 cp_fw_ring_id;
967};
968
969struct bnxt_vnic_info {
970 u16 fw_vnic_id; /* returned by Chimp during alloc */
Michael Chan44c6f722018-10-14 07:02:53 -0400971#define BNXT_MAX_CTX_PER_VNIC 8
Prashant Sreedharan94ce9ca2016-07-18 07:15:21 -0400972 u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC];
Michael Chanc0c050c2015-10-22 16:01:17 -0400973 u16 fw_l2_ctx_id;
974#define BNXT_MAX_UC_ADDRS 4
975 __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS];
976 /* index 0 always dev_addr */
977 u16 uc_filter_count;
978 u8 *uc_list;
979
980 u16 *fw_grp_ids;
Michael Chanc0c050c2015-10-22 16:01:17 -0400981 dma_addr_t rss_table_dma_addr;
982 __le16 *rss_table;
983 dma_addr_t rss_hash_key_dma_addr;
984 u64 *rss_hash_key;
985 u32 rx_mask;
986
987 u8 *mc_list;
988 int mc_list_size;
989 int mc_list_count;
990 dma_addr_t mc_list_mapping;
991#define BNXT_MAX_MC_ADDRS 16
992
993 u32 flags;
994#define BNXT_VNIC_RSS_FLAG 1
995#define BNXT_VNIC_RFS_FLAG 2
996#define BNXT_VNIC_MCAST_FLAG 4
997#define BNXT_VNIC_UCAST_FLAG 8
Michael Chanae10ae72016-12-29 12:13:38 -0500998#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10
Michael Chanc0c050c2015-10-22 16:01:17 -0400999};
1000
Michael Chan6a4f2942018-01-17 03:21:06 -05001001struct bnxt_hw_resc {
1002 u16 min_rsscos_ctxs;
1003 u16 max_rsscos_ctxs;
1004 u16 min_cp_rings;
1005 u16 max_cp_rings;
1006 u16 resv_cp_rings;
1007 u16 min_tx_rings;
1008 u16 max_tx_rings;
1009 u16 resv_tx_rings;
Michael Chandb4723b2018-03-31 13:54:13 -04001010 u16 max_tx_sch_inputs;
Michael Chan6a4f2942018-01-17 03:21:06 -05001011 u16 min_rx_rings;
1012 u16 max_rx_rings;
1013 u16 resv_rx_rings;
1014 u16 min_hw_ring_grps;
1015 u16 max_hw_ring_grps;
1016 u16 resv_hw_ring_grps;
1017 u16 min_l2_ctxs;
1018 u16 max_l2_ctxs;
1019 u16 min_vnics;
1020 u16 max_vnics;
1021 u16 resv_vnics;
1022 u16 min_stat_ctxs;
1023 u16 max_stat_ctxs;
Vasundhara Volam780baad2018-12-16 18:46:23 -05001024 u16 resv_stat_ctxs;
Michael Chanf7588cd2018-12-16 18:46:19 -05001025 u16 max_nqs;
Michael Chan6a4f2942018-01-17 03:21:06 -05001026 u16 max_irqs;
Michael Chan75720e62018-12-09 07:01:00 -05001027 u16 resv_irqs;
Michael Chan6a4f2942018-01-17 03:21:06 -05001028};
1029
Michael Chanc0c050c2015-10-22 16:01:17 -04001030#if defined(CONFIG_BNXT_SRIOV)
1031struct bnxt_vf_info {
1032 u16 fw_fid;
Vasundhara Volam91cdda42018-01-17 03:21:14 -05001033 u8 mac_addr[ETH_ALEN]; /* PF assigned MAC Address */
1034 u8 vf_mac_addr[ETH_ALEN]; /* VF assigned MAC address, only
1035 * stored by PF.
1036 */
Michael Chanc0c050c2015-10-22 16:01:17 -04001037 u16 vlan;
Michael Chan2a516442019-02-19 05:31:14 -05001038 u16 func_qcfg_flags;
Michael Chanc0c050c2015-10-22 16:01:17 -04001039 u32 flags;
1040#define BNXT_VF_QOS 0x1
1041#define BNXT_VF_SPOOFCHK 0x2
1042#define BNXT_VF_LINK_FORCED 0x4
1043#define BNXT_VF_LINK_UP 0x8
Vasundhara Volam746df132018-03-31 13:54:10 -04001044#define BNXT_VF_TRUST 0x10
Michael Chanc0c050c2015-10-22 16:01:17 -04001045 u32 func_flags; /* func cfg flags */
1046 u32 min_tx_rate;
1047 u32 max_tx_rate;
1048 void *hwrm_cmd_req_addr;
1049 dma_addr_t hwrm_cmd_req_dma_addr;
1050};
Michael Chan379a80a2015-10-23 15:06:19 -04001051#endif
Michael Chanc0c050c2015-10-22 16:01:17 -04001052
1053struct bnxt_pf_info {
1054#define BNXT_FIRST_PF_FID 1
1055#define BNXT_FIRST_VF_FID 128
Michael Chana58a3e62016-07-01 18:46:20 -04001056 u16 fw_fid;
1057 u16 port_id;
Michael Chanc0c050c2015-10-22 16:01:17 -04001058 u8 mac_addr[ETH_ALEN];
Michael Chanc0c050c2015-10-22 16:01:17 -04001059 u32 first_vf_id;
1060 u16 active_vfs;
1061 u16 max_vfs;
1062 u32 max_encap_records;
1063 u32 max_decap_records;
1064 u32 max_tx_em_flows;
1065 u32 max_tx_wm_flows;
1066 u32 max_rx_em_flows;
1067 u32 max_rx_wm_flows;
1068 unsigned long *vf_event_bmap;
1069 u16 hwrm_cmd_req_pages;
Michael Chan4673d662018-01-17 03:21:11 -05001070 u8 vf_resv_strategy;
1071#define BNXT_VF_RESV_STRATEGY_MAXIMAL 0
1072#define BNXT_VF_RESV_STRATEGY_MINIMAL 1
Michael Chanbf827362018-08-05 16:51:50 -04001073#define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC 2
Michael Chanc0c050c2015-10-22 16:01:17 -04001074 void *hwrm_cmd_req_addr[4];
1075 dma_addr_t hwrm_cmd_req_dma_addr[4];
1076 struct bnxt_vf_info *vf;
1077};
Michael Chanc0c050c2015-10-22 16:01:17 -04001078
1079struct bnxt_ntuple_filter {
1080 struct hlist_node hash;
Michael Chana54c4d72016-07-25 12:33:35 -04001081 u8 dst_mac_addr[ETH_ALEN];
Michael Chanc0c050c2015-10-22 16:01:17 -04001082 u8 src_mac_addr[ETH_ALEN];
1083 struct flow_keys fkeys;
1084 __le64 filter_id;
1085 u16 sw_id;
Michael Chana54c4d72016-07-25 12:33:35 -04001086 u8 l2_fltr_idx;
Michael Chanc0c050c2015-10-22 16:01:17 -04001087 u16 rxq;
1088 u32 flow_id;
1089 unsigned long state;
1090#define BNXT_FLTR_VALID 0
1091#define BNXT_FLTR_UPDATE 1
1092};
1093
Michael Chanc0c050c2015-10-22 16:01:17 -04001094struct bnxt_link_info {
Michael Chan03efbec2016-04-11 04:11:11 -04001095 u8 phy_type;
Michael Chanc0c050c2015-10-22 16:01:17 -04001096 u8 media_type;
1097 u8 transceiver;
1098 u8 phy_addr;
1099 u8 phy_link_status;
1100#define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK
1101#define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL
1102#define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK
1103 u8 wire_speed;
1104 u8 loop_back;
1105 u8 link_up;
1106 u8 duplex;
Michael Chanacb20052017-07-24 12:34:20 -04001107#define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF
1108#define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL
Michael Chanc0c050c2015-10-22 16:01:17 -04001109 u8 pause;
1110#define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX
1111#define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX
1112#define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \
1113 PORT_PHY_QCFG_RESP_PAUSE_TX)
Michael Chan32773602016-03-07 15:38:42 -05001114 u8 lp_pause;
Michael Chanc0c050c2015-10-22 16:01:17 -04001115 u8 auto_pause_setting;
1116 u8 force_pause_setting;
1117 u8 duplex_setting;
1118 u8 auto_mode;
1119#define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \
1120 (mode) <= BNXT_LINK_AUTO_MSK)
1121#define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE
1122#define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
1123#define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
1124#define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
Michael Chan11f15ed2016-04-05 14:08:55 -04001125#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
Michael Chanc0c050c2015-10-22 16:01:17 -04001126#define PHY_VER_LEN 3
1127 u8 phy_ver[PHY_VER_LEN];
1128 u16 link_speed;
1129#define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB
1130#define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB
1131#define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB
1132#define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB
1133#define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB
1134#define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB
1135#define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB
1136#define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB
1137#define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB
Deepak Khungar38a21b32017-04-21 20:11:24 -04001138#define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB
Michael Chanc0c050c2015-10-22 16:01:17 -04001139 u16 support_speeds;
Michael Chan68515a12016-12-29 12:13:34 -05001140 u16 auto_link_speeds; /* fw adv setting */
Michael Chanc0c050c2015-10-22 16:01:17 -04001141#define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB
1142#define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB
1143#define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB
1144#define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB
1145#define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB
1146#define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB
1147#define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
1148#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
1149#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
Deepak Khungar38a21b32017-04-21 20:11:24 -04001150#define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB
Michael Chan93ed8112016-06-13 02:25:37 -04001151 u16 support_auto_speeds;
Michael Chan32773602016-03-07 15:38:42 -05001152 u16 lp_auto_link_speeds;
Michael Chanc0c050c2015-10-22 16:01:17 -04001153 u16 force_link_speed;
1154 u32 preemphasis;
Ajit Khaparde42ee18f2016-05-15 03:04:44 -04001155 u8 module_status;
Michael Chane70c7522017-02-12 19:18:16 -05001156 u16 fec_cfg;
1157#define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED
1158#define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED
1159#define BNXT_FEC_ENC_RS PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED
Michael Chanc0c050c2015-10-22 16:01:17 -04001160
1161 /* copy of requested setting from ethtool cmd */
1162 u8 autoneg;
1163#define BNXT_AUTONEG_SPEED 1
1164#define BNXT_AUTONEG_FLOW_CTRL 2
1165 u8 req_duplex;
1166 u8 req_flow_ctrl;
1167 u16 req_link_speed;
Michael Chan68515a12016-12-29 12:13:34 -05001168 u16 advertising; /* user adv setting */
Michael Chanc0c050c2015-10-22 16:01:17 -04001169 bool force_link_chng;
Michael Chan4bb13ab2016-04-05 14:09:01 -04001170
Michael Chana1ef4a792018-08-05 16:51:49 -04001171 bool phy_retry;
1172 unsigned long phy_retry_expires;
1173
Michael Chanc0c050c2015-10-22 16:01:17 -04001174 /* a copy of phy_qcfg output used to report link
1175 * info to VF
1176 */
1177 struct hwrm_port_phy_qcfg_output phy_qcfg_resp;
1178};
1179
1180#define BNXT_MAX_QUEUE 8
1181
1182struct bnxt_queue_info {
1183 u8 queue_id;
1184 u8 queue_profile;
1185};
1186
Michael Chan5ad2cbe2017-01-13 01:32:03 -05001187#define BNXT_MAX_LED 4
1188
1189struct bnxt_led_info {
1190 u8 led_id;
1191 u8 led_type;
1192 u8 led_group_id;
1193 u8 unused;
1194 __le16 led_state_caps;
1195#define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \
1196 cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED))
1197
1198 __le16 led_color_caps;
1199};
1200
Michael Chaneb513652017-04-04 18:14:12 -04001201#define BNXT_MAX_TEST 8
1202
1203struct bnxt_test_info {
1204 u8 offline_mask;
Michael Chan55fd0cf2018-08-05 16:51:48 -04001205 u8 flags;
1206#define BNXT_TEST_FL_EXT_LPBK 0x1
Michael Chaneb513652017-04-04 18:14:12 -04001207 u16 timeout;
1208 char string[BNXT_MAX_TEST][ETH_GSTRING_LEN];
1209};
1210
Venkat Duvvuru2e9ee392018-12-20 03:38:45 -05001211#define BNXT_GRCPF_REG_CHIMP_COMM 0x0
1212#define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER 0x100
1213#define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400
1214#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
1215#define BNXT_CAG_REG_BASE 0x300000
Jeffrey Huang11809492015-11-05 16:25:49 -05001216
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001217#define BNXT_GRCPF_REG_KONG_COMM 0xA00
1218#define BNXT_GRCPF_REG_KONG_COMM_TRIGGER 0xB00
1219
Sathya Perla5a84acb2017-10-26 11:51:31 -04001220struct bnxt_tc_flow_stats {
1221 u64 packets;
1222 u64 bytes;
1223};
1224
Sathya Perla2ae74082017-08-28 13:40:33 -04001225struct bnxt_tc_info {
1226 bool enabled;
1227
1228 /* hash table to store TC offloaded flows */
1229 struct rhashtable flow_table;
1230 struct rhashtable_params flow_ht_params;
1231
1232 /* hash table to store L2 keys of TC flows */
1233 struct rhashtable l2_table;
1234 struct rhashtable_params l2_ht_params;
Sathya Perla8c95f772017-10-26 11:51:29 -04001235 /* hash table to store L2 keys for TC tunnel decap */
1236 struct rhashtable decap_l2_table;
1237 struct rhashtable_params decap_l2_ht_params;
1238 /* hash table to store tunnel decap entries */
1239 struct rhashtable decap_table;
1240 struct rhashtable_params decap_ht_params;
1241 /* hash table to store tunnel encap entries */
1242 struct rhashtable encap_table;
1243 struct rhashtable_params encap_ht_params;
Sathya Perla2ae74082017-08-28 13:40:33 -04001244
1245 /* lock to atomically add/del an l2 node when a flow is
1246 * added or deleted.
1247 */
1248 struct mutex lock;
1249
Sathya Perla5a84acb2017-10-26 11:51:31 -04001250 /* Fields used for batching stats query */
1251 struct rhashtable_iter iter;
1252#define BNXT_FLOW_STATS_BATCH_MAX 10
1253 struct bnxt_tc_stats_batch {
1254 void *flow_node;
1255 struct bnxt_tc_flow_stats hw_stats;
1256 } stats_batch[BNXT_FLOW_STATS_BATCH_MAX];
1257
Sathya Perla2ae74082017-08-28 13:40:33 -04001258 /* Stat counter mask (width) */
1259 u64 bytes_mask;
1260 u64 packets_mask;
1261};
1262
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001263struct bnxt_vf_rep_stats {
1264 u64 packets;
1265 u64 bytes;
1266 u64 dropped;
1267};
1268
1269struct bnxt_vf_rep {
1270 struct bnxt *bp;
1271 struct net_device *dev;
Sathya Perlaee5c7fb2017-07-24 12:34:28 -04001272 struct metadata_dst *dst;
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001273 u16 vf_idx;
1274 u16 tx_cfa_action;
1275 u16 rx_cfa_code;
1276
1277 struct bnxt_vf_rep_stats rx_stats;
1278 struct bnxt_vf_rep_stats tx_stats;
1279};
1280
Michael Chan66cca202018-10-14 07:02:42 -04001281#define PTU_PTE_VALID 0x1UL
1282#define PTU_PTE_LAST 0x2UL
1283#define PTU_PTE_NEXT_TO_LAST 0x4UL
1284
Michael Chan98f04cf2018-10-14 07:02:43 -04001285#define MAX_CTX_PAGES (BNXT_PAGE_SIZE / 8)
Michael Chan08fe9d12018-12-20 03:38:50 -05001286#define MAX_CTX_TOTAL_PAGES (MAX_CTX_PAGES * MAX_CTX_PAGES)
Michael Chan98f04cf2018-10-14 07:02:43 -04001287
1288struct bnxt_ctx_pg_info {
1289 u32 entries;
Michael Chan08fe9d12018-12-20 03:38:50 -05001290 u32 nr_pages;
Michael Chan98f04cf2018-10-14 07:02:43 -04001291 void *ctx_pg_arr[MAX_CTX_PAGES];
1292 dma_addr_t ctx_dma_arr[MAX_CTX_PAGES];
1293 struct bnxt_ring_mem_info ring_mem;
Michael Chan08fe9d12018-12-20 03:38:50 -05001294 struct bnxt_ctx_pg_info **ctx_pg_tbl;
Michael Chan98f04cf2018-10-14 07:02:43 -04001295};
1296
1297struct bnxt_ctx_mem_info {
1298 u32 qp_max_entries;
1299 u16 qp_min_qp1_entries;
1300 u16 qp_max_l2_entries;
1301 u16 qp_entry_size;
1302 u16 srq_max_l2_entries;
1303 u32 srq_max_entries;
1304 u16 srq_entry_size;
1305 u16 cq_max_l2_entries;
1306 u32 cq_max_entries;
1307 u16 cq_entry_size;
1308 u16 vnic_max_vnic_entries;
1309 u16 vnic_max_ring_table_entries;
1310 u16 vnic_entry_size;
1311 u32 stat_max_entries;
1312 u16 stat_entry_size;
1313 u16 tqm_entry_size;
1314 u32 tqm_min_entries_per_ring;
1315 u32 tqm_max_entries_per_ring;
1316 u32 mrav_max_entries;
1317 u16 mrav_entry_size;
1318 u16 tim_entry_size;
1319 u32 tim_max_entries;
Devesh Sharma53579e32019-05-05 07:17:04 -04001320 u16 mrav_num_entries_units;
Michael Chan98f04cf2018-10-14 07:02:43 -04001321 u8 tqm_entries_multiple;
1322
1323 u32 flags;
1324 #define BNXT_CTX_FLAG_INITED 0x01
1325
1326 struct bnxt_ctx_pg_info qp_mem;
1327 struct bnxt_ctx_pg_info srq_mem;
1328 struct bnxt_ctx_pg_info cq_mem;
1329 struct bnxt_ctx_pg_info vnic_mem;
1330 struct bnxt_ctx_pg_info stat_mem;
Michael Chancf6daed2018-12-20 03:38:51 -05001331 struct bnxt_ctx_pg_info mrav_mem;
1332 struct bnxt_ctx_pg_info tim_mem;
Michael Chan98f04cf2018-10-14 07:02:43 -04001333 struct bnxt_ctx_pg_info *tqm_mem[9];
1334};
1335
Michael Chanc0c050c2015-10-22 16:01:17 -04001336struct bnxt {
1337 void __iomem *bar0;
1338 void __iomem *bar1;
1339 void __iomem *bar2;
1340
1341 u32 reg_base;
Michael Chan659c8052016-06-13 02:25:33 -04001342 u16 chip_num;
1343#define CHIP_NUM_57301 0x16c8
1344#define CHIP_NUM_57302 0x16c9
1345#define CHIP_NUM_57304 0x16ca
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -04001346#define CHIP_NUM_58700 0x16cd
Michael Chan659c8052016-06-13 02:25:33 -04001347#define CHIP_NUM_57402 0x16d0
1348#define CHIP_NUM_57404 0x16d1
1349#define CHIP_NUM_57406 0x16d2
Michael Chan3284f9e2017-05-29 19:06:07 -04001350#define CHIP_NUM_57407 0x16d5
Michael Chan659c8052016-06-13 02:25:33 -04001351
1352#define CHIP_NUM_57311 0x16ce
1353#define CHIP_NUM_57312 0x16cf
1354#define CHIP_NUM_57314 0x16df
Michael Chan3284f9e2017-05-29 19:06:07 -04001355#define CHIP_NUM_57317 0x16e0
Michael Chan659c8052016-06-13 02:25:33 -04001356#define CHIP_NUM_57412 0x16d6
1357#define CHIP_NUM_57414 0x16d7
1358#define CHIP_NUM_57416 0x16d8
1359#define CHIP_NUM_57417 0x16d9
Michael Chan3284f9e2017-05-29 19:06:07 -04001360#define CHIP_NUM_57412L 0x16da
1361#define CHIP_NUM_57414L 0x16db
1362
1363#define CHIP_NUM_5745X 0xd730
Michael Chan659c8052016-06-13 02:25:33 -04001364
Michael Chane38287b2018-10-14 07:02:45 -04001365#define CHIP_NUM_57500 0x1750
1366
Ray Jui4a581392017-08-28 13:40:28 -04001367#define CHIP_NUM_58802 0xd802
Ray Jui8ed693b2017-10-26 11:51:20 -04001368#define CHIP_NUM_58804 0xd804
Ray Jui4a581392017-08-28 13:40:28 -04001369#define CHIP_NUM_58808 0xd808
1370
Michael Chan659c8052016-06-13 02:25:33 -04001371#define BNXT_CHIP_NUM_5730X(chip_num) \
1372 ((chip_num) >= CHIP_NUM_57301 && \
1373 (chip_num) <= CHIP_NUM_57304)
1374
1375#define BNXT_CHIP_NUM_5740X(chip_num) \
Michael Chan3284f9e2017-05-29 19:06:07 -04001376 (((chip_num) >= CHIP_NUM_57402 && \
1377 (chip_num) <= CHIP_NUM_57406) || \
1378 (chip_num) == CHIP_NUM_57407)
Michael Chan659c8052016-06-13 02:25:33 -04001379
1380#define BNXT_CHIP_NUM_5731X(chip_num) \
1381 ((chip_num) == CHIP_NUM_57311 || \
1382 (chip_num) == CHIP_NUM_57312 || \
Michael Chan3284f9e2017-05-29 19:06:07 -04001383 (chip_num) == CHIP_NUM_57314 || \
1384 (chip_num) == CHIP_NUM_57317)
Michael Chan659c8052016-06-13 02:25:33 -04001385
1386#define BNXT_CHIP_NUM_5741X(chip_num) \
1387 ((chip_num) >= CHIP_NUM_57412 && \
Michael Chan3284f9e2017-05-29 19:06:07 -04001388 (chip_num) <= CHIP_NUM_57414L)
1389
1390#define BNXT_CHIP_NUM_58700(chip_num) \
1391 ((chip_num) == CHIP_NUM_58700)
1392
1393#define BNXT_CHIP_NUM_5745X(chip_num) \
1394 ((chip_num) == CHIP_NUM_5745X)
Michael Chan659c8052016-06-13 02:25:33 -04001395
1396#define BNXT_CHIP_NUM_57X0X(chip_num) \
1397 (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num))
1398
1399#define BNXT_CHIP_NUM_57X1X(chip_num) \
1400 (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num))
Michael Chanc0c050c2015-10-22 16:01:17 -04001401
Ray Jui4a581392017-08-28 13:40:28 -04001402#define BNXT_CHIP_NUM_588XX(chip_num) \
1403 ((chip_num) == CHIP_NUM_58802 || \
Ray Jui8ed693b2017-10-26 11:51:20 -04001404 (chip_num) == CHIP_NUM_58804 || \
Ray Jui4a581392017-08-28 13:40:28 -04001405 (chip_num) == CHIP_NUM_58808)
1406
Michael Chanc0c050c2015-10-22 16:01:17 -04001407 struct net_device *dev;
1408 struct pci_dev *pdev;
1409
1410 atomic_t intr_sem;
1411
1412 u32 flags;
Michael Chane38287b2018-10-14 07:02:45 -04001413 #define BNXT_FLAG_CHIP_P5 0x1
Michael Chanc0c050c2015-10-22 16:01:17 -04001414 #define BNXT_FLAG_VF 0x2
1415 #define BNXT_FLAG_LRO 0x4
Michael Chand1611c32015-10-25 22:27:57 -04001416#ifdef CONFIG_INET
Michael Chanc0c050c2015-10-22 16:01:17 -04001417 #define BNXT_FLAG_GRO 0x8
Michael Chand1611c32015-10-25 22:27:57 -04001418#else
1419 /* Cannot support hardware GRO if CONFIG_INET is not set */
1420 #define BNXT_FLAG_GRO 0x0
1421#endif
Michael Chanc0c050c2015-10-22 16:01:17 -04001422 #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO)
1423 #define BNXT_FLAG_JUMBO 0x10
1424 #define BNXT_FLAG_STRIP_VLAN 0x20
1425 #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
1426 BNXT_FLAG_LRO)
1427 #define BNXT_FLAG_USING_MSIX 0x40
1428 #define BNXT_FLAG_MSIX_CAP 0x80
1429 #define BNXT_FLAG_RFS 0x100
Michael Chan6e6c5a52016-01-02 23:45:02 -05001430 #define BNXT_FLAG_SHARED_RINGS 0x200
Michael Chan3bdf56c2016-03-07 15:38:45 -05001431 #define BNXT_FLAG_PORT_STATS 0x400
Michael Chan87da7f72016-11-16 21:13:09 -05001432 #define BNXT_FLAG_UDP_RSS_CAP 0x800
Michael Chan170ce012016-04-05 14:08:57 -04001433 #define BNXT_FLAG_EEE_CAP 0x1000
Michael Chan8fdefd62016-12-29 12:13:36 -05001434 #define BNXT_FLAG_NEW_RSS_CAP 0x2000
Michael Chanc1ef1462017-04-04 18:14:07 -04001435 #define BNXT_FLAG_WOL_CAP 0x4000
Michael Chane4060d32016-12-07 00:26:19 -05001436 #define BNXT_FLAG_ROCEV1_CAP 0x8000
1437 #define BNXT_FLAG_ROCEV2_CAP 0x10000
1438 #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \
1439 BNXT_FLAG_ROCEV2_CAP)
Michael Chanbdbd1eb2016-12-29 12:13:43 -05001440 #define BNXT_FLAG_NO_AGG_RINGS 0x20000
Michael Chanc61fb992017-02-06 16:55:36 -05001441 #define BNXT_FLAG_RX_PAGE_MODE 0x40000
Deepak Khungar9e54e322017-04-21 20:11:26 -04001442 #define BNXT_FLAG_MULTI_HOST 0x100000
Michael Chan434c9752017-05-29 19:06:08 -04001443 #define BNXT_FLAG_DOUBLE_DB 0x400000
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -04001444 #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000
Andy Gospodarek6a8788f2018-01-09 16:06:20 -05001445 #define BNXT_FLAG_DIM 0x2000000
Michael Chanabe93ad2018-03-31 13:54:08 -04001446 #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000
Vasundhara Volam00db3cb2018-03-31 13:54:12 -04001447 #define BNXT_FLAG_PORT_STATS_EXT 0x10000000
Vasundhara Volam55e43982019-05-05 07:17:00 -04001448 #define BNXT_FLAG_PCIE_STATS 0x40000000
Michael Chan6e6c5a52016-01-02 23:45:02 -05001449
Michael Chanc0c050c2015-10-22 16:01:17 -04001450 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
1451 BNXT_FLAG_RFS | \
1452 BNXT_FLAG_STRIP_VLAN)
1453
1454#define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
1455#define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
Satish Baddipadige567b2ab2016-06-13 02:25:31 -04001456#define BNXT_NPAR(bp) ((bp)->port_partition_type)
Deepak Khungar9e54e322017-04-21 20:11:26 -04001457#define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST)
1458#define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -04001459#define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
Michael Chanc61fb992017-02-06 16:55:36 -05001460#define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)
Michael Chane38287b2018-10-14 07:02:45 -04001461#define BNXT_SUPPORTS_TPA(bp) (!BNXT_CHIP_TYPE_NITRO_A0(bp) && \
Michael Chan7c380912019-07-29 06:10:31 -04001462 (!((bp)->flags & BNXT_FLAG_CHIP_P5) || \
1463 (bp)->max_tpa_v2) && !is_kdump_kernel())
Michael Chanc0c050c2015-10-22 16:01:17 -04001464
Michael Chane38287b2018-10-14 07:02:45 -04001465/* Chip class phase 5 */
1466#define BNXT_CHIP_P5(bp) \
1467 ((bp)->chip_num == CHIP_NUM_57500)
1468
1469/* Chip class phase 4.x */
1470#define BNXT_CHIP_P4(bp) \
Michael Chan3284f9e2017-05-29 19:06:07 -04001471 (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \
1472 BNXT_CHIP_NUM_5745X((bp)->chip_num) || \
Ray Jui4a581392017-08-28 13:40:28 -04001473 BNXT_CHIP_NUM_588XX((bp)->chip_num) || \
Michael Chan3284f9e2017-05-29 19:06:07 -04001474 (BNXT_CHIP_NUM_58700((bp)->chip_num) && \
1475 !BNXT_CHIP_TYPE_NITRO_A0(bp)))
1476
Michael Chane38287b2018-10-14 07:02:45 -04001477#define BNXT_CHIP_P4_PLUS(bp) \
1478 (BNXT_CHIP_P4(bp) || BNXT_CHIP_P5(bp))
1479
Michael Chana588e452016-12-07 00:26:21 -05001480 struct bnxt_en_dev *edev;
1481 struct bnxt_en_dev * (*ulp_probe)(struct net_device *);
1482
Michael Chanc0c050c2015-10-22 16:01:17 -04001483 struct bnxt_napi **bnapi;
1484
Michael Chanb6ab4b02016-01-02 23:44:59 -05001485 struct bnxt_rx_ring_info *rx_ring;
1486 struct bnxt_tx_ring_info *tx_ring;
Michael Chana960dec2017-02-06 16:55:39 -05001487 u16 *tx_ring_map;
Michael Chanb6ab4b02016-01-02 23:44:59 -05001488
Michael Chan309369c2016-06-13 02:25:34 -04001489 struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int,
1490 struct sk_buff *);
1491
Michael Chan6bb19472017-02-06 16:55:32 -05001492 struct sk_buff * (*rx_skb_func)(struct bnxt *,
1493 struct bnxt_rx_ring_info *,
1494 u16, void *, u8 *, dma_addr_t,
1495 unsigned int);
1496
Michael Chan79632e92019-07-29 06:10:21 -04001497 u16 max_tpa_v2;
1498 u16 max_tpa;
Michael Chanc0c050c2015-10-22 16:01:17 -04001499 u32 rx_buf_size;
1500 u32 rx_buf_use_size; /* useable size */
Michael Chanb3dba772017-02-06 16:55:35 -05001501 u16 rx_offset;
1502 u16 rx_dma_offset;
Michael Chan745fc052017-02-06 16:55:34 -05001503 enum dma_data_direction rx_dir;
Michael Chanc0c050c2015-10-22 16:01:17 -04001504 u32 rx_ring_size;
1505 u32 rx_agg_ring_size;
1506 u32 rx_copy_thresh;
1507 u32 rx_ring_mask;
1508 u32 rx_agg_ring_mask;
1509 int rx_nr_pages;
1510 int rx_agg_nr_pages;
1511 int rx_nr_rings;
1512 int rsscos_nr_ctxs;
1513
1514 u32 tx_ring_size;
1515 u32 tx_ring_mask;
1516 int tx_nr_pages;
1517 int tx_nr_rings;
1518 int tx_nr_rings_per_tc;
Michael Chan5f449242017-02-06 16:55:40 -05001519 int tx_nr_rings_xdp;
Michael Chanc0c050c2015-10-22 16:01:17 -04001520
1521 int tx_wake_thresh;
1522 int tx_push_thresh;
1523 int tx_push_size;
1524
1525 u32 cp_ring_size;
1526 u32 cp_ring_mask;
1527 u32 cp_bit;
1528 int cp_nr_pages;
1529 int cp_nr_rings;
1530
Michael Chanb81a90d2016-01-02 23:45:01 -05001531 /* grp_info indexed by completion ring index */
Michael Chanc0c050c2015-10-22 16:01:17 -04001532 struct bnxt_ring_grp_info *grp_info;
1533 struct bnxt_vnic_info *vnic_info;
1534 int nr_vnics;
Michael Chan87da7f72016-11-16 21:13:09 -05001535 u32 rss_hash_cfg;
Michael Chanc0c050c2015-10-22 16:01:17 -04001536
Michael Chan7eb9bb32017-10-26 11:51:25 -04001537 u16 max_mtu;
Michael Chanc0c050c2015-10-22 16:01:17 -04001538 u8 max_tc;
Michael Chan87c374d2016-12-02 21:17:16 -05001539 u8 max_lltc; /* lossless TCs */
Michael Chanc0c050c2015-10-22 16:01:17 -04001540 struct bnxt_queue_info q_info[BNXT_MAX_QUEUE];
Michael Chan2e8ef772018-04-26 17:44:31 -04001541 u8 tc_to_qidx[BNXT_MAX_QUEUE];
Michael Chan98f04cf2018-10-14 07:02:43 -04001542 u8 q_ids[BNXT_MAX_QUEUE];
1543 u8 max_q;
Michael Chanc0c050c2015-10-22 16:01:17 -04001544
1545 unsigned int current_interval;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001546#define BNXT_TIMER_INTERVAL HZ
Michael Chanc0c050c2015-10-22 16:01:17 -04001547
1548 struct timer_list timer;
1549
Michael Chancaefe522015-12-09 19:35:42 -05001550 unsigned long state;
1551#define BNXT_STATE_OPEN 0
Michael Chan4cebdce2015-12-09 19:35:43 -05001552#define BNXT_STATE_IN_SP_TASK 1
Michael Chanf9b76eb2017-07-11 13:05:34 -04001553#define BNXT_STATE_READ_STATS 2
Michael Chanc0c050c2015-10-22 16:01:17 -04001554
1555 struct bnxt_irq *irq_tbl;
Michael Chan78095922016-12-07 00:26:16 -05001556 int total_irqs;
Michael Chanc0c050c2015-10-22 16:01:17 -04001557 u8 mac_addr[ETH_ALEN];
1558
Michael Chan7df4ae92016-12-02 21:17:17 -05001559#ifdef CONFIG_BNXT_DCB
1560 struct ieee_pfc *ieee_pfc;
1561 struct ieee_ets *ieee_ets;
1562 u8 dcbx_cap;
1563 u8 default_pri;
Michael Chanafdc8a82018-08-05 16:51:57 -04001564 u8 max_dscp_value;
Michael Chan7df4ae92016-12-02 21:17:17 -05001565#endif /* CONFIG_BNXT_DCB */
1566
Michael Chanc0c050c2015-10-22 16:01:17 -04001567 u32 msg_enable;
1568
Michael Chan97381a12018-08-05 16:51:54 -04001569 u32 fw_cap;
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001570 #define BNXT_FW_CAP_SHORT_CMD 0x00000001
1571 #define BNXT_FW_CAP_LLDP_AGENT 0x00000002
1572 #define BNXT_FW_CAP_DCBX_AGENT 0x00000004
1573 #define BNXT_FW_CAP_NEW_RM 0x00000008
1574 #define BNXT_FW_CAP_IF_CHANGE 0x00000010
1575 #define BNXT_FW_CAP_KONG_MB_CHNL 0x00000080
Venkat Duvvuruabd43a12018-12-20 03:38:52 -05001576 #define BNXT_FW_CAP_OVS_64BIT_HANDLE 0x00000400
Michael Chan2a516442019-02-19 05:31:14 -05001577 #define BNXT_FW_CAP_TRUSTED_VF 0x00000800
Vasundhara Volam691aa622019-05-05 07:17:02 -04001578 #define BNXT_FW_CAP_PKG_VER 0x00004000
Michael Chane969ae52019-05-05 07:17:06 -04001579 #define BNXT_FW_CAP_CFA_ADV_FLOW 0x00008000
1580 #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX 0x00010000
Vasundhara Volam55e43982019-05-05 07:17:00 -04001581 #define BNXT_FW_CAP_PCIE_STATS_SUPPORTED 0x00020000
Vasundhara Volam61545322019-05-05 07:17:01 -04001582 #define BNXT_FW_CAP_EXT_STATS_SUPPORTED 0x00040000
Michael Chan97381a12018-08-05 16:51:54 -04001583
1584#define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
Michael Chan11f15ed2016-04-05 14:08:55 -04001585 u32 hwrm_spec_code;
Michael Chanc0c050c2015-10-22 16:01:17 -04001586 u16 hwrm_cmd_seq;
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001587 u16 hwrm_cmd_kong_seq;
Venkat Duvvurufc718bb2018-12-20 03:38:44 -05001588 u16 hwrm_intr_seq_id;
Deepak Khungare605db82017-05-29 19:06:04 -04001589 void *hwrm_short_cmd_req_addr;
1590 dma_addr_t hwrm_short_cmd_req_dma_addr;
Michael Chanc0c050c2015-10-22 16:01:17 -04001591 void *hwrm_cmd_resp_addr;
1592 dma_addr_t hwrm_cmd_resp_dma_addr;
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001593 void *hwrm_cmd_kong_resp_addr;
1594 dma_addr_t hwrm_cmd_kong_resp_dma_addr;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001595
Michael Chanb8875ca2018-12-16 18:46:29 -05001596 struct rtnl_link_stats64 net_stats_prev;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001597 struct rx_port_stats *hw_rx_port_stats;
1598 struct tx_port_stats *hw_tx_port_stats;
Vasundhara Volam00db3cb2018-03-31 13:54:12 -04001599 struct rx_port_stats_ext *hw_rx_port_stats_ext;
Dan Carpenter35b842f2018-10-18 11:02:39 +03001600 struct tx_port_stats_ext *hw_tx_port_stats_ext;
Vasundhara Volam55e43982019-05-05 07:17:00 -04001601 struct pcie_ctx_hw_stats *hw_pcie_stats;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001602 dma_addr_t hw_rx_port_stats_map;
1603 dma_addr_t hw_tx_port_stats_map;
Vasundhara Volam00db3cb2018-03-31 13:54:12 -04001604 dma_addr_t hw_rx_port_stats_ext_map;
Michael Chan36e53342018-10-14 07:02:38 -04001605 dma_addr_t hw_tx_port_stats_ext_map;
Vasundhara Volam55e43982019-05-05 07:17:00 -04001606 dma_addr_t hw_pcie_stats_map;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001607 int hw_port_stats_size;
Michael Chan36e53342018-10-14 07:02:38 -04001608 u16 fw_rx_stats_ext_size;
1609 u16 fw_tx_stats_ext_size;
Michael Chan4e748502019-07-29 06:10:29 -04001610 u16 hw_ring_stats_size;
Michael Chane37fed72018-12-16 18:46:26 -05001611 u8 pri2cos[8];
1612 u8 pri2cos_valid;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001613
Michael Chane6ef2692016-03-28 19:46:05 -04001614 u16 hwrm_max_req_len;
Michael Chan1dfddc42018-10-14 07:02:39 -04001615 u16 hwrm_max_ext_req_len;
Michael Chanff4fe812016-02-26 04:00:04 -05001616 int hwrm_cmd_timeout;
Michael Chanc0c050c2015-10-22 16:01:17 -04001617 struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
1618 struct hwrm_ver_get_output ver_resp;
1619#define FW_VER_STR_LEN 32
1620#define BC_HWRM_STR_LEN 21
1621#define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
1622 char fw_ver_str[FW_VER_STR_LEN];
1623 __be16 vxlan_port;
1624 u8 vxlan_port_cnt;
1625 __le16 vxlan_fw_dst_port_id;
Alexander Duyck7cdd5fc2016-06-16 12:21:36 -07001626 __be16 nge_port;
Michael Chanc0c050c2015-10-22 16:01:17 -04001627 u8 nge_port_cnt;
1628 __le16 nge_fw_dst_port_id;
Satish Baddipadige567b2ab2016-06-13 02:25:31 -04001629 u8 port_partition_type;
Michael Chand5430d32017-08-28 13:40:31 -04001630 u8 port_count;
Michael Chan32e8239c2017-07-24 12:34:21 -04001631 u16 br_mode;
Michael Chandfc9c942016-02-26 04:00:03 -05001632
Michael Chan74706af2018-10-14 07:02:40 -04001633 struct bnxt_coal_cap coal_cap;
Michael Chan18775aa2017-10-26 11:51:27 -04001634 struct bnxt_coal rx_coal;
1635 struct bnxt_coal tx_coal;
Michael Chanc0c050c2015-10-22 16:01:17 -04001636
Michael Chan51f30782016-07-01 18:46:29 -04001637 u32 stats_coal_ticks;
1638#define BNXT_DEF_STATS_COAL_TICKS 1000000
1639#define BNXT_MIN_STATS_COAL_TICKS 250000
1640#define BNXT_MAX_STATS_COAL_TICKS 1000000
1641
Michael Chanc0c050c2015-10-22 16:01:17 -04001642 struct work_struct sp_task;
1643 unsigned long sp_event;
1644#define BNXT_RX_MASK_SP_EVENT 0
1645#define BNXT_RX_NTP_FLTR_SP_EVENT 1
1646#define BNXT_LINK_CHNG_SP_EVENT 2
Jeffrey Huangc5d77742015-11-05 16:25:47 -05001647#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3
1648#define BNXT_VXLAN_ADD_PORT_SP_EVENT 4
1649#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
1650#define BNXT_RESET_TASK_SP_EVENT 6
1651#define BNXT_RST_RING_SP_EVENT 7
Jeffrey Huang19241362016-02-26 04:00:00 -05001652#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
Michael Chan3bdf56c2016-03-07 15:38:45 -05001653#define BNXT_PERIODIC_STATS_SP_EVENT 9
Michael Chan4bb13ab2016-04-05 14:09:01 -04001654#define BNXT_HWRM_PORT_MODULE_SP_EVENT 10
Michael Chanfc0f1922016-06-13 02:25:30 -04001655#define BNXT_RESET_TASK_SILENT_SP_EVENT 11
Alexander Duyck7cdd5fc2016-06-16 12:21:36 -07001656#define BNXT_GENEVE_ADD_PORT_SP_EVENT 12
1657#define BNXT_GENEVE_DEL_PORT_SP_EVENT 13
Michael Chan286ef9d2016-11-16 21:13:08 -05001658#define BNXT_LINK_SPEED_CHNG_SP_EVENT 14
Sathya Perla5a84acb2017-10-26 11:51:31 -04001659#define BNXT_FLOW_STATS_SP_EVENT 15
Michael Chana1ef4a792018-08-05 16:51:49 -04001660#define BNXT_UPDATE_PHY_SP_EVENT 16
Michael Chanffd77622018-11-15 03:25:40 -05001661#define BNXT_RING_COAL_NOW_SP_EVENT 17
Michael Chanc0c050c2015-10-22 16:01:17 -04001662
Michael Chan6a4f2942018-01-17 03:21:06 -05001663 struct bnxt_hw_resc hw_resc;
Michael Chan379a80a2015-10-23 15:06:19 -04001664 struct bnxt_pf_info pf;
Michael Chan98f04cf2018-10-14 07:02:43 -04001665 struct bnxt_ctx_mem_info *ctx;
Michael Chanc0c050c2015-10-22 16:01:17 -04001666#ifdef CONFIG_BNXT_SRIOV
1667 int nr_vfs;
Michael Chanc0c050c2015-10-22 16:01:17 -04001668 struct bnxt_vf_info vf;
1669 wait_queue_head_t sriov_cfg_wait;
1670 bool sriov_cfg;
1671#define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000)
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001672
1673 /* lock to protect VF-rep creation/cleanup via
1674 * multiple paths such as ->sriov_configure() and
1675 * devlink ->eswitch_mode_set()
1676 */
1677 struct mutex sriov_lock;
Michael Chanc0c050c2015-10-22 16:01:17 -04001678#endif
1679
Michael Chan697197e2018-10-14 07:02:46 -04001680#if BITS_PER_LONG == 32
1681 /* ensure atomic 64-bit doorbell writes on 32-bit systems. */
1682 spinlock_t db_lock;
1683#endif
1684
Michael Chanc0c050c2015-10-22 16:01:17 -04001685#define BNXT_NTP_FLTR_MAX_FLTR 4096
1686#define BNXT_NTP_FLTR_HASH_SIZE 512
1687#define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1)
1688 struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE];
1689 spinlock_t ntp_fltr_lock; /* for hash table add, del */
1690
1691 unsigned long *ntp_fltr_bmap;
1692 int ntp_fltr_count;
1693
Michael Chane2dc9b62017-10-13 21:09:30 -04001694 /* To protect link related settings during link changes and
1695 * ethtool settings changes.
1696 */
1697 struct mutex link_lock;
Michael Chanc0c050c2015-10-22 16:01:17 -04001698 struct bnxt_link_info link_info;
Michael Chan170ce012016-04-05 14:08:57 -04001699 struct ethtool_eee eee;
1700 u32 lpi_tmr_lo;
1701 u32 lpi_tmr_hi;
Michael Chan5ad2cbe2017-01-13 01:32:03 -05001702
Michael Chaneb513652017-04-04 18:14:12 -04001703 u8 num_tests;
1704 struct bnxt_test_info *test_info;
1705
Michael Chanc1ef1462017-04-04 18:14:07 -04001706 u8 wol_filter_id;
1707 u8 wol;
1708
Michael Chan5ad2cbe2017-01-13 01:32:03 -05001709 u8 num_leds;
1710 struct bnxt_led_info leds[BNXT_MAX_LED];
Michael Chanc6d30e82017-02-06 16:55:42 -05001711
1712 struct bpf_prog *xdp_prog;
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001713
1714 /* devlink interface and vf-rep structs */
1715 struct devlink *dl;
Vasundhara Volam782a6242019-01-28 18:00:27 +05301716 struct devlink_port dl_port;
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001717 enum devlink_eswitch_mode eswitch_mode;
1718 struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */
1719 u16 *cfa_code_map; /* cfa_code -> vf_idx map */
Sathya Perladd4ea1d2018-01-17 03:21:16 -05001720 u8 switch_id[8];
Sathya Perlacd663582017-10-26 11:51:32 -04001721 struct bnxt_tc_info *tc_info;
Andy Gospodarekcabfb092018-04-26 17:44:40 -04001722 struct dentry *debugfs_pdev;
1723 struct dentry *debugfs_dim;
Vasundhara Volamcde49a42018-08-05 16:51:56 -04001724 struct device *hwmon_dev;
Michael Chanc0c050c2015-10-22 16:01:17 -04001725};
1726
Michael Chanc77192f2016-12-02 21:17:18 -05001727#define BNXT_RX_STATS_OFFSET(counter) \
1728 (offsetof(struct rx_port_stats, counter) / 8)
1729
1730#define BNXT_TX_STATS_OFFSET(counter) \
1731 ((offsetof(struct tx_port_stats, counter) + \
1732 sizeof(struct rx_port_stats) + 512) / 8)
1733
Vasundhara Volam00db3cb2018-03-31 13:54:12 -04001734#define BNXT_RX_STATS_EXT_OFFSET(counter) \
1735 (offsetof(struct rx_port_stats_ext, counter) / 8)
1736
Michael Chan36e53342018-10-14 07:02:38 -04001737#define BNXT_TX_STATS_EXT_OFFSET(counter) \
1738 (offsetof(struct tx_port_stats_ext, counter) / 8)
1739
Vasundhara Volam55e43982019-05-05 07:17:00 -04001740#define BNXT_PCIE_STATS_OFFSET(counter) \
1741 (offsetof(struct pcie_ctx_hw_stats, counter) / 8)
1742
Ajit Khaparde42ee18f2016-05-15 03:04:44 -04001743#define I2C_DEV_ADDR_A0 0xa0
1744#define I2C_DEV_ADDR_A2 0xa2
Vasundhara Volam7328a232018-05-08 03:18:40 -04001745#define SFF_DIAG_SUPPORT_OFFSET 0x5c
Ajit Khaparde42ee18f2016-05-15 03:04:44 -04001746#define SFF_MODULE_ID_SFP 0x3
1747#define SFF_MODULE_ID_QSFP 0xc
1748#define SFF_MODULE_ID_QSFP_PLUS 0xd
1749#define SFF_MODULE_ID_QSFP28 0x11
1750#define BNXT_MAX_PHY_I2C_RESP_SIZE 64
1751
Michael Chan38413402017-02-06 16:55:43 -05001752static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
1753{
1754 /* Tell compiler to fetch tx indices from memory. */
1755 barrier();
1756
1757 return bp->tx_ring_size -
1758 ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask);
1759}
1760
Michael Chan697197e2018-10-14 07:02:46 -04001761#if BITS_PER_LONG == 32
1762#define writeq(val64, db) \
1763do { \
1764 spin_lock(&bp->db_lock); \
1765 writel((val64) & 0xffffffff, db); \
1766 writel((val64) >> 32, (db) + 4); \
1767 spin_unlock(&bp->db_lock); \
1768} while (0)
1769
1770#define writeq_relaxed writeq
1771#endif
1772
Sinan Kayafd141fa2018-03-25 10:39:20 -04001773/* For TX and RX ring doorbells with no ordering guarantee*/
Michael Chan697197e2018-10-14 07:02:46 -04001774static inline void bnxt_db_write_relaxed(struct bnxt *bp,
1775 struct bnxt_db_info *db, u32 idx)
Sinan Kayafd141fa2018-03-25 10:39:20 -04001776{
Michael Chan697197e2018-10-14 07:02:46 -04001777 if (bp->flags & BNXT_FLAG_CHIP_P5) {
1778 writeq_relaxed(db->db_key64 | idx, db->doorbell);
1779 } else {
1780 u32 db_val = db->db_key32 | idx;
1781
1782 writel_relaxed(db_val, db->doorbell);
1783 if (bp->flags & BNXT_FLAG_DOUBLE_DB)
1784 writel_relaxed(db_val, db->doorbell);
1785 }
Sinan Kayafd141fa2018-03-25 10:39:20 -04001786}
1787
Michael Chan434c9752017-05-29 19:06:08 -04001788/* For TX and RX ring doorbells */
Michael Chan697197e2018-10-14 07:02:46 -04001789static inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db,
1790 u32 idx)
Michael Chan434c9752017-05-29 19:06:08 -04001791{
Michael Chan697197e2018-10-14 07:02:46 -04001792 if (bp->flags & BNXT_FLAG_CHIP_P5) {
1793 writeq(db->db_key64 | idx, db->doorbell);
1794 } else {
1795 u32 db_val = db->db_key32 | idx;
1796
1797 writel(db_val, db->doorbell);
1798 if (bp->flags & BNXT_FLAG_DOUBLE_DB)
1799 writel(db_val, db->doorbell);
1800 }
Michael Chan434c9752017-05-29 19:06:08 -04001801}
1802
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001803static inline bool bnxt_cfa_hwrm_message(u16 req_type)
Venkat Duvvuru5c209fc2018-12-20 03:38:47 -05001804{
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001805 switch (req_type) {
1806 case HWRM_CFA_ENCAP_RECORD_ALLOC:
1807 case HWRM_CFA_ENCAP_RECORD_FREE:
1808 case HWRM_CFA_DECAP_FILTER_ALLOC:
1809 case HWRM_CFA_DECAP_FILTER_FREE:
1810 case HWRM_CFA_NTUPLE_FILTER_ALLOC:
1811 case HWRM_CFA_NTUPLE_FILTER_FREE:
1812 case HWRM_CFA_NTUPLE_FILTER_CFG:
1813 case HWRM_CFA_EM_FLOW_ALLOC:
1814 case HWRM_CFA_EM_FLOW_FREE:
1815 case HWRM_CFA_EM_FLOW_CFG:
1816 case HWRM_CFA_FLOW_ALLOC:
1817 case HWRM_CFA_FLOW_FREE:
1818 case HWRM_CFA_FLOW_INFO:
1819 case HWRM_CFA_FLOW_FLUSH:
1820 case HWRM_CFA_FLOW_STATS:
1821 case HWRM_CFA_METER_PROFILE_ALLOC:
1822 case HWRM_CFA_METER_PROFILE_FREE:
1823 case HWRM_CFA_METER_PROFILE_CFG:
1824 case HWRM_CFA_METER_INSTANCE_ALLOC:
1825 case HWRM_CFA_METER_INSTANCE_FREE:
1826 return true;
1827 default:
1828 return false;
1829 }
Venkat Duvvuru5c209fc2018-12-20 03:38:47 -05001830}
1831
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001832static inline bool bnxt_kong_hwrm_message(struct bnxt *bp, struct input *req)
1833{
1834 return (bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL &&
1835 bnxt_cfa_hwrm_message(le16_to_cpu(req->req_type)));
1836}
1837
1838static inline bool bnxt_hwrm_kong_chnl(struct bnxt *bp, struct input *req)
1839{
1840 return (bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL &&
1841 req->resp_addr == cpu_to_le64(bp->hwrm_cmd_kong_resp_dma_addr));
1842}
1843
1844static inline void *bnxt_get_hwrm_resp_addr(struct bnxt *bp, void *req)
1845{
1846 if (bnxt_hwrm_kong_chnl(bp, (struct input *)req))
1847 return bp->hwrm_cmd_kong_resp_addr;
1848 else
1849 return bp->hwrm_cmd_resp_addr;
1850}
1851
1852static inline u16 bnxt_get_hwrm_seq_id(struct bnxt *bp, u16 dst)
Venkat Duvvuru5c209fc2018-12-20 03:38:47 -05001853{
1854 u16 seq_id;
1855
Venkat Duvvuru760b6d32018-12-20 03:38:48 -05001856 if (dst == BNXT_HWRM_CHNL_CHIMP)
1857 seq_id = bp->hwrm_cmd_seq++;
1858 else
1859 seq_id = bp->hwrm_cmd_kong_seq++;
Venkat Duvvuru5c209fc2018-12-20 03:38:47 -05001860 return seq_id;
1861}
1862
Michael Chan38413402017-02-06 16:55:43 -05001863extern const u16 bnxt_lhint_arr[];
1864
1865int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
1866 u16 prod, gfp_t gfp);
Michael Chanc6d30e82017-02-06 16:55:42 -05001867void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data);
1868void bnxt_set_tpa_flags(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001869void bnxt_set_ring_params(struct bnxt *);
Michael Chanc61fb992017-02-06 16:55:36 -05001870int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
Michael Chanc0c050c2015-10-22 16:01:17 -04001871void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
1872int _hwrm_send_message(struct bnxt *, void *, u32, int);
Michael Chancc72f3b2017-10-13 21:09:33 -04001873int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
Michael Chanc0c050c2015-10-22 16:01:17 -04001874int hwrm_send_message(struct bnxt *, void *, u32, int);
Michael Chan90e209212016-02-26 04:00:08 -05001875int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
Michael Chana1653b12016-12-07 00:26:20 -05001876int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
1877 int bmap_size);
Michael Chana588e452016-12-07 00:26:21 -05001878int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
Michael Chan391be5c2016-12-29 12:13:41 -05001879int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
Michael Chanb16b6892018-12-16 18:46:25 -05001880int bnxt_nq_rings_in_use(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001881int bnxt_hwrm_set_coal(struct bnxt *);
Michael Chane4060d32016-12-07 00:26:19 -05001882unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
Vasundhara Volamc027c6b2018-12-16 18:46:21 -05001883unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);
Michael Chane4060d32016-12-07 00:26:19 -05001884unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
Michael Chane916b082018-12-16 18:46:20 -05001885unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
Michael Chanfbcfc8e2018-03-31 13:54:20 -04001886int bnxt_get_avail_msix(struct bnxt *bp, int num);
Michael Chan1b3f0b72019-05-22 19:12:55 -04001887int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init);
Michael Chan7df4ae92016-12-02 21:17:17 -05001888void bnxt_tx_disable(struct bnxt *bp);
1889void bnxt_tx_enable(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001890int bnxt_hwrm_set_pause(struct bnxt *);
Michael Chan939f7f02016-04-05 14:08:58 -04001891int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
Michael Chan5282db62017-04-04 18:14:10 -04001892int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
1893int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
Michael Chandb4723b2018-03-31 13:54:13 -04001894int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);
Rob Swindell5ac67d82016-09-19 03:58:03 -04001895int bnxt_hwrm_fw_set_time(struct bnxt *);
Michael Chanc0c050c2015-10-22 16:01:17 -04001896int bnxt_open_nic(struct bnxt *, bool, bool);
Michael Chanf7dc1ea2017-04-04 18:14:13 -04001897int bnxt_half_open_nic(struct bnxt *bp);
1898void bnxt_half_close_nic(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001899int bnxt_close_nic(struct bnxt *, bool, bool);
Michael Chan98fdbe72017-08-28 13:40:26 -04001900int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1901 int tx_xdp);
Michael Chanc5e3deb2016-12-02 21:17:15 -05001902int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
Michael Chan6e6c5a52016-01-02 23:45:02 -05001903int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
Michael Chan80fcaf42018-01-17 03:21:05 -05001904int bnxt_restore_pf_fw_resources(struct bnxt *bp);
Florian Fainelli52d52542019-02-06 09:45:36 -08001905int bnxt_get_port_parent_id(struct net_device *dev,
1906 struct netdev_phys_item_id *ppid);
Andy Gospodarek6a8788f2018-01-09 16:06:20 -05001907void bnxt_dim_work(struct work_struct *work);
1908int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi);
1909
Michael Chanc0c050c2015-10-22 16:01:17 -04001910#endif