netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Use helper functions to update stats
@ 2023-08-10  8:56 Li Zetao
  2023-08-10  8:56 ` [PATCH net-next 1/2] net: macsec: " Li Zetao
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Li Zetao @ 2023-08-10  8:56 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir
  Cc: lizetao1, netdev

The patch set uses the helper functions dev_sw_netstats_rx_add() and
dev_sw_netstats_tx_add() to update stats, which is the same as 
implementing the function separately.

Li Zetao (2):
  net: macsec: Use helper functions to update stats
  vxlan: Use helper functions to update stats

 drivers/net/macsec.c           | 17 +++--------------
 drivers/net/vxlan/vxlan_core.c | 13 ++-----------
 2 files changed, 5 insertions(+), 25 deletions(-)

-- 
2.34.1


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

* [PATCH net-next 1/2] net: macsec: Use helper functions to update stats
  2023-08-10  8:56 [PATCH net-next 0/2] Use helper functions to update stats Li Zetao
@ 2023-08-10  8:56 ` Li Zetao
  2023-08-11  9:57   ` Simon Horman
  2023-08-10  8:56 ` [PATCH net-next 2/2] vxlan: " Li Zetao
  2023-08-14  7:10 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Li Zetao @ 2023-08-10  8:56 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir
  Cc: lizetao1, netdev

Use the helper functions dev_sw_netstats_rx_add() and
dev_sw_netstats_tx_add() to update stats, which helps to
provide code readability.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/macsec.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 144ec756c796..ae60817ec5c2 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -518,14 +518,8 @@ static void macsec_count_tx(struct sk_buff *skb, struct macsec_tx_sc *tx_sc,
 
 static void count_tx(struct net_device *dev, int ret, int len)
 {
-	if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
-		struct pcpu_sw_netstats *stats = this_cpu_ptr(dev->tstats);
-
-		u64_stats_update_begin(&stats->syncp);
-		u64_stats_inc(&stats->tx_packets);
-		u64_stats_add(&stats->tx_bytes, len);
-		u64_stats_update_end(&stats->syncp);
-	}
+	if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN))
+		dev_sw_netstats_tx_add(dev, 1, len);
 }
 
 static void macsec_encrypt_done(void *data, int err)
@@ -827,12 +821,7 @@ static void macsec_finalize_skb(struct sk_buff *skb, u8 icv_len, u8 hdr_len)
 
 static void count_rx(struct net_device *dev, int len)
 {
-	struct pcpu_sw_netstats *stats = this_cpu_ptr(dev->tstats);
-
-	u64_stats_update_begin(&stats->syncp);
-	u64_stats_inc(&stats->rx_packets);
-	u64_stats_add(&stats->rx_bytes, len);
-	u64_stats_update_end(&stats->syncp);
+	dev_sw_netstats_rx_add(dev, len);
 }
 
 static void macsec_decrypt_done(void *data, int err)
-- 
2.34.1


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

* [PATCH net-next 2/2] vxlan: Use helper functions to update stats
  2023-08-10  8:56 [PATCH net-next 0/2] Use helper functions to update stats Li Zetao
  2023-08-10  8:56 ` [PATCH net-next 1/2] net: macsec: " Li Zetao
@ 2023-08-10  8:56 ` Li Zetao
  2023-08-10 16:36   ` Ido Schimmel
  2023-08-11 10:01   ` Nikolay Aleksandrov
  2023-08-14  7:10 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
  2 siblings, 2 replies; 7+ messages in thread
From: Li Zetao @ 2023-08-10  8:56 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir
  Cc: lizetao1, netdev

Use the helper functions dev_sw_netstats_rx_add() and
dev_sw_netstats_tx_add() to update stats, which helps to
provide code readability.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/vxlan/vxlan_core.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 2bddcdf482a7..e463f59e95c2 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2328,14 +2328,11 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
 			       struct vxlan_dev *dst_vxlan, __be32 vni,
 			       bool snoop)
 {
-	struct pcpu_sw_netstats *tx_stats, *rx_stats;
 	union vxlan_addr loopback;
 	union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
 	struct net_device *dev;
 	int len = skb->len;
 
-	tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
-	rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats);
 	skb->pkt_type = PACKET_HOST;
 	skb->encapsulation = 0;
 	skb->dev = dst_vxlan->dev;
@@ -2361,17 +2358,11 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
 	if ((dst_vxlan->cfg.flags & VXLAN_F_LEARN) && snoop)
 		vxlan_snoop(dev, &loopback, eth_hdr(skb)->h_source, 0, vni);
 
