lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  7 Apr 2022 18:55:05 +0200
From:   Lorenzo Bianconi <lorenzo@...nel.org>
To:     netdev@...r.kernel.org
Cc:     lorenzo.bianconi@...hat.com, davem@...emloft.net, kuba@...nel.org,
        pabeni@...hat.com, thomas.petazzoni@...tlin.com,
        ilias.apalodimas@...aro.org, jbrouer@...hat.com, andrew@...n.ch,
        jdamato@...tly.com
Subject: [RFC net-next 2/2] net: mvneta: add support for page_pool_get_stats

Introduce support for the page_pool_get_stats API to mvneta driver.
Report page_pool stats through ethtool.

Signed-off-by: Lorenzo Bianconi <lorenzo@...nel.org>
---
 drivers/net/ethernet/marvell/Kconfig  |  1 +
 drivers/net/ethernet/marvell/mvneta.c | 59 ++++++++++++++++++++++++---
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index fe0989c0fc25..1240cb2dc07f 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -62,6 +62,7 @@ config MVNETA
 	select MVMDIO
 	select PHYLINK
 	select PAGE_POOL
+	select PAGE_POOL_STATS
 	help
 	  This driver supports the network interface units in the
 	  Marvell ARMADA XP, ARMADA 370, ARMADA 38x and
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 934f6dd90992..9864ea09e887 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -540,7 +540,7 @@ struct mvneta_port {
 	bool eee_active;
 	bool tx_lpi_enabled;
 
-	u64 ethtool_stats[ARRAY_SIZE(mvneta_statistics)];
+	u64 *ethtool_stats;
 
 	u32 indir[MVNETA_RSS_LU_TABLE_SIZE];
 
@@ -4732,9 +4732,13 @@ static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
 	if (sset == ETH_SS_STATS) {
 		int i;
 
-		for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++)
-			memcpy(data + i * ETH_GSTRING_LEN,
-			       mvneta_statistics[i].name, ETH_GSTRING_LEN);
+		for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++) {
+			memcpy(data, mvneta_statistics[i].name,
+			       ETH_GSTRING_LEN);
+			data += ETH_GSTRING_LEN;
+		}
+
+		page_pool_ethtool_stats_get_strings(data);
 	}
 }
 
@@ -4847,6 +4851,38 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
 	}
 }
 
+static void mvneta_ethtool_pp_stats(struct mvneta_port *pp, u64 *data)
+{
+	struct page_pool_stats stats = {};
+	int i;
+
+	for (i = 0; i < rxq_number; i++) {
+		struct page_pool *page_pool = pp->rxqs[i].page_pool;
+		struct page_pool_stats pp_stats = {};
+
+		if (!page_pool_get_stats(page_pool, &pp_stats))
+			continue;
+
+		stats.alloc_stats.fast += pp_stats.alloc_stats.fast;
+		stats.alloc_stats.slow += pp_stats.alloc_stats.slow;
+		stats.alloc_stats.slow_high_order +=
+			pp_stats.alloc_stats.slow_high_order;
+		stats.alloc_stats.empty += pp_stats.alloc_stats.empty;
+		stats.alloc_stats.refill += pp_stats.alloc_stats.refill;
+		stats.alloc_stats.waive += pp_stats.alloc_stats.waive;
+		stats.recycle_stats.cached += pp_stats.recycle_stats.cached;
+		stats.recycle_stats.cache_full +=
+			pp_stats.recycle_stats.cache_full;
+		stats.recycle_stats.ring += pp_stats.recycle_stats.ring;
+		stats.recycle_stats.ring_full +=
+			pp_stats.recycle_stats.ring_full;
+		stats.recycle_stats.released_refcnt +=
+			pp_stats.recycle_stats.released_refcnt;
+	}
+
+	page_pool_ethtool_stats_get(data, &stats);
+}
+
 static void mvneta_ethtool_get_stats(struct net_device *dev,
 				     struct ethtool_stats *stats, u64 *data)
 {
@@ -4857,12 +4893,16 @@ static void mvneta_ethtool_get_stats(struct net_device *dev,
 
 	for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++)
 		*data++ = pp->ethtool_stats[i];
+
+	mvneta_ethtool_pp_stats(pp, data);
 }
 
 static int mvneta_ethtool_get_sset_count(struct net_device *dev, int sset)
 {
 	if (sset == ETH_SS_STATS)
-		return ARRAY_SIZE(mvneta_statistics);
+		return ARRAY_SIZE(mvneta_statistics) +
+		       page_pool_ethtool_stats_get_count();
+
 	return -EOPNOTSUPP;
 }
 
@@ -5372,6 +5412,7 @@ static int mvneta_probe(struct platform_device *pdev)
 	phy_interface_t phy_mode;
 	const char *mac_from;
 	int tx_csum_limit;
+	int stats_len;
 	int err;
 	int cpu;
 
@@ -5392,6 +5433,14 @@ static int mvneta_probe(struct platform_device *pdev)
 	pp->rxq_def = rxq_def;
 	pp->indir[0] = rxq_def;
 
+	stats_len = ARRAY_SIZE(mvneta_statistics) +
+		    page_pool_ethtool_stats_get_count();
+	pp->ethtool_stats = devm_kzalloc(&pdev->dev,
+					 sizeof(*pp->ethtool_stats) * stats_len,
+					 GFP_KERNEL);
+	if (!pp->ethtool_stats)
+		return -ENOMEM;
+
 	err = of_get_phy_mode(dn, &phy_mode);
 	if (err) {
 		dev_err(&pdev->dev, "incorrect phy-mode\n");
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