]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: phy: phy_device: Use link_capabilities lookup for PHY aneg config
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Fri, 7 Mar 2025 17:36:05 +0000 (18:36 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 18 Mar 2025 08:03:11 +0000 (09:03 +0100)
When configuring PHY advertising with autoneg disabled, we lookd for an
exact linkmode to advertise and configure for the requested Speed and
Duplex, specially at or over 1G.

Using phy_caps_lookup allows us to build a list of the supported
linkmodes at that speed that we can advertise instead of the first mode
that matches.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20250307173611.129125-9-maxime.chevallier@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/phy/phy_device.c

index 4980862398d0491b413517ef74d4db7536b803d5..3f734e847e8e263a76f440bfdce42b575a4cc370 100644 (file)
@@ -2120,7 +2120,7 @@ EXPORT_SYMBOL(genphy_check_and_restart_aneg);
 int __genphy_config_aneg(struct phy_device *phydev, bool changed)
 {
        __ETHTOOL_DECLARE_LINK_MODE_MASK(fixed_advert);
-       const struct phy_setting *set;
+       const struct link_capabilities *c;
        unsigned long *advert;
        int err;
 
@@ -2146,10 +2146,11 @@ int __genphy_config_aneg(struct phy_device *phydev, bool changed)
        } else {
                linkmode_zero(fixed_advert);
 
-               set = phy_lookup_setting(phydev->speed, phydev->duplex,
-                                        phydev->supported, true);
-               if (set)
-                       linkmode_set_bit(set->bit, fixed_advert);
+               c = phy_caps_lookup(phydev->speed, phydev->duplex,
+                                   phydev->supported, true);
+               if (c)
+                       linkmode_and(fixed_advert, phydev->supported,
+                                    c->linkmodes);
 
                advert = fixed_advert;
        }