Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1 | /* bnx2x.h: Broadcom Everest network driver. |
| 2 | * |
Eliezer Tamir | 49d6677 | 2008-02-28 11:53:13 -0800 | [diff] [blame] | 3 | * Copyright (c) 2007-2008 Broadcom Corporation |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 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 | * |
Eilon Greenstein | 24e3fce | 2008-06-12 14:30:28 -0700 | [diff] [blame] | 9 | * Maintained by: Eilon Greenstein <eilong@broadcom.com> |
| 10 | * Written by: Eliezer Tamir |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 11 | * Based on code from Michael Chan's bnx2 driver |
| 12 | */ |
| 13 | |
| 14 | #ifndef BNX2X_H |
| 15 | #define BNX2X_H |
| 16 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 17 | /* 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 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 23 | /* error/debug prints */ |
| 24 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 25 | #define DRV_MODULE_NAME "bnx2x" |
| 26 | #define PFX DRV_MODULE_NAME ": " |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 27 | |
| 28 | /* for messages that are currently off */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 29 | #define BNX2X_MSG_OFF 0 |
| 30 | #define BNX2X_MSG_MCP 0x010000 /* was: NETIF_MSG_HW */ |
| 31 | #define BNX2X_MSG_STATS 0x020000 /* was: NETIF_MSG_TIMER */ |
| 32 | #define BNX2X_MSG_NVM 0x040000 /* was: NETIF_MSG_HW */ |
| 33 | #define BNX2X_MSG_DMAE 0x080000 /* was: NETIF_MSG_HW */ |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 34 | #define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */ |
| 35 | #define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 36 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 37 | #define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 38 | |
| 39 | /* regular debug print */ |
| 40 | #define DP(__mask, __fmt, __args...) do { \ |
| 41 | if (bp->msglevel & (__mask)) \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 42 | printk(DP_LEVEL "[%s:%d(%s)]" __fmt, __func__, __LINE__, \ |
| 43 | bp->dev?(bp->dev->name):"?", ##__args); \ |
| 44 | } while (0) |
| 45 | |
| 46 | /* errors debug print */ |
| 47 | #define BNX2X_DBG_ERR(__fmt, __args...) do { \ |
| 48 | if (bp->msglevel & NETIF_MSG_PROBE) \ |
| 49 | printk(KERN_ERR "[%s:%d(%s)]" __fmt, __func__, __LINE__, \ |
| 50 | bp->dev?(bp->dev->name):"?", ##__args); \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 51 | } while (0) |
| 52 | |
| 53 | /* for errors (never masked) */ |
| 54 | #define BNX2X_ERR(__fmt, __args...) do { \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 55 | printk(KERN_ERR "[%s:%d(%s)]" __fmt, __func__, __LINE__, \ |
| 56 | bp->dev?(bp->dev->name):"?", ##__args); \ |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 57 | } while (0) |
| 58 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 59 | /* before we have a dev->name use dev_info() */ |
| 60 | #define BNX2X_DEV_INFO(__fmt, __args...) do { \ |
| 61 | if (bp->msglevel & NETIF_MSG_PROBE) \ |
| 62 | dev_info(&bp->pdev->dev, __fmt, ##__args); \ |
| 63 | } while (0) |
| 64 | |
| 65 | |
| 66 | #ifdef BNX2X_STOP_ON_ERROR |
| 67 | #define bnx2x_panic() do { \ |
| 68 | bp->panic = 1; \ |
| 69 | BNX2X_ERR("driver assert\n"); \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 70 | bnx2x_int_disable(bp); \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 71 | bnx2x_panic_dump(bp); \ |
| 72 | } while (0) |
| 73 | #else |
| 74 | #define bnx2x_panic() do { \ |
| 75 | BNX2X_ERR("driver assert\n"); \ |
| 76 | bnx2x_panic_dump(bp); \ |
| 77 | } while (0) |
| 78 | #endif |
| 79 | |
| 80 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 81 | #ifdef NETIF_F_HW_VLAN_TX |
| 82 | #define BCM_VLAN 1 |
| 83 | #endif |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 84 | |
| 85 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 86 | #define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff) |
| 87 | #define U64_HI(x) (u32)(((u64)(x)) >> 32) |
| 88 | #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 89 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 90 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 91 | #define REG_ADDR(bp, offset) (bp->regview + offset) |
| 92 | |
| 93 | #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset)) |
| 94 | #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset)) |
| 95 | #define REG_RD64(bp, offset) readq(REG_ADDR(bp, offset)) |
| 96 | |
| 97 | #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 98 | #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset)) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 99 | #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset)) |
| 100 | #define REG_WR32(bp, offset, val) REG_WR(bp, offset, val) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 101 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 102 | #define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset) |
| 103 | #define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 104 | |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 105 | #define REG_RD_DMAE(bp, offset, valp, len32) \ |
| 106 | do { \ |
| 107 | bnx2x_read_dmae(bp, offset, len32);\ |
| 108 | memcpy(valp, bnx2x_sp(bp, wb_data[0]), len32 * 4); \ |
| 109 | } while (0) |
| 110 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 111 | #define REG_WR_DMAE(bp, offset, valp, len32) \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 112 | do { \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 113 | memcpy(bnx2x_sp(bp, wb_data[0]), valp, len32 * 4); \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 114 | bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \ |
| 115 | offset, len32); \ |
| 116 | } while (0) |
| 117 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 118 | #define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \ |
| 119 | offsetof(struct shmem_region, field)) |
| 120 | #define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field)) |
| 121 | #define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 122 | |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame^] | 123 | #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 124 | #define NIG_WR(reg, val) REG_WR(bp, reg, val) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 125 | #define EMAC_WR(reg, val) REG_WR(bp, emac_base + reg, val) |
| 126 | #define BMAC_WR(reg, val) REG_WR(bp, GRCBASE_NIG + bmac_addr + reg, val) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 127 | |
| 128 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 129 | #define for_each_queue(bp, var) for (var = 0; var < bp->num_queues; var++) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 130 | |
| 131 | #define for_each_nondefault_queue(bp, var) \ |
| 132 | for (var = 1; var < bp->num_queues; var++) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 133 | #define is_multi(bp) (bp->num_queues > 1) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 134 | |
| 135 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 136 | /* fast path */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 137 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 138 | struct sw_rx_bd { |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 139 | struct sk_buff *skb; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 140 | DECLARE_PCI_UNMAP_ADDR(mapping) |
| 141 | }; |
| 142 | |
| 143 | struct sw_tx_bd { |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 144 | struct sk_buff *skb; |
| 145 | u16 first_bd; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 146 | }; |
| 147 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 148 | struct sw_rx_page { |
| 149 | struct page *page; |
| 150 | DECLARE_PCI_UNMAP_ADDR(mapping) |
| 151 | }; |
| 152 | |
| 153 | |
| 154 | /* MC hsi */ |
| 155 | #define BCM_PAGE_SHIFT 12 |
| 156 | #define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT) |
| 157 | #define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1)) |
| 158 | #define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK) |
| 159 | |
| 160 | #define PAGES_PER_SGE_SHIFT 0 |
| 161 | #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) |
| 162 | |
| 163 | /* SGE ring related macros */ |
| 164 | #define NUM_RX_SGE_PAGES 2 |
| 165 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) |
| 166 | #define MAX_RX_SGE_CNT (RX_SGE_CNT - 2) |
| 167 | /* RX_SGE_CNT is promissed to be a power of 2 */ |
| 168 | #define RX_SGE_MASK (RX_SGE_CNT - 1) |
| 169 | #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES) |
| 170 | #define MAX_RX_SGE (NUM_RX_SGE - 1) |
| 171 | #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \ |
| 172 | (MAX_RX_SGE_CNT - 1)) ? (x) + 3 : (x) + 1) |
| 173 | #define RX_SGE(x) ((x) & MAX_RX_SGE) |
| 174 | |
| 175 | /* SGE producer mask related macros */ |
| 176 | /* Number of bits in one sge_mask array element */ |
| 177 | #define RX_SGE_MASK_ELEM_SZ 64 |
| 178 | #define RX_SGE_MASK_ELEM_SHIFT 6 |
| 179 | #define RX_SGE_MASK_ELEM_MASK ((u64)RX_SGE_MASK_ELEM_SZ - 1) |
| 180 | |
| 181 | /* Creates a bitmask of all ones in less significant bits. |
| 182 | idx - index of the most significant bit in the created mask */ |
| 183 | #define RX_SGE_ONES_MASK(idx) \ |
| 184 | (((u64)0x1 << (((idx) & RX_SGE_MASK_ELEM_MASK) + 1)) - 1) |
| 185 | #define RX_SGE_MASK_ELEM_ONE_MASK ((u64)(~0)) |
| 186 | |
| 187 | /* Number of u64 elements in SGE mask array */ |
| 188 | #define RX_SGE_MASK_LEN ((NUM_RX_SGE_PAGES * RX_SGE_CNT) / \ |
| 189 | RX_SGE_MASK_ELEM_SZ) |
| 190 | #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1) |
| 191 | #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK) |
| 192 | |
| 193 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 194 | struct bnx2x_fastpath { |
| 195 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 196 | struct napi_struct napi; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 197 | |
| 198 | struct host_status_block *status_blk; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 199 | dma_addr_t status_blk_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 200 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 201 | struct eth_tx_db_data *hw_tx_prods; |
| 202 | dma_addr_t tx_prods_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 203 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 204 | struct sw_tx_bd *tx_buf_ring; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 205 | |
| 206 | struct eth_tx_bd *tx_desc_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 207 | dma_addr_t tx_desc_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 208 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 209 | struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */ |
| 210 | struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 211 | |
| 212 | struct eth_rx_bd *rx_desc_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 213 | dma_addr_t rx_desc_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 214 | |
| 215 | union eth_rx_cqe *rx_comp_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 216 | dma_addr_t rx_comp_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 217 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 218 | /* SGE ring */ |
| 219 | struct eth_rx_sge *rx_sge_ring; |
| 220 | dma_addr_t rx_sge_mapping; |
| 221 | |
| 222 | u64 sge_mask[RX_SGE_MASK_LEN]; |
| 223 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 224 | int state; |
| 225 | #define BNX2X_FP_STATE_CLOSED 0 |
| 226 | #define BNX2X_FP_STATE_IRQ 0x80000 |
| 227 | #define BNX2X_FP_STATE_OPENING 0x90000 |
| 228 | #define BNX2X_FP_STATE_OPEN 0xa0000 |
| 229 | #define BNX2X_FP_STATE_HALTING 0xb0000 |
| 230 | #define BNX2X_FP_STATE_HALTED 0xc0000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 231 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 232 | u8 index; /* number in fp array */ |
| 233 | u8 cl_id; /* eth client id */ |
| 234 | u8 sb_id; /* status block number in HW */ |
| 235 | #define FP_IDX(fp) (fp->index) |
| 236 | #define FP_CL_ID(fp) (fp->cl_id) |
| 237 | #define BP_CL_ID(bp) (bp->fp[0].cl_id) |
| 238 | #define FP_SB_ID(fp) (fp->sb_id) |
| 239 | #define CNIC_SB_ID 0 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 240 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 241 | u16 tx_pkt_prod; |
| 242 | u16 tx_pkt_cons; |
| 243 | u16 tx_bd_prod; |
| 244 | u16 tx_bd_cons; |
| 245 | u16 *tx_cons_sb; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 246 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 247 | u16 fp_c_idx; |
| 248 | u16 fp_u_idx; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 249 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 250 | u16 rx_bd_prod; |
| 251 | u16 rx_bd_cons; |
| 252 | u16 rx_comp_prod; |
| 253 | u16 rx_comp_cons; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 254 | u16 rx_sge_prod; |
| 255 | /* The last maximal completed SGE */ |
| 256 | u16 last_max_sge; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 257 | u16 *rx_cons_sb; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 258 | u16 *rx_bd_cons_sb; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 259 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 260 | unsigned long tx_pkt, |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 261 | rx_pkt, |
Yitchak Gertner | 66e855f | 2008-08-13 15:49:05 -0700 | [diff] [blame] | 262 | rx_calls; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 263 | /* TPA related */ |
| 264 | struct sw_rx_bd tpa_pool[ETH_MAX_AGGREGATION_QUEUES_E1H]; |
| 265 | u8 tpa_state[ETH_MAX_AGGREGATION_QUEUES_E1H]; |
| 266 | #define BNX2X_TPA_START 1 |
| 267 | #define BNX2X_TPA_STOP 2 |
| 268 | u8 disable_tpa; |
| 269 | #ifdef BNX2X_STOP_ON_ERROR |
| 270 | u64 tpa_queue_used; |
| 271 | #endif |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 272 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 273 | struct bnx2x *bp; /* parent */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 274 | }; |
| 275 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 276 | #define bnx2x_fp(bp, nr, var) (bp->fp[nr].var) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 277 | |
Vladislav Zolotarov | da5a662 | 2008-08-13 15:50:00 -0700 | [diff] [blame] | 278 | #define BNX2X_HAS_TX_WORK(fp) \ |
| 279 | ((fp->tx_pkt_prod != le16_to_cpu(*fp->tx_cons_sb)) || \ |
| 280 | (fp->tx_pkt_prod != fp->tx_pkt_cons)) |
| 281 | |
| 282 | #define BNX2X_HAS_RX_WORK(fp) \ |
| 283 | (fp->rx_comp_cons != le16_to_cpu(*fp->rx_cons_sb)) |
| 284 | |
| 285 | #define BNX2X_HAS_WORK(fp) (BNX2X_HAS_RX_WORK(fp) || BNX2X_HAS_TX_WORK(fp)) |
| 286 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 287 | |
| 288 | /* MC hsi */ |
| 289 | #define MAX_FETCH_BD 13 /* HW max BDs per packet */ |
| 290 | #define RX_COPY_THRESH 92 |
| 291 | |
| 292 | #define NUM_TX_RINGS 16 |
| 293 | #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_tx_bd)) |
| 294 | #define MAX_TX_DESC_CNT (TX_DESC_CNT - 1) |
| 295 | #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS) |
| 296 | #define MAX_TX_BD (NUM_TX_BD - 1) |
| 297 | #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2) |
| 298 | #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \ |
| 299 | (MAX_TX_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) |
| 300 | #define TX_BD(x) ((x) & MAX_TX_BD) |
| 301 | #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT) |
| 302 | |
| 303 | /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */ |
| 304 | #define NUM_RX_RINGS 8 |
| 305 | #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd)) |
| 306 | #define MAX_RX_DESC_CNT (RX_DESC_CNT - 2) |
| 307 | #define RX_DESC_MASK (RX_DESC_CNT - 1) |
| 308 | #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS) |
| 309 | #define MAX_RX_BD (NUM_RX_BD - 1) |
| 310 | #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2) |
| 311 | #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \ |
| 312 | (MAX_RX_DESC_CNT - 1)) ? (x) + 3 : (x) + 1) |
| 313 | #define RX_BD(x) ((x) & MAX_RX_BD) |
| 314 | |
| 315 | /* As long as CQE is 4 times bigger than BD entry we have to allocate |
| 316 | 4 times more pages for CQ ring in order to keep it balanced with |
| 317 | BD ring */ |
| 318 | #define NUM_RCQ_RINGS (NUM_RX_RINGS * 4) |
| 319 | #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) |
| 320 | #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - 1) |
| 321 | #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS) |
| 322 | #define MAX_RCQ_BD (NUM_RCQ_BD - 1) |
| 323 | #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2) |
| 324 | #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \ |
| 325 | (MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) |
| 326 | #define RCQ_BD(x) ((x) & MAX_RCQ_BD) |
| 327 | |
| 328 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 329 | /* This is needed for determening of last_max */ |
| 330 | #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) |
| 331 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 332 | #define __SGE_MASK_SET_BIT(el, bit) \ |
| 333 | do { \ |
| 334 | el = ((el) | ((u64)0x1 << (bit))); \ |
| 335 | } while (0) |
| 336 | |
| 337 | #define __SGE_MASK_CLEAR_BIT(el, bit) \ |
| 338 | do { \ |
| 339 | el = ((el) & (~((u64)0x1 << (bit)))); \ |
| 340 | } while (0) |
| 341 | |
| 342 | #define SGE_MASK_SET_BIT(fp, idx) \ |
| 343 | __SGE_MASK_SET_BIT(fp->sge_mask[(idx) >> RX_SGE_MASK_ELEM_SHIFT], \ |
| 344 | ((idx) & RX_SGE_MASK_ELEM_MASK)) |
| 345 | |
| 346 | #define SGE_MASK_CLEAR_BIT(fp, idx) \ |
| 347 | __SGE_MASK_CLEAR_BIT(fp->sge_mask[(idx) >> RX_SGE_MASK_ELEM_SHIFT], \ |
| 348 | ((idx) & RX_SGE_MASK_ELEM_MASK)) |
| 349 | |
| 350 | |
| 351 | /* used on a CID received from the HW */ |
| 352 | #define SW_CID(x) (le32_to_cpu(x) & \ |
| 353 | (COMMON_RAMROD_ETH_RX_CQE_CID >> 7)) |
| 354 | #define CQE_CMD(x) (le32_to_cpu(x) >> \ |
| 355 | COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT) |
| 356 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 357 | #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \ |
| 358 | le32_to_cpu((bd)->addr_lo)) |
| 359 | #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes)) |
| 360 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 361 | |
| 362 | #define DPM_TRIGER_TYPE 0x40 |
| 363 | #define DOORBELL(bp, cid, val) \ |
| 364 | do { \ |
| 365 | writel((u32)val, (bp)->doorbells + (BCM_PAGE_SIZE * cid) + \ |
| 366 | DPM_TRIGER_TYPE); \ |
| 367 | } while (0) |
| 368 | |
| 369 | |
| 370 | /* TX CSUM helpers */ |
| 371 | #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \ |
| 372 | skb->csum_offset) |
| 373 | #define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \ |
| 374 | skb->csum_offset)) |
| 375 | |
| 376 | #define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff) |
| 377 | |
| 378 | #define XMIT_PLAIN 0 |
| 379 | #define XMIT_CSUM_V4 0x1 |
| 380 | #define XMIT_CSUM_V6 0x2 |
| 381 | #define XMIT_CSUM_TCP 0x4 |
| 382 | #define XMIT_GSO_V4 0x8 |
| 383 | #define XMIT_GSO_V6 0x10 |
| 384 | |
| 385 | #define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6) |
| 386 | #define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6) |
| 387 | |
| 388 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 389 | /* stuff added to make the code fit 80Col */ |
| 390 | |
| 391 | #define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE) |
| 392 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 393 | #define TPA_TYPE_START ETH_FAST_PATH_RX_CQE_START_FLG |
| 394 | #define TPA_TYPE_END ETH_FAST_PATH_RX_CQE_END_FLG |
| 395 | #define TPA_TYPE(cqe_fp_flags) ((cqe_fp_flags) & \ |
| 396 | (TPA_TYPE_START | TPA_TYPE_END)) |
| 397 | |
Eilon Greenstein | 1adcd8b | 2008-08-13 15:48:29 -0700 | [diff] [blame] | 398 | #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG |
| 399 | |
| 400 | #define BNX2X_IP_CSUM_ERR(cqe) \ |
| 401 | (!((cqe)->fast_path_cqe.status_flags & \ |
| 402 | ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG) && \ |
| 403 | ((cqe)->fast_path_cqe.type_error_flags & \ |
| 404 | ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG)) |
| 405 | |
| 406 | #define BNX2X_L4_CSUM_ERR(cqe) \ |
| 407 | (!((cqe)->fast_path_cqe.status_flags & \ |
| 408 | ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG) && \ |
| 409 | ((cqe)->fast_path_cqe.type_error_flags & \ |
| 410 | ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG)) |
| 411 | |
| 412 | #define BNX2X_RX_CSUM_OK(cqe) \ |
| 413 | (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe))) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 414 | |
| 415 | #define BNX2X_RX_SUM_FIX(cqe) \ |
| 416 | ((le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & \ |
| 417 | PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) == \ |
| 418 | (1 << PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT)) |
| 419 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 420 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 421 | #define FP_USB_FUNC_OFF (2 + 2*HC_USTORM_SB_NUM_INDICES) |
| 422 | #define FP_CSB_FUNC_OFF (2 + 2*HC_CSTORM_SB_NUM_INDICES) |
| 423 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 424 | #define U_SB_ETH_RX_CQ_INDEX HC_INDEX_U_ETH_RX_CQ_CONS |
| 425 | #define U_SB_ETH_RX_BD_INDEX HC_INDEX_U_ETH_RX_BD_CONS |
| 426 | #define C_SB_ETH_TX_CQ_INDEX HC_INDEX_C_ETH_TX_CQ_CONS |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 427 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 428 | #define BNX2X_RX_SB_INDEX \ |
| 429 | (&fp->status_blk->u_status_block.index_values[U_SB_ETH_RX_CQ_INDEX]) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 430 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 431 | #define BNX2X_RX_SB_BD_INDEX \ |
| 432 | (&fp->status_blk->u_status_block.index_values[U_SB_ETH_RX_BD_INDEX]) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 433 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 434 | #define BNX2X_RX_SB_INDEX_NUM \ |
| 435 | (((U_SB_ETH_RX_CQ_INDEX << \ |
| 436 | USTORM_ETH_ST_CONTEXT_CONFIG_CQE_SB_INDEX_NUMBER_SHIFT) & \ |
| 437 | USTORM_ETH_ST_CONTEXT_CONFIG_CQE_SB_INDEX_NUMBER) | \ |
| 438 | ((U_SB_ETH_RX_BD_INDEX << \ |
| 439 | USTORM_ETH_ST_CONTEXT_CONFIG_BD_SB_INDEX_NUMBER_SHIFT) & \ |
| 440 | USTORM_ETH_ST_CONTEXT_CONFIG_BD_SB_INDEX_NUMBER)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 441 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 442 | #define BNX2X_TX_SB_INDEX \ |
| 443 | (&fp->status_blk->c_status_block.index_values[C_SB_ETH_TX_CQ_INDEX]) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 444 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 445 | |
| 446 | /* end of fast path */ |
| 447 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 448 | /* common */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 449 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 450 | struct bnx2x_common { |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 451 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 452 | u32 chip_id; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 453 | /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 454 | #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 455 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 456 | #define CHIP_NUM(bp) (bp->common.chip_id >> 16) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 457 | #define CHIP_NUM_57710 0x164e |
| 458 | #define CHIP_NUM_57711 0x164f |
| 459 | #define CHIP_NUM_57711E 0x1650 |
| 460 | #define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710) |
| 461 | #define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711) |
| 462 | #define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E) |
| 463 | #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \ |
| 464 | CHIP_IS_57711E(bp)) |
| 465 | #define IS_E1H_OFFSET CHIP_IS_E1H(bp) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 466 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 467 | #define CHIP_REV(bp) (bp->common.chip_id & 0x0000f000) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 468 | #define CHIP_REV_Ax 0x00000000 |
| 469 | /* assume maximum 5 revisions */ |
| 470 | #define CHIP_REV_IS_SLOW(bp) (CHIP_REV(bp) > 0x00005000) |
| 471 | /* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */ |
| 472 | #define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \ |
| 473 | !(CHIP_REV(bp) & 0x00001000)) |
| 474 | /* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */ |
| 475 | #define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \ |
| 476 | (CHIP_REV(bp) & 0x00001000)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 477 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 478 | #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \ |
| 479 | ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1)) |
| 480 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 481 | #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0) |
| 482 | #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 483 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 484 | int flash_size; |
| 485 | #define NVRAM_1MB_SIZE 0x20000 /* 1M bit in bytes */ |
| 486 | #define NVRAM_TIMEOUT_COUNT 30000 |
| 487 | #define NVRAM_PAGE_SIZE 256 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 488 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 489 | u32 shmem_base; |
| 490 | |
| 491 | u32 hw_config; |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 492 | u32 board; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 493 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 494 | u32 bc_ver; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 495 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 496 | char *name; |
| 497 | }; |
| 498 | |
| 499 | |
| 500 | /* end of common */ |
| 501 | |
| 502 | /* port */ |
| 503 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 504 | struct nig_stats { |
| 505 | u32 brb_discard; |
| 506 | u32 brb_packet; |
| 507 | u32 brb_truncate; |
| 508 | u32 flow_ctrl_discard; |
| 509 | u32 flow_ctrl_octets; |
| 510 | u32 flow_ctrl_packet; |
| 511 | u32 mng_discard; |
| 512 | u32 mng_octet_inp; |
| 513 | u32 mng_octet_out; |
| 514 | u32 mng_packet_inp; |
| 515 | u32 mng_packet_out; |
| 516 | u32 pbf_octets; |
| 517 | u32 pbf_packet; |
| 518 | u32 safc_inp; |
| 519 | u32 egress_mac_pkt0_lo; |
| 520 | u32 egress_mac_pkt0_hi; |
| 521 | u32 egress_mac_pkt1_lo; |
| 522 | u32 egress_mac_pkt1_hi; |
| 523 | }; |
| 524 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 525 | struct bnx2x_port { |
| 526 | u32 pmf; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 527 | |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 528 | u32 link_config; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 529 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 530 | u32 supported; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 531 | /* link settings - missing defines */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 532 | #define SUPPORTED_2500baseX_Full (1 << 15) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 533 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 534 | u32 advertising; |
| 535 | /* link settings - missing defines */ |
| 536 | #define ADVERTISED_2500baseX_Full (1 << 15) |
| 537 | |
| 538 | u32 phy_addr; |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 539 | |
| 540 | /* used to synchronize phy accesses */ |
| 541 | struct mutex phy_mutex; |
| 542 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 543 | u32 port_stx; |
| 544 | |
| 545 | struct nig_stats old_nig_stats; |
| 546 | }; |
| 547 | |
| 548 | /* end of port */ |
| 549 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 550 | |
| 551 | enum bnx2x_stats_event { |
| 552 | STATS_EVENT_PMF = 0, |
| 553 | STATS_EVENT_LINK_UP, |
| 554 | STATS_EVENT_UPDATE, |
| 555 | STATS_EVENT_STOP, |
| 556 | STATS_EVENT_MAX |
| 557 | }; |
| 558 | |
| 559 | enum bnx2x_stats_state { |
| 560 | STATS_STATE_DISABLED = 0, |
| 561 | STATS_STATE_ENABLED, |
| 562 | STATS_STATE_MAX |
| 563 | }; |
| 564 | |
| 565 | struct bnx2x_eth_stats { |
| 566 | u32 total_bytes_received_hi; |
| 567 | u32 total_bytes_received_lo; |
| 568 | u32 total_bytes_transmitted_hi; |
| 569 | u32 total_bytes_transmitted_lo; |
| 570 | u32 total_unicast_packets_received_hi; |
| 571 | u32 total_unicast_packets_received_lo; |
| 572 | u32 total_multicast_packets_received_hi; |
| 573 | u32 total_multicast_packets_received_lo; |
| 574 | u32 total_broadcast_packets_received_hi; |
| 575 | u32 total_broadcast_packets_received_lo; |
| 576 | u32 total_unicast_packets_transmitted_hi; |
| 577 | u32 total_unicast_packets_transmitted_lo; |
| 578 | u32 total_multicast_packets_transmitted_hi; |
| 579 | u32 total_multicast_packets_transmitted_lo; |
| 580 | u32 total_broadcast_packets_transmitted_hi; |
| 581 | u32 total_broadcast_packets_transmitted_lo; |
| 582 | u32 valid_bytes_received_hi; |
| 583 | u32 valid_bytes_received_lo; |
| 584 | |
| 585 | u32 error_bytes_received_hi; |
| 586 | u32 error_bytes_received_lo; |
| 587 | |
| 588 | u32 rx_stat_ifhcinbadoctets_hi; |
| 589 | u32 rx_stat_ifhcinbadoctets_lo; |
| 590 | u32 tx_stat_ifhcoutbadoctets_hi; |
| 591 | u32 tx_stat_ifhcoutbadoctets_lo; |
| 592 | u32 rx_stat_dot3statsfcserrors_hi; |
| 593 | u32 rx_stat_dot3statsfcserrors_lo; |
| 594 | u32 rx_stat_dot3statsalignmenterrors_hi; |
| 595 | u32 rx_stat_dot3statsalignmenterrors_lo; |
| 596 | u32 rx_stat_dot3statscarriersenseerrors_hi; |
| 597 | u32 rx_stat_dot3statscarriersenseerrors_lo; |
| 598 | u32 rx_stat_falsecarriererrors_hi; |
| 599 | u32 rx_stat_falsecarriererrors_lo; |
| 600 | u32 rx_stat_etherstatsundersizepkts_hi; |
| 601 | u32 rx_stat_etherstatsundersizepkts_lo; |
| 602 | u32 rx_stat_dot3statsframestoolong_hi; |
| 603 | u32 rx_stat_dot3statsframestoolong_lo; |
| 604 | u32 rx_stat_etherstatsfragments_hi; |
| 605 | u32 rx_stat_etherstatsfragments_lo; |
| 606 | u32 rx_stat_etherstatsjabbers_hi; |
| 607 | u32 rx_stat_etherstatsjabbers_lo; |
| 608 | u32 rx_stat_maccontrolframesreceived_hi; |
| 609 | u32 rx_stat_maccontrolframesreceived_lo; |
| 610 | u32 rx_stat_bmac_xpf_hi; |
| 611 | u32 rx_stat_bmac_xpf_lo; |
| 612 | u32 rx_stat_bmac_xcf_hi; |
| 613 | u32 rx_stat_bmac_xcf_lo; |
| 614 | u32 rx_stat_xoffstateentered_hi; |
| 615 | u32 rx_stat_xoffstateentered_lo; |
| 616 | u32 rx_stat_xonpauseframesreceived_hi; |
| 617 | u32 rx_stat_xonpauseframesreceived_lo; |
| 618 | u32 rx_stat_xoffpauseframesreceived_hi; |
| 619 | u32 rx_stat_xoffpauseframesreceived_lo; |
| 620 | u32 tx_stat_outxonsent_hi; |
| 621 | u32 tx_stat_outxonsent_lo; |
| 622 | u32 tx_stat_outxoffsent_hi; |
| 623 | u32 tx_stat_outxoffsent_lo; |
| 624 | u32 tx_stat_flowcontroldone_hi; |
| 625 | u32 tx_stat_flowcontroldone_lo; |
| 626 | u32 tx_stat_etherstatscollisions_hi; |
| 627 | u32 tx_stat_etherstatscollisions_lo; |
| 628 | u32 tx_stat_dot3statssinglecollisionframes_hi; |
| 629 | u32 tx_stat_dot3statssinglecollisionframes_lo; |
| 630 | u32 tx_stat_dot3statsmultiplecollisionframes_hi; |
| 631 | u32 tx_stat_dot3statsmultiplecollisionframes_lo; |
| 632 | u32 tx_stat_dot3statsdeferredtransmissions_hi; |
| 633 | u32 tx_stat_dot3statsdeferredtransmissions_lo; |
| 634 | u32 tx_stat_dot3statsexcessivecollisions_hi; |
| 635 | u32 tx_stat_dot3statsexcessivecollisions_lo; |
| 636 | u32 tx_stat_dot3statslatecollisions_hi; |
| 637 | u32 tx_stat_dot3statslatecollisions_lo; |
| 638 | u32 tx_stat_etherstatspkts64octets_hi; |
| 639 | u32 tx_stat_etherstatspkts64octets_lo; |
| 640 | u32 tx_stat_etherstatspkts65octetsto127octets_hi; |
| 641 | u32 tx_stat_etherstatspkts65octetsto127octets_lo; |
| 642 | u32 tx_stat_etherstatspkts128octetsto255octets_hi; |
| 643 | u32 tx_stat_etherstatspkts128octetsto255octets_lo; |
| 644 | u32 tx_stat_etherstatspkts256octetsto511octets_hi; |
| 645 | u32 tx_stat_etherstatspkts256octetsto511octets_lo; |
| 646 | u32 tx_stat_etherstatspkts512octetsto1023octets_hi; |
| 647 | u32 tx_stat_etherstatspkts512octetsto1023octets_lo; |
| 648 | u32 tx_stat_etherstatspkts1024octetsto1522octets_hi; |
| 649 | u32 tx_stat_etherstatspkts1024octetsto1522octets_lo; |
| 650 | u32 tx_stat_etherstatspktsover1522octets_hi; |
| 651 | u32 tx_stat_etherstatspktsover1522octets_lo; |
| 652 | u32 tx_stat_bmac_2047_hi; |
| 653 | u32 tx_stat_bmac_2047_lo; |
| 654 | u32 tx_stat_bmac_4095_hi; |
| 655 | u32 tx_stat_bmac_4095_lo; |
| 656 | u32 tx_stat_bmac_9216_hi; |
| 657 | u32 tx_stat_bmac_9216_lo; |
| 658 | u32 tx_stat_bmac_16383_hi; |
| 659 | u32 tx_stat_bmac_16383_lo; |
| 660 | u32 tx_stat_dot3statsinternalmactransmiterrors_hi; |
| 661 | u32 tx_stat_dot3statsinternalmactransmiterrors_lo; |
| 662 | u32 tx_stat_bmac_ufl_hi; |
| 663 | u32 tx_stat_bmac_ufl_lo; |
| 664 | |
| 665 | u32 brb_drop_hi; |
| 666 | u32 brb_drop_lo; |
Yitchak Gertner | 66e855f | 2008-08-13 15:49:05 -0700 | [diff] [blame] | 667 | u32 brb_truncate_hi; |
| 668 | u32 brb_truncate_lo; |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 669 | |
| 670 | u32 jabber_packets_received; |
| 671 | |
| 672 | u32 etherstatspkts1024octetsto1522octets_hi; |
| 673 | u32 etherstatspkts1024octetsto1522octets_lo; |
| 674 | u32 etherstatspktsover1522octets_hi; |
| 675 | u32 etherstatspktsover1522octets_lo; |
| 676 | |
| 677 | u32 no_buff_discard; |
| 678 | |
| 679 | u32 mac_filter_discard; |
| 680 | u32 xxoverflow_discard; |
| 681 | u32 brb_truncate_discard; |
| 682 | u32 mac_discard; |
| 683 | |
| 684 | u32 driver_xoff; |
Yitchak Gertner | 66e855f | 2008-08-13 15:49:05 -0700 | [diff] [blame] | 685 | u32 rx_err_discard_pkt; |
| 686 | u32 rx_skb_alloc_failed; |
| 687 | u32 hw_csum_err; |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 688 | }; |
| 689 | |
| 690 | #define STATS_OFFSET32(stat_name) \ |
| 691 | (offsetof(struct bnx2x_eth_stats, stat_name) / 4) |
| 692 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 693 | |
| 694 | #ifdef BNX2X_MULTI |
| 695 | #define MAX_CONTEXT 16 |
| 696 | #else |
| 697 | #define MAX_CONTEXT 1 |
| 698 | #endif |
| 699 | |
| 700 | union cdu_context { |
| 701 | struct eth_context eth; |
| 702 | char pad[1024]; |
| 703 | }; |
| 704 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 705 | #define MAX_DMAE_C 8 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 706 | |
| 707 | /* DMA memory not used in fastpath */ |
| 708 | struct bnx2x_slowpath { |
| 709 | union cdu_context context[MAX_CONTEXT]; |
| 710 | struct eth_stats_query fw_stats; |
| 711 | struct mac_configuration_cmd mac_config; |
| 712 | struct mac_configuration_cmd mcast_config; |
| 713 | |
| 714 | /* used by dmae command executer */ |
| 715 | struct dmae_command dmae[MAX_DMAE_C]; |
| 716 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 717 | u32 stats_comp; |
| 718 | union mac_stats mac_stats; |
| 719 | struct nig_stats nig_stats; |
| 720 | struct host_port_stats port_stats; |
| 721 | struct host_func_stats func_stats; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 722 | |
| 723 | u32 wb_comp; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 724 | u32 wb_data[4]; |
| 725 | }; |
| 726 | |
| 727 | #define bnx2x_sp(bp, var) (&bp->slowpath->var) |
| 728 | #define bnx2x_sp_mapping(bp, var) \ |
| 729 | (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 730 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 731 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 732 | /* attn group wiring */ |
| 733 | #define MAX_DYNAMIC_ATTN_GRPS 8 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 734 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 735 | struct attn_route { |
| 736 | u32 sig[4]; |
| 737 | }; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 738 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 739 | struct bnx2x { |
| 740 | /* Fields used in the tx and intr/napi performance paths |
| 741 | * are grouped together in the beginning of the structure |
| 742 | */ |
| 743 | struct bnx2x_fastpath fp[MAX_CONTEXT]; |
| 744 | void __iomem *regview; |
| 745 | void __iomem *doorbells; |
| 746 | #define BNX2X_DB_SIZE (16*2048) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 747 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 748 | struct net_device *dev; |
| 749 | struct pci_dev *pdev; |
| 750 | |
| 751 | atomic_t intr_sem; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 752 | struct msix_entry msix_table[MAX_CONTEXT+1]; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 753 | |
| 754 | int tx_ring_size; |
| 755 | |
| 756 | #ifdef BCM_VLAN |
| 757 | struct vlan_group *vlgrp; |
| 758 | #endif |
| 759 | |
| 760 | u32 rx_csum; |
| 761 | u32 rx_offset; |
| 762 | u32 rx_buf_use_size; /* useable size */ |
| 763 | u32 rx_buf_size; /* with alignment */ |
| 764 | #define ETH_OVREHEAD (ETH_HLEN + 8) /* 8 for CRC + VLAN */ |
| 765 | #define ETH_MIN_PACKET_SIZE 60 |
| 766 | #define ETH_MAX_PACKET_SIZE 1500 |
| 767 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 768 | |
| 769 | struct host_def_status_block *def_status_blk; |
| 770 | #define DEF_SB_ID 16 |
| 771 | u16 def_c_idx; |
| 772 | u16 def_u_idx; |
| 773 | u16 def_x_idx; |
| 774 | u16 def_t_idx; |
| 775 | u16 def_att_idx; |
| 776 | u32 attn_state; |
| 777 | struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS]; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 778 | u32 nig_mask; |
| 779 | |
| 780 | /* slow path ring */ |
| 781 | struct eth_spe *spq; |
| 782 | dma_addr_t spq_mapping; |
| 783 | u16 spq_prod_idx; |
| 784 | struct eth_spe *spq_prod_bd; |
| 785 | struct eth_spe *spq_last_bd; |
| 786 | u16 *dsb_sp_prod; |
| 787 | u16 spq_left; /* serialize spq */ |
| 788 | /* used to synchronize spq accesses */ |
| 789 | spinlock_t spq_lock; |
| 790 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 791 | /* Flags for marking that there is a STAT_QUERY or |
| 792 | SET_MAC ramrod pending */ |
| 793 | u8 stats_pending; |
| 794 | u8 set_mac_pending; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 795 | |
| 796 | /* End of fileds used in the performance code paths */ |
| 797 | |
| 798 | int panic; |
| 799 | int msglevel; |
| 800 | |
| 801 | u32 flags; |
| 802 | #define PCIX_FLAG 1 |
| 803 | #define PCI_32BIT_FLAG 2 |
| 804 | #define ONE_TDMA_FLAG 4 /* no longer used */ |
| 805 | #define NO_WOL_FLAG 8 |
| 806 | #define USING_DAC_FLAG 0x10 |
| 807 | #define USING_MSIX_FLAG 0x20 |
| 808 | #define ASF_ENABLE_FLAG 0x40 |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 809 | #define TPA_ENABLE_FLAG 0x80 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 810 | #define NO_MCP_FLAG 0x100 |
| 811 | #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) |
| 812 | |
| 813 | int func; |
| 814 | #define BP_PORT(bp) (bp->func % PORT_MAX) |
| 815 | #define BP_FUNC(bp) (bp->func) |
| 816 | #define BP_E1HVN(bp) (bp->func >> 1) |
| 817 | #define BP_L_ID(bp) (BP_E1HVN(bp) << 2) |
| 818 | /* assorted E1HVN */ |
| 819 | #define IS_E1HMF(bp) (bp->e1hmf != 0) |
| 820 | #define BP_MAX_QUEUES(bp) (IS_E1HMF(bp) ? 4 : 16) |
| 821 | |
| 822 | int pm_cap; |
| 823 | int pcie_cap; |
| 824 | |
| 825 | struct work_struct sp_task; |
| 826 | struct work_struct reset_task; |
| 827 | |
| 828 | struct timer_list timer; |
| 829 | int timer_interval; |
| 830 | int current_interval; |
| 831 | |
| 832 | u16 fw_seq; |
| 833 | u16 fw_drv_pulse_wr_seq; |
| 834 | u32 func_stx; |
| 835 | |
| 836 | struct link_params link_params; |
| 837 | struct link_vars link_vars; |
| 838 | |
| 839 | struct bnx2x_common common; |
| 840 | struct bnx2x_port port; |
| 841 | |
| 842 | u32 mf_config; |
| 843 | u16 e1hov; |
| 844 | u8 e1hmf; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 845 | |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 846 | u8 wol; |
| 847 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 848 | int rx_ring_size; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 849 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 850 | u16 tx_quick_cons_trip_int; |
| 851 | u16 tx_quick_cons_trip; |
| 852 | u16 tx_ticks_int; |
| 853 | u16 tx_ticks; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 854 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 855 | u16 rx_quick_cons_trip_int; |
| 856 | u16 rx_quick_cons_trip; |
| 857 | u16 rx_ticks_int; |
| 858 | u16 rx_ticks; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 859 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 860 | u32 lin_cnt; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 861 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 862 | int state; |
| 863 | #define BNX2X_STATE_CLOSED 0x0 |
| 864 | #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000 |
| 865 | #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 866 | #define BNX2X_STATE_OPEN 0x3000 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 867 | #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 868 | #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000 |
| 869 | #define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 870 | #define BNX2X_STATE_DISABLED 0xd000 |
| 871 | #define BNX2X_STATE_DIAG 0xe000 |
| 872 | #define BNX2X_STATE_ERROR 0xf000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 873 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 874 | int num_queues; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 875 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 876 | u32 rx_mode; |
| 877 | #define BNX2X_RX_MODE_NONE 0 |
| 878 | #define BNX2X_RX_MODE_NORMAL 1 |
| 879 | #define BNX2X_RX_MODE_ALLMULTI 2 |
| 880 | #define BNX2X_RX_MODE_PROMISC 3 |
| 881 | #define BNX2X_MAX_MULTICAST 64 |
| 882 | #define BNX2X_MAX_EMUL_MULTI 16 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 883 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 884 | dma_addr_t def_status_blk_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 885 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 886 | struct bnx2x_slowpath *slowpath; |
| 887 | dma_addr_t slowpath_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 888 | |
| 889 | #ifdef BCM_ISCSI |
| 890 | void *t1; |
| 891 | dma_addr_t t1_mapping; |
| 892 | void *t2; |
| 893 | dma_addr_t t2_mapping; |
| 894 | void *timers; |
| 895 | dma_addr_t timers_mapping; |
| 896 | void *qm; |
| 897 | dma_addr_t qm_mapping; |
| 898 | #endif |
| 899 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 900 | int dmae_ready; |
| 901 | /* used to synchronize dmae accesses */ |
| 902 | struct mutex dmae_mutex; |
| 903 | struct dmae_command init_dmae; |
| 904 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 905 | /* used to synchronize stats collecting */ |
| 906 | int stats_state; |
| 907 | /* used by dmae command loader */ |
| 908 | struct dmae_command stats_dmae; |
| 909 | int executer_idx; |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 910 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 911 | u16 stats_counter; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 912 | struct tstorm_per_client_stats old_tclient; |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 913 | struct xstorm_per_client_stats old_xclient; |
| 914 | struct bnx2x_eth_stats eth_stats; |
| 915 | |
| 916 | struct z_stream_s *strm; |
| 917 | void *gunzip_buf; |
| 918 | dma_addr_t gunzip_mapping; |
| 919 | int gunzip_outlen; |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 920 | #define FW_BUF_SIZE 0x8000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 921 | |
| 922 | }; |
| 923 | |
| 924 | |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 925 | void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32); |
| 926 | void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, |
| 927 | u32 len32); |
Eilon Greenstein | 17de50b | 2008-08-13 15:56:59 -0700 | [diff] [blame] | 928 | int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 929 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 930 | static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, |
| 931 | int wait) |
| 932 | { |
| 933 | u32 val; |
| 934 | |
| 935 | do { |
| 936 | val = REG_RD(bp, reg); |
| 937 | if (val == expected) |
| 938 | break; |
| 939 | ms -= wait; |
| 940 | msleep(wait); |
| 941 | |
| 942 | } while (ms > 0); |
| 943 | |
| 944 | return val; |
| 945 | } |
| 946 | |
| 947 | |
| 948 | /* load/unload mode */ |
| 949 | #define LOAD_NORMAL 0 |
| 950 | #define LOAD_OPEN 1 |
| 951 | #define LOAD_DIAG 2 |
| 952 | #define UNLOAD_NORMAL 0 |
| 953 | #define UNLOAD_CLOSE 1 |
| 954 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 955 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 956 | /* DMAE command defines */ |
| 957 | #define DMAE_CMD_SRC_PCI 0 |
| 958 | #define DMAE_CMD_SRC_GRC DMAE_COMMAND_SRC |
| 959 | |
| 960 | #define DMAE_CMD_DST_PCI (1 << DMAE_COMMAND_DST_SHIFT) |
| 961 | #define DMAE_CMD_DST_GRC (2 << DMAE_COMMAND_DST_SHIFT) |
| 962 | |
| 963 | #define DMAE_CMD_C_DST_PCI 0 |
| 964 | #define DMAE_CMD_C_DST_GRC (1 << DMAE_COMMAND_C_DST_SHIFT) |
| 965 | |
| 966 | #define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE |
| 967 | |
| 968 | #define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT) |
| 969 | #define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT) |
| 970 | #define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT) |
| 971 | #define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT) |
| 972 | |
| 973 | #define DMAE_CMD_PORT_0 0 |
| 974 | #define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT |
| 975 | |
| 976 | #define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET |
| 977 | #define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET |
| 978 | #define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT |
| 979 | |
| 980 | #define DMAE_LEN32_RD_MAX 0x80 |
| 981 | #define DMAE_LEN32_WR_MAX 0x400 |
| 982 | |
| 983 | #define DMAE_COMP_VAL 0xe0d0d0ae |
| 984 | |
| 985 | #define MAX_DMAE_C_PER_PORT 8 |
| 986 | #define INIT_DMAE_C(bp) (BP_PORT(bp)*MAX_DMAE_C_PER_PORT + \ |
| 987 | BP_E1HVN(bp)) |
| 988 | #define PMF_DMAE_C(bp) (BP_PORT(bp)*MAX_DMAE_C_PER_PORT + \ |
| 989 | E1HVN_MAX) |
| 990 | |
| 991 | |
Eliezer Tamir | 2504795 | 2008-02-28 11:50:16 -0800 | [diff] [blame] | 992 | /* PCIE link and speed */ |
| 993 | #define PCICFG_LINK_WIDTH 0x1f00000 |
| 994 | #define PCICFG_LINK_WIDTH_SHIFT 20 |
| 995 | #define PCICFG_LINK_SPEED 0xf0000 |
| 996 | #define PCICFG_LINK_SPEED_SHIFT 16 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 997 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 998 | |
Yitchak Gertner | 66e855f | 2008-08-13 15:49:05 -0700 | [diff] [blame] | 999 | #define BNX2X_NUM_STATS 42 |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1000 | #define BNX2X_NUM_TESTS 8 |
| 1001 | |
| 1002 | #define BNX2X_MAC_LOOPBACK 0 |
| 1003 | #define BNX2X_PHY_LOOPBACK 1 |
| 1004 | #define BNX2X_MAC_LOOPBACK_FAILED 1 |
| 1005 | #define BNX2X_PHY_LOOPBACK_FAILED 2 |
| 1006 | #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \ |
| 1007 | BNX2X_PHY_LOOPBACK_FAILED) |
Eliezer Tamir | 96fc178 | 2008-02-28 11:57:55 -0800 | [diff] [blame] | 1008 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1009 | |
| 1010 | #define STROM_ASSERT_ARRAY_SIZE 50 |
| 1011 | |
Eliezer Tamir | 96fc178 | 2008-02-28 11:57:55 -0800 | [diff] [blame] | 1012 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1013 | /* must be used on a CID before placing it on a HW ring */ |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1014 | #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | (BP_E1HVN(bp) << 17) | x) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1015 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1016 | #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe)) |
| 1017 | #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1) |
| 1018 | |
| 1019 | |
| 1020 | #define BNX2X_BTR 3 |
| 1021 | #define MAX_SPQ_PENDING 8 |
| 1022 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1023 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1024 | /* CMNG constants |
| 1025 | derived from lab experiments, and not from system spec calculations !!! */ |
| 1026 | #define DEF_MIN_RATE 100 |
| 1027 | /* resolution of the rate shaping timer - 100 usec */ |
| 1028 | #define RS_PERIODIC_TIMEOUT_USEC 100 |
| 1029 | /* resolution of fairness algorithm in usecs - |
| 1030 | coefficient for clauclating the actuall t fair */ |
| 1031 | #define T_FAIR_COEF 10000000 |
| 1032 | /* number of bytes in single QM arbitration cycle - |
| 1033 | coeffiecnt for calculating the fairness timer */ |
| 1034 | #define QM_ARB_BYTES 40000 |
| 1035 | #define FAIR_MEM 2 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1036 | |
| 1037 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1038 | #define ATTN_NIG_FOR_FUNC (1L << 8) |
| 1039 | #define ATTN_SW_TIMER_4_FUNC (1L << 9) |
| 1040 | #define GPIO_2_FUNC (1L << 10) |
| 1041 | #define GPIO_3_FUNC (1L << 11) |
| 1042 | #define GPIO_4_FUNC (1L << 12) |
| 1043 | #define ATTN_GENERAL_ATTN_1 (1L << 13) |
| 1044 | #define ATTN_GENERAL_ATTN_2 (1L << 14) |
| 1045 | #define ATTN_GENERAL_ATTN_3 (1L << 15) |
| 1046 | #define ATTN_GENERAL_ATTN_4 (1L << 13) |
| 1047 | #define ATTN_GENERAL_ATTN_5 (1L << 14) |
| 1048 | #define ATTN_GENERAL_ATTN_6 (1L << 15) |
| 1049 | |
| 1050 | #define ATTN_HARD_WIRED_MASK 0xff00 |
| 1051 | #define ATTENTION_ID 4 |
| 1052 | |
| 1053 | |
| 1054 | /* stuff added to make the code fit 80Col */ |
| 1055 | |
| 1056 | #define BNX2X_PMF_LINK_ASSERT \ |
| 1057 | GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp)) |
| 1058 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1059 | #define BNX2X_MC_ASSERT_BITS \ |
| 1060 | (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \ |
| 1061 | GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \ |
| 1062 | GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \ |
| 1063 | GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT)) |
| 1064 | |
| 1065 | #define BNX2X_MCP_ASSERT \ |
| 1066 | GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT) |
| 1067 | |
| 1068 | #define BNX2X_DOORQ_ASSERT \ |
| 1069 | AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT |
| 1070 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1071 | #define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC) |
| 1072 | #define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \ |
| 1073 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \ |
| 1074 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \ |
| 1075 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \ |
| 1076 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \ |
| 1077 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC)) |
| 1078 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1079 | #define HW_INTERRUT_ASSERT_SET_0 \ |
| 1080 | (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \ |
| 1081 | AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \ |
| 1082 | AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \ |
| 1083 | AEU_INPUTS_ATTN_BITS_PBF_HW_INTERRUPT) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1084 | #define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1085 | AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \ |
| 1086 | AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \ |
| 1087 | AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\ |
| 1088 | AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR) |
| 1089 | #define HW_INTERRUT_ASSERT_SET_1 \ |
| 1090 | (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \ |
| 1091 | AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \ |
| 1092 | AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \ |
| 1093 | AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \ |
| 1094 | AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \ |
| 1095 | AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \ |
| 1096 | AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \ |
| 1097 | AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \ |
| 1098 | AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \ |
| 1099 | AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \ |
| 1100 | AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1101 | #define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR |\ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1102 | AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \ |
| 1103 | AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \ |
| 1104 | AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \ |
| 1105 | AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\ |
| 1106 | AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\ |
| 1107 | AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \ |
| 1108 | AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \ |
| 1109 | AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \ |
| 1110 | AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \ |
| 1111 | AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR) |
| 1112 | #define HW_INTERRUT_ASSERT_SET_2 \ |
| 1113 | (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \ |
| 1114 | AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \ |
| 1115 | AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \ |
| 1116 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\ |
| 1117 | AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1118 | #define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1119 | AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \ |
| 1120 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\ |
| 1121 | AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \ |
| 1122 | AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \ |
| 1123 | AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \ |
| 1124 | AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR) |
| 1125 | |
| 1126 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1127 | #define MULTI_FLAGS \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1128 | (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \ |
| 1129 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \ |
| 1130 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \ |
| 1131 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \ |
| 1132 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_ENABLE) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1133 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1134 | #define MULTI_MASK 0x7f |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1135 | |
| 1136 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1137 | #define DEF_USB_FUNC_OFF (2 + 2*HC_USTORM_DEF_SB_NUM_INDICES) |
| 1138 | #define DEF_CSB_FUNC_OFF (2 + 2*HC_CSTORM_DEF_SB_NUM_INDICES) |
| 1139 | #define DEF_XSB_FUNC_OFF (2 + 2*HC_XSTORM_DEF_SB_NUM_INDICES) |
| 1140 | #define DEF_TSB_FUNC_OFF (2 + 2*HC_TSTORM_DEF_SB_NUM_INDICES) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1141 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1142 | #define C_DEF_SB_SP_INDEX HC_INDEX_DEF_C_ETH_SLOW_PATH |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1143 | |
| 1144 | #define BNX2X_SP_DSB_INDEX \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1145 | (&bp->def_status_blk->c_def_status_block.index_values[C_DEF_SB_SP_INDEX]) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1146 | |
| 1147 | |
| 1148 | #define CAM_IS_INVALID(x) \ |
| 1149 | (x.target_table_entry.flags == TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) |
| 1150 | |
| 1151 | #define CAM_INVALIDATE(x) \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1152 | (x.target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1153 | |
| 1154 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1155 | /* Number of u32 elements in MC hash array */ |
| 1156 | #define MC_HASH_SIZE 8 |
| 1157 | #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \ |
| 1158 | TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4) |
| 1159 | |
| 1160 | |
| 1161 | #ifndef PXP2_REG_PXP2_INT_STS |
| 1162 | #define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0 |
| 1163 | #endif |
| 1164 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1165 | /* MISC_REG_RESET_REG - this is here for the hsi to work don't touch */ |
| 1166 | |
| 1167 | #endif /* bnx2x.h */ |