[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <86f4e67f3f2eaf13e588b4989b364b1616b5fcad.1649405981.git.lorenzo@kernel.org>
Date: Fri, 8 Apr 2022 10:24:00 +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: [PATCH v2 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 | 38 +++++++++++++++++++++++----
2 files changed, 34 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..7cc20d25a7a3 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,17 @@ 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++)
+ page_pool_get_stats(pp->rxqs[i].page_pool, &stats);
+
+ 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 +4872,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 +5391,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 +5412,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