diff mbox series

[04/38] backport: add dev_sw_netstats_tx/rx_add() functions

Message ID 20221011230356.2960f8b2fb4e.I16f0b19a20bfa28f277fa171600017bbdd4ed8b2@changeid (mailing list archive)
State New, archived
Headers show
Series backports updates | expand

Commit Message

Johannes Berg Oct. 11, 2022, 9:04 p.m. UTC
From: Luca Coelho <luciano.coelho@intel.com>

Two new functions were added in v5.10 and are now used in mac80211.
Add them as bakcports in netdevice.h

type=maint
ticket=jira:WIFI-95070

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Reviewed-on: https://git-ger-8.devtools.intel.com/gerrit/139718
---
 backport/backport-include/linux/netdevice.h | 25 +++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
index e17731909ca5..c6ca8b5556d5 100644
--- a/backport/backport-include/linux/netdevice.h
+++ b/backport/backport-include/linux/netdevice.h
@@ -111,6 +111,31 @@  void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
 
 #define netif_rx_any_context LINUX_BACKPORT(netif_rx_any_context)
 int netif_rx_any_context(struct sk_buff *skb);
+
+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);
+}
+
+#endif /* < 5.10 */
+
+#if LINUX_VERSION_IS_LESS(5,10,0)
+static inline void dev_sw_netstats_tx_add(struct net_device *dev,
+					  unsigned int packets,
+					  unsigned int len)
+{
+	struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
+
+	u64_stats_update_begin(&tstats->syncp);
+	tstats->tx_bytes += len;
+	tstats->tx_packets += packets;
+	u64_stats_update_end(&tstats->syncp);
+}
 #endif /* < 5.10 */
 
 #if LINUX_VERSION_IS_LESS(5,10,0)