]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: add dev_dstats_rx_dropped_add() helper
authorBreno Leitao <leitao@debian.org>
Wed, 18 Jun 2025 08:32:44 +0000 (01:32 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Jun 2025 23:15:34 +0000 (16:15 -0700)
Introduce the dev_dstats_rx_dropped_add() helper to allow incrementing
the rx_drops per-CPU statistic by an arbitrary value, rather than just
one. This is useful for drivers or code paths that need to account for
multiple dropped packets at once, such as when dropping entire queues.

Reviewed-by: Joe Damato <joe@dama.to>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20250618-netdevsim_stat-v4-3-19fe0d35e28e@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h

index 9cbc4e54b7e4a8a431f68032a9eebc82393f59c1..03c26bb0fbbef925fd022b3c8d7b6b30e85c4667 100644 (file)
@@ -3016,6 +3016,16 @@ static inline void dev_dstats_rx_dropped(struct net_device *dev)
        u64_stats_update_end(&dstats->syncp);
 }
 
+static inline void dev_dstats_rx_dropped_add(struct net_device *dev,
+                                            unsigned int packets)
+{
+       struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
+
+       u64_stats_update_begin(&dstats->syncp);
+       u64_stats_add(&dstats->rx_drops, packets);
+       u64_stats_update_end(&dstats->syncp);
+}
+
 static inline void dev_dstats_tx_add(struct net_device *dev,
                                     unsigned int len)
 {