diff mbox series

[3/3] net: xfrm: use core API for updating TX stats

Message ID 20201112111345.34625-1-lev@openvpn.net (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/3] net: mac80211: use core API for updating TX stats | expand

Checks

Context Check Description
netdev/cover_letter warning Series does not have a cover letter
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Lev Stipakov <lstipakov@gmail.com>' != 'Signed-off-by: Lev Stipakov <lev@openvpn.net>'
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Lev Stipakov Nov. 12, 2020, 11:13 a.m. UTC
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.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 net/xfrm/xfrm_interface.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Heiner Kallweit Nov. 13, 2020, 7:46 a.m. UTC | #1
Am 12.11.2020 um 12:13 schrieb 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.
> 
LGTM. In addition you can replace xfrmi_get_stats64() with
dev_get_tstats64().

> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> ---
>  net/xfrm/xfrm_interface.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
> index 9b8e292a7c6a..43ee4c5a6fa9 100644
> --- a/net/xfrm/xfrm_interface.c
> +++ b/net/xfrm/xfrm_interface.c
> @@ -319,12 +319,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
>  
>  	err = dst_output(xi->net, skb->sk, skb);
>  	if (net_xmit_eval(err) == 0) {
> -		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
> -
> -		u64_stats_update_begin(&tstats->syncp);
> -		tstats->tx_bytes += length;
> -		tstats->tx_packets++;
> -		u64_stats_update_end(&tstats->syncp);
> +		dev_sw_netstats_tx_add(dev, 1, length);
>  	} else {
>  		stats->tx_errors++;
>  		stats->tx_aborted_errors++;
>
diff mbox series

Patch

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 9b8e292a7c6a..43ee4c5a6fa9 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -319,12 +319,7 @@  xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 
 	err = dst_output(xi->net, skb->sk, skb);
 	if (net_xmit_eval(err) == 0) {
-		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
-
-		u64_stats_update_begin(&tstats->syncp);
-		tstats->tx_bytes += length;
-		tstats->tx_packets++;
-		u64_stats_update_end(&tstats->syncp);
+		dev_sw_netstats_tx_add(dev, 1, length);
 	} else {
 		stats->tx_errors++;
 		stats->tx_aborted_errors++;