aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x/bnx2x.h')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h124
1 files changed, 92 insertions, 32 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index f127768e4e83..2f92487724c6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -310,6 +310,14 @@ union db_prod {
310 u32 raw; 310 u32 raw;
311}; 311};
312 312
313/* dropless fc FW/HW related params */
314#define BRB_SIZE(bp) (CHIP_IS_E3(bp) ? 1024 : 512)
315#define MAX_AGG_QS(bp) (CHIP_IS_E1(bp) ? \
316 ETH_MAX_AGGREGATION_QUEUES_E1 :\
317 ETH_MAX_AGGREGATION_QUEUES_E1H_E2)
318#define FW_DROP_LEVEL(bp) (3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp))
319#define FW_PREFETCH_CNT 16
320#define DROPLESS_FC_HEADROOM 100
313 321
314/* MC hsi */ 322/* MC hsi */
315#define BCM_PAGE_SHIFT 12 323#define BCM_PAGE_SHIFT 12
@@ -326,15 +334,35 @@ union db_prod {
326/* SGE ring related macros */ 334/* SGE ring related macros */
327#define NUM_RX_SGE_PAGES 2 335#define NUM_RX_SGE_PAGES 2
328#define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) 336#define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
329#define MAX_RX_SGE_CNT (RX_SGE_CNT - 2) 337#define NEXT_PAGE_SGE_DESC_CNT 2
338#define MAX_RX_SGE_CNT (RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT)
330/* RX_SGE_CNT is promised to be a power of 2 */ 339/* RX_SGE_CNT is promised to be a power of 2 */
331#define RX_SGE_MASK (RX_SGE_CNT - 1) 340#define RX_SGE_MASK (RX_SGE_CNT - 1)
332#define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES) 341#define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES)
333#define MAX_RX_SGE (NUM_RX_SGE - 1) 342#define MAX_RX_SGE (NUM_RX_SGE - 1)
334#define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \ 343#define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \
335 (MAX_RX_SGE_CNT - 1)) ? (x) + 3 : (x) + 1) 344 (MAX_RX_SGE_CNT - 1)) ? \
345 (x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \
346 (x) + 1)
336#define RX_SGE(x) ((x) & MAX_RX_SGE) 347#define RX_SGE(x) ((x) & MAX_RX_SGE)
337 348
349/*
350 * Number of required SGEs is the sum of two:
351 * 1. Number of possible opened aggregations (next packet for
352 * these aggregations will probably consume SGE immidiatelly)
353 * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only
354 * after placement on BD for new TPA aggregation)
355 *
356 * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page
357 */
358#define NUM_SGE_REQ (MAX_AGG_QS(bp) + \
359 (BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2)
360#define NUM_SGE_PG_REQ ((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \
361 MAX_RX_SGE_CNT)
362#define SGE_TH_LO(bp) (NUM_SGE_REQ + \
363 NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT)
364#define SGE_TH_HI(bp) (SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM)
365
338/* Manipulate a bit vector defined as an array of u64 */ 366/* Manipulate a bit vector defined as an array of u64 */
339 367
340/* Number of bits in one sge_mask array element */ 368/* Number of bits in one sge_mask array element */
@@ -546,24 +574,43 @@ struct bnx2x_fastpath {
546 574
547#define NUM_TX_RINGS 16 575#define NUM_TX_RINGS 16
548#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types)) 576#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
549#define MAX_TX_DESC_CNT (TX_DESC_CNT - 1) 577#define NEXT_PAGE_TX_DESC_CNT 1
578#define MAX_TX_DESC_CNT (TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT)
550#define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS) 579#define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS)
551#define MAX_TX_BD (NUM_TX_BD - 1) 580#define MAX_TX_BD (NUM_TX_BD - 1)
552#define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2) 581#define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
553#define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \ 582#define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \
554 (MAX_TX_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) 583 (MAX_TX_DESC_CNT - 1)) ? \
584 (x) + 1 + NEXT_PAGE_TX_DESC_CNT : \
585 (x) + 1)
555#define TX_BD(x) ((x) & MAX_TX_BD) 586#define TX_BD(x) ((x) & MAX_TX_BD)
556#define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT) 587#define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT)
557 588
558/* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */ 589/* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
559#define NUM_RX_RINGS 8 590#define NUM_RX_RINGS 8
560#define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd)) 591#define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
561#define MAX_RX_DESC_CNT (RX_DESC_CNT - 2) 592#define NEXT_PAGE_RX_DESC_CNT 2
593#define MAX_RX_DESC_CNT (RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT)
562#define RX_DESC_MASK (RX_DESC_CNT - 1) 594#define RX_DESC_MASK (RX_DESC_CNT - 1)
563#define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS) 595#define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS)
564#define MAX_RX_BD (NUM_RX_BD - 1) 596#define MAX_RX_BD (NUM_RX_BD - 1)
565#define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2) 597#define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
566#define MIN_RX_AVAIL 128 598
599/* dropless fc calculations for BDs
600 *
601 * Number of BDs should as number of buffers in BRB:
602 * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT
603 * "next" elements on each page
604 */
605#define NUM_BD_REQ BRB_SIZE(bp)
606#define NUM_BD_PG_REQ ((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \
607 MAX_RX_DESC_CNT)
608#define BD_TH_LO(bp) (NUM_BD_REQ + \
609 NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \
610 FW_DROP_LEVEL(bp))
611#define BD_TH_HI(bp) (BD_TH_LO(bp) + DROPLESS_FC_HEADROOM)
612
613#define MIN_RX_AVAIL ((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128)
567 614
568#define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \ 615#define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \
569 ETH_MIN_RX_CQES_WITH_TPA_E1 : \ 616 ETH_MIN_RX_CQES_WITH_TPA_E1 : \
@@ -574,7 +621,9 @@ struct bnx2x_fastpath {
574 MIN_RX_AVAIL)) 621 MIN_RX_AVAIL))
575 622
576#define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \ 623#define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \
577 (MAX_RX_DESC_CNT - 1)) ? (x) + 3 : (x) + 1) 624 (MAX_RX_DESC_CNT - 1)) ? \
625 (x) + 1 + NEXT_PAGE_RX_DESC_CNT : \
626 (x) + 1)
578#define RX_BD(x) ((x) & MAX_RX_BD) 627#define RX_BD(x) ((x) & MAX_RX_BD)
579 628
580/* 629/*
@@ -584,14 +633,31 @@ struct bnx2x_fastpath {
584#define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd)) 633#define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
585#define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL) 634#define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL)
586#define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) 635#define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
587#define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - 1) 636#define NEXT_PAGE_RCQ_DESC_CNT 1
637#define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT)
588#define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS) 638#define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS)
589#define MAX_RCQ_BD (NUM_RCQ_BD - 1) 639#define MAX_RCQ_BD (NUM_RCQ_BD - 1)
590#define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2) 640#define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
591#define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \ 641#define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \
592 (MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) 642 (MAX_RCQ_DESC_CNT - 1)) ? \
643 (x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \
644 (x) + 1)
593#define RCQ_BD(x) ((x) & MAX_RCQ_BD) 645#define RCQ_BD(x) ((x) & MAX_RCQ_BD)
594 646
647/* dropless fc calculations for RCQs
648 *
649 * Number of RCQs should be as number of buffers in BRB:
650 * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT
651 * "next" elements on each page
652 */
653#define NUM_RCQ_REQ BRB_SIZE(bp)
654#define NUM_RCQ_PG_REQ ((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \
655 MAX_RCQ_DESC_CNT)
656#define RCQ_TH_LO(bp) (NUM_RCQ_REQ + \
657 NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \
658 FW_DROP_LEVEL(bp))
659#define RCQ_TH_HI(bp) (RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM)
660
595 661
596/* This is needed for determining of last_max */ 662/* This is needed for determining of last_max */
597#define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) 663#define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b))
@@ -680,24 +746,17 @@ struct bnx2x_fastpath {
680#define FP_CSB_FUNC_OFF \ 746#define FP_CSB_FUNC_OFF \
681 offsetof(struct cstorm_status_block_c, func) 747 offsetof(struct cstorm_status_block_c, func)
682 748
683#define HC_INDEX_TOE_RX_CQ_CONS 0 /* Formerly Ustorm TOE CQ index */ 749#define HC_INDEX_ETH_RX_CQ_CONS 1
684 /* (HC_INDEX_U_TOE_RX_CQ_CONS) */
685#define HC_INDEX_ETH_RX_CQ_CONS 1 /* Formerly Ustorm ETH CQ index */
686 /* (HC_INDEX_U_ETH_RX_CQ_CONS) */
687#define HC_INDEX_ETH_RX_BD_CONS 2 /* Formerly Ustorm ETH BD index */
688 /* (HC_INDEX_U_ETH_RX_BD_CONS) */
689
690#define HC_INDEX_TOE_TX_CQ_CONS 4 /* Formerly Cstorm TOE CQ index */
691 /* (HC_INDEX_C_TOE_TX_CQ_CONS) */
692#define HC_INDEX_ETH_TX_CQ_CONS_COS0 5 /* Formerly Cstorm ETH CQ index */
693 /* (HC_INDEX_C_ETH_TX_CQ_CONS) */
694#define HC_INDEX_ETH_TX_CQ_CONS_COS1 6 /* Formerly Cstorm ETH CQ index */
695 /* (HC_INDEX_C_ETH_TX_CQ_CONS) */
696#define HC_INDEX_ETH_TX_CQ_CONS_COS2 7 /* Formerly Cstorm ETH CQ index */
697 /* (HC_INDEX_C_ETH_TX_CQ_CONS) */
698 750
699#define HC_INDEX_ETH_FIRST_TX_CQ_CONS HC_INDEX_ETH_TX_CQ_CONS_COS0 751#define HC_INDEX_OOO_TX_CQ_CONS 4
700 752
753#define HC_INDEX_ETH_TX_CQ_CONS_COS0 5
754
755#define HC_INDEX_ETH_TX_CQ_CONS_COS1 6
756
757#define HC_INDEX_ETH_TX_CQ_CONS_COS2 7
758
759#define HC_INDEX_ETH_FIRST_TX_CQ_CONS HC_INDEX_ETH_TX_CQ_CONS_COS0
701 760
702#define BNX2X_RX_SB_INDEX \ 761#define BNX2X_RX_SB_INDEX \
703 (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS]) 762 (&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
@@ -1095,11 +1154,12 @@ struct bnx2x {
1095#define BP_PORT(bp) (bp->pfid & 1) 1154#define BP_PORT(bp) (bp->pfid & 1)
1096#define BP_FUNC(bp) (bp->pfid) 1155#define BP_FUNC(bp) (bp->pfid)
1097#define BP_ABS_FUNC(bp) (bp->pf_num) 1156#define BP_ABS_FUNC(bp) (bp->pf_num)
1098#define BP_E1HVN(bp) (bp->pfid >> 1) 1157#define BP_VN(bp) ((bp)->pfid >> 1)
1099#define BP_VN(bp) (BP_E1HVN(bp)) /*remove when approved*/ 1158#define BP_MAX_VN_NUM(bp) (CHIP_MODE_IS_4_PORT(bp) ? 2 : 4)
1100#define BP_L_ID(bp) (BP_E1HVN(bp) << 2) 1159#define BP_L_ID(bp) (BP_VN(bp) << 2)
1101#define BP_FW_MB_IDX(bp) (BP_PORT(bp) +\ 1160#define BP_FW_MB_IDX_VN(bp, vn) (BP_PORT(bp) +\
1102 BP_VN(bp) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1)) 1161 (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2 : 1))
1162#define BP_FW_MB_IDX(bp) BP_FW_MB_IDX_VN(bp, BP_VN(bp))
1103 1163
1104 struct net_device *dev; 1164 struct net_device *dev;
1105 struct pci_dev *pdev; 1165 struct pci_dev *pdev;
@@ -1762,7 +1822,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
1762 1822
1763#define MAX_DMAE_C_PER_PORT 8 1823#define MAX_DMAE_C_PER_PORT 8
1764#define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ 1824#define INIT_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
1765 BP_E1HVN(bp)) 1825 BP_VN(bp))
1766#define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ 1826#define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
1767 E1HVN_MAX) 1827 E1HVN_MAX)
1768 1828
@@ -1788,7 +1848,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
1788 1848
1789/* must be used on a CID before placing it on a HW ring */ 1849/* must be used on a CID before placing it on a HW ring */
1790#define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \ 1850#define HW_CID(bp, x) ((BP_PORT(bp) << 23) | \
1791 (BP_E1HVN(bp) << BNX2X_SWCID_SHIFT) | \ 1851 (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \
1792 (x)) 1852 (x))
1793 1853
1794#define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe)) 1854#define SP_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_spe))