All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: phy: realtek: check validity of 10GbE link-partner advertisement
Date: Fri, 4 Oct 2024 23:06:01 +0100	[thread overview]
Message-ID: <ZwBmycWDB6ui4Y7j@makrotopia.org> (raw)
In-Reply-To: <8fb5c25d-8ef5-4126-b709-0cfe2d722330@lunn.ch>

On Fri, Oct 04, 2024 at 11:17:28PM +0200, Andrew Lunn wrote:
> On Fri, Oct 04, 2024 at 04:50:36PM +0100, Daniel Golle wrote:
> > Only use link-partner advertisement bits for 10GbE modes if they are
> > actually valid. Check LOCALOK and REMOTEOK bits and clear 10GbE modes
> > unless both of them are set.
> > This prevents misinterpreting the stale 2500M link-partner advertisement
> > bit in case a subsequent linkpartner doesn't do any NBase-T
> > advertisement at all.
> > 
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> >  drivers/net/phy/realtek.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> > index c4d0d93523ad..d276477cf511 100644
> > --- a/drivers/net/phy/realtek.c
> > +++ b/drivers/net/phy/realtek.c
> > @@ -927,6 +927,10 @@ static int rtl822x_read_status(struct phy_device *phydev)
> >  		if (lpadv < 0)
> >  			return lpadv;
> >  
> > +		if (!(lpadv & MDIO_AN_10GBT_STAT_REMOK) ||
> > +		    !(lpadv & MDIO_AN_10GBT_STAT_LOCOK))
> > +			lpadv = 0;
> > +
> >  		mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising,
> >  						  lpadv);
> 
> I know lpadv is coming from a vendor register, but does
> MDIO_AN_10GBT_STAT_LOCOK and MDIO_AN_10GBT_STAT_REMOK apply if it was
> also from the register defined in 802.3? I'm just wondering if this
> test should be inside mii_10gbt_stat_mod_linkmode_lpa_t()?

Yes, it does apply and I thought the same, but as
mii_10gbt_stat_mod_linkmode_lpa_t is used in various places without
checking those two bits we may break other PHYs which may not use
them (and apparently this is mostly a problem on RealTek PHYs where
all the other bits in the register persist in case of a non-NBase-T-
capable subsequent link-partner after initially being connected to
an NBase-T-capable one).

Maybe we could introduce a new function
mii_10gbt_stat_mod_linkmode_lpa_validate_t()
which calls mii_10gbt_stat_mod_linkmode_lpa_t() but checks LOCOK and
REMOK as a precondition?


  reply	other threads:[~2024-10-04 22:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 15:50 [PATCH net-next] net: phy: realtek: check validity of 10GbE link-partner advertisement Daniel Golle
2024-10-04 21:17 ` Andrew Lunn
2024-10-04 22:06   ` Daniel Golle [this message]
2024-10-08 11:10     ` Russell King (Oracle)
2024-10-08 11:59       ` Daniel Golle
2024-10-08 12:45         ` Russell King (Oracle)
2024-10-08 14:27           ` Russell King (Oracle)
2024-10-08 23:15             ` Daniel Golle
     [not found] <ZwBmycWDB6ui4Y7j () makrotopia ! org>
2024-10-08 10:41 ` Paolo Abeni

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=ZwBmycWDB6ui4Y7j@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.