net: natsemi: fix `rx_dropped` double accounting on `netif_rx()` failure
Subsystems (2)
PATCH v2 1/1 net: natsemi: fix `rx_dropped` double accounting on `netif_rx()` failure
netif_rx() already increments rx_dropped core stat when it fails. The driver was also updating ndev->stats.rx_dropped in the same path. Since both are reported together via ip -s -s command, this resulted in drops being counted twice in user-visible stats.
Keep the driver update on if (unlikely(!skb)), but skip it after netif_rx() errors.
---
changelog:
v1: https://lore.kernel.org/netdev/[email protected]/
v2:
- Correct commit reference in Fixes: tag.
- Fix incorrect commit message.
--- drivers/net/ethernet/natsemi/ns83820.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/natsemi/ns83820.c +6 -7
@@ -820,7 +820,7 @@ static void rx_irq(struct net_device *ndev)struct ns83820 *dev =PRIV (ndev);struct rx_info *info = &dev->rx_info;unsigned next_rx; -int rx_rc, len; +int len;u32 cmdsts;__le32 *desc;unsigned long flags;
@@ -881,8 +881,10 @@ static void rx_irq(struct net_device *ndev)if (likely (CMDSTS_OK & cmdsts)) {#endif skb_put (skb, len); -if (unlikely (!skb)) +if (unlikely (!skb)) { + ndev->stats.rx_dropped++; goto netdev_mangle_me_harder_failed; + }if (cmdsts &CMDSTS_DEST_MULTI ) ndev->stats.multicast++; ndev->stats.rx_packets++;
@@ -901,15 +903,12 @@ static void rx_irq(struct net_device *ndev) __vlan_hwaccel_put_tag(skb, htons(ETH_P_IPV6), tag); }#endif - rx_rc =netif_rx (skb); -if (NET_RX_DROP == rx_rc) { -netdev_mangle_me_harder_failed: - ndev->stats.rx_dropped++; - } +netif_rx (skb); }else {dev_kfree_skb_irq (skb); } +netdev_mangle_me_harder_failed: nr++; next_rx = info->next_rx; desc = info->descs + (DESC_SIZE * next_rx);
Signature · 1 line
2.51.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sat, 13 Sep 2025 15:01:36 +0900 you wrote:
netif_rx()already incrementsrx_droppedcore stat when it fails. The driver was also updatingndev->stats.rx_droppedin the same path. Since both are reported together viaip -s -scommand, this resulted in drops being counted twice in user-visible stats.Keep the driver update on
if (unlikely(!skb)), but skip it afternetif_rx()errors.[...]
Here is the summary with links:
- [net,v2] net: natsemi: fix rx_dropped double accounting on netif_rx() failure
https://git.kernel.org/netdev/net/c/93ab4881a4e2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html