[PATCH v3 net-next 5/5] net: ethernet: mtk_eth_soc: add support for page_pool_get_stats

Paolo Abeni pabeni at redhat.com
Tue Jul 19 02:26:36 PDT 2022


On Sat, 2022-07-16 at 09:34 +0200, Lorenzo Bianconi wrote:
> Introduce support for the page_pool stats API into mtk_eth_soc driver.
> Report page_pool stats through ethtool.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> ---
>  drivers/net/ethernet/mediatek/Kconfig       |  1 +
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 40 +++++++++++++++++++--
>  2 files changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
> index d2422c7b31b0..97374fb3ee79 100644
> --- a/drivers/net/ethernet/mediatek/Kconfig
> +++ b/drivers/net/ethernet/mediatek/Kconfig
> @@ -18,6 +18,7 @@ config NET_MEDIATEK_SOC
>  	select PHYLINK
>  	select DIMLIB
>  	select PAGE_POOL
> +	select PAGE_POOL_STATS
>  	help
>  	  This driver supports the gigabit ethernet MACs in the
>  	  MediaTek SoC family.
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index abb8bc281015..eba95a86086d 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -3517,11 +3517,19 @@ static void mtk_get_strings(struct net_device *dev, u32 stringset, u8 *data)
>  	int i;
>  
>  	switch (stringset) {
> -	case ETH_SS_STATS:
> +	case ETH_SS_STATS: {
> +		struct mtk_mac *mac = netdev_priv(dev);
> +		struct mtk_eth *eth = mac->hw;
> +
>  		for (i = 0; i < ARRAY_SIZE(mtk_ethtool_stats); i++) {
>  			memcpy(data, mtk_ethtool_stats[i].str, ETH_GSTRING_LEN);
>  			data += ETH_GSTRING_LEN;
>  		}
> +		if (!eth->hwlro)

I see the page_pool is enabled if and only if !hwlro, but I think it
would be more clear if you explicitly check for page_pool here (and in
a few other places below), so that if the condition to enable page_pool
someday will change, this code will still be fine.

Thanks!

Paolo




More information about the Linux-mediatek mailing list