Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Lukasz Czapnik <lukasz.czapnik@intel.com>,
	Marcin Kubiak <marcin.kubiak@intel.com>,
	Michal Kubiak <michal.kubiak@intel.com>,
	Michal Swiatkowski <michal.swiatkowski@intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Netanel Belgazal <netanel@amazon.com>,
	Arthur Kiyanovski <akiyano@amazon.com>,
	Guy Tzalik <gtzalik@amazon.com>,
	Saeed Bishara <saeedb@amazon.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Marcin Wojtas <mw@semihalf.com>,
	Russell King <linux@armlinux.org.uk>,
	Edward Cree <ecree.xilinx@gmail.com>,
	Martin Habets <habetsm.xilinx@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, KP Singh <kpsingh@kernel.org>,
	Shay Agroskin <shayagr@amazon.com>,
	Sameeh Jubran <sameehj@amazon.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	Danielle Ratson <danieller@nvidia.com>,
	Ido Schimmel <idosch@nvidia.com>, Andrew Lunn <andrew@lunn.ch>,
	Vladyslav Tarasiuk <vladyslavt@nvidia.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jian Shen <shenjian15@huawei.com>,
	Petr Vorel <petr.vorel@gmail.com>, Dan Murphy <dmurphy@ti.com>,
	Yangbo Lu <yangbo.lu@nxp.com>, Michal Kubecek <mkubecek@suse.cz>,
	Zheng Yongjun <zhengyongjun3@huawei.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	YueHaibing <yuehaibing@huawei.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org, bpf@vger.kernel.org
Subject: [PATCH net-next 10/21] ethernet, mvneta: convert to standard XDP stats
Date: Tue,  3 Aug 2021 18:36:30 +0200	[thread overview]
Message-ID: <20210803163641.3743-11-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20210803163641.3743-1-alexandr.lobakin@intel.com>

Replace custom Ethtools XDP statistics with the standard infra based
one (7 basic fields).
This driver uses global [per-cpu] stats, no other callbacks needed.

Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 108 +++++++++++++-------------
 1 file changed, 52 insertions(+), 56 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index f030d5b7bdee..9015c8b45395 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -345,13 +345,6 @@ enum {
 	ETHTOOL_STAT_EEE_WAKEUP,
 	ETHTOOL_STAT_SKB_ALLOC_ERR,
 	ETHTOOL_STAT_REFILL_ERR,
-	ETHTOOL_XDP_REDIRECT,
-	ETHTOOL_XDP_PASS,
-	ETHTOOL_XDP_DROP,
-	ETHTOOL_XDP_TX,
-	ETHTOOL_XDP_TX_ERR,
-	ETHTOOL_XDP_XMIT,
-	ETHTOOL_XDP_XMIT_DROPS,
 	ETHTOOL_MAX_STATS,
 };
 
