Go to the documentation of this file.
16 #include <linux/netdevice.h>
18 #include <linux/types.h>
26 #define DRV_MODULE_VERSION "1.78.00-0"
27 #define DRV_MODULE_RELDATE "2012/09/27"
28 #define BNX2X_BC_VER 0x040200
30 #if defined(CONFIG_DCB)
37 #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
39 #include "../cnic_if.h"
43 #define BNX2X_MIN_MSIX_VEC_CNT 3
44 #define BNX2X_MSIX_VEC_FP_START 2
46 #define BNX2X_MIN_MSIX_VEC_CNT 2
47 #define BNX2X_MSIX_VEC_FP_START 1
50 #include <linux/mdio.h>
63 #define DRV_MODULE_NAME "bnx2x"
66 #define BNX2X_MSG_OFF 0x0
67 #define BNX2X_MSG_MCP 0x0010000
68 #define BNX2X_MSG_STATS 0x0020000
69 #define BNX2X_MSG_NVM 0x0040000
70 #define BNX2X_MSG_DMAE 0x0080000
71 #define BNX2X_MSG_SP 0x0100000
72 #define BNX2X_MSG_FP 0x0200000
73 #define BNX2X_MSG_IOV 0x0800000
74 #define BNX2X_MSG_IDLE 0x2000000
75 #define BNX2X_MSG_ETHTOOL 0x4000000
76 #define BNX2X_MSG_DCB 0x8000000
79 #define DP(__mask, fmt, ...) \
81 if (unlikely(bp->msg_enable & (__mask))) \
82 pr_notice("[%s:%d(%s)]" fmt, \
84 bp->dev ? (bp->dev->name) : "?", \
88 #define DP_CONT(__mask, fmt, ...) \
90 if (unlikely(bp->msg_enable & (__mask))) \
91 pr_cont(fmt, ##__VA_ARGS__); \
95 #define BNX2X_DBG_ERR(fmt, ...) \
97 if (unlikely(netif_msg_probe(bp))) \
98 pr_err("[%s:%d(%s)]" fmt, \
100 bp->dev ? (bp->dev->name) : "?", \
105 #define BNX2X_ERR(fmt, ...) \
107 pr_err("[%s:%d(%s)]" fmt, \
108 __func__, __LINE__, \
109 bp->dev ? (bp->dev->name) : "?", \
113 #define BNX2X_ERROR(fmt, ...) \
114 pr_err("[%s:%d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
118 #define BNX2X_DEV_INFO(fmt, ...) \
120 if (unlikely(netif_msg_probe(bp))) \
121 dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__); \
124 #ifdef BNX2X_STOP_ON_ERROR
126 #define bnx2x_panic() \
129 BNX2X_ERR("driver assert\n"); \
130 bnx2x_int_disable(bp); \
131 bnx2x_panic_dump(bp); \
134 #define bnx2x_panic() \
137 BNX2X_ERR("driver assert\n"); \
138 bnx2x_panic_dump(bp); \
142 #define bnx2x_mc_addr(ha) ((ha)->addr)
143 #define bnx2x_uc_addr(ha) ((ha)->addr)
145 #define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff)
146 #define U64_HI(x) (u32)(((u64)(x)) >> 32)
147 #define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
150 #define REG_ADDR(bp, offset) ((bp->regview) + (offset))
152 #define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
153 #define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
154 #define REG_RD16(bp, offset) readw(REG_ADDR(bp, offset))
156 #define REG_WR(bp, offset, val) writel((u32)val, REG_ADDR(bp, offset))
157 #define REG_WR8(bp, offset, val) writeb((u8)val, REG_ADDR(bp, offset))
158 #define REG_WR16(bp, offset, val) writew((u16)val, REG_ADDR(bp, offset))
160 #define REG_RD_IND(bp, offset) bnx2x_reg_rd_ind(bp, offset)
161 #define REG_WR_IND(bp, offset, val) bnx2x_reg_wr_ind(bp, offset, val)
163 #define REG_RD_DMAE(bp, offset, valp, len32) \
165 bnx2x_read_dmae(bp, offset, len32);\
166 memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
169 #define REG_WR_DMAE(bp, offset, valp, len32) \
171 memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
172 bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
176 #define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
177 REG_WR_DMAE(bp, offset, valp, len32)
179 #define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
181 memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
182 bnx2x_write_big_buf_wb(bp, addr, len32); \
185 #define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \
186 offsetof(struct shmem_region, field))
187 #define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field))
188 #define SHMEM_WR(bp, field, val) REG_WR(bp, SHMEM_ADDR(bp, field), val)
190 #define SHMEM2_ADDR(bp, field) (bp->common.shmem2_base + \
191 offsetof(struct shmem2_region, field))
192 #define SHMEM2_RD(bp, field) REG_RD(bp, SHMEM2_ADDR(bp, field))
193 #define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val)
194 #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \
195 offsetof(struct mf_cfg, field))
196 #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \
197 offsetof(struct mf2_cfg, field))
199 #define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field))
200 #define MF_CFG_WR(bp, field, val) REG_WR(bp,\
201 MF_CFG_ADDR(bp, field), (val))
202 #define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field))
204 #define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \
205 (SHMEM2_RD((bp), size) > \
206 offsetof(struct shmem2_region, field)))
208 #define EMAC_RD(bp, reg) REG_RD(bp, emac_base + reg)
209 #define EMAC_WR(bp, reg, val) REG_WR(bp, emac_base + reg, val)
214 #define HC_SP_INDEX_ETH_DEF_CONS 3
217 #define HC_SP_INDEX_EQ_CONS 7
220 #define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS 6
221 #define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS 4
223 #define HC_SP_INDEX_ETH_ISCSI_CQ_CONS 5
224 #define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS 1
230 #define BNX2X_FCOE_L2_RX_INDEX \
231 (&bp->def_status_blk->sp_sb.\
232 index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS])
234 #define BNX2X_FCOE_L2_TX_INDEX \
235 (&bp->def_status_blk->sp_sb.\
236 index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS])
252 #define BNX2X_CNIC_START_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) *\
255 #define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp))
257 #define BNX2X_FCOE_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp) + 1)
261 #define CNIC_PRESENT 1
262 #define FCOE_PRESENT 1
264 #define CNIC_PRESENT 0
265 #define FCOE_PRESENT 0
267 #define NON_ETH_CONTEXT_USE (FCOE_PRESENT)
269 #define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
270 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
276 #define FIRST_TX_ONLY_COS_INDEX 1
277 #define FIRST_TX_COS_INDEX 0
280 #define CID_TO_FP(cid, bp) ((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp))
281 #define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \
282 (cid + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
285 #define FP_COS_TO_TXQ(fp, cos, bp) \
286 ((fp)->index + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
299 #define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
301 #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
320 #define BNX2X_TSO_SPLIT_BD (1<<0)
334 #define BRB_SIZE(bp) (CHIP_IS_E3(bp) ? 1024 : 512)
335 #define MAX_AGG_QS(bp) (CHIP_IS_E1(bp) ? \
336 ETH_MAX_AGGREGATION_QUEUES_E1 :\
337 ETH_MAX_AGGREGATION_QUEUES_E1H_E2)
338 #define FW_DROP_LEVEL(bp) (3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp))
339 #define FW_PREFETCH_CNT 16
340 #define DROPLESS_FC_HEADROOM 100
343 #define BCM_PAGE_SHIFT 12
344 #define BCM_PAGE_SIZE (1 << BCM_PAGE_SHIFT)
345 #define BCM_PAGE_MASK (~(BCM_PAGE_SIZE - 1))
346 #define BCM_PAGE_ALIGN(addr) (((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
348 #define PAGES_PER_SGE_SHIFT 0
349 #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
350 #define SGE_PAGE_SIZE PAGE_SIZE
351 #define SGE_PAGE_SHIFT PAGE_SHIFT
352 #define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr))
355 #define NUM_RX_SGE_PAGES 2
356 #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
357 #define NEXT_PAGE_SGE_DESC_CNT 2
358 #define MAX_RX_SGE_CNT (RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT)
360 #define RX_SGE_MASK (RX_SGE_CNT - 1)
361 #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES)
362 #define MAX_RX_SGE (NUM_RX_SGE - 1)
363 #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \
364 (MAX_RX_SGE_CNT - 1)) ? \
365 (x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \
367 #define RX_SGE(x) ((x) & MAX_RX_SGE)
378 #define NUM_SGE_REQ (MAX_AGG_QS(bp) + \
379 (BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2)
380 #define NUM_SGE_PG_REQ ((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \
382 #define SGE_TH_LO(bp) (NUM_SGE_REQ + \
383 NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT)
384 #define SGE_TH_HI(bp) (SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM)
389 #define BIT_VEC64_ELEM_SZ 64
390 #define BIT_VEC64_ELEM_SHIFT 6
391 #define BIT_VEC64_ELEM_MASK ((u64)BIT_VEC64_ELEM_SZ - 1)
394 #define __BIT_VEC64_SET_BIT(el, bit) \
396 el = ((el) | ((u64)0x1 << (bit))); \
399 #define __BIT_VEC64_CLEAR_BIT(el, bit) \
401 el = ((el) & (~((u64)0x1 << (bit)))); \
405 #define BIT_VEC64_SET_BIT(vec64, idx) \
406 __BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
407 (idx) & BIT_VEC64_ELEM_MASK)
409 #define BIT_VEC64_CLEAR_BIT(vec64, idx) \
410 __BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
411 (idx) & BIT_VEC64_ELEM_MASK)
413 #define BIT_VEC64_TEST_BIT(vec64, idx) \
414 (((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
415 ((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
419 #define BIT_VEC64_ONES_MASK(idx) \
420 (((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
421 #define BIT_VEC64_ELEM_ONE_MASK ((u64)(~0))
428 #define RX_SGE_MASK_LEN (NUM_RX_SGE / BIT_VEC64_ELEM_SZ)
429 #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1)
430 #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK)
449 #define BNX2X_TPA_START 1
450 #define BNX2X_TPA_STOP 2
451 #define BNX2X_TPA_ERROR 3
462 #define Q_STATS_OFFSET32(stat_name) \
463 (offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
498 #define BNX2X_NAPI_WEIGHT 128
556 #ifdef BNX2X_STOP_ON_ERROR
563 #define FP_NAME_SIZE (sizeof(((struct net_device *)0)->name) + 8)
567 #define bnx2x_fp(bp, nr, var) ((bp)->fp[(nr)].var)
568 #define bnx2x_sp_obj(bp, fp) ((bp)->sp_objs[(fp)->index])
569 #define bnx2x_fp_stats(bp, fp) (&((bp)->fp_stats[(fp)->index]))
570 #define bnx2x_fp_qstats(bp, fp) (&((bp)->fp_stats[(fp)->index].eth_q_stats))
573 #define BNX2X_FCOE_MINI_JUMBO_MTU 2500
575 #define FCOE_IDX_OFFSET 0
577 #define FCOE_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) + \
579 #define bnx2x_fcoe_fp(bp) (&bp->fp[FCOE_IDX(bp)])
580 #define bnx2x_fcoe(bp, var) (bnx2x_fcoe_fp(bp)->var)
581 #define bnx2x_fcoe_inner_sp_obj(bp) (&bp->sp_objs[FCOE_IDX(bp)])
582 #define bnx2x_fcoe_sp_obj(bp, var) (bnx2x_fcoe_inner_sp_obj(bp)->var)
583 #define bnx2x_fcoe_tx(bp, var) (bnx2x_fcoe_fp(bp)-> \
584 txdata_ptr[FIRST_TX_COS_INDEX] \
588 #define IS_ETH_FP(fp) (fp->index < \
589 BNX2X_NUM_ETH_QUEUES(fp->bp))
591 #define IS_FCOE_FP(fp) (fp->index == FCOE_IDX(fp->bp))
592 #define IS_FCOE_IDX(idx) ((idx) == FCOE_IDX(bp))
594 #define IS_FCOE_FP(fp) false
595 #define IS_FCOE_IDX(idx) false
600 #define MAX_FETCH_BD 13
601 #define RX_COPY_THRESH 92
603 #define NUM_TX_RINGS 16
604 #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
605 #define NEXT_PAGE_TX_DESC_CNT 1
606 #define MAX_TX_DESC_CNT (TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT)
607 #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS)
608 #define MAX_TX_BD (NUM_TX_BD - 1)
609 #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
610 #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \
611 (MAX_TX_DESC_CNT - 1)) ? \
612 (x) + 1 + NEXT_PAGE_TX_DESC_CNT : \
614 #define TX_BD(x) ((x) & MAX_TX_BD)
615 #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT)
618 #define NEXT_CNT_PER_TX_PKT(bds) \
619 (((bds) + MAX_TX_DESC_CNT - 1) / \
620 MAX_TX_DESC_CNT * NEXT_PAGE_TX_DESC_CNT)
627 #define BDS_PER_TX_PKT 3
628 #define MAX_BDS_PER_TX_PKT (MAX_SKB_FRAGS + BDS_PER_TX_PKT)
630 #define MAX_DESC_PER_TX_PKT (MAX_BDS_PER_TX_PKT + \
631 NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))
634 #define NUM_RX_RINGS 8
635 #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
636 #define NEXT_PAGE_RX_DESC_CNT 2
637 #define MAX_RX_DESC_CNT (RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT)
638 #define RX_DESC_MASK (RX_DESC_CNT - 1)
639 #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS)
640 #define MAX_RX_BD (NUM_RX_BD - 1)
641 #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
649 #define NUM_BD_REQ BRB_SIZE(bp)
650 #define NUM_BD_PG_REQ ((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \
652 #define BD_TH_LO(bp) (NUM_BD_REQ + \
653 NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \
655 #define BD_TH_HI(bp) (BD_TH_LO(bp) + DROPLESS_FC_HEADROOM)
657 #define MIN_RX_AVAIL ((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128)
659 #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \
660 ETH_MIN_RX_CQES_WITH_TPA_E1 : \
661 ETH_MIN_RX_CQES_WITH_TPA_E1H_E2)
662 #define MIN_RX_SIZE_NONTPA_HW ETH_MIN_RX_CQES_WITHOUT_TPA
663 #define MIN_RX_SIZE_TPA (max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL))
664 #define MIN_RX_SIZE_NONTPA (max_t(u32, MIN_RX_SIZE_NONTPA_HW,\
667 #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \
668 (MAX_RX_DESC_CNT - 1)) ? \
669 (x) + 1 + NEXT_PAGE_RX_DESC_CNT : \
671 #define RX_BD(x) ((x) & MAX_RX_BD)
677 #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
678 #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL)
679 #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
680 #define NEXT_PAGE_RCQ_DESC_CNT 1
681 #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT)
682 #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS)
683 #define MAX_RCQ_BD (NUM_RCQ_BD - 1)
684 #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
685 #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \
686 (MAX_RCQ_DESC_CNT - 1)) ? \
687 (x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \
689 #define RCQ_BD(x) ((x) & MAX_RCQ_BD)
697 #define NUM_RCQ_REQ BRB_SIZE(bp)
698 #define NUM_RCQ_PG_REQ ((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \
700 #define RCQ_TH_LO(bp) (NUM_RCQ_REQ + \
701 NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \
703 #define RCQ_TH_HI(bp) (RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM)
707 #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b))
708 #define SUB_S32(a, b) (s32)((s32)(a) - (s32)(b))
711 #define BNX2X_SWCID_SHIFT 17
712 #define BNX2X_SWCID_MASK ((0x1 << BNX2X_SWCID_SHIFT) - 1)
715 #define SW_CID(x) (le32_to_cpu(x) & BNX2X_SWCID_MASK)
716 #define CQE_CMD(x) (le32_to_cpu(x) >> \
717 COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
719 #define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr_hi), \
720 le32_to_cpu((bd)->addr_lo))
721 #define BD_UNMAP_LEN(bd) (le16_to_cpu((bd)->nbytes))
723 #define BNX2X_DB_MIN_SHIFT 3
724 #define BNX2X_DB_SHIFT 7
725 #if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT)
726 #error "Min DB doorbell stride is 8"
728 #define DPM_TRIGER_TYPE 0x40
729 #define DOORBELL(bp, cid, val) \
731 writel((u32)(val), bp->doorbells + (bp->db_size * (cid)) + \
737 #define SKB_CS_OFF(skb) (offsetof(struct tcphdr, check) - \
739 #define SKB_CS(skb) (*(u16 *)(skb_transport_header(skb) + \
742 #define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff)
745 #define XMIT_CSUM_V4 0x1
746 #define XMIT_CSUM_V6 0x2
747 #define XMIT_CSUM_TCP 0x4
748 #define XMIT_GSO_V4 0x8
749 #define XMIT_GSO_V6 0x10
751 #define XMIT_CSUM (XMIT_CSUM_V4 | XMIT_CSUM_V6)
752 #define XMIT_GSO (XMIT_GSO_V4 | XMIT_GSO_V6)
756 #define CQE_TYPE(cqe_fp_flags) ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
757 #define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG)
758 #define CQE_TYPE_STOP(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG)
759 #define CQE_TYPE_SLOW(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD)
760 #define CQE_TYPE_FAST(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH)
762 #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
764 #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
765 (((le16_to_cpu(flags) & \
766 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
767 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
768 == PRS_FLAG_OVERETH_IPV4)
769 #define BNX2X_RX_SUM_FIX(cqe) \
770 BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
773 #define FP_USB_FUNC_OFF \
774 offsetof(struct cstorm_status_block_u, func)
775 #define FP_CSB_FUNC_OFF \
776 offsetof(struct cstorm_status_block_c, func)
778 #define HC_INDEX_ETH_RX_CQ_CONS 1
780 #define HC_INDEX_OOO_TX_CQ_CONS 4
782 #define HC_INDEX_ETH_TX_CQ_CONS_COS0 5
784 #define HC_INDEX_ETH_TX_CQ_CONS_COS1 6
786 #define HC_INDEX_ETH_TX_CQ_CONS_COS2 7
788 #define HC_INDEX_ETH_FIRST_TX_CQ_CONS HC_INDEX_ETH_TX_CQ_CONS_COS0
790 #define BNX2X_RX_SB_INDEX \
791 (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
793 #define BNX2X_TX_SB_INDEX_BASE BNX2X_TX_SB_INDEX_COS0
795 #define BNX2X_TX_SB_INDEX_COS0 \
796 (&fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0])
806 #define CHIP_ID(bp) (bp->common.chip_id & 0xfffffff0)
808 #define CHIP_NUM(bp) (bp->common.chip_id >> 16)
809 #define CHIP_NUM_57710 0x164e
810 #define CHIP_NUM_57711 0x164f
811 #define CHIP_NUM_57711E 0x1650
812 #define CHIP_NUM_57712 0x1662
813 #define CHIP_NUM_57712_MF 0x1663
814 #define CHIP_NUM_57713 0x1651
815 #define CHIP_NUM_57713E 0x1652
816 #define CHIP_NUM_57800 0x168a
817 #define CHIP_NUM_57800_MF 0x16a5
818 #define CHIP_NUM_57810 0x168e
819 #define CHIP_NUM_57810_MF 0x16ae
820 #define CHIP_NUM_57811 0x163d
821 #define CHIP_NUM_57811_MF 0x163e
822 #define CHIP_NUM_57840_OBSOLETE 0x168d
823 #define CHIP_NUM_57840_MF_OBSOLETE 0x16ab
824 #define CHIP_NUM_57840_4_10 0x16a1
825 #define CHIP_NUM_57840_2_20 0x16a2
826 #define CHIP_NUM_57840_MF 0x16a4
827 #define CHIP_IS_E1(bp) (CHIP_NUM(bp) == CHIP_NUM_57710)
828 #define CHIP_IS_57711(bp) (CHIP_NUM(bp) == CHIP_NUM_57711)
829 #define CHIP_IS_57711E(bp) (CHIP_NUM(bp) == CHIP_NUM_57711E)
830 #define CHIP_IS_57712(bp) (CHIP_NUM(bp) == CHIP_NUM_57712)
831 #define CHIP_IS_57712_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57712_MF)
832 #define CHIP_IS_57800(bp) (CHIP_NUM(bp) == CHIP_NUM_57800)
833 #define CHIP_IS_57800_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57800_MF)
834 #define CHIP_IS_57810(bp) (CHIP_NUM(bp) == CHIP_NUM_57810)
835 #define CHIP_IS_57810_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57810_MF)
836 #define CHIP_IS_57811(bp) (CHIP_NUM(bp) == CHIP_NUM_57811)
837 #define CHIP_IS_57811_MF(bp) (CHIP_NUM(bp) == CHIP_NUM_57811_MF)
838 #define CHIP_IS_57840(bp) \
839 ((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) || \
840 (CHIP_NUM(bp) == CHIP_NUM_57840_2_20) || \
841 (CHIP_NUM(bp) == CHIP_NUM_57840_OBSOLETE))
842 #define CHIP_IS_57840_MF(bp) ((CHIP_NUM(bp) == CHIP_NUM_57840_MF) || \
843 (CHIP_NUM(bp) == CHIP_NUM_57840_MF_OBSOLETE))
844 #define CHIP_IS_E1H(bp) (CHIP_IS_57711(bp) || \
846 #define CHIP_IS_E2(bp) (CHIP_IS_57712(bp) || \
847 CHIP_IS_57712_MF(bp))
848 #define CHIP_IS_E3(bp) (CHIP_IS_57800(bp) || \
849 CHIP_IS_57800_MF(bp) || \
850 CHIP_IS_57810(bp) || \
851 CHIP_IS_57810_MF(bp) || \
852 CHIP_IS_57811(bp) || \
853 CHIP_IS_57811_MF(bp) || \
854 CHIP_IS_57840(bp) || \
855 CHIP_IS_57840_MF(bp))
856 #define CHIP_IS_E1x(bp) (CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
857 #define USES_WARPCORE(bp) (CHIP_IS_E3(bp))
858 #define IS_E1H_OFFSET (!CHIP_IS_E1(bp))
860 #define CHIP_REV_SHIFT 12
861 #define CHIP_REV_MASK (0xF << CHIP_REV_SHIFT)
862 #define CHIP_REV_VAL(bp) (bp->common.chip_id & CHIP_REV_MASK)
863 #define CHIP_REV_Ax (0x0 << CHIP_REV_SHIFT)
864 #define CHIP_REV_Bx (0x1 << CHIP_REV_SHIFT)
866 #define CHIP_REV_IS_SLOW(bp) (CHIP_REV_VAL(bp) > 0x00005000)
868 #define CHIP_REV_IS_EMUL(bp) ((CHIP_REV_IS_SLOW(bp)) && \
869 !(CHIP_REV_VAL(bp) & 0x00001000))
871 #define CHIP_REV_IS_FPGA(bp) ((CHIP_REV_IS_SLOW(bp)) && \
872 (CHIP_REV_VAL(bp) & 0x00001000))
874 #define CHIP_TIME(bp) ((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
875 ((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
877 #define CHIP_METAL(bp) (bp->common.chip_id & 0x00000ff0)
878 #define CHIP_BOND_ID(bp) (bp->common.chip_id & 0x0000000f)
879 #define CHIP_REV_SIM(bp) (((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\
880 (CHIP_REV_SHIFT + 1)) \
882 #define CHIP_REV(bp) (CHIP_REV_IS_SLOW(bp) ? \
885 #define CHIP_IS_E3B0(bp) (CHIP_IS_E3(bp) && \
886 (CHIP_REV(bp) == CHIP_REV_Bx))
887 #define CHIP_IS_E3A0(bp) (CHIP_IS_E3(bp) && \
888 (CHIP_REV(bp) == CHIP_REV_Ax))
891 #define BNX2X_NVRAM_1MB_SIZE 0x20000
892 #define BNX2X_NVRAM_TIMEOUT_COUNT 30000
893 #define BNX2X_NVRAM_PAGE_SIZE 256
905 #define INT_BLOCK_HC 0
906 #define INT_BLOCK_IGU 1
907 #define INT_BLOCK_MODE_NORMAL 0
908 #define INT_BLOCK_MODE_BW_COMP 2
909 #define CHIP_INT_MODE_IS_NBC(bp) \
910 (!CHIP_IS_E1x(bp) && \
911 !((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
912 #define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
915 #define CHIP_4_PORT_MODE 0x0
916 #define CHIP_2_PORT_MODE 0x1
917 #define CHIP_PORT_MODE_NONE 0x2
918 #define CHIP_MODE(bp) (bp->common.chip_port_mode)
919 #define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
925 #define BNX2X_IGU_STAS_MSG_VF_CNT 64
926 #define BNX2X_IGU_STAS_MSG_PF_CNT 4
939 #define SUPPORTED_2500baseX_Full (1 << 15)
943 #define ADVERTISED_2500baseX_Full (1 << 15)
958 #define STATS_OFFSET32(stat_name) \
959 (offsetof(struct bnx2x_eth_stats, stat_name) / 4)
966 #define BNX2X_MAX_NUM_OF_VFS 64
967 #define BNX2X_VF_ID_INVALID 0xFF
992 #define FP_SB_MAX_E1x 16
994 #define FP_SB_MAX_E2 HC_SB_MAX_SB_E2
1002 #define CDU_ILT_PAGE_SZ_HW 2
1003 #define CDU_ILT_PAGE_SZ (8192 << CDU_ILT_PAGE_SZ_HW)
1004 #define ILT_PAGE_CIDS (CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
1007 #define CNIC_ISCSI_CID_MAX 256
1008 #define CNIC_FCOE_CID_MAX 2048
1009 #define CNIC_CID_MAX (CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
1010 #define CNIC_ILT_LINES DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
1013 #define QM_ILT_PAGE_SZ_HW 0
1014 #define QM_ILT_PAGE_SZ (4096 << QM_ILT_PAGE_SZ_HW)
1015 #define QM_CID_ROUND 1024
1019 #define TM_ILT_PAGE_SZ_HW 0
1020 #define TM_ILT_PAGE_SZ (4096 << TM_ILT_PAGE_SZ_HW)
1022 #define TM_CONN_NUM 1024
1023 #define TM_ILT_SZ (8 * TM_CONN_NUM)
1024 #define TM_ILT_LINES DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
1027 #define SRC_ILT_PAGE_SZ_HW 0
1028 #define SRC_ILT_PAGE_SZ (4096 << SRC_ILT_PAGE_SZ_HW)
1029 #define SRC_HASH_BITS 10
1030 #define SRC_CONN_NUM (1 << SRC_HASH_BITS)
1031 #define SRC_ILT_SZ (sizeof(struct src_ent) * SRC_CONN_NUM)
1032 #define SRC_T2_SZ SRC_ILT_SZ
1033 #define SRC_ILT_LINES DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
1037 #define MAX_DMAE_C 8
1093 #define bnx2x_sp(bp, var) (&bp->slowpath->var)
1094 #define bnx2x_sp_mapping(bp, var) \
1095 (bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
1099 #define MAX_DYNAMIC_ATTN_GRPS 8
1135 #define NUM_EQ_PAGES 1
1136 #define EQ_DESC_CNT_PAGE (BCM_PAGE_SIZE / sizeof(union event_ring_elem))
1137 #define EQ_DESC_MAX_PAGE (EQ_DESC_CNT_PAGE - 1)
1138 #define NUM_EQ_DESC (EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
1139 #define EQ_DESC_MASK (NUM_EQ_DESC - 1)
1140 #define MAX_EQ_AVAIL (EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
1143 #define NEXT_EQ_IDX(x) ((((x) & EQ_DESC_MAX_PAGE) == \
1144 (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
1147 #define EQ_DESC(x) ((x) & EQ_DESC_MASK)
1149 #define BNX2X_EQ_INDEX \
1150 (&bp->def_status_blk->sp_sb.\
1151 index_values[HC_SP_INDEX_EQ_CONS])
1238 #define BP_PATH(bp) (CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1))
1239 #define BP_PORT(bp) (bp->pfid & 1)
1240 #define BP_FUNC(bp) (bp->pfid)
1241 #define BP_ABS_FUNC(bp) (bp->pf_num)
1242 #define BP_VN(bp) ((bp)->pfid >> 1)
1243 #define BP_MAX_VN_NUM(bp) (CHIP_MODE_IS_4_PORT(bp) ? 2 : 4)
1244 #define BP_L_ID(bp) (BP_VN(bp) << 2)
1245 #define BP_FW_MB_IDX_VN(bp, vn) (BP_PORT(bp) +\
1246 (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1))
1247 #define BP_FW_MB_IDX(bp) BP_FW_MB_IDX_VN(bp, BP_VN(bp))
1253 #define IRO (bp->iro_arr)
1262 #define ETH_OVREHEAD (ETH_HLEN + 8 + 8)
1263 #define ETH_MIN_PACKET_SIZE 60
1264 #define ETH_MAX_PACKET_SIZE 1500
1265 #define ETH_MAX_JUMBO_PACKET_SIZE 9600
1267 #define ETH_MAX_TPA_HEADER_SIZE 72
1270 #define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT)
1278 #define BNX2X_FW_RX_ALIGN_START (1UL << BNX2X_RX_ALIGN_SHIFT)
1280 #define BNX2X_FW_RX_ALIGN_END \
1281 max_t(u64, 1UL << BNX2X_RX_ALIGN_SHIFT, \
1282 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
1284 #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5)
1287 #define DEF_SB_IGU_ID 16
1288 #define DEF_SB_ID HC_SP_SB_ID
1326 #define PCIX_FLAG (1 << 0)
1327 #define PCI_32BIT_FLAG (1 << 1)
1328 #define ONE_PORT_FLAG (1 << 2)
1329 #define NO_WOL_FLAG (1 << 3)
1330 #define USING_DAC_FLAG (1 << 4)
1331 #define USING_MSIX_FLAG (1 << 5)
1332 #define USING_MSI_FLAG (1 << 6)
1333 #define DISABLE_MSI_FLAG (1 << 7)
1334 #define TPA_ENABLE_FLAG (1 << 8)
1335 #define NO_MCP_FLAG (1 << 9)
1337 #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
1338 #define GRO_ENABLE_FLAG (1 << 10)
1339 #define MF_FUNC_DIS (1 << 11)
1340 #define OWN_CNIC_IRQ (1 << 12)
1341 #define NO_ISCSI_OOO_FLAG (1 << 13)
1342 #define NO_ISCSI_FLAG (1 << 14)
1343 #define NO_FCOE_FLAG (1 << 15)
1344 #define BC_SUPPORTS_PFC_STATS (1 << 17)
1345 #define BC_SUPPORTS_FCOE_FEATURES (1 << 19)
1346 #define USING_SINGLE_MSIX_FLAG (1 << 20)
1347 #define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21)
1349 #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG)
1350 #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
1351 #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG)
1384 #define IS_MF(bp) (bp->mf_mode != 0)
1385 #define IS_MF_SI(bp) (bp->mf_mode == MULTI_FUNCTION_SI)
1386 #define IS_MF_SD(bp) (bp->mf_mode == MULTI_FUNCTION_SD)
1387 #define IS_MF_AFEX(bp) (bp->mf_mode == MULTI_FUNCTION_AFEX)
1403 #define BNX2X_MAX_COALESCE_TOUT (0xf0*12)
1408 #define BNX2X_STATE_CLOSED 0
1409 #define BNX2X_STATE_OPENING_WAIT4_LOAD 0x1000
1410 #define BNX2X_STATE_OPENING_WAIT4_PORT 0x2000
1411 #define BNX2X_STATE_OPEN 0x3000
1412 #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
1413 #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
1415 #define BNX2X_STATE_DIAG 0xe000
1416 #define BNX2X_STATE_ERROR 0xf000
1418 #define BNX2X_MAX_PRIORITY 8
1419 #define BNX2X_MAX_ENTRIES_PER_PRI 16
1420 #define BNX2X_MAX_COS 3
1421 #define BNX2X_MAX_TX_COS 2
1427 #define BNX2X_RX_MODE_NONE 0
1428 #define BNX2X_RX_MODE_NORMAL 1
1429 #define BNX2X_RX_MODE_ALLMULTI 2
1430 #define BNX2X_RX_MODE_PROMISC 3
1431 #define BNX2X_MAX_MULTICAST 64
1471 #define ILT_MAX_L2_LINES 8
1475 #define BP_ILT(bp) ((bp)->ilt)
1476 #define ILT_MAX_LINES 256
1481 #define BNX2X_MAX_RSS_COUNT(bp) ((bp)->igu_sb_cnt - CNIC_PRESENT)
1487 #define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
1488 + NON_ETH_CONTEXT_USE + CNIC_PRESENT)
1489 #define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
1490 + NON_ETH_CONTEXT_USE + CNIC_PRESENT)
1491 #define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
1500 #define BNX2X_CNIC_FLAG_MAC_SET 1
1510 struct eth_spe *cnic_kwq_prod;
1511 struct eth_spe *cnic_kwq_cons;
1512 struct eth_spe *cnic_kwq_last;
1513 u16 cnic_kwq_pending;
1514 u16 cnic_spq_pending;
1516 struct mutex cnic_mutex;
1552 #define FW_BUF_SIZE 0x8000
1553 #define GUNZIP_BUF(bp) (bp->gunzip_buf)
1554 #define GUNZIP_PHYS(bp) (bp->gunzip_mapping)
1555 #define GUNZIP_OUTLEN(bp) (bp->gunzip_outlen)
1563 #define INIT_MODE_FLAGS(bp) (bp->init_mode_flags)
1573 #define INIT_OPS(bp) (bp->init_ops)
1574 #define INIT_OPS_OFFSETS(bp) (bp->init_ops_offsets)
1575 #define INIT_DATA(bp) (bp->init_data)
1576 #define INIT_TSEM_INT_TABLE_DATA(bp) (bp->tsem_int_table_data)
1577 #define INIT_TSEM_PRAM_DATA(bp) (bp->tsem_pram_data)
1578 #define INIT_USEM_INT_TABLE_DATA(bp) (bp->usem_int_table_data)
1579 #define INIT_USEM_PRAM_DATA(bp) (bp->usem_pram_data)
1580 #define INIT_XSEM_INT_TABLE_DATA(bp) (bp->xsem_int_table_data)
1581 #define INIT_XSEM_PRAM_DATA(bp) (bp->xsem_pram_data)
1582 #define INIT_CSEM_INT_TABLE_DATA(bp) (bp->csem_int_table_data)
1583 #define INIT_CSEM_PRAM_DATA(bp) (bp->csem_pram_data)
1585 #define PHY_FW_VER_LEN 20
1591 #define BNX2X_DCB_STATE_OFF 0
1592 #define BNX2X_DCB_STATE_ON 1
1596 #define BNX2X_DCBX_ENABLED_OFF 0
1597 #define BNX2X_DCBX_ENABLED_ON_NEG_OFF 1
1598 #define BNX2X_DCBX_ENABLED_ON_NEG_ON 2
1599 #define BNX2X_DCBX_ENABLED_INVALID (-1)
1633 u32 dcbx_remote_flags;
1649 #define BNX2X_NUM_QUEUES(bp) (bp->num_queues)
1650 #define BNX2X_NUM_ETH_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - NON_ETH_CONTEXT_USE)
1651 #define BNX2X_NUM_NON_CNIC_QUEUES(bp) (BNX2X_NUM_QUEUES(bp) - \
1652 NON_ETH_CONTEXT_USE)
1653 #define BNX2X_NUM_RX_QUEUES(bp) BNX2X_NUM_QUEUES(bp)
1655 #define is_multi(bp) (BNX2X_NUM_QUEUES(bp) > 1)
1657 #define BNX2X_MAX_QUEUES(bp) BNX2X_MAX_RSS_COUNT(bp)
1660 #define RSS_IPV4_CAP_MASK \
1661 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
1663 #define RSS_IPV4_TCP_CAP_MASK \
1664 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
1666 #define RSS_IPV6_CAP_MASK \
1667 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
1669 #define RSS_IPV6_TCP_CAP_MASK \
1670 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
1673 #define FUNC_FLG_RSS 0x0001
1674 #define FUNC_FLG_STATS 0x0002
1676 #define FUNC_FLG_TPA 0x0008
1677 #define FUNC_FLG_SPQ 0x0010
1678 #define FUNC_FLG_LEADING 0x0020
1692 #define for_each_eth_queue(bp, var) \
1693 for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
1695 #define for_each_nondefault_eth_queue(bp, var) \
1696 for ((var) = 1; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
1698 #define for_each_queue(bp, var) \
1699 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1700 if (skip_queue(bp, var)) \
1705 #define for_each_rx_queue(bp, var) \
1706 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1707 if (skip_rx_queue(bp, var)) \
1712 #define for_each_tx_queue(bp, var) \
1713 for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1714 if (skip_tx_queue(bp, var)) \
1718 #define for_each_nondefault_queue(bp, var) \
1719 for ((var) = 1; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
1720 if (skip_queue(bp, var)) \
1724 #define for_each_cos_in_tx_queue(fp, var) \
1725 for ((var) = 0; (var) < (fp)->max_cos; (var)++)
1730 #define skip_rx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
1735 #define skip_tx_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
1737 #define skip_queue(bp, idx) (NO_FCOE(bp) && IS_FCOE_IDX(idx))
1762 int mac_type,
unsigned long *ramrod_flags);
1779 int mac_type,
bool wait_for_comp);
1803 u32 data_hi,
u32 data_lo,
int cmd_type);
1814 if (val == expected)
1824 #define BNX2X_ILT_ZALLOC(x, y, size) \
1826 x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
1828 memset(x, 0, size); \
1831 #define BNX2X_ILT_FREE(x, y, size) \
1834 dma_free_coherent(&bp->pdev->dev, size, x, y); \
1840 #define ILOG2(x) (ilog2((x)))
1842 #define ILT_NUM_PAGE_ENTRIES (3072)
1847 #define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8)
1849 #define FUNC_ILT_BASE(func) (func * ILT_PER_FUNC)
1856 #define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
1857 #define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
1860 #define LOAD_NORMAL 0
1863 #define LOAD_LOOPBACK_EXT 3
1864 #define UNLOAD_NORMAL 0
1865 #define UNLOAD_CLOSE 1
1866 #define UNLOAD_RECOVERY 2
1870 #define DMAE_TIMEOUT -1
1871 #define DMAE_PCI_ERROR -2
1872 #define DMAE_NOT_RDY -3
1873 #define DMAE_PCI_ERR_FLAG 0x80000000
1875 #define DMAE_SRC_PCI 0
1876 #define DMAE_SRC_GRC 1
1878 #define DMAE_DST_NONE 0
1879 #define DMAE_DST_PCI 1
1880 #define DMAE_DST_GRC 2
1882 #define DMAE_COMP_PCI 0
1883 #define DMAE_COMP_GRC 1
1887 #define DMAE_COMP_REGULAR 0
1888 #define DMAE_COM_SET_ERR 1
1890 #define DMAE_CMD_SRC_PCI (DMAE_SRC_PCI << \
1891 DMAE_COMMAND_SRC_SHIFT)
1892 #define DMAE_CMD_SRC_GRC (DMAE_SRC_GRC << \
1893 DMAE_COMMAND_SRC_SHIFT)
1895 #define DMAE_CMD_DST_PCI (DMAE_DST_PCI << \
1896 DMAE_COMMAND_DST_SHIFT)
1897 #define DMAE_CMD_DST_GRC (DMAE_DST_GRC << \
1898 DMAE_COMMAND_DST_SHIFT)
1900 #define DMAE_CMD_C_DST_PCI (DMAE_COMP_PCI << \
1901 DMAE_COMMAND_C_DST_SHIFT)
1902 #define DMAE_CMD_C_DST_GRC (DMAE_COMP_GRC << \
1903 DMAE_COMMAND_C_DST_SHIFT)
1905 #define DMAE_CMD_C_ENABLE DMAE_COMMAND_C_TYPE_ENABLE
1907 #define DMAE_CMD_ENDIANITY_NO_SWAP (0 << DMAE_COMMAND_ENDIANITY_SHIFT)
1908 #define DMAE_CMD_ENDIANITY_B_SWAP (1 << DMAE_COMMAND_ENDIANITY_SHIFT)
1909 #define DMAE_CMD_ENDIANITY_DW_SWAP (2 << DMAE_COMMAND_ENDIANITY_SHIFT)
1910 #define DMAE_CMD_ENDIANITY_B_DW_SWAP (3 << DMAE_COMMAND_ENDIANITY_SHIFT)
1912 #define DMAE_CMD_PORT_0 0
1913 #define DMAE_CMD_PORT_1 DMAE_COMMAND_PORT
1915 #define DMAE_CMD_SRC_RESET DMAE_COMMAND_SRC_RESET
1916 #define DMAE_CMD_DST_RESET DMAE_COMMAND_DST_RESET
1917 #define DMAE_CMD_E1HVN_SHIFT DMAE_COMMAND_E1HVN_SHIFT
1919 #define DMAE_SRC_PF 0
1920 #define DMAE_SRC_VF 1
1922 #define DMAE_DST_PF 0
1923 #define DMAE_DST_VF 1
1925 #define DMAE_C_SRC 0
1926 #define DMAE_C_DST 1
1928 #define DMAE_LEN32_RD_MAX 0x80
1929 #define DMAE_LEN32_WR_MAX(bp) (CHIP_IS_E1(bp) ? 0x400 : 0x2000)
1931 #define DMAE_COMP_VAL 0x60d0d0ae
1934 #define MAX_DMAE_C_PER_PORT 8
1935 #define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
1937 #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
1941 #define PCICFG_LINK_WIDTH 0x1f00000
1942 #define PCICFG_LINK_WIDTH_SHIFT 20
1943 #define PCICFG_LINK_SPEED 0xf0000
1944 #define PCICFG_LINK_SPEED_SHIFT 16
1946 #define BNX2X_NUM_TESTS_SF 7
1947 #define BNX2X_NUM_TESTS_MF 3
1948 #define BNX2X_NUM_TESTS(bp) (IS_MF(bp) ? BNX2X_NUM_TESTS_MF : \
1951 #define BNX2X_PHY_LOOPBACK 0
1952 #define BNX2X_MAC_LOOPBACK 1
1953 #define BNX2X_EXT_LOOPBACK 2
1954 #define BNX2X_PHY_LOOPBACK_FAILED 1
1955 #define BNX2X_MAC_LOOPBACK_FAILED 2
1956 #define BNX2X_EXT_LOOPBACK_FAILED 3
1957 #define BNX2X_LOOPBACK_FAILED (BNX2X_MAC_LOOPBACK_FAILED | \
1958 BNX2X_PHY_LOOPBACK_FAILED)
1961 #define STROM_ASSERT_ARRAY_SIZE 50
1965 #define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \
1966 (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \
1969 #define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe))
1970 #define MAX_SP_DESC_CNT (SP_DESC_CNT - 1)
1974 #define MAX_SPQ_PENDING 8
1978 #define DEF_MIN_RATE 100
1980 #define RS_PERIODIC_TIMEOUT_USEC 400
1983 #define QM_ARB_BYTES 160000
1987 #define MIN_ABOVE_THRESH 32768
1990 #define T_FAIR_COEF ((MIN_ABOVE_THRESH + QM_ARB_BYTES) * 8 * MIN_RES)
1995 #define ATTN_NIG_FOR_FUNC (1L << 8)
1996 #define ATTN_SW_TIMER_4_FUNC (1L << 9)
1997 #define GPIO_2_FUNC (1L << 10)
1998 #define GPIO_3_FUNC (1L << 11)
1999 #define GPIO_4_FUNC (1L << 12)
2000 #define ATTN_GENERAL_ATTN_1 (1L << 13)
2001 #define ATTN_GENERAL_ATTN_2 (1L << 14)
2002 #define ATTN_GENERAL_ATTN_3 (1L << 15)
2003 #define ATTN_GENERAL_ATTN_4 (1L << 13)
2004 #define ATTN_GENERAL_ATTN_5 (1L << 14)
2005 #define ATTN_GENERAL_ATTN_6 (1L << 15)
2007 #define ATTN_HARD_WIRED_MASK 0xff00
2008 #define ATTENTION_ID 4
2013 #define BNX2X_PMF_LINK_ASSERT \
2014 GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
2016 #define BNX2X_MC_ASSERT_BITS \
2017 (GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
2018 GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
2019 GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
2020 GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
2022 #define BNX2X_MCP_ASSERT \
2023 GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
2025 #define BNX2X_GRC_TIMEOUT GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
2026 #define BNX2X_GRC_RSV (GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
2027 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
2028 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
2029 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
2030 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
2031 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
2033 #define HW_INTERRUT_ASSERT_SET_0 \
2034 (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
2035 AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
2036 AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
2037 AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT)
2038 #define HW_PRTY_ASSERT_SET_0 (AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
2039 AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
2040 AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
2041 AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
2042 AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\
2043 AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\
2044 AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR)
2045 #define HW_INTERRUT_ASSERT_SET_1 \
2046 (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
2047 AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
2048 AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
2049 AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
2050 AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
2051 AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
2052 AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
2053 AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
2054 AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
2055 AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
2056 AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
2057 #define HW_PRTY_ASSERT_SET_1 (AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\
2058 AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
2059 AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\
2060 AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
2061 AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\
2062 AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
2063 AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
2064 AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\
2065 AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
2066 AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
2067 AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
2068 AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\
2069 AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
2070 AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
2071 AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\
2072 AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR)
2073 #define HW_INTERRUT_ASSERT_SET_2 \
2074 (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
2075 AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
2076 AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
2077 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
2078 AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
2079 #define HW_PRTY_ASSERT_SET_2 (AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
2080 AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
2081 AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
2082 AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
2083 AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
2084 AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\
2085 AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
2086 AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
2088 #define HW_PRTY_ASSERT_SET_3 (AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
2089 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
2090 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY | \
2091 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
2093 #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \
2094 AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)
2096 #define MULTI_MASK 0x7f
2099 #define DEF_USB_FUNC_OFF offsetof(struct cstorm_def_status_block_u, func)
2100 #define DEF_CSB_FUNC_OFF offsetof(struct cstorm_def_status_block_c, func)
2101 #define DEF_XSB_FUNC_OFF offsetof(struct xstorm_def_status_block, func)
2102 #define DEF_TSB_FUNC_OFF offsetof(struct tstorm_def_status_block, func)
2104 #define DEF_USB_IGU_INDEX_OFF \
2105 offsetof(struct cstorm_def_status_block_u, igu_index)
2106 #define DEF_CSB_IGU_INDEX_OFF \
2107 offsetof(struct cstorm_def_status_block_c, igu_index)
2108 #define DEF_XSB_IGU_INDEX_OFF \
2109 offsetof(struct xstorm_def_status_block, igu_index)
2110 #define DEF_TSB_IGU_INDEX_OFF \
2111 offsetof(struct tstorm_def_status_block, igu_index)
2113 #define DEF_USB_SEGMENT_OFF \
2114 offsetof(struct cstorm_def_status_block_u, segment)
2115 #define DEF_CSB_SEGMENT_OFF \
2116 offsetof(struct cstorm_def_status_block_c, segment)
2117 #define DEF_XSB_SEGMENT_OFF \
2118 offsetof(struct xstorm_def_status_block, segment)
2119 #define DEF_TSB_SEGMENT_OFF \
2120 offsetof(struct tstorm_def_status_block, segment)
2122 #define BNX2X_SP_DSB_INDEX \
2123 (&bp->def_status_blk->sp_sb.\
2124 index_values[HC_SP_INDEX_ETH_DEF_CONS])
2126 #define SET_FLAG(value, mask, flag) \
2128 (value) &= ~(mask);\
2129 (value) |= ((flag) << (mask##_SHIFT));\
2132 #define GET_FLAG(value, mask) \
2133 (((value) & (mask)) >> (mask##_SHIFT))
2135 #define GET_FIELD(value, fname) \
2136 (((value) & (fname##_MASK)) >> (fname##_SHIFT))
2138 #define CAM_IS_INVALID(x) \
2139 (GET_FLAG(x.flags, \
2140 MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
2141 (T_ETH_MAC_COMMAND_INVALIDATE))
2144 #define MC_HASH_SIZE 8
2145 #define MC_HASH_OFFSET(bp, i) (BAR_TSTRORM_INTMEM + \
2146 TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
2149 #ifndef PXP2_REG_PXP2_INT_STS
2150 #define PXP2_REG_PXP2_INT_STS PXP2_REG_PXP2_INT_STS_0
2153 #ifndef ETH_MAX_RX_CLIENTS_E2
2154 #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
2157 #define BNX2X_VPD_LEN 128
2158 #define VENDOR_ID_LEN 4
2161 #define CMNG_FNS_NONE 0
2162 #define CMNG_FNS_MINMAX 1
2164 #define HC_SEG_ACCESS_DEF 0
2165 #define HC_SEG_ACCESS_ATTN 4
2166 #define HC_SEG_ACCESS_NORM 0
2168 static const u32 dmae_reg_go_c[] = {
2179 #define BNX2X_MF_SD_PROTOCOL(bp) \
2180 ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
2183 #define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
2184 (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
2186 #define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \
2187 (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE)
2189 #define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp))
2190 #define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))
2192 #define BNX2X_MF_EXT_PROTOCOL_FCOE(bp) ((bp)->mf_ext_config & \
2193 MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
2195 #define IS_MF_FCOE_AFEX(bp) (IS_MF_AFEX(bp) && BNX2X_MF_EXT_PROTOCOL_FCOE(bp))
2196 #define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \
2197 (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \
2198 BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
2200 #define IS_MF_FCOE_AFEX(bp) false