Thread (16 messages) 16 messages, 4 authors, 2023-03-28
STALE1174d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs

From: Oleksij Rempel <o.rempel@pengutronix.de>
Date: 2023-03-27 14:24:18
Also in: lkml
Subsystem: ethernet phy library, networking drivers, the rest · Maintainers: Andrew Lunn, Heiner Kallweit, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Not all PHYs are implemented fully according to the IEEE 802.3
specification and cannot be handled by the generic
phy_ethtool_get/set_eee() functions. To address this, this commit adds
driver-specific get/set_eee support, enabling better handling of such
PHYs. This is particularly important for handling PHYs with SmartEEE
support, which requires specialized management.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/phy.c | 10 ++++++++--
 include/linux/phy.h   |  5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 0c0df38cd1ab..103484c24437 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1568,7 +1568,10 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
 		return -EIO;
 
 	mutex_lock(&phydev->lock);
-	ret = genphy_c45_ethtool_get_eee(phydev, data);
+	if (phydev->drv->get_eee)
+		ret = phydev->drv->get_eee(phydev, data);
+	else
+		ret = genphy_c45_ethtool_get_eee(phydev, data);
 	mutex_unlock(&phydev->lock);
 
 	return ret;
@@ -1590,7 +1593,10 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 		return -EIO;
 
 	mutex_lock(&phydev->lock);
-	ret = genphy_c45_ethtool_set_eee(phydev, data);
+	if (phydev->drv->set_eee)
+		ret = phydev->drv->set_eee(phydev, data);
+	else
+		ret = genphy_c45_ethtool_set_eee(phydev, data);
 	mutex_unlock(&phydev->lock);
 
 	return ret;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index fefd5091bc24..07cebf110aa6 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1056,6 +1056,11 @@ struct phy_driver {
 	/** @get_plca_status: Return the current PLCA status info */
 	int (*get_plca_status)(struct phy_device *dev,
 			       struct phy_plca_status *plca_st);
+
+	/** @get_eee: Return the current EEE configuration */
+	int (*get_eee)(struct phy_device *phydev, struct ethtool_eee *e);
+	/** @set_eee: Set the EEE configuration */
+	int (*set_eee)(struct phy_device *phydev, struct ethtool_eee *e);
 };
 #define to_phy_driver(d) container_of(to_mdio_common_driver(d),		\
 				      struct phy_driver, mdiodrv)
-- 
2.30.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help