diff options
author | Dmitry Kravkov <dmitry@broadcom.com> | 2011-08-29 20:08:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-09-15 14:49:29 -0400 |
commit | dfacf1387ceb6d7d6df614b18016fd1f347a1996 (patch) | |
tree | 59d234bafb337ff407851b96b5592abf61ee5da4 /drivers/net/bnx2x | |
parent | e9278a475f845833b569ca47171e64fe48c616e0 (diff) |
bnx2x: fix BRB thresholds for dropless_fc mode
Fix the thresholds according to 5778x HW and increase rx_ring size
to suit new thresholds in dropless_fc mode.
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x')
-rw-r--r-- | drivers/net/bnx2x/bnx2x.h | 84 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_cmn.c | 10 | ||||
-rw-r--r-- | drivers/net/bnx2x/bnx2x_main.c | 33 |
3 files changed, 102 insertions, 25 deletions
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index c423504a755f..85297326506c 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h | |||
@@ -315,6 +315,14 @@ union db_prod { | |||
315 | u32 raw; | 315 | u32 raw; |
316 | }; | 316 | }; |
317 | 317 | ||
318 | /* dropless fc FW/HW related params */ | ||
319 | #define BRB_SIZE(bp) (CHIP_IS_E3(bp) ? 1024 : 512) | ||
320 | #define MAX_AGG_QS(bp) (CHIP_IS_E1(bp) ? \ | ||
321 | ETH_MAX_AGGREGATION_QUEUES_E1 :\ | ||
322 | ETH_MAX_AGGREGATION_QUEUES_E1H_E2) | ||
323 | #define FW_DROP_LEVEL(bp) (3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp)) | ||
324 | #define FW_PREFETCH_CNT 16 | ||
325 | #define DROPLESS_FC_HEADROOM 100 | ||
318 | 326 | ||
319 | /* MC hsi */ | 327 | /* MC hsi */ |
320 | #define BCM_PAGE_SHIFT 12 | 328 | #define BCM_PAGE_SHIFT 12 |
@@ -331,15 +339,35 @@ union db_prod { | |||
331 | /* SGE ring related macros */ | 339 | /* SGE ring related macros */ |
332 | #define NUM_RX_SGE_PAGES 2 | 340 | #define NUM_RX_SGE_PAGES 2 |
333 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) | 341 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) |
334 | #define MAX_RX_SGE_CNT (RX_SGE_CNT - 2) | 342 | #define NEXT_PAGE_SGE_DESC_CNT 2 |
343 | #define MAX_RX_SGE_CNT (RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT) | ||
335 | /* RX_SGE_CNT is promised to be a power of 2 */ | 344 | /* RX_SGE_CNT is promised to be a power of 2 */ |
336 | #define RX_SGE_MASK (RX_SGE_CNT - 1) | 345 | #define RX_SGE_MASK (RX_SGE_CNT - 1) |
337 | #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES) | 346 | #define NUM_RX_SGE (RX_SGE_CNT * NUM_RX_SGE_PAGES) |
338 | #define MAX_RX_SGE (NUM_RX_SGE - 1) | 347 | #define MAX_RX_SGE (NUM_RX_SGE - 1) |
339 | #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \ | 348 | #define NEXT_SGE_IDX(x) ((((x) & RX_SGE_MASK) == \ |
340 | (MAX_RX_SGE_CNT - 1)) ? (x) + 3 : (x) + 1) | 349 | (MAX_RX_SGE_CNT - 1)) ? \ |
350 | (x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \ | ||
351 | (x) + 1) | ||
341 | #define RX_SGE(x) ((x) & MAX_RX_SGE) | 352 | #define RX_SGE(x) ((x) & MAX_RX_SGE) |
342 | 353 | ||
354 | /* | ||
355 | * Number of required SGEs is the sum of two: | ||
356 | * 1. Number of possible opened aggregations (next packet for | ||
357 | * these aggregations will probably consume SGE immidiatelly) | ||
358 | * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only | ||
359 | * after placement on BD for new TPA aggregation) | ||
360 | * | ||
361 | * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page | ||
362 | */ | ||
363 | #define NUM_SGE_REQ (MAX_AGG_QS(bp) + \ | ||
364 | (BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2) | ||
365 | #define NUM_SGE_PG_REQ ((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \ | ||
366 | MAX_RX_SGE_CNT) | ||
367 | #define SGE_TH_LO(bp) (NUM_SGE_REQ + \ | ||
368 | NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT) | ||
369 | #define SGE_TH_HI(bp) (SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM) | ||
370 | |||
343 | /* Manipulate a bit vector defined as an array of u64 */ | 371 | /* Manipulate a bit vector defined as an array of u64 */ |
344 | 372 | ||
345 | /* Number of bits in one sge_mask array element */ | 373 | /* Number of bits in one sge_mask array element */ |
@@ -551,24 +579,43 @@ struct bnx2x_fastpath { | |||
551 | 579 | ||
552 | #define NUM_TX_RINGS 16 | 580 | #define NUM_TX_RINGS 16 |
553 | #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types)) | 581 | #define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types)) |
554 | #define MAX_TX_DESC_CNT (TX_DESC_CNT - 1) | 582 | #define NEXT_PAGE_TX_DESC_CNT 1 |
583 | #define MAX_TX_DESC_CNT (TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT) | ||
555 | #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS) | 584 | #define NUM_TX_BD (TX_DESC_CNT * NUM_TX_RINGS) |
556 | #define MAX_TX_BD (NUM_TX_BD - 1) | 585 | #define MAX_TX_BD (NUM_TX_BD - 1) |
557 | #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2) | 586 | #define MAX_TX_AVAIL (MAX_TX_DESC_CNT * NUM_TX_RINGS - 2) |
558 | #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \ | 587 | #define NEXT_TX_IDX(x) ((((x) & MAX_TX_DESC_CNT) == \ |
559 | (MAX_TX_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) | 588 | (MAX_TX_DESC_CNT - 1)) ? \ |
589 | (x) + 1 + NEXT_PAGE_TX_DESC_CNT : \ | ||
590 | (x) + 1) | ||
560 | #define TX_BD(x) ((x) & MAX_TX_BD) | 591 | #define TX_BD(x) ((x) & MAX_TX_BD) |
561 | #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT) | 592 | #define TX_BD_POFF(x) ((x) & MAX_TX_DESC_CNT) |
562 | 593 | ||
563 | /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */ | 594 | /* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */ |
564 | #define NUM_RX_RINGS 8 | 595 | #define NUM_RX_RINGS 8 |
565 | #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd)) | 596 | #define RX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_bd)) |
566 | #define MAX_RX_DESC_CNT (RX_DESC_CNT - 2) | 597 | #define NEXT_PAGE_RX_DESC_CNT 2 |
598 | #define MAX_RX_DESC_CNT (RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT) | ||
567 | #define RX_DESC_MASK (RX_DESC_CNT - 1) | 599 | #define RX_DESC_MASK (RX_DESC_CNT - 1) |
568 | #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS) | 600 | #define NUM_RX_BD (RX_DESC_CNT * NUM_RX_RINGS) |
569 | #define MAX_RX_BD (NUM_RX_BD - 1) | 601 | #define MAX_RX_BD (NUM_RX_BD - 1) |
570 | #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2) | 602 | #define MAX_RX_AVAIL (MAX_RX_DESC_CNT * NUM_RX_RINGS - 2) |
571 | #define MIN_RX_AVAIL 128 | 603 | |
604 | /* dropless fc calculations for BDs | ||
605 | * | ||
606 | * Number of BDs should as number of buffers in BRB: | ||
607 | * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT | ||
608 | * "next" elements on each page | ||
609 | */ | ||
610 | #define NUM_BD_REQ BRB_SIZE(bp) | ||
611 | #define NUM_BD_PG_REQ ((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \ | ||
612 | MAX_RX_DESC_CNT) | ||
613 | #define BD_TH_LO(bp) (NUM_BD_REQ + \ | ||
614 | NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \ | ||
615 | FW_DROP_LEVEL(bp)) | ||
616 | #define BD_TH_HI(bp) (BD_TH_LO(bp) + DROPLESS_FC_HEADROOM) | ||
617 | |||
618 | #define MIN_RX_AVAIL ((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128) | ||
572 | 619 | ||
573 | #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \ | 620 | #define MIN_RX_SIZE_TPA_HW (CHIP_IS_E1(bp) ? \ |
574 | ETH_MIN_RX_CQES_WITH_TPA_E1 : \ | 621 | ETH_MIN_RX_CQES_WITH_TPA_E1 : \ |
@@ -579,7 +626,9 @@ struct bnx2x_fastpath { | |||
579 | MIN_RX_AVAIL)) | 626 | MIN_RX_AVAIL)) |
580 | 627 | ||
581 | #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \ | 628 | #define NEXT_RX_IDX(x) ((((x) & RX_DESC_MASK) == \ |
582 | (MAX_RX_DESC_CNT - 1)) ? (x) + 3 : (x) + 1) | 629 | (MAX_RX_DESC_CNT - 1)) ? \ |
630 | (x) + 1 + NEXT_PAGE_RX_DESC_CNT : \ | ||
631 | (x) + 1) | ||
583 | #define RX_BD(x) ((x) & MAX_RX_BD) | 632 | #define RX_BD(x) ((x) & MAX_RX_BD) |
584 | 633 | ||
585 | /* | 634 | /* |
@@ -589,14 +638,31 @@ struct bnx2x_fastpath { | |||
589 | #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd)) | 638 | #define CQE_BD_REL (sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd)) |
590 | #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL) | 639 | #define NUM_RCQ_RINGS (NUM_RX_RINGS * CQE_BD_REL) |
591 | #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) | 640 | #define RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) |
592 | #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - 1) | 641 | #define NEXT_PAGE_RCQ_DESC_CNT 1 |
642 | #define MAX_RCQ_DESC_CNT (RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT) | ||
593 | #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS) | 643 | #define NUM_RCQ_BD (RCQ_DESC_CNT * NUM_RCQ_RINGS) |
594 | #define MAX_RCQ_BD (NUM_RCQ_BD - 1) | 644 | #define MAX_RCQ_BD (NUM_RCQ_BD - 1) |
595 | #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2) | 645 | #define MAX_RCQ_AVAIL (MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2) |
596 | #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \ | 646 | #define NEXT_RCQ_IDX(x) ((((x) & MAX_RCQ_DESC_CNT) == \ |
597 | (MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1) | 647 | (MAX_RCQ_DESC_CNT - 1)) ? \ |
648 | (x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \ | ||
649 | (x) + 1) | ||
598 | #define RCQ_BD(x) ((x) & MAX_RCQ_BD) | 650 | #define RCQ_BD(x) ((x) & MAX_RCQ_BD) |
599 | 651 | ||
652 | /* dropless fc calculations for RCQs | ||
653 | * | ||
654 | * Number of RCQs should be as number of buffers in BRB: | ||
655 | * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT | ||
656 | * "next" elements on each page | ||
657 | */ | ||
658 | #define NUM_RCQ_REQ BRB_SIZE(bp) | ||
659 | #define NUM_RCQ_PG_REQ ((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \ | ||
660 | MAX_RCQ_DESC_CNT) | ||
661 | #define RCQ_TH_LO(bp) (NUM_RCQ_REQ + \ | ||
662 | NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \ | ||
663 | FW_DROP_LEVEL(bp)) | ||
664 | #define RCQ_TH_HI(bp) (RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM) | ||
665 | |||
600 | 666 | ||
601 | /* This is needed for determining of last_max */ | 667 | /* This is needed for determining of last_max */ |
602 | #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) | 668 | #define SUB_S16(a, b) (s16)((s16)(a) - (s16)(b)) |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c index 37e5790681ad..2a33d2433c31 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.c +++ b/drivers/net/bnx2x/bnx2x_cmn.c | |||
@@ -987,8 +987,6 @@ void __bnx2x_link_report(struct bnx2x *bp) | |||
987 | void bnx2x_init_rx_rings(struct bnx2x *bp) | 987 | void bnx2x_init_rx_rings(struct bnx2x *bp) |
988 | { | 988 | { |
989 | int func = BP_FUNC(bp); | 989 | int func = BP_FUNC(bp); |
990 | int max_agg_queues = CHIP_IS_E1(bp) ? ETH_MAX_AGGREGATION_QUEUES_E1 : | ||
991 | ETH_MAX_AGGREGATION_QUEUES_E1H_E2; | ||
992 | u16 ring_prod; | 990 | u16 ring_prod; |
993 | int i, j; | 991 | int i, j; |
994 | 992 | ||
@@ -1001,7 +999,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) | |||
1001 | 999 | ||
1002 | if (!fp->disable_tpa) { | 1000 | if (!fp->disable_tpa) { |
1003 | /* Fill the per-aggregtion pool */ | 1001 | /* Fill the per-aggregtion pool */ |
1004 | for (i = 0; i < max_agg_queues; i++) { | 1002 | for (i = 0; i < MAX_AGG_QS(bp); i++) { |
1005 | struct bnx2x_agg_info *tpa_info = | 1003 | struct bnx2x_agg_info *tpa_info = |
1006 | &fp->tpa_info[i]; | 1004 | &fp->tpa_info[i]; |
1007 | struct sw_rx_bd *first_buf = | 1005 | struct sw_rx_bd *first_buf = |
@@ -1041,7 +1039,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) | |||
1041 | bnx2x_free_rx_sge_range(bp, fp, | 1039 | bnx2x_free_rx_sge_range(bp, fp, |
1042 | ring_prod); | 1040 | ring_prod); |
1043 | bnx2x_free_tpa_pool(bp, fp, | 1041 | bnx2x_free_tpa_pool(bp, fp, |
1044 | max_agg_queues); | 1042 | MAX_AGG_QS(bp)); |
1045 | fp->disable_tpa = 1; | 1043 | fp->disable_tpa = 1; |
1046 | ring_prod = 0; | 1044 | ring_prod = 0; |
1047 | break; | 1045 | break; |
@@ -1137,9 +1135,7 @@ static void bnx2x_free_rx_skbs(struct bnx2x *bp) | |||
1137 | bnx2x_free_rx_bds(fp); | 1135 | bnx2x_free_rx_bds(fp); |
1138 | 1136 | ||
1139 | if (!fp->disable_tpa) | 1137 | if (!fp->disable_tpa) |
1140 | bnx2x_free_tpa_pool(bp, fp, CHIP_IS_E1(bp) ? | 1138 | bnx2x_free_tpa_pool(bp, fp, MAX_AGG_QS(bp)); |
1141 | ETH_MAX_AGGREGATION_QUEUES_E1 : | ||
1142 | ETH_MAX_AGGREGATION_QUEUES_E1H_E2); | ||
1143 | } | 1139 | } |
1144 | } | 1140 | } |
1145 | 1141 | ||
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index f74582a22c68..3f93e8666104 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -2756,8 +2756,14 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, | |||
2756 | u16 tpa_agg_size = 0; | 2756 | u16 tpa_agg_size = 0; |
2757 | 2757 | ||
2758 | if (!fp->disable_tpa) { | 2758 | if (!fp->disable_tpa) { |
2759 | pause->sge_th_hi = 250; | 2759 | pause->sge_th_lo = SGE_TH_LO(bp); |
2760 | pause->sge_th_lo = 150; | 2760 | pause->sge_th_hi = SGE_TH_HI(bp); |
2761 | |||
2762 | /* validate SGE ring has enough to cross high threshold */ | ||
2763 | WARN_ON(bp->dropless_fc && | ||
2764 | pause->sge_th_hi + FW_PREFETCH_CNT > | ||
2765 | MAX_RX_SGE_CNT * NUM_RX_SGE_PAGES); | ||
2766 | |||
2761 | tpa_agg_size = min_t(u32, | 2767 | tpa_agg_size = min_t(u32, |
2762 | (min_t(u32, 8, MAX_SKB_FRAGS) * | 2768 | (min_t(u32, 8, MAX_SKB_FRAGS) * |
2763 | SGE_PAGE_SIZE * PAGES_PER_SGE), 0xffff); | 2769 | SGE_PAGE_SIZE * PAGES_PER_SGE), 0xffff); |
@@ -2771,10 +2777,21 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, | |||
2771 | 2777 | ||
2772 | /* pause - not for e1 */ | 2778 | /* pause - not for e1 */ |
2773 | if (!CHIP_IS_E1(bp)) { | 2779 | if (!CHIP_IS_E1(bp)) { |
2774 | pause->bd_th_hi = 350; | 2780 | pause->bd_th_lo = BD_TH_LO(bp); |
2775 | pause->bd_th_lo = 250; | 2781 | pause->bd_th_hi = BD_TH_HI(bp); |
2776 | pause->rcq_th_hi = 350; | 2782 | |
2777 | pause->rcq_th_lo = 250; | 2783 | pause->rcq_th_lo = RCQ_TH_LO(bp); |
2784 | pause->rcq_th_hi = RCQ_TH_HI(bp); | ||
2785 | /* | ||
2786 | * validate that rings have enough entries to cross | ||
2787 | * high thresholds | ||
2788 | */ | ||
2789 | WARN_ON(bp->dropless_fc && | ||
2790 | pause->bd_th_hi + FW_PREFETCH_CNT > | ||
2791 | bp->rx_ring_size); | ||
2792 | WARN_ON(bp->dropless_fc && | ||
2793 | pause->rcq_th_hi + FW_PREFETCH_CNT > | ||
2794 | NUM_RCQ_RINGS * MAX_RCQ_DESC_CNT); | ||
2778 | 2795 | ||
2779 | pause->pri_map = 1; | 2796 | pause->pri_map = 1; |
2780 | } | 2797 | } |
@@ -2802,9 +2819,7 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, | |||
2802 | * For PF Clients it should be the maximum avaliable number. | 2819 | * For PF Clients it should be the maximum avaliable number. |
2803 | * VF driver(s) may want to define it to a smaller value. | 2820 | * VF driver(s) may want to define it to a smaller value. |
2804 | */ | 2821 | */ |
2805 | rxq_init->max_tpa_queues = | 2822 | rxq_init->max_tpa_queues = MAX_AGG_QS(bp); |
2806 | (CHIP_IS_E1(bp) ? ETH_MAX_AGGREGATION_QUEUES_E1 : | ||
2807 | ETH_MAX_AGGREGATION_QUEUES_E1H_E2); | ||
2808 | 2823 | ||
2809 | rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT; | 2824 | rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT; |
2810 | rxq_init->fw_sb_id = fp->fw_sb_id; | 2825 | rxq_init->fw_sb_id = fp->fw_sb_id; |