diff options
| author | Serge Semin <fancer.lancer@gmail.com> | 2025-08-20 16:01:48 +0300 |
|---|---|---|
| committer | Serge Semin <fancer.lancer@gmail.com> | 2026-08-13 20:29:53 +0300 |
| commit | dda9cd0a96dcb47ad8fc1140505187ace1ee2140 (patch) | |
| tree | 5e3d4cad22a6444b20a7a979281e223bb82d0251 | |
| parent | b3e0ead2417a30df046b237e7fc6959976f97541 (diff) | |
| download | linux-dda9cd0a96dcb47ad8fc1140505187ace1ee2140.tar.gz linux-dda9cd0a96dcb47ad8fc1140505187ace1ee2140.zip | |
net: stmmac: dwxgmac2: Collect MTL missing frames statistics
DW XGMAC/XLGMAC expose the frames missing due to Rx buffer unavailable or
MTL Rx FIFO overflow statistics via MTL_RxQ(#i)_Missed_Pkt_Overflow_Cnt
CSR for each available queue. Functionally it's equivalent to what is
available in DW MAC100/GMAC IP-cores in the framework of the
DMA-missing-frames counters.
Such counters are exceptionally useful on the interface performance
debugging to track down the reasons of the sudden packets disappearance.
So let's add their support in the same way as it has been done for DW
MAC100/GMAC controllers - via the stmmac_dma_ops::dma_diagnostic_fr()
callback implementation.
Fixes: d6ddfacd95c7 ("net: stmmac: Add DMA related callbacks for XGMAC2")
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 5 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index ca86112a7f23..a2037d224ce9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -325,6 +325,11 @@ #define XGMAC_EHFC BIT(7) #define XGMAC_RSF BIT(5) #define XGMAC_RTC GENMASK(1, 0) +#define XGMAC_MTL_RXQ_MISSED_PKT_CTR(x) (0x00001144 + (0x80 * (x))) +#define XGMAC_MISCNTOVF BIT(31) +#define XGMAC_MISPKTCNT GENMASK(26, 16) +#define XGMAC_OVFCNTOVF BIT(15) +#define XGMAC_OVFPKTCNT GENMASK(10, 0) #define XGMAC_MTL_RXQ_DEBUG(x) (0x00001148 + (0x80 * (x))) #define XGMAC_RXQSTS_MASK GENMASK(5, 4) #define XGMAC_RXQSTS_EMPTY 0 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c index 0425199e91a0..c5888055c4e6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -614,6 +614,25 @@ static int dwxgmac2_enable_tbs(struct stmmac_priv *priv, void __iomem *ioaddr, return 0; } +static void dwxgmac2_dma_diagnostic_fr(struct stmmac_priv *priv, void __iomem *ioaddr, + struct stmmac_extra_stats *x, u32 chan) +{ + u32 value = readl(ioaddr + XGMAC_MTL_RXQ_MISSED_PKT_CTR(chan)); + unsigned long cntr; + + cntr = FIELD_GET(XGMAC_MISPKTCNT, value); + if (value & XGMAC_MISCNTOVF) + cntr += FIELD_MAX(XGMAC_MISPKTCNT) + 1; + + x->rx_missed_cntr += cntr; + + cntr = FIELD_GET(XGMAC_OVFPKTCNT, value); + if (value & XGMAC_OVFCNTOVF) + cntr += FIELD_MAX(XGMAC_OVFPKTCNT) + 1; + + x->rx_overflow_cntr += cntr; +} + const struct stmmac_dma_ops dwxgmac210_dma_ops = { .reset = dwxgmac2_dma_reset, .init = dwxgmac2_dma_init, @@ -624,6 +643,7 @@ const struct stmmac_dma_ops dwxgmac210_dma_ops = { .dump_regs = dwxgmac2_dma_dump_regs, .dma_rx_mode = dwxgmac2_dma_rx_mode, .dma_tx_mode = dwxgmac2_dma_tx_mode, + .dma_diagnostic_fr = dwxgmac2_dma_diagnostic_fr, .enable_dma_irq = dwxgmac2_enable_dma_irq, .disable_dma_irq = dwxgmac2_disable_dma_irq, .start_tx = dwxgmac2_dma_start_tx, |
