netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	maxime.chevallier@bootlin.com
Subject: Re: [net PATCH 2/2] net: phylink: Set advertising based on phy_lookup_setting in ksettings_set
Date: Wed, 2 Apr 2025 19:02:06 +0100	[thread overview]
Message-ID: <Z-17nu2epjG1EiAd@shell.armlinux.org.uk> (raw)
In-Reply-To: <174354301312.26800.4565150748823347100.stgit@ahduyck-xeon-server.home.arpa>

On Tue, Apr 01, 2025 at 02:30:13PM -0700, Alexander Duyck wrote:
> From: Alexander Duyck <alexanderduyck@fb.com>
> 
> While testing a driver that supports mulitple speeds on the same SFP module
> I noticed I wasn't able to change them when I was not using
> autonegotiation. I would attempt to update the speed, but it had no effect.
> 
> A bit of digging led me to the fact that we weren't updating the advertised
> link mask and as a result the interface wasn't being updated when I
> requested an updated speed. This change makes it so that we apply the speed
> from the phy settings to the config.advertised following a behavior similar
> to what we already do when setting up a fixed-link.
> 
> Fixes: ea269a6f7207 ("net: phylink: Update SFP selected interface on advertising changes")
> Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
> ---
>  drivers/net/phy/phylink.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 380e51c5bdaa..f561a803e5ce 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -2763,6 +2763,7 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
>  
>  		config.speed = c->speed;
>  		config.duplex = c->duplex;
> +		linkmode_and(config.advertising, c->linkmodes, pl->supported);

I had thought that ethtool provided an appropriate advertising mask
when aneg is disabled, but it just preserves the old mask, which seems
to be the intended behaviour (if one looks at phylib, that's also what
happens there.) We should not deviate from that with a user API.

So, I would like to change how this works somewhat to avoid a user
visible change. Also, interface mode changing on AUTONEG_DISABLED was
never intended to work. Indeed, mvneta and mvpp2 don't support
AUTONEG_DISABLED for 1000BASE-X nor 2500BASE-X which is where this
interface switching was implemented (for switching between these two.)

I've already got rid of the phylink_sfp_select_interface() usage when
a module is inserted (see phylink_sfp_config_optical(), where we base
the interface selection off interface support masks there rather than
advertisements - it used to be advertisements.)

We now have phylink_interface_max_speed() which gives the speed of
the interface, which gives us the possibility of doing something
like this for the AUTONEG_DISABLE state:

	phy_interface_and(interfaces, pl->config->supported_interfaces,
			  pl->sfp_interfaces);

	best_speed = SPEED_UNKNOWN;
	best_interface = PHY_INTERFACE_MODE_NA;

	for_each_set_bit(interface, interfaces, __ETHTOOL_LINK_MODE_MASK_NBITS) {
		max_speed = phylink_interface_max_speed(interface);
		if (max_speed < config.speed)
			continue;
		if (max_speed == config.speed)
			return interface;
		if (best_speed == SPEED_UNKNOWN ||
		    max_speed < best_speed) {
			best_speed = max_speed;
			best_interface = interface;
		}
	}

	return best_interface;

to select the interface from aneg-disabled state.

Do you think that would work for you?

-- 
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-04-02 18:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 21:29 [net PATCH 0/2] Fixes for net/phy/phylink.c Alexander Duyck
2025-04-01 21:30 ` [net PATCH 1/2] net: phy: Cleanup handling of recent changes to phy_lookup_setting Alexander Duyck
2025-04-02  7:00   ` Maxime Chevallier
2025-04-02 14:21     ` Alexander H Duyck
2025-04-02 17:17       ` Jakub Kicinski
2025-04-02 17:30         ` Russell King (Oracle)
2025-04-02 22:37           ` Alexander Duyck
2025-04-03 14:55   ` Russell King (Oracle)
2025-04-03 15:29     ` Maxime Chevallier
2025-04-03 16:34       ` Andrew Lunn
2025-04-03 21:53         ` Alexander Duyck
2025-04-03 23:19           ` Russell King (Oracle)
2025-04-04 15:56             ` Alexander Duyck
2025-04-04 16:33               ` Andrew Lunn
2025-04-04 22:46                 ` Alexander Duyck
2025-04-05  9:43                   ` Russell King (Oracle)
2025-04-05 14:51                   ` Andrew Lunn
2025-04-05 20:41                     ` Alexander Duyck
2025-04-05 20:53                       ` Andrew Lunn
2025-04-05  9:10               ` Russell King (Oracle)
2025-04-05 15:43                 ` Andrew Lunn
2025-04-05 15:52                 ` Andrew Lunn
2025-04-05 16:19                   ` Alexander Duyck
2025-04-05 20:23                 ` Alexander Duyck
2025-04-03 23:26           ` Russell King (Oracle)
2025-04-04  1:46             ` Andrew Lunn
2025-04-04  7:16               ` Russell King (Oracle)
2025-04-04 16:18                 ` Alexander Duyck
2025-04-07 17:01                   ` Jakub Kicinski
2025-04-07 18:20                     ` Alexander Duyck
2025-04-07 19:34                       ` Andrew Lunn
2025-04-07 23:01                         ` Alexander Duyck
2025-04-01 21:30 ` [net PATCH 2/2] net: phylink: Set advertising based on phy_lookup_setting in ksettings_set Alexander Duyck
2025-04-02 18:02   ` Russell King (Oracle) [this message]
2025-04-02 22:34     ` Alexander Duyck

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=Z-17nu2epjG1EiAd@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=alexander.duyck@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --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 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).