Skip to content

Commit eb30b26

Browse files
stefanchulskidavem330
authored andcommitted
net: mvpp2: add BM protection underrun feature support
The PP2v23 hardware supports a feature allowing to double the size of BPPI by decreasing number of pools from 16 to 8. Increasing of BPPI size protect BM drop from BPPI underrun. Underrun could occurred due to stress on DDR and as result slow buffer transition from BPPE to BPPI. New BPPI threshold recommended by spec is: BPPI low threshold - 640 buffers BPPI high threshold - 832 buffers Supported only in PPv23. Signed-off-by: Stefan Chulski <[email protected]> Acked-by: Marcin Wojtas <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7605583 commit eb30b26

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@
324324
#define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000
325325
#define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \
326326
MVPP2_BM_HIGH_THRESH_OFFS)
327+
#define MVPP2_BM_BPPI_HIGH_THRESH 0x1E
328+
#define MVPP2_BM_BPPI_LOW_THRESH 0x1C
329+
#define MVPP23_BM_BPPI_HIGH_THRESH 0x34
330+
#define MVPP23_BM_BPPI_LOW_THRESH 0x28
327331
#define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4))
328332
#define MVPP2_BM_RELEASED_DELAY_MASK BIT(0)
329333
#define MVPP2_BM_ALLOC_FAILED_MASK BIT(1)
@@ -352,6 +356,10 @@
352356
#define MVPP2_OVERRUN_ETH_DROP 0x7000
353357
#define MVPP2_CLS_ETH_DROP 0x7020
354358

359+
#define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG 0x6310
360+
#define MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK 0xff
361+
#define MVPP23_BM_8POOL_MODE BIT(8)
362+
355363
/* Hit counters registers */
356364
#define MVPP2_CTRS_IDX 0x7040
357365
#define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7))

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,19 @@ static int mvpp2_bm_pool_create(struct device *dev, struct mvpp2 *priv,
423423

424424
val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id));
425425
val |= MVPP2_BM_START_MASK;
426+
427+
val &= ~MVPP2_BM_LOW_THRESH_MASK;
428+
val &= ~MVPP2_BM_HIGH_THRESH_MASK;
429+
430+
/* Set 8 Pools BPPI threshold for MVPP23 */
431+
if (priv->hw_version == MVPP23) {
432+
val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP23_BM_BPPI_LOW_THRESH);
433+
val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP23_BM_BPPI_HIGH_THRESH);
434+
} else {
435+
val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP2_BM_BPPI_LOW_THRESH);
436+
val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP2_BM_BPPI_HIGH_THRESH);
437+
}
438+
426439
mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val);
427440

428441
bm_pool->size = size;
@@ -591,6 +604,16 @@ static int mvpp2_bm_pools_init(struct device *dev, struct mvpp2 *priv)
591604
return err;
592605
}
593606

607+
/* Routine enable PPv23 8 pool mode */
608+
static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv)
609+
{
610+
int val;
611+
612+
val = mvpp2_read(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG);
613+
val |= MVPP23_BM_8POOL_MODE;
614+
mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val);
615+
}
616+
594617
static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
595618
{
596619
enum dma_data_direction dma_dir = DMA_FROM_DEVICE;
@@ -644,6 +667,9 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
644667
if (!priv->bm_pools)
645668
return -ENOMEM;
646669

670+
if (priv->hw_version == MVPP23)
671+
mvpp23_bm_set_8pool_mode(priv);
672+
647673
err = mvpp2_bm_pools_init(dev, priv);
648674
if (err < 0)
649675
return err;

0 commit comments

Comments
 (0)