linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Furong Xu <0x1207@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jon Hunter <jonathanh@nvidia.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
	Thierry Reding <treding@nvidia.com>
Subject: Re: [PATCH RFC net-next 1/5] net: stmmac: call phylink_start() and phylink_stop() in XDP functions
Date: Fri, 28 Feb 2025 14:38:15 +0000	[thread overview]
Message-ID: <Z8HKV4ytpJJ9NJw8@shell.armlinux.org.uk> (raw)
In-Reply-To: <7706823a-a787-4c7e-a6ac-9a4feaf76dee@lunn.ch>

On Fri, Feb 28, 2025 at 02:14:29PM +0100, Andrew Lunn wrote:
> On Fri, Feb 28, 2025 at 03:31:22PM +0800, Furong Xu wrote:
> > On Thu, 27 Feb 2025 15:05:02 +0000
> > "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:
> > 
> > > Phylink does not permit drivers to mess with the netif carrier, as
> > > this will de-synchronise phylink with the MAC driver. Moreover,
> > > setting and clearing the TE and RE bits via stmmac_mac_set() in this
> > > path is also wrong as the link may not be up.
> > > 
> > > Replace the netif_carrier_on(), netif_carrier_off() and
> > > stmmac_mac_set() calls with the appropriate phylink_start() and
> > > phylink_stop() calls, thereby allowing phylink to manage the netif
> > > carrier and TE/RE bits through the .mac_link_up() and .mac_link_down()
> > > methods.
> > > 
> > > Note that RE should only be set after the DMA is ready to avoid the
> > > receive FIFO between the MAC and DMA blocks overflowing, so
> > > phylink_start() needs to be placed after DMA has been started.
> > > 
> > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>  
> > XDP programs work like a charm both before and after this patch.
> > 
> > Tested-by: Furong Xu <0x1207@gmail.com>
> 
> Thanks for testing this.
> 
> Could you give a little details of how you actually tested it?
> 
> The issues here is, when is the link set admin up, requiring that
> phylink triggers an autoneg etc.
> 
> For plain old TCP/IP, you at some point use:
> 
> ip link set eth42 up
> 
> which will cause the core to call the drivers open() method, which
> then triggers phylnk.
> 
> The carrier manipulation which this code replaces seems to suggest you
> can load an XDP program while the interface is admin down, and that
> action of loading the program will implicitly set the carrier up.

It won't. See
drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c::stmmac_xdp_set_prog():

        if_running = netif_running(dev);

        need_update = !!priv->xdp_prog != !!prog;

        if (if_running && need_update)
                stmmac_xdp_release(dev);

	...

        if (if_running && need_update)
                stmmac_xdp_open(dev);

stmmac_xdp_open() and stmmac_xdp_release() will only be called if
netif_running() returns true as explained yesterday (but maybe
without enough detail). This tests __LINK_STATE_START in dev->state,
which is set just before calling .ndo_open(), and cleared if it fails
or before calling .ndo_stop().

Thus, netif_running() indicates whether the net core thinks the
device is adminsitratively "up".

Therefore, in the old code, if the programme is changed while the
device is administratively down, netif_running() will return false,
if_running will be false, and neither stmmac_xdp_release() nor
stmmac_xdp_open() will be called.

Hope that addresses your concern.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!


  reply	other threads:[~2025-02-28 14:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 15:00 [PATCH RFC 0/5] net: stmmac: fix setting RE and TE inappropriately Russell King (Oracle)
2025-02-27 15:05 ` [PATCH RFC net-next 1/5] net: stmmac: call phylink_start() and phylink_stop() in XDP functions Russell King (Oracle)
2025-02-27 22:27   ` Andrew Lunn
2025-02-28  0:02     ` Russell King (Oracle)
2025-02-28  7:31   ` Furong Xu
2025-02-28 13:14     ` Andrew Lunn
2025-02-28 14:38       ` Russell King (Oracle) [this message]
2025-02-27 15:05 ` [PATCH RFC net-next 2/5] net: stmmac: remove redundant racy tear-down in stmmac_dvr_remove() Russell King (Oracle)
2025-02-27 22:16   ` Andrew Lunn
2025-02-28  3:28   ` Furong Xu
2025-02-27 15:05 ` [PATCH RFC net-next 3/5] net: stmmac: remove unnecessary stmmac_mac_set() in stmmac_release() Russell King (Oracle)
2025-02-27 22:17   ` Andrew Lunn
2025-02-28  2:51   ` Furong Xu
2025-02-27 15:05 ` [PATCH RFC net-next 4/5] net: stmmac: remove _RE and _TE in (start|stop)_(tx|rx)() methods Russell King (Oracle)
2025-02-27 22:25   ` Andrew Lunn
2025-02-28  2:52   ` Furong Xu
2025-02-27 15:05 ` [PATCH RFC net-next 5/5] net: stmmac: leave enabling RE and TE to stmmac_mac_link_up() Russell King (Oracle)
2025-02-28  2:52   ` Furong Xu

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=Z8HKV4ytpJJ9NJw8@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=0x1207@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=treding@nvidia.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).