[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201005203418.55128-1-fabf@skynet.be>
Date: Mon, 5 Oct 2020 22:34:18 +0200
From: Fabian Frederick <fabf@...net.be>
To: davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org
Cc: pablo@...filter.org, laforge@...monks.org,
steffen.klassert@...unet.com, herbert@...dor.apana.org.au,
pshelar@....org, dev@...nvswitch.org, yoshfuji@...ux-ipv6.org,
kuznet@....inr.ac.ru, Fabian Frederick <fabf@...net.be>
Subject: [PATCH 1/9 net-next] 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@...net.be>
---
include/linux/netdevice.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0c79d9e56a5e5..42b18e034adde 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2530,6 +2530,17 @@ 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);
--
2.28.0
Powered by blists - more mailing lists