[PATCH v3 net-next 5/5] net: ethernet: mtk_eth_soc: add support for page_pool_get_stats
Lorenzo Bianconi
lorenzo.bianconi at redhat.com
Tue Jul 19 03:18: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.
Hi Paolo,
page_pool pointer is defined in mtk_rx_ring structure, so theoretically we can have a
page_pool defined for queue 0 but not for queues {1, 2, 3}. "!eth->hwlro" means
there is at least one page_pool allocated. Do you prefer to do something like:
bool mtk_is_pp_enabled(struct mtk_eth *eth)
{
for (i = 0; i < ARRAY_SIZE(eth->rx_ring); i++) {
struct mtk_rx_ring *ring = ð->rx_ring[i];
if (ring->page_pool)
return true;
}
return false;
}
Regards,
Lorenzo
>
> Thanks!
>
> Paolo
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20220719/1c33e1fc/attachment-0001.sig>
More information about the Linux-mediatek
mailing list