blob: 63756f0389d71e1d5ebe20cdef66661ef1aa40ed [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 Chanbac9a7e2017-02-12 19:18:10 -05004 * Copyright (c) 2016-2017 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 Chanacb20052017-07-24 12:34:20 -040015#define DRV_MODULE_VERSION "1.8.0"
Michael Chanc0c050c2015-10-22 16:01:17 -040016
Michael Chanc1935542015-12-27 18:19:28 -050017#define DRV_VER_MAJ 1
Michael Chanacb20052017-07-24 12:34:20 -040018#define DRV_VER_MIN 8
Michael Chanc1935542015-12-27 18:19:28 -050019#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 Perla4ab0c6a2017-07-24 12:34:27 -040022#include <net/devlink.h>
Sathya Perlaee5c7fb2017-07-24 12:34:28 -040023#include <net/dst_metadata.h>
Florian Westphal282ccf62017-03-29 17:17:31 +020024
Michael Chanc0c050c2015-10-22 16:01:17 -040025struct tx_bd {
26 __le32 tx_bd_len_flags_type;
27 #define TX_BD_TYPE (0x3f << 0)
28 #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0)
29 #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0)
30 #define TX_BD_FLAGS_PACKET_END (1 << 6)
31 #define TX_BD_FLAGS_NO_CMPL (1 << 7)
32 #define TX_BD_FLAGS_BD_CNT (0x1f << 8)
33 #define TX_BD_FLAGS_BD_CNT_SHIFT 8
34 #define TX_BD_FLAGS_LHINT (3 << 13)
35 #define TX_BD_FLAGS_LHINT_SHIFT 13
36 #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13)
37 #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13)
38 #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13)
39 #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13)
40 #define TX_BD_FLAGS_COAL_NOW (1 << 15)
41 #define TX_BD_LEN (0xffff << 16)
42 #define TX_BD_LEN_SHIFT 16
43
44 u32 tx_bd_opaque;
45 __le64 tx_bd_haddr;
46} __packed;
47
48struct tx_bd_ext {
49 __le32 tx_bd_hsize_lflags;
50 #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0)
51 #define TX_BD_FLAGS_IP_CKSUM (1 << 1)
52 #define TX_BD_FLAGS_NO_CRC (1 << 2)
53 #define TX_BD_FLAGS_STAMP (1 << 3)
54 #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4)
55 #define TX_BD_FLAGS_LSO (1 << 5)
56 #define TX_BD_FLAGS_IPID_FMT (1 << 6)
57 #define TX_BD_FLAGS_T_IPID (1 << 7)
58 #define TX_BD_HSIZE (0xff << 16)
59 #define TX_BD_HSIZE_SHIFT 16
60
61 __le32 tx_bd_mss;
62 __le32 tx_bd_cfa_action;
63 #define TX_BD_CFA_ACTION (0xffff << 16)
64 #define TX_BD_CFA_ACTION_SHIFT 16
65
66 __le32 tx_bd_cfa_meta;
67 #define TX_BD_CFA_META_MASK 0xfffffff
68 #define TX_BD_CFA_META_VID_MASK 0xfff
69 #define TX_BD_CFA_META_PRI_MASK (0xf << 12)
70 #define TX_BD_CFA_META_PRI_SHIFT 12
71 #define TX_BD_CFA_META_TPID_MASK (3 << 16)
72 #define TX_BD_CFA_META_TPID_SHIFT 16
73 #define TX_BD_CFA_META_KEY (0xf << 28)
74 #define TX_BD_CFA_META_KEY_SHIFT 28
75 #define TX_BD_CFA_META_KEY_VLAN (1 << 28)
76};
77
78struct rx_bd {
79 __le32 rx_bd_len_flags_type;
80 #define RX_BD_TYPE (0x3f << 0)
81 #define RX_BD_TYPE_RX_PACKET_BD 0x4
82 #define RX_BD_TYPE_RX_BUFFER_BD 0x5
83 #define RX_BD_TYPE_RX_AGG_BD 0x6
84 #define RX_BD_TYPE_16B_BD_SIZE (0 << 4)
85 #define RX_BD_TYPE_32B_BD_SIZE (1 << 4)
86 #define RX_BD_TYPE_48B_BD_SIZE (2 << 4)
87 #define RX_BD_TYPE_64B_BD_SIZE (3 << 4)
88 #define RX_BD_FLAGS_SOP (1 << 6)
89 #define RX_BD_FLAGS_EOP (1 << 7)
90 #define RX_BD_FLAGS_BUFFERS (3 << 8)
91 #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8)
92 #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8)
93 #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8)
94 #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8)
95 #define RX_BD_LEN (0xffff << 16)
96 #define RX_BD_LEN_SHIFT 16
97
98 u32 rx_bd_opaque;
99 __le64 rx_bd_haddr;
100};
101
102struct tx_cmp {
103 __le32 tx_cmp_flags_type;
104 #define CMP_TYPE (0x3f << 0)
105 #define CMP_TYPE_TX_L2_CMP 0
106 #define CMP_TYPE_RX_L2_CMP 17
107 #define CMP_TYPE_RX_AGG_CMP 18
108 #define CMP_TYPE_RX_L2_TPA_START_CMP 19
109 #define CMP_TYPE_RX_L2_TPA_END_CMP 21
110 #define CMP_TYPE_STATUS_CMP 32
111 #define CMP_TYPE_REMOTE_DRIVER_REQ 34
112 #define CMP_TYPE_REMOTE_DRIVER_RESP 36
113 #define CMP_TYPE_ERROR_STATUS 48
Michael Chan441cabb2016-09-19 03:58:02 -0400114 #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL
115 #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL
116 #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
117 #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL
118 #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL
Michael Chanc0c050c2015-10-22 16:01:17 -0400119
120 #define TX_CMP_FLAGS_ERROR (1 << 6)
121 #define TX_CMP_FLAGS_PUSH (1 << 7)
122
123 u32 tx_cmp_opaque;
124 __le32 tx_cmp_errors_v;
125 #define TX_CMP_V (1 << 0)
126 #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1)
127 #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0
128 #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2
129 #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4
130 #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5
131 #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4)
132 #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5)
133 #define TX_CMP_ERRORS_DMA_ERROR (1 << 6)
134 #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7)
135
136 __le32 tx_cmp_unsed_3;
137};
138
139struct rx_cmp {
140 __le32 rx_cmp_len_flags_type;
141 #define RX_CMP_CMP_TYPE (0x3f << 0)
142 #define RX_CMP_FLAGS_ERROR (1 << 6)
143 #define RX_CMP_FLAGS_PLACEMENT (7 << 7)
144 #define RX_CMP_FLAGS_RSS_VALID (1 << 10)
145 #define RX_CMP_FLAGS_UNUSED (1 << 11)
146 #define RX_CMP_FLAGS_ITYPES_SHIFT 12
147 #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
148 #define RX_CMP_FLAGS_ITYPE_IP (1 << 12)
149 #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12)
150 #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)
151 #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)
152 #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12)
153 #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)
154 #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)
155 #define RX_CMP_LEN (0xffff << 16)
156 #define RX_CMP_LEN_SHIFT 16
157
158 u32 rx_cmp_opaque;
159 __le32 rx_cmp_misc_v1;
160 #define RX_CMP_V1 (1 << 0)
161 #define RX_CMP_AGG_BUFS (0x1f << 1)
162 #define RX_CMP_AGG_BUFS_SHIFT 1
163 #define RX_CMP_RSS_HASH_TYPE (0x7f << 9)
164 #define RX_CMP_RSS_HASH_TYPE_SHIFT 9
165 #define RX_CMP_PAYLOAD_OFFSET (0xff << 16)
166 #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16
167
168 __le32 rx_cmp_rss_hash;
169};
170
171#define RX_CMP_HASH_VALID(rxcmp) \
172 ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
173
Michael Chan614388c2015-11-05 16:25:48 -0500174#define RSS_PROFILE_ID_MASK 0x1f
175
Michael Chanc0c050c2015-10-22 16:01:17 -0400176#define RX_CMP_HASH_TYPE(rxcmp) \
Michael Chan614388c2015-11-05 16:25:48 -0500177 (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\
178 RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
Michael Chanc0c050c2015-10-22 16:01:17 -0400179
180struct rx_cmp_ext {
181 __le32 rx_cmp_flags2;
182 #define RX_CMP_FLAGS2_IP_CS_CALC 0x1
183 #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
184 #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
185 #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
186 #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4)
187 __le32 rx_cmp_meta_data;
188 #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
189 #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000
190 #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16
191 __le32 rx_cmp_cfa_code_errors_v2;
192 #define RX_CMP_V (1 << 0)
193 #define RX_CMPL_ERRORS_MASK (0x7fff << 1)
194 #define RX_CMPL_ERRORS_SFT 1
195 #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1)
196 #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1)
197 #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1)
198 #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1)
199 #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1)
200 #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4)
201 #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5)
202 #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6)
203 #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7)
204 #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8)
205 #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9)
206 #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9)
207 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9)
208 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9)
209 #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9)
210 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9)
211 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9)
212 #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9)
213 #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12)
214 #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12)
215 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12)
216 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12)
217 #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12)
218 #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12)
219 #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12)
220 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12)
221 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12)
222 #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12)
223
224 #define RX_CMPL_CFA_CODE_MASK (0xffff << 16)
225 #define RX_CMPL_CFA_CODE_SFT 16
226
227 __le32 rx_cmp_unused3;
228};
229
230#define RX_CMP_L2_ERRORS \
231 cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR)
232
233#define RX_CMP_L4_CS_BITS \
234 (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC))
235
236#define RX_CMP_L4_CS_ERR_BITS \
237 (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR))
238
239#define RX_CMP_L4_CS_OK(rxcmp1) \
240 (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \
241 !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS))
242
243#define RX_CMP_ENCAP(rxcmp1) \
244 ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \
245 RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3)
246
Sathya Perlaee5c7fb2017-07-24 12:34:28 -0400247#define RX_CMP_CFA_CODE(rxcmpl1) \
248 ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \
249 RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT)
250
Michael Chanc0c050c2015-10-22 16:01:17 -0400251struct rx_agg_cmp {
252 __le32 rx_agg_cmp_len_flags_type;
253 #define RX_AGG_CMP_TYPE (0x3f << 0)
254 #define RX_AGG_CMP_LEN (0xffff << 16)
255 #define RX_AGG_CMP_LEN_SHIFT 16
256 u32 rx_agg_cmp_opaque;
257 __le32 rx_agg_cmp_v;
258 #define RX_AGG_CMP_V (1 << 0)
259 __le32 rx_agg_cmp_unused;
260};
261
262struct rx_tpa_start_cmp {
263 __le32 rx_tpa_start_cmp_len_flags_type;
264 #define RX_TPA_START_CMP_TYPE (0x3f << 0)
265 #define RX_TPA_START_CMP_FLAGS (0x3ff << 6)
266 #define RX_TPA_START_CMP_FLAGS_SHIFT 6
267 #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7)
268 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7
269 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
270 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
271 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
272 #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
273 #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10)
274 #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12)
275 #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12
276 #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
277 #define RX_TPA_START_CMP_LEN (0xffff << 16)
278 #define RX_TPA_START_CMP_LEN_SHIFT 16
279
280 u32 rx_tpa_start_cmp_opaque;
281 __le32 rx_tpa_start_cmp_misc_v1;
282 #define RX_TPA_START_CMP_V1 (0x1 << 0)
283 #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9)
284 #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9
285 #define RX_TPA_START_CMP_AGG_ID (0x7f << 25)
286 #define RX_TPA_START_CMP_AGG_ID_SHIFT 25
287
288 __le32 rx_tpa_start_cmp_rss_hash;
289};
290
291#define TPA_START_HASH_VALID(rx_tpa_start) \
292 ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \
293 cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID))
294
295#define TPA_START_HASH_TYPE(rx_tpa_start) \
Michael Chan614388c2015-11-05 16:25:48 -0500296 (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
297 RX_TPA_START_CMP_RSS_HASH_TYPE) >> \
298 RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK)
Michael Chanc0c050c2015-10-22 16:01:17 -0400299
300#define TPA_START_AGG_ID(rx_tpa_start) \
301 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \
302 RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT)
303
304struct rx_tpa_start_cmp_ext {
305 __le32 rx_tpa_start_cmp_flags2;
306 #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0)
307 #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1)
308 #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)
309 #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)
Michael Chan94758f82016-06-13 02:25:35 -0400310 #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8)
Michael Chanc0c050c2015-10-22 16:01:17 -0400311
312 __le32 rx_tpa_start_cmp_metadata;
313 __le32 rx_tpa_start_cmp_cfa_code_v2;
314 #define RX_TPA_START_CMP_V2 (0x1 << 0)
315 #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16)
316 #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16
Michael Chan94758f82016-06-13 02:25:35 -0400317 __le32 rx_tpa_start_cmp_hdr_info;
Michael Chanc0c050c2015-10-22 16:01:17 -0400318};
319
Sathya Perlaee5c7fb2017-07-24 12:34:28 -0400320#define TPA_START_CFA_CODE(rx_tpa_start) \
321 ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \
322 RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT)
323
Michael Chanc0c050c2015-10-22 16:01:17 -0400324struct rx_tpa_end_cmp {
325 __le32 rx_tpa_end_cmp_len_flags_type;
326 #define RX_TPA_END_CMP_TYPE (0x3f << 0)
327 #define RX_TPA_END_CMP_FLAGS (0x3ff << 6)
328 #define RX_TPA_END_CMP_FLAGS_SHIFT 6
329 #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7)
330 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7
331 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7)
332 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7)
333 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7)
334 #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7)
335 #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10)
336 #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12)
337 #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12
338 #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12)
339 #define RX_TPA_END_CMP_LEN (0xffff << 16)
340 #define RX_TPA_END_CMP_LEN_SHIFT 16
341
342 u32 rx_tpa_end_cmp_opaque;
343 __le32 rx_tpa_end_cmp_misc_v1;
344 #define RX_TPA_END_CMP_V1 (0x1 << 0)
345 #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1)
346 #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1
347 #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8)
348 #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8
349 #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16)
350 #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16
351 #define RX_TPA_END_CMP_AGG_ID (0x7f << 25)
352 #define RX_TPA_END_CMP_AGG_ID_SHIFT 25
353
354 __le32 rx_tpa_end_cmp_tsdelta;
355 #define RX_TPA_END_GRO_TS (0x1 << 31)
356};
357
358#define TPA_END_AGG_ID(rx_tpa_end) \
359 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
360 RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT)
361
362#define TPA_END_TPA_SEGS(rx_tpa_end) \
363 ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \
364 RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT)
365
366#define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \
367 cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \
368 RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS)
369
370#define TPA_END_GRO(rx_tpa_end) \
371 ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \
372 RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO)
373
374#define TPA_END_GRO_TS(rx_tpa_end) \
Michael Chana58a3e62016-07-01 18:46:20 -0400375 (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \
376 cpu_to_le32(RX_TPA_END_GRO_TS)))
Michael Chanc0c050c2015-10-22 16:01:17 -0400377
378struct rx_tpa_end_cmp_ext {
379 __le32 rx_tpa_end_cmp_dup_acks;
380 #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0)
381
382 __le32 rx_tpa_end_cmp_seg_len;
383 #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0)
384
385 __le32 rx_tpa_end_cmp_errors_v2;
386 #define RX_TPA_END_CMP_V2 (0x1 << 0)
Michael Chan69c149e2017-06-23 14:01:00 -0400387 #define RX_TPA_END_CMP_ERRORS (0x3 << 1)
Michael Chanc0c050c2015-10-22 16:01:17 -0400388 #define RX_TPA_END_CMPL_ERRORS_SHIFT 1
389
390 u32 rx_tpa_end_cmp_start_opaque;
391};
392
Michael Chan69c149e2017-06-23 14:01:00 -0400393#define TPA_END_ERRORS(rx_tpa_end_ext) \
394 ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \
395 cpu_to_le32(RX_TPA_END_CMP_ERRORS))
396
Michael Chanc0c050c2015-10-22 16:01:17 -0400397#define DB_IDX_MASK 0xffffff
398#define DB_IDX_VALID (0x1 << 26)
399#define DB_IRQ_DIS (0x1 << 27)
400#define DB_KEY_TX (0x0 << 28)
401#define DB_KEY_RX (0x1 << 28)
402#define DB_KEY_CP (0x2 << 28)
403#define DB_KEY_ST (0x3 << 28)
404#define DB_KEY_TX_PUSH (0x4 << 28)
405#define DB_LONG_TX_PUSH (0x2 << 24)
406
Michael Chane4060d32016-12-07 00:26:19 -0500407#define BNXT_MIN_ROCE_CP_RINGS 2
408#define BNXT_MIN_ROCE_STAT_CTXS 1
409
Michael Chanc0c050c2015-10-22 16:01:17 -0400410#define INVALID_HW_RING_ID ((u16)-1)
411
Michael Chanc0c050c2015-10-22 16:01:17 -0400412/* The hardware supports certain page sizes. Use the supported page sizes
413 * to allocate the rings.
414 */
415#if (PAGE_SHIFT < 12)
416#define BNXT_PAGE_SHIFT 12
417#elif (PAGE_SHIFT <= 13)
418#define BNXT_PAGE_SHIFT PAGE_SHIFT
419#elif (PAGE_SHIFT < 16)
420#define BNXT_PAGE_SHIFT 13
421#else
422#define BNXT_PAGE_SHIFT 16
423#endif
424
425#define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT)
426
Michael Chan2839f282016-04-25 02:30:50 -0400427/* The RXBD length is 16-bit so we can only support page sizes < 64K */
428#if (PAGE_SHIFT > 15)
429#define BNXT_RX_PAGE_SHIFT 15
430#else
431#define BNXT_RX_PAGE_SHIFT PAGE_SHIFT
432#endif
433
434#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
435
Michael Chanc61fb992017-02-06 16:55:36 -0500436#define BNXT_MAX_MTU 9500
437#define BNXT_MAX_PAGE_MODE_MTU \
Michael Chanc6d30e82017-02-06 16:55:42 -0500438 ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \
439 XDP_PACKET_HEADROOM)
Michael Chanc61fb992017-02-06 16:55:36 -0500440
Michael Chan4ffcd582016-09-19 03:58:07 -0400441#define BNXT_MIN_PKT_SIZE 52
Michael Chanc0c050c2015-10-22 16:01:17 -0400442
Michael Chan51dd55b2016-02-10 17:33:50 -0500443#define BNXT_DEFAULT_RX_RING_SIZE 511
444#define BNXT_DEFAULT_TX_RING_SIZE 511
Michael Chanc0c050c2015-10-22 16:01:17 -0400445
446#define MAX_TPA 64
447
Michael Chand0a42d62016-05-15 03:04:46 -0400448#if (BNXT_PAGE_SHIFT == 16)
449#define MAX_RX_PAGES 1
450#define MAX_RX_AGG_PAGES 4
451#define MAX_TX_PAGES 1
452#define MAX_CP_PAGES 8
453#else
Michael Chanc0c050c2015-10-22 16:01:17 -0400454#define MAX_RX_PAGES 8
455#define MAX_RX_AGG_PAGES 32
456#define MAX_TX_PAGES 8
457#define MAX_CP_PAGES 64
Michael Chand0a42d62016-05-15 03:04:46 -0400458#endif
Michael Chanc0c050c2015-10-22 16:01:17 -0400459
460#define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd))
461#define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd))
462#define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp))
463
464#define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT)
465#define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT)
466
467#define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT)
468
469#define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT)
470#define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT)
471
472#define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT)
473
474#define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1)
475#define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
476#define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1)
477
478#define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
479#define RX_IDX(x) ((x) & (RX_DESC_CNT - 1))
480
481#define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
482#define TX_IDX(x) ((x) & (TX_DESC_CNT - 1))
483
484#define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
485#define CP_IDX(x) ((x) & (CP_DESC_CNT - 1))
486
487#define TX_CMP_VALID(txcmp, raw_cons) \
488 (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \
489 !((raw_cons) & bp->cp_bit))
490
491#define RX_CMP_VALID(rxcmp1, raw_cons) \
492 (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
493 !((raw_cons) & bp->cp_bit))
494
495#define RX_AGG_CMP_VALID(agg, raw_cons) \
496 (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \
497 !((raw_cons) & bp->cp_bit))
498
499#define TX_CMP_TYPE(txcmp) \
500 (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
501
502#define RX_CMP_TYPE(rxcmp) \
503 (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE)
504
505#define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask)
506
507#define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask)
508
509#define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask)
510
511#define ADV_RAW_CMP(idx, n) ((idx) + (n))
512#define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1)
513#define RING_CMP(idx) ((idx) & bp->cp_ring_mask)
514#define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1))
515
Michael Chane6ef2692016-03-28 19:46:05 -0400516#define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
Deepak Khungare605db82017-05-29 19:06:04 -0400517#define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input)
Michael Chanff4fe812016-02-26 04:00:04 -0500518#define DFLT_HWRM_CMD_TIMEOUT 500
519#define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
Michael Chanc0c050c2015-10-22 16:01:17 -0400520#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
521#define HWRM_RESP_ERR_CODE_MASK 0xffff
Michael Chana8643e12016-02-26 04:00:05 -0500522#define HWRM_RESP_LEN_OFFSET 4
Michael Chanc0c050c2015-10-22 16:01:17 -0400523#define HWRM_RESP_LEN_MASK 0xffff0000
524#define HWRM_RESP_LEN_SFT 16
525#define HWRM_RESP_VALID_MASK 0xff000000
Michael Chana8643e12016-02-26 04:00:05 -0500526#define HWRM_SEQ_ID_INVALID -1
Michael Chanc0c050c2015-10-22 16:01:17 -0400527#define BNXT_HWRM_REQ_MAX_SIZE 128
528#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
529 BNXT_HWRM_REQ_MAX_SIZE)
530
Michael Chan4e5dbbda2017-02-06 16:55:37 -0500531#define BNXT_RX_EVENT 1
532#define BNXT_AGG_EVENT 2
Michael Chan38413402017-02-06 16:55:43 -0500533#define BNXT_TX_EVENT 4
Michael Chan4e5dbbda2017-02-06 16:55:37 -0500534
Michael Chanc0c050c2015-10-22 16:01:17 -0400535struct bnxt_sw_tx_bd {
536 struct sk_buff *skb;
537 DEFINE_DMA_UNMAP_ADDR(mapping);
538 u8 is_gso;
539 u8 is_push;
Michael Chan38413402017-02-06 16:55:43 -0500540 union {
541 unsigned short nr_frags;
542 u16 rx_prod;
543 };
Michael Chanc0c050c2015-10-22 16:01:17 -0400544};
545
546struct bnxt_sw_rx_bd {
Michael Chan6bb19472017-02-06 16:55:32 -0500547 void *data;
548 u8 *data_ptr;
Michael Chan11cd1192017-02-06 16:55:33 -0500549 dma_addr_t mapping;
Michael Chanc0c050c2015-10-22 16:01:17 -0400550};
551
552struct bnxt_sw_rx_agg_bd {
553 struct page *page;
Michael Chan89d0a062016-04-25 02:30:51 -0400554 unsigned int offset;
Michael Chanc0c050c2015-10-22 16:01:17 -0400555 dma_addr_t mapping;
556};
557
558struct bnxt_ring_struct {
559 int nr_pages;
560 int page_size;
561 void **pg_arr;
562 dma_addr_t *dma_arr;
563
564 __le64 *pg_tbl;
565 dma_addr_t pg_tbl_map;
566
567 int vmem_size;
568 void **vmem;
569
570 u16 fw_ring_id; /* Ring id filled by Chimp FW */
571 u8 queue_id;
572};
573
574struct tx_push_bd {
575 __le32 doorbell;
Michael Chan4419dbe2016-02-10 17:33:49 -0500576 __le32 tx_bd_len_flags_type;
577 u32 tx_bd_opaque;
Michael Chanc0c050c2015-10-22 16:01:17 -0400578 struct tx_bd_ext txbd2;
579};
580
Michael Chan4419dbe2016-02-10 17:33:49 -0500581struct tx_push_buffer {
582 struct tx_push_bd push_bd;
583 u32 data[25];
584};
585
Michael Chanc0c050c2015-10-22 16:01:17 -0400586struct bnxt_tx_ring_info {
Michael Chanb6ab4b02016-01-02 23:44:59 -0500587 struct bnxt_napi *bnapi;
Michael Chanc0c050c2015-10-22 16:01:17 -0400588 u16 tx_prod;
589 u16 tx_cons;
Michael Chana960dec2017-02-06 16:55:39 -0500590 u16 txq_index;
Michael Chanc0c050c2015-10-22 16:01:17 -0400591 void __iomem *tx_doorbell;
592
593 struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
594 struct bnxt_sw_tx_bd *tx_buf_ring;
595
596 dma_addr_t tx_desc_mapping[MAX_TX_PAGES];
597
Michael Chan4419dbe2016-02-10 17:33:49 -0500598 struct tx_push_buffer *tx_push;
Michael Chanc0c050c2015-10-22 16:01:17 -0400599 dma_addr_t tx_push_mapping;
Michael Chan4419dbe2016-02-10 17:33:49 -0500600 __le64 data_mapping;
Michael Chanc0c050c2015-10-22 16:01:17 -0400601
602#define BNXT_DEV_STATE_CLOSING 0x1
603 u32 dev_state;
604
605 struct bnxt_ring_struct tx_ring_struct;
606};
607
608struct bnxt_tpa_info {
Michael Chan6bb19472017-02-06 16:55:32 -0500609 void *data;
610 u8 *data_ptr;
Michael Chanc0c050c2015-10-22 16:01:17 -0400611 dma_addr_t mapping;
612 u16 len;
613 unsigned short gso_type;
614 u32 flags2;
615 u32 metadata;
616 enum pkt_hash_types hash_type;
617 u32 rss_hash;
Michael Chan94758f82016-06-13 02:25:35 -0400618 u32 hdr_info;
619
620#define BNXT_TPA_L4_SIZE(hdr_info) \
621 (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32)
622
623#define BNXT_TPA_INNER_L3_OFF(hdr_info) \
624 (((hdr_info) >> 18) & 0x1ff)
625
626#define BNXT_TPA_INNER_L2_OFF(hdr_info) \
627 (((hdr_info) >> 9) & 0x1ff)
628
629#define BNXT_TPA_OUTER_L3_OFF(hdr_info) \
630 ((hdr_info) & 0x1ff)
Sathya Perla4ab0c6a2017-07-24 12:34:27 -0400631
632 u16 cfa_code; /* cfa_code in TPA start compl */
Michael Chanc0c050c2015-10-22 16:01:17 -0400633};
634
635struct bnxt_rx_ring_info {
Michael Chanb6ab4b02016-01-02 23:44:59 -0500636 struct bnxt_napi *bnapi;
Michael Chanc0c050c2015-10-22 16:01:17 -0400637 u16 rx_prod;
638 u16 rx_agg_prod;
639 u16 rx_sw_agg_prod;
Michael Chan376a5b82016-05-10 19:17:59 -0400640 u16 rx_next_cons;
Michael Chanc0c050c2015-10-22 16:01:17 -0400641 void __iomem *rx_doorbell;
642 void __iomem *rx_agg_doorbell;
643
Michael Chanc6d30e82017-02-06 16:55:42 -0500644 struct bpf_prog *xdp_prog;
645
Michael Chanc0c050c2015-10-22 16:01:17 -0400646 struct rx_bd *rx_desc_ring[MAX_RX_PAGES];
647 struct bnxt_sw_rx_bd *rx_buf_ring;
648
649 struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES];
650 struct bnxt_sw_rx_agg_bd *rx_agg_ring;
651
652 unsigned long *rx_agg_bmap;
653 u16 rx_agg_bmap_size;
654
Michael Chan89d0a062016-04-25 02:30:51 -0400655 struct page *rx_page;
656 unsigned int rx_page_offset;
657
Michael Chanc0c050c2015-10-22 16:01:17 -0400658 dma_addr_t rx_desc_mapping[MAX_RX_PAGES];
659 dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES];
660
661 struct bnxt_tpa_info *rx_tpa;
662
663 struct bnxt_ring_struct rx_ring_struct;
664 struct bnxt_ring_struct rx_agg_ring_struct;
665};
666
667struct bnxt_cp_ring_info {
668 u32 cp_raw_cons;
669 void __iomem *cp_doorbell;
670
671 struct tx_cmp *cp_desc_ring[MAX_CP_PAGES];
672
673 dma_addr_t cp_desc_mapping[MAX_CP_PAGES];
674
675 struct ctx_hw_stats *hw_stats;
676 dma_addr_t hw_stats_map;
677 u32 hw_stats_ctx_id;
678 u64 rx_l4_csum_errors;
679
680 struct bnxt_ring_struct cp_ring_struct;
681};
682
683struct bnxt_napi {
684 struct napi_struct napi;
685 struct bnxt *bp;
686
687 int index;
688 struct bnxt_cp_ring_info cp_ring;
Michael Chanb6ab4b02016-01-02 23:44:59 -0500689 struct bnxt_rx_ring_info *rx_ring;
690 struct bnxt_tx_ring_info *tx_ring;
Michael Chanc0c050c2015-10-22 16:01:17 -0400691
Michael Chanfa3e93e2017-02-06 16:55:41 -0500692 void (*tx_int)(struct bnxt *, struct bnxt_napi *,
693 int);
694 u32 flags;
695#define BNXT_NAPI_FLAG_XDP 0x1
696
Michael Chanfa7e2812016-05-10 19:18:00 -0400697 bool in_reset;
Michael Chanc0c050c2015-10-22 16:01:17 -0400698};
699
Michael Chanc0c050c2015-10-22 16:01:17 -0400700struct bnxt_irq {
701 irq_handler_t handler;
702 unsigned int vector;
703 u8 requested;
704 char name[IFNAMSIZ + 2];
705};
706
707#define HWRM_RING_ALLOC_TX 0x1
708#define HWRM_RING_ALLOC_RX 0x2
709#define HWRM_RING_ALLOC_AGG 0x4
710#define HWRM_RING_ALLOC_CMPL 0x8
711
712#define INVALID_STATS_CTX_ID -1
713
Michael Chanc0c050c2015-10-22 16:01:17 -0400714struct bnxt_ring_grp_info {
715 u16 fw_stats_ctx;
716 u16 fw_grp_id;
717 u16 rx_fw_ring_id;
718 u16 agg_fw_ring_id;
719 u16 cp_fw_ring_id;
720};
721
722struct bnxt_vnic_info {
723 u16 fw_vnic_id; /* returned by Chimp during alloc */
Prashant Sreedharan94ce9ca2016-07-18 07:15:21 -0400724#define BNXT_MAX_CTX_PER_VNIC 2
725 u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC];
Michael Chanc0c050c2015-10-22 16:01:17 -0400726 u16 fw_l2_ctx_id;
727#define BNXT_MAX_UC_ADDRS 4
728 __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS];
729 /* index 0 always dev_addr */
730 u16 uc_filter_count;
731 u8 *uc_list;
732
733 u16 *fw_grp_ids;
Michael Chanc0c050c2015-10-22 16:01:17 -0400734 dma_addr_t rss_table_dma_addr;
735 __le16 *rss_table;
736 dma_addr_t rss_hash_key_dma_addr;
737 u64 *rss_hash_key;
738 u32 rx_mask;
739
740 u8 *mc_list;
741 int mc_list_size;
742 int mc_list_count;
743 dma_addr_t mc_list_mapping;
744#define BNXT_MAX_MC_ADDRS 16
745
746 u32 flags;
747#define BNXT_VNIC_RSS_FLAG 1
748#define BNXT_VNIC_RFS_FLAG 2
749#define BNXT_VNIC_MCAST_FLAG 4
750#define BNXT_VNIC_UCAST_FLAG 8
Michael Chanae10ae72016-12-29 12:13:38 -0500751#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10
Michael Chanc0c050c2015-10-22 16:01:17 -0400752};
753
754#if defined(CONFIG_BNXT_SRIOV)
755struct bnxt_vf_info {
756 u16 fw_fid;
757 u8 mac_addr[ETH_ALEN];
758 u16 max_rsscos_ctxs;
759 u16 max_cp_rings;
760 u16 max_tx_rings;
761 u16 max_rx_rings;
Michael Chanb72d4a62015-12-27 18:19:27 -0500762 u16 max_hw_ring_grps;
Michael Chanc0c050c2015-10-22 16:01:17 -0400763 u16 max_l2_ctxs;
764 u16 max_irqs;
765 u16 max_vnics;
766 u16 max_stat_ctxs;
767 u16 vlan;
768 u32 flags;
769#define BNXT_VF_QOS 0x1
770#define BNXT_VF_SPOOFCHK 0x2
771#define BNXT_VF_LINK_FORCED 0x4
772#define BNXT_VF_LINK_UP 0x8
773 u32 func_flags; /* func cfg flags */
774 u32 min_tx_rate;
775 u32 max_tx_rate;
776 void *hwrm_cmd_req_addr;
777 dma_addr_t hwrm_cmd_req_dma_addr;
778};
Michael Chan379a80a2015-10-23 15:06:19 -0400779#endif
Michael Chanc0c050c2015-10-22 16:01:17 -0400780
781struct bnxt_pf_info {
782#define BNXT_FIRST_PF_FID 1
783#define BNXT_FIRST_VF_FID 128
Michael Chana58a3e62016-07-01 18:46:20 -0400784 u16 fw_fid;
785 u16 port_id;
Michael Chanc0c050c2015-10-22 16:01:17 -0400786 u8 mac_addr[ETH_ALEN];
787 u16 max_rsscos_ctxs;
788 u16 max_cp_rings;
789 u16 max_tx_rings; /* HW assigned max tx rings for this PF */
Michael Chanc0c050c2015-10-22 16:01:17 -0400790 u16 max_rx_rings; /* HW assigned max rx rings for this PF */
Michael Chanb72d4a62015-12-27 18:19:27 -0500791 u16 max_hw_ring_grps;
Michael Chanc0c050c2015-10-22 16:01:17 -0400792 u16 max_irqs;
793 u16 max_l2_ctxs;
794 u16 max_vnics;
795 u16 max_stat_ctxs;
796 u32 first_vf_id;
797 u16 active_vfs;
798 u16 max_vfs;
799 u32 max_encap_records;
800 u32 max_decap_records;
801 u32 max_tx_em_flows;
802 u32 max_tx_wm_flows;
803 u32 max_rx_em_flows;
804 u32 max_rx_wm_flows;
805 unsigned long *vf_event_bmap;
806 u16 hwrm_cmd_req_pages;
807 void *hwrm_cmd_req_addr[4];
808 dma_addr_t hwrm_cmd_req_dma_addr[4];
809 struct bnxt_vf_info *vf;
810};
Michael Chanc0c050c2015-10-22 16:01:17 -0400811
812struct bnxt_ntuple_filter {
813 struct hlist_node hash;
Michael Chana54c4d72016-07-25 12:33:35 -0400814 u8 dst_mac_addr[ETH_ALEN];
Michael Chanc0c050c2015-10-22 16:01:17 -0400815 u8 src_mac_addr[ETH_ALEN];
816 struct flow_keys fkeys;
817 __le64 filter_id;
818 u16 sw_id;
Michael Chana54c4d72016-07-25 12:33:35 -0400819 u8 l2_fltr_idx;
Michael Chanc0c050c2015-10-22 16:01:17 -0400820 u16 rxq;
821 u32 flow_id;
822 unsigned long state;
823#define BNXT_FLTR_VALID 0
824#define BNXT_FLTR_UPDATE 1
825};
826
Michael Chanc0c050c2015-10-22 16:01:17 -0400827struct bnxt_link_info {
Michael Chan03efbec2016-04-11 04:11:11 -0400828 u8 phy_type;
Michael Chanc0c050c2015-10-22 16:01:17 -0400829 u8 media_type;
830 u8 transceiver;
831 u8 phy_addr;
832 u8 phy_link_status;
833#define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK
834#define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL
835#define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK
836 u8 wire_speed;
837 u8 loop_back;
838 u8 link_up;
839 u8 duplex;
Michael Chanacb20052017-07-24 12:34:20 -0400840#define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF
841#define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL
Michael Chanc0c050c2015-10-22 16:01:17 -0400842 u8 pause;
843#define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX
844#define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX
845#define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \
846 PORT_PHY_QCFG_RESP_PAUSE_TX)
Michael Chan32773602016-03-07 15:38:42 -0500847 u8 lp_pause;
Michael Chanc0c050c2015-10-22 16:01:17 -0400848 u8 auto_pause_setting;
849 u8 force_pause_setting;
850 u8 duplex_setting;
851 u8 auto_mode;
852#define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \
853 (mode) <= BNXT_LINK_AUTO_MSK)
854#define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE
855#define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS
856#define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED
857#define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW
Michael Chan11f15ed2016-04-05 14:08:55 -0400858#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK
Michael Chanc0c050c2015-10-22 16:01:17 -0400859#define PHY_VER_LEN 3
860 u8 phy_ver[PHY_VER_LEN];
861 u16 link_speed;
862#define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB
863#define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB
864#define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB
865#define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB
866#define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB
867#define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB
868#define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB
869#define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB
870#define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB
Deepak Khungar38a21b32017-04-21 20:11:24 -0400871#define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB
Michael Chanc0c050c2015-10-22 16:01:17 -0400872 u16 support_speeds;
Michael Chan68515a12016-12-29 12:13:34 -0500873 u16 auto_link_speeds; /* fw adv setting */
Michael Chanc0c050c2015-10-22 16:01:17 -0400874#define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB
875#define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB
876#define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB
877#define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB
878#define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB
879#define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB
880#define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
881#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
882#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
Deepak Khungar38a21b32017-04-21 20:11:24 -0400883#define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB
Michael Chan93ed8112016-06-13 02:25:37 -0400884 u16 support_auto_speeds;
Michael Chan32773602016-03-07 15:38:42 -0500885 u16 lp_auto_link_speeds;
Michael Chanc0c050c2015-10-22 16:01:17 -0400886 u16 force_link_speed;
887 u32 preemphasis;
Ajit Khaparde42ee18f2016-05-15 03:04:44 -0400888 u8 module_status;
Michael Chane70c7522017-02-12 19:18:16 -0500889 u16 fec_cfg;
890#define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED
891#define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED
892#define BNXT_FEC_ENC_RS PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED
Michael Chanc0c050c2015-10-22 16:01:17 -0400893
894 /* copy of requested setting from ethtool cmd */
895 u8 autoneg;
896#define BNXT_AUTONEG_SPEED 1
897#define BNXT_AUTONEG_FLOW_CTRL 2
898 u8 req_duplex;
899 u8 req_flow_ctrl;
900 u16 req_link_speed;
Michael Chan68515a12016-12-29 12:13:34 -0500901 u16 advertising; /* user adv setting */
Michael Chanc0c050c2015-10-22 16:01:17 -0400902 bool force_link_chng;
Michael Chan4bb13ab2016-04-05 14:09:01 -0400903
Michael Chanc0c050c2015-10-22 16:01:17 -0400904 /* a copy of phy_qcfg output used to report link
905 * info to VF
906 */
907 struct hwrm_port_phy_qcfg_output phy_qcfg_resp;
908};
909
910#define BNXT_MAX_QUEUE 8
911
912struct bnxt_queue_info {
913 u8 queue_id;
914 u8 queue_profile;
915};
916
Michael Chan5ad2cbe2017-01-13 01:32:03 -0500917#define BNXT_MAX_LED 4
918
919struct bnxt_led_info {
920 u8 led_id;
921 u8 led_type;
922 u8 led_group_id;
923 u8 unused;
924 __le16 led_state_caps;
925#define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \
926 cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED))
927
928 __le16 led_color_caps;
929};
930
Michael Chaneb513652017-04-04 18:14:12 -0400931#define BNXT_MAX_TEST 8
932
933struct bnxt_test_info {
934 u8 offline_mask;
935 u16 timeout;
936 char string[BNXT_MAX_TEST][ETH_GSTRING_LEN];
937};
938
Jeffrey Huang11809492015-11-05 16:25:49 -0500939#define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400
940#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
941#define BNXT_CAG_REG_BASE 0x300000
942
Sathya Perla4ab0c6a2017-07-24 12:34:27 -0400943struct bnxt_vf_rep_stats {
944 u64 packets;
945 u64 bytes;
946 u64 dropped;
947};
948
949struct bnxt_vf_rep {
950 struct bnxt *bp;
951 struct net_device *dev;
Sathya Perlaee5c7fb2017-07-24 12:34:28 -0400952 struct metadata_dst *dst;
Sathya Perla4ab0c6a2017-07-24 12:34:27 -0400953 u16 vf_idx;
954 u16 tx_cfa_action;
955 u16 rx_cfa_code;
956
957 struct bnxt_vf_rep_stats rx_stats;
958 struct bnxt_vf_rep_stats tx_stats;
959};
960
Michael Chanc0c050c2015-10-22 16:01:17 -0400961struct bnxt {
962 void __iomem *bar0;
963 void __iomem *bar1;
964 void __iomem *bar2;
965
966 u32 reg_base;
Michael Chan659c8052016-06-13 02:25:33 -0400967 u16 chip_num;
968#define CHIP_NUM_57301 0x16c8
969#define CHIP_NUM_57302 0x16c9
970#define CHIP_NUM_57304 0x16ca
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -0400971#define CHIP_NUM_58700 0x16cd
Michael Chan659c8052016-06-13 02:25:33 -0400972#define CHIP_NUM_57402 0x16d0
973#define CHIP_NUM_57404 0x16d1
974#define CHIP_NUM_57406 0x16d2
Michael Chan3284f9e2017-05-29 19:06:07 -0400975#define CHIP_NUM_57407 0x16d5
Michael Chan659c8052016-06-13 02:25:33 -0400976
977#define CHIP_NUM_57311 0x16ce
978#define CHIP_NUM_57312 0x16cf
979#define CHIP_NUM_57314 0x16df
Michael Chan3284f9e2017-05-29 19:06:07 -0400980#define CHIP_NUM_57317 0x16e0
Michael Chan659c8052016-06-13 02:25:33 -0400981#define CHIP_NUM_57412 0x16d6
982#define CHIP_NUM_57414 0x16d7
983#define CHIP_NUM_57416 0x16d8
984#define CHIP_NUM_57417 0x16d9
Michael Chan3284f9e2017-05-29 19:06:07 -0400985#define CHIP_NUM_57412L 0x16da
986#define CHIP_NUM_57414L 0x16db
987
988#define CHIP_NUM_5745X 0xd730
Michael Chan659c8052016-06-13 02:25:33 -0400989
990#define BNXT_CHIP_NUM_5730X(chip_num) \
991 ((chip_num) >= CHIP_NUM_57301 && \
992 (chip_num) <= CHIP_NUM_57304)
993
994#define BNXT_CHIP_NUM_5740X(chip_num) \
Michael Chan3284f9e2017-05-29 19:06:07 -0400995 (((chip_num) >= CHIP_NUM_57402 && \
996 (chip_num) <= CHIP_NUM_57406) || \
997 (chip_num) == CHIP_NUM_57407)
Michael Chan659c8052016-06-13 02:25:33 -0400998
999#define BNXT_CHIP_NUM_5731X(chip_num) \
1000 ((chip_num) == CHIP_NUM_57311 || \
1001 (chip_num) == CHIP_NUM_57312 || \
Michael Chan3284f9e2017-05-29 19:06:07 -04001002 (chip_num) == CHIP_NUM_57314 || \
1003 (chip_num) == CHIP_NUM_57317)
Michael Chan659c8052016-06-13 02:25:33 -04001004
1005#define BNXT_CHIP_NUM_5741X(chip_num) \
1006 ((chip_num) >= CHIP_NUM_57412 && \
Michael Chan3284f9e2017-05-29 19:06:07 -04001007 (chip_num) <= CHIP_NUM_57414L)
1008
1009#define BNXT_CHIP_NUM_58700(chip_num) \
1010 ((chip_num) == CHIP_NUM_58700)
1011
1012#define BNXT_CHIP_NUM_5745X(chip_num) \
1013 ((chip_num) == CHIP_NUM_5745X)
Michael Chan659c8052016-06-13 02:25:33 -04001014
1015#define BNXT_CHIP_NUM_57X0X(chip_num) \
1016 (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num))
1017
1018#define BNXT_CHIP_NUM_57X1X(chip_num) \
1019 (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num))
Michael Chanc0c050c2015-10-22 16:01:17 -04001020
1021 struct net_device *dev;
1022 struct pci_dev *pdev;
1023
1024 atomic_t intr_sem;
1025
1026 u32 flags;
1027 #define BNXT_FLAG_DCB_ENABLED 0x1
1028 #define BNXT_FLAG_VF 0x2
1029 #define BNXT_FLAG_LRO 0x4
Michael Chand1611c32015-10-25 22:27:57 -04001030#ifdef CONFIG_INET
Michael Chanc0c050c2015-10-22 16:01:17 -04001031 #define BNXT_FLAG_GRO 0x8
Michael Chand1611c32015-10-25 22:27:57 -04001032#else
1033 /* Cannot support hardware GRO if CONFIG_INET is not set */
1034 #define BNXT_FLAG_GRO 0x0
1035#endif
Michael Chanc0c050c2015-10-22 16:01:17 -04001036 #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO)
1037 #define BNXT_FLAG_JUMBO 0x10
1038 #define BNXT_FLAG_STRIP_VLAN 0x20
1039 #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
1040 BNXT_FLAG_LRO)
1041 #define BNXT_FLAG_USING_MSIX 0x40
1042 #define BNXT_FLAG_MSIX_CAP 0x80
1043 #define BNXT_FLAG_RFS 0x100
Michael Chan6e6c5a52016-01-02 23:45:02 -05001044 #define BNXT_FLAG_SHARED_RINGS 0x200
Michael Chan3bdf56c2016-03-07 15:38:45 -05001045 #define BNXT_FLAG_PORT_STATS 0x400
Michael Chan87da7f72016-11-16 21:13:09 -05001046 #define BNXT_FLAG_UDP_RSS_CAP 0x800
Michael Chan170ce012016-04-05 14:08:57 -04001047 #define BNXT_FLAG_EEE_CAP 0x1000
Michael Chan8fdefd62016-12-29 12:13:36 -05001048 #define BNXT_FLAG_NEW_RSS_CAP 0x2000
Michael Chanc1ef1462017-04-04 18:14:07 -04001049 #define BNXT_FLAG_WOL_CAP 0x4000
Michael Chane4060d32016-12-07 00:26:19 -05001050 #define BNXT_FLAG_ROCEV1_CAP 0x8000
1051 #define BNXT_FLAG_ROCEV2_CAP 0x10000
1052 #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \
1053 BNXT_FLAG_ROCEV2_CAP)
Michael Chanbdbd1eb2016-12-29 12:13:43 -05001054 #define BNXT_FLAG_NO_AGG_RINGS 0x20000
Michael Chanc61fb992017-02-06 16:55:36 -05001055 #define BNXT_FLAG_RX_PAGE_MODE 0x40000
Michael Chanbc39f882017-03-08 18:44:34 -05001056 #define BNXT_FLAG_FW_LLDP_AGENT 0x80000
Deepak Khungar9e54e322017-04-21 20:11:26 -04001057 #define BNXT_FLAG_MULTI_HOST 0x100000
Deepak Khungare605db82017-05-29 19:06:04 -04001058 #define BNXT_FLAG_SHORT_CMD 0x200000
Michael Chan434c9752017-05-29 19:06:08 -04001059 #define BNXT_FLAG_DOUBLE_DB 0x400000
Michael Chan9315edc2017-07-24 12:34:25 -04001060 #define BNXT_FLAG_FW_DCBX_AGENT 0x800000
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -04001061 #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000
Michael Chan6e6c5a52016-01-02 23:45:02 -05001062
Michael Chanc0c050c2015-10-22 16:01:17 -04001063 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
1064 BNXT_FLAG_RFS | \
1065 BNXT_FLAG_STRIP_VLAN)
1066
1067#define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
1068#define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
Satish Baddipadige567b2ab2016-06-13 02:25:31 -04001069#define BNXT_NPAR(bp) ((bp)->port_partition_type)
Deepak Khungar9e54e322017-04-21 20:11:26 -04001070#define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST)
1071#define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
Prashant Sreedharan3e8060f2016-07-18 07:15:20 -04001072#define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
Michael Chanc61fb992017-02-06 16:55:36 -05001073#define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)
Michael Chanc0c050c2015-10-22 16:01:17 -04001074
Michael Chan3284f9e2017-05-29 19:06:07 -04001075/* Chip class phase 4 and later */
1076#define BNXT_CHIP_P4_PLUS(bp) \
1077 (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \
1078 BNXT_CHIP_NUM_5745X((bp)->chip_num) || \
1079 (BNXT_CHIP_NUM_58700((bp)->chip_num) && \
1080 !BNXT_CHIP_TYPE_NITRO_A0(bp)))
1081
Michael Chana588e452016-12-07 00:26:21 -05001082 struct bnxt_en_dev *edev;
1083 struct bnxt_en_dev * (*ulp_probe)(struct net_device *);
1084
Michael Chanc0c050c2015-10-22 16:01:17 -04001085 struct bnxt_napi **bnapi;
1086
Michael Chanb6ab4b02016-01-02 23:44:59 -05001087 struct bnxt_rx_ring_info *rx_ring;
1088 struct bnxt_tx_ring_info *tx_ring;
Michael Chana960dec2017-02-06 16:55:39 -05001089 u16 *tx_ring_map;
Michael Chanb6ab4b02016-01-02 23:44:59 -05001090
Michael Chan309369c2016-06-13 02:25:34 -04001091 struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int,
1092 struct sk_buff *);
1093
Michael Chan6bb19472017-02-06 16:55:32 -05001094 struct sk_buff * (*rx_skb_func)(struct bnxt *,
1095 struct bnxt_rx_ring_info *,
1096 u16, void *, u8 *, dma_addr_t,
1097 unsigned int);
1098
Michael Chanc0c050c2015-10-22 16:01:17 -04001099 u32 rx_buf_size;
1100 u32 rx_buf_use_size; /* useable size */
Michael Chanb3dba772017-02-06 16:55:35 -05001101 u16 rx_offset;
1102 u16 rx_dma_offset;
Michael Chan745fc052017-02-06 16:55:34 -05001103 enum dma_data_direction rx_dir;
Michael Chanc0c050c2015-10-22 16:01:17 -04001104 u32 rx_ring_size;
1105 u32 rx_agg_ring_size;
1106 u32 rx_copy_thresh;
1107 u32 rx_ring_mask;
1108 u32 rx_agg_ring_mask;
1109 int rx_nr_pages;
1110 int rx_agg_nr_pages;
1111 int rx_nr_rings;
1112 int rsscos_nr_ctxs;
1113
1114 u32 tx_ring_size;
1115 u32 tx_ring_mask;
1116 int tx_nr_pages;
1117 int tx_nr_rings;
1118 int tx_nr_rings_per_tc;
Michael Chan5f449242017-02-06 16:55:40 -05001119 int tx_nr_rings_xdp;
Michael Chanc0c050c2015-10-22 16:01:17 -04001120
1121 int tx_wake_thresh;
1122 int tx_push_thresh;
1123 int tx_push_size;
1124
1125 u32 cp_ring_size;
1126 u32 cp_ring_mask;
1127 u32 cp_bit;
1128 int cp_nr_pages;
1129 int cp_nr_rings;
1130
1131 int num_stat_ctxs;
Michael Chanb81a90d2016-01-02 23:45:01 -05001132
1133 /* grp_info indexed by completion ring index */
Michael Chanc0c050c2015-10-22 16:01:17 -04001134 struct bnxt_ring_grp_info *grp_info;
1135 struct bnxt_vnic_info *vnic_info;
1136 int nr_vnics;
Michael Chan87da7f72016-11-16 21:13:09 -05001137 u32 rss_hash_cfg;
Michael Chanc0c050c2015-10-22 16:01:17 -04001138
1139 u8 max_tc;
Michael Chan87c374d2016-12-02 21:17:16 -05001140 u8 max_lltc; /* lossless TCs */
Michael Chanc0c050c2015-10-22 16:01:17 -04001141 struct bnxt_queue_info q_info[BNXT_MAX_QUEUE];
1142
1143 unsigned int current_interval;
Michael Chan3bdf56c2016-03-07 15:38:45 -05001144#define BNXT_TIMER_INTERVAL HZ
Michael Chanc0c050c2015-10-22 16:01:17 -04001145
1146 struct timer_list timer;
1147
Michael Chancaefe522015-12-09 19:35:42 -05001148 unsigned long state;
1149#define BNXT_STATE_OPEN 0
Michael Chan4cebdce2015-12-09 19:35:43 -05001150#define BNXT_STATE_IN_SP_TASK 1
Michael Chanf9b76eb2017-07-11 13:05:34 -04001151#define BNXT_STATE_READ_STATS 2
Michael Chanc0c050c2015-10-22 16:01:17 -04001152
1153 struct bnxt_irq *irq_tbl;
Michael Chan78095922016-12-07 00:26:16 -05001154 int total_irqs;
Michael Chanc0c050c2015-10-22 16:01:17 -04001155 u8 mac_addr[ETH_ALEN];
1156
Michael Chan7df4ae92016-12-02 21:17:17 -05001157#ifdef CONFIG_BNXT_DCB
1158 struct ieee_pfc *ieee_pfc;
1159 struct ieee_ets *ieee_ets;
1160 u8 dcbx_cap;
1161 u8 default_pri;
1162#endif /* CONFIG_BNXT_DCB */
1163
Michael Chanc0c050c2015-10-22 16:01:17 -04001164 u32 msg_enable;
1165
Michael Chan11f15ed2016-04-05 14:08:55 -04001166 u32 hwrm_spec_code;
Michael Chanc0c050c2015-10-22 16:01:17 -04001167 u16 hwrm_cmd_seq;
1168 u32 hwrm_intr_seq_id;
Deepak Khungare605db82017-05-29 19:06:04 -04001169 void *hwrm_short_cmd_req_addr;
1170 dma_addr_t hwrm_short_cmd_req_dma_addr;
Michael Chanc0c050c2015-10-22 16:01:17 -04001171 void *hwrm_cmd_resp_addr;
1172 dma_addr_t hwrm_cmd_resp_dma_addr;
1173 void *hwrm_dbg_resp_addr;
1174 dma_addr_t hwrm_dbg_resp_dma_addr;
1175#define HWRM_DBG_REG_BUF_SIZE 128
Michael Chan3bdf56c2016-03-07 15:38:45 -05001176
1177 struct rx_port_stats *hw_rx_port_stats;
1178 struct tx_port_stats *hw_tx_port_stats;
1179 dma_addr_t hw_rx_port_stats_map;
1180 dma_addr_t hw_tx_port_stats_map;
1181 int hw_port_stats_size;
1182
Michael Chane6ef2692016-03-28 19:46:05 -04001183 u16 hwrm_max_req_len;
Michael Chanff4fe812016-02-26 04:00:04 -05001184 int hwrm_cmd_timeout;
Michael Chanc0c050c2015-10-22 16:01:17 -04001185 struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
1186 struct hwrm_ver_get_output ver_resp;
1187#define FW_VER_STR_LEN 32
1188#define BC_HWRM_STR_LEN 21
1189#define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
1190 char fw_ver_str[FW_VER_STR_LEN];
1191 __be16 vxlan_port;
1192 u8 vxlan_port_cnt;
1193 __le16 vxlan_fw_dst_port_id;
Alexander Duyck7cdd5fc2016-06-16 12:21:36 -07001194 __be16 nge_port;
Michael Chanc0c050c2015-10-22 16:01:17 -04001195 u8 nge_port_cnt;
1196 __le16 nge_fw_dst_port_id;
Satish Baddipadige567b2ab2016-06-13 02:25:31 -04001197 u8 port_partition_type;
Michael Chan32e8239c2017-07-24 12:34:21 -04001198 u16 br_mode;
Michael Chandfc9c942016-02-26 04:00:03 -05001199
Michael Chandfb5b892016-02-26 04:00:01 -05001200 u16 rx_coal_ticks;
1201 u16 rx_coal_ticks_irq;
1202 u16 rx_coal_bufs;
1203 u16 rx_coal_bufs_irq;
Michael Chandfc9c942016-02-26 04:00:03 -05001204 u16 tx_coal_ticks;
1205 u16 tx_coal_ticks_irq;
1206 u16 tx_coal_bufs;
1207 u16 tx_coal_bufs_irq;
Michael Chanc0c050c2015-10-22 16:01:17 -04001208
1209#define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
Michael Chanc0c050c2015-10-22 16:01:17 -04001210
Michael Chan51f30782016-07-01 18:46:29 -04001211 u32 stats_coal_ticks;
1212#define BNXT_DEF_STATS_COAL_TICKS 1000000
1213#define BNXT_MIN_STATS_COAL_TICKS 250000
1214#define BNXT_MAX_STATS_COAL_TICKS 1000000
1215
Michael Chanc0c050c2015-10-22 16:01:17 -04001216 struct work_struct sp_task;
1217 unsigned long sp_event;
1218#define BNXT_RX_MASK_SP_EVENT 0
1219#define BNXT_RX_NTP_FLTR_SP_EVENT 1
1220#define BNXT_LINK_CHNG_SP_EVENT 2
Jeffrey Huangc5d77742015-11-05 16:25:47 -05001221#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3
1222#define BNXT_VXLAN_ADD_PORT_SP_EVENT 4
1223#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
1224#define BNXT_RESET_TASK_SP_EVENT 6
1225#define BNXT_RST_RING_SP_EVENT 7
Jeffrey Huang19241362016-02-26 04:00:00 -05001226#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
Michael Chan3bdf56c2016-03-07 15:38:45 -05001227#define BNXT_PERIODIC_STATS_SP_EVENT 9
Michael Chan4bb13ab2016-04-05 14:09:01 -04001228#define BNXT_HWRM_PORT_MODULE_SP_EVENT 10
Michael Chanfc0f1922016-06-13 02:25:30 -04001229#define BNXT_RESET_TASK_SILENT_SP_EVENT 11
Alexander Duyck7cdd5fc2016-06-16 12:21:36 -07001230#define BNXT_GENEVE_ADD_PORT_SP_EVENT 12
1231#define BNXT_GENEVE_DEL_PORT_SP_EVENT 13
Michael Chan286ef9d2016-11-16 21:13:08 -05001232#define BNXT_LINK_SPEED_CHNG_SP_EVENT 14
Michael Chanc0c050c2015-10-22 16:01:17 -04001233
Michael Chan379a80a2015-10-23 15:06:19 -04001234 struct bnxt_pf_info pf;
Michael Chanc0c050c2015-10-22 16:01:17 -04001235#ifdef CONFIG_BNXT_SRIOV
1236 int nr_vfs;
Michael Chanc0c050c2015-10-22 16:01:17 -04001237 struct bnxt_vf_info vf;
1238 wait_queue_head_t sriov_cfg_wait;
1239 bool sriov_cfg;
1240#define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000)
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001241
1242 /* lock to protect VF-rep creation/cleanup via
1243 * multiple paths such as ->sriov_configure() and
1244 * devlink ->eswitch_mode_set()
1245 */
1246 struct mutex sriov_lock;
Michael Chanc0c050c2015-10-22 16:01:17 -04001247#endif
1248
1249#define BNXT_NTP_FLTR_MAX_FLTR 4096
1250#define BNXT_NTP_FLTR_HASH_SIZE 512
1251#define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1)
1252 struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE];
1253 spinlock_t ntp_fltr_lock; /* for hash table add, del */
1254
1255 unsigned long *ntp_fltr_bmap;
1256 int ntp_fltr_count;
1257
1258 struct bnxt_link_info link_info;
Michael Chan170ce012016-04-05 14:08:57 -04001259 struct ethtool_eee eee;
1260 u32 lpi_tmr_lo;
1261 u32 lpi_tmr_hi;
Michael Chan5ad2cbe2017-01-13 01:32:03 -05001262
Michael Chaneb513652017-04-04 18:14:12 -04001263 u8 num_tests;
1264 struct bnxt_test_info *test_info;
1265
Michael Chanc1ef1462017-04-04 18:14:07 -04001266 u8 wol_filter_id;
1267 u8 wol;
1268
Michael Chan5ad2cbe2017-01-13 01:32:03 -05001269 u8 num_leds;
1270 struct bnxt_led_info leds[BNXT_MAX_LED];
Michael Chanc6d30e82017-02-06 16:55:42 -05001271
1272 struct bpf_prog *xdp_prog;
Sathya Perla4ab0c6a2017-07-24 12:34:27 -04001273
1274 /* devlink interface and vf-rep structs */
1275 struct devlink *dl;
1276 enum devlink_eswitch_mode eswitch_mode;
1277 struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */
1278 u16 *cfa_code_map; /* cfa_code -> vf_idx map */
Michael Chanc0c050c2015-10-22 16:01:17 -04001279};
1280
Michael Chanc77192f2016-12-02 21:17:18 -05001281#define BNXT_RX_STATS_OFFSET(counter) \
1282 (offsetof(struct rx_port_stats, counter) / 8)
1283
1284#define BNXT_TX_STATS_OFFSET(counter) \
1285 ((offsetof(struct tx_port_stats, counter) + \
1286 sizeof(struct rx_port_stats) + 512) / 8)
1287
Ajit Khaparde42ee18f2016-05-15 03:04:44 -04001288#define I2C_DEV_ADDR_A0 0xa0
1289#define I2C_DEV_ADDR_A2 0xa2
1290#define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e
1291#define SFP_EEPROM_SFF_8472_COMP_SIZE 1
1292#define SFF_MODULE_ID_SFP 0x3
1293#define SFF_MODULE_ID_QSFP 0xc
1294#define SFF_MODULE_ID_QSFP_PLUS 0xd
1295#define SFF_MODULE_ID_QSFP28 0x11
1296#define BNXT_MAX_PHY_I2C_RESP_SIZE 64
1297
Michael Chan38413402017-02-06 16:55:43 -05001298static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
1299{
1300 /* Tell compiler to fetch tx indices from memory. */
1301 barrier();
1302
1303 return bp->tx_ring_size -
1304 ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask);
1305}
1306
Michael Chan434c9752017-05-29 19:06:08 -04001307/* For TX and RX ring doorbells */
1308static inline void bnxt_db_write(struct bnxt *bp, void __iomem *db, u32 val)
1309{
1310 writel(val, db);
1311 if (bp->flags & BNXT_FLAG_DOUBLE_DB)
1312 writel(val, db);
1313}
1314
Michael Chan38413402017-02-06 16:55:43 -05001315extern const u16 bnxt_lhint_arr[];
1316
1317int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
1318 u16 prod, gfp_t gfp);
Michael Chanc6d30e82017-02-06 16:55:42 -05001319void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data);
1320void bnxt_set_tpa_flags(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001321void bnxt_set_ring_params(struct bnxt *);
Michael Chanc61fb992017-02-06 16:55:36 -05001322int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
Michael Chanc0c050c2015-10-22 16:01:17 -04001323void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
1324int _hwrm_send_message(struct bnxt *, void *, u32, int);
1325int hwrm_send_message(struct bnxt *, void *, u32, int);
Michael Chan90e209212016-02-26 04:00:08 -05001326int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
Michael Chana1653b12016-12-07 00:26:20 -05001327int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
1328 int bmap_size);
Michael Chana588e452016-12-07 00:26:21 -05001329int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
Michael Chan391be5c2016-12-29 12:13:41 -05001330int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
Michael Chanc0c050c2015-10-22 16:01:17 -04001331int bnxt_hwrm_set_coal(struct bnxt *);
Michael Chane4060d32016-12-07 00:26:19 -05001332unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
Michael Chana588e452016-12-07 00:26:21 -05001333void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
Michael Chane4060d32016-12-07 00:26:19 -05001334unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
Michael Chana588e452016-12-07 00:26:21 -05001335void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max);
Michael Chan33c26572016-12-07 00:26:15 -05001336void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max);
Michael Chan7df4ae92016-12-02 21:17:17 -05001337void bnxt_tx_disable(struct bnxt *bp);
1338void bnxt_tx_enable(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001339int bnxt_hwrm_set_pause(struct bnxt *);
Michael Chan939f7f02016-04-05 14:08:58 -04001340int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
Michael Chan5282db62017-04-04 18:14:10 -04001341int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
1342int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
Rob Swindell5ac67d82016-09-19 03:58:03 -04001343int bnxt_hwrm_fw_set_time(struct bnxt *);
Michael Chanc0c050c2015-10-22 16:01:17 -04001344int bnxt_open_nic(struct bnxt *, bool, bool);
Michael Chanf7dc1ea2017-04-04 18:14:13 -04001345int bnxt_half_open_nic(struct bnxt *bp);
1346void bnxt_half_close_nic(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001347int bnxt_close_nic(struct bnxt *, bool, bool);
Michael Chan3b6b34d2017-07-11 13:05:35 -04001348int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1349 int tx_xdp);
Michael Chanc5e3deb2016-12-02 21:17:15 -05001350int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
Michael Chan6e6c5a52016-01-02 23:45:02 -05001351int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
Michael Chan7b08f662016-12-07 00:26:18 -05001352void bnxt_restore_pf_fw_resources(struct bnxt *bp);
Michael Chanc0c050c2015-10-22 16:01:17 -04001353#endif