]>
Commit | Line | Data |
---|---|---|
a2fbb9ea ET |
1 | /* bnx2x.h: Broadcom Everest network driver. |
2 | * | |
85b26ea1 | 3 | * Copyright (c) 2007-2012 Broadcom Corporation |
a2fbb9ea ET |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation. | |
8 | * | |
24e3fcef EG |
9 | * Maintained by: Eilon Greenstein <[email protected]> |
10 | * Written by: Eliezer Tamir | |
a2fbb9ea ET |
11 | * Based on code from Michael Chan's bnx2 driver |
12 | */ | |
13 | ||
14 | #ifndef BNX2X_H | |
15 | #define BNX2X_H | |
ec6ba945 | 16 | #include <linux/netdevice.h> |
b7f080cf | 17 | #include <linux/dma-mapping.h> |
ec6ba945 | 18 | #include <linux/types.h> |
a2fbb9ea | 19 | |
34f80b04 EG |
20 | /* compilation time flags */ |
21 | ||
22 | /* define this to make the driver freeze on error to allow getting debug info | |
23 | * (you will need to reboot afterwards) */ | |
24 | /* #define BNX2X_STOP_ON_ERROR */ | |
25 | ||
515e1240 YM |
26 | #define DRV_MODULE_VERSION "1.78.00-0" |
27 | #define DRV_MODULE_RELDATE "2012/09/27" | |
de0c62db DK |
28 | #define BNX2X_BC_VER 0x040200 |
29 | ||
785b9b1a | 30 | #if defined(CONFIG_DCB) |
98507672 | 31 | #define BCM_DCBNL |
785b9b1a | 32 | #endif |
b475d78f YM |
33 | |
34 | ||
35 | #include "bnx2x_hsi.h" | |
36 | ||
993ac7b5 MC |
37 | #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE) |
38 | #define BCM_CNIC 1 | |
5d1e859c | 39 | #include "../cnic_if.h" |
993ac7b5 | 40 | #endif |
0c6671b0 | 41 | |
1ac218c8 VZ |
42 | #ifdef BCM_CNIC |
43 | #define BNX2X_MIN_MSIX_VEC_CNT 3 | |
44 | #define BNX2X_MSIX_VEC_FP_START 2 | |
45 | #else | |
46 | #define BNX2X_MIN_MSIX_VEC_CNT 2 | |
47 | #define BNX2X_MSIX_VEC_FP_START 1 | |
48 | #endif | |
01cd4528 EG |
49 | |
50 | #include <linux/mdio.h> | |
619c5cb6 | 51 | |
359d8b15 EG |
52 | #include "bnx2x_reg.h" |
53 | #include "bnx2x_fw_defs.h" | |
2e499d3c | 54 | #include "bnx2x_mfw_req.h" |
359d8b15 EG |
55 | #include "bnx2x_hsi.h" |
56 | #include "bnx2x_link.h" | |
619c5cb6 | 57 | #include "bnx2x_sp.h" |
e4901dde | 58 | #include "bnx2x_dcb.h" |
6c719d00 | 59 | #include "bnx2x_stats.h" |
359d8b15 | 60 | |
a2fbb9ea ET |
61 | /* error/debug prints */ |
62 | ||
34f80b04 | 63 | #define DRV_MODULE_NAME "bnx2x" |
a2fbb9ea ET |
64 | |
65 | /* for messages that are currently off */ | |
51c1a580 MS |
66 | #define BNX2X_MSG_OFF 0x0 |
67 | #define BNX2X_MSG_MCP 0x0010000 /* was: NETIF_MSG_HW */ | |
68 | #define BNX2X_MSG_STATS 0x0020000 /* was: NETIF_MSG_TIMER */ | |
69 | #define BNX2X_MSG_NVM 0x0040000 /* was: NETIF_MSG_HW */ | |
70 | #define BNX2X_MSG_DMAE 0x0080000 /* was: NETIF_MSG_HW */ | |
71 | #define BNX2X_MSG_SP 0x0100000 /* was: NETIF_MSG_INTR */ | |
72 | #define BNX2X_MSG_FP 0x0200000 /* was: NETIF_MSG_INTR */ | |
73 | #define BNX2X_MSG_IOV 0x0800000 | |
74 | #define BNX2X_MSG_IDLE 0x2000000 /* used for idle check*/ | |
75 | #define BNX2X_MSG_ETHTOOL 0x4000000 | |
76 | #define BNX2X_MSG_DCB 0x8000000 | |
a2fbb9ea | 77 | |
a2fbb9ea | 78 | /* regular debug print */ |
f1deab50 | 79 | #define DP(__mask, fmt, ...) \ |
7995c64e | 80 | do { \ |
51c1a580 | 81 | if (unlikely(bp->msg_enable & (__mask))) \ |
f1deab50 JP |
82 | pr_notice("[%s:%d(%s)]" fmt, \ |
83 | __func__, __LINE__, \ | |
84 | bp->dev ? (bp->dev->name) : "?", \ | |
85 | ##__VA_ARGS__); \ | |
7995c64e | 86 | } while (0) |
a2fbb9ea | 87 | |
f1deab50 | 88 | #define DP_CONT(__mask, fmt, ...) \ |
619c5cb6 | 89 | do { \ |
51c1a580 | 90 | if (unlikely(bp->msg_enable & (__mask))) \ |
f1deab50 | 91 | pr_cont(fmt, ##__VA_ARGS__); \ |
619c5cb6 VZ |
92 | } while (0) |
93 | ||
34f80b04 | 94 | /* errors debug print */ |
f1deab50 | 95 | #define BNX2X_DBG_ERR(fmt, ...) \ |
7995c64e | 96 | do { \ |
51c1a580 | 97 | if (unlikely(netif_msg_probe(bp))) \ |
f1deab50 | 98 | pr_err("[%s:%d(%s)]" fmt, \ |
7995c64e JP |
99 | __func__, __LINE__, \ |
100 | bp->dev ? (bp->dev->name) : "?", \ | |
f1deab50 | 101 | ##__VA_ARGS__); \ |
7995c64e | 102 | } while (0) |
a2fbb9ea | 103 | |
34f80b04 | 104 | /* for errors (never masked) */ |
f1deab50 | 105 | #define BNX2X_ERR(fmt, ...) \ |
7995c64e | 106 | do { \ |
f1deab50 | 107 | pr_err("[%s:%d(%s)]" fmt, \ |
7995c64e JP |
108 | __func__, __LINE__, \ |
109 | bp->dev ? (bp->dev->name) : "?", \ | |
f1deab50 JP |
110 | ##__VA_ARGS__); \ |
111 | } while (0) | |
cdaa7cb8 | 112 | |
f1deab50 JP |
113 | #define BNX2X_ERROR(fmt, ...) \ |
114 | pr_err("[%s:%d]" fmt, __func__, __LINE__, ##__VA_ARGS__) | |
cdaa7cb8 | 115 | |
f1410647 | 116 | |
a2fbb9ea | 117 | /* before we have a dev->name use dev_info() */ |
f1deab50 | 118 | #define BNX2X_DEV_INFO(fmt, ...) \ |
7995c64e | 119 | do { \ |
51c1a580 | 120 | if (unlikely(netif_msg_probe(bp))) \ |
f1deab50 | 121 | dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__); \ |
7995c64e | 122 | } while (0) |
a2fbb9ea | 123 | |
a2fbb9ea | 124 | #ifdef BNX2X_STOP_ON_ERROR |
6383c0b3 | 125 | void bnx2x_int_disable(struct bnx2x *bp); |
f1deab50 JP |
126 | #define bnx2x_panic() \ |
127 | do { \ | |
128 | bp->panic = 1; \ | |
129 | BNX2X_ERR("driver assert\n"); \ | |
130 | bnx2x_int_disable(bp); \ | |
131 | bnx2x_panic_dump(bp); \ | |
132 | } while (0) | |
a2fbb9ea | 133 | #else |
f1deab50 JP |
134 | #define bnx2x_panic() \ |
135 | do { \ | |
136 | bp->panic = 1; \ | |
137 | BNX2X_ERR("driver assert\n"); \ | |
138 | bnx2x_panic_dump(bp); \ | |
139 | } while (0) | |
a2fbb9ea ET |
140 | #endif |
141 | ||
523224a3 | 142 | #define bnx2x_mc_addr(ha) ((ha)->addr) |
6e30dd4e | 143 | #define bnx2x_uc_addr(ha) ((ha)->addr) |
a2fbb9ea | 144 | |
34f80b04 EG |
145 | #define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff) |
146 | #define U64_HI(x) (u32)(((u64)(x)) >> 32) | |
147 | #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo)) | |
a2fbb9ea | 148 | |
a2fbb9ea | 149 | |
523224a3 | 150 | #define REG_ADDR(bp, offset) ((bp->regview) + (offset)) |
a2fbb9ea | 151 | |
34f80b04 EG |
152 | #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset)) |
153 | #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset)) | |
523224a3 | 154 | #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset)) |
34f80b04 EG |
155 | |
156 | #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset)) | |
a2fbb9ea | 157 | #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset)) |
34f80b04 | 158 | #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset)) |
a2fbb9ea | 159 | |
34f80b04 EG |
160 | #define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset) |
161 | #define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val) | |
a2fbb9ea | 162 | |
c18487ee YR |
163 | #define REG_RD_DMAE(bp, offset, valp, len32) \ |
164 | do { \ | |
165 | bnx2x_read_dmae(bp, offset, len32);\ | |
573f2035 | 166 | memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \ |
c18487ee YR |
167 | } while (0) |
168 | ||
34f80b04 | 169 | #define REG_WR_DMAE(bp, offset, valp, len32) \ |
a2fbb9ea | 170 | do { \ |
573f2035 | 171 | memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \ |
a2fbb9ea ET |
172 | bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \ |
173 | offset, len32); \ | |
174 | } while (0) | |
175 | ||
523224a3 DK |
176 | #define REG_WR_DMAE_LEN(bp, offset, valp, len32) \ |
177 | REG_WR_DMAE(bp, offset, valp, len32) | |
178 | ||
3359fced | 179 | #define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \ |
573f2035 EG |
180 | do { \ |
181 | memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \ | |
182 | bnx2x_write_big_buf_wb(bp, addr, len32); \ | |
183 | } while (0) | |
184 | ||
34f80b04 EG |
185 | #define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \ |
186 | offsetof(struct shmem_region, field)) | |
187 | #define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field)) | |
188 | #define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val) | |
a2fbb9ea | 189 | |
2691d51d EG |
190 | #define SHMEM2_ADDR(bp, field) (bp->common.shmem2_base + \ |
191 | offsetof(struct shmem2_region, field)) | |
192 | #define SHMEM2_RD(bp, field) REG_RD(bp, SHMEM2_ADDR(bp, field)) | |
193 | #define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val) | |
523224a3 DK |
194 | #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \ |
195 | offsetof(struct mf_cfg, field)) | |
f85582f8 | 196 | #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \ |
f2e0899f | 197 | offsetof(struct mf2_cfg, field)) |
2691d51d | 198 | |
523224a3 DK |
199 | #define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field)) |
200 | #define MF_CFG_WR(bp, field, val) REG_WR(bp,\ | |
201 | MF_CFG_ADDR(bp, field), (val)) | |
f2e0899f | 202 | #define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field)) |
f85582f8 | 203 | |
f2e0899f DK |
204 | #define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \ |
205 | (SHMEM2_RD((bp), size) > \ | |
206 | offsetof(struct shmem2_region, field))) | |
72fd0718 | 207 | |
345b5d52 | 208 | #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg) |
3196a88a | 209 | #define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val) |
a2fbb9ea | 210 | |
523224a3 DK |
211 | /* SP SB indices */ |
212 | ||
213 | /* General SP events - stats query, cfc delete, etc */ | |
214 | #define HC_SP_INDEX_ETH_DEF_CONS 3 | |
215 | ||
216 | /* EQ completions */ | |
217 | #define HC_SP_INDEX_EQ_CONS 7 | |
218 | ||
ec6ba945 VZ |
219 | /* FCoE L2 connection completions */ |
220 | #define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS 6 | |
221 | #define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS 4 | |
523224a3 DK |
222 | /* iSCSI L2 */ |
223 | #define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5 | |
224 | #define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1 | |
225 | ||
ec6ba945 VZ |
226 | /* Special clients parameters */ |
227 | ||
228 | /* SB indices */ | |
229 | /* FCoE L2 */ | |
230 | #define BNX2X_FCOE_L2_RX_INDEX \ | |
231 | (&bp->def_status_blk->sp_sb.\ | |
232 | index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS]) | |
233 | ||
234 | #define BNX2X_FCOE_L2_TX_INDEX \ | |
235 | (&bp->def_status_blk->sp_sb.\ | |
236 | index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS]) | |
237 | ||
523224a3 DK |
238 | /** |
239 | * CIDs and CLIDs: | |
240 | * CLIDs below is a CLID for func 0, then the CLID for other | |
241 | * functions will be calculated by the formula: | |
242 | * | |
243 | * FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X | |
244 | * | |
245 | */ | |
134d0f97 DK |
246 | enum { |
247 | BNX2X_ISCSI_ETH_CL_ID_IDX, | |
248 | BNX2X_FCOE_ETH_CL_ID_IDX, | |
249 | BNX2X_MAX_CNIC_ETH_CL_ID_IDX, | |
250 | }; | |
251 | ||
37ae41a9 MS |
252 | #define BNX2X_CNIC_START_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) *\ |
253 | (bp)->max_cos) | |
134d0f97 | 254 | /* iSCSI L2 */ |
37ae41a9 | 255 | #define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp)) |
134d0f97 | 256 | /* FCoE L2 */ |
37ae41a9 | 257 | #define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1) |
ec6ba945 | 258 | |
523224a3 DK |
259 | /** Additional rings budgeting */ |
260 | #ifdef BCM_CNIC | |
6383c0b3 AE |
261 | #define CNIC_PRESENT 1 |
262 | #define FCOE_PRESENT 1 | |
523224a3 | 263 | #else |
6383c0b3 AE |
264 | #define CNIC_PRESENT 0 |
265 | #define FCOE_PRESENT 0 | |
523224a3 | 266 | #endif /* BCM_CNIC */ |
6383c0b3 | 267 | #define NON_ETH_CONTEXT_USE (FCOE_PRESENT) |
523224a3 | 268 | |
72fd0718 VZ |
269 | #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \ |
270 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR | |
271 | ||
523224a3 DK |
272 | #define SM_RX_ID 0 |
273 | #define SM_TX_ID 1 | |
a2fbb9ea | 274 | |
6383c0b3 AE |
275 | /* defines for multiple tx priority indices */ |
276 | #define FIRST_TX_ONLY_COS_INDEX 1 | |
277 | #define FIRST_TX_COS_INDEX 0 | |
278 | ||
6383c0b3 | 279 | /* rules for calculating the cids of tx-only connections */ |
65565884 MS |
280 | #define CID_TO_FP(cid, bp) ((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp)) |
281 | #define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \ | |
282 | (cid + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp)) | |
6383c0b3 AE |
283 | |
284 | /* fp index inside class of service range */ | |
65565884 MS |
285 | #define FP_COS_TO_TXQ(fp, cos, bp) \ |
286 | ((fp)->index + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp)) | |
287 | ||
288 | /* Indexes for transmission queues array: | |
289 | * txdata for RSS i CoS j is at location i + (j * num of RSS) | |
290 | * txdata for FCoE (if exist) is at location max cos * num of RSS | |
291 | * txdata for FWD (if exist) is one location after FCoE | |
292 | * txdata for OOO (if exist) is one location after FWD | |
6383c0b3 | 293 | */ |
65565884 MS |
294 | enum { |
295 | FCOE_TXQ_IDX_OFFSET, | |
296 | FWD_TXQ_IDX_OFFSET, | |
297 | OOO_TXQ_IDX_OFFSET, | |
298 | }; | |
299 | #define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos) | |
300 | #ifdef BCM_CNIC | |
301 | #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET) | |
302 | #endif | |
a2fbb9ea | 303 | |
6383c0b3 | 304 | /* fast path */ |
e52fcb24 ED |
305 | /* |
306 | * This driver uses new build_skb() API : | |
307 | * RX ring buffer contains pointer to kmalloc() data only, | |
308 | * skb are built only after Hardware filled the frame. | |
309 | */ | |
a2fbb9ea | 310 | struct sw_rx_bd { |
e52fcb24 | 311 | u8 *data; |
1a983142 | 312 | DEFINE_DMA_UNMAP_ADDR(mapping); |
a2fbb9ea ET |
313 | }; |
314 | ||
315 | struct sw_tx_bd { | |
34f80b04 EG |
316 | struct sk_buff *skb; |
317 | u16 first_bd; | |
ca00392c EG |
318 | u8 flags; |
319 | /* Set on the first BD descriptor when there is a split BD */ | |
320 | #define BNX2X_TSO_SPLIT_BD (1<<0) | |
a2fbb9ea ET |
321 | }; |
322 | ||
7a9b2557 VZ |
323 | struct sw_rx_page { |
324 | struct page *page; | |
1a983142 | 325 | DEFINE_DMA_UNMAP_ADDR(mapping); |
7a9b2557 VZ |
326 | }; |
327 | ||
ca00392c EG |
328 | union db_prod { |
329 | struct doorbell_set_prod data; | |
330 | u32 raw; | |
331 | }; | |
332 | ||
dfacf138 DK |
333 | /* dropless fc FW/HW related params */ |
334 | #define BRB_SIZE(bp) (CHIP_IS_E3(bp) ? 1024 : 512) | |
335 | #define MAX_AGG_QS(bp) (CHIP_IS_E1(bp) ? \ | |
336 | ETH_MAX_AGGREGATION_QUEUES_E1 :\ | |
337 | ETH_MAX_AGGREGATION_QUEUES_E1H_E2) | |
338 | #define FW_DROP_LEVEL(bp) (3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp)) | |
339 | #define FW_PREFETCH_CNT 16 | |
340 | #define DROPLESS_FC_HEADROOM 100 | |
7a9b2557 VZ |
341 | |
342 | /* MC hsi */ | |
619c5cb6 VZ |
343 | #define BCM_PAGE_SHIFT 12 |
344 | #define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT) | |
345 | #define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1)) | |
7a9b2557 VZ |
346 | #define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK) |
347 | ||
619c5cb6 VZ |
348 | #define PAGES_PER_SGE_SHIFT 0 |
349 | #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) | |
350 | #define SGE_PAGE_SIZE PAGE_SIZE | |
351 | #define SGE_PAGE_SHIFT PAGE_SHIFT | |
352 | #define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr)) | |
7a9b2557 VZ |
353 | |
354 | /* SGE ring related macros */ | |
619c5cb6 | 355 | #define NUM_RX_SGE_PAGES 2 |
7a9b2557 | 356 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) |
dfacf138 DK |
357 | #define NEXT_PAGE_SGE_DESC_CNT 2 |
358 | #define MAX_RX_SGE_CNT (RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT) | |
33471629 | 359 | /* RX_SGE_CNT is promised to be a power of 2 */ |
619c5cb6 VZ |
360 | #define RX_SGE_MASK (RX_SGE_CNT - 1) |
361 | #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES) | |
362 | #define MAX_RX_SGE (NUM_RX_SGE - 1) | |
7a9b2557 | 363 | #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \ |
dfacf138 DK |
364 | (MAX_RX_SGE_CNT - 1)) ? \ |
365 | (x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \ | |
366 | (x) + 1) | |
619c5cb6 VZ |
367 | #define RX_SGE(x) ((x) & MAX_RX_SGE) |
368 | ||
dfacf138 DK |
369 | /* |
370 | * Number of required SGEs is the sum of two: | |
371 | * 1. Number of possible opened aggregations (next packet for | |
372 | * these aggregations will probably consume SGE immidiatelly) | |
373 | * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only | |
374 | * after placement on BD for new TPA aggregation) | |
375 | * | |
376 | * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page | |
377 | */ | |
378 | #define NUM_SGE_REQ (MAX_AGG_QS(bp) + \ | |
379 | (BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2) | |
380 | #define NUM_SGE_PG_REQ ((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \ | |
381 | MAX_RX_SGE_CNT) | |
382 | #define SGE_TH_LO(bp) (NUM_SGE_REQ + \ | |
383 | NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT) | |
384 | #define SGE_TH_HI(bp) (SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM) | |
385 | ||
619c5cb6 | 386 | /* Manipulate a bit vector defined as an array of u64 */ |
7a9b2557 | 387 | |
7a9b2557 | 388 | /* Number of bits in one sge_mask array element */ |
619c5cb6 VZ |
389 | #define BIT_VEC64_ELEM_SZ 64 |
390 | #define BIT_VEC64_ELEM_SHIFT 6 | |
391 | #define BIT_VEC64_ELEM_MASK ((u64)BIT_VEC64_ELEM_SZ - 1) | |
392 | ||
393 | ||
394 | #define __BIT_VEC64_SET_BIT(el, bit) \ | |
395 | do { \ | |
396 | el = ((el) | ((u64)0x1 << (bit))); \ | |
397 | } while (0) | |
398 | ||
399 | #define __BIT_VEC64_CLEAR_BIT(el, bit) \ | |
400 | do { \ | |
401 | el = ((el) & (~((u64)0x1 << (bit)))); \ | |
402 | } while (0) | |
403 | ||
404 | ||
405 | #define BIT_VEC64_SET_BIT(vec64, idx) \ | |
406 | __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \ | |
407 | (idx) & BIT_VEC64_ELEM_MASK) | |
408 | ||
409 | #define BIT_VEC64_CLEAR_BIT(vec64, idx) \ | |
410 | __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \ | |
411 | (idx) & BIT_VEC64_ELEM_MASK) | |
412 | ||
413 | #define BIT_VEC64_TEST_BIT(vec64, idx) \ | |
414 | (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \ | |
415 | ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1) | |
7a9b2557 VZ |
416 | |
417 | /* Creates a bitmask of all ones in less significant bits. | |
418 | idx - index of the most significant bit in the created mask */ | |
619c5cb6 VZ |
419 | #define BIT_VEC64_ONES_MASK(idx) \ |
420 | (((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1) | |
421 | #define BIT_VEC64_ELEM_ONE_MASK ((u64)(~0)) | |
422 | ||
423 | /*******************************************************/ | |
424 | ||
425 | ||
7a9b2557 VZ |
426 | |
427 | /* Number of u64 elements in SGE mask array */ | |
b3637827 | 428 | #define RX_SGE_MASK_LEN (NUM_RX_SGE / BIT_VEC64_ELEM_SZ) |
7a9b2557 VZ |
429 | #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1) |
430 | #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK) | |
431 | ||
523224a3 DK |
432 | union host_hc_status_block { |
433 | /* pointer to fp status block e1x */ | |
434 | struct host_hc_status_block_e1x *e1x_sb; | |
f2e0899f DK |
435 | /* pointer to fp status block e2 */ |
436 | struct host_hc_status_block_e2 *e2_sb; | |
523224a3 | 437 | }; |
7a9b2557 | 438 | |
619c5cb6 VZ |
439 | struct bnx2x_agg_info { |
440 | /* | |
e52fcb24 ED |
441 | * First aggregation buffer is a data buffer, the following - are pages. |
442 | * We will preallocate the data buffer for each aggregation when | |
619c5cb6 VZ |
443 | * we open the interface and will replace the BD at the consumer |
444 | * with this one when we receive the TPA_START CQE in order to | |
445 | * keep the Rx BD ring consistent. | |
446 | */ | |
447 | struct sw_rx_bd first_buf; | |
448 | u8 tpa_state; | |
449 | #define BNX2X_TPA_START 1 | |
450 | #define BNX2X_TPA_STOP 2 | |
451 | #define BNX2X_TPA_ERROR 3 | |
452 | u8 placement_offset; | |
453 | u16 parsing_flags; | |
454 | u16 vlan_tag; | |
455 | u16 len_on_bd; | |
e52fcb24 | 456 | u32 rxhash; |
a334b5fb | 457 | bool l4_rxhash; |
621b4d66 DK |
458 | u16 gro_size; |
459 | u16 full_page; | |
619c5cb6 VZ |
460 | }; |
461 | ||
462 | #define Q_STATS_OFFSET32(stat_name) \ | |
463 | (offsetof(struct bnx2x_eth_q_stats, stat_name) / 4) | |
464 | ||
6383c0b3 AE |
465 | struct bnx2x_fp_txdata { |
466 | ||
467 | struct sw_tx_bd *tx_buf_ring; | |
468 | ||
469 | union eth_tx_bd_types *tx_desc_ring; | |
470 | dma_addr_t tx_desc_mapping; | |
471 | ||
472 | u32 cid; | |
473 | ||
474 | union db_prod tx_db; | |
475 | ||
476 | u16 tx_pkt_prod; | |
477 | u16 tx_pkt_cons; | |
478 | u16 tx_bd_prod; | |
479 | u16 tx_bd_cons; | |
480 | ||
481 | unsigned long tx_pkt; | |
482 | ||
483 | __le16 *tx_cons_sb; | |
484 | ||
485 | int txq_index; | |
65565884 MS |
486 | struct bnx2x_fastpath *parent_fp; |
487 | int tx_ring_size; | |
6383c0b3 AE |
488 | }; |
489 | ||
621b4d66 DK |
490 | enum bnx2x_tpa_mode_t { |
491 | TPA_MODE_LRO, | |
492 | TPA_MODE_GRO | |
493 | }; | |
494 | ||
a2fbb9ea | 495 | struct bnx2x_fastpath { |
619c5cb6 | 496 | struct bnx2x *bp; /* parent */ |
a2fbb9ea | 497 | |
d6214d7a | 498 | #define BNX2X_NAPI_WEIGHT 128 |
34f80b04 | 499 | struct napi_struct napi; |
f85582f8 | 500 | union host_hc_status_block status_blk; |
523224a3 DK |
501 | /* chip independed shortcuts into sb structure */ |
502 | __le16 *sb_index_values; | |
503 | __le16 *sb_running_index; | |
504 | /* chip independed shortcut into rx_prods_offset memory */ | |
505 | u32 ustorm_rx_prods_offset; | |
506 | ||
a8c94b91 VZ |
507 | u32 rx_buf_size; |
508 | ||
34f80b04 | 509 | dma_addr_t status_blk_mapping; |
a2fbb9ea | 510 | |
621b4d66 DK |
511 | enum bnx2x_tpa_mode_t mode; |
512 | ||
6383c0b3 | 513 | u8 max_cos; /* actual number of active tx coses */ |
65565884 | 514 | struct bnx2x_fp_txdata *txdata_ptr[BNX2X_MULTI_TX_COS]; |
a2fbb9ea | 515 | |
7a9b2557 VZ |
516 | struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */ |
517 | struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */ | |
a2fbb9ea ET |
518 | |
519 | struct eth_rx_bd *rx_desc_ring; | |
34f80b04 | 520 | dma_addr_t rx_desc_mapping; |
a2fbb9ea ET |
521 | |
522 | union eth_rx_cqe *rx_comp_ring; | |
34f80b04 EG |
523 | dma_addr_t rx_comp_mapping; |
524 | ||
7a9b2557 VZ |
525 | /* SGE ring */ |
526 | struct eth_rx_sge *rx_sge_ring; | |
527 | dma_addr_t rx_sge_mapping; | |
528 | ||
529 | u64 sge_mask[RX_SGE_MASK_LEN]; | |
530 | ||
619c5cb6 | 531 | u32 cid; |
34f80b04 | 532 | |
6383c0b3 AE |
533 | __le16 fp_hc_idx; |
534 | ||
f85582f8 | 535 | u8 index; /* number in fp array */ |
f233cafe | 536 | u8 rx_queue; /* index for skb_record */ |
f85582f8 | 537 | u8 cl_id; /* eth client id */ |
523224a3 DK |
538 | u8 cl_qzone_id; |
539 | u8 fw_sb_id; /* status block number in FW */ | |
540 | u8 igu_sb_id; /* status block number in HW */ | |
34f80b04 EG |
541 | |
542 | u16 rx_bd_prod; | |
543 | u16 rx_bd_cons; | |
544 | u16 rx_comp_prod; | |
545 | u16 rx_comp_cons; | |
7a9b2557 VZ |
546 | u16 rx_sge_prod; |
547 | /* The last maximal completed SGE */ | |
548 | u16 last_max_sge; | |
4781bfad | 549 | __le16 *rx_cons_sb; |
6383c0b3 | 550 | unsigned long rx_pkt, |
66e855f3 | 551 | rx_calls; |
ab6ad5a4 | 552 | |
7a9b2557 | 553 | /* TPA related */ |
15192a8c | 554 | struct bnx2x_agg_info *tpa_info; |
7a9b2557 VZ |
555 | u8 disable_tpa; |
556 | #ifdef BNX2X_STOP_ON_ERROR | |
557 | u64 tpa_queue_used; | |
558 | #endif | |
ca00392c EG |
559 | /* The size is calculated using the following: |
560 | sizeof name field from netdev structure + | |
561 | 4 ('-Xx-' string) + | |
562 | 4 (for the digits and to make it DWORD aligned) */ | |
563 | #define FP_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8) | |
564 | char name[FP_NAME_SIZE]; | |
a2fbb9ea ET |
565 | }; |
566 | ||
15192a8c BW |
567 | #define bnx2x_fp(bp, nr, var) ((bp)->fp[(nr)].var) |
568 | #define bnx2x_sp_obj(bp, fp) ((bp)->sp_objs[(fp)->index]) | |
569 | #define bnx2x_fp_stats(bp, fp) (&((bp)->fp_stats[(fp)->index])) | |
570 | #define bnx2x_fp_qstats(bp, fp) (&((bp)->fp_stats[(fp)->index].eth_q_stats)) | |
a8c94b91 VZ |
571 | |
572 | /* Use 2500 as a mini-jumbo MTU for FCoE */ | |
573 | #define BNX2X_FCOE_MINI_JUMBO_MTU 2500 | |
574 | ||
65565884 MS |
575 | #define FCOE_IDX_OFFSET 0 |
576 | ||
577 | #define FCOE_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) + \ | |
578 | FCOE_IDX_OFFSET) | |
579 | #define bnx2x_fcoe_fp(bp) (&bp->fp[FCOE_IDX(bp)]) | |
580 | #define bnx2x_fcoe(bp, var) (bnx2x_fcoe_fp(bp)->var) | |
15192a8c BW |
581 | #define bnx2x_fcoe_inner_sp_obj(bp) (&bp->sp_objs[FCOE_IDX(bp)]) |
582 | #define bnx2x_fcoe_sp_obj(bp, var) (bnx2x_fcoe_inner_sp_obj(bp)->var) | |
65565884 MS |
583 | #define bnx2x_fcoe_tx(bp, var) (bnx2x_fcoe_fp(bp)-> \ |
584 | txdata_ptr[FIRST_TX_COS_INDEX] \ | |
585 | ->var) | |
619c5cb6 VZ |
586 | |
587 | ||
6383c0b3 AE |
588 | #define IS_ETH_FP(fp) (fp->index < \ |
589 | BNX2X_NUM_ETH_QUEUES(fp->bp)) | |
619c5cb6 | 590 | #ifdef BCM_CNIC |
65565884 MS |
591 | #define IS_FCOE_FP(fp) (fp->index == FCOE_IDX(fp->bp)) |
592 | #define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX(bp)) | |
ec6ba945 VZ |
593 | #else |
594 | #define IS_FCOE_FP(fp) false | |
595 | #define IS_FCOE_IDX(idx) false | |
596 | #endif | |
7a9b2557 VZ |
597 | |
598 | ||
599 | /* MC hsi */ | |
619c5cb6 VZ |
600 | #define MAX_FETCH_BD 13 /* HW max BDs per packet */ |
601 | #define RX_COPY_THRESH 92 | |
7a9b2557 | 602 | |
619c5cb6 | 603 | #define NUM_TX_RINGS 16 |
ca00392c | 604 | #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types)) |
dfacf138 DK |
605 | #define NEXT_PAGE_TX_DESC_CNT 1 |
606 | #define MAX_TX_DESC_CNT (TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT) | |
619c5cb6 VZ |
607 | #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS) |
608 | #define MAX_TX_BD (NUM_TX_BD - 1) | |
609 | #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2) | |
7a9b2557 | 610 | #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \ |
dfacf138 DK |
611 | (MAX_TX_DESC_CNT - 1)) ? \ |
612 | (x) + 1 + NEXT_PAGE_TX_DESC_CNT : \ | |
613 | (x) + 1) | |
619c5cb6 VZ |
614 | #define TX_BD(x) ((x) & MAX_TX_BD) |
615 | #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT) | |
7a9b2557 | 616 | |
7df2dc6b DK |
617 | /* number of NEXT_PAGE descriptors may be required during placement */ |
618 | #define NEXT_CNT_PER_TX_PKT(bds) \ | |
619 | (((bds) + MAX_TX_DESC_CNT - 1) / \ | |
620 | MAX_TX_DESC_CNT * NEXT_PAGE_TX_DESC_CNT) | |
621 | /* max BDs per tx packet w/o next_pages: | |
622 | * START_BD - describes packed | |
623 | * START_BD(splitted) - includes unpaged data segment for GSO | |
624 | * PARSING_BD - for TSO and CSUM data | |
625 | * Frag BDs - decribes pages for frags | |
626 | */ | |
627 | #define BDS_PER_TX_PKT 3 | |
628 | #define MAX_BDS_PER_TX_PKT (MAX_SKB_FRAGS + BDS_PER_TX_PKT) | |
629 | /* max BDs per tx packet including next pages */ | |
630 | #define MAX_DESC_PER_TX_PKT (MAX_BDS_PER_TX_PKT + \ | |
631 | NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT)) | |
632 | ||
7a9b2557 | 633 | /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */ |
619c5cb6 | 634 | #define NUM_RX_RINGS 8 |
7a9b2557 | 635 | #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd)) |
dfacf138 DK |
636 | #define NEXT_PAGE_RX_DESC_CNT 2 |
637 | #define MAX_RX_DESC_CNT (RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT) | |
619c5cb6 VZ |
638 | #define RX_DESC_MASK (RX_DESC_CNT - 1) |
639 | #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS) | |
640 | #define MAX_RX_BD (NUM_RX_BD - 1) | |
641 | #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2) | |
dfacf138 DK |
642 | |
643 | /* dropless fc calculations for BDs | |
644 | * | |
645 | * Number of BDs should as number of buffers in BRB: | |
646 | * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT | |
647 | * "next" elements on each page | |
648 | */ | |
649 | #define NUM_BD_REQ BRB_SIZE(bp) | |
650 | #define NUM_BD_PG_REQ ((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \ | |
651 | MAX_RX_DESC_CNT) | |
652 | #define BD_TH_LO(bp) (NUM_BD_REQ + \ | |
653 | NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \ | |
654 | FW_DROP_LEVEL(bp)) | |
655 | #define BD_TH_HI(bp) (BD_TH_LO(bp) + DROPLESS_FC_HEADROOM) | |
656 | ||
657 | #define MIN_RX_AVAIL ((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128) | |
619c5cb6 VZ |
658 | |
659 | #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \ | |
660 | ETH_MIN_RX_CQES_WITH_TPA_E1 : \ | |
661 | ETH_MIN_RX_CQES_WITH_TPA_E1H_E2) | |
662 | #define MIN_RX_SIZE_NONTPA_HW ETH_MIN_RX_CQES_WITHOUT_TPA | |
663 | #define MIN_RX_SIZE_TPA (max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL)) | |
664 | #define MIN_RX_SIZE_NONTPA (max_t(u32, MIN_RX_SIZE_NONTPA_HW,\ | |
665 | MIN_RX_AVAIL)) | |
666 | ||
7a9b2557 | 667 | #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \ |
dfacf138 DK |
668 | (MAX_RX_DESC_CNT - 1)) ? \ |
669 | (x) + 1 + NEXT_PAGE_RX_DESC_CNT : \ | |
670 | (x) + 1) | |
619c5cb6 | 671 | #define RX_BD(x) ((x) & MAX_RX_BD) |
7a9b2557 | 672 | |
619c5cb6 VZ |
673 | /* |
674 | * As long as CQE is X times bigger than BD entry we have to allocate X times | |
675 | * more pages for CQ ring in order to keep it balanced with BD ring | |
676 | */ | |
677 | #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd)) | |
678 | #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL) | |
7a9b2557 | 679 | #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) |
dfacf138 DK |
680 | #define NEXT_PAGE_RCQ_DESC_CNT 1 |
681 | #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT) | |
619c5cb6 VZ |
682 | #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS) |
683 | #define MAX_RCQ_BD (NUM_RCQ_BD - 1) | |
684 | #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2) | |
7a9b2557 | 685 | #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \ |
dfacf138 DK |
686 | (MAX_RCQ_DESC_CNT - 1)) ? \ |
687 | (x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \ | |
688 | (x) + 1) | |
619c5cb6 | 689 | #define RCQ_BD(x) ((x) & MAX_RCQ_BD) |
7a9b2557 | 690 | |
dfacf138 DK |
691 | /* dropless fc calculations for RCQs |
692 | * | |
693 | * Number of RCQs should be as number of buffers in BRB: | |
694 | * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT | |
695 | * "next" elements on each page | |
696 | */ | |
697 | #define NUM_RCQ_REQ BRB_SIZE(bp) | |
698 | #define NUM_RCQ_PG_REQ ((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \ | |
699 | MAX_RCQ_DESC_CNT) | |
700 | #define RCQ_TH_LO(bp) (NUM_RCQ_REQ + \ | |
701 | NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \ | |
702 | FW_DROP_LEVEL(bp)) | |
703 | #define RCQ_TH_HI(bp) (RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM) | |
704 | ||
7a9b2557 | 705 | |
33471629 | 706 | /* This is needed for determining of last_max */ |
619c5cb6 VZ |
707 | #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) |
708 | #define SUB_S32(a, b) (s32)((s32)(a) - (s32)(b)) | |
7a9b2557 | 709 | |
7a9b2557 | 710 | |
619c5cb6 VZ |
711 | #define BNX2X_SWCID_SHIFT 17 |
712 | #define BNX2X_SWCID_MASK ((0x1 << BNX2X_SWCID_SHIFT) - 1) | |
7a9b2557 VZ |
713 | |
714 | /* used on a CID received from the HW */ | |
619c5cb6 | 715 | #define SW_CID(x) (le32_to_cpu(x) & BNX2X_SWCID_MASK) |
7a9b2557 VZ |
716 | #define CQE_CMD(x) (le32_to_cpu(x) >> \ |
717 | COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT) | |
718 | ||
bb2a0f7a YG |
719 | #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \ |
720 | le32_to_cpu((bd)->addr_lo)) | |
721 | #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes)) | |
722 | ||
523224a3 DK |
723 | #define BNX2X_DB_MIN_SHIFT 3 /* 8 bytes */ |
724 | #define BNX2X_DB_SHIFT 7 /* 128 bytes*/ | |
619c5cb6 VZ |
725 | #if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT) |
726 | #error "Min DB doorbell stride is 8" | |
727 | #endif | |
7a9b2557 VZ |
728 | #define DPM_TRIGER_TYPE 0x40 |
729 | #define DOORBELL(bp, cid, val) \ | |
730 | do { \ | |
523224a3 | 731 | writel((u32)(val), bp->doorbells + (bp->db_size * (cid)) + \ |
7a9b2557 VZ |
732 | DPM_TRIGER_TYPE); \ |
733 | } while (0) | |
734 | ||
735 | ||
736 | /* TX CSUM helpers */ | |
737 | #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \ | |
738 | skb->csum_offset) | |
739 | #define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \ | |
740 | skb->csum_offset)) | |
741 | ||
742 | #define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff) | |
743 | ||
744 | #define XMIT_PLAIN 0 | |
745 | #define XMIT_CSUM_V4 0x1 | |
746 | #define XMIT_CSUM_V6 0x2 | |
747 | #define XMIT_CSUM_TCP 0x4 | |
748 | #define XMIT_GSO_V4 0x8 | |
749 | #define XMIT_GSO_V6 0x10 | |
750 | ||
751 | #define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6) | |
752 | #define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6) | |
753 | ||
754 | ||
34f80b04 | 755 | /* stuff added to make the code fit 80Col */ |
619c5cb6 VZ |
756 | #define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE) |
757 | #define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG) | |
758 | #define CQE_TYPE_STOP(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG) | |
759 | #define CQE_TYPE_SLOW(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD) | |
760 | #define CQE_TYPE_FAST(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH) | |
7a9b2557 | 761 | |
1adcd8be EG |
762 | #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG |
763 | ||
052a38e0 EG |
764 | #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \ |
765 | (((le16_to_cpu(flags) & \ | |
766 | PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \ | |
767 | PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \ | |
768 | == PRS_FLAG_OVERETH_IPV4) | |
7a9b2557 | 769 | #define BNX2X_RX_SUM_FIX(cqe) \ |
052a38e0 | 770 | BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags) |
7a9b2557 | 771 | |
619c5cb6 VZ |
772 | |
773 | #define FP_USB_FUNC_OFF \ | |
774 | offsetof(struct cstorm_status_block_u, func) | |
775 | #define FP_CSB_FUNC_OFF \ | |
776 | offsetof(struct cstorm_status_block_c, func) | |
777 | ||
150966ad | 778 | #define HC_INDEX_ETH_RX_CQ_CONS 1 |
619c5cb6 | 779 | |
150966ad | 780 | #define HC_INDEX_OOO_TX_CQ_CONS 4 |
6383c0b3 | 781 | |
150966ad AE |
782 | #define HC_INDEX_ETH_TX_CQ_CONS_COS0 5 |
783 | ||
784 | #define HC_INDEX_ETH_TX_CQ_CONS_COS1 6 | |
6383c0b3 | 785 | |
150966ad AE |
786 | #define HC_INDEX_ETH_TX_CQ_CONS_COS2 7 |
787 | ||
788 | #define HC_INDEX_ETH_FIRST_TX_CQ_CONS HC_INDEX_ETH_TX_CQ_CONS_COS0 | |
a2fbb9ea | 789 | |
34f80b04 | 790 | #define BNX2X_RX_SB_INDEX \ |
619c5cb6 | 791 | (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS]) |
a2fbb9ea | 792 | |
6383c0b3 AE |
793 | #define BNX2X_TX_SB_INDEX_BASE BNX2X_TX_SB_INDEX_COS0 |
794 | ||
795 | #define BNX2X_TX_SB_INDEX_COS0 \ | |
796 | (&fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0]) | |
7a9b2557 VZ |
797 | |
798 | /* end of fast path */ | |
799 | ||
34f80b04 | 800 | /* common */ |
a2fbb9ea | 801 | |
34f80b04 | 802 | struct bnx2x_common { |
a2fbb9ea | 803 | |
ad8d3948 | 804 | u32 chip_id; |
a2fbb9ea | 805 | /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */ |
34f80b04 | 806 | #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0) |
ad8d3948 | 807 | |
34f80b04 | 808 | #define CHIP_NUM(bp) (bp->common.chip_id >> 16) |
ad8d3948 EG |
809 | #define CHIP_NUM_57710 0x164e |
810 | #define CHIP_NUM_57711 0x164f | |
811 | #define CHIP_NUM_57711E 0x1650 | |
f2e0899f | 812 | #define CHIP_NUM_57712 0x1662 |
619c5cb6 VZ |
813 | #define CHIP_NUM_57712_MF 0x1663 |
814 | #define CHIP_NUM_57713 0x1651 | |
815 | #define CHIP_NUM_57713E 0x1652 | |
816 | #define CHIP_NUM_57800 0x168a | |
817 | #define CHIP_NUM_57800_MF 0x16a5 | |
818 | #define CHIP_NUM_57810 0x168e | |
819 | #define CHIP_NUM_57810_MF 0x16ae | |
7e8e02df BW |
820 | #define CHIP_NUM_57811 0x163d |
821 | #define CHIP_NUM_57811_MF 0x163e | |
c3def943 YM |
822 | #define CHIP_NUM_57840_OBSOLETE 0x168d |
823 | #define CHIP_NUM_57840_MF_OBSOLETE 0x16ab | |
824 | #define CHIP_NUM_57840_4_10 0x16a1 | |
825 | #define CHIP_NUM_57840_2_20 0x16a2 | |
826 | #define CHIP_NUM_57840_MF 0x16a4 | |
ad8d3948 EG |
827 | #define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710) |
828 | #define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711) | |
829 | #define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E) | |
f2e0899f | 830 | #define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712) |
619c5cb6 VZ |
831 | #define CHIP_IS_57712_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57712_MF) |
832 | #define CHIP_IS_57800(bp) (CHIP_NUM(bp) == CHIP_NUM_57800) | |
833 | #define CHIP_IS_57800_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57800_MF) | |
834 | #define CHIP_IS_57810(bp) (CHIP_NUM(bp) == CHIP_NUM_57810) | |
835 | #define CHIP_IS_57810_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57810_MF) | |
7e8e02df BW |
836 | #define CHIP_IS_57811(bp) (CHIP_NUM(bp) == CHIP_NUM_57811) |
837 | #define CHIP_IS_57811_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57811_MF) | |
c3def943 YM |
838 | #define CHIP_IS_57840(bp) \ |
839 | ((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) || \ | |
840 | (CHIP_NUM(bp) == CHIP_NUM_57840_2_20) || \ | |
841 | (CHIP_NUM(bp) == CHIP_NUM_57840_OBSOLETE)) | |
842 | #define CHIP_IS_57840_MF(bp) ((CHIP_NUM(bp) == CHIP_NUM_57840_MF) || \ | |
843 | (CHIP_NUM(bp) == CHIP_NUM_57840_MF_OBSOLETE)) | |
ad8d3948 EG |
844 | #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \ |
845 | CHIP_IS_57711E(bp)) | |
f2e0899f | 846 | #define CHIP_IS_E2(bp) (CHIP_IS_57712(bp) || \ |
619c5cb6 VZ |
847 | CHIP_IS_57712_MF(bp)) |
848 | #define CHIP_IS_E3(bp) (CHIP_IS_57800(bp) || \ | |
849 | CHIP_IS_57800_MF(bp) || \ | |
850 | CHIP_IS_57810(bp) || \ | |
851 | CHIP_IS_57810_MF(bp) || \ | |
7e8e02df BW |
852 | CHIP_IS_57811(bp) || \ |
853 | CHIP_IS_57811_MF(bp) || \ | |
619c5cb6 VZ |
854 | CHIP_IS_57840(bp) || \ |
855 | CHIP_IS_57840_MF(bp)) | |
f2e0899f | 856 | #define CHIP_IS_E1x(bp) (CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp))) |
619c5cb6 VZ |
857 | #define USES_WARPCORE(bp) (CHIP_IS_E3(bp)) |
858 | #define IS_E1H_OFFSET (!CHIP_IS_E1(bp)) | |
859 | ||
860 | #define CHIP_REV_SHIFT 12 | |
861 | #define CHIP_REV_MASK (0xF << CHIP_REV_SHIFT) | |
862 | #define CHIP_REV_VAL(bp) (bp->common.chip_id & CHIP_REV_MASK) | |
863 | #define CHIP_REV_Ax (0x0 << CHIP_REV_SHIFT) | |
864 | #define CHIP_REV_Bx (0x1 << CHIP_REV_SHIFT) | |
ad8d3948 | 865 | /* assume maximum 5 revisions */ |
619c5cb6 | 866 | #define CHIP_REV_IS_SLOW(bp) (CHIP_REV_VAL(bp) > 0x00005000) |
ad8d3948 EG |
867 | /* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */ |
868 | #define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \ | |
619c5cb6 | 869 | !(CHIP_REV_VAL(bp) & 0x00001000)) |
ad8d3948 EG |
870 | /* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */ |
871 | #define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \ | |
619c5cb6 | 872 | (CHIP_REV_VAL(bp) & 0x00001000)) |
ad8d3948 EG |
873 | |
874 | #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \ | |
875 | ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1)) | |
876 | ||
34f80b04 EG |
877 | #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0) |
878 | #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f) | |
619c5cb6 VZ |
879 | #define CHIP_REV_SIM(bp) (((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\ |
880 | (CHIP_REV_SHIFT + 1)) \ | |
881 | << CHIP_REV_SHIFT) | |
882 | #define CHIP_REV(bp) (CHIP_REV_IS_SLOW(bp) ? \ | |
883 | CHIP_REV_SIM(bp) :\ | |
884 | CHIP_REV_VAL(bp)) | |
885 | #define CHIP_IS_E3B0(bp) (CHIP_IS_E3(bp) && \ | |
886 | (CHIP_REV(bp) == CHIP_REV_Bx)) | |
887 | #define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \ | |
888 | (CHIP_REV(bp) == CHIP_REV_Ax)) | |
a2fbb9ea | 889 | |
34f80b04 | 890 | int flash_size; |
754a2f52 DK |
891 | #define BNX2X_NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */ |
892 | #define BNX2X_NVRAM_TIMEOUT_COUNT 30000 | |
893 | #define BNX2X_NVRAM_PAGE_SIZE 256 | |
a2fbb9ea | 894 | |
34f80b04 | 895 | u32 shmem_base; |
2691d51d | 896 | u32 shmem2_base; |
523224a3 | 897 | u32 mf_cfg_base; |
f2e0899f | 898 | u32 mf2_cfg_base; |
34f80b04 EG |
899 | |
900 | u32 hw_config; | |
c18487ee | 901 | |
34f80b04 | 902 | u32 bc_ver; |
523224a3 DK |
903 | |
904 | u8 int_block; | |
905 | #define INT_BLOCK_HC 0 | |
f2e0899f DK |
906 | #define INT_BLOCK_IGU 1 |
907 | #define INT_BLOCK_MODE_NORMAL 0 | |
908 | #define INT_BLOCK_MODE_BW_COMP 2 | |
909 | #define CHIP_INT_MODE_IS_NBC(bp) \ | |
619c5cb6 | 910 | (!CHIP_IS_E1x(bp) && \ |
f2e0899f DK |
911 | !((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP)) |
912 | #define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp)) | |
913 | ||
523224a3 | 914 | u8 chip_port_mode; |
f2e0899f DK |
915 | #define CHIP_4_PORT_MODE 0x0 |
916 | #define CHIP_2_PORT_MODE 0x1 | |
523224a3 | 917 | #define CHIP_PORT_MODE_NONE 0x2 |
f2e0899f DK |
918 | #define CHIP_MODE(bp) (bp->common.chip_port_mode) |
919 | #define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE) | |
1d187b34 BW |
920 | |
921 | u32 boot_mode; | |
34f80b04 | 922 | }; |
c18487ee | 923 | |
f2e0899f DK |
924 | /* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */ |
925 | #define BNX2X_IGU_STAS_MSG_VF_CNT 64 | |
926 | #define BNX2X_IGU_STAS_MSG_PF_CNT 4 | |
34f80b04 EG |
927 | |
928 | /* end of common */ | |
929 | ||
930 | /* port */ | |
931 | ||
932 | struct bnx2x_port { | |
933 | u32 pmf; | |
c18487ee | 934 | |
a22f0788 | 935 | u32 link_config[LINK_CONFIG_SIZE]; |
a2fbb9ea | 936 | |
a22f0788 | 937 | u32 supported[LINK_CONFIG_SIZE]; |
34f80b04 EG |
938 | /* link settings - missing defines */ |
939 | #define SUPPORTED_2500baseX_Full (1 << 15) | |
940 | ||
a22f0788 | 941 | u32 advertising[LINK_CONFIG_SIZE]; |
a2fbb9ea | 942 | /* link settings - missing defines */ |
34f80b04 | 943 | #define ADVERTISED_2500baseX_Full (1 << 15) |
a2fbb9ea | 944 | |
34f80b04 | 945 | u32 phy_addr; |
c18487ee YR |
946 | |
947 | /* used to synchronize phy accesses */ | |
948 | struct mutex phy_mutex; | |
46c6a674 | 949 | int need_hw_lock; |
c18487ee | 950 | |
34f80b04 | 951 | u32 port_stx; |
a2fbb9ea | 952 | |
34f80b04 EG |
953 | struct nig_stats old_nig_stats; |
954 | }; | |
a2fbb9ea | 955 | |
34f80b04 EG |
956 | /* end of port */ |
957 | ||
619c5cb6 VZ |
958 | #define STATS_OFFSET32(stat_name) \ |
959 | (offsetof(struct bnx2x_eth_stats, stat_name) / 4) | |
bb2a0f7a | 960 | |
619c5cb6 VZ |
961 | /* slow path */ |
962 | ||
963 | /* slow path work-queue */ | |
964 | extern struct workqueue_struct *bnx2x_wq; | |
965 | ||
966 | #define BNX2X_MAX_NUM_OF_VFS 64 | |
523224a3 | 967 | #define BNX2X_VF_ID_INVALID 0xFF |
34f80b04 | 968 | |
523224a3 DK |
969 | /* |
970 | * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is | |
971 | * control by the number of fast-path status blocks supported by the | |
972 | * device (HW/FW). Each fast-path status block (FP-SB) aka non-default | |
973 | * status block represents an independent interrupts context that can | |
974 | * serve a regular L2 networking queue. However special L2 queues such | |
975 | * as the FCoE queue do not require a FP-SB and other components like | |
976 | * the CNIC may consume FP-SB reducing the number of possible L2 queues | |
977 | * | |
978 | * If the maximum number of FP-SB available is X then: | |
979 | * a. If CNIC is supported it consumes 1 FP-SB thus the max number of | |
980 | * regular L2 queues is Y=X-1 | |
981 | * b. in MF mode the actual number of L2 queues is Y= (X-1/MF_factor) | |
982 | * c. If the FCoE L2 queue is supported the actual number of L2 queues | |
983 | * is Y+1 | |
984 | * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for | |
985 | * slow-path interrupts) or Y+2 if CNIC is supported (one additional | |
986 | * FP interrupt context for the CNIC). | |
987 | * e. The number of HW context (CID count) is always X or X+1 if FCoE | |
988 | * L2 queue is supported. the cid for the FCoE L2 queue is always X. | |
989 | */ | |
990 | ||
619c5cb6 VZ |
991 | /* fast-path interrupt contexts E1x */ |
992 | #define FP_SB_MAX_E1x 16 | |
993 | /* fast-path interrupt contexts E2 */ | |
994 | #define FP_SB_MAX_E2 HC_SB_MAX_SB_E2 | |
523224a3 | 995 | |
34f80b04 EG |
996 | union cdu_context { |
997 | struct eth_context eth; | |
998 | char pad[1024]; | |
999 | }; | |
1000 | ||
523224a3 | 1001 | /* CDU host DB constants */ |
a052997e MS |
1002 | #define CDU_ILT_PAGE_SZ_HW 2 |
1003 | #define CDU_ILT_PAGE_SZ (8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */ | |
523224a3 DK |
1004 | #define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context)) |
1005 | ||
1006 | #ifdef BCM_CNIC | |
1007 | #define CNIC_ISCSI_CID_MAX 256 | |
ec6ba945 VZ |
1008 | #define CNIC_FCOE_CID_MAX 2048 |
1009 | #define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX) | |
523224a3 DK |
1010 | #define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS) |
1011 | #endif | |
1012 | ||
619c5cb6 VZ |
1013 | #define QM_ILT_PAGE_SZ_HW 0 |
1014 | #define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 4K */ | |
523224a3 DK |
1015 | #define QM_CID_ROUND 1024 |
1016 | ||
1017 | #ifdef BCM_CNIC | |
1018 | /* TM (timers) host DB constants */ | |
619c5cb6 VZ |
1019 | #define TM_ILT_PAGE_SZ_HW 0 |
1020 | #define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 4K */ | |
523224a3 DK |
1021 | /* #define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */ |
1022 | #define TM_CONN_NUM 1024 | |
1023 | #define TM_ILT_SZ (8 * TM_CONN_NUM) | |
1024 | #define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ) | |
1025 | ||
1026 | /* SRC (Searcher) host DB constants */ | |
619c5cb6 VZ |
1027 | #define SRC_ILT_PAGE_SZ_HW 0 |
1028 | #define SRC_ILT_PAGE_SZ (4096 << SRC_ILT_PAGE_SZ_HW) /* 4K */ | |
523224a3 DK |
1029 | #define SRC_HASH_BITS 10 |
1030 | #define SRC_CONN_NUM (1 << SRC_HASH_BITS) /* 1024 */ | |
1031 | #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM) | |
1032 | #define SRC_T2_SZ SRC_ILT_SZ | |
1033 | #define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ) | |
619c5cb6 | 1034 | |
523224a3 DK |
1035 | #endif |
1036 | ||
619c5cb6 | 1037 | #define MAX_DMAE_C 8 |
34f80b04 EG |
1038 | |
1039 | /* DMA memory not used in fastpath */ | |
1040 | struct bnx2x_slowpath { | |
619c5cb6 VZ |
1041 | union { |
1042 | struct mac_configuration_cmd e1x; | |
1043 | struct eth_classify_rules_ramrod_data e2; | |
1044 | } mac_rdata; | |
1045 | ||
1046 | ||
1047 | union { | |
1048 | struct tstorm_eth_mac_filter_config e1x; | |
1049 | struct eth_filter_rules_ramrod_data e2; | |
1050 | } rx_mode_rdata; | |
1051 | ||
1052 | union { | |
1053 | struct mac_configuration_cmd e1; | |
1054 | struct eth_multicast_rules_ramrod_data e2; | |
1055 | } mcast_rdata; | |
1056 | ||
1057 | struct eth_rss_update_ramrod_data rss_rdata; | |
1058 | ||
1059 | /* Queue State related ramrods are always sent under rtnl_lock */ | |
1060 | union { | |
1061 | struct client_init_ramrod_data init_data; | |
1062 | struct client_update_ramrod_data update_data; | |
1063 | } q_rdata; | |
1064 | ||
1065 | union { | |
1066 | struct function_start_data func_start; | |
6debea87 DK |
1067 | /* pfc configuration for DCBX ramrod */ |
1068 | struct flow_control_configuration pfc_config; | |
619c5cb6 | 1069 | } func_rdata; |
34f80b04 | 1070 | |
a3348722 BW |
1071 | /* afex ramrod can not be a part of func_rdata union because these |
1072 | * events might arrive in parallel to other events from func_rdata. | |
1073 | * Therefore, if they would have been defined in the same union, | |
1074 | * data can get corrupted. | |
1075 | */ | |
1076 | struct afex_vif_list_ramrod_data func_afex_rdata; | |
1077 | ||
34f80b04 EG |
1078 | /* used by dmae command executer */ |
1079 | struct dmae_command dmae[MAX_DMAE_C]; | |
1080 | ||
bb2a0f7a YG |
1081 | u32 stats_comp; |
1082 | union mac_stats mac_stats; | |
1083 | struct nig_stats nig_stats; | |
1084 | struct host_port_stats port_stats; | |
1085 | struct host_func_stats func_stats; | |
34f80b04 EG |
1086 | |
1087 | u32 wb_comp; | |
34f80b04 | 1088 | u32 wb_data[4]; |
1d187b34 BW |
1089 | |
1090 | union drv_info_to_mcp drv_info_to_mcp; | |
34f80b04 EG |
1091 | }; |
1092 | ||
1093 | #define bnx2x_sp(bp, var) (&bp->slowpath->var) | |
1094 | #define bnx2x_sp_mapping(bp, var) \ | |
1095 | (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var)) | |
1096 | ||
1097 | ||
1098 | /* attn group wiring */ | |
1099 | #define MAX_DYNAMIC_ATTN_GRPS 8 | |
1100 | ||
1101 | struct attn_route { | |
619c5cb6 | 1102 | u32 sig[5]; |
34f80b04 EG |
1103 | }; |
1104 | ||
523224a3 DK |
1105 | struct iro { |
1106 | u32 base; | |
1107 | u16 m1; | |
1108 | u16 m2; | |
1109 | u16 m3; | |
1110 | u16 size; | |
1111 | }; | |
1112 | ||
1113 | struct hw_context { | |
1114 | union cdu_context *vcxt; | |
1115 | dma_addr_t cxt_mapping; | |
1116 | size_t size; | |
1117 | }; | |
1118 | ||
1119 | /* forward */ | |
1120 | struct bnx2x_ilt; | |
1121 | ||
c9ee9206 VZ |
1122 | |
1123 | enum bnx2x_recovery_state { | |
72fd0718 VZ |
1124 | BNX2X_RECOVERY_DONE, |
1125 | BNX2X_RECOVERY_INIT, | |
1126 | BNX2X_RECOVERY_WAIT, | |
95c6c616 AE |
1127 | BNX2X_RECOVERY_FAILED, |
1128 | BNX2X_RECOVERY_NIC_LOADING | |
c9ee9206 | 1129 | }; |
72fd0718 | 1130 | |
619c5cb6 | 1131 | /* |
523224a3 DK |
1132 | * Event queue (EQ or event ring) MC hsi |
1133 | * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2 | |
1134 | */ | |
1135 | #define NUM_EQ_PAGES 1 | |
1136 | #define EQ_DESC_CNT_PAGE (BCM_PAGE_SIZE / sizeof(union event_ring_elem)) | |
1137 | #define EQ_DESC_MAX_PAGE (EQ_DESC_CNT_PAGE - 1) | |
1138 | #define NUM_EQ_DESC (EQ_DESC_CNT_PAGE * NUM_EQ_PAGES) | |
1139 | #define EQ_DESC_MASK (NUM_EQ_DESC - 1) | |
1140 | #define MAX_EQ_AVAIL (EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2) | |
1141 | ||
1142 | /* depends on EQ_DESC_CNT_PAGE being a power of 2 */ | |
1143 | #define NEXT_EQ_IDX(x) ((((x) & EQ_DESC_MAX_PAGE) == \ | |
1144 | (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1) | |
1145 | ||
1146 | /* depends on the above and on NUM_EQ_PAGES being a power of 2 */ | |
1147 | #define EQ_DESC(x) ((x) & EQ_DESC_MASK) | |
1148 | ||
1149 | #define BNX2X_EQ_INDEX \ | |
1150 | (&bp->def_status_blk->sp_sb.\ | |
1151 | index_values[HC_SP_INDEX_EQ_CONS]) | |
1152 | ||
2ae17f66 VZ |
1153 | /* This is a data that will be used to create a link report message. |
1154 | * We will keep the data used for the last link report in order | |
1155 | * to prevent reporting the same link parameters twice. | |
1156 | */ | |
1157 | struct bnx2x_link_report_data { | |
1158 | u16 line_speed; /* Effective line speed */ | |
1159 | unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */ | |
1160 | }; | |
1161 | ||
1162 | enum { | |
1163 | BNX2X_LINK_REPORT_FD, /* Full DUPLEX */ | |
1164 | BNX2X_LINK_REPORT_LINK_DOWN, | |
1165 | BNX2X_LINK_REPORT_RX_FC_ON, | |
1166 | BNX2X_LINK_REPORT_TX_FC_ON, | |
1167 | }; | |
1168 | ||
619c5cb6 VZ |
1169 | enum { |
1170 | BNX2X_PORT_QUERY_IDX, | |
1171 | BNX2X_PF_QUERY_IDX, | |
50f0a562 | 1172 | BNX2X_FCOE_QUERY_IDX, |
619c5cb6 VZ |
1173 | BNX2X_FIRST_QUEUE_QUERY_IDX, |
1174 | }; | |
1175 | ||
1176 | struct bnx2x_fw_stats_req { | |
1177 | struct stats_query_header hdr; | |
50f0a562 BW |
1178 | struct stats_query_entry query[FP_SB_MAX_E1x+ |
1179 | BNX2X_FIRST_QUEUE_QUERY_IDX]; | |
619c5cb6 VZ |
1180 | }; |
1181 | ||
1182 | struct bnx2x_fw_stats_data { | |
1183 | struct stats_counter storm_counters; | |
1184 | struct per_port_stats port; | |
1185 | struct per_pf_stats pf; | |
50f0a562 | 1186 | struct fcoe_statistics_params fcoe; |
619c5cb6 VZ |
1187 | struct per_queue_stats queue_stats[1]; |
1188 | }; | |
1189 | ||
7be08a72 AE |
1190 | /* Public slow path states */ |
1191 | enum { | |
6383c0b3 | 1192 | BNX2X_SP_RTNL_SETUP_TC, |
7be08a72 | 1193 | BNX2X_SP_RTNL_TX_TIMEOUT, |
a3348722 | 1194 | BNX2X_SP_RTNL_AFEX_F_UPDATE, |
8304859a | 1195 | BNX2X_SP_RTNL_FAN_FAILURE, |
7be08a72 AE |
1196 | }; |
1197 | ||
1198 | ||
452427b0 YM |
1199 | struct bnx2x_prev_path_list { |
1200 | u8 bus; | |
1201 | u8 slot; | |
1202 | u8 path; | |
1203 | struct list_head list; | |
1204 | }; | |
1205 | ||
15192a8c BW |
1206 | struct bnx2x_sp_objs { |
1207 | /* MACs object */ | |
1208 | struct bnx2x_vlan_mac_obj mac_obj; | |
1209 | ||
1210 | /* Queue State object */ | |
1211 | struct bnx2x_queue_sp_obj q_obj; | |
1212 | }; | |
1213 | ||
1214 | struct bnx2x_fp_stats { | |
1215 | struct tstorm_per_queue_stats old_tclient; | |
1216 | struct ustorm_per_queue_stats old_uclient; | |
1217 | struct xstorm_per_queue_stats old_xclient; | |
1218 | struct bnx2x_eth_q_stats eth_q_stats; | |
1219 | struct bnx2x_eth_q_stats_old eth_q_stats_old; | |
1220 | }; | |
1221 | ||
34f80b04 EG |
1222 | struct bnx2x { |
1223 | /* Fields used in the tx and intr/napi performance paths | |
1224 | * are grouped together in the beginning of the structure | |
1225 | */ | |
523224a3 | 1226 | struct bnx2x_fastpath *fp; |
15192a8c BW |
1227 | struct bnx2x_sp_objs *sp_objs; |
1228 | struct bnx2x_fp_stats *fp_stats; | |
65565884 MS |
1229 | struct bnx2x_fp_txdata *bnx2x_txq; |
1230 | int bnx2x_txq_size; | |
34f80b04 EG |
1231 | void __iomem *regview; |
1232 | void __iomem *doorbells; | |
523224a3 | 1233 | u16 db_size; |
34f80b04 | 1234 | |
619c5cb6 VZ |
1235 | u8 pf_num; /* absolute PF number */ |
1236 | u8 pfid; /* per-path PF number */ | |
1237 | int base_fw_ndsb; /**/ | |
1238 | #define BP_PATH(bp) (CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1)) | |
1239 | #define BP_PORT(bp) (bp->pfid & 1) | |
1240 | #define BP_FUNC(bp) (bp->pfid) | |
1241 | #define BP_ABS_FUNC(bp) (bp->pf_num) | |
3395a033 DK |
1242 | #define BP_VN(bp) ((bp)->pfid >> 1) |
1243 | #define BP_MAX_VN_NUM(bp) (CHIP_MODE_IS_4_PORT(bp) ? 2 : 4) | |
1244 | #define BP_L_ID(bp) (BP_VN(bp) << 2) | |
1245 | #define BP_FW_MB_IDX_VN(bp, vn) (BP_PORT(bp) +\ | |
1246 | (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1)) | |
1247 | #define BP_FW_MB_IDX(bp) BP_FW_MB_IDX_VN(bp, BP_VN(bp)) | |
619c5cb6 | 1248 | |
34f80b04 EG |
1249 | struct net_device *dev; |
1250 | struct pci_dev *pdev; | |
1251 | ||
619c5cb6 | 1252 | const struct iro *iro_arr; |
523224a3 DK |
1253 | #define IRO (bp->iro_arr) |
1254 | ||
c9ee9206 | 1255 | enum bnx2x_recovery_state recovery_state; |
72fd0718 | 1256 | int is_leader; |
523224a3 | 1257 | struct msix_entry *msix_table; |
34f80b04 EG |
1258 | |
1259 | int tx_ring_size; | |
1260 | ||
523224a3 DK |
1261 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
1262 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) | |
34f80b04 EG |
1263 | #define ETH_MIN_PACKET_SIZE 60 |
1264 | #define ETH_MAX_PACKET_SIZE 1500 | |
1265 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 | |
621b4d66 DK |
1266 | /* TCP with Timestamp Option (32) + IPv6 (40) */ |
1267 | #define ETH_MAX_TPA_HEADER_SIZE 72 | |
a2fbb9ea | 1268 | |
0f00846d | 1269 | /* Max supported alignment is 256 (8 shift) */ |
e52fcb24 ED |
1270 | #define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT) |
1271 | ||
1272 | /* FW uses 2 Cache lines Alignment for start packet and size | |
1273 | * | |
1274 | * We assume skb_build() uses sizeof(struct skb_shared_info) bytes | |
1275 | * at the end of skb->data, to avoid wasting a full cache line. | |
1276 | * This reduces memory use (skb->truesize). | |
1277 | */ | |
1278 | #define BNX2X_FW_RX_ALIGN_START (1UL << BNX2X_RX_ALIGN_SHIFT) | |
1279 | ||
1280 | #define BNX2X_FW_RX_ALIGN_END \ | |
f57b07c0 | 1281 | max_t(u64, 1UL << BNX2X_RX_ALIGN_SHIFT, \ |
e52fcb24 ED |
1282 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) |
1283 | ||
523224a3 | 1284 | #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5) |
0f00846d | 1285 | |
523224a3 DK |
1286 | struct host_sp_status_block *def_status_blk; |
1287 | #define DEF_SB_IGU_ID 16 | |
1288 | #define DEF_SB_ID HC_SP_SB_ID | |
1289 | __le16 def_idx; | |
4781bfad | 1290 | __le16 def_att_idx; |
34f80b04 EG |
1291 | u32 attn_state; |
1292 | struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS]; | |
34f80b04 EG |
1293 | |
1294 | /* slow path ring */ | |
1295 | struct eth_spe *spq; | |
1296 | dma_addr_t spq_mapping; | |
1297 | u16 spq_prod_idx; | |
1298 | struct eth_spe *spq_prod_bd; | |
1299 | struct eth_spe *spq_last_bd; | |
4781bfad | 1300 | __le16 *dsb_sp_prod; |
6e30dd4e | 1301 | atomic_t cq_spq_left; /* ETH_XXX ramrods credit */ |
34f80b04 EG |
1302 | /* used to synchronize spq accesses */ |
1303 | spinlock_t spq_lock; | |
1304 | ||
523224a3 DK |
1305 | /* event queue */ |
1306 | union event_ring_elem *eq_ring; | |
1307 | dma_addr_t eq_mapping; | |
1308 | u16 eq_prod; | |
1309 | u16 eq_cons; | |
1310 | __le16 *eq_cons_sb; | |
6e30dd4e | 1311 | atomic_t eq_spq_left; /* COMMON_XXX ramrods credit */ |
523224a3 | 1312 | |
619c5cb6 VZ |
1313 | |
1314 | ||
1315 | /* Counter for marking that there is a STAT_QUERY ramrod pending */ | |
1316 | u16 stats_pending; | |
1317 | /* Counter for completed statistics ramrods */ | |
1318 | u16 stats_comp; | |
34f80b04 | 1319 | |
33471629 | 1320 | /* End of fields used in the performance code paths */ |
34f80b04 EG |
1321 | |
1322 | int panic; | |
7995c64e | 1323 | int msg_enable; |
34f80b04 EG |
1324 | |
1325 | u32 flags; | |
619c5cb6 VZ |
1326 | #define PCIX_FLAG (1 << 0) |
1327 | #define PCI_32BIT_FLAG (1 << 1) | |
1328 | #define ONE_PORT_FLAG (1 << 2) | |
1329 | #define NO_WOL_FLAG (1 << 3) | |
1330 | #define USING_DAC_FLAG (1 << 4) | |
1331 | #define USING_MSIX_FLAG (1 << 5) | |
1332 | #define USING_MSI_FLAG (1 << 6) | |
1333 | #define DISABLE_MSI_FLAG (1 << 7) | |
1334 | #define TPA_ENABLE_FLAG (1 << 8) | |
1335 | #define NO_MCP_FLAG (1 << 9) | |
1336 | ||
34f80b04 | 1337 | #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) |
621b4d66 | 1338 | #define GRO_ENABLE_FLAG (1 << 10) |
619c5cb6 VZ |
1339 | #define MF_FUNC_DIS (1 << 11) |
1340 | #define OWN_CNIC_IRQ (1 << 12) | |
1341 | #define NO_ISCSI_OOO_FLAG (1 << 13) | |
1342 | #define NO_ISCSI_FLAG (1 << 14) | |
1343 | #define NO_FCOE_FLAG (1 << 15) | |
0e898dd7 | 1344 | #define BC_SUPPORTS_PFC_STATS (1 << 17) |
2e499d3c | 1345 | #define BC_SUPPORTS_FCOE_FEATURES (1 << 19) |
30a5de77 | 1346 | #define USING_SINGLE_MSIX_FLAG (1 << 20) |
9876879f | 1347 | #define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21) |
ec6ba945 | 1348 | |
2ba45142 VZ |
1349 | #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG) |
1350 | #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG) | |
619c5cb6 | 1351 | #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG) |
37b091ba | 1352 | |
34f80b04 | 1353 | int pm_cap; |
8d5726c4 | 1354 | int mrrs; |
34f80b04 | 1355 | |
1cf167f2 | 1356 | struct delayed_work sp_task; |
7be08a72 | 1357 | struct delayed_work sp_rtnl_task; |
3deb8167 YR |
1358 | |
1359 | struct delayed_work period_task; | |
34f80b04 | 1360 | struct timer_list timer; |
34f80b04 EG |
1361 | int current_interval; |
1362 | ||
1363 | u16 fw_seq; | |
1364 | u16 fw_drv_pulse_wr_seq; | |
1365 | u32 func_stx; | |
1366 | ||
1367 | struct link_params link_params; | |
1368 | struct link_vars link_vars; | |
2ae17f66 VZ |
1369 | u32 link_cnt; |
1370 | struct bnx2x_link_report_data last_reported_link; | |
1371 | ||
01cd4528 | 1372 | struct mdio_if_info mdio; |
a2fbb9ea | 1373 | |
34f80b04 EG |
1374 | struct bnx2x_common common; |
1375 | struct bnx2x_port port; | |
1376 | ||
b475d78f YM |
1377 | struct cmng_init cmng; |
1378 | ||
f2e0899f | 1379 | u32 mf_config[E1HVN_MAX]; |
a3348722 | 1380 | u32 mf_ext_config; |
619c5cb6 | 1381 | u32 path_has_ovlan; /* E3 */ |
fb3bff17 DK |
1382 | u16 mf_ov; |
1383 | u8 mf_mode; | |
f85582f8 | 1384 | #define IS_MF(bp) (bp->mf_mode != 0) |
0793f83f DK |
1385 | #define IS_MF_SI(bp) (bp->mf_mode == MULTI_FUNCTION_SI) |
1386 | #define IS_MF_SD(bp) (bp->mf_mode == MULTI_FUNCTION_SD) | |
a3348722 | 1387 | #define IS_MF_AFEX(bp) (bp->mf_mode == MULTI_FUNCTION_AFEX) |
a2fbb9ea | 1388 | |
f1410647 ET |
1389 | u8 wol; |
1390 | ||
34f80b04 | 1391 | int rx_ring_size; |
a2fbb9ea | 1392 | |
34f80b04 EG |
1393 | u16 tx_quick_cons_trip_int; |
1394 | u16 tx_quick_cons_trip; | |
1395 | u16 tx_ticks_int; | |
1396 | u16 tx_ticks; | |
a2fbb9ea | 1397 | |
34f80b04 EG |
1398 | u16 rx_quick_cons_trip_int; |
1399 | u16 rx_quick_cons_trip; | |
1400 | u16 rx_ticks_int; | |
1401 | u16 rx_ticks; | |
cdaa7cb8 VZ |
1402 | /* Maximal coalescing timeout in us */ |
1403 | #define BNX2X_MAX_COALESCE_TOUT (0xf0*12) | |
a2fbb9ea | 1404 | |
34f80b04 | 1405 | u32 lin_cnt; |
a2fbb9ea | 1406 | |
619c5cb6 | 1407 | u16 state; |
356e2385 | 1408 | #define BNX2X_STATE_CLOSED 0 |
34f80b04 EG |
1409 | #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000 |
1410 | #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000 | |
a2fbb9ea | 1411 | #define BNX2X_STATE_OPEN 0x3000 |
34f80b04 | 1412 | #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000 |
a2fbb9ea | 1413 | #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000 |
619c5cb6 | 1414 | |
34f80b04 EG |
1415 | #define BNX2X_STATE_DIAG 0xe000 |
1416 | #define BNX2X_STATE_ERROR 0xf000 | |
a2fbb9ea | 1417 | |
6383c0b3 AE |
1418 | #define BNX2X_MAX_PRIORITY 8 |
1419 | #define BNX2X_MAX_ENTRIES_PER_PRI 16 | |
1420 | #define BNX2X_MAX_COS 3 | |
1421 | #define BNX2X_MAX_TX_COS 2 | |
54b9ddaa | 1422 | int num_queues; |
0e8d2ec5 | 1423 | int num_napi_queues; |
5d7cd496 | 1424 | int disable_tpa; |
523224a3 | 1425 | |
34f80b04 EG |
1426 | u32 rx_mode; |
1427 | #define BNX2X_RX_MODE_NONE 0 | |
1428 | #define BNX2X_RX_MODE_NORMAL 1 | |
1429 | #define BNX2X_RX_MODE_ALLMULTI 2 | |
1430 | #define BNX2X_RX_MODE_PROMISC 3 | |
1431 | #define BNX2X_MAX_MULTICAST 64 | |
a2fbb9ea | 1432 | |
523224a3 DK |
1433 | u8 igu_dsb_id; |
1434 | u8 igu_base_sb; | |
1435 | u8 igu_sb_cnt; | |
65565884 | 1436 | |
34f80b04 | 1437 | dma_addr_t def_status_blk_mapping; |
a2fbb9ea | 1438 | |
34f80b04 EG |
1439 | struct bnx2x_slowpath *slowpath; |
1440 | dma_addr_t slowpath_mapping; | |
619c5cb6 VZ |
1441 | |
1442 | /* Total number of FW statistics requests */ | |
1443 | u8 fw_stats_num; | |
1444 | ||
1445 | /* | |
1446 | * This is a memory buffer that will contain both statistics | |
1447 | * ramrod request and data. | |
1448 | */ | |
1449 | void *fw_stats; | |
1450 | dma_addr_t fw_stats_mapping; | |
1451 | ||
1452 | /* | |
1453 | * FW statistics request shortcut (points at the | |
1454 | * beginning of fw_stats buffer). | |
1455 | */ | |
1456 | struct bnx2x_fw_stats_req *fw_stats_req; | |
1457 | dma_addr_t fw_stats_req_mapping; | |
1458 | int fw_stats_req_sz; | |
1459 | ||
1460 | /* | |
1461 | * FW statistics data shortcut (points at the begining of | |
1462 | * fw_stats buffer + fw_stats_req_sz). | |
1463 | */ | |
1464 | struct bnx2x_fw_stats_data *fw_stats_data; | |
1465 | dma_addr_t fw_stats_data_mapping; | |
1466 | int fw_stats_data_sz; | |
1467 | ||
a052997e MS |
1468 | /* For max 196 cids (64*3 + non-eth), 32KB ILT page size and 1KB |
1469 | * context size we need 8 ILT entries. | |
1470 | */ | |
1471 | #define ILT_MAX_L2_LINES 8 | |
1472 | struct hw_context context[ILT_MAX_L2_LINES]; | |
523224a3 DK |
1473 | |
1474 | struct bnx2x_ilt *ilt; | |
1475 | #define BP_ILT(bp) ((bp)->ilt) | |
619c5cb6 | 1476 | #define ILT_MAX_LINES 256 |
6383c0b3 AE |
1477 | /* |
1478 | * Maximum supported number of RSS queues: number of IGU SBs minus one that goes | |
1479 | * to CNIC. | |
1480 | */ | |
1481 | #define BNX2X_MAX_RSS_COUNT(bp) ((bp)->igu_sb_cnt - CNIC_PRESENT) | |
523224a3 | 1482 | |
6383c0b3 AE |
1483 | /* |
1484 | * Maximum CID count that might be required by the bnx2x: | |
37ae41a9 | 1485 | * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI |
6383c0b3 | 1486 | */ |
37ae41a9 MS |
1487 | #define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \ |
1488 | + NON_ETH_CONTEXT_USE + CNIC_PRESENT) | |
1489 | #define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \ | |
1490 | + NON_ETH_CONTEXT_USE + CNIC_PRESENT) | |
6383c0b3 AE |
1491 | #define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\ |
1492 | ILT_PAGE_CIDS)) | |
523224a3 DK |
1493 | |
1494 | int qm_cid_count; | |
a2fbb9ea | 1495 | |
a18f5128 EG |
1496 | int dropless_fc; |
1497 | ||
37b091ba MC |
1498 | #ifdef BCM_CNIC |
1499 | u32 cnic_flags; | |
1500 | #define BNX2X_CNIC_FLAG_MAC_SET 1 | |
37b091ba MC |
1501 | void *t2; |
1502 | dma_addr_t t2_mapping; | |
13707f9e | 1503 | struct cnic_ops __rcu *cnic_ops; |
37b091ba MC |
1504 | void *cnic_data; |
1505 | u32 cnic_tag; | |
1506 | struct cnic_eth_dev cnic_eth_dev; | |
523224a3 | 1507 | union host_hc_status_block cnic_sb; |
37b091ba | 1508 | dma_addr_t cnic_sb_mapping; |
37b091ba MC |
1509 | struct eth_spe *cnic_kwq; |
1510 | struct eth_spe *cnic_kwq_prod; | |
1511 | struct eth_spe *cnic_kwq_cons; | |
1512 | struct eth_spe *cnic_kwq_last; | |
1513 | u16 cnic_kwq_pending; | |
1514 | u16 cnic_spq_pending; | |
ec6ba945 | 1515 | u8 fip_mac[ETH_ALEN]; |
619c5cb6 VZ |
1516 | struct mutex cnic_mutex; |
1517 | struct bnx2x_vlan_mac_obj iscsi_l2_mac_obj; | |
1518 | ||
1519 | /* Start index of the "special" (CNIC related) L2 cleints */ | |
1520 | u8 cnic_base_cl_id; | |
37b091ba MC |
1521 | #endif |
1522 | ||
ad8d3948 EG |
1523 | int dmae_ready; |
1524 | /* used to synchronize dmae accesses */ | |
6e30dd4e | 1525 | spinlock_t dmae_lock; |
ad8d3948 | 1526 | |
c4ff7cbf EG |
1527 | /* used to protect the FW mail box */ |
1528 | struct mutex fw_mb_mutex; | |
1529 | ||
bb2a0f7a YG |
1530 | /* used to synchronize stats collecting */ |
1531 | int stats_state; | |
a13773a5 VZ |
1532 | |
1533 | /* used for synchronization of concurrent threads statistics handling */ | |
1534 | spinlock_t stats_lock; | |
1535 | ||
bb2a0f7a YG |
1536 | /* used by dmae command loader */ |
1537 | struct dmae_command stats_dmae; | |
1538 | int executer_idx; | |
ad8d3948 | 1539 | |
bb2a0f7a | 1540 | u16 stats_counter; |
bb2a0f7a | 1541 | struct bnx2x_eth_stats eth_stats; |
cb4dca27 | 1542 | struct host_func_stats func_stats; |
1355b704 MY |
1543 | struct bnx2x_eth_stats_old eth_stats_old; |
1544 | struct bnx2x_net_stats_old net_stats_old; | |
1545 | struct bnx2x_fw_port_stats_old fw_stats_old; | |
1546 | bool stats_init; | |
bb2a0f7a YG |
1547 | |
1548 | struct z_stream_s *strm; | |
1549 | void *gunzip_buf; | |
1550 | dma_addr_t gunzip_mapping; | |
1551 | int gunzip_outlen; | |
ad8d3948 | 1552 | #define FW_BUF_SIZE 0x8000 |
573f2035 EG |
1553 | #define GUNZIP_BUF(bp) (bp->gunzip_buf) |
1554 | #define GUNZIP_PHYS(bp) (bp->gunzip_mapping) | |
1555 | #define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen) | |
a2fbb9ea | 1556 | |
ab6ad5a4 | 1557 | struct raw_op *init_ops; |
94a78b79 | 1558 | /* Init blocks offsets inside init_ops */ |
ab6ad5a4 | 1559 | u16 *init_ops_offsets; |
94a78b79 | 1560 | /* Data blob - has 32 bit granularity */ |
ab6ad5a4 | 1561 | u32 *init_data; |
619c5cb6 VZ |
1562 | u32 init_mode_flags; |
1563 | #define INIT_MODE_FLAGS(bp) (bp->init_mode_flags) | |
94a78b79 | 1564 | /* Zipped PRAM blobs - raw data */ |
ab6ad5a4 EG |
1565 | const u8 *tsem_int_table_data; |
1566 | const u8 *tsem_pram_data; | |
1567 | const u8 *usem_int_table_data; | |
1568 | const u8 *usem_pram_data; | |
1569 | const u8 *xsem_int_table_data; | |
1570 | const u8 *xsem_pram_data; | |
1571 | const u8 *csem_int_table_data; | |
1572 | const u8 *csem_pram_data; | |
573f2035 EG |
1573 | #define INIT_OPS(bp) (bp->init_ops) |
1574 | #define INIT_OPS_OFFSETS(bp) (bp->init_ops_offsets) | |
1575 | #define INIT_DATA(bp) (bp->init_data) | |
1576 | #define INIT_TSEM_INT_TABLE_DATA(bp) (bp->tsem_int_table_data) | |
1577 | #define INIT_TSEM_PRAM_DATA(bp) (bp->tsem_pram_data) | |
1578 | #define INIT_USEM_INT_TABLE_DATA(bp) (bp->usem_int_table_data) | |
1579 | #define INIT_USEM_PRAM_DATA(bp) (bp->usem_pram_data) | |
1580 | #define INIT_XSEM_INT_TABLE_DATA(bp) (bp->xsem_int_table_data) | |
1581 | #define INIT_XSEM_PRAM_DATA(bp) (bp->xsem_pram_data) | |
1582 | #define INIT_CSEM_INT_TABLE_DATA(bp) (bp->csem_int_table_data) | |
1583 | #define INIT_CSEM_PRAM_DATA(bp) (bp->csem_pram_data) | |
1584 | ||
619c5cb6 | 1585 | #define PHY_FW_VER_LEN 20 |
34f24c7f | 1586 | char fw_ver[32]; |
ab6ad5a4 | 1587 | const struct firmware *firmware; |
619c5cb6 | 1588 | |
785b9b1a SR |
1589 | /* DCB support on/off */ |
1590 | u16 dcb_state; | |
1591 | #define BNX2X_DCB_STATE_OFF 0 | |
1592 | #define BNX2X_DCB_STATE_ON 1 | |
1593 | ||
1594 | /* DCBX engine mode */ | |
1595 | int dcbx_enabled; | |
1596 | #define BNX2X_DCBX_ENABLED_OFF 0 | |
1597 | #define BNX2X_DCBX_ENABLED_ON_NEG_OFF 1 | |
1598 | #define BNX2X_DCBX_ENABLED_ON_NEG_ON 2 | |
1599 | #define BNX2X_DCBX_ENABLED_INVALID (-1) | |
1600 | ||
1601 | bool dcbx_mode_uset; | |
1602 | ||
e4901dde | 1603 | struct bnx2x_config_dcbx_params dcbx_config_params; |
e4901dde VZ |
1604 | struct bnx2x_dcbx_port_params dcbx_port_params; |
1605 | int dcb_version; | |
1606 | ||
619c5cb6 VZ |
1607 | /* CAM credit pools */ |
1608 | struct bnx2x_credit_pool_obj macs_pool; | |
1609 | ||
1610 | /* RX_MODE object */ | |
1611 | struct bnx2x_rx_mode_obj rx_mode_obj; | |
1612 | ||
1613 | /* MCAST object */ | |
1614 | struct bnx2x_mcast_obj mcast_obj; | |
1615 | ||
1616 | /* RSS configuration object */ | |
1617 | struct bnx2x_rss_config_obj rss_conf_obj; | |
1618 | ||
1619 | /* Function State controlling object */ | |
1620 | struct bnx2x_func_sp_obj func_obj; | |
1621 | ||
1622 | unsigned long sp_state; | |
1623 | ||
7be08a72 AE |
1624 | /* operation indication for the sp_rtnl task */ |
1625 | unsigned long sp_rtnl_state; | |
1626 | ||
619c5cb6 | 1627 | /* DCBX Negotation results */ |
e4901dde VZ |
1628 | struct dcbx_features dcbx_local_feat; |
1629 | u32 dcbx_error; | |
619c5cb6 | 1630 | |
0be6bc62 SR |
1631 | #ifdef BCM_DCBNL |
1632 | struct dcbx_features dcbx_remote_feat; | |
1633 | u32 dcbx_remote_flags; | |
1634 | #endif | |
a3348722 BW |
1635 | /* AFEX: store default vlan used */ |
1636 | int afex_def_vlan_tag; | |
1637 | enum mf_cfg_afex_vlan_mode afex_vlan_mode; | |
e3835b99 | 1638 | u32 pending_max; |
6383c0b3 AE |
1639 | |
1640 | /* multiple tx classes of service */ | |
1641 | u8 max_cos; | |
1642 | ||
1643 | /* priority to cos mapping */ | |
1644 | u8 prio_to_cos[8]; | |
a2fbb9ea ET |
1645 | }; |
1646 | ||
619c5cb6 VZ |
1647 | /* Tx queues may be less or equal to Rx queues */ |
1648 | extern int num_queues; | |
54b9ddaa | 1649 | #define BNX2X_NUM_QUEUES(bp) (bp->num_queues) |
6383c0b3 | 1650 | #define BNX2X_NUM_ETH_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - NON_ETH_CONTEXT_USE) |
65565884 MS |
1651 | #define BNX2X_NUM_NON_CNIC_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - \ |
1652 | NON_ETH_CONTEXT_USE) | |
6383c0b3 | 1653 | #define BNX2X_NUM_RX_QUEUES(bp) BNX2X_NUM_QUEUES(bp) |
ec6ba945 | 1654 | |
54b9ddaa | 1655 | #define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1) |
3196a88a | 1656 | |
6383c0b3 AE |
1657 | #define BNX2X_MAX_QUEUES(bp) BNX2X_MAX_RSS_COUNT(bp) |
1658 | /* #define is_eth_multi(bp) (BNX2X_NUM_ETH_QUEUES(bp) > 1) */ | |
523224a3 DK |
1659 | |
1660 | #define RSS_IPV4_CAP_MASK \ | |
1661 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | |
1662 | ||
1663 | #define RSS_IPV4_TCP_CAP_MASK \ | |
1664 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | |
1665 | ||
1666 | #define RSS_IPV6_CAP_MASK \ | |
1667 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | |
1668 | ||
1669 | #define RSS_IPV6_TCP_CAP_MASK \ | |
1670 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | |
1671 | ||
1672 | /* func init flags */ | |
619c5cb6 VZ |
1673 | #define FUNC_FLG_RSS 0x0001 |
1674 | #define FUNC_FLG_STATS 0x0002 | |
1675 | /* removed FUNC_FLG_UNMATCHED 0x0004 */ | |
1676 | #define FUNC_FLG_TPA 0x0008 | |
1677 | #define FUNC_FLG_SPQ 0x0010 | |
1678 | #define FUNC_FLG_LEADING 0x0020 /* PF only */ | |
523224a3 | 1679 | |
523224a3 DK |
1680 | |
1681 | struct bnx2x_func_init_params { | |
523224a3 DK |
1682 | /* dma */ |
1683 | dma_addr_t fw_stat_map; /* valid iff FUNC_FLG_STATS */ | |
1684 | dma_addr_t spq_map; /* valid iff FUNC_FLG_SPQ */ | |
1685 | ||
1686 | u16 func_flgs; | |
1687 | u16 func_id; /* abs fid */ | |
1688 | u16 pf_id; | |
1689 | u16 spq_prod; /* valid iff FUNC_FLG_SPQ */ | |
1690 | }; | |
1691 | ||
ec6ba945 | 1692 | #define for_each_eth_queue(bp, var) \ |
6383c0b3 | 1693 | for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++) |
ec6ba945 VZ |
1694 | |
1695 | #define for_each_nondefault_eth_queue(bp, var) \ | |
6383c0b3 | 1696 | for ((var) = 1; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++) |
ec6ba945 | 1697 | |
555f6c78 | 1698 | #define for_each_queue(bp, var) \ |
6383c0b3 | 1699 | for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ |
ec6ba945 VZ |
1700 | if (skip_queue(bp, var)) \ |
1701 | continue; \ | |
1702 | else | |
1703 | ||
6383c0b3 | 1704 | /* Skip forwarding FP */ |
ec6ba945 | 1705 | #define for_each_rx_queue(bp, var) \ |
6383c0b3 | 1706 | for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ |
ec6ba945 VZ |
1707 | if (skip_rx_queue(bp, var)) \ |
1708 | continue; \ | |
1709 | else | |
1710 | ||
6383c0b3 | 1711 | /* Skip OOO FP */ |
ec6ba945 | 1712 | #define for_each_tx_queue(bp, var) \ |
6383c0b3 | 1713 | for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ |
ec6ba945 VZ |
1714 | if (skip_tx_queue(bp, var)) \ |
1715 | continue; \ | |
1716 | else | |
1717 | ||
3196a88a | 1718 | #define for_each_nondefault_queue(bp, var) \ |
6383c0b3 | 1719 | for ((var) = 1; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \ |
ec6ba945 VZ |
1720 | if (skip_queue(bp, var)) \ |
1721 | continue; \ | |
1722 | else | |
3196a88a | 1723 | |
6383c0b3 AE |
1724 | #define for_each_cos_in_tx_queue(fp, var) \ |
1725 | for ((var) = 0; (var) < (fp)->max_cos; (var)++) | |
1726 | ||
ec6ba945 | 1727 | /* skip rx queue |
008d23e4 | 1728 | * if FCOE l2 support is disabled and this is the fcoe L2 queue |
ec6ba945 VZ |
1729 | */ |
1730 | #define skip_rx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx)) | |
1731 | ||
1732 | /* skip tx queue | |
008d23e4 | 1733 | * if FCOE l2 support is disabled and this is the fcoe L2 queue |
ec6ba945 VZ |
1734 | */ |
1735 | #define skip_tx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx)) | |
1736 | ||
1737 | #define skip_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx)) | |
3196a88a | 1738 | |
f85582f8 | 1739 | |
619c5cb6 VZ |
1740 | |
1741 | ||
1742 | /** | |
1743 | * bnx2x_set_mac_one - configure a single MAC address | |
1744 | * | |
1745 | * @bp: driver handle | |
1746 | * @mac: MAC to configure | |
1747 | * @obj: MAC object handle | |
1748 | * @set: if 'true' add a new MAC, otherwise - delete | |
1749 | * @mac_type: the type of the MAC to configure (e.g. ETH, UC list) | |
1750 | * @ramrod_flags: RAMROD_XXX flags (e.g. RAMROD_CONT, RAMROD_COMP_WAIT) | |
1751 | * | |
1752 | * Configures one MAC according to provided parameters or continues the | |
1753 | * execution of previously scheduled commands if RAMROD_CONT is set in | |
1754 | * ramrod_flags. | |
1755 | * | |
1756 | * Returns zero if operation has successfully completed, a positive value if the | |
1757 | * operation has been successfully scheduled and a negative - if a requested | |
1758 | * operations has failed. | |
1759 | */ | |
1760 | int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac, | |
1761 | struct bnx2x_vlan_mac_obj *obj, bool set, | |
1762 | int mac_type, unsigned long *ramrod_flags); | |
619c5cb6 VZ |
1763 | /** |
1764 | * bnx2x_del_all_macs - delete all MACs configured for the specific MAC object | |
1765 | * | |
1766 | * @bp: driver handle | |
1767 | * @mac_obj: MAC object handle | |
1768 | * @mac_type: type of the MACs to clear (BNX2X_XXX_MAC) | |
1769 | * @wait_for_comp: if 'true' block until completion | |
1770 | * | |
1771 | * Deletes all MACs of the specific type (e.g. ETH, UC list). | |
1772 | * | |
1773 | * Returns zero if operation has successfully completed, a positive value if the | |
1774 | * operation has been successfully scheduled and a negative - if a requested | |
1775 | * operations has failed. | |
1776 | */ | |
1777 | int bnx2x_del_all_macs(struct bnx2x *bp, | |
1778 | struct bnx2x_vlan_mac_obj *mac_obj, | |
1779 | int mac_type, bool wait_for_comp); | |
1780 | ||
1781 | /* Init Function API */ | |
1782 | void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p); | |
1783 | int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port); | |
1784 | int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); | |
1785 | int bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode); | |
1786 | int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); | |
2ae17f66 VZ |
1787 | void bnx2x_read_mf_cfg(struct bnx2x *bp); |
1788 | ||
619c5cb6 | 1789 | |
f85582f8 | 1790 | /* dmae */ |
c18487ee YR |
1791 | void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32); |
1792 | void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, | |
1793 | u32 len32); | |
f85582f8 DK |
1794 | void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx); |
1795 | u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type); | |
1796 | u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode); | |
1797 | u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type, | |
1798 | bool with_comp, u8 comp_type); | |
1799 | ||
f85582f8 | 1800 | |
de0c62db DK |
1801 | void bnx2x_calc_fc_adv(struct bnx2x *bp); |
1802 | int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, | |
619c5cb6 | 1803 | u32 data_hi, u32 data_lo, int cmd_type); |
de0c62db | 1804 | void bnx2x_update_coalesce(struct bnx2x *bp); |
1ac9e428 | 1805 | int bnx2x_get_cur_phy_idx(struct bnx2x *bp); |
f85582f8 | 1806 | |
34f80b04 EG |
1807 | static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, |
1808 | int wait) | |
1809 | { | |
1810 | u32 val; | |
1811 | ||
1812 | do { | |
1813 | val = REG_RD(bp, reg); | |
1814 | if (val == expected) | |
1815 | break; | |
1816 | ms -= wait; | |
1817 | msleep(wait); | |
1818 | ||
1819 | } while (ms > 0); | |
1820 | ||
1821 | return val; | |
1822 | } | |
f85582f8 | 1823 | |
523224a3 DK |
1824 | #define BNX2X_ILT_ZALLOC(x, y, size) \ |
1825 | do { \ | |
d245a111 | 1826 | x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \ |
523224a3 DK |
1827 | if (x) \ |
1828 | memset(x, 0, size); \ | |
1829 | } while (0) | |
1830 | ||
1831 | #define BNX2X_ILT_FREE(x, y, size) \ | |
1832 | do { \ | |
1833 | if (x) { \ | |
d245a111 | 1834 | dma_free_coherent(&bp->pdev->dev, size, x, y); \ |
523224a3 DK |
1835 | x = NULL; \ |
1836 | y = 0; \ | |
1837 | } \ | |
1838 | } while (0) | |
1839 | ||
1840 | #define ILOG2(x) (ilog2((x))) | |
1841 | ||
1842 | #define ILT_NUM_PAGE_ENTRIES (3072) | |
1843 | /* In 57710/11 we use whole table since we have 8 func | |
f85582f8 DK |
1844 | * In 57712 we have only 4 func, but use same size per func, then only half of |
1845 | * the table in use | |
523224a3 DK |
1846 | */ |
1847 | #define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8) | |
1848 | ||
1849 | #define FUNC_ILT_BASE(func) (func * ILT_PER_FUNC) | |
1850 | /* | |
1851 | * the phys address is shifted right 12 bits and has an added | |
1852 | * 1=valid bit added to the 53rd bit | |
1853 | * then since this is a wide register(TM) | |
1854 | * we split it into two 32 bit writes | |
1855 | */ | |
1856 | #define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF)) | |
1857 | #define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44))) | |
34f80b04 | 1858 | |
34f80b04 EG |
1859 | /* load/unload mode */ |
1860 | #define LOAD_NORMAL 0 | |
1861 | #define LOAD_OPEN 1 | |
1862 | #define LOAD_DIAG 2 | |
8970b2e4 | 1863 | #define LOAD_LOOPBACK_EXT 3 |
34f80b04 EG |
1864 | #define UNLOAD_NORMAL 0 |
1865 | #define UNLOAD_CLOSE 1 | |
f85582f8 | 1866 | #define UNLOAD_RECOVERY 2 |
34f80b04 | 1867 | |
bb2a0f7a | 1868 | |
ad8d3948 | 1869 | /* DMAE command defines */ |
f2e0899f DK |
1870 | #define DMAE_TIMEOUT -1 |
1871 | #define DMAE_PCI_ERROR -2 /* E2 and onward */ | |
1872 | #define DMAE_NOT_RDY -3 | |
1873 | #define DMAE_PCI_ERR_FLAG 0x80000000 | |
1874 | ||
1875 | #define DMAE_SRC_PCI 0 | |
1876 | #define DMAE_SRC_GRC 1 | |
1877 | ||
1878 | #define DMAE_DST_NONE 0 | |
1879 | #define DMAE_DST_PCI 1 | |
1880 | #define DMAE_DST_GRC 2 | |
1881 | ||
1882 | #define DMAE_COMP_PCI 0 | |
1883 | #define DMAE_COMP_GRC 1 | |
1884 | ||
1885 | /* E2 and onward - PCI error handling in the completion */ | |
1886 | ||
1887 | #define DMAE_COMP_REGULAR 0 | |
1888 | #define DMAE_COM_SET_ERR 1 | |
ad8d3948 | 1889 | |
f2e0899f DK |
1890 | #define DMAE_CMD_SRC_PCI (DMAE_SRC_PCI << \ |
1891 | DMAE_COMMAND_SRC_SHIFT) | |
1892 | #define DMAE_CMD_SRC_GRC (DMAE_SRC_GRC << \ | |
1893 | DMAE_COMMAND_SRC_SHIFT) | |
ad8d3948 | 1894 | |
f2e0899f DK |
1895 | #define DMAE_CMD_DST_PCI (DMAE_DST_PCI << \ |
1896 | DMAE_COMMAND_DST_SHIFT) | |
1897 | #define DMAE_CMD_DST_GRC (DMAE_DST_GRC << \ | |
1898 | DMAE_COMMAND_DST_SHIFT) | |
1899 | ||
1900 | #define DMAE_CMD_C_DST_PCI (DMAE_COMP_PCI << \ | |
1901 | DMAE_COMMAND_C_DST_SHIFT) | |
1902 | #define DMAE_CMD_C_DST_GRC (DMAE_COMP_GRC << \ | |
1903 | DMAE_COMMAND_C_DST_SHIFT) | |
ad8d3948 EG |
1904 | |
1905 | #define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE | |
1906 | ||
1907 | #define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT) | |
1908 | #define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT) | |
1909 | #define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT) | |
1910 | #define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT) | |
1911 | ||
1912 | #define DMAE_CMD_PORT_0 0 | |
1913 | #define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT | |
1914 | ||
1915 | #define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET | |
1916 | #define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET | |
1917 | #define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT | |
1918 | ||
f2e0899f DK |
1919 | #define DMAE_SRC_PF 0 |
1920 | #define DMAE_SRC_VF 1 | |
1921 | ||
1922 | #define DMAE_DST_PF 0 | |
1923 | #define DMAE_DST_VF 1 | |
1924 | ||
1925 | #define DMAE_C_SRC 0 | |
1926 | #define DMAE_C_DST 1 | |
1927 | ||
ad8d3948 | 1928 | #define DMAE_LEN32_RD_MAX 0x80 |
02e3c6cb | 1929 | #define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000) |
ad8d3948 | 1930 | |
f2e0899f DK |
1931 | #define DMAE_COMP_VAL 0x60d0d0ae /* E2 and on - upper bit |
1932 | indicates eror */ | |
ad8d3948 EG |
1933 | |
1934 | #define MAX_DMAE_C_PER_PORT 8 | |
ab6ad5a4 | 1935 | #define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ |
3395a033 | 1936 | BP_VN(bp)) |
ab6ad5a4 | 1937 | #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ |
ad8d3948 EG |
1938 | E1HVN_MAX) |
1939 | ||
25047950 ET |
1940 | /* PCIE link and speed */ |
1941 | #define PCICFG_LINK_WIDTH 0x1f00000 | |
1942 | #define PCICFG_LINK_WIDTH_SHIFT 20 | |
1943 | #define PCICFG_LINK_SPEED 0xf0000 | |
1944 | #define PCICFG_LINK_SPEED_SHIFT 16 | |
a2fbb9ea | 1945 | |
cf2c1df6 MS |
1946 | #define BNX2X_NUM_TESTS_SF 7 |
1947 | #define BNX2X_NUM_TESTS_MF 3 | |
1948 | #define BNX2X_NUM_TESTS(bp) (IS_MF(bp) ? BNX2X_NUM_TESTS_MF : \ | |
1949 | BNX2X_NUM_TESTS_SF) | |
bb2a0f7a | 1950 | |
b5bf9068 EG |
1951 | #define BNX2X_PHY_LOOPBACK 0 |
1952 | #define BNX2X_MAC_LOOPBACK 1 | |
8970b2e4 | 1953 | #define BNX2X_EXT_LOOPBACK 2 |
b5bf9068 EG |
1954 | #define BNX2X_PHY_LOOPBACK_FAILED 1 |
1955 | #define BNX2X_MAC_LOOPBACK_FAILED 2 | |
8970b2e4 | 1956 | #define BNX2X_EXT_LOOPBACK_FAILED 3 |
bb2a0f7a YG |
1957 | #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \ |
1958 | BNX2X_PHY_LOOPBACK_FAILED) | |
96fc1784 | 1959 | |
7a9b2557 VZ |
1960 | |
1961 | #define STROM_ASSERT_ARRAY_SIZE 50 | |
1962 | ||
96fc1784 | 1963 | |
34f80b04 | 1964 | /* must be used on a CID before placing it on a HW ring */ |
ab6ad5a4 | 1965 | #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \ |
3395a033 | 1966 | (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \ |
619c5cb6 | 1967 | (x)) |
7a9b2557 VZ |
1968 | |
1969 | #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe)) | |
1970 | #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1) | |
1971 | ||
1972 | ||
523224a3 | 1973 | #define BNX2X_BTR 4 |
7a9b2557 | 1974 | #define MAX_SPQ_PENDING 8 |
a2fbb9ea | 1975 | |
ff80ee02 DK |
1976 | /* CMNG constants, as derived from system spec calculations */ |
1977 | /* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */ | |
1978 | #define DEF_MIN_RATE 100 | |
9b3de1ef DK |
1979 | /* resolution of the rate shaping timer - 400 usec */ |
1980 | #define RS_PERIODIC_TIMEOUT_USEC 400 | |
34f80b04 | 1981 | /* number of bytes in single QM arbitration cycle - |
ff80ee02 DK |
1982 | * coefficient for calculating the fairness timer */ |
1983 | #define QM_ARB_BYTES 160000 | |
1984 | /* resolution of Min algorithm 1:100 */ | |
1985 | #define MIN_RES 100 | |
1986 | /* how many bytes above threshold for the minimal credit of Min algorithm*/ | |
1987 | #define MIN_ABOVE_THRESH 32768 | |
1988 | /* Fairness algorithm integration time coefficient - | |
1989 | * for calculating the actual Tfair */ | |
1990 | #define T_FAIR_COEF ((MIN_ABOVE_THRESH + QM_ARB_BYTES) * 8 * MIN_RES) | |
1991 | /* Memory of fairness algorithm . 2 cycles */ | |
1992 | #define FAIR_MEM 2 | |
34f80b04 EG |
1993 | |
1994 | ||
1995 | #define ATTN_NIG_FOR_FUNC (1L << 8) | |
1996 | #define ATTN_SW_TIMER_4_FUNC (1L << 9) | |
1997 | #define GPIO_2_FUNC (1L << 10) | |
1998 | #define GPIO_3_FUNC (1L << 11) | |
1999 | #define GPIO_4_FUNC (1L << 12) | |
2000 | #define ATTN_GENERAL_ATTN_1 (1L << 13) | |
2001 | #define ATTN_GENERAL_ATTN_2 (1L << 14) | |
2002 | #define ATTN_GENERAL_ATTN_3 (1L << 15) | |
2003 | #define ATTN_GENERAL_ATTN_4 (1L << 13) | |
2004 | #define ATTN_GENERAL_ATTN_5 (1L << 14) | |
2005 | #define ATTN_GENERAL_ATTN_6 (1L << 15) | |
2006 | ||
2007 | #define ATTN_HARD_WIRED_MASK 0xff00 | |
2008 | #define ATTENTION_ID 4 | |
a2fbb9ea ET |
2009 | |
2010 | ||
34f80b04 EG |
2011 | /* stuff added to make the code fit 80Col */ |
2012 | ||
2013 | #define BNX2X_PMF_LINK_ASSERT \ | |
2014 | GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp)) | |
2015 | ||
a2fbb9ea ET |
2016 | #define BNX2X_MC_ASSERT_BITS \ |
2017 | (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \ | |
2018 | GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \ | |
2019 | GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \ | |
2020 | GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT)) | |
2021 | ||
2022 | #define BNX2X_MCP_ASSERT \ | |
2023 | GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT) | |
2024 | ||
34f80b04 EG |
2025 | #define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC) |
2026 | #define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \ | |
2027 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \ | |
2028 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \ | |
2029 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \ | |
2030 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \ | |
2031 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC)) | |
2032 | ||
a2fbb9ea ET |
2033 | #define HW_INTERRUT_ASSERT_SET_0 \ |
2034 | (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \ | |
2035 | AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \ | |
2036 | AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \ | |
c9ee9206 | 2037 | AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT) |
34f80b04 | 2038 | #define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \ |
a2fbb9ea ET |
2039 | AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \ |
2040 | AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \ | |
2041 | AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\ | |
c9ee9206 VZ |
2042 | AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\ |
2043 | AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\ | |
2044 | AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR) | |
a2fbb9ea ET |
2045 | #define HW_INTERRUT_ASSERT_SET_1 \ |
2046 | (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \ | |
2047 | AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \ | |
2048 | AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \ | |
2049 | AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \ | |
2050 | AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \ | |
2051 | AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \ | |
2052 | AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \ | |
2053 | AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \ | |
2054 | AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \ | |
2055 | AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \ | |
2056 | AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT) | |
c9ee9206 | 2057 | #define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\ |
a2fbb9ea | 2058 | AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \ |
c9ee9206 | 2059 | AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\ |
a2fbb9ea | 2060 | AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \ |
c9ee9206 | 2061 | AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\ |
a2fbb9ea | 2062 | AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \ |
ab6ad5a4 | 2063 | AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\ |
c9ee9206 | 2064 | AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\ |
ab6ad5a4 | 2065 | AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\ |
a2fbb9ea ET |
2066 | AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \ |
2067 | AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \ | |
c9ee9206 | 2068 | AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\ |
a2fbb9ea ET |
2069 | AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \ |
2070 | AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \ | |
c9ee9206 VZ |
2071 | AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\ |
2072 | AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR) | |
a2fbb9ea ET |
2073 | #define HW_INTERRUT_ASSERT_SET_2 \ |
2074 | (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \ | |
2075 | AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \ | |
2076 | AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \ | |
2077 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\ | |
2078 | AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT) | |
34f80b04 | 2079 | #define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \ |
a2fbb9ea ET |
2080 | AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \ |
2081 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\ | |
2082 | AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \ | |
2083 | AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \ | |
c9ee9206 | 2084 | AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\ |
a2fbb9ea ET |
2085 | AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \ |
2086 | AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR) | |
2087 | ||
72fd0718 VZ |
2088 | #define HW_PRTY_ASSERT_SET_3 (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \ |
2089 | AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \ | |
2090 | AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \ | |
2091 | AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY) | |
a2fbb9ea | 2092 | |
8736c826 VZ |
2093 | #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \ |
2094 | AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR) | |
2095 | ||
34f80b04 | 2096 | #define MULTI_MASK 0x7f |
a2fbb9ea | 2097 | |
619c5cb6 VZ |
2098 | |
2099 | #define DEF_USB_FUNC_OFF offsetof(struct cstorm_def_status_block_u, func) | |
2100 | #define DEF_CSB_FUNC_OFF offsetof(struct cstorm_def_status_block_c, func) | |
2101 | #define DEF_XSB_FUNC_OFF offsetof(struct xstorm_def_status_block, func) | |
2102 | #define DEF_TSB_FUNC_OFF offsetof(struct tstorm_def_status_block, func) | |
2103 | ||
2104 | #define DEF_USB_IGU_INDEX_OFF \ | |
2105 | offsetof(struct cstorm_def_status_block_u, igu_index) | |
2106 | #define DEF_CSB_IGU_INDEX_OFF \ | |
2107 | offsetof(struct cstorm_def_status_block_c, igu_index) | |
2108 | #define DEF_XSB_IGU_INDEX_OFF \ | |
2109 | offsetof(struct xstorm_def_status_block, igu_index) | |
2110 | #define DEF_TSB_IGU_INDEX_OFF \ | |
2111 | offsetof(struct tstorm_def_status_block, igu_index) | |
2112 | ||
2113 | #define DEF_USB_SEGMENT_OFF \ | |
2114 | offsetof(struct cstorm_def_status_block_u, segment) | |
2115 | #define DEF_CSB_SEGMENT_OFF \ | |
2116 | offsetof(struct cstorm_def_status_block_c, segment) | |
2117 | #define DEF_XSB_SEGMENT_OFF \ | |
2118 | offsetof(struct xstorm_def_status_block, segment) | |
2119 | #define DEF_TSB_SEGMENT_OFF \ | |
2120 | offsetof(struct tstorm_def_status_block, segment) | |
2121 | ||
a2fbb9ea | 2122 | #define BNX2X_SP_DSB_INDEX \ |
523224a3 DK |
2123 | (&bp->def_status_blk->sp_sb.\ |
2124 | index_values[HC_SP_INDEX_ETH_DEF_CONS]) | |
f85582f8 | 2125 | |
523224a3 DK |
2126 | #define SET_FLAG(value, mask, flag) \ |
2127 | do {\ | |
2128 | (value) &= ~(mask);\ | |
2129 | (value) |= ((flag) << (mask##_SHIFT));\ | |
2130 | } while (0) | |
a2fbb9ea | 2131 | |
523224a3 | 2132 | #define GET_FLAG(value, mask) \ |
619c5cb6 | 2133 | (((value) & (mask)) >> (mask##_SHIFT)) |
a2fbb9ea | 2134 | |
f2e0899f DK |
2135 | #define GET_FIELD(value, fname) \ |
2136 | (((value) & (fname##_MASK)) >> (fname##_SHIFT)) | |
2137 | ||
a2fbb9ea | 2138 | #define CAM_IS_INVALID(x) \ |
523224a3 DK |
2139 | (GET_FLAG(x.flags, \ |
2140 | MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \ | |
2141 | (T_ETH_MAC_COMMAND_INVALIDATE)) | |
a2fbb9ea | 2142 | |
34f80b04 EG |
2143 | /* Number of u32 elements in MC hash array */ |
2144 | #define MC_HASH_SIZE 8 | |
2145 | #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \ | |
2146 | TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4) | |
a2fbb9ea ET |
2147 | |
2148 | ||
34f80b04 EG |
2149 | #ifndef PXP2_REG_PXP2_INT_STS |
2150 | #define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0 | |
2151 | #endif | |
2152 | ||
f2e0899f DK |
2153 | #ifndef ETH_MAX_RX_CLIENTS_E2 |
2154 | #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H | |
2155 | #endif | |
f85582f8 | 2156 | |
34f24c7f VZ |
2157 | #define BNX2X_VPD_LEN 128 |
2158 | #define VENDOR_ID_LEN 4 | |
2159 | ||
523224a3 DK |
2160 | /* Congestion management fairness mode */ |
2161 | #define CMNG_FNS_NONE 0 | |
2162 | #define CMNG_FNS_MINMAX 1 | |
2163 | ||
2164 | #define HC_SEG_ACCESS_DEF 0 /*Driver decision 0-3*/ | |
2165 | #define HC_SEG_ACCESS_ATTN 4 | |
2166 | #define HC_SEG_ACCESS_NORM 0 /*Driver decision 0-1*/ | |
2167 | ||
619c5cb6 VZ |
2168 | static const u32 dmae_reg_go_c[] = { |
2169 | DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3, | |
2170 | DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7, | |
2171 | DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11, | |
2172 | DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15 | |
2173 | }; | |
de0c62db | 2174 | |
619c5cb6 | 2175 | void bnx2x_set_ethtool_ops(struct net_device *netdev); |
3deb8167 | 2176 | void bnx2x_notify_link_changed(struct bnx2x *bp); |
614c76df DK |
2177 | |
2178 | ||
9e62e912 | 2179 | #define BNX2X_MF_SD_PROTOCOL(bp) \ |
614c76df DK |
2180 | ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK) |
2181 | ||
2182 | #ifdef BCM_CNIC | |
9e62e912 DK |
2183 | #define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \ |
2184 | (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI) | |
614c76df | 2185 | |
9e62e912 DK |
2186 | #define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \ |
2187 | (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE) | |
2188 | ||
2189 | #define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp)) | |
2190 | #define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)) | |
2191 | ||
a3348722 BW |
2192 | #define BNX2X_MF_EXT_PROTOCOL_FCOE(bp) ((bp)->mf_ext_config & \ |
2193 | MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) | |
2194 | ||
2195 | #define IS_MF_FCOE_AFEX(bp) (IS_MF_AFEX(bp) && BNX2X_MF_EXT_PROTOCOL_FCOE(bp)) | |
9e62e912 DK |
2196 | #define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \ |
2197 | (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \ | |
2198 | BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))) | |
a3348722 BW |
2199 | #else |
2200 | #define IS_MF_FCOE_AFEX(bp) false | |
614c76df DK |
2201 | #endif |
2202 | ||
a3348722 | 2203 | |
a2fbb9ea | 2204 | #endif /* bnx2x.h */ |