Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1 | /* bnx2x.h: Broadcom Everest network driver. |
| 2 | * |
Vladislav Zolotarov | 3359fce | 2010-02-17 13:35:01 -0800 | [diff] [blame] | 3 | * Copyright (c) 2007-2010 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 | |
Dmitry Kravkov | 2514158 | 2010-09-12 05:48:28 +0000 | [diff] [blame] | 23 | #define DRV_MODULE_VERSION "1.52.53-7" |
| 24 | #define DRV_MODULE_RELDATE "2010/09/12" |
Dmitry Kravkov | de0c62d | 2010-07-27 12:35:24 +0000 | [diff] [blame] | 25 | #define BNX2X_BC_VER 0x040200 |
| 26 | |
Eilon Greenstein | 0c6671b | 2009-01-14 21:26:51 -0800 | [diff] [blame] | 27 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
| 28 | #define BCM_VLAN 1 |
| 29 | #endif |
| 30 | |
Eilon Greenstein | 555f6c7 | 2009-02-12 08:36:11 +0000 | [diff] [blame] | 31 | #define BNX2X_MULTI_QUEUE |
| 32 | |
| 33 | #define BNX2X_NEW_NAPI |
| 34 | |
Eilon Greenstein | 359d8b1 | 2009-02-12 08:38:25 +0000 | [diff] [blame] | 35 | |
Vladislav Zolotarov | 1ac218c | 2010-04-19 01:14:18 +0000 | [diff] [blame] | 36 | #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE) |
| 37 | #define BCM_CNIC 1 |
Dmitry Kravkov | 5d1e859 | 2010-07-27 12:31:10 +0000 | [diff] [blame] | 38 | #include "../cnic_if.h" |
Vladislav Zolotarov | 1ac218c | 2010-04-19 01:14:18 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
Vladislav Zolotarov | 1ac218c | 2010-04-19 01:14:18 +0000 | [diff] [blame] | 41 | #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 Greenstein | 01cd452 | 2009-08-12 08:23:08 +0000 | [diff] [blame] | 49 | #include <linux/mdio.h> |
Dmitry Kravkov | 9f6c925 | 2010-07-27 12:34:34 +0000 | [diff] [blame] | 50 | #include <linux/pci.h> |
Eilon Greenstein | 359d8b1 | 2009-02-12 08:38:25 +0000 | [diff] [blame] | 51 | #include "bnx2x_reg.h" |
| 52 | #include "bnx2x_fw_defs.h" |
| 53 | #include "bnx2x_hsi.h" |
| 54 | #include "bnx2x_link.h" |
Dmitry Kravkov | 6c719d0 | 2010-07-27 12:36:15 +0000 | [diff] [blame] | 55 | #include "bnx2x_stats.h" |
Eilon Greenstein | 359d8b1 | 2009-02-12 08:38:25 +0000 | [diff] [blame] | 56 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 57 | /* error/debug prints */ |
| 58 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 59 | #define DRV_MODULE_NAME "bnx2x" |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 60 | |
| 61 | /* for messages that are currently off */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 62 | #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 Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 67 | #define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */ |
| 68 | #define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 69 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 70 | #define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 71 | |
| 72 | /* regular debug print */ |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 73 | #define DP(__mask, __fmt, __args...) \ |
| 74 | do { \ |
| 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 81 | |
| 82 | /* errors debug print */ |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 83 | #define BNX2X_DBG_ERR(__fmt, __args...) \ |
| 84 | do { \ |
| 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 91 | |
| 92 | /* for errors (never masked) */ |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 93 | #define BNX2X_ERR(__fmt, __args...) \ |
| 94 | do { \ |
| 95 | pr_err("[%s:%d(%s)]" __fmt, \ |
| 96 | __func__, __LINE__, \ |
| 97 | bp->dev ? (bp->dev->name) : "?", \ |
| 98 | ##__args); \ |
Vladislav Zolotarov | cdaa7cb | 2010-04-19 01:13:57 +0000 | [diff] [blame] | 99 | } while (0) |
| 100 | |
| 101 | #define BNX2X_ERROR(__fmt, __args...) do { \ |
| 102 | pr_err("[%s:%d]" __fmt, __func__, __LINE__, ##__args); \ |
| 103 | } while (0) |
| 104 | |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 105 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 106 | /* before we have a dev->name use dev_info() */ |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 107 | #define BNX2X_DEV_INFO(__fmt, __args...) \ |
| 108 | do { \ |
| 109 | if (netif_msg_probe(bp)) \ |
| 110 | dev_info(&bp->pdev->dev, __fmt, ##__args); \ |
| 111 | } while (0) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 112 | |
Dmitry Kravkov | 6c719d0 | 2010-07-27 12:36:15 +0000 | [diff] [blame] | 113 | void bnx2x_panic_dump(struct bnx2x *bp); |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 114 | |
| 115 | #ifdef BNX2X_STOP_ON_ERROR |
| 116 | #define bnx2x_panic() do { \ |
| 117 | bp->panic = 1; \ |
| 118 | BNX2X_ERR("driver assert\n"); \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 119 | bnx2x_int_disable(bp); \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 120 | bnx2x_panic_dump(bp); \ |
| 121 | } while (0) |
| 122 | #else |
| 123 | #define bnx2x_panic() do { \ |
Eilon Greenstein | e3553b2 | 2009-08-12 08:23:31 +0000 | [diff] [blame] | 124 | bp->panic = 1; \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 125 | BNX2X_ERR("driver assert\n"); \ |
| 126 | bnx2x_panic_dump(bp); \ |
| 127 | } while (0) |
| 128 | #endif |
| 129 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 130 | #define bnx2x_mc_addr(ha) ((ha)->addr) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 131 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 132 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 135 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 136 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 137 | #define REG_ADDR(bp, offset) ((bp->regview) + (offset)) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 138 | |
| 139 | #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset)) |
| 140 | #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset)) |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 141 | #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset)) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 142 | |
| 143 | #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] | 144 | #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] | 145 | #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 146 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 147 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 149 | |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 150 | #define REG_RD_DMAE(bp, offset, valp, len32) \ |
| 151 | do { \ |
| 152 | bnx2x_read_dmae(bp, offset, len32);\ |
Eilon Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 153 | memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \ |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 154 | } while (0) |
| 155 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 156 | #define REG_WR_DMAE(bp, offset, valp, len32) \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 157 | do { \ |
Eilon Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 158 | memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 159 | bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \ |
| 160 | offset, len32); \ |
| 161 | } while (0) |
| 162 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 163 | #define REG_WR_DMAE_LEN(bp, offset, valp, len32) \ |
| 164 | REG_WR_DMAE(bp, offset, valp, len32) |
| 165 | |
Vladislav Zolotarov | 3359fce | 2010-02-17 13:35:01 -0800 | [diff] [blame] | 166 | #define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \ |
Eilon Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 167 | do { \ |
| 168 | memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \ |
| 169 | bnx2x_write_big_buf_wb(bp, addr, len32); \ |
| 170 | } while (0) |
| 171 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 172 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 176 | |
Eilon Greenstein | 2691d51 | 2009-08-12 08:22:08 +0000 | [diff] [blame] | 177 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 181 | #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \ |
| 182 | offsetof(struct mf_cfg, field)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 183 | #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \ |
| 184 | offsetof(struct mf2_cfg, field)) |
Eilon Greenstein | 2691d51 | 2009-08-12 08:22:08 +0000 | [diff] [blame] | 185 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 186 | #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 Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 189 | #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 Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 193 | |
Eilon Greenstein | 345b5d5 | 2008-08-13 15:58:12 -0700 | [diff] [blame] | 194 | #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg) |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 195 | #define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 196 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 197 | /* 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 Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 228 | #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \ |
| 229 | AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |
| 230 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 231 | #define SM_RX_ID 0 |
| 232 | #define SM_TX_ID 1 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 233 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 234 | /* fast path */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 235 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 236 | struct sw_rx_bd { |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 237 | struct sk_buff *skb; |
FUJITA Tomonori | 1a98314 | 2010-04-04 01:51:03 +0000 | [diff] [blame] | 238 | DEFINE_DMA_UNMAP_ADDR(mapping); |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | struct sw_tx_bd { |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 242 | struct sk_buff *skb; |
| 243 | u16 first_bd; |
Eilon Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 244 | u8 flags; |
| 245 | /* Set on the first BD descriptor when there is a split BD */ |
| 246 | #define BNX2X_TSO_SPLIT_BD (1<<0) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 247 | }; |
| 248 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 249 | struct sw_rx_page { |
| 250 | struct page *page; |
FUJITA Tomonori | 1a98314 | 2010-04-04 01:51:03 +0000 | [diff] [blame] | 251 | DEFINE_DMA_UNMAP_ADDR(mapping); |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 252 | }; |
| 253 | |
Eilon Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 254 | union db_prod { |
| 255 | struct doorbell_set_prod data; |
| 256 | u32 raw; |
| 257 | }; |
| 258 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 259 | |
| 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 Greenstein | 4f40f2c | 2009-01-14 21:24:17 -0800 | [diff] [blame] | 268 | #define SGE_PAGE_SIZE PAGE_SIZE |
| 269 | #define SGE_PAGE_SHIFT PAGE_SHIFT |
Eilon Greenstein | 5b6402d | 2009-07-21 05:47:51 +0000 | [diff] [blame] | 270 | #define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr)) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 271 | |
| 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 Greenstein | 3347162 | 2008-08-13 15:59:08 -0700 | [diff] [blame] | 276 | /* RX_SGE_CNT is promised to be a power of 2 */ |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 277 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 302 | union host_hc_status_block { |
| 303 | /* pointer to fp status block e1x */ |
| 304 | struct host_hc_status_block_e1x *e1x_sb; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 305 | /* pointer to fp status block e2 */ |
| 306 | struct host_hc_status_block_e2 *e2_sb; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 307 | }; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 308 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 309 | struct bnx2x_fastpath { |
| 310 | |
Dmitry Kravkov | d6214d7 | 2010-10-06 03:32:10 +0000 | [diff] [blame^] | 311 | #define BNX2X_NAPI_WEIGHT 128 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 312 | struct napi_struct napi; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 313 | 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 320 | dma_addr_t status_blk_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 321 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 322 | struct sw_tx_bd *tx_buf_ring; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 323 | |
Eilon Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 324 | union eth_tx_bd_types *tx_desc_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 325 | dma_addr_t tx_desc_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 326 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 327 | struct sw_rx_bd *rx_buf_ring; /* BDs mappings ring */ |
| 328 | struct sw_rx_page *rx_page_ring; /* SGE pages mappings ring */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 329 | |
| 330 | struct eth_rx_bd *rx_desc_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 331 | dma_addr_t rx_desc_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 332 | |
| 333 | union eth_rx_cqe *rx_comp_ring; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 334 | dma_addr_t rx_comp_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 335 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 336 | /* 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 342 | 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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 349 | #define BNX2X_FP_STATE_TERMINATING 0xd0000 |
| 350 | #define BNX2X_FP_STATE_TERMINATED 0xe0000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 351 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 352 | u8 index; /* number in fp array */ |
| 353 | u8 cl_id; /* eth client id */ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 354 | 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 358 | |
Eilon Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 359 | union db_prod tx_db; |
| 360 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 361 | u16 tx_pkt_prod; |
| 362 | u16 tx_pkt_cons; |
| 363 | u16 tx_bd_prod; |
| 364 | u16 tx_bd_cons; |
Eilon Greenstein | 4781bfa | 2009-02-12 08:38:17 +0000 | [diff] [blame] | 365 | __le16 *tx_cons_sb; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 366 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 367 | __le16 fp_hc_idx; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 368 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 369 | u16 rx_bd_prod; |
| 370 | u16 rx_bd_cons; |
| 371 | u16 rx_comp_prod; |
| 372 | u16 rx_comp_cons; |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 373 | u16 rx_sge_prod; |
| 374 | /* The last maximal completed SGE */ |
| 375 | u16 last_max_sge; |
Eilon Greenstein | 4781bfa | 2009-02-12 08:38:17 +0000 | [diff] [blame] | 376 | __le16 *rx_cons_sb; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 377 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 378 | |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 379 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 380 | unsigned long tx_pkt, |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 381 | rx_pkt, |
Yitchak Gertner | 66e855f | 2008-08-13 15:49:05 -0700 | [diff] [blame] | 382 | rx_calls; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 383 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 384 | /* 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 393 | |
Eilon Greenstein | de832a5 | 2009-02-12 08:36:33 +0000 | [diff] [blame] | 394 | 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 Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 399 | /* 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 405 | struct bnx2x *bp; /* parent */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 406 | }; |
| 407 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 408 | #define bnx2x_fp(bp, nr, var) (bp->fp[nr].var) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 409 | |
| 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 Greenstein | ca00392 | 2009-08-12 22:53:28 -0700 | [diff] [blame] | 416 | #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types)) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 417 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 421 | #define INIT_JUMBO_TX_RING_SIZE MAX_TX_AVAIL |
| 422 | #define INIT_TX_RING_SIZE MAX_TX_AVAIL |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 423 | #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 Kravkov | 2514158 | 2010-09-12 05:48:28 +0000 | [diff] [blame] | 436 | #define MIN_RX_AVAIL 128 |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 437 | #define INIT_JUMBO_RX_RING_SIZE MAX_RX_AVAIL |
| 438 | #define INIT_RX_RING_SIZE MAX_RX_AVAIL |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 439 | #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 Greenstein | 3347162 | 2008-08-13 15:59:08 -0700 | [diff] [blame] | 457 | /* This is needed for determining of last_max */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 458 | #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) |
| 459 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 460 | #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 Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 485 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 489 | #define BNX2X_DB_MIN_SHIFT 3 /* 8 bytes */ |
| 490 | #define BNX2X_DB_SHIFT 7 /* 128 bytes*/ |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 491 | #define DPM_TRIGER_TYPE 0x40 |
| 492 | #define DOORBELL(bp, cid, val) \ |
| 493 | do { \ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 494 | writel((u32)(val), bp->doorbells + (bp->db_size * (cid)) + \ |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 495 | 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 518 | /* 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 Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 522 | #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 Greenstein | 1adcd8b | 2008-08-13 15:48:29 -0700 | [diff] [blame] | 527 | #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 Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 543 | |
Eilon Greenstein | 052a38e | 2009-02-12 08:37:16 +0000 | [diff] [blame] | 544 | #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 Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 549 | #define BNX2X_RX_SUM_FIX(cqe) \ |
Eilon Greenstein | 052a38e | 2009-02-12 08:37:16 +0000 | [diff] [blame] | 550 | BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 551 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 552 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 555 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 556 | #define BNX2X_RX_SB_INDEX \ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 557 | (&fp->sb_index_values[U_SB_ETH_RX_CQ_INDEX]) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 558 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 559 | #define BNX2X_TX_SB_INDEX \ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 560 | (&fp->sb_index_values[C_SB_ETH_TX_CQ_INDEX]) |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 561 | |
| 562 | /* end of fast path */ |
| 563 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 564 | /* common */ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 565 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 566 | struct bnx2x_common { |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 567 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 568 | u32 chip_id; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 569 | /* 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] | 570 | #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 571 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 572 | #define CHIP_NUM(bp) (bp->common.chip_id >> 16) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 573 | #define CHIP_NUM_57710 0x164e |
| 574 | #define CHIP_NUM_57711 0x164f |
| 575 | #define CHIP_NUM_57711E 0x1650 |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 576 | #define CHIP_NUM_57712 0x1662 |
| 577 | #define CHIP_NUM_57712E 0x1663 |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 578 | #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 Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 581 | #define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712) |
| 582 | #define CHIP_IS_57712E(bp) (CHIP_NUM(bp) == CHIP_NUM_57712E) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 583 | #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \ |
| 584 | CHIP_IS_57711E(bp)) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 585 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 589 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 590 | #define CHIP_REV(bp) (bp->common.chip_id & 0x0000f000) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 591 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 600 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 601 | #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \ |
| 602 | ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1)) |
| 603 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 604 | #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0) |
| 605 | #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 606 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 607 | 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 611 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 612 | u32 shmem_base; |
Eilon Greenstein | 2691d51 | 2009-08-12 08:22:08 +0000 | [diff] [blame] | 613 | u32 shmem2_base; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 614 | u32 mf_cfg_base; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 615 | u32 mf2_cfg_base; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 616 | |
| 617 | u32 hw_config; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 618 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 619 | u32 bc_ver; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 620 | |
| 621 | u8 int_block; |
| 622 | #define INT_BLOCK_HC 0 |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 623 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 631 | u8 chip_port_mode; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 632 | #define CHIP_4_PORT_MODE 0x0 |
| 633 | #define CHIP_2_PORT_MODE 0x1 |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 634 | #define CHIP_PORT_MODE_NONE 0x2 |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 635 | #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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 637 | }; |
| 638 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 639 | /* 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 642 | |
| 643 | /* end of common */ |
| 644 | |
| 645 | /* port */ |
| 646 | |
| 647 | struct bnx2x_port { |
| 648 | u32 pmf; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 649 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 650 | u32 link_config[LINK_CONFIG_SIZE]; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 651 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 652 | u32 supported[LINK_CONFIG_SIZE]; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 653 | /* link settings - missing defines */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 654 | #define SUPPORTED_2500baseX_Full (1 << 15) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 655 | |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 656 | u32 advertising[LINK_CONFIG_SIZE]; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 657 | /* link settings - missing defines */ |
| 658 | #define ADVERTISED_2500baseX_Full (1 << 15) |
| 659 | |
| 660 | u32 phy_addr; |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 661 | |
| 662 | /* used to synchronize phy accesses */ |
| 663 | struct mutex phy_mutex; |
Eilon Greenstein | 46c6a67 | 2009-02-12 08:36:58 +0000 | [diff] [blame] | 664 | int need_hw_lock; |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 665 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 666 | u32 port_stx; |
| 667 | |
| 668 | struct nig_stats old_nig_stats; |
| 669 | }; |
| 670 | |
| 671 | /* end of port */ |
| 672 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 673 | /* e1h Classification CAM line allocations */ |
| 674 | enum { |
| 675 | CAM_ETH_LINE = 0, |
| 676 | CAM_ISCSI_ETH_LINE, |
| 677 | CAM_MAX_PF_LINE = CAM_ISCSI_ETH_LINE |
| 678 | }; |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 679 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 680 | #define BNX2X_VF_ID_INVALID 0xFF |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 681 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 682 | /* |
| 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 Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 705 | #define FP_SB_MAX_E2 16 /* fast-path interrupt contexts E2 */ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 706 | |
| 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 717 | |
| 718 | union cdu_context { |
| 719 | struct eth_context eth; |
| 720 | char pad[1024]; |
| 721 | }; |
| 722 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 723 | /* 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 Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 757 | #define MAX_DMAE_C 8 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 758 | |
| 759 | /* DMA memory not used in fastpath */ |
| 760 | struct bnx2x_slowpath { |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 761 | struct eth_stats_query fw_stats; |
| 762 | struct mac_configuration_cmd mac_config; |
| 763 | struct mac_configuration_cmd mcast_config; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 764 | struct client_init_ramrod_data client_init_data; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 765 | |
| 766 | /* used by dmae command executer */ |
| 767 | struct dmae_command dmae[MAX_DMAE_C]; |
| 768 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 769 | 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 Greenstein | 6fe49bb | 2009-08-12 08:23:17 +0000 | [diff] [blame] | 774 | struct host_func_stats func_stats_base; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 775 | |
| 776 | u32 wb_comp; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 777 | 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 783 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 784 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 785 | /* attn group wiring */ |
| 786 | #define MAX_DYNAMIC_ATTN_GRPS 8 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 787 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 788 | struct attn_route { |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 789 | u32 sig[5]; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 790 | }; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 791 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 792 | struct iro { |
| 793 | u32 base; |
| 794 | u16 m1; |
| 795 | u16 m2; |
| 796 | u16 m3; |
| 797 | u16 size; |
| 798 | }; |
| 799 | |
| 800 | struct hw_context { |
| 801 | union cdu_context *vcxt; |
| 802 | dma_addr_t cxt_mapping; |
| 803 | size_t size; |
| 804 | }; |
| 805 | |
| 806 | /* forward */ |
| 807 | struct bnx2x_ilt; |
| 808 | |
Vladislav Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 809 | typedef enum { |
| 810 | BNX2X_RECOVERY_DONE, |
| 811 | BNX2X_RECOVERY_INIT, |
| 812 | BNX2X_RECOVERY_WAIT, |
| 813 | } bnx2x_recovery_state_t; |
| 814 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 815 | /** |
| 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 837 | struct bnx2x { |
| 838 | /* Fields used in the tx and intr/napi performance paths |
| 839 | * are grouped together in the beginning of the structure |
| 840 | */ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 841 | struct bnx2x_fastpath *fp; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 842 | void __iomem *regview; |
| 843 | void __iomem *doorbells; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 844 | u16 db_size; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 845 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 846 | struct net_device *dev; |
| 847 | struct pci_dev *pdev; |
| 848 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 849 | struct iro *iro_arr; |
| 850 | #define IRO (bp->iro_arr) |
| 851 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 852 | atomic_t intr_sem; |
Vladislav Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 853 | |
| 854 | bnx2x_recovery_state_t recovery_state; |
| 855 | int is_leader; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 856 | struct msix_entry *msix_table; |
Eilon Greenstein | 8badd27 | 2009-02-12 08:36:15 +0000 | [diff] [blame] | 857 | #define INT_MODE_INTx 1 |
| 858 | #define INT_MODE_MSI 2 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 859 | |
| 860 | int tx_ring_size; |
| 861 | |
| 862 | #ifdef BCM_VLAN |
| 863 | struct vlan_group *vlgrp; |
| 864 | #endif |
| 865 | |
| 866 | u32 rx_csum; |
Eilon Greenstein | 437cf2f | 2008-09-03 14:38:00 -0700 | [diff] [blame] | 867 | u32 rx_buf_size; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 868 | /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */ |
| 869 | #define ETH_OVREHEAD (ETH_HLEN + 8 + 8) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 870 | #define ETH_MIN_PACKET_SIZE 60 |
| 871 | #define ETH_MAX_PACKET_SIZE 1500 |
| 872 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
| 873 | |
Eilon Greenstein | 0f00846 | 2009-02-12 08:36:18 +0000 | [diff] [blame] | 874 | /* 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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 878 | #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5) |
Eilon Greenstein | 0f00846 | 2009-02-12 08:36:18 +0000 | [diff] [blame] | 879 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 880 | 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 Greenstein | 4781bfa | 2009-02-12 08:38:17 +0000 | [diff] [blame] | 884 | __le16 def_att_idx; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 885 | u32 attn_state; |
| 886 | struct attn_route attn_group[MAX_DYNAMIC_ATTN_GRPS]; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 887 | |
| 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 Greenstein | 4781bfa | 2009-02-12 08:38:17 +0000 | [diff] [blame] | 894 | __le16 *dsb_sp_prod; |
Dmitry Kravkov | 8fe23fb | 2010-10-06 03:27:41 +0000 | [diff] [blame] | 895 | atomic_t spq_left; /* serialize spq */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 896 | /* used to synchronize spq accesses */ |
| 897 | spinlock_t spq_lock; |
| 898 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 899 | /* 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 Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 906 | /* Flags for marking that there is a STAT_QUERY or |
| 907 | SET_MAC ramrod pending */ |
Michael Chan | e665bfd | 2009-10-10 13:46:54 +0000 | [diff] [blame] | 908 | int stats_pending; |
| 909 | int set_mac_pending; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 910 | |
Eilon Greenstein | 3347162 | 2008-08-13 15:59:08 -0700 | [diff] [blame] | 911 | /* End of fields used in the performance code paths */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 912 | |
| 913 | int panic; |
Joe Perches | 7995c64 | 2010-02-17 15:01:52 +0000 | [diff] [blame] | 914 | int msg_enable; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 915 | |
| 916 | u32 flags; |
| 917 | #define PCIX_FLAG 1 |
| 918 | #define PCI_32BIT_FLAG 2 |
Eilon Greenstein | 1c06328 | 2009-02-12 08:36:43 +0000 | [diff] [blame] | 919 | #define ONE_PORT_FLAG 4 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 920 | #define NO_WOL_FLAG 8 |
| 921 | #define USING_DAC_FLAG 0x10 |
| 922 | #define USING_MSIX_FLAG 0x20 |
Eilon Greenstein | 8badd27 | 2009-02-12 08:36:15 +0000 | [diff] [blame] | 923 | #define USING_MSI_FLAG 0x40 |
Dmitry Kravkov | d6214d7 | 2010-10-06 03:32:10 +0000 | [diff] [blame^] | 924 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 925 | #define TPA_ENABLE_FLAG 0x80 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 926 | #define NO_MCP_FLAG 0x100 |
Dmitry Kravkov | d6214d7 | 2010-10-06 03:32:10 +0000 | [diff] [blame^] | 927 | #define DISABLE_MSI_FLAG 0x200 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 928 | #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) |
Eilon Greenstein | 0c6671b | 2009-01-14 21:26:51 -0800 | [diff] [blame] | 929 | #define HW_VLAN_TX_FLAG 0x400 |
| 930 | #define HW_VLAN_RX_FLAG 0x800 |
Eilon Greenstein | f34d28e | 2009-10-15 00:18:08 -0700 | [diff] [blame] | 931 | #define MF_FUNC_DIS 0x1000 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 932 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 933 | int pf_num; /* absolute PF number */ |
| 934 | int pfid; /* per-path PF number */ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 935 | int base_fw_ndsb; |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 936 | #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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 944 | #define BP_L_ID(bp) (BP_E1HVN(bp) << 2) |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 945 | #define BP_FW_MB_IDX(bp) (BP_PORT(bp) +\ |
| 946 | BP_VN(bp) * (CHIP_IS_E1x(bp) ? 2 : 1)) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 947 | |
Michael Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 948 | #ifdef BCM_CNIC |
| 949 | #define BCM_CNIC_CID_START 16 |
| 950 | #define BCM_ISCSI_ETH_CL_ID 17 |
| 951 | #endif |
| 952 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 953 | int pm_cap; |
| 954 | int pcie_cap; |
Eilon Greenstein | 8d5726c | 2009-02-12 08:37:19 +0000 | [diff] [blame] | 955 | int mrrs; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 956 | |
Eilon Greenstein | 1cf167f | 2009-01-14 21:22:18 -0800 | [diff] [blame] | 957 | struct delayed_work sp_task; |
Vladislav Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 958 | struct delayed_work reset_task; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 959 | struct timer_list timer; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 960 | 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 Greenstein | 01cd452 | 2009-08-12 08:23:08 +0000 | [diff] [blame] | 968 | struct mdio_if_info mdio; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 969 | |
| 970 | struct bnx2x_common common; |
| 971 | struct bnx2x_port port; |
| 972 | |
Eilon Greenstein | 8a1c38d | 2009-02-12 08:36:40 +0000 | [diff] [blame] | 973 | struct cmng_struct_per_port cmng; |
| 974 | u32 vn_weight_sum; |
| 975 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 976 | u32 mf_config[E1HVN_MAX]; |
| 977 | u32 mf2_config[E2_FUNC_MAX]; |
Dmitry Kravkov | fb3bff1 | 2010-10-06 03:26:40 +0000 | [diff] [blame] | 978 | u16 mf_ov; |
| 979 | u8 mf_mode; |
| 980 | #define IS_MF(bp) (bp->mf_mode != 0) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 981 | |
Eliezer Tamir | f141064 | 2008-02-28 11:51:50 -0800 | [diff] [blame] | 982 | u8 wol; |
| 983 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 984 | int rx_ring_size; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 985 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 986 | u16 tx_quick_cons_trip_int; |
| 987 | u16 tx_quick_cons_trip; |
| 988 | u16 tx_ticks_int; |
| 989 | u16 tx_ticks; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 990 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 991 | u16 rx_quick_cons_trip_int; |
| 992 | u16 rx_quick_cons_trip; |
| 993 | u16 rx_ticks_int; |
| 994 | u16 rx_ticks; |
Vladislav Zolotarov | cdaa7cb | 2010-04-19 01:13:57 +0000 | [diff] [blame] | 995 | /* Maximal coalescing timeout in us */ |
| 996 | #define BNX2X_MAX_COALESCE_TOUT (0xf0*12) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 997 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 998 | u32 lin_cnt; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 999 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1000 | int state; |
Eilon Greenstein | 356e238 | 2009-02-12 08:38:32 +0000 | [diff] [blame] | 1001 | #define BNX2X_STATE_CLOSED 0 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1002 | #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000 |
| 1003 | #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1004 | #define BNX2X_STATE_OPEN 0x3000 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1005 | #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1006 | #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000 |
| 1007 | #define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000 |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1008 | #define BNX2X_STATE_FUNC_STARTED 0x7000 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1009 | #define BNX2X_STATE_DIAG 0xe000 |
| 1010 | #define BNX2X_STATE_ERROR 0xf000 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1011 | |
Eilon Greenstein | 555f6c7 | 2009-02-12 08:36:11 +0000 | [diff] [blame] | 1012 | int multi_mode; |
Vladislav Zolotarov | 54b9dda | 2009-11-16 06:05:58 +0000 | [diff] [blame] | 1013 | int num_queues; |
Dmitry Kravkov | 5d7cd49 | 2010-07-27 12:32:19 +0000 | [diff] [blame] | 1014 | int disable_tpa; |
| 1015 | int int_mode; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1016 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1017 | 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1026 | 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1033 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1034 | u8 igu_dsb_id; |
| 1035 | u8 igu_base_sb; |
| 1036 | u8 igu_sb_cnt; |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1037 | dma_addr_t def_status_blk_mapping; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1038 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1039 | struct bnx2x_slowpath *slowpath; |
| 1040 | dma_addr_t slowpath_mapping; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1041 | 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1053 | |
Eilon Greenstein | a18f512 | 2009-08-12 08:23:26 +0000 | [diff] [blame] | 1054 | int dropless_fc; |
| 1055 | |
Michael Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 1056 | #ifdef BCM_CNIC |
| 1057 | u32 cnic_flags; |
| 1058 | #define BNX2X_CNIC_FLAG_MAC_SET 1 |
Michael Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 1059 | void *t2; |
| 1060 | dma_addr_t t2_mapping; |
Michael Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 1061 | struct cnic_ops *cnic_ops; |
| 1062 | void *cnic_data; |
| 1063 | u32 cnic_tag; |
| 1064 | struct cnic_eth_dev cnic_eth_dev; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1065 | union host_hc_status_block cnic_sb; |
Michael Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 1066 | dma_addr_t cnic_sb_mapping; |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1067 | #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 Chan | 37b091b | 2009-10-10 13:46:55 +0000 | [diff] [blame] | 1069 | 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 Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1079 | int dmae_ready; |
| 1080 | /* used to synchronize dmae accesses */ |
| 1081 | struct mutex dmae_mutex; |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1082 | |
Eilon Greenstein | c4ff7cb | 2009-10-15 00:18:27 -0700 | [diff] [blame] | 1083 | /* used to protect the FW mail box */ |
| 1084 | struct mutex fw_mb_mutex; |
| 1085 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1086 | /* used to synchronize stats collecting */ |
| 1087 | int stats_state; |
Vladislav Zolotarov | a13773a | 2010-07-21 05:59:01 +0000 | [diff] [blame] | 1088 | |
| 1089 | /* used for synchronization of concurrent threads statistics handling */ |
| 1090 | spinlock_t stats_lock; |
| 1091 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1092 | /* used by dmae command loader */ |
| 1093 | struct dmae_command stats_dmae; |
| 1094 | int executer_idx; |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1095 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1096 | u16 stats_counter; |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1097 | 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 Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1103 | #define FW_BUF_SIZE 0x8000 |
Eilon Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 1104 | #define GUNZIP_BUF(bp) (bp->gunzip_buf) |
| 1105 | #define GUNZIP_PHYS(bp) (bp->gunzip_mapping) |
| 1106 | #define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1107 | |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1108 | struct raw_op *init_ops; |
Vladislav Zolotarov | 94a78b7 | 2009-04-27 03:27:43 -0700 | [diff] [blame] | 1109 | /* Init blocks offsets inside init_ops */ |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1110 | u16 *init_ops_offsets; |
Vladislav Zolotarov | 94a78b7 | 2009-04-27 03:27:43 -0700 | [diff] [blame] | 1111 | /* Data blob - has 32 bit granularity */ |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1112 | u32 *init_data; |
Vladislav Zolotarov | 94a78b7 | 2009-04-27 03:27:43 -0700 | [diff] [blame] | 1113 | /* Zipped PRAM blobs - raw data */ |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1114 | 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 Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 1122 | #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 Zolotarov | 34f24c7 | 2010-04-19 01:13:23 +0000 | [diff] [blame] | 1134 | char fw_ver[32]; |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1135 | const struct firmware *firmware; |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1136 | }; |
| 1137 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1138 | /** |
| 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1164 | |
Vladislav Zolotarov | 54b9dda | 2009-11-16 06:05:58 +0000 | [diff] [blame] | 1165 | #define BNX2X_NUM_QUEUES(bp) (bp->num_queues) |
| 1166 | #define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1) |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1167 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1168 | #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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1170 | |
| 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 | |
| 1194 | struct 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 | |
| 1204 | struct 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 | |
| 1241 | struct 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 | |
| 1260 | struct 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 | |
| 1271 | struct 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 | |
| 1278 | struct bnx2x_rss_params { |
| 1279 | int mode; |
| 1280 | u16 cap; |
| 1281 | u16 result_mask; |
| 1282 | }; |
| 1283 | |
| 1284 | struct 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 Greenstein | 555f6c7 | 2009-02-12 08:36:11 +0000 | [diff] [blame] | 1299 | #define for_each_queue(bp, var) \ |
| 1300 | for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++) |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1301 | #define for_each_nondefault_queue(bp, var) \ |
Vladislav Zolotarov | 54b9dda | 2009-11-16 06:05:58 +0000 | [diff] [blame] | 1302 | for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++) |
Eilon Greenstein | 3196a88 | 2008-08-13 15:58:49 -0700 | [diff] [blame] | 1303 | |
| 1304 | |
Yaniv Rosner | c18487e | 2008-06-23 20:27:52 -0700 | [diff] [blame] | 1305 | void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32); |
| 1306 | void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, |
| 1307 | u32 len32); |
Eilon Greenstein | 4acac6a | 2009-02-12 08:36:52 +0000 | [diff] [blame] | 1308 | int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port); |
Eilon Greenstein | 17de50b | 2008-08-13 15:56:59 -0700 | [diff] [blame] | 1309 | int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); |
Eilon Greenstein | 4acac6a | 2009-02-12 08:36:52 +0000 | [diff] [blame] | 1310 | int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 1311 | u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param); |
Eilon Greenstein | 573f203 | 2009-08-12 08:24:14 +0000 | [diff] [blame] | 1312 | void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val); |
| 1313 | void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr, |
| 1314 | u32 addr, u32 len); |
Dmitry Kravkov | de0c62d | 2010-07-27 12:35:24 +0000 | [diff] [blame] | 1315 | void bnx2x_calc_fc_adv(struct bnx2x *bp); |
| 1316 | int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, |
| 1317 | u32 data_hi, u32 data_lo, int common); |
| 1318 | void bnx2x_update_coalesce(struct bnx2x *bp); |
Yaniv Rosner | a22f078 | 2010-09-07 11:41:20 +0000 | [diff] [blame] | 1319 | int bnx2x_get_link_cfg_idx(struct bnx2x *bp); |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1320 | static 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 Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1336 | #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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1368 | |
| 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 Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 1376 | #define UNLOAD_RECOVERY 2 |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1377 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1378 | |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1379 | /* DMAE command defines */ |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1380 | #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 Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1384 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1385 | #define DMAE_SRC_PCI 0 |
| 1386 | #define DMAE_SRC_GRC 1 |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1387 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1388 | #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 Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1414 | |
| 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 Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1429 | #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 Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1438 | #define DMAE_LEN32_RD_MAX 0x80 |
Vladislav Zolotarov | 02e3c6c | 2010-04-19 01:13:33 +0000 | [diff] [blame] | 1439 | #define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000) |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1440 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1441 | #define DMAE_COMP_VAL 0x60d0d0ae /* E2 and on - upper bit |
| 1442 | indicates eror */ |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1443 | |
| 1444 | #define MAX_DMAE_C_PER_PORT 8 |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1445 | #define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1446 | BP_E1HVN(bp)) |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1447 | #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ |
Eilon Greenstein | ad8d394 | 2008-06-23 20:29:02 -0700 | [diff] [blame] | 1448 | E1HVN_MAX) |
| 1449 | |
| 1450 | |
Eliezer Tamir | 2504795 | 2008-02-28 11:50:16 -0800 | [diff] [blame] | 1451 | /* 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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1456 | |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1457 | |
Eilon Greenstein | d3d4f49 | 2009-02-12 08:36:27 +0000 | [diff] [blame] | 1458 | #define BNX2X_NUM_TESTS 7 |
Yitchak Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1459 | |
Eilon Greenstein | b5bf906 | 2009-02-12 08:38:08 +0000 | [diff] [blame] | 1460 | #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 Gertner | bb2a0f7 | 2008-06-23 20:33:36 -0700 | [diff] [blame] | 1464 | #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \ |
| 1465 | BNX2X_PHY_LOOPBACK_FAILED) |
Eliezer Tamir | 96fc178 | 2008-02-28 11:57:55 -0800 | [diff] [blame] | 1466 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1467 | |
| 1468 | #define STROM_ASSERT_ARRAY_SIZE 50 |
| 1469 | |
Eliezer Tamir | 96fc178 | 2008-02-28 11:57:55 -0800 | [diff] [blame] | 1470 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1471 | /* must be used on a CID before placing it on a HW ring */ |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1472 | #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \ |
| 1473 | (BP_E1HVN(bp) << 17) | (x)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1474 | |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1475 | #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe)) |
| 1476 | #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1) |
| 1477 | |
| 1478 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1479 | #define BNX2X_BTR 4 |
Vladislav Zolotarov | 7a9b255 | 2008-06-23 20:34:36 -0700 | [diff] [blame] | 1480 | #define MAX_SPQ_PENDING 8 |
| 1481 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1482 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1483 | /* 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 Greenstein | 3347162 | 2008-08-13 15:59:08 -0700 | [diff] [blame] | 1489 | coefficient for calculating the actual t fair */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1490 | #define T_FAIR_COEF 10000000 |
| 1491 | /* number of bytes in single QM arbitration cycle - |
Eilon Greenstein | 3347162 | 2008-08-13 15:59:08 -0700 | [diff] [blame] | 1492 | coefficient for calculating the fairness timer */ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1493 | #define QM_ARB_BYTES 40000 |
| 1494 | #define FAIR_MEM 2 |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1495 | |
| 1496 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1497 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1518 | #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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1527 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1535 | #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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1540 | #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] | 1541 | 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1557 | #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] | 1558 | AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \ |
| 1559 | AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \ |
| 1560 | AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \ |
Eilon Greenstein | ab6ad5a | 2009-08-12 08:24:29 +0000 | [diff] [blame] | 1561 | AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\ |
| 1562 | AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\ |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1563 | 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 Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1574 | #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] | 1575 | 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 Zolotarov | 72fd071 | 2010-04-19 01:13:12 +0000 | [diff] [blame] | 1582 | #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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1586 | |
Tom Herbert | c68ed25 | 2010-04-23 00:10:52 -0700 | [diff] [blame] | 1587 | #define RSS_FLAGS(bp) \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1588 | (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 Greenstein | 555f6c7 | 2009-02-12 08:36:11 +0000 | [diff] [blame] | 1592 | (bp->multi_mode << \ |
| 1593 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT)) |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1594 | #define MULTI_MASK 0x7f |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1595 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1596 | #define BNX2X_SP_DSB_INDEX \ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1597 | (&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 Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1604 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1605 | #define GET_FLAG(value, mask) \ |
| 1606 | (((value) &= (mask)) >> (mask##_SHIFT)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1607 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1608 | #define GET_FIELD(value, fname) \ |
| 1609 | (((value) & (fname##_MASK)) >> (fname##_SHIFT)) |
| 1610 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1611 | #define CAM_IS_INVALID(x) \ |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1612 | (GET_FLAG(x.flags, \ |
| 1613 | MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \ |
| 1614 | (T_ETH_MAC_COMMAND_INVALIDATE)) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1615 | |
| 1616 | #define CAM_INVALIDATE(x) \ |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1617 | (x.target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1618 | |
| 1619 | |
Eilon Greenstein | 34f80b0 | 2008-06-23 20:33:01 -0700 | [diff] [blame] | 1620 | /* 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 Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1630 | #ifndef ETH_MAX_RX_CLIENTS_E2 |
| 1631 | #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H |
| 1632 | #endif |
Vladislav Zolotarov | 34f24c7 | 2010-04-19 01:13:23 +0000 | [diff] [blame] | 1633 | #define BNX2X_VPD_LEN 128 |
| 1634 | #define VENDOR_ID_LEN 4 |
| 1635 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1636 | /* 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 Kravkov | b0efbb9 | 2010-07-27 12:33:43 +0000 | [diff] [blame] | 1644 | #ifdef BNX2X_MAIN |
| 1645 | #define BNX2X_EXTERN |
| 1646 | #else |
| 1647 | #define BNX2X_EXTERN extern |
| 1648 | #endif |
| 1649 | |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1650 | BNX2X_EXTERN int load_count[2][3]; /* per path: 0-common, 1-port0, 2-port1 */ |
Dmitry Kravkov | b0efbb9 | 2010-07-27 12:33:43 +0000 | [diff] [blame] | 1651 | |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1652 | /* MISC_REG_RESET_REG - this is here for the hsi to work don't touch */ |
| 1653 | |
Dmitry Kravkov | de0c62d | 2010-07-27 12:35:24 +0000 | [diff] [blame] | 1654 | extern void bnx2x_set_ethtool_ops(struct net_device *netdev); |
| 1655 | |
Dmitry Kravkov | 6c719d0 | 2010-07-27 12:36:15 +0000 | [diff] [blame] | 1656 | void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx); |
Dmitry Kravkov | f2e0899 | 2010-10-06 03:28:26 +0000 | [diff] [blame] | 1657 | u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type); |
| 1658 | u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode); |
| 1659 | u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type, |
| 1660 | bool with_comp, u8 comp_type); |
| 1661 | |
Dmitry Kravkov | 6c719d0 | 2010-07-27 12:36:15 +0000 | [diff] [blame] | 1662 | |
Dmitry Kravkov | 523224a | 2010-10-06 03:23:26 +0000 | [diff] [blame] | 1663 | #define WAIT_RAMROD_POLL 0x01 |
| 1664 | #define WAIT_RAMROD_COMMON 0x02 |
| 1665 | |
| 1666 | int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx, |
| 1667 | int *state_p, int flags); |
Eliezer Tamir | a2fbb9e | 2007-11-15 20:09:02 +0200 | [diff] [blame] | 1668 | #endif /* bnx2x.h */ |