[PATCH net-next v1 1/4] net: dsa: user: Skip set_mac_eee() if support_eee() is implemented

Oleksij Rempel posted 4 patches 9 months, 3 weeks ago
[PATCH net-next v1 1/4] net: dsa: user: Skip set_mac_eee() if support_eee() is implemented
Posted by Oleksij Rempel 9 months, 3 weeks ago
Some switches with integrated PHYs, like Microchip KSZ, manage EEE
internally based on PHY advertisement and link resolution. If
ds->ops->support_eee() is implemented, assume EEE is supported
and skip requiring set_mac_eee().

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 net/dsa/user.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/dsa/user.c b/net/dsa/user.c
index 804dc7dac4f2..87b78a4c1d6c 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -1246,14 +1246,12 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_keee *e)
 	/* 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)) {
+	if (ds->ops->set_mac_eee &&
+	    !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;
-
 		ret = ds->ops->set_mac_eee(ds, dp->index, e);
 		if (ret)
 			return ret;
-- 
2.39.5
Re: [PATCH net-next v1 1/4] net: dsa: user: Skip set_mac_eee() if support_eee() is implemented
Posted by Russell King (Oracle) 9 months, 3 weeks ago
On Thu, Apr 24, 2025 at 03:02:19PM +0200, Oleksij Rempel wrote:
> Some switches with integrated PHYs, like Microchip KSZ, manage EEE
> internally based on PHY advertisement and link resolution. If
> ds->ops->support_eee() is implemented, assume EEE is supported
> and skip requiring set_mac_eee().
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

If you look at the conditions here, there's a path for legacy where
set_mac_eee() is mandatory (which is what you're changing to be
optional) and there's a path for phylink based EEE where set_mac_eee()
becomes optional.

I would rather we left legacy alone, except to remove it entirely.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!