Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp997284pxb; Fri, 13 Nov 2020 01:10:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC+8hfF+fJobq+ORjUf8UV1mnCgegg/OGF47srNLOb5mb2YODPZMNDVGoVCzj4LY3boavg X-Received: by 2002:a17:906:86cf:: with SMTP id j15mr1011970ejy.260.1605258621114; Fri, 13 Nov 2020 01:10:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605258621; cv=none; d=google.com; s=arc-20160816; b=Q1JI/+HQsFC7pddsVBRXIPYjOLgInO9TN0v4NZc9qFtn/EJvJZWgu65/6Czv5tES8c Ot7mLhHsCDHB4ncdgTAjMFsEmHDNKveaQ4NrQ1pp0EgawhBUhVqOE7S6kzY4UobmtQud jKMD2HuzR2nV77UtwUg5i9vTUQTS++b2to6G2p4J3afJN6cJFL82uTCMEfj5F0uJL6Nc QDNeeUp2VrLIRZabxtOcHzjBd5KTHeA/7qDdOdPTYgislk3xmJeeDezETnx/KkBWo3l9 MrbXvN82omViKMMBbTWWJOTK1Am6mVFIIiVXkd4SFTb0gMiI4h9ic74hfF1JaexEP76U EMbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lR7/8vjXJDBM73PVRP/RhfEwJV/6UykOcvsNpMs/RAE=; b=lQES6GlFa/CJK7kOsQ2SFbjR8Ymm06+i0RlTSX6fE0lcXm0vhPTSMipA+fuzsCwY// g49IPi7MiEfy8k6wah3pT4v/KW9C2OXSmk1Rekaqh1Cf41PD2WKNHUCG+bDoMzuKTRhv 28g5cUHqswPUPYF53gY/FIxLa/1PDHdTxRRfOZxRqKJ5PQ1c3nEEcUmVbdV79RVnHU3A lfcC8M6bS4w1h/wisSpEXYbNIWmcEurdV06qvdmTXIzvCnHNh11/wTmmitYHAdeCZHJK soyKOP1c9QL1TIpBK1akSMo3+DE+K9eF1akzHncBqcunNJJ1uBWYvMm+TH/85pUByr95 Cnrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cXKphYEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr25si5599011ejc.123.2020.11.13.01.09.56; Fri, 13 Nov 2020 01:10:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cXKphYEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgKMJH6 (ORCPT + 99 others); Fri, 13 Nov 2020 04:07:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbgKMJH4 (ORCPT ); Fri, 13 Nov 2020 04:07:56 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F9B0C0613D1; Fri, 13 Nov 2020 01:07:56 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id 74so12741845lfo.5; Fri, 13 Nov 2020 01:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lR7/8vjXJDBM73PVRP/RhfEwJV/6UykOcvsNpMs/RAE=; b=cXKphYEMrBWFsSAa2+890QE7UsPFgUnJm7kKit91fFJrp3FJULrOTbjYIn5Oo1T3rl BWYXXOTj+sOzD6G5ITNcokkG6aFPZYHajJ0EmNFyttZQ2LiII68OaQ23kpbOnkzdUuQG eBTxlIZGTW524iE1sbUuOewyIWkFVukBgSdUrrM2SmWFHNlynjf5svkFHYm3nEDNB7Wt DdocptY4OqYdGOu00ThUMbL1HUSiNqMddLtZQMDEfb1Q/FbFEpJlKB4+5BkGtsiQa1+G 8gUrTQFvd/jkWS5TJawiOFD5pVZCHlddnhnQdMDJsJaGEgaXeCg1F+ti0u0GRq0ZQekf T8Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lR7/8vjXJDBM73PVRP/RhfEwJV/6UykOcvsNpMs/RAE=; b=hYeLveu1K9TlVtz5jf9akPzyXo6vxGqUjOyGLOr+m+EMbKFY6Xq7ItH+AcwA0uqqEj OqfRm+uKCLIfYPxPO1sZSlIGq2xDlJKCwirpOWv/v4Vh0KeTFCGPSKnjMwbviPren1Bt psn0IgPTh5zyhOsRjZGMNBlvDF9yLNbQczFQm/4rANQvTvFzD7QJ4DMsj7UR7FUo1t3E xym0KpAtSz0vAJ0wXtI6kdqPLeg7OasQTBOffqnXhHzms8l0fwYEr3rFi2vkGcWWV4er ozq4mAtrxFWQDpwQnxWsnLRqs69N+GawmiIuEjpsKWPoW4E8k7zMeDy7+SMrr/WKSigR mVpw== X-Gm-Message-State: AOAM5319CD2ksWi7XKR5DRf8NUMfRJuBhNwK54fbAKrRTXmswFQue7II Fd17vpC6P7wqBOWhTolGKyY= X-Received: by 2002:a19:c191:: with SMTP id r139mr535421lff.258.1605258474914; Fri, 13 Nov 2020 01:07:54 -0800 (PST) Received: from localhost.localdomain (dmjt96jhvbz3j2f08hy-4.rev.dnainternet.fi. [2001:14bb:51:e1dd:1cd1:d2e:7b13:dc30]) by smtp.gmail.com with ESMTPSA id a8sm603684ljq.77.2020.11.13.01.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 01:07:54 -0800 (PST) From: Lev Stipakov X-Google-Original-From: Lev Stipakov To: Steffen Klassert , Herbert Xu , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Heiner Kallweit Cc: Lev Stipakov Subject: [PATCH v2 3/3] net: xfrm: use core API for updating/providing stats Date: Fri, 13 Nov 2020 11:07:34 +0200 Message-Id: <20201113090734.117349-1-lev@openvpn.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <59b6c94d-e0de-e4f5-d02e-e799694f6dc8@gmail.com> References: <59b6c94d-e0de-e4f5-d02e-e799694f6dc8@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, remove xfrmi_get_stats64() and replace it with dev_get_tstats64(). Signed-off-by: Lev Stipakov --- v2: replace xfrmi_get_stats64() vs dev_get_tstats64() net/xfrm/xfrm_interface.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c index 9b8e292a7c6a..697cdcfbb5e1 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++; @@ -538,15 +533,6 @@ static int xfrmi_update(struct xfrm_if *xi, struct xfrm_if_parms *p) return err; } -static void xfrmi_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *s) -{ - dev_fetch_sw_netstats(s, dev->tstats); - - s->rx_dropped = dev->stats.rx_dropped; - s->tx_dropped = dev->stats.tx_dropped; -} - static int xfrmi_get_iflink(const struct net_device *dev) { struct xfrm_if *xi = netdev_priv(dev); @@ -554,12 +540,11 @@ static int xfrmi_get_iflink(const struct net_device *dev) return xi->p.link; } - static const struct net_device_ops xfrmi_netdev_ops = { .ndo_init = xfrmi_dev_init, .ndo_uninit = xfrmi_dev_uninit, .ndo_start_xmit = xfrmi_xmit, - .ndo_get_stats64 = xfrmi_get_stats64, + .ndo_get_stats64 = dev_get_tstats64, .ndo_get_iflink = xfrmi_get_iflink, }; -- 2.25.1