aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x.h
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2011-08-29 20:08:39 -0400
committerDavid S. Miller <davem@davemloft.net>2011-09-15 14:49:29 -0400
commitdfacf1387ceb6d7d6df614b18016fd1f347a1996 (patch)
tree59d234bafb337ff407851b96b5592abf61ee5da4 /drivers/net/bnx2x/bnx2x.h
parente9278a475f845833b569ca47171e64fe48c616e0 (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/bnx2x.h')
-rw-r--r--drivers/net/bnx2x/bnx2x.h84
1 files changed, 75 insertions, 9 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))