blob: d80809f5ffc99bba251c761580b3e1d7bb628bf3 [file] [log] [blame]
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001/* bnx2x.h: Broadcom Everest network driver.
2 *
Vladislav Zolotarov3359fce2010-02-17 13:35:01 -08003 * Copyright (c) 2007-2010 Broadcom Corporation
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02004 *
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 *
Eilon Greenstein24e3fce2008-06-12 14:30:28 -07009 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
10 * Written by: Eliezer Tamir
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020011 * Based on code from Michael Chan's bnx2 driver
12 */
13
14#ifndef BNX2X_H
15#define BNX2X_H
16
Eilon Greenstein34f80b02008-06-23 20:33:01 -070017/* compilation time flags */
18
19/* define this to make the driver freeze on error to allow getting debug info
20 * (you will need to reboot afterwards) */
21/* #define BNX2X_STOP_ON_ERROR */
22
Dmitry Kravkov25141582010-09-12 05:48:28 +000023#define DRV_MODULE_VERSION "1.52.53-7"
24#define DRV_MODULE_RELDATE "2010/09/12"
Dmitry Kravkovde0c62d2010-07-27 12:35:24 +000025#define BNX2X_BC_VER 0x040200
26
Eilon Greenstein0c6671b2009-01-14 21:26:51 -080027#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
28#define BCM_VLAN 1
29#endif
30
Eilon Greenstein555f6c72009-02-12 08:36:11 +000031#define BNX2X_MULTI_QUEUE
32
33#define BNX2X_NEW_NAPI
34
Eilon Greenstein359d8b12009-02-12 08:38:25 +000035
Vladislav Zolotarov1ac218c2010-04-19 01:14:18 +000036#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
37#define BCM_CNIC 1
Dmitry Kravkov5d1e8592010-07-27 12:31:10 +000038#include "../cnic_if.h"
Vladislav Zolotarov1ac218c2010-04-19 01:14:18 +000039#endif
40
Vladislav Zolotarov1ac218c2010-04-19 01:14:18 +000041#ifdef BCM_CNIC
42#define BNX2X_MIN_MSIX_VEC_CNT 3
43#define BNX2X_MSIX_VEC_FP_START 2
44#else
45#define BNX2X_MIN_MSIX_VEC_CNT 2
46#define BNX2X_MSIX_VEC_FP_START 1
47#endif
48
Eilon Greenstein01cd4522009-08-12 08:23:08 +000049#include <linux/mdio.h>
Dmitry Kravkov9f6c9252010-07-27 12:34:34 +000050#include <linux/pci.h>
Eilon Greenstein359d8b12009-02-12 08:38:25 +000051#include "bnx2x_reg.h"
52#include "bnx2x_fw_defs.h"
53#include "bnx2x_hsi.h"
54#include "bnx2x_link.h"
Dmitry Kravkov6c719d02010-07-27 12:36:15 +000055#include "bnx2x_stats.h"
Eilon Greenstein359d8b12009-02-12 08:38:25 +000056
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020057/* error/debug prints */
58
Eilon Greenstein34f80b02008-06-23 20:33:01 -070059#define DRV_MODULE_NAME "bnx2x"
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020060
61/* for messages that are currently off */
Eilon Greenstein34f80b02008-06-23 20:33:01 -070062#define BNX2X_MSG_OFF 0
63#define BNX2X_MSG_MCP 0x010000 /* was: NETIF_MSG_HW */
64#define BNX2X_MSG_STATS 0x020000 /* was: NETIF_MSG_TIMER */
65#define BNX2X_MSG_NVM 0x040000 /* was: NETIF_MSG_HW */
66#define BNX2X_MSG_DMAE 0x080000 /* was: NETIF_MSG_HW */
Eliezer Tamirf1410642008-02-28 11:51:50 -080067#define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */
68#define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020069
Eilon Greenstein34f80b02008-06-23 20:33:01 -070070#define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020071
72/* regular debug print */
Joe Perches7995c642010-02-17 15:01:52 +000073#define DP(__mask, __fmt, __args...) \
74do { \
75 if (bp->msg_enable & (__mask)) \
76 printk(DP_LEVEL "[%s:%d(%s)]" __fmt, \
77 __func__, __LINE__, \
78 bp->dev ? (bp->dev->name) : "?", \
79 ##__args); \
80} while (0)
Eilon Greenstein34f80b02008-06-23 20:33:01 -070081
82/* errors debug print */
Joe Perches7995c642010-02-17 15:01:52 +000083#define BNX2X_DBG_ERR(__fmt, __args...) \
84do { \
85 if (netif_msg_probe(bp)) \
86 pr_err("[%s:%d(%s)]" __fmt, \
87 __func__, __LINE__, \
88 bp->dev ? (bp->dev->name) : "?", \
89 ##__args); \
90} while (0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +020091
92/* for errors (never masked) */
Joe Perches7995c642010-02-17 15:01:52 +000093#define BNX2X_ERR(__fmt, __args...) \
94do { \
95 pr_err("[%s:%d(%s)]" __fmt, \
96 __func__, __LINE__, \
97 bp->dev ? (bp->dev->name) : "?", \
98 ##__args); \
Vladislav Zolotarovcdaa7cb2010-04-19 01:13:57 +000099 } while (0)
100
101#define BNX2X_ERROR(__fmt, __args...) do { \
102 pr_err("[%s:%d]" __fmt, __func__, __LINE__, ##__args); \
103 } while (0)
104
Eliezer Tamirf1410642008-02-28 11:51:50 -0800105
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200106/* before we have a dev->name use dev_info() */
Joe Perches7995c642010-02-17 15:01:52 +0000107#define BNX2X_DEV_INFO(__fmt, __args...) \
108do { \
109 if (netif_msg_probe(bp)) \
110 dev_info(&bp->pdev->dev, __fmt, ##__args); \
111} while (0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200112
Dmitry Kravkov6c719d02010-07-27 12:36:15 +0000113void bnx2x_panic_dump(struct bnx2x *bp);
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200114
115#ifdef BNX2X_STOP_ON_ERROR
116#define bnx2x_panic() do { \
117 bp->panic = 1; \
118 BNX2X_ERR("driver assert\n"); \
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700119 bnx2x_int_disable(bp); \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200120 bnx2x_panic_dump(bp); \
121 } while (0)
122#else
123#define bnx2x_panic() do { \
Eilon Greensteine3553b22009-08-12 08:23:31 +0000124 bp->panic = 1; \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200125 BNX2X_ERR("driver assert\n"); \
126 bnx2x_panic_dump(bp); \
127 } while (0)
128#endif
129
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000130#define bnx2x_mc_addr(ha) ((ha)->addr)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200131
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700132#define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff)
133#define U64_HI(x) (u32)(((u64)(x)) >> 32)
134#define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200135
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200136
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000137#define REG_ADDR(bp, offset) ((bp->regview) + (offset))
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700138
139#define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
140#define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000141#define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset))
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700142
143#define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200144#define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset))
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700145#define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200146
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700147#define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset)
148#define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200149
Yaniv Rosnerc18487e2008-06-23 20:27:52 -0700150#define REG_RD_DMAE(bp, offset, valp, len32) \
151 do { \
152 bnx2x_read_dmae(bp, offset, len32);\
Eilon Greenstein573f2032009-08-12 08:24:14 +0000153 memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
Yaniv Rosnerc18487e2008-06-23 20:27:52 -0700154 } while (0)
155
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700156#define REG_WR_DMAE(bp, offset, valp, len32) \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200157 do { \
Eilon Greenstein573f2032009-08-12 08:24:14 +0000158 memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200159 bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
160 offset, len32); \
161 } while (0)
162
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000163#define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
164 REG_WR_DMAE(bp, offset, valp, len32)
165
Vladislav Zolotarov3359fce2010-02-17 13:35:01 -0800166#define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
Eilon Greenstein573f2032009-08-12 08:24:14 +0000167 do { \
168 memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
169 bnx2x_write_big_buf_wb(bp, addr, len32); \
170 } while (0)
171
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700172#define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \
173 offsetof(struct shmem_region, field))
174#define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field))
175#define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200176
Eilon Greenstein2691d512009-08-12 08:22:08 +0000177#define SHMEM2_ADDR(bp, field) (bp->common.shmem2_base + \
178 offsetof(struct shmem2_region, field))
179#define SHMEM2_RD(bp, field) REG_RD(bp, SHMEM2_ADDR(bp, field))
180#define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val)
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000181#define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \
182 offsetof(struct mf_cfg, field))
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000183#define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \
184 offsetof(struct mf2_cfg, field))
Eilon Greenstein2691d512009-08-12 08:22:08 +0000185
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000186#define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field))
187#define MF_CFG_WR(bp, field, val) REG_WR(bp,\
188 MF_CFG_ADDR(bp, field), (val))
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000189#define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field))
190#define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \
191 (SHMEM2_RD((bp), size) > \
192 offsetof(struct shmem2_region, field)))
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +0000193
Eilon Greenstein345b5d52008-08-13 15:58:12 -0700194#define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg)
Eilon Greenstein3196a882008-08-13 15:58:49 -0700195#define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200196
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000197/* SP SB indices */
198
199/* General SP events - stats query, cfc delete, etc */
200#define HC_SP_INDEX_ETH_DEF_CONS 3
201
202/* EQ completions */
203#define HC_SP_INDEX_EQ_CONS 7
204
205/* iSCSI L2 */
206#define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5
207#define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1
208
209/**
210 * CIDs and CLIDs:
211 * CLIDs below is a CLID for func 0, then the CLID for other
212 * functions will be calculated by the formula:
213 *
214 * FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X
215 *
216 */
217/* iSCSI L2 */
218#define BNX2X_ISCSI_ETH_CL_ID 17
219#define BNX2X_ISCSI_ETH_CID 17
220
221/** Additional rings budgeting */
222#ifdef BCM_CNIC
223#define CNIC_CONTEXT_USE 1
224#else
225#define CNIC_CONTEXT_USE 0
226#endif /* BCM_CNIC */
227
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +0000228#define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
229 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
230
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000231#define SM_RX_ID 0
232#define SM_TX_ID 1
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200233
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700234/* fast path */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200235
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200236struct sw_rx_bd {
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700237 struct sk_buff *skb;
FUJITA Tomonori1a983142010-04-04 01:51:03 +0000238 DEFINE_DMA_UNMAP_ADDR(mapping);
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200239};
240
241struct sw_tx_bd {
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700242 struct sk_buff *skb;
243 u16 first_bd;
Eilon Greensteinca003922009-08-12 22:53:28 -0700244 u8 flags;
245/* Set on the first BD descriptor when there is a split BD */
246#define BNX2X_TSO_SPLIT_BD (1<<0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200247};
248
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700249struct sw_rx_page {
250 struct page *page;
FUJITA Tomonori1a983142010-04-04 01:51:03 +0000251 DEFINE_DMA_UNMAP_ADDR(mapping);
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700252};
253
Eilon Greensteinca003922009-08-12 22:53:28 -0700254union db_prod {
255 struct doorbell_set_prod data;
256 u32 raw;
257};
258
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700259
260/* MC hsi */
261#define BCM_PAGE_SHIFT 12
262#define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT)
263#define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1))
264#define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
265
266#define PAGES_PER_SGE_SHIFT 0
267#define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
Eilon Greenstein4f40f2c2009-01-14 21:24:17 -0800268#define SGE_PAGE_SIZE PAGE_SIZE
269#define SGE_PAGE_SHIFT PAGE_SHIFT
Eilon Greenstein5b6402d2009-07-21 05:47:51 +0000270#define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr))
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700271
272/* SGE ring related macros */
273#define NUM_RX_SGE_PAGES 2
274#define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
275#define MAX_RX_SGE_CNT (RX_SGE_CNT - 2)
Eilon Greenstein33471622008-08-13 15:59:08 -0700276/* RX_SGE_CNT is promised to be a power of 2 */
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700277#define RX_SGE_MASK (RX_SGE_CNT - 1)
278#define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES)
279#define MAX_RX_SGE (NUM_RX_SGE - 1)
280#define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \
281 (MAX_RX_SGE_CNT - 1)) ? (x) + 3 : (x) + 1)
282#define RX_SGE(x) ((x) & MAX_RX_SGE)
283
284/* SGE producer mask related macros */
285/* Number of bits in one sge_mask array element */
286#define RX_SGE_MASK_ELEM_SZ 64
287#define RX_SGE_MASK_ELEM_SHIFT 6
288#define RX_SGE_MASK_ELEM_MASK ((u64)RX_SGE_MASK_ELEM_SZ - 1)
289
290/* Creates a bitmask of all ones in less significant bits.
291 idx - index of the most significant bit in the created mask */
292#define RX_SGE_ONES_MASK(idx) \
293 (((u64)0x1 << (((idx) & RX_SGE_MASK_ELEM_MASK) + 1)) - 1)
294#define RX_SGE_MASK_ELEM_ONE_MASK ((u64)(~0))
295
296/* Number of u64 elements in SGE mask array */
297#define RX_SGE_MASK_LEN ((NUM_RX_SGE_PAGES * RX_SGE_CNT) / \
298 RX_SGE_MASK_ELEM_SZ)
299#define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1)
300#define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK)
301
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000302union host_hc_status_block {
303 /* pointer to fp status block e1x */
304 struct host_hc_status_block_e1x *e1x_sb;
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000305 /* pointer to fp status block e2 */
306 struct host_hc_status_block_e2 *e2_sb;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000307};
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700308
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200309struct bnx2x_fastpath {
310
Dmitry Kravkovd6214d72010-10-06 03:32:10 +0000311#define BNX2X_NAPI_WEIGHT 128
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700312 struct napi_struct napi;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000313 union host_hc_status_block status_blk;
314 /* chip independed shortcuts into sb structure */
315 __le16 *sb_index_values;
316 __le16 *sb_running_index;
317 /* chip independed shortcut into rx_prods_offset memory */
318 u32 ustorm_rx_prods_offset;
319
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700320 dma_addr_t status_blk_mapping;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200321
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700322 struct sw_tx_bd *tx_buf_ring;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200323
Eilon Greensteinca003922009-08-12 22:53:28 -0700324 union eth_tx_bd_types *tx_desc_ring;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700325 dma_addr_t tx_desc_mapping;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200326
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700327 struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */
328 struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200329
330 struct eth_rx_bd *rx_desc_ring;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700331 dma_addr_t rx_desc_mapping;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200332
333 union eth_rx_cqe *rx_comp_ring;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700334 dma_addr_t rx_comp_mapping;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200335
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700336 /* SGE ring */
337 struct eth_rx_sge *rx_sge_ring;
338 dma_addr_t rx_sge_mapping;
339
340 u64 sge_mask[RX_SGE_MASK_LEN];
341
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700342 int state;
343#define BNX2X_FP_STATE_CLOSED 0
344#define BNX2X_FP_STATE_IRQ 0x80000
345#define BNX2X_FP_STATE_OPENING 0x90000
346#define BNX2X_FP_STATE_OPEN 0xa0000
347#define BNX2X_FP_STATE_HALTING 0xb0000
348#define BNX2X_FP_STATE_HALTED 0xc0000
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000349#define BNX2X_FP_STATE_TERMINATING 0xd0000
350#define BNX2X_FP_STATE_TERMINATED 0xe0000
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200351
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700352 u8 index; /* number in fp array */
353 u8 cl_id; /* eth client id */
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000354 u8 cl_qzone_id;
355 u8 fw_sb_id; /* status block number in FW */
356 u8 igu_sb_id; /* status block number in HW */
357 u32 cid;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200358
Eilon Greensteinca003922009-08-12 22:53:28 -0700359 union db_prod tx_db;
360
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700361 u16 tx_pkt_prod;
362 u16 tx_pkt_cons;
363 u16 tx_bd_prod;
364 u16 tx_bd_cons;
Eilon Greenstein4781bfa2009-02-12 08:38:17 +0000365 __le16 *tx_cons_sb;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200366
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000367 __le16 fp_hc_idx;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200368
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700369 u16 rx_bd_prod;
370 u16 rx_bd_cons;
371 u16 rx_comp_prod;
372 u16 rx_comp_cons;
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700373 u16 rx_sge_prod;
374 /* The last maximal completed SGE */
375 u16 last_max_sge;
Eilon Greenstein4781bfa2009-02-12 08:38:17 +0000376 __le16 *rx_cons_sb;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000377
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200378
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +0000379
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700380 unsigned long tx_pkt,
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200381 rx_pkt,
Yitchak Gertner66e855f2008-08-13 15:49:05 -0700382 rx_calls;
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +0000383
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700384 /* TPA related */
385 struct sw_rx_bd tpa_pool[ETH_MAX_AGGREGATION_QUEUES_E1H];
386 u8 tpa_state[ETH_MAX_AGGREGATION_QUEUES_E1H];
387#define BNX2X_TPA_START 1
388#define BNX2X_TPA_STOP 2
389 u8 disable_tpa;
390#ifdef BNX2X_STOP_ON_ERROR
391 u64 tpa_queue_used;
392#endif
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200393
Eilon Greensteinde832a52009-02-12 08:36:33 +0000394 struct tstorm_per_client_stats old_tclient;
395 struct ustorm_per_client_stats old_uclient;
396 struct xstorm_per_client_stats old_xclient;
397 struct bnx2x_eth_q_stats eth_q_stats;
398
Eilon Greensteinca003922009-08-12 22:53:28 -0700399 /* The size is calculated using the following:
400 sizeof name field from netdev structure +
401 4 ('-Xx-' string) +
402 4 (for the digits and to make it DWORD aligned) */
403#define FP_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
404 char name[FP_NAME_SIZE];
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700405 struct bnx2x *bp; /* parent */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200406};
407
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700408#define bnx2x_fp(bp, nr, var) (bp->fp[nr].var)
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700409
410
411/* MC hsi */
412#define MAX_FETCH_BD 13 /* HW max BDs per packet */
413#define RX_COPY_THRESH 92
414
415#define NUM_TX_RINGS 16
Eilon Greensteinca003922009-08-12 22:53:28 -0700416#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700417#define MAX_TX_DESC_CNT (TX_DESC_CNT - 1)
418#define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS)
419#define MAX_TX_BD (NUM_TX_BD - 1)
420#define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000421#define INIT_JUMBO_TX_RING_SIZE MAX_TX_AVAIL
422#define INIT_TX_RING_SIZE MAX_TX_AVAIL
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700423#define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \
424 (MAX_TX_DESC_CNT - 1)) ? (x) + 2 : (x) + 1)
425#define TX_BD(x) ((x) & MAX_TX_BD)
426#define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT)
427
428/* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
429#define NUM_RX_RINGS 8
430#define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
431#define MAX_RX_DESC_CNT (RX_DESC_CNT - 2)
432#define RX_DESC_MASK (RX_DESC_CNT - 1)
433#define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS)
434#define MAX_RX_BD (NUM_RX_BD - 1)
435#define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
Dmitry Kravkov25141582010-09-12 05:48:28 +0000436#define MIN_RX_AVAIL 128
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000437#define INIT_JUMBO_RX_RING_SIZE MAX_RX_AVAIL
438#define INIT_RX_RING_SIZE MAX_RX_AVAIL
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700439#define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \
440 (MAX_RX_DESC_CNT - 1)) ? (x) + 3 : (x) + 1)
441#define RX_BD(x) ((x) & MAX_RX_BD)
442
443/* As long as CQE is 4 times bigger than BD entry we have to allocate
444 4 times more pages for CQ ring in order to keep it balanced with
445 BD ring */
446#define NUM_RCQ_RINGS (NUM_RX_RINGS * 4)
447#define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
448#define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - 1)
449#define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS)
450#define MAX_RCQ_BD (NUM_RCQ_BD - 1)
451#define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
452#define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \
453 (MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1)
454#define RCQ_BD(x) ((x) & MAX_RCQ_BD)
455
456
Eilon Greenstein33471622008-08-13 15:59:08 -0700457/* This is needed for determining of last_max */
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700458#define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b))
459
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700460#define __SGE_MASK_SET_BIT(el, bit) \
461 do { \
462 el = ((el) | ((u64)0x1 << (bit))); \
463 } while (0)
464
465#define __SGE_MASK_CLEAR_BIT(el, bit) \
466 do { \
467 el = ((el) & (~((u64)0x1 << (bit)))); \
468 } while (0)
469
470#define SGE_MASK_SET_BIT(fp, idx) \
471 __SGE_MASK_SET_BIT(fp->sge_mask[(idx) >> RX_SGE_MASK_ELEM_SHIFT], \
472 ((idx) & RX_SGE_MASK_ELEM_MASK))
473
474#define SGE_MASK_CLEAR_BIT(fp, idx) \
475 __SGE_MASK_CLEAR_BIT(fp->sge_mask[(idx) >> RX_SGE_MASK_ELEM_SHIFT], \
476 ((idx) & RX_SGE_MASK_ELEM_MASK))
477
478
479/* used on a CID received from the HW */
480#define SW_CID(x) (le32_to_cpu(x) & \
481 (COMMON_RAMROD_ETH_RX_CQE_CID >> 7))
482#define CQE_CMD(x) (le32_to_cpu(x) >> \
483 COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
484
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -0700485#define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \
486 le32_to_cpu((bd)->addr_lo))
487#define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
488
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000489#define BNX2X_DB_MIN_SHIFT 3 /* 8 bytes */
490#define BNX2X_DB_SHIFT 7 /* 128 bytes*/
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700491#define DPM_TRIGER_TYPE 0x40
492#define DOORBELL(bp, cid, val) \
493 do { \
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000494 writel((u32)(val), bp->doorbells + (bp->db_size * (cid)) + \
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700495 DPM_TRIGER_TYPE); \
496 } while (0)
497
498
499/* TX CSUM helpers */
500#define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \
501 skb->csum_offset)
502#define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \
503 skb->csum_offset))
504
505#define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff)
506
507#define XMIT_PLAIN 0
508#define XMIT_CSUM_V4 0x1
509#define XMIT_CSUM_V6 0x2
510#define XMIT_CSUM_TCP 0x4
511#define XMIT_GSO_V4 0x8
512#define XMIT_GSO_V6 0x10
513
514#define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6)
515#define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6)
516
517
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700518/* stuff added to make the code fit 80Col */
519
520#define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
521
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700522#define TPA_TYPE_START ETH_FAST_PATH_RX_CQE_START_FLG
523#define TPA_TYPE_END ETH_FAST_PATH_RX_CQE_END_FLG
524#define TPA_TYPE(cqe_fp_flags) ((cqe_fp_flags) & \
525 (TPA_TYPE_START | TPA_TYPE_END))
526
Eilon Greenstein1adcd8b2008-08-13 15:48:29 -0700527#define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
528
529#define BNX2X_IP_CSUM_ERR(cqe) \
530 (!((cqe)->fast_path_cqe.status_flags & \
531 ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG) && \
532 ((cqe)->fast_path_cqe.type_error_flags & \
533 ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG))
534
535#define BNX2X_L4_CSUM_ERR(cqe) \
536 (!((cqe)->fast_path_cqe.status_flags & \
537 ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG) && \
538 ((cqe)->fast_path_cqe.type_error_flags & \
539 ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG))
540
541#define BNX2X_RX_CSUM_OK(cqe) \
542 (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe)))
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700543
Eilon Greenstein052a38e2009-02-12 08:37:16 +0000544#define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
545 (((le16_to_cpu(flags) & \
546 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
547 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
548 == PRS_FLAG_OVERETH_IPV4)
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700549#define BNX2X_RX_SUM_FIX(cqe) \
Eilon Greenstein052a38e2009-02-12 08:37:16 +0000550 BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700551
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000552#define U_SB_ETH_RX_CQ_INDEX 1
553#define U_SB_ETH_RX_BD_INDEX 2
554#define C_SB_ETH_TX_CQ_INDEX 5
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200555
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700556#define BNX2X_RX_SB_INDEX \
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000557 (&fp->sb_index_values[U_SB_ETH_RX_CQ_INDEX])
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200558
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700559#define BNX2X_TX_SB_INDEX \
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000560 (&fp->sb_index_values[C_SB_ETH_TX_CQ_INDEX])
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700561
562/* end of fast path */
563
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700564/* common */
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200565
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700566struct bnx2x_common {
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200567
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700568 u32 chip_id;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200569/* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700570#define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200571
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700572#define CHIP_NUM(bp) (bp->common.chip_id >> 16)
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700573#define CHIP_NUM_57710 0x164e
574#define CHIP_NUM_57711 0x164f
575#define CHIP_NUM_57711E 0x1650
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000576#define CHIP_NUM_57712 0x1662
577#define CHIP_NUM_57712E 0x1663
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700578#define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710)
579#define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711)
580#define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E)
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000581#define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712)
582#define CHIP_IS_57712E(bp) (CHIP_NUM(bp) == CHIP_NUM_57712E)
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700583#define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \
584 CHIP_IS_57711E(bp))
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000585#define CHIP_IS_E2(bp) (CHIP_IS_57712(bp) || \
586 CHIP_IS_57712E(bp))
587#define CHIP_IS_E1x(bp) (CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
588#define IS_E1H_OFFSET (CHIP_IS_E1H(bp) || CHIP_IS_E2(bp))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200589
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700590#define CHIP_REV(bp) (bp->common.chip_id & 0x0000f000)
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700591#define CHIP_REV_Ax 0x00000000
592/* assume maximum 5 revisions */
593#define CHIP_REV_IS_SLOW(bp) (CHIP_REV(bp) > 0x00005000)
594/* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */
595#define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \
596 !(CHIP_REV(bp) & 0x00001000))
597/* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */
598#define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \
599 (CHIP_REV(bp) & 0x00001000))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200600
Eilon Greensteinad8d3942008-06-23 20:29:02 -0700601#define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
602 ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
603
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700604#define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0)
605#define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200606
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700607 int flash_size;
608#define NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */
609#define NVRAM_TIMEOUT_COUNT 30000
610#define NVRAM_PAGE_SIZE 256
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200611
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700612 u32 shmem_base;
Eilon Greenstein2691d512009-08-12 08:22:08 +0000613 u32 shmem2_base;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000614 u32 mf_cfg_base;
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000615 u32 mf2_cfg_base;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700616
617 u32 hw_config;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200618
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700619 u32 bc_ver;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000620
621 u8 int_block;
622#define INT_BLOCK_HC 0
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000623#define INT_BLOCK_IGU 1
624#define INT_BLOCK_MODE_NORMAL 0
625#define INT_BLOCK_MODE_BW_COMP 2
626#define CHIP_INT_MODE_IS_NBC(bp) \
627 (CHIP_IS_E2(bp) && \
628 !((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
629#define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
630
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000631 u8 chip_port_mode;
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000632#define CHIP_4_PORT_MODE 0x0
633#define CHIP_2_PORT_MODE 0x1
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000634#define CHIP_PORT_MODE_NONE 0x2
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000635#define CHIP_MODE(bp) (bp->common.chip_port_mode)
636#define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700637};
638
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000639/* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
640#define BNX2X_IGU_STAS_MSG_VF_CNT 64
641#define BNX2X_IGU_STAS_MSG_PF_CNT 4
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700642
643/* end of common */
644
645/* port */
646
647struct bnx2x_port {
648 u32 pmf;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200649
Yaniv Rosnera22f0782010-09-07 11:41:20 +0000650 u32 link_config[LINK_CONFIG_SIZE];
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200651
Yaniv Rosnera22f0782010-09-07 11:41:20 +0000652 u32 supported[LINK_CONFIG_SIZE];
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200653/* link settings - missing defines */
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700654#define SUPPORTED_2500baseX_Full (1 << 15)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200655
Yaniv Rosnera22f0782010-09-07 11:41:20 +0000656 u32 advertising[LINK_CONFIG_SIZE];
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700657/* link settings - missing defines */
658#define ADVERTISED_2500baseX_Full (1 << 15)
659
660 u32 phy_addr;
Yaniv Rosnerc18487e2008-06-23 20:27:52 -0700661
662 /* used to synchronize phy accesses */
663 struct mutex phy_mutex;
Eilon Greenstein46c6a672009-02-12 08:36:58 +0000664 int need_hw_lock;
Yaniv Rosnerc18487e2008-06-23 20:27:52 -0700665
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700666 u32 port_stx;
667
668 struct nig_stats old_nig_stats;
669};
670
671/* end of port */
672
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000673/* e1h Classification CAM line allocations */
674enum {
675 CAM_ETH_LINE = 0,
676 CAM_ISCSI_ETH_LINE,
677 CAM_MAX_PF_LINE = CAM_ISCSI_ETH_LINE
678};
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -0700679
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000680#define BNX2X_VF_ID_INVALID 0xFF
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700681
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000682/*
683 * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is
684 * control by the number of fast-path status blocks supported by the
685 * device (HW/FW). Each fast-path status block (FP-SB) aka non-default
686 * status block represents an independent interrupts context that can
687 * serve a regular L2 networking queue. However special L2 queues such
688 * as the FCoE queue do not require a FP-SB and other components like
689 * the CNIC may consume FP-SB reducing the number of possible L2 queues
690 *
691 * If the maximum number of FP-SB available is X then:
692 * a. If CNIC is supported it consumes 1 FP-SB thus the max number of
693 * regular L2 queues is Y=X-1
694 * b. in MF mode the actual number of L2 queues is Y= (X-1/MF_factor)
695 * c. If the FCoE L2 queue is supported the actual number of L2 queues
696 * is Y+1
697 * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for
698 * slow-path interrupts) or Y+2 if CNIC is supported (one additional
699 * FP interrupt context for the CNIC).
700 * e. The number of HW context (CID count) is always X or X+1 if FCoE
701 * L2 queue is supported. the cid for the FCoE L2 queue is always X.
702 */
703
704#define FP_SB_MAX_E1x 16 /* fast-path interrupt contexts E1x */
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000705#define FP_SB_MAX_E2 16 /* fast-path interrupt contexts E2 */
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000706
707/*
708 * cid_cnt paramter below refers to the value returned by
709 * 'bnx2x_get_l2_cid_count()' routine
710 */
711
712/*
713 * The number of FP context allocated by the driver == max number of regular
714 * L2 queues + 1 for the FCoE L2 queue
715 */
716#define L2_FP_COUNT(cid_cnt) ((cid_cnt) - CNIC_CONTEXT_USE)
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700717
718union cdu_context {
719 struct eth_context eth;
720 char pad[1024];
721};
722
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000723/* CDU host DB constants */
724#define CDU_ILT_PAGE_SZ_HW 3
725#define CDU_ILT_PAGE_SZ (4096 << CDU_ILT_PAGE_SZ_HW) /* 32K */
726#define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
727
728#ifdef BCM_CNIC
729#define CNIC_ISCSI_CID_MAX 256
730#define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX)
731#define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
732#endif
733
734#define QM_ILT_PAGE_SZ_HW 3
735#define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW) /* 32K */
736#define QM_CID_ROUND 1024
737
738#ifdef BCM_CNIC
739/* TM (timers) host DB constants */
740#define TM_ILT_PAGE_SZ_HW 2
741#define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW) /* 16K */
742/* #define TM_CONN_NUM (CNIC_STARTING_CID+CNIC_ISCSI_CXT_MAX) */
743#define TM_CONN_NUM 1024
744#define TM_ILT_SZ (8 * TM_CONN_NUM)
745#define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
746
747/* SRC (Searcher) host DB constants */
748#define SRC_ILT_PAGE_SZ_HW 3
749#define SRC_ILT_PAGE_SZ (4096 << SRC_ILT_PAGE_SZ_HW) /* 32K */
750#define SRC_HASH_BITS 10
751#define SRC_CONN_NUM (1 << SRC_HASH_BITS) /* 1024 */
752#define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)
753#define SRC_T2_SZ SRC_ILT_SZ
754#define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
755#endif
756
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -0700757#define MAX_DMAE_C 8
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700758
759/* DMA memory not used in fastpath */
760struct bnx2x_slowpath {
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700761 struct eth_stats_query fw_stats;
762 struct mac_configuration_cmd mac_config;
763 struct mac_configuration_cmd mcast_config;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000764 struct client_init_ramrod_data client_init_data;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700765
766 /* used by dmae command executer */
767 struct dmae_command dmae[MAX_DMAE_C];
768
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -0700769 u32 stats_comp;
770 union mac_stats mac_stats;
771 struct nig_stats nig_stats;
772 struct host_port_stats port_stats;
773 struct host_func_stats func_stats;
Eilon Greenstein6fe49bb2009-08-12 08:23:17 +0000774 struct host_func_stats func_stats_base;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700775
776 u32 wb_comp;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700777 u32 wb_data[4];
778};
779
780#define bnx2x_sp(bp, var) (&bp->slowpath->var)
781#define bnx2x_sp_mapping(bp, var) \
782 (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200783
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200784
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700785/* attn group wiring */
786#define MAX_DYNAMIC_ATTN_GRPS 8
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200787
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700788struct attn_route {
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000789 u32 sig[5];
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700790};
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200791
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000792struct iro {
793 u32 base;
794 u16 m1;
795 u16 m2;
796 u16 m3;
797 u16 size;
798};
799
800struct hw_context {
801 union cdu_context *vcxt;
802 dma_addr_t cxt_mapping;
803 size_t size;
804};
805
806/* forward */
807struct bnx2x_ilt;
808
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +0000809typedef enum {
810 BNX2X_RECOVERY_DONE,
811 BNX2X_RECOVERY_INIT,
812 BNX2X_RECOVERY_WAIT,
813} bnx2x_recovery_state_t;
814
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000815/**
816 * Event queue (EQ or event ring) MC hsi
817 * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2
818 */
819#define NUM_EQ_PAGES 1
820#define EQ_DESC_CNT_PAGE (BCM_PAGE_SIZE / sizeof(union event_ring_elem))
821#define EQ_DESC_MAX_PAGE (EQ_DESC_CNT_PAGE - 1)
822#define NUM_EQ_DESC (EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
823#define EQ_DESC_MASK (NUM_EQ_DESC - 1)
824#define MAX_EQ_AVAIL (EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
825
826/* depends on EQ_DESC_CNT_PAGE being a power of 2 */
827#define NEXT_EQ_IDX(x) ((((x) & EQ_DESC_MAX_PAGE) == \
828 (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
829
830/* depends on the above and on NUM_EQ_PAGES being a power of 2 */
831#define EQ_DESC(x) ((x) & EQ_DESC_MASK)
832
833#define BNX2X_EQ_INDEX \
834 (&bp->def_status_blk->sp_sb.\
835 index_values[HC_SP_INDEX_EQ_CONS])
836
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700837struct bnx2x {
838 /* Fields used in the tx and intr/napi performance paths
839 * are grouped together in the beginning of the structure
840 */
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000841 struct bnx2x_fastpath *fp;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700842 void __iomem *regview;
843 void __iomem *doorbells;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000844 u16 db_size;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200845
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700846 struct net_device *dev;
847 struct pci_dev *pdev;
848
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000849 struct iro *iro_arr;
850#define IRO (bp->iro_arr)
851
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700852 atomic_t intr_sem;
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +0000853
854 bnx2x_recovery_state_t recovery_state;
855 int is_leader;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000856 struct msix_entry *msix_table;
Eilon Greenstein8badd272009-02-12 08:36:15 +0000857#define INT_MODE_INTx 1
858#define INT_MODE_MSI 2
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700859
860 int tx_ring_size;
861
862#ifdef BCM_VLAN
863 struct vlan_group *vlgrp;
864#endif
865
866 u32 rx_csum;
Eilon Greenstein437cf2f2008-09-03 14:38:00 -0700867 u32 rx_buf_size;
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000868/* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
869#define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700870#define ETH_MIN_PACKET_SIZE 60
871#define ETH_MAX_PACKET_SIZE 1500
872#define ETH_MAX_JUMBO_PACKET_SIZE 9600
873
Eilon Greenstein0f008462009-02-12 08:36:18 +0000874 /* Max supported alignment is 256 (8 shift) */
875#define BNX2X_RX_ALIGN_SHIFT ((L1_CACHE_SHIFT < 8) ? \
876 L1_CACHE_SHIFT : 8)
877#define BNX2X_RX_ALIGN (1 << BNX2X_RX_ALIGN_SHIFT)
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000878#define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5)
Eilon Greenstein0f008462009-02-12 08:36:18 +0000879
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000880 struct host_sp_status_block *def_status_blk;
881#define DEF_SB_IGU_ID 16
882#define DEF_SB_ID HC_SP_SB_ID
883 __le16 def_idx;
Eilon Greenstein4781bfa2009-02-12 08:38:17 +0000884 __le16 def_att_idx;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700885 u32 attn_state;
886 struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS];
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700887
888 /* slow path ring */
889 struct eth_spe *spq;
890 dma_addr_t spq_mapping;
891 u16 spq_prod_idx;
892 struct eth_spe *spq_prod_bd;
893 struct eth_spe *spq_last_bd;
Eilon Greenstein4781bfa2009-02-12 08:38:17 +0000894 __le16 *dsb_sp_prod;
Dmitry Kravkov8fe23fb2010-10-06 03:27:41 +0000895 atomic_t spq_left; /* serialize spq */
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700896 /* used to synchronize spq accesses */
897 spinlock_t spq_lock;
898
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000899 /* event queue */
900 union event_ring_elem *eq_ring;
901 dma_addr_t eq_mapping;
902 u16 eq_prod;
903 u16 eq_cons;
904 __le16 *eq_cons_sb;
905
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -0700906 /* Flags for marking that there is a STAT_QUERY or
907 SET_MAC ramrod pending */
Michael Chane665bfd2009-10-10 13:46:54 +0000908 int stats_pending;
909 int set_mac_pending;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700910
Eilon Greenstein33471622008-08-13 15:59:08 -0700911 /* End of fields used in the performance code paths */
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700912
913 int panic;
Joe Perches7995c642010-02-17 15:01:52 +0000914 int msg_enable;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700915
916 u32 flags;
917#define PCIX_FLAG 1
918#define PCI_32BIT_FLAG 2
Eilon Greenstein1c063282009-02-12 08:36:43 +0000919#define ONE_PORT_FLAG 4
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700920#define NO_WOL_FLAG 8
921#define USING_DAC_FLAG 0x10
922#define USING_MSIX_FLAG 0x20
Eilon Greenstein8badd272009-02-12 08:36:15 +0000923#define USING_MSI_FLAG 0x40
Dmitry Kravkovd6214d72010-10-06 03:32:10 +0000924
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -0700925#define TPA_ENABLE_FLAG 0x80
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700926#define NO_MCP_FLAG 0x100
Dmitry Kravkovd6214d72010-10-06 03:32:10 +0000927#define DISABLE_MSI_FLAG 0x200
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700928#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
Eilon Greenstein0c6671b2009-01-14 21:26:51 -0800929#define HW_VLAN_TX_FLAG 0x400
930#define HW_VLAN_RX_FLAG 0x800
Eilon Greensteinf34d28e2009-10-15 00:18:08 -0700931#define MF_FUNC_DIS 0x1000
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700932
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000933 int pf_num; /* absolute PF number */
934 int pfid; /* per-path PF number */
Dmitry Kravkov523224a2010-10-06 03:23:26 +0000935 int base_fw_ndsb;
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000936#define BP_PATH(bp) (!CHIP_IS_E2(bp) ? \
937 0 : (bp->pf_num & 1))
938#define BP_PORT(bp) (bp->pfid & 1)
939#define BP_FUNC(bp) (bp->pfid)
940#define BP_ABS_FUNC(bp) (bp->pf_num)
941#define BP_E1HVN(bp) (bp->pfid >> 1)
942#define BP_VN(bp) (CHIP_MODE_IS_4_PORT(bp) ? \
943 0 : BP_E1HVN(bp))
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700944#define BP_L_ID(bp) (BP_E1HVN(bp) << 2)
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000945#define BP_FW_MB_IDX(bp) (BP_PORT(bp) +\
946 BP_VN(bp) * (CHIP_IS_E1x(bp) ? 2 : 1))
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700947
Michael Chan37b091b2009-10-10 13:46:55 +0000948#ifdef BCM_CNIC
949#define BCM_CNIC_CID_START 16
950#define BCM_ISCSI_ETH_CL_ID 17
951#endif
952
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700953 int pm_cap;
954 int pcie_cap;
Eilon Greenstein8d5726c2009-02-12 08:37:19 +0000955 int mrrs;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700956
Eilon Greenstein1cf167f2009-01-14 21:22:18 -0800957 struct delayed_work sp_task;
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +0000958 struct delayed_work reset_task;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700959 struct timer_list timer;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700960 int current_interval;
961
962 u16 fw_seq;
963 u16 fw_drv_pulse_wr_seq;
964 u32 func_stx;
965
966 struct link_params link_params;
967 struct link_vars link_vars;
Eilon Greenstein01cd4522009-08-12 08:23:08 +0000968 struct mdio_if_info mdio;
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700969
970 struct bnx2x_common common;
971 struct bnx2x_port port;
972
Eilon Greenstein8a1c38d2009-02-12 08:36:40 +0000973 struct cmng_struct_per_port cmng;
974 u32 vn_weight_sum;
975
Dmitry Kravkovf2e08992010-10-06 03:28:26 +0000976 u32 mf_config[E1HVN_MAX];
977 u32 mf2_config[E2_FUNC_MAX];
Dmitry Kravkovfb3bff12010-10-06 03:26:40 +0000978 u16 mf_ov;
979 u8 mf_mode;
980#define IS_MF(bp) (bp->mf_mode != 0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200981
Eliezer Tamirf1410642008-02-28 11:51:50 -0800982 u8 wol;
983
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700984 int rx_ring_size;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200985
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700986 u16 tx_quick_cons_trip_int;
987 u16 tx_quick_cons_trip;
988 u16 tx_ticks_int;
989 u16 tx_ticks;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200990
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700991 u16 rx_quick_cons_trip_int;
992 u16 rx_quick_cons_trip;
993 u16 rx_ticks_int;
994 u16 rx_ticks;
Vladislav Zolotarovcdaa7cb2010-04-19 01:13:57 +0000995/* Maximal coalescing timeout in us */
996#define BNX2X_MAX_COALESCE_TOUT (0xf0*12)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200997
Eilon Greenstein34f80b02008-06-23 20:33:01 -0700998 u32 lin_cnt;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +0200999
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001000 int state;
Eilon Greenstein356e2382009-02-12 08:38:32 +00001001#define BNX2X_STATE_CLOSED 0
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001002#define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000
1003#define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001004#define BNX2X_STATE_OPEN 0x3000
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001005#define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001006#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
1007#define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001008#define BNX2X_STATE_FUNC_STARTED 0x7000
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001009#define BNX2X_STATE_DIAG 0xe000
1010#define BNX2X_STATE_ERROR 0xf000
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001011
Eilon Greenstein555f6c72009-02-12 08:36:11 +00001012 int multi_mode;
Vladislav Zolotarov54b9dda2009-11-16 06:05:58 +00001013 int num_queues;
Dmitry Kravkov5d7cd492010-07-27 12:32:19 +00001014 int disable_tpa;
1015 int int_mode;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001016
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001017 struct tstorm_eth_mac_filter_config mac_filters;
1018#define BNX2X_ACCEPT_NONE 0x0000
1019#define BNX2X_ACCEPT_UNICAST 0x0001
1020#define BNX2X_ACCEPT_MULTICAST 0x0002
1021#define BNX2X_ACCEPT_ALL_UNICAST 0x0004
1022#define BNX2X_ACCEPT_ALL_MULTICAST 0x0008
1023#define BNX2X_ACCEPT_BROADCAST 0x0010
1024#define BNX2X_PROMISCUOUS_MODE 0x10000
1025
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001026 u32 rx_mode;
1027#define BNX2X_RX_MODE_NONE 0
1028#define BNX2X_RX_MODE_NORMAL 1
1029#define BNX2X_RX_MODE_ALLMULTI 2
1030#define BNX2X_RX_MODE_PROMISC 3
1031#define BNX2X_MAX_MULTICAST 64
1032#define BNX2X_MAX_EMUL_MULTI 16
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001033
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001034 u8 igu_dsb_id;
1035 u8 igu_base_sb;
1036 u8 igu_sb_cnt;
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001037 dma_addr_t def_status_blk_mapping;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001038
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001039 struct bnx2x_slowpath *slowpath;
1040 dma_addr_t slowpath_mapping;
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001041 struct hw_context context;
1042
1043 struct bnx2x_ilt *ilt;
1044#define BP_ILT(bp) ((bp)->ilt)
1045#define ILT_MAX_LINES 128
1046
1047 int l2_cid_count;
1048#define L2_ILT_LINES(bp) (DIV_ROUND_UP((bp)->l2_cid_count, \
1049 ILT_PAGE_CIDS))
1050#define BNX2X_DB_SIZE(bp) ((bp)->l2_cid_count * (1 << BNX2X_DB_SHIFT))
1051
1052 int qm_cid_count;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001053
Eilon Greensteina18f5122009-08-12 08:23:26 +00001054 int dropless_fc;
1055
Michael Chan37b091b2009-10-10 13:46:55 +00001056#ifdef BCM_CNIC
1057 u32 cnic_flags;
1058#define BNX2X_CNIC_FLAG_MAC_SET 1
Michael Chan37b091b2009-10-10 13:46:55 +00001059 void *t2;
1060 dma_addr_t t2_mapping;
Michael Chan37b091b2009-10-10 13:46:55 +00001061 struct cnic_ops *cnic_ops;
1062 void *cnic_data;
1063 u32 cnic_tag;
1064 struct cnic_eth_dev cnic_eth_dev;
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001065 union host_hc_status_block cnic_sb;
Michael Chan37b091b2009-10-10 13:46:55 +00001066 dma_addr_t cnic_sb_mapping;
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001067#define CNIC_SB_ID(bp) ((bp)->base_fw_ndsb + BP_L_ID(bp))
1068#define CNIC_IGU_SB_ID(bp) ((bp)->igu_base_sb)
Michael Chan37b091b2009-10-10 13:46:55 +00001069 struct eth_spe *cnic_kwq;
1070 struct eth_spe *cnic_kwq_prod;
1071 struct eth_spe *cnic_kwq_cons;
1072 struct eth_spe *cnic_kwq_last;
1073 u16 cnic_kwq_pending;
1074 u16 cnic_spq_pending;
1075 struct mutex cnic_mutex;
1076 u8 iscsi_mac[6];
1077#endif
1078
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001079 int dmae_ready;
1080 /* used to synchronize dmae accesses */
1081 struct mutex dmae_mutex;
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001082
Eilon Greensteinc4ff7cb2009-10-15 00:18:27 -07001083 /* used to protect the FW mail box */
1084 struct mutex fw_mb_mutex;
1085
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001086 /* used to synchronize stats collecting */
1087 int stats_state;
Vladislav Zolotarova13773a2010-07-21 05:59:01 +00001088
1089 /* used for synchronization of concurrent threads statistics handling */
1090 spinlock_t stats_lock;
1091
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001092 /* used by dmae command loader */
1093 struct dmae_command stats_dmae;
1094 int executer_idx;
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001095
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001096 u16 stats_counter;
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001097 struct bnx2x_eth_stats eth_stats;
1098
1099 struct z_stream_s *strm;
1100 void *gunzip_buf;
1101 dma_addr_t gunzip_mapping;
1102 int gunzip_outlen;
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001103#define FW_BUF_SIZE 0x8000
Eilon Greenstein573f2032009-08-12 08:24:14 +00001104#define GUNZIP_BUF(bp) (bp->gunzip_buf)
1105#define GUNZIP_PHYS(bp) (bp->gunzip_mapping)
1106#define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001107
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001108 struct raw_op *init_ops;
Vladislav Zolotarov94a78b72009-04-27 03:27:43 -07001109 /* Init blocks offsets inside init_ops */
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001110 u16 *init_ops_offsets;
Vladislav Zolotarov94a78b72009-04-27 03:27:43 -07001111 /* Data blob - has 32 bit granularity */
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001112 u32 *init_data;
Vladislav Zolotarov94a78b72009-04-27 03:27:43 -07001113 /* Zipped PRAM blobs - raw data */
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001114 const u8 *tsem_int_table_data;
1115 const u8 *tsem_pram_data;
1116 const u8 *usem_int_table_data;
1117 const u8 *usem_pram_data;
1118 const u8 *xsem_int_table_data;
1119 const u8 *xsem_pram_data;
1120 const u8 *csem_int_table_data;
1121 const u8 *csem_pram_data;
Eilon Greenstein573f2032009-08-12 08:24:14 +00001122#define INIT_OPS(bp) (bp->init_ops)
1123#define INIT_OPS_OFFSETS(bp) (bp->init_ops_offsets)
1124#define INIT_DATA(bp) (bp->init_data)
1125#define INIT_TSEM_INT_TABLE_DATA(bp) (bp->tsem_int_table_data)
1126#define INIT_TSEM_PRAM_DATA(bp) (bp->tsem_pram_data)
1127#define INIT_USEM_INT_TABLE_DATA(bp) (bp->usem_int_table_data)
1128#define INIT_USEM_PRAM_DATA(bp) (bp->usem_pram_data)
1129#define INIT_XSEM_INT_TABLE_DATA(bp) (bp->xsem_int_table_data)
1130#define INIT_XSEM_PRAM_DATA(bp) (bp->xsem_pram_data)
1131#define INIT_CSEM_INT_TABLE_DATA(bp) (bp->csem_int_table_data)
1132#define INIT_CSEM_PRAM_DATA(bp) (bp->csem_pram_data)
1133
Vladislav Zolotarov34f24c72010-04-19 01:13:23 +00001134 char fw_ver[32];
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001135 const struct firmware *firmware;
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001136};
1137
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001138/**
1139 * Init queue/func interface
1140 */
1141/* queue init flags */
1142#define QUEUE_FLG_TPA 0x0001
1143#define QUEUE_FLG_CACHE_ALIGN 0x0002
1144#define QUEUE_FLG_STATS 0x0004
1145#define QUEUE_FLG_OV 0x0008
1146#define QUEUE_FLG_VLAN 0x0010
1147#define QUEUE_FLG_COS 0x0020
1148#define QUEUE_FLG_HC 0x0040
1149#define QUEUE_FLG_DHC 0x0080
1150#define QUEUE_FLG_OOO 0x0100
1151
1152#define QUEUE_DROP_IP_CS_ERR TSTORM_ETH_CLIENT_CONFIG_DROP_IP_CS_ERR
1153#define QUEUE_DROP_TCP_CS_ERR TSTORM_ETH_CLIENT_CONFIG_DROP_TCP_CS_ERR
1154#define QUEUE_DROP_TTL0 TSTORM_ETH_CLIENT_CONFIG_DROP_TTL0
1155#define QUEUE_DROP_UDP_CS_ERR TSTORM_ETH_CLIENT_CONFIG_DROP_UDP_CS_ERR
1156
1157
1158
1159/* rss capabilities */
1160#define RSS_IPV4_CAP 0x0001
1161#define RSS_IPV4_TCP_CAP 0x0002
1162#define RSS_IPV6_CAP 0x0004
1163#define RSS_IPV6_TCP_CAP 0x0008
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001164
Vladislav Zolotarov54b9dda2009-11-16 06:05:58 +00001165#define BNX2X_NUM_QUEUES(bp) (bp->num_queues)
1166#define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1)
Eilon Greenstein3196a882008-08-13 15:58:49 -07001167
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001168#define BNX2X_MAX_QUEUES(bp) (bp->igu_sb_cnt - CNIC_CONTEXT_USE)
1169#define is_eth_multi(bp) (BNX2X_NUM_ETH_QUEUES(bp) > 1)
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001170
1171#define RSS_IPV4_CAP_MASK \
1172 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
1173
1174#define RSS_IPV4_TCP_CAP_MASK \
1175 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
1176
1177#define RSS_IPV6_CAP_MASK \
1178 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
1179
1180#define RSS_IPV6_TCP_CAP_MASK \
1181 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
1182
1183/* func init flags */
1184#define FUNC_FLG_RSS 0x0001
1185#define FUNC_FLG_STATS 0x0002
1186/* removed FUNC_FLG_UNMATCHED 0x0004 */
1187#define FUNC_FLG_TPA 0x0008
1188#define FUNC_FLG_SPQ 0x0010
1189#define FUNC_FLG_LEADING 0x0020 /* PF only */
1190
1191#define FUNC_CONFIG(flgs) ((flgs) & (FUNC_FLG_RSS | FUNC_FLG_TPA | \
1192 FUNC_FLG_LEADING))
1193
1194struct rxq_pause_params {
1195 u16 bd_th_lo;
1196 u16 bd_th_hi;
1197 u16 rcq_th_lo;
1198 u16 rcq_th_hi;
1199 u16 sge_th_lo; /* valid iff QUEUE_FLG_TPA */
1200 u16 sge_th_hi; /* valid iff QUEUE_FLG_TPA */
1201 u16 pri_map;
1202};
1203
1204struct bnx2x_rxq_init_params {
1205 /* cxt*/
1206 struct eth_context *cxt;
1207
1208 /* dma */
1209 dma_addr_t dscr_map;
1210 dma_addr_t sge_map;
1211 dma_addr_t rcq_map;
1212 dma_addr_t rcq_np_map;
1213
1214 u16 flags;
1215 u16 drop_flags;
1216 u16 mtu;
1217 u16 buf_sz;
1218 u16 fw_sb_id;
1219 u16 cl_id;
1220 u16 spcl_id;
1221 u16 cl_qzone_id;
1222
1223 /* valid iff QUEUE_FLG_STATS */
1224 u16 stat_id;
1225
1226 /* valid iff QUEUE_FLG_TPA */
1227 u16 tpa_agg_sz;
1228 u16 sge_buf_sz;
1229 u16 max_sges_pkt;
1230
1231 /* valid iff QUEUE_FLG_CACHE_ALIGN */
1232 u8 cache_line_log;
1233
1234 u8 sb_cq_index;
1235 u32 cid;
1236
1237 /* desired interrupts per sec. valid iff QUEUE_FLG_HC */
1238 u32 hc_rate;
1239};
1240
1241struct bnx2x_txq_init_params {
1242 /* cxt*/
1243 struct eth_context *cxt;
1244
1245 /* dma */
1246 dma_addr_t dscr_map;
1247
1248 u16 flags;
1249 u16 fw_sb_id;
1250 u8 sb_cq_index;
1251 u8 cos; /* valid iff QUEUE_FLG_COS */
1252 u16 stat_id; /* valid iff QUEUE_FLG_STATS */
1253 u16 traffic_type;
1254 u32 cid;
1255 u16 hc_rate; /* desired interrupts per sec.*/
1256 /* valid iff QUEUE_FLG_HC */
1257
1258};
1259
1260struct bnx2x_client_ramrod_params {
1261 int *pstate;
1262 int state;
1263 u16 index;
1264 u16 cl_id;
1265 u32 cid;
1266 u8 poll;
1267#define CLIENT_IS_LEADING_RSS 0x02
1268 u8 flags;
1269};
1270
1271struct bnx2x_client_init_params {
1272 struct rxq_pause_params pause;
1273 struct bnx2x_rxq_init_params rxq_params;
1274 struct bnx2x_txq_init_params txq_params;
1275 struct bnx2x_client_ramrod_params ramrod_params;
1276};
1277
1278struct bnx2x_rss_params {
1279 int mode;
1280 u16 cap;
1281 u16 result_mask;
1282};
1283
1284struct bnx2x_func_init_params {
1285
1286 /* rss */
1287 struct bnx2x_rss_params *rss; /* valid iff FUNC_FLG_RSS */
1288
1289 /* dma */
1290 dma_addr_t fw_stat_map; /* valid iff FUNC_FLG_STATS */
1291 dma_addr_t spq_map; /* valid iff FUNC_FLG_SPQ */
1292
1293 u16 func_flgs;
1294 u16 func_id; /* abs fid */
1295 u16 pf_id;
1296 u16 spq_prod; /* valid iff FUNC_FLG_SPQ */
1297};
1298
Eilon Greenstein555f6c72009-02-12 08:36:11 +00001299#define for_each_queue(bp, var) \
1300 for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++)
Eilon Greenstein3196a882008-08-13 15:58:49 -07001301#define for_each_nondefault_queue(bp, var) \
Vladislav Zolotarov54b9dda2009-11-16 06:05:58 +00001302 for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++)
Eilon Greenstein3196a882008-08-13 15:58:49 -07001303
1304
Yaniv Rosnerc18487e2008-06-23 20:27:52 -07001305void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
1306void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
1307 u32 len32);
Eilon Greenstein4acac6a2009-02-12 08:36:52 +00001308int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
Eilon Greenstein17de50b2008-08-13 15:56:59 -07001309int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
Eilon Greenstein4acac6a2009-02-12 08:36:52 +00001310int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
Yaniv Rosnera22f0782010-09-07 11:41:20 +00001311u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param);
Eilon Greenstein573f2032009-08-12 08:24:14 +00001312void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
1313void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
1314 u32 addr, u32 len);
Dmitry Kravkovde0c62d2010-07-27 12:35:24 +00001315void bnx2x_calc_fc_adv(struct bnx2x *bp);
1316int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
1317 u32 data_hi, u32 data_lo, int common);
1318void bnx2x_update_coalesce(struct bnx2x *bp);
Yaniv Rosnera22f0782010-09-07 11:41:20 +00001319int bnx2x_get_link_cfg_idx(struct bnx2x *bp);
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001320static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
1321 int wait)
1322{
1323 u32 val;
1324
1325 do {
1326 val = REG_RD(bp, reg);
1327 if (val == expected)
1328 break;
1329 ms -= wait;
1330 msleep(wait);
1331
1332 } while (ms > 0);
1333
1334 return val;
1335}
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001336#define BNX2X_ILT_ZALLOC(x, y, size) \
1337 do { \
1338 x = pci_alloc_consistent(bp->pdev, size, y); \
1339 if (x) \
1340 memset(x, 0, size); \
1341 } while (0)
1342
1343#define BNX2X_ILT_FREE(x, y, size) \
1344 do { \
1345 if (x) { \
1346 pci_free_consistent(bp->pdev, size, x, y); \
1347 x = NULL; \
1348 y = 0; \
1349 } \
1350 } while (0)
1351
1352#define ILOG2(x) (ilog2((x)))
1353
1354#define ILT_NUM_PAGE_ENTRIES (3072)
1355/* In 57710/11 we use whole table since we have 8 func
1356 */
1357#define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8)
1358
1359#define FUNC_ILT_BASE(func) (func * ILT_PER_FUNC)
1360/*
1361 * the phys address is shifted right 12 bits and has an added
1362 * 1=valid bit added to the 53rd bit
1363 * then since this is a wide register(TM)
1364 * we split it into two 32 bit writes
1365 */
1366#define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
1367#define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001368
1369
1370/* load/unload mode */
1371#define LOAD_NORMAL 0
1372#define LOAD_OPEN 1
1373#define LOAD_DIAG 2
1374#define UNLOAD_NORMAL 0
1375#define UNLOAD_CLOSE 1
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +00001376#define UNLOAD_RECOVERY 2
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001377
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001378
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001379/* DMAE command defines */
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001380#define DMAE_TIMEOUT -1
1381#define DMAE_PCI_ERROR -2 /* E2 and onward */
1382#define DMAE_NOT_RDY -3
1383#define DMAE_PCI_ERR_FLAG 0x80000000
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001384
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001385#define DMAE_SRC_PCI 0
1386#define DMAE_SRC_GRC 1
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001387
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001388#define DMAE_DST_NONE 0
1389#define DMAE_DST_PCI 1
1390#define DMAE_DST_GRC 2
1391
1392#define DMAE_COMP_PCI 0
1393#define DMAE_COMP_GRC 1
1394
1395/* E2 and onward - PCI error handling in the completion */
1396
1397#define DMAE_COMP_REGULAR 0
1398#define DMAE_COM_SET_ERR 1
1399
1400#define DMAE_CMD_SRC_PCI (DMAE_SRC_PCI << \
1401 DMAE_COMMAND_SRC_SHIFT)
1402#define DMAE_CMD_SRC_GRC (DMAE_SRC_GRC << \
1403 DMAE_COMMAND_SRC_SHIFT)
1404
1405#define DMAE_CMD_DST_PCI (DMAE_DST_PCI << \
1406 DMAE_COMMAND_DST_SHIFT)
1407#define DMAE_CMD_DST_GRC (DMAE_DST_GRC << \
1408 DMAE_COMMAND_DST_SHIFT)
1409
1410#define DMAE_CMD_C_DST_PCI (DMAE_COMP_PCI << \
1411 DMAE_COMMAND_C_DST_SHIFT)
1412#define DMAE_CMD_C_DST_GRC (DMAE_COMP_GRC << \
1413 DMAE_COMMAND_C_DST_SHIFT)
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001414
1415#define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE
1416
1417#define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT)
1418#define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT)
1419#define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT)
1420#define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT)
1421
1422#define DMAE_CMD_PORT_0 0
1423#define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT
1424
1425#define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET
1426#define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET
1427#define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT
1428
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001429#define DMAE_SRC_PF 0
1430#define DMAE_SRC_VF 1
1431
1432#define DMAE_DST_PF 0
1433#define DMAE_DST_VF 1
1434
1435#define DMAE_C_SRC 0
1436#define DMAE_C_DST 1
1437
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001438#define DMAE_LEN32_RD_MAX 0x80
Vladislav Zolotarov02e3c6c2010-04-19 01:13:33 +00001439#define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000)
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001440
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001441#define DMAE_COMP_VAL 0x60d0d0ae /* E2 and on - upper bit
1442 indicates eror */
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001443
1444#define MAX_DMAE_C_PER_PORT 8
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001445#define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001446 BP_E1HVN(bp))
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001447#define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
Eilon Greensteinad8d3942008-06-23 20:29:02 -07001448 E1HVN_MAX)
1449
1450
Eliezer Tamir25047952008-02-28 11:50:16 -08001451/* PCIE link and speed */
1452#define PCICFG_LINK_WIDTH 0x1f00000
1453#define PCICFG_LINK_WIDTH_SHIFT 20
1454#define PCICFG_LINK_SPEED 0xf0000
1455#define PCICFG_LINK_SPEED_SHIFT 16
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001456
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001457
Eilon Greensteind3d4f492009-02-12 08:36:27 +00001458#define BNX2X_NUM_TESTS 7
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001459
Eilon Greensteinb5bf9062009-02-12 08:38:08 +00001460#define BNX2X_PHY_LOOPBACK 0
1461#define BNX2X_MAC_LOOPBACK 1
1462#define BNX2X_PHY_LOOPBACK_FAILED 1
1463#define BNX2X_MAC_LOOPBACK_FAILED 2
Yitchak Gertnerbb2a0f72008-06-23 20:33:36 -07001464#define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \
1465 BNX2X_PHY_LOOPBACK_FAILED)
Eliezer Tamir96fc1782008-02-28 11:57:55 -08001466
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -07001467
1468#define STROM_ASSERT_ARRAY_SIZE 50
1469
Eliezer Tamir96fc1782008-02-28 11:57:55 -08001470
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001471/* must be used on a CID before placing it on a HW ring */
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001472#define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \
1473 (BP_E1HVN(bp) << 17) | (x))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001474
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -07001475#define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe))
1476#define MAX_SP_DESC_CNT (SP_DESC_CNT - 1)
1477
1478
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001479#define BNX2X_BTR 4
Vladislav Zolotarov7a9b2552008-06-23 20:34:36 -07001480#define MAX_SPQ_PENDING 8
1481
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001482
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001483/* CMNG constants
1484 derived from lab experiments, and not from system spec calculations !!! */
1485#define DEF_MIN_RATE 100
1486/* resolution of the rate shaping timer - 100 usec */
1487#define RS_PERIODIC_TIMEOUT_USEC 100
1488/* resolution of fairness algorithm in usecs -
Eilon Greenstein33471622008-08-13 15:59:08 -07001489 coefficient for calculating the actual t fair */
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001490#define T_FAIR_COEF 10000000
1491/* number of bytes in single QM arbitration cycle -
Eilon Greenstein33471622008-08-13 15:59:08 -07001492 coefficient for calculating the fairness timer */
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001493#define QM_ARB_BYTES 40000
1494#define FAIR_MEM 2
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001495
1496
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001497#define ATTN_NIG_FOR_FUNC (1L << 8)
1498#define ATTN_SW_TIMER_4_FUNC (1L << 9)
1499#define GPIO_2_FUNC (1L << 10)
1500#define GPIO_3_FUNC (1L << 11)
1501#define GPIO_4_FUNC (1L << 12)
1502#define ATTN_GENERAL_ATTN_1 (1L << 13)
1503#define ATTN_GENERAL_ATTN_2 (1L << 14)
1504#define ATTN_GENERAL_ATTN_3 (1L << 15)
1505#define ATTN_GENERAL_ATTN_4 (1L << 13)
1506#define ATTN_GENERAL_ATTN_5 (1L << 14)
1507#define ATTN_GENERAL_ATTN_6 (1L << 15)
1508
1509#define ATTN_HARD_WIRED_MASK 0xff00
1510#define ATTENTION_ID 4
1511
1512
1513/* stuff added to make the code fit 80Col */
1514
1515#define BNX2X_PMF_LINK_ASSERT \
1516 GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
1517
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001518#define BNX2X_MC_ASSERT_BITS \
1519 (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
1520 GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
1521 GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
1522 GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
1523
1524#define BNX2X_MCP_ASSERT \
1525 GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
1526
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001527#define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
1528#define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
1529 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
1530 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
1531 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
1532 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
1533 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
1534
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001535#define HW_INTERRUT_ASSERT_SET_0 \
1536 (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
1537 AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
1538 AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
1539 AEU_INPUTS_ATTN_BITS_PBF_HW_INTERRUPT)
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001540#define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001541 AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
1542 AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
1543 AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
1544 AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR)
1545#define HW_INTERRUT_ASSERT_SET_1 \
1546 (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
1547 AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
1548 AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
1549 AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
1550 AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
1551 AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
1552 AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
1553 AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
1554 AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
1555 AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
1556 AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001557#define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR |\
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001558 AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
1559 AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
1560 AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
Eilon Greensteinab6ad5a2009-08-12 08:24:29 +00001561 AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
1562 AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001563 AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
1564 AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
1565 AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
1566 AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
1567 AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR)
1568#define HW_INTERRUT_ASSERT_SET_2 \
1569 (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
1570 AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
1571 AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
1572 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
1573 AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001574#define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001575 AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
1576 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
1577 AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
1578 AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
1579 AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
1580 AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
1581
Vladislav Zolotarov72fd0712010-04-19 01:13:12 +00001582#define HW_PRTY_ASSERT_SET_3 (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
1583 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
1584 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \
1585 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001586
Tom Herbertc68ed252010-04-23 00:10:52 -07001587#define RSS_FLAGS(bp) \
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001588 (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \
1589 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \
1590 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \
1591 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \
Eilon Greenstein555f6c72009-02-12 08:36:11 +00001592 (bp->multi_mode << \
1593 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT))
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001594#define MULTI_MASK 0x7f
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001595
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001596#define BNX2X_SP_DSB_INDEX \
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001597 (&bp->def_status_blk->sp_sb.\
1598 index_values[HC_SP_INDEX_ETH_DEF_CONS])
1599#define SET_FLAG(value, mask, flag) \
1600 do {\
1601 (value) &= ~(mask);\
1602 (value) |= ((flag) << (mask##_SHIFT));\
1603 } while (0)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001604
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001605#define GET_FLAG(value, mask) \
1606 (((value) &= (mask)) >> (mask##_SHIFT))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001607
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001608#define GET_FIELD(value, fname) \
1609 (((value) & (fname##_MASK)) >> (fname##_SHIFT))
1610
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001611#define CAM_IS_INVALID(x) \
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001612 (GET_FLAG(x.flags, \
1613 MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
1614 (T_ETH_MAC_COMMAND_INVALIDATE))
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001615
1616#define CAM_INVALIDATE(x) \
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001617 (x.target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE)
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001618
1619
Eilon Greenstein34f80b02008-06-23 20:33:01 -07001620/* Number of u32 elements in MC hash array */
1621#define MC_HASH_SIZE 8
1622#define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \
1623 TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
1624
1625
1626#ifndef PXP2_REG_PXP2_INT_STS
1627#define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0
1628#endif
1629
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001630#ifndef ETH_MAX_RX_CLIENTS_E2
1631#define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
1632#endif
Vladislav Zolotarov34f24c72010-04-19 01:13:23 +00001633#define BNX2X_VPD_LEN 128
1634#define VENDOR_ID_LEN 4
1635
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001636/* Congestion management fairness mode */
1637#define CMNG_FNS_NONE 0
1638#define CMNG_FNS_MINMAX 1
1639
1640#define HC_SEG_ACCESS_DEF 0 /*Driver decision 0-3*/
1641#define HC_SEG_ACCESS_ATTN 4
1642#define HC_SEG_ACCESS_NORM 0 /*Driver decision 0-1*/
1643
Dmitry Kravkovb0efbb92010-07-27 12:33:43 +00001644#ifdef BNX2X_MAIN
1645#define BNX2X_EXTERN
1646#else
1647#define BNX2X_EXTERN extern
1648#endif
1649
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001650BNX2X_EXTERN int load_count[2][3]; /* per path: 0-common, 1-port0, 2-port1 */
Dmitry Kravkovb0efbb92010-07-27 12:33:43 +00001651
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001652/* MISC_REG_RESET_REG - this is here for the hsi to work don't touch */
1653
Dmitry Kravkovde0c62d2010-07-27 12:35:24 +00001654extern void bnx2x_set_ethtool_ops(struct net_device *netdev);
1655
Dmitry Kravkov6c719d02010-07-27 12:36:15 +00001656void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
Dmitry Kravkovf2e08992010-10-06 03:28:26 +00001657u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
1658u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
1659u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
1660 bool with_comp, u8 comp_type);
1661
Dmitry Kravkov6c719d02010-07-27 12:36:15 +00001662
Dmitry Kravkov523224a2010-10-06 03:23:26 +00001663#define WAIT_RAMROD_POLL 0x01
1664#define WAIT_RAMROD_COMMON 0x02
1665
1666int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
1667 int *state_p, int flags);
Eliezer Tamira2fbb9e2007-11-15 20:09:02 +02001668#endif /* bnx2x.h */