]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: phylink: fix ksettings_set() ethtool call
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Sat, 13 May 2023 21:03:45 +0000 (22:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 May 2023 09:31:23 +0000 (10:31 +0100)
While testing a Fiberstore SFP-10G-T module (which uses 10GBASE-R with
rate adaption) in a Clearfog platform (which can't do that) it was
found that the PHYs advertisement was not limited according to the
hosts capabilities when using ethtool to change it.

Fix this by ensuring that we mask the advertisement with the computed
support mask as the very first thing we do.

Fixes: cbc1bb1e4689 ("net: phylink: simplify phy case for ksettings_set method")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phylink.c

index a4111f1be375738033042f3c86fcba8197c528bb..e237949deee64f486695557ba2396f4173993270 100644 (file)
@@ -2225,6 +2225,10 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
 
        ASSERT_RTNL();
 
+       /* Mask out unsupported advertisements */
+       linkmode_and(config.advertising, kset->link_modes.advertising,
+                    pl->supported);
+
        if (pl->phydev) {
                /* We can rely on phylib for this update; we also do not need
                 * to update the pl->link_config settings:
@@ -2249,10 +2253,6 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
 
        config = pl->link_config;
 
-       /* Mask out unsupported advertisements */
-       linkmode_and(config.advertising, kset->link_modes.advertising,
-                    pl->supported);
-
        /* FIXME: should we reject autoneg if phy/mac does not support it? */
        switch (kset->base.autoneg) {
        case AUTONEG_DISABLE: