netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: Paolo Abeni <pabeni@redhat.com>,
	davem@davemloft.net, Andrew Lunn <andrew@lunn.ch>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, Simon Horman <horms@kernel.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Herve Codina <herve.codina@bootlin.com>,
	Romain Gantois <romain.gantois@bootlin.com>,
	Jijie Shao <shaojijie@huawei.com>
Subject: Re: [PATCH net] net: phy: phy_caps: Don't skip better duplex macth on non-exact match
Date: Fri, 6 Jun 2025 09:30:59 +0100	[thread overview]
Message-ID: <aEKnQ4haQtcJWzXX@shell.armlinux.org.uk> (raw)
In-Reply-To: <20250606101923.04393789@fedora>

On Fri, Jun 06, 2025 at 10:19:23AM +0200, Maxime Chevallier wrote:
> In reality, the case you're mentioning would be a device that supports
> 1000/Full, 100/Full and 100/Half, user asks for 1000/Half, and 100/Full
> would be reported.
> 
> That's unlikely to exist, but I'll document it as I've been surprised
> in the past with setups that shouldn't exist that actually do :)

That's not unlikely. Many MACs do not support 1000/Half but do support
100/Half and 10/Half.

Also... you're wrong about the result.

If phy_lookup_setting() is called with speed = 1000, duplex = half,
and we have a MAC that supports 1000/Full, 100/Half, 100/Full, then:

- We iterate down through the phy_settings[] to:
	PHY_SETTING(   1000, FULL,   1000baseT_Full             ),

	if (p->speed == speed && p->duplex == duplex) {
  the first condition is true, the second is false.
	} else if (!exact) {
  this is true.
		if (!match && p->speed <= speed)
  match is NULL, and p->speed == speed, so this is a candidate:
			match = p;
  We continue.
- The next entry that will be tested is:
	PHY_SETTING(    100, FULL,    100baseT_Full             ),

	if (p->speed == speed && p->duplex == duplex) {
  the first condition is false.
	} else if (!exact) {
  this is true.
		if (!match && p->speed <= speed)
  this is now false because match is set.
  We continue.
- The next entry that will be tested is:
	PHY_SETTING(    100, HALF,    100baseT_Half             ),

	if (p->speed == speed && p->duplex == duplex) {
  the first condition is false.
	} else if (!exact) {
  this is true.
		if (!match && p->speed <= speed)
  this is now false because match is set.
  We continue.

- We eventually get to the end of the list.
	if (!match && !exact)
  this is false.

- We return the entry for 1000/Full, which is exactly the behaviour I
  was after when I wrote this matching.

If you're version doesn't come out with a matching speed, then I'm
afraid it's still broken.

-- 
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-06-06  8:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03  8:35 [PATCH net] net: phy: phy_caps: Don't skip better duplex macth on non-exact match Maxime Chevallier
2025-06-03  9:43 ` Jijie Shao
2025-06-03 13:10 ` Larysa Zaremba
2025-06-05 10:24 ` Paolo Abeni
2025-06-06  8:19   ` Maxime Chevallier
2025-06-06  8:30     ` Russell King (Oracle) [this message]
2025-06-06  9:24       ` Maxime Chevallier

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=aEKnQ4haQtcJWzXX@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=christophe.leroy@csgroup.eu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herve.codina@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=romain.gantois@bootlin.com \
    --cc=shaojijie@huawei.com \
    --cc=thomas.petazzoni@bootlin.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).