[PATCH net v2 3/4] net: macb: increment stats.tx_dropped on tx error

Théo Lebrun
2026-04-28T16:33:35Z

macb_tx_error_task() is the workqueue callback on Tx errors interrupts
(MACB_TX_ERR_FLAGS). Count number of errored SKBs and increment the Tx
dropped stat by that amount.

Two types of dropped (not consumed) packets:
- Those that have been TX_USED but with an error.
- Those that have not been TX_USED but that'll we drop to reset.

Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver")
Cc: stable@vger.kernel.org
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/net/ethernet/cadence/macb_main.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5a2500bd59a6..ba7cbb10dc2c 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1261,6 +1261,7 @@ static void macb_tx_error_task(struct work_struct *work)
struct macb *bp = queue->bp;
u32 queue_index;
u32 packets = 0;
+ unsigned int dropped = 0;
u32 bytes = 0;
struct macb_tx_skb *tx_skb;
struct macb_dma_desc *desc;
@@ -1332,6 +1333,8 @@ static void macb_tx_error_task(struct work_struct *work)
queue->stats.tx_bytes += skb->len;
bytes += skb->len;
reason = SKB_CONSUMED;
+ } else {
+ dropped++;
}
} else {
/* "Buffers exhausted mid-frame" errors may only happen
@@ -1343,11 +1346,17 @@ static void macb_tx_error_task(struct work_struct *work)
"BUG: TX buffers exhausted mid-frame\n");

desc->ctrl = ctrl | MACB_BIT(TX_USED);
+
+ if (skb)
+ dropped++;
}

macb_tx_unmap(bp, tx_skb, 0, reason);
}

+ queue->stats.tx_dropped += dropped;
+ bp->dev->stats.tx_dropped += dropped;
+
netdev_tx_completed_queue(netdev_get_tx_queue(bp->dev, queue_index),
packets, bytes);

--
2.54.0