* [PATCH 1/9 net-next] net: netdevice.h: sw_netstats_rx_add helper
@ 2020-10-05 20:34 Fabian Frederick
2020-10-05 23:14 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2020-10-05 20:34 UTC (permalink / raw)
To: davem, kuba, netdev
Cc: pablo, laforge, steffen.klassert, herbert, pshelar, dev,
yoshfuji, kuznet, Fabian Frederick
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/9 net-next] net: netdevice.h: sw_netstats_rx_add helper
2020-10-05 20:34 [PATCH 1/9 net-next] net: netdevice.h: sw_netstats_rx_add helper Fabian Frederick
@ 2020-10-05 23:14 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-10-05 23:14 UTC (permalink / raw)
To: Fabian Frederick
Cc: davem, netdev, pablo, laforge, steffen.klassert, herbert,
pshelar, dev, yoshfuji, kuznet
On Mon, 5 Oct 2020 22:34:18 +0200 Fabian Frederick wrote:
> +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);
> +
checkpatch points out there is an unnecessary empty line here
> +}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-05 23:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 20:34 [PATCH 1/9 net-next] net: netdevice.h: sw_netstats_rx_add helper Fabian Frederick
2020-10-05 23:14 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).