netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS.
@ 2024-12-09 11:46 James Chapman
  2024-12-09 12:59 ` Guillaume Nault
  2024-12-11 14:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: James Chapman @ 2024-12-09 11:46 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, tparkin, aleksander.lobakin,
	ricardo, mail, gnault

l2tp_eth uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX
and TX packet counters and DEV_STATS_INC for dropped counters.

Consolidate that using the DSTATS infrastructure, which can
handle both packet counters and packet drops. Statistics that don't
fit DSTATS are still updated atomically with DEV_STATS_INC().

This change is inspired by the introduction of DSTATS helpers and
their use in other udp tunnel drivers:
Link: https://lore.kernel.org/all/cover.1733313925.git.gnault@redhat.com/

Signed-off-by: James Chapman <jchapman@katalix.com>
---
 net/l2tp/l2tp_eth.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index d692b902e120..e83691073496 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -73,9 +73,9 @@ static netdev_tx_t l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev
 	int ret = l2tp_xmit_skb(session, skb);
 
 	if (likely(ret == NET_XMIT_SUCCESS))
-		dev_sw_netstats_tx_add(dev, 1, len);
+		dev_dstats_tx_add(dev, len);
 	else
-		DEV_STATS_INC(dev, tx_dropped);
+		dev_dstats_tx_dropped(dev);
 
 	return NETDEV_TX_OK;
 }
@@ -84,7 +84,6 @@ static const struct net_device_ops l2tp_eth_netdev_ops = {
 	.ndo_init		= l2tp_eth_dev_init,
 	.ndo_uninit		= l2tp_eth_dev_uninit,
 	.ndo_start_xmit		= l2tp_eth_dev_xmit,
-	.ndo_get_stats64	= dev_get_tstats64,
 	.ndo_set_mac_address	= eth_mac_addr,
 };
 
@@ -100,7 +99,7 @@ static void l2tp_eth_dev_setup(struct net_device *dev)
 	dev->lltx		= true;
 	dev->netdev_ops		= &l2tp_eth_netdev_ops;
 	dev->needs_free_netdev	= true;
-	dev->pcpu_stat_type	= NETDEV_PCPU_STAT_TSTATS;
+	dev->pcpu_stat_type	= NETDEV_PCPU_STAT_DSTATS;
 }
 
 static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
@@ -128,7 +127,7 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
 		goto error_rcu;
 
 	if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS)
-		dev_sw_netstats_rx_add(dev, data_len);
+		dev_dstats_rx_add(dev, data_len);
 	else
 		DEV_STATS_INC(dev, rx_errors);
 
-- 
2.34.1


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

* Re: [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS.
  2024-12-09 11:46 [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS James Chapman
@ 2024-12-09 12:59 ` Guillaume Nault
  2024-12-11 14:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Guillaume Nault @ 2024-12-09 12:59 UTC (permalink / raw)
  To: James Chapman
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, tparkin,
	aleksander.lobakin, ricardo, mail

On Mon, Dec 09, 2024 at 11:46:07AM +0000, James Chapman wrote:
> l2tp_eth uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX
> and TX packet counters and DEV_STATS_INC for dropped counters.
> 
> Consolidate that using the DSTATS infrastructure, which can
> handle both packet counters and packet drops. Statistics that don't
> fit DSTATS are still updated atomically with DEV_STATS_INC().

Reviewed-by: Guillaume Nault <gnault@redhat.com>

Thanks!


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

* Re: [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS.
  2024-12-09 11:46 [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS James Chapman
  2024-12-09 12:59 ` Guillaume Nault
@ 2024-12-11 14:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-11 14:00 UTC (permalink / raw)
  To: James Chapman
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, tparkin,
	aleksander.lobakin, ricardo, mail, gnault

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon,  9 Dec 2024 11:46:07 +0000 you wrote:
> l2tp_eth uses the TSTATS infrastructure (dev_sw_netstats_*()) for RX
> and TX packet counters and DEV_STATS_INC for dropped counters.
> 
> Consolidate that using the DSTATS infrastructure, which can
> handle both packet counters and packet drops. Statistics that don't
> fit DSTATS are still updated atomically with DEV_STATS_INC().
> 
> [...]

Here is the summary with links:
  - [net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS.
    https://git.kernel.org/netdev/net-next/c/c0b8980e6041

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-12-11 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 11:46 [PATCH net-next] l2tp: Handle eth stats using NETDEV_PCPU_STAT_DSTATS James Chapman
2024-12-09 12:59 ` Guillaume Nault
2024-12-11 14:00 ` 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).