@@ -406,13 +399,6 @@ static const struct mvneta_statistic mvneta_statistics[] = {
 	{ ETHTOOL_STAT_EEE_WAKEUP, T_SW, "eee_wakeup_errors", },
 	{ ETHTOOL_STAT_SKB_ALLOC_ERR, T_SW, "skb_alloc_errors", },
 	{ ETHTOOL_STAT_REFILL_ERR, T_SW, "refill_errors", },
-	{ ETHTOOL_XDP_REDIRECT, T_SW, "rx_xdp_redirect", },
-	{ ETHTOOL_XDP_PASS, T_SW, "rx_xdp_pass", },
-	{ ETHTOOL_XDP_DROP, T_SW, "rx_xdp_drop", },
-	{ ETHTOOL_XDP_TX, T_SW, "rx_xdp_tx", },
-	{ ETHTOOL_XDP_TX_ERR, T_SW, "rx_xdp_tx_errors", },
-	{ ETHTOOL_XDP_XMIT, T_SW, "tx_xdp_xmit", },
-	{ ETHTOOL_XDP_XMIT_DROPS, T_SW, "tx_xdp_xmit_drops", },
 };
 
 struct mvneta_stats {
@@ -4630,38 +4616,17 @@ mvneta_ethtool_update_pcpu_stats(struct mvneta_port *pp,
 	for_each_possible_cpu(cpu) {
 		struct mvneta_pcpu_stats *stats;
 		u64 skb_alloc_error;
-		u64 xdp_xmit_drops;
 		u64 refill_error;
-		u64 xdp_redirect;
-		u64 xdp_tx_err;
-		u64 xdp_pass;
-		u64 xdp_drop;
-		u64 xdp_xmit;
-		u64 xdp_tx;
 
 		stats = per_cpu_ptr(pp->stats, cpu);
 		do {
 			start = u64_stats_fetch_begin_irq(&stats->syncp);
 			skb_alloc_error = stats->es.skb_alloc_error;
 			refill_error = stats->es.refill_error;
-			xdp_redirect = stats->es.ps.xdp_redirect;
-			xdp_pass = stats->es.ps.xdp_pass;
-			xdp_drop = stats->es.ps.xdp_drop;
-			xdp_xmit = stats->es.ps.xdp_xmit;
-			xdp_xmit_drops = stats->es.ps.xdp_xmit_drops;
-			xdp_tx = stats->es.ps.xdp_tx;
-			xdp_tx_err = stats->es.ps.xdp_tx_err;
 		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
 
 		es->skb_alloc_error += skb_alloc_error;
 		es->refill_error += refill_error;
-		es->ps.xdp_redirect += xdp_redirect;
-		es->ps.xdp_pass += xdp_pass;
-		es->ps.xdp_drop += xdp_drop;
-		es->ps.xdp_xmit += xdp_xmit;
-		es->ps.xdp_xmit_drops += xdp_xmit_drops;
-		es->ps.xdp_tx += xdp_tx;
-		es->ps.xdp_tx_err += xdp_tx_err;
 	}
 }
 
@@ -4702,27 +4667,6 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
 			case ETHTOOL_STAT_REFILL_ERR:
 				pp->ethtool_stats[i] = stats.refill_error;
 				break;
-			case ETHTOOL_XDP_REDIRECT:
-				pp->ethtool_stats[i] = stats.ps.xdp_redirect;
-				break;
-			case ETHTOOL_XDP_PASS:
-				pp->ethtool_stats[i] = stats.ps.xdp_pass;
-				break;
-			case ETHTOOL_XDP_DROP:
-				pp->ethtool_stats[i] = stats.ps.xdp_drop;
-				break;
-			case ETHTOOL_XDP_TX:
-				pp->ethtool_stats[i] = stats.ps.xdp_tx;
-				break;
-			case ETHTOOL_XDP_TX_ERR:
-				pp->ethtool_stats[i] = stats.ps.xdp_tx_err;
-				break;
-			case ETHTOOL_XDP_XMIT:
-				pp->ethtool_stats[i] = stats.ps.xdp_xmit;
-				break;
-			case ETHTOOL_XDP_XMIT_DROPS:
-				pp->ethtool_stats[i] = stats.ps.xdp_xmit_drops;
-				break;
 			}
 			break;
 		}
@@ -4748,6 +4692,57 @@ static int mvneta_ethtool_get_sset_count(struct net_device *dev, int sset)
 	return -EOPNOTSUPP;
 }
 
