public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail•com>
To: "David Miller" <davem@davemloft•net>,
	"Jakub Kicinski" <kuba@kernel•org>, "Bjørn Mork" <bjorn@mork•no>,
	"Oliver Neukum" <oneukum@suse•com>,
	"Igor Mitsyanko" <imitsyanko@quantenna•com>,
	"Sergey Matyukevich" <geomatsi@gmail•com>,
	"Kalle Valo" <kvalo@codeaurora•org>,
	"Roopa Prabhu" <roopa@nvidia•com>,
	"Nikolay Aleksandrov" <nikolay@nvidia•com>,
	"Andrew Lunn" <andrew@lunn•ch>,
	"Vivien Didelot" <vivien.didelot@gmail•com>,
	"Florian Fainelli" <f.fainelli@gmail•com>,
	"Vladimir Oltean" <olteanv@gmail•com>,
	"Alexey Kuznetsov" <kuznet@ms2•inr.ac.ru>,
	"Hideaki YOSHIFUJI" <yoshfuji@linux-ipv6•org>,
	"Johannes Berg" <johannes@sipsolutions•net>,
	"Pravin B Shelar" <pshelar@ovn•org>,
	"Steffen Klassert" <steffen.klassert@secunet•com>,
	"Herbert Xu" <herbert@gondor•apana.org.au>
Cc: "netdev@vger•kernel.org" <netdev@vger•kernel.org>,
	linux-rdma@vger•kernel.org,
	Linux USB Mailing List <linux-usb@vger•kernel.org>,
	linux-wireless <linux-wireless@vger•kernel.org>,
	bridge@lists•linux-foundation.org
Subject: [PATCH net-next v2 05/12] net: usbnet: use new function dev_fetch_sw_netstats
Date: Mon, 12 Oct 2020 10:07:33 +0200	[thread overview]
Message-ID: <70ad3e33-8ea6-e12e-31de-5fec7a3c4f6e@gmail.com> (raw)
In-Reply-To: <d77b65de-1793-f808-66b5-aaa4e7c8a8f0@gmail.com>

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail•com>
---
 drivers/net/usb/usbnet.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 963d260d1..6062dc278 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -983,31 +983,9 @@ EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings);
 void usbnet_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats)
 {
 	struct usbnet *dev = netdev_priv(net);
-	unsigned int start;
-	int cpu;
 
 	netdev_stats_to_stats64(stats, &net->stats);
-
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *stats64;
-		u64 rx_packets, rx_bytes;
-		u64 tx_packets, tx_bytes;
-
-		stats64 = per_cpu_ptr(dev->stats64, cpu);
-
-		do {
-			start = u64_stats_fetch_begin_irq(&stats64->syncp);
-			rx_packets = stats64->rx_packets;
-			rx_bytes = stats64->rx_bytes;
-			tx_packets = stats64->tx_packets;
-			tx_bytes = stats64->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
-
-		stats->rx_packets += rx_packets;
-		stats->rx_bytes += rx_bytes;
-		stats->tx_packets += tx_packets;
-		stats->tx_bytes += tx_bytes;
-	}
+	dev_fetch_sw_netstats(stats, dev->stats64);
 }
 EXPORT_SYMBOL_GPL(usbnet_get_stats64);
 
-- 
2.28.0



  parent reply	other threads:[~2020-10-12  8:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12  8:00 [PATCH net-next v2 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
2020-10-12  8:01 ` [PATCH net-next v2 01/12] net: add " Heiner Kallweit
2020-10-12  8:03 ` [PATCH net-next v2 02/12] IB/hfi1: use new function dev_fetch_sw_netstats Heiner Kallweit
2020-10-12  8:04 ` [PATCH net-next v2 03/12] net: macsec: " Heiner Kallweit
2020-10-12  8:06 ` [PATCH net-next v2 04/12] net: usb: qmi_wwan: " Heiner Kallweit
2020-10-12  8:07 ` Heiner Kallweit [this message]
2020-10-12  8:14 ` [PATCH net-next v2 06/12] qtnfmac: " Heiner Kallweit
2020-10-12  8:15 ` [PATCH net-next v2 07/12] net: bridge: " Heiner Kallweit
2020-10-12  8:16 ` [PATCH net-next v2 08/12] net: dsa: " Heiner Kallweit
2020-10-12  8:17 ` [PATCH net-next v2 09/12] iptunnel: " Heiner Kallweit
2020-10-12  8:18 ` [PATCH net-next v2 10/12] mac80211: " Heiner Kallweit
2020-10-12  8:19 ` [PATCH net-next v2 11/12] net: openvswitch: " Heiner Kallweit
2020-10-12  8:19 ` [PATCH net-next v2 12/12] xfrm: " Heiner Kallweit
2020-10-14  0:39 ` [PATCH net-next v2 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
2020-10-14  5:42   ` Leon Romanovsky
2020-10-14  6:13     ` Heiner Kallweit
2020-10-14  7:53       ` Leon Romanovsky
2020-10-14  7:59         ` Heiner Kallweit
2020-10-14  8:01           ` Johannes Berg
2020-10-14  8:33             ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70ad3e33-8ea6-e12e-31de-5fec7a3c4f6e@gmail.com \
    --to=hkallweit1@gmail$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=bjorn@mork$(echo .)no \
    --cc=bridge@lists$(echo .)linux-foundation.org \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=geomatsi@gmail$(echo .)com \
    --cc=herbert@gondor$(echo .)apana.org.au \
    --cc=imitsyanko@quantenna$(echo .)com \
    --cc=johannes@sipsolutions$(echo .)net \
    --cc=kuba@kernel$(echo .)org \
    --cc=kuznet@ms2$(echo .)inr.ac.ru \
    --cc=kvalo@codeaurora$(echo .)org \
    --cc=linux-rdma@vger$(echo .)kernel.org \
    --cc=linux-usb@vger$(echo .)kernel.org \
    --cc=linux-wireless@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikolay@nvidia$(echo .)com \
    --cc=olteanv@gmail$(echo .)com \
    --cc=oneukum@suse$(echo .)com \
    --cc=pshelar@ovn$(echo .)org \
    --cc=roopa@nvidia$(echo .)com \
    --cc=steffen.klassert@secunet$(echo .)com \
    --cc=vivien.didelot@gmail$(echo .)com \
    --cc=yoshfuji@linux-ipv6$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox