netdev.vger.kernel.org archive mirror
 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 02/12] IB/hfi1: use new function dev_fetch_sw_netstats
Date: Sun, 11 Oct 2020 21:37:27 +0200	[thread overview]
Message-ID: <b87c6e8c-13f9-831f-a65b-0fc7707e658e@gmail.com> (raw)
In-Reply-To: <a46f539e-a54d-7e92-0372-cd96bb280729@gmail.com>

Simplify the code by using new function dev_fetch_sw_netstats().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/infiniband/hw/hfi1/ipoib_main.c | 34 +------------------------
 1 file changed, 1 insertion(+), 33 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
index 014351ebb..9f71b9d70 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_main.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
@@ -97,41 +97,9 @@ static void hfi1_ipoib_dev_get_stats64(struct net_device *dev,
 				       struct rtnl_link_stats64 *storage)
 {
 	struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
-	u64 rx_packets = 0ull;
-	u64 rx_bytes = 0ull;
-	u64 tx_packets = 0ull;
-	u64 tx_bytes = 0ull;
-	int i;
 
 	netdev_stats_to_stats64(storage, &dev->stats);
-
-	for_each_possible_cpu(i) {
-		const struct pcpu_sw_netstats *stats;
-		unsigned int start;
-		u64 trx_packets;
-		u64 trx_bytes;
-		u64 ttx_packets;
-		u64 ttx_bytes;
-
-		stats = per_cpu_ptr(priv->netstats, i);
-		do {
-			start = u64_stats_fetch_begin_irq(&stats->syncp);
-			trx_packets = stats->rx_packets;
-			trx_bytes = stats->rx_bytes;
-			ttx_packets = stats->tx_packets;
-			ttx_bytes = stats->tx_bytes;
-		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
-
-		rx_packets += trx_packets;
-		rx_bytes += trx_bytes;
-		tx_packets += ttx_packets;
-		tx_bytes += ttx_bytes;
-	}
-
-	storage->rx_packets += rx_packets;
-	storage->rx_bytes += rx_bytes;
-	storage->tx_packets += tx_packets;
-	storage->tx_bytes += tx_bytes;
+	dev_fetch_sw_netstats(storage, priv->netstats);
 }
 
 static const struct net_device_ops hfi1_ipoib_netdev_ops = {
-- 
2.28.0



  parent reply	other threads:[~2020-10-11 19:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11 19:34 [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Heiner Kallweit
2020-10-11 19:36 ` [PATCH net-next 01/12] net: core: add " Heiner Kallweit
2020-10-11 19:54   ` Stephen Hemminger
2020-10-11 20:18     ` Heiner Kallweit
2020-10-11 22:07   ` Jakub Kicinski
2020-10-11 19:37 ` Heiner Kallweit [this message]
2020-10-11 19:38 ` [PATCH net-next 03/12] net: macsec: use new function dev_fetch_sw_netstats Heiner Kallweit
2020-10-11 19:38 ` [PATCH net-next 04/12] net: usb: qmi_wwan: " Heiner Kallweit
2020-10-12  6:47   ` Bjørn Mork
2020-10-11 19:39 ` [PATCH net-next 05/12] net: usbnet: " Heiner Kallweit
2020-10-11 19:40 ` [PATCH net-next 06/12] qtnfmac: " Heiner Kallweit
2020-10-12  7:10   ` Kalle Valo
2020-10-11 19:40 ` [PATCH net-next 07/12] net: bridge: " Heiner Kallweit
2020-10-11 19:41 ` [PATCH net-next 08/12] net: dsa: " Heiner Kallweit
2020-10-11 20:15   ` Vladimir Oltean
2020-10-12  1:49   ` Florian Fainelli
2020-10-11 19:42 ` [PATCH net-next 09/12] iptunnel: " Heiner Kallweit
2020-10-11 19:42 ` [PATCH net-next 10/12] mac80211: " Heiner Kallweit
2020-10-11 19:43 ` [PATCH net-next 11/12] net: openvswitch: " Heiner Kallweit
2020-10-11 19:44 ` [PATCH net-next 12/12] xfrm: " Heiner Kallweit
2020-10-11 22:10 ` [PATCH net-next 00/12] net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats Jakub Kicinski
2020-10-11 22:29   ` Heiner Kallweit
2020-10-11 22:41     ` Jakub Kicinski

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=b87c6e8c-13f9-831f-a65b-0fc7707e658e@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bjorn@mork.no \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=geomatsi@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=imitsyanko@quantenna.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=kvalo@codeaurora.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=olteanv@gmail.com \
    --cc=oneukum@suse.com \
    --cc=pshelar@ovn.org \
    --cc=roopa@nvidia.com \
    --cc=steffen.klassert@secunet.com \
    --cc=vivien.didelot@gmail.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).