+static void mvneta_ethtool_get_xdp_stats(struct net_device *dev,
+					 struct ethtool_xdp_stats *xdp_stats)
+{
+	const struct mvneta_port *pp = netdev_priv(dev);
+	u32 cpu;
+
+	xdp_stats->drop = 0;
+	xdp_stats->pass = 0;
+	xdp_stats->redirect = 0;
+	xdp_stats->tx = 0;
+	xdp_stats->tx_errors = 0;
+	xdp_stats->xmit = 0;
+	xdp_stats->xmit_drops = 0;
+
+	for_each_possible_cpu(cpu) {
+		const struct mvneta_pcpu_stats *stats;
+		const struct mvneta_stats *ps;
+		u64 xdp_xmit_drops;
+		u64 xdp_redirect;
+		u64 xdp_tx_err;
+		u64 xdp_pass;
+		u64 xdp_drop;
+		u64 xdp_xmit;
+		u64 xdp_tx;
+		u32 start;
+
+		stats = per_cpu_ptr(pp->stats, cpu);
+		ps = &stats->es.ps;
+
+		do {
+			start = u64_stats_fetch_begin_irq(&stats->syncp);
+
+			xdp_drop = ps->xdp_drop;
+			xdp_pass = ps->xdp_pass;
+			xdp_redirect = ps->xdp_redirect;
+			xdp_tx = ps->xdp_tx;
+			xdp_tx_err = ps->xdp_tx_err;
+			xdp_xmit = ps->xdp_xmit;
+			xdp_xmit_drops = ps->xdp_xmit_drops;
+		} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
+
+		xdp_stats->drop += xdp_drop;
+		xdp_stats->pass += xdp_pass;
+		xdp_stats->redirect += xdp_redirect;
+		xdp_stats->tx += xdp_tx;
+		xdp_stats->tx_errors += xdp_tx_err;
+		xdp_stats->xmit += xdp_xmit;
+		xdp_stats->xmit_drops += xdp_xmit_drops;
+	}
+}
+
 static u32 mvneta_ethtool_get_rxfh_indir_size(struct net_device *dev)
 {
 	return MVNETA_RSS_LU_TABLE_SIZE;
@@ -5025,6 +5020,7 @@ static const struct ethtool_ops mvneta_eth_tool_ops = {
 	.set_wol        = mvneta_ethtool_set_wol,
 	.get_eee	= mvneta_ethtool_get_eee,
 	.set_eee	= mvneta_ethtool_set_eee,
+	.get_xdp_stats	= mvneta_ethtool_get_xdp_stats,
 };
 
 /* Initialize hw */
-- 
2.31.1


  parent reply	other threads:[~2021-08-03 16:40 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 16:36 [PATCH net-next 00/21] ethtool, stats: introduce and use " Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 01/21] ethtool, stats: use a shorthand pointer in stats_prepare_data() Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 02/21] ethtool, stats: add compile-time checks for standard stats Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 03/21] ethtool, stats: introduce standard XDP statistics Alexander Lobakin
2021-08-03 20:49   ` Jakub Kicinski
2021-08-03 23:57     ` Saeed Mahameed
2021-08-04 12:36       ` Jakub Kicinski
2021-08-04 15:53         ` Alexander Lobakin
2021-08-04 16:57           ` Jakub Kicinski
2021-08-05 11:18             ` Alexander Lobakin
2021-08-05 13:31               ` Jakub Kicinski
2021-08-04 16:17         ` David Ahern
2021-08-04 16:44           ` Jakub Kicinski
2021-08-04 17:28             ` David Ahern
2021-08-04 18:27               ` Saeed Mahameed
2021-08-05  0:43                 ` David Ahern
2021-08-05  2:14                   ` Saeed Mahameed
2021-08-12 12:19             ` Jesper Dangaard Brouer
2021-10-26  9:23       ` Alexander Lobakin
2021-11-05 16:44         ` Alexander Lobakin
2021-11-08 11:37           ` Toke Høiland-Jørgensen
2021-11-08 13:21             ` Alexander Lobakin
2021-11-08 18:09               ` Toke Høiland-Jørgensen
2021-08-03 16:36 ` [PATCH net-next 04/21] ethernet, dpaa2: simplify per-channel Ethtool stats counting Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 05/21] ethernet, dpaa2: convert to standard XDP stats Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 06/21] ethernet, ena: constify src and syncp args of ena_safe_update_stat() Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 07/21] ethernet, ena: convert to standard XDP stats Alexander Lobakin
2021-08-04 13:04   ` Shay Agroskin
2021-08-04 15:24     ` Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 08/21] ethernet, enetc: " Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 09/21] ethernet, mvneta: rename xdp_xmit_err to xdp_xmit_drops Alexander Lobakin
2021-08-03 16:36 ` Alexander Lobakin [this message]
2021-08-03 16:36 ` [PATCH net-next 11/21] ethernet, mvpp2: " Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 12/21] ethernet, mvpp2: convert to standard XDP stats Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 13/21] ethernet, sfc: " Alexander Lobakin
2021-08-03 17:59   ` Edward Cree
2021-08-03 16:36 ` [PATCH net-next 14/21] veth: rename rx_drops to xdp_errors Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 15/21] veth: rename xdp_xmit_errors to xdp_xmit_drops Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 16/21] veth: rename drop xdp_ suffix from packets and bytes stats Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 17/21] veth: convert to standard XDP stats Alexander Lobakin
2021-08-03 16:36 ` [PATCH net-next 18/21] virtio-net: rename xdp_tx{,__drops} SQ stats to xdp_xmit{,__drops} Alexander Lobakin
2021-08-03 16:42 ` Alexander Lobakin
2021-08-03 16:42 ` [PATCH net-next 19/21] virtio-net: don't mix error-caused drops with XDP_DROP cases Alexander Lobakin
2021-08-03 16:42 ` [PATCH net-next 20/21] virtio-net: convert to standard XDP stats Alexander Lobakin
2021-08-03 16:42 ` [PATCH net-next 21/21] Documentation, ethtool-netlink: update standard statistics documentation Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803163641.3743-11-alexandr.lobakin@intel.com \
    --to=alexandr.lobakin@intel.com \
    --cc=akiyano@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexanderduyck@fb.com \
    --cc=andrew@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dmurphy@ti.com \
    --cc=ecree.xilinx@gmail.com \
    --cc=gtzalik@amazon.com \
    --cc=habetsm.xilinx@gmail.com \
    --cc=hawk@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=jasowang@redhat.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukasz.czapnik@intel.com \
    --cc=marcin.kubiak@intel.com \
    --cc=michal.kubiak@intel.com \
    --cc=michal.swiatkowski@intel.com \
    --cc=mkubecek@suse.cz \
    --cc=mst@redhat.com \
    --cc=mw@semihalf.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=petr.vorel@gmail.com \
    --cc=saeedb@amazon.com \
    --cc=sameehj@amazon.com \
    --cc=shayagr@amazon.com \
    --cc=shenjian15@huawei.com \
    --cc=songliubraving@fb.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=vladyslavt@nvidia.com \
    --cc=yangbo.lu@nxp.com \
    --cc=yhs@fb.com \
    --cc=yuehaibing@huawei.com \
    --cc=zhengyongjun3@huawei.com \
    --subject='Re: [PATCH net-next 10/21] ethernet, mvneta: convert to standard XDP stats' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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