netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] net: openvswitch: use core API for updating TX stats
@ 2020-11-12 11:11 Lev Stipakov
  2020-11-13  7:40 ` Heiner Kallweit
  0 siblings, 1 reply; 6+ messages in thread
From: Lev Stipakov @ 2020-11-12 11:11 UTC (permalink / raw)
  To: Pravin B Shelar, David S. Miller, Jakub Kicinski, netdev, dev,
	linux-kernel
  Cc: Lev Stipakov

Commit d3fd65484c781 ("net: core: add dev_sw_netstats_tx_add") has added
function "dev_sw_netstats_tx_add()" to update net device per-cpu TX
stats.

Use this function instead of own code. While on it, replace
"len" variable with "skb->len".

Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 net/openvswitch/vport-internal_dev.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 1e30d8df3ba5..116738d36e02 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -33,23 +33,17 @@ static struct internal_dev *internal_dev_priv(struct net_device *netdev)
 static netdev_tx_t
 internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
-	int len, err;
+	int err;
 
-	len = skb->len;
 	rcu_read_lock();
 	err = ovs_vport_receive(internal_dev_priv(netdev)->vport, skb, NULL);
 	rcu_read_unlock();
 
-	if (likely(!err)) {
-		struct pcpu_sw_netstats *tstats = this_cpu_ptr(netdev->tstats);
-
-		u64_stats_update_begin(&tstats->syncp);
-		tstats->tx_bytes += len;
-		tstats->tx_packets++;
-		u64_stats_update_end(&tstats->syncp);
-	} else {
+	if (likely(!err))
+		dev_sw_netstats_tx_add(netdev, 1, skb->len);
+	else
 		netdev->stats.tx_errors++;
-	}
+
 	return NETDEV_TX_OK;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-15  1:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-12 11:11 [PATCH 2/3] net: openvswitch: use core API for updating TX stats Lev Stipakov
2020-11-13  7:40 ` Heiner Kallweit
2020-11-13  9:02   ` [PATCH v2 2/3] net: openvswitch: use core API to update/provide stats Lev Stipakov
2020-11-13 10:46     ` Heiner Kallweit
2020-11-13 21:53       ` [PATCH v3] " Lev Stipakov
2020-11-15  1:10         ` patchwork-bot+netdevbpf

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).