MANA relies on page_pool for RX buffers, and the buffer refill paths can behave quite differently across architectures and configurations (e.g. base page size, fragment vs full-page usage). This makes it harder to understand and compare RX buffer behavior when investigating performance and memory differences across platforms.
Wire up the generic page_pool ethtool stats helpers and report page_pool allocation/recycle statistics via ethtool -S when CONFIG_PAGE_POOL_STATS is enabled. The counters are exposed with the standard "rx_pp_*" names, for example: rx_pp_alloc_fast rx_pp_alloc_slow rx_pp_alloc_slow_ho rx_pp_alloc_empty rx_pp_alloc_refill rx_pp_alloc_waive rx_pp_recycle_cached rx_pp_recycle_cache_full rx_pp_recycle_ring rx_pp_recycle_ring_full rx_pp_recycle_released_ref Signed-off-by: Dipayaan Roy <[email protected]> --- .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c index f2d220b371b5..8fec74cdd3c3 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -6,6 +6,7 @@ #include <linux/ethtool.h> #include <net/mana/mana.h> +#include <net/page_pool/helpers.h> struct mana_stats_desc { char name[ETH_GSTRING_LEN]; @@ -143,8 +144,10 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset) if (stringset != ETH_SS_STATS) return -EINVAL; - return ARRAY_SIZE(mana_eth_stats) + ARRAY_SIZE(mana_phy_stats) + ARRAY_SIZE(mana_hc_stats) + - num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT); + return ARRAY_SIZE(mana_eth_stats) + ARRAY_SIZE(mana_phy_stats) + + ARRAY_SIZE(mana_hc_stats) + + num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT) + + page_pool_ethtool_stats_get_count(); } static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) @@ -185,6 +188,27 @@ static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) ethtool_sprintf(&data, "tx_%d_csum_partial", i); ethtool_sprintf(&data, "tx_%d_mana_map_err", i); } + + page_pool_ethtool_stats_get_strings(data); +} + +static void mana_get_page_pool_stats(struct net_device *ndev, u64 *data) +{ +#ifdef CONFIG_PAGE_POOL_STATS + struct mana_port_context *apc = netdev_priv(ndev); + unsigned int num_queues = apc->num_queues; + struct page_pool_stats pp_stats = {}; + int q; + + for (q = 0; q < num_queues; q++) { + if (!apc->rxqs[q] || !apc->rxqs[q]->page_pool) + continue; + + page_pool_get_stats(apc->rxqs[q]->page_pool, &pp_stats); + } + + page_pool_ethtool_stats_get(data, &pp_stats); +#endif /* CONFIG_PAGE_POOL_STATS */ } static void mana_get_ethtool_stats(struct net_device *ndev, @@ -280,6 +304,8 @@ static void mana_get_ethtool_stats(struct net_device *ndev, data[i++] = csum_partial; data[i++] = mana_map_err; } + + mana_get_page_pool_stats(ndev, &data[i]); } static u32 mana_get_rx_ring_count(struct net_device *ndev) -- 2.43.0