-	u64_stats_update_begin(&tx_stats->syncp);
-	u64_stats_inc(&tx_stats->tx_packets);
-	u64_stats_add(&tx_stats->tx_bytes, len);
-	u64_stats_update_end(&tx_stats->syncp);
+	dev_sw_netstats_tx_add(src_vxlan->dev, 1, len);
 	vxlan_vnifilter_count(src_vxlan, vni, NULL, VXLAN_VNI_STATS_TX, len);
 
 	if (__netif_rx(skb) == NET_RX_SUCCESS) {
-		u64_stats_update_begin(&rx_stats->syncp);
-		u64_stats_inc(&rx_stats->rx_packets);
-		u64_stats_add(&rx_stats->rx_bytes, len);
-		u64_stats_update_end(&rx_stats->syncp);
+		dev_sw_netstats_rx_add(dst_vxlan->dev, len);
 		vxlan_vnifilter_count(dst_vxlan, vni, NULL, VXLAN_VNI_STATS_RX,
 				      len);
 	} else {
-- 
2.34.1


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

* Re: [PATCH net-next 2/2] vxlan: Use helper functions to update stats
  2023-08-10  8:56 ` [PATCH net-next 2/2] vxlan: " Li Zetao
@ 2023-08-10 16:36   ` Ido Schimmel
  2023-08-11 10:01   ` Nikolay Aleksandrov
  1 sibling, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2023-08-10 16:36 UTC (permalink / raw)
  To: Li Zetao
  Cc: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir, netdev

On Thu, Aug 10, 2023 at 04:56:42PM +0800, Li Zetao wrote:
> Use the helper functions dev_sw_netstats_rx_add() and
> dev_sw_netstats_tx_add() to update stats, which helps to
> provide code readability.
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

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

* Re: [PATCH net-next 1/2] net: macsec: Use helper functions to update stats
  2023-08-10  8:56 ` [PATCH net-next 1/2] net: macsec: " Li Zetao
@ 2023-08-11  9:57   ` Simon Horman
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2023-08-11  9:57 UTC (permalink / raw)
  To: Li Zetao
  Cc: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir, netdev

On Thu, Aug 10, 2023 at 04:56:41PM +0800, Li Zetao wrote:
> Use the helper functions dev_sw_netstats_rx_add() and
> dev_sw_netstats_tx_add() to update stats, which helps to
> provide code readability.
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next 2/2] vxlan: Use helper functions to update stats
  2023-08-10  8:56 ` [PATCH net-next 2/2] vxlan: " Li Zetao
  2023-08-10 16:36   ` Ido Schimmel
@ 2023-08-11 10:01   ` Nikolay Aleksandrov
  1 sibling, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2023-08-11 10:01 UTC (permalink / raw)
  To: Li Zetao, davem, edumazet, kuba, pabeni, idosch, jbenc, gavinl,
	wsa+renesas, vladimir
  Cc: netdev

On 8/10/23 11:56, Li Zetao wrote:
> Use the helper functions dev_sw_netstats_rx_add() and
> dev_sw_netstats_tx_add() to update stats, which helps to
> provide code readability.
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
>   drivers/net/vxlan/vxlan_core.c | 13 ++-----------
>   1 file changed, 2 insertions(+), 11 deletions(-)
> 

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>



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

* Re: [PATCH net-next 0/2] Use helper functions to update stats
  2023-08-10  8:56 [PATCH net-next 0/2] Use helper functions to update stats Li Zetao
  2023-08-10  8:56 ` [PATCH net-next 1/2] net: macsec: " Li Zetao
  2023-08-10  8:56 ` [PATCH net-next 2/2] vxlan: " Li Zetao
@ 2023-08-14  7:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-14  7:10 UTC (permalink / raw)
  To: Li Zetao
  Cc: davem, edumazet, kuba, pabeni, idosch, razor, jbenc, gavinl,
	wsa+renesas, vladimir, netdev

Hello:

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

On Thu, 10 Aug 2023 16:56:40 +0800 you wrote:
> The patch set uses the helper functions dev_sw_netstats_rx_add() and
> dev_sw_netstats_tx_add() to update stats, which is the same as
> implementing the function separately.
> 
> Li Zetao (2):
>   net: macsec: Use helper functions to update stats
>   vxlan: Use helper functions to update stats
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: macsec: Use helper functions to update stats
    https://git.kernel.org/netdev/net-next/c/bf98bbe98553
  - [net-next,2/2] vxlan: Use helper functions to update stats
    https://git.kernel.org/netdev/net-next/c/3c0930b491f8

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] 7+ messages in thread

end of thread, other threads:[~2023-08-14  7:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10  8:56 [PATCH net-next 0/2] Use helper functions to update stats Li Zetao
2023-08-10  8:56 ` [PATCH net-next 1/2] net: macsec: " Li Zetao
2023-08-11  9:57   ` Simon Horman
2023-08-10  8:56 ` [PATCH net-next 2/2] vxlan: " Li Zetao
2023-08-10 16:36   ` Ido Schimmel
2023-08-11 10:01   ` Nikolay Aleksandrov
2023-08-14  7:10 ` [PATCH net-next 0/2] " 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).