netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
	netdev@vger.kernel.org, nbd@nbd.name, john@phrozen.org,
	sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org,
	ilias.apalodimas@linaro.org, jbrouer@redhat.com
Subject: Re: [PATCH v3 net-next 5/5] net: ethernet: mtk_eth_soc: add support for page_pool_get_stats
Date: Tue, 19 Jul 2022 16:02:38 +0200	[thread overview]
Message-ID: <Yta5fsw0U6KWMmTL@localhost.localdomain> (raw)
In-Reply-To: <d432c897a8eef451bdd65cfdf5b1da0d866a9a5b.camel@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3204 bytes --]

> On Tue, 2022-07-19 at 12:18 +0200, Lorenzo Bianconi wrote:
> > > 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@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}.
> 
> I see. I missed hwlro is a per device setting.
> 
> > "!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 = &eth->rx_ring[i];
> > 
> > 		if (ring->page_pool)
> > 			return true;
> > 	}
> > 	return false;
> > }
> 
> Even:
> 
> bool mtk_is_pp_enabled(struct mtk_eth *eth)
> {
> 	return !eth->hwlro;
> }
> 
> will suffice to encaspulate the logic behind page pool enabling in a
> single place.

ack, I am fine with it. I will fix in v4.

Regards,
Lorenzo

> 
> /P
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2022-07-19 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16  7:34 [PATCH v3 net-next 0/5] mtk_eth_soc: add xdp support Lorenzo Bianconi
2022-07-16  7:34 ` [PATCH v3 net-next 1/5] net: ethernet: mtk_eth_soc: rely on page_pool for single page buffers Lorenzo Bianconi
2022-07-16  7:34 ` [PATCH v3 net-next 2/5] net: ethernet: mtk_eth_soc: add basic XDP support Lorenzo Bianconi
2022-07-19  9:22   ` Paolo Abeni
2022-07-19 10:31     ` Lorenzo Bianconi
2022-07-16  7:34 ` [PATCH v3 net-next 3/5] net: ethernet: mtk_eth_soc: introduce xdp ethtool counters Lorenzo Bianconi
2022-07-16  7:34 ` [PATCH v3 net-next 4/5] net: ethernet: mtk_eth_soc: add xmit XDP support Lorenzo Bianconi
2022-07-16  7:34 ` [PATCH v3 net-next 5/5] net: ethernet: mtk_eth_soc: add support for page_pool_get_stats Lorenzo Bianconi
2022-07-19  9:26   ` Paolo Abeni
2022-07-19 10:18     ` Lorenzo Bianconi
2022-07-19 13:58       ` Paolo Abeni
2022-07-19 14:02         ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yta5fsw0U6KWMmTL@localhost.localdomain \
    --to=lorenzo.bianconi@redhat.com \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jbrouer@redhat.com \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).