aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Frederick <fabf@skynet.be>2020-10-05 22:34:18 +0200
committerDavid S. Miller <davem@davemloft.net>2020-10-06 06:23:21 -0700
commit451b05f413d3fd89ee84ae99a5029f619ed3cb78 (patch)
tree5ed9d7aa61f139a8c86b9c46e1c9f3ba8860579b
parentMerge branch 'net-atlantic-phy-tunables-from-mac-driver' (diff)
downloadlinux-dev-451b05f413d3fd89ee84ae99a5029f619ed3cb78.tar.xz
linux-dev-451b05f413d3fd89ee84ae99a5029f619ed3cb78.zip
net: netdevice.h: sw_netstats_rx_add helper
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 <fabf@skynet.be> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d126e36580c9..a0df43b13839 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -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);