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

Message ID 20230327142202.3754446-2-o.rempel@pengutronix.de
State New
Headers
Series Make SmartEEE support controllable |

Commit Message

Oleksij Rempel March 27, 2023, 2:21 p.m. UTC
  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(-)
  

Comments

Andrew Lunn March 27, 2023, 4:41 p.m. UTC | #1
On Mon, Mar 27, 2023 at 04:21:55PM +0200, Oleksij Rempel wrote:
> 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>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
  

Patch

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)