]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: allow use of phylink managed EEE support
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 10 Feb 2025 10:36:49 +0000 (10:36 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 13 Feb 2025 02:20:04 +0000 (18:20 -0800)
In order to allow DSA drivers to use phylink managed EEE, we need to
change the behaviour of the DSA's .set_eee() ethtool method.
Implementation of the DSA .set_mac_eee() method becomes optional with
phylink managed EEE as it is only used to validate the EEE parameters
supplied from userspace. The rest of the EEE state management should
be left to phylink.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1thR9l-003vXC-9F@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/user.c

index 291ab1b4acc4d5fb3cd885544bc33c322eeb3817..2296a4ead02030745807a7d003c70b3be76e6847 100644 (file)
@@ -1243,16 +1243,25 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_keee *e)
        if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
                return -EOPNOTSUPP;
 
-       /* Port's PHY and MAC both need to be EEE capable */
-       if (!dev->phydev)
-               return -ENODEV;
+       /* If the port is using phylink managed EEE, then an unimplemented
+        * set_mac_eee() is permissible.
+        */
+       if (!phylink_mac_implements_lpi(ds->phylink_mac_ops)) {
+               /* Port's PHY and MAC both need to be EEE capable */
+               if (!dev->phydev)
+                       return -ENODEV;
 
-       if (!ds->ops->set_mac_eee)
-               return -EOPNOTSUPP;
+               if (!ds->ops->set_mac_eee)
+                       return -EOPNOTSUPP;
 
-       ret = ds->ops->set_mac_eee(ds, dp->index, e);
-       if (ret)
-               return ret;
+               ret = ds->ops->set_mac_eee(ds, dp->index, e);
+               if (ret)
+                       return ret;
+       } else if (ds->ops->set_mac_eee) {
+               ret = ds->ops->set_mac_eee(ds, dp->index, e);
+               if (ret)
+                       return ret;
+       }
 
        return phylink_ethtool_set_eee(dp->pl, e);
 }