]> Git Repo - linux.git/commitdiff
net: netdevice.h: sw_netstats_rx_add helper
authorFabian Frederick <[email protected]>
Mon, 5 Oct 2020 20:34:18 +0000 (22:34 +0200)
committerDavid S. Miller <[email protected]>
Tue, 6 Oct 2020 13:23:21 +0000 (06:23 -0700)
some drivers/network protocols update rx bytes/packets under
u64_stats_update_begin/end sequence.
Add a specific helper like dev_lstats_add()

Signed-off-by: Fabian Frederick <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
include/linux/netdevice.h

index d126e36580c95ab37e04c6c6e7b0de682ec70a0d..a0df43b1383927658bda01c65e81a1d92437e517 100644 (file)
@@ -2543,6 +2543,16 @@ struct pcpu_lstats {
 
 void dev_lstats_read(struct net_device *dev, u64 *packets, u64 *bytes);
 
+static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int len)
+{
+       struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
+
+       u64_stats_update_begin(&tstats->syncp);
+       tstats->rx_bytes += len;
+       tstats->rx_packets++;
+       u64_stats_update_end(&tstats->syncp);
+}
+
 static inline void dev_lstats_add(struct net_device *dev, unsigned int len)
 {
        struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats);
This page took 0.065512 seconds and 4 git commands to generate.