linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/8] Make SmartEEE support controllable
@ 2023-03-27 14:21 Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Oleksij Rempel
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

changes v2:
- handle lack of eee_get/set directly by the ethtool framework. This
  will avoid the need to patch all ethernet controller drivers.
- add mac_supports_eee and is_smart_eee_phy flags to indicate support
  of different levels.
- reword commit logs.
- add FEC patch to indicated EEE support for some SoCs

Some PHYs, such as the AR8035, provide so-called SmartEEE support, which
enables the use of EEE with MACs that lack native EEE capabilities,
particularly the LPI support. Since this functionality is usually
enabled by default, it may have a negative impact on certain use cases
(e.g., PTP) or even prevent the use of all link modes without PHY driver
assistance (e.g., a full range of half-duplex modes).

To address at least some of these issues, this patch series aims to pass
EEE ethtool access to PHY drivers, enabling them to control SmartEEE
support more effectively. The series consists of several patches that
improve EEE handling for specific PHYs and MACs, making it possible to
enable or disable SmartEEE functionality as needed, depending on the
specific use case and requirements. As a result, users will gain more
control and flexibility over energy-saving features and compatibility in
their networking setups.

Oleksij Rempel (8):
  net: phy: Add driver-specific get/set_eee support for non-standard
    PHYs
  net: phy: add is_smart_eee_phy variable for SmartEEE support
  net: phy: Add mac_supports_eee variable for EEE support and LPI
    handling
  ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with
    non-EEE MACs
  net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs
  net: phy: at803x: Make SmartEEE support optional and configurable via
    ethtool
  net: phy: at803x: Fix SmartEEE support for some link configurations
  net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers

 drivers/net/ethernet/freescale/fec_main.c |   2 +
 drivers/net/phy/at803x.c                  | 158 +++++++++++++++++++++-
 drivers/net/phy/phy.c                     |  10 +-
 include/linux/phy.h                       |   9 ++
 net/ethtool/common.c                      |  38 ++++++
 net/ethtool/common.h                      |   2 +
 net/ethtool/eee.c                         |  17 ++-
 7 files changed, 221 insertions(+), 15 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
@ 2023-03-27 14:21 ` Oleksij Rempel
  2023-03-27 16:41   ` Andrew Lunn
  2023-03-27 14:21 ` [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support Oleksij Rempel
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Oleksij Rempel
@ 2023-03-27 14:21 ` Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling Oleksij Rempel
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit introduces a new variable, is_smart_eee_phy, to the PHY
layer. This variable is used to indicate whether a PHY supports the
SmartEEE functionality, which is a Low Power Idle (LPI) implementation
on the PHY side, typically handled by the MAC.

By adding the is_smart_eee_phy variable, PHY drivers and the PHYlib
framework can provide proper configuration depending on the side that
implements LPI (PHY or MAC).

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 include/linux/phy.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 07cebf110aa6..6622b59ab5a1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -547,6 +547,7 @@ struct macsec_ops;
  * @downshifted_rate: Set true if link speed has been downshifted.
  * @is_on_sfp_module: Set true if PHY is located on an SFP module.
  * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY
+ * @is_smart_eee_phy: Set true if PHY is a Smart EEE PHY
  * @state: State of the PHY for management purposes
  * @dev_flags: Device-specific flags used by the PHY driver.
  *
@@ -642,6 +643,7 @@ struct phy_device {
 	unsigned downshifted_rate:1;
 	unsigned is_on_sfp_module:1;
 	unsigned mac_managed_pm:1;
+	unsigned is_smart_eee_phy:1;
 
 	unsigned autoneg:1;
 	/* The most recently read link state */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support Oleksij Rempel
@ 2023-03-27 14:21 ` Oleksij Rempel
  2023-03-27 14:21 ` [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Oleksij Rempel
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit introduces a new variable, mac_supports_eee, to the PHY
layer. This variable is used to indicate if a MAC provides EEE support
or is responsible for Low Power Idle (LPI) handling. The
mac_supports_eee variable should be used in conjunction with
is_smart_eee_phy to make proper configuration decisions based on the
capabilities of both the PHY and MAC.

By adding the mac_supports_eee variable, PHY drivers and the PHYlib
framework can better coordinate EEE and LPI management between the PHY
and MAC.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 include/linux/phy.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6622b59ab5a1..573ad3fc2bf7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -548,6 +548,7 @@ struct macsec_ops;
  * @is_on_sfp_module: Set true if PHY is located on an SFP module.
  * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY
  * @is_smart_eee_phy: Set true if PHY is a Smart EEE PHY
+ * @mac_supports_eee: Set true if MAC supports EEE
  * @state: State of the PHY for management purposes
  * @dev_flags: Device-specific flags used by the PHY driver.
  *
@@ -644,6 +645,7 @@ struct phy_device {
 	unsigned is_on_sfp_module:1;
 	unsigned mac_managed_pm:1;
 	unsigned is_smart_eee_phy:1;
+	unsigned mac_supports_eee:1;
 
 	unsigned autoneg:1;
 	/* The most recently read link state */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
                   ` (2 preceding siblings ...)
  2023-03-27 14:21 ` [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling Oleksij Rempel
@ 2023-03-27 14:21 ` Oleksij Rempel
  2023-03-27 20:45   ` kernel test robot
  2023-03-28  3:36   ` kernel test robot
  2023-03-27 14:21 ` [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs Oleksij Rempel
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This patch reworks the ethtool handler to allow accessing set/get EEE
properties of SmartEEE-capable PHYs, even when the associated MAC does
not provide EEE support. Previously, the handler would not allow
configuration or management of EEE properties for such PHYs, limiting
their functionality and energy efficiency.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 net/ethtool/common.c | 38 ++++++++++++++++++++++++++++++++++++++
 net/ethtool/common.h |  2 ++
 net/ethtool/eee.c    | 17 +++++++++++------
 3 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 5fb19050991e..267fd3600f15 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -661,6 +661,44 @@ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index)
 }
 EXPORT_SYMBOL(ethtool_get_phc_vclocks);
 
+int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee)
+{
+	const struct ethtool_ops *ops = dev->ethtool_ops;
+	struct phy_device *phydev = dev->phydev;
+	int ret;
+
+	if (ops->get_eee)
+		ret = ops->get_eee(dev, eee);
+	else
+		ret = -EOPNOTSUPP;
+
+	if (ret == -EOPNOTSUPP) {
+		if (phydev && phydev->is_smart_eee_phy)
+			ret = phy_ethtool_get_eee(phydev, eee);
+	}
+
+	return ret;
+}
+
+int __ethtool_set_eee(struct net_device *dev, struct ethtool_eee *eee)
+{
+	const struct ethtool_ops *ops = dev->ethtool_ops;
+	struct phy_device *phydev = dev->phydev;
+	int ret;
+
+	if (ops->set_eee)
+		ret = ops->set_eee(dev, eee);
+	else
+		ret = -EOPNOTSUPP;
+
+	if (ret == -EOPNOTSUPP) {
+		if (phydev && phydev->is_smart_eee_phy)
+			ret = phy_ethtool_set_eee(phydev, eee);
+	}
+
+	return ret;
+}
+
 const struct ethtool_phy_ops *ethtool_phy_ops;
 
 void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops)
diff --git a/net/ethtool/common.h b/net/ethtool/common.h
index 28b8aaaf9bcb..59c1906ec800 100644
--- a/net/ethtool/common.h
+++ b/net/ethtool/common.h
@@ -45,6 +45,8 @@ bool convert_legacy_settings_to_link_ksettings(
 int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max);
 int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max);
 int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info);
+int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee);
+int __ethtool_set_eee(struct net_device *dev, struct ethtool_eee *eee);
 
 extern const struct ethtool_phy_ops *ethtool_phy_ops;
 extern const struct ethtool_pse_ops *ethtool_pse_ops;
diff --git a/net/ethtool/eee.c b/net/ethtool/eee.c
index 42104bcb0e47..43b866184297 100644
--- a/net/ethtool/eee.c
+++ b/net/ethtool/eee.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include <linux/phy.h>
+
 #include "netlink.h"
 #include "common.h"
 #include "bitset.h"
@@ -32,12 +34,10 @@ static int eee_prepare_data(const struct ethnl_req_info *req_base,
 	struct net_device *dev = reply_base->dev;
 	int ret;
 
-	if (!dev->ethtool_ops->get_eee)
-		return -EOPNOTSUPP;
 	ret = ethnl_ops_begin(dev);
 	if (ret < 0)
 		return ret;
-	ret = dev->ethtool_ops->get_eee(dev, &data->eee);
+	ret =  __ethtool_get_eee(dev, &data->eee);
 	ethnl_ops_complete(dev);
 
 	return ret;
@@ -123,8 +123,13 @@ static int
 ethnl_set_eee_validate(struct ethnl_req_info *req_info, struct genl_info *info)
 {
 	const struct ethtool_ops *ops = req_info->dev->ethtool_ops;
+	struct net_device *dev = req_info->dev;
+
+	if ((ops->get_eee && ops->set_eee) ||
+	    (dev->phydev && dev->phydev->is_smart_eee_phy))
+		return 1;
 
-	return ops->get_eee && ops->set_eee ? 1 : -EOPNOTSUPP;
+	return -EOPNOTSUPP;
 }
 
 static int
@@ -136,7 +141,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info)
 	bool mod = false;
 	int ret;
 
-	ret = dev->ethtool_ops->get_eee(dev, &eee);
+	ret = __ethtool_get_eee(dev, &eee);
 	if (ret < 0)
 		return ret;
 
@@ -153,7 +158,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info)
 	if (!mod)
 		return 0;
 
-	ret = dev->ethtool_ops->set_eee(dev, &eee);
+	ret = __ethtool_set_eee(dev, &eee);
 	return ret < 0 ? ret : 1;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
                   ` (3 preceding siblings ...)
  2023-03-27 14:21 ` [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Oleksij Rempel
@ 2023-03-27 14:21 ` Oleksij Rempel
  2023-03-27 14:22 ` [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Oleksij Rempel
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:21 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit adds SmartEEE support indication for the AR8035 and AR8031
PHYs in the at803x driver. These PHYs support the SmartEEE
functionality, which is a Low Power Idle (LPI) implementation on the PHY
side, typically handled by the MAC.

By indicating SmartEEE support for these PHYs, the at803x driver and the
PHYlib framework can provide proper configuration and management of EEE
and LPI features. This allows for improved power management and energy
efficiency in devices using AR8035 and AR8031 PHYs.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 656136628ffd..653d27a2e62b 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -856,6 +856,12 @@ static int at803x_probe(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	if (phydev->drv->phy_id == ATH8035_PHY_ID ||
+	    phydev->drv->phy_id == ATH8031_PHY_ID) {
+		if (!(priv->flags & AT803X_DISABLE_SMARTEEE))
+			phydev->is_smart_eee_phy = true;
+	}
+
 	if (priv->vddio) {
 		ret = regulator_enable(priv->vddio);
 		if (ret < 0)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
                   ` (4 preceding siblings ...)
  2023-03-27 14:21 ` [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs Oleksij Rempel
@ 2023-03-27 14:22 ` Oleksij Rempel
  2023-03-28 12:05   ` Oleksij Rempel
  2023-03-27 14:22 ` [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations Oleksij Rempel
  2023-03-27 14:22 ` [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Oleksij Rempel
  7 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:22 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit makes SmartEEE support in the AR8035 PHY optional and
configurable through the ethtool eee_set/get interface. Before this
patch, SmartEEE was always enabled except when a device tree option was
preventing it. Since EEE support not only provides advantages in power
management, but can also uncover compatibility issues and other bugs, it
is beneficial to allow users to control this functionality.

By making SmartEEE support optional and configurable via ethtool, the
at803x driver can adapt to different MAC configurations and properly
handle EEE and LPI features. This flexibility empowers users to manage
the trade-offs between power management, compatibility, and overall
performance as needed.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 126 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 118 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 653d27a2e62b..4f65b3ebf806 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -165,8 +165,18 @@
 
 #define AT803X_MMD3_SMARTEEE_CTL1		0x805b
 #define AT803X_MMD3_SMARTEEE_CTL2		0x805c
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_LOW	GENMASK(15, 0)
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_15_0	GENMASK(15, 0)
 #define AT803X_MMD3_SMARTEEE_CTL3		0x805d
 #define AT803X_MMD3_SMARTEEE_CTL3_LPI_EN	BIT(8)
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH	GENMASK(7, 0)
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_23_16	GENMASK(23, 16)
+/* Tx LPI timer resolution */
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS	163840
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US	\
+	((GENMASK(23, 0) * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS) / \
+	       NSEC_PER_USEC)
+#define AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US	335544
 
 #define ATH9331_PHY_ID				0x004dd041
 #define ATH8030_PHY_ID				0x004dd076
@@ -302,6 +312,8 @@ struct at803x_priv {
 	u8 smarteee_lpi_tw_100m;
 	bool is_fiber;
 	bool is_1000basex;
+	bool tx_lpi_on;
+	u32 tx_lpi_timer;
 	struct regulator_dev *vddio_rdev;
 	struct regulator_dev *vddh_rdev;
 	struct regulator *vddio;
@@ -858,8 +870,12 @@ static int at803x_probe(struct phy_device *phydev)
 
 	if (phydev->drv->phy_id == ATH8035_PHY_ID ||
 	    phydev->drv->phy_id == ATH8031_PHY_ID) {
-		if (!(priv->flags & AT803X_DISABLE_SMARTEEE))
+		if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) {
 			phydev->is_smart_eee_phy = true;
+			priv->tx_lpi_on = true;
+			priv->tx_lpi_timer =
+				AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US;
+		}
 	}
 
 	if (priv->vddio) {
@@ -959,10 +975,12 @@ static int at803x_get_features(struct phy_device *phydev)
 static int at803x_smarteee_config(struct phy_device *phydev)
 {
 	struct at803x_priv *priv = phydev->priv;
+	u64 tx_lpi_timer_raw;
+	u64 tx_lpi_timer_ns;
 	u16 mask = 0, val = 0;
 	int ret;
 
-	if (priv->flags & AT803X_DISABLE_SMARTEEE)
+	if (!priv->tx_lpi_on)
 		return phy_modify_mmd(phydev, MDIO_MMD_PCS,
 				      AT803X_MMD3_SMARTEEE_CTL3,
 				      AT803X_MMD3_SMARTEEE_CTL3_LPI_EN, 0);
@@ -983,9 +1001,27 @@ static int at803x_smarteee_config(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	tx_lpi_timer_ns = priv->tx_lpi_timer * NSEC_PER_USEC;
+	tx_lpi_timer_raw =
+		DIV_ROUND_CLOSEST_ULL(tx_lpi_timer_ns,
+				      AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS);
+	val = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW,
+			 FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0,
+				   tx_lpi_timer_raw));
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL2,
+			    val);
+	if (ret)
+		return ret;
+
+	val = AT803X_MMD3_SMARTEEE_CTL3_LPI_EN |
+		FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH,
+			   FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16,
+				     tx_lpi_timer_raw));
+
 	return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3,
-			      AT803X_MMD3_SMARTEEE_CTL3_LPI_EN,
-			      AT803X_MMD3_SMARTEEE_CTL3_LPI_EN);
+			      AT803X_MMD3_SMARTEEE_CTL3_LPI_EN |
+			      AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, val);
 }
 
 static int at803x_clk_out_config(struct phy_device *phydev)
@@ -1072,10 +1108,6 @@ static int at803x_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
-	ret = at803x_smarteee_config(phydev);
-	if (ret < 0)
-		return ret;
-
 	ret = at803x_clk_out_config(phydev);
 	if (ret < 0)
 		return ret;
@@ -1359,6 +1391,16 @@ static int at803x_config_aneg(struct phy_device *phydev)
 			return ret;
 	}
 
+	/* only after PHY is attached we will be able to see if MAC supports
+	 * EEE
+	 */
+	if (phydev->mac_supports_eee)
+		priv->tx_lpi_on = false;
+
+	ret = at803x_smarteee_config(phydev);
+	if (ret < 0)
+		return ret;
+
 	return __genphy_config_aneg(phydev, ret);
 }
 
@@ -1617,6 +1659,72 @@ static int at803x_cable_test_start(struct phy_device *phydev)
 	return 0;
 }
 
+static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
+{
+	struct at803x_priv *priv = phydev->priv;
+	u32 tx_timer_raw;
+	u64 tx_timer_ns;
+	int ret;
+
+	/* If SmartEEE is not enabled, it is expected that tx_lpi_* fields
+	 * are processed by the MAC driver.
+	 */
+	if (priv->flags & AT803X_DISABLE_SMARTEEE)
+		return genphy_c45_ethtool_get_eee(phydev, data);
+
+	ret = phy_read_mmd(phydev, MDIO_MMD_PCS,
+			   AT803X_MMD3_SMARTEEE_CTL2);
+	tx_timer_raw = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0,
+				  FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW,
+					    ret));
+	if (ret < 0)
+		return ret;
+
+	ret = phy_read_mmd(phydev, MDIO_MMD_PCS,
+			   AT803X_MMD3_SMARTEEE_CTL3);
+	if (ret < 0)
+		return ret;
+
+	tx_timer_raw |= FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16,
+				   FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH,
+					     ret));
+	tx_timer_ns = tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS;
+	data->tx_lpi_timer = DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC);
+
+	data->tx_lpi_enabled = !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN);
+
+	return genphy_c45_ethtool_get_eee(phydev, data);
+}
+
+static int at803x_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
+{
+	struct at803x_priv *priv = phydev->priv;
+	int ret;
+
+	/* If SmartEEE is not enabled, it is expected that tx_lpi_* fields
+	 * are processed by the MAC driver.
+	 */
+	if (phydev->mac_supports_eee || !phydev->is_smart_eee_phy)
+		return genphy_c45_ethtool_set_eee(phydev, data);
+
+	if (data->tx_lpi_timer > AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US) {
+		phydev_err(phydev, "Max LPI timer is %lu microsecs\n",
+			   AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US);
+		return -EINVAL;
+	}
+
+	/* Changing Tx LPI on/off or Tx LPI timer settings
+	 * do not require link reset.
+	 */
+	priv->tx_lpi_timer = data->tx_lpi_timer;
+	priv->tx_lpi_on = data->tx_lpi_enabled;
+	ret = at803x_smarteee_config(phydev);
+	if (ret)
+		return ret;
+
+	return genphy_c45_ethtool_set_eee(phydev, data);
+}
+
 static int qca83xx_config_init(struct phy_device *phydev)
 {
 	u8 switch_revision;
@@ -2043,6 +2151,8 @@ static struct phy_driver at803x_driver[] = {
 	.set_tunable		= at803x_set_tunable,
 	.cable_test_start	= at803x_cable_test_start,
 	.cable_test_get_status	= at803x_cable_test_get_status,
+	.get_eee		= at803x_get_eee,
+	.set_eee		= at803x_set_eee,
 }, {
 	/* Qualcomm Atheros AR8030 */
 	.phy_id			= ATH8030_PHY_ID,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
                   ` (5 preceding siblings ...)
  2023-03-27 14:22 ` [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Oleksij Rempel
@ 2023-03-27 14:22 ` Oleksij Rempel
  2023-03-27 14:22 ` [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Oleksij Rempel
  7 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:22 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit fixes SmartEEE support for certain link configurations on the
AR8035 PHY. Before this patch, if AR8035 was running with SmartEEE enabled
(EEE and LPI are on), it would not be able to establish a 100BaseTX/Half or
1000BaseT/Half link. A similar issue would occur with 100BaseTX/Full and an
LPI TX timer configured to less than 80 msec.

To avoid this issue, we need to keep LPI disabled before the link is
established and enable it only when a supported link configuration is
detected. By implementing this fix, the at803x driver can now correctly
handle SmartEEE features for various link configurations, improving link
establishment, compatibility, and overall performance.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 4f65b3ebf806..5a12f778d675 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -1014,10 +1014,15 @@ static int at803x_smarteee_config(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
-	val = AT803X_MMD3_SMARTEEE_CTL3_LPI_EN |
-		FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH,
-			   FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16,
-				     tx_lpi_timer_raw));
+	val = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH,
+			 FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16,
+				   tx_lpi_timer_raw));
+
+	if (phydev->state == PHY_RUNNING &&
+	    phy_check_valid(phydev->speed, phydev->duplex,
+			    phydev->supported_eee)) {
+		val |= AT803X_MMD3_SMARTEEE_CTL3_LPI_EN;
+	}
 
 	return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3,
 			      AT803X_MMD3_SMARTEEE_CTL3_LPI_EN |
@@ -1691,7 +1696,7 @@ static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
 	tx_timer_ns = tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS;
 	data->tx_lpi_timer = DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC);
 
-	data->tx_lpi_enabled = !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN);
+	data->tx_lpi_enabled = priv->tx_lpi_on;
 
 	return genphy_c45_ethtool_get_eee(phydev, data);
 }
@@ -1725,6 +1730,28 @@ static int at803x_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
 	return genphy_c45_ethtool_set_eee(phydev, data);
 }
 
+static void at8035_link_change_notify(struct phy_device *phydev)
+{
+	struct at803x_priv *priv = phydev->priv;
+
+	if (phydev->mac_supports_eee || !phydev->is_smart_eee_phy)
+		return;
+
+	if (phydev->state == PHY_RUNNING) {
+		if (priv->tx_lpi_on && phy_check_valid(phydev->speed,
+						       phydev->duplex,
+						       phydev->supported_eee))
+			phy_set_bits_mmd(phydev, MDIO_MMD_PCS,
+					 AT803X_MMD3_SMARTEEE_CTL3,
+					 AT803X_MMD3_SMARTEEE_CTL3_LPI_EN);
+	} else {
+		if (priv->tx_lpi_on)
+			phy_clear_bits_mmd(phydev, MDIO_MMD_PCS,
+					   AT803X_MMD3_SMARTEEE_CTL3,
+					   AT803X_MMD3_SMARTEEE_CTL3_LPI_EN);
+	}
+}
+
 static int qca83xx_config_init(struct phy_device *phydev)
 {
 	u8 switch_revision;
@@ -2153,6 +2180,7 @@ static struct phy_driver at803x_driver[] = {
 	.cable_test_get_status	= at803x_cable_test_get_status,
 	.get_eee		= at803x_get_eee,
 	.set_eee		= at803x_set_eee,
+	.link_change_notify	= at8035_link_change_notify,
 }, {
 	/* Qualcomm Atheros AR8030 */
 	.phy_id			= ATH8030_PHY_ID,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers
  2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
                   ` (6 preceding siblings ...)
  2023-03-27 14:22 ` [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations Oleksij Rempel
@ 2023-03-27 14:22 ` Oleksij Rempel
  2023-03-28  1:48   ` Wei Fang
  7 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-27 14:22 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Shenwei Wang,
	Clark Wang, NXP Linux Team, Amit Cohen, Gal Pressman,
	Alexandru Tachici, Piergiorgio Beruto, Willem de Bruijn,
	Vladimir Oltean

This commit adds EEE (LPI) support indication for specific FEC Ethernet
controllers. By indicating EEE support for these controllers, it allows
PHY drivers to choose the right configuration for EEE and LPI features,
depending on whether the MAC or the PHY is responsible for handling them.

This change provides more flexibility and control over energy-saving
features, enabling PHY drivers to disable SmartEEE functionality in favor
of MAC EEE support when appropriate, depending on their specific use cases
and requirements.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f3b16a6673e2..554a5dc92817 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2318,6 +2318,8 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 	fep->link = 0;
 	fep->full_duplex = 0;
 
+	if (fep->quirks & FEC_QUIRK_HAS_EEE)
+		phy_dev->mac_supports_eee = true;
 	phy_dev->mac_managed_pm = true;
 
 	phy_attached_info(phy_dev);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs
  2023-03-27 14:21 ` [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Oleksij Rempel
@ 2023-03-27 16:41   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2023-03-27 16:41 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Heiner Kallweit, Russell King, kernel, linux-kernel,
	netdev, Shenwei Wang, Clark Wang, NXP Linux Team, Amit Cohen,
	Gal Pressman, Alexandru Tachici, Piergiorgio Beruto,
	Willem de Bruijn, Vladimir Oltean

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs
  2023-03-27 14:21 ` [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Oleksij Rempel
@ 2023-03-27 20:45   ` kernel test robot
  2023-03-28  3:36   ` kernel test robot
  1 sibling, 0 replies; 16+ messages in thread
From: kernel test robot @ 2023-03-27 20:45 UTC (permalink / raw)
  To: Oleksij Rempel, Wei Fang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Andrew Lunn, Heiner Kallweit,
	Russell King
  Cc: oe-kbuild-all, netdev, Oleksij Rempel, kernel, linux-kernel,
	Shenwei Wang, Clark Wang, NXP Linux Team, Amit Cohen,
	Gal Pressman, Alexandru Tachici, Piergiorgio Beruto,
	Willem de Bruijn, Vladimir Oltean

Hi Oleksij,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/net-phy-Add-driver-specific-get-set_eee-support-for-non-standard-PHYs/20230327-222630
patch link:    https://lore.kernel.org/r/20230327142202.3754446-5-o.rempel%40pengutronix.de
patch subject: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20230328/202303280408.Krp7V753-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/fcee3230c8abb824746744ba0fc39dfd626faa65
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Oleksij-Rempel/net-phy-Add-driver-specific-get-set_eee-support-for-non-standard-PHYs/20230327-222630
        git checkout fcee3230c8abb824746744ba0fc39dfd626faa65
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=um SUBARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303280408.Krp7V753-lkp@intel.com/

All errors (new ones prefixed by >>):

   /usr/bin/ld: net/ethtool/common.o: in function `__ethtool_get_eee':
>> net/ethtool/common.c:677: undefined reference to `phy_ethtool_get_eee'
   /usr/bin/ld: net/ethtool/common.o: in function `__ethtool_set_eee':
>> net/ethtool/common.c:696: undefined reference to `phy_ethtool_set_eee'
   collect2: error: ld returned 1 exit status


vim +677 net/ethtool/common.c

   663	
   664	int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee)
   665	{
   666		const struct ethtool_ops *ops = dev->ethtool_ops;
   667		struct phy_device *phydev = dev->phydev;
   668		int ret;
   669	
   670		if (ops->get_eee)
   671			ret = ops->get_eee(dev, eee);
   672		else
   673			ret = -EOPNOTSUPP;
   674	
   675		if (ret == -EOPNOTSUPP) {
   676			if (phydev && phydev->is_smart_eee_phy)
 > 677				ret = phy_ethtool_get_eee(phydev, eee);
   678		}
   679	
   680		return ret;
   681	}
   682	
   683	int __ethtool_set_eee(struct net_device *dev, struct ethtool_eee *eee)
   684	{
   685		const struct ethtool_ops *ops = dev->ethtool_ops;
   686		struct phy_device *phydev = dev->phydev;
   687		int ret;
   688	
   689		if (ops->set_eee)
   690			ret = ops->set_eee(dev, eee);
   691		else
   692			ret = -EOPNOTSUPP;
   693	
   694		if (ret == -EOPNOTSUPP) {
   695			if (phydev && phydev->is_smart_eee_phy)
 > 696				ret = phy_ethtool_set_eee(phydev, eee);
   697		}
   698	
   699		return ret;
   700	}
   701	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers
  2023-03-27 14:22 ` [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Oleksij Rempel
@ 2023-03-28  1:48   ` Wei Fang
  0 siblings, 0 replies; 16+ messages in thread
From: Wei Fang @ 2023-03-28  1:48 UTC (permalink / raw)
  To: Oleksij Rempel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: kernel, linux-kernel, netdev, Shenwei Wang, Clark Wang,
	dl-linux-imx, Amit Cohen, Gal Pressman, Alexandru Tachici,
	Piergiorgio Beruto, Willem de Bruijn, Vladimir Oltean

> -----Original Message-----
> From: Oleksij Rempel <o.rempel@pengutronix.de>
> Sent: 2023年3月27日 22:22
> To: Wei Fang <wei.fang@nxp.com>; David S. Miller <davem@davemloft.net>;
> Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>;
> Paolo Abeni <pabeni@redhat.com>; Andrew Lunn <andrew@lunn.ch>; Heiner
> Kallweit <hkallweit1@gmail.com>; Russell King <linux@armlinux.org.uk>
> Cc: Oleksij Rempel <o.rempel@pengutronix.de>; kernel@pengutronix.de;
> linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Shenwei Wang
> <shenwei.wang@nxp.com>; Clark Wang <xiaoning.wang@nxp.com>;
> dl-linux-imx <linux-imx@nxp.com>; Amit Cohen <amcohen@nvidia.com>; Gal
> Pressman <gal@nvidia.com>; Alexandru Tachici
> <alexandru.tachici@analog.com>; Piergiorgio Beruto
> <piergiorgio.beruto@gmail.com>; Willem de Bruijn <willemb@google.com>;
> Vladimir Oltean <vladimir.oltean@nxp.com>
> Subject: [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some
> FEC Ethernet controllers
> 
> This commit adds EEE (LPI) support indication for specific FEC Ethernet
> controllers. By indicating EEE support for these controllers, it allows PHY
> drivers to choose the right configuration for EEE and LPI features, depending
> on whether the MAC or the PHY is responsible for handling them.
> 
> This change provides more flexibility and control over energy-saving features,
> enabling PHY drivers to disable SmartEEE functionality in favor of MAC EEE
> support when appropriate, depending on their specific use cases and
> requirements.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Wei Fang <wei.fang@nxp.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs
  2023-03-27 14:21 ` [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Oleksij Rempel
  2023-03-27 20:45   ` kernel test robot
@ 2023-03-28  3:36   ` kernel test robot
  1 sibling, 0 replies; 16+ messages in thread
From: kernel test robot @ 2023-03-28  3:36 UTC (permalink / raw)
  To: Oleksij Rempel, Wei Fang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Andrew Lunn, Heiner Kallweit,
	Russell King
  Cc: oe-kbuild-all, netdev, Oleksij Rempel, kernel, linux-kernel,
	Shenwei Wang, Clark Wang, NXP Linux Team, Amit Cohen,
	Gal Pressman, Alexandru Tachici, Piergiorgio Beruto,
	Willem de Bruijn, Vladimir Oltean

Hi Oleksij,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/net-phy-Add-driver-specific-get-set_eee-support-for-non-standard-PHYs/20230327-222630
patch link:    https://lore.kernel.org/r/20230327142202.3754446-5-o.rempel%40pengutronix.de
patch subject: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs
config: csky-defconfig (https://download.01.org/0day-ci/archive/20230328/202303281117.3288i7kT-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/fcee3230c8abb824746744ba0fc39dfd626faa65
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Oleksij-Rempel/net-phy-Add-driver-specific-get-set_eee-support-for-non-standard-PHYs/20230327-222630
        git checkout fcee3230c8abb824746744ba0fc39dfd626faa65
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303281117.3288i7kT-lkp@intel.com/

All errors (new ones prefixed by >>):

   csky-linux-ld: net/ethtool/common.o: in function `__ethtool_get_eee':
   common.c:(.text+0x45c): undefined reference to `phy_ethtool_get_eee'
   csky-linux-ld: net/ethtool/common.o: in function `__ethtool_set_eee':
   common.c:(.text+0x49c): undefined reference to `phy_ethtool_set_eee'
>> csky-linux-ld: common.c:(.text+0x4b8): undefined reference to `phy_ethtool_get_eee'
>> csky-linux-ld: common.c:(.text+0x4bc): undefined reference to `phy_ethtool_set_eee'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool
  2023-03-27 14:22 ` [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Oleksij Rempel
@ 2023-03-28 12:05   ` Oleksij Rempel
  2023-03-28 12:49     ` Andrew Lunn
  0 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-28 12:05 UTC (permalink / raw)
  To: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: kernel, linux-kernel, netdev, Shenwei Wang, Clark Wang,
	NXP Linux Team, Amit Cohen, Gal Pressman, Alexandru Tachici,
	Piergiorgio Beruto, Willem de Bruijn, Vladimir Oltean

On Mon, Mar 27, 2023 at 04:22:00PM +0200, Oleksij Rempel wrote:
> This commit makes SmartEEE support in the AR8035 PHY optional and
> configurable through the ethtool eee_set/get interface. Before this
> patch, SmartEEE was always enabled except when a device tree option was
> preventing it. Since EEE support not only provides advantages in power
> management, but can also uncover compatibility issues and other bugs, it
> is beneficial to allow users to control this functionality.
> 
> By making SmartEEE support optional and configurable via ethtool, the
> at803x driver can adapt to different MAC configurations and properly
> handle EEE and LPI features. This flexibility empowers users to manage
> the trade-offs between power management, compatibility, and overall
> performance as needed.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/at803x.c | 126 ++++++++++++++++++++++++++++++++++++---
>  1 file changed, 118 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 653d27a2e62b..4f65b3ebf806 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -165,8 +165,18 @@
>  
>  #define AT803X_MMD3_SMARTEEE_CTL1		0x805b
>  #define AT803X_MMD3_SMARTEEE_CTL2		0x805c
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_LOW	GENMASK(15, 0)
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_15_0	GENMASK(15, 0)
>  #define AT803X_MMD3_SMARTEEE_CTL3		0x805d
>  #define AT803X_MMD3_SMARTEEE_CTL3_LPI_EN	BIT(8)
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH	GENMASK(7, 0)
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_23_16	GENMASK(23, 16)
> +/* Tx LPI timer resolution */
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS	163840
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US	\
> +	((GENMASK(23, 0) * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS) / \
> +	       NSEC_PER_USEC)
> +#define AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US	335544
>  
>  #define ATH9331_PHY_ID				0x004dd041
>  #define ATH8030_PHY_ID				0x004dd076
> @@ -302,6 +312,8 @@ struct at803x_priv {
>  	u8 smarteee_lpi_tw_100m;
>  	bool is_fiber;
>  	bool is_1000basex;
> +	bool tx_lpi_on;

@Andrew, this variable can be replace by your phydev->tx_lpi_enabled
variable. Should I wait for your patches went mainline?

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool
  2023-03-28 12:05   ` Oleksij Rempel
@ 2023-03-28 12:49     ` Andrew Lunn
  2023-03-28 13:00       ` Oleksij Rempel
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Lunn @ 2023-03-28 12:49 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Heiner Kallweit, Russell King, kernel, linux-kernel,
	netdev, Shenwei Wang, Clark Wang, NXP Linux Team, Amit Cohen,
	Gal Pressman, Alexandru Tachici, Piergiorgio Beruto,
	Willem de Bruijn, Vladimir Oltean

> > @@ -302,6 +312,8 @@ struct at803x_priv {
> >  	u8 smarteee_lpi_tw_100m;
> >  	bool is_fiber;
> >  	bool is_1000basex;
> > +	bool tx_lpi_on;
> 
> @Andrew, this variable can be replace by your phydev->tx_lpi_enabled
> variable. Should I wait for your patches went mainline?

I was wondering about the overlap and the best way to address it.

My patchset is also a bit big, and getting bigger. So it might make
sense to split out some of the bits you need and get them merged
first.

You need the MAC indicating it is EEE capable. I don't store that
information explicitly, but that is a quick simple change. You also
need phydev->tx_lpi_enabled. Anything else?

     Andrew

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool
  2023-03-28 12:49     ` Andrew Lunn
@ 2023-03-28 13:00       ` Oleksij Rempel
  0 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2023-03-28 13:00 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Wei Fang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Heiner Kallweit, Russell King, kernel, linux-kernel,
	netdev, Shenwei Wang, Clark Wang, NXP Linux Team, Amit Cohen,
	Gal Pressman, Alexandru Tachici, Piergiorgio Beruto,
	Willem de Bruijn, Vladimir Oltean

On Tue, Mar 28, 2023 at 02:49:58PM +0200, Andrew Lunn wrote:
> > > @@ -302,6 +312,8 @@ struct at803x_priv {
> > >  	u8 smarteee_lpi_tw_100m;
> > >  	bool is_fiber;
> > >  	bool is_1000basex;
> > > +	bool tx_lpi_on;
> > 
> > @Andrew, this variable can be replace by your phydev->tx_lpi_enabled
> > variable. Should I wait for your patches went mainline?
> 
> I was wondering about the overlap and the best way to address it.
> 
> My patchset is also a bit big, and getting bigger. So it might make
> sense to split out some of the bits you need and get them merged
> first.
> 
> You need the MAC indicating it is EEE capable. I don't store that
> information explicitly, but that is a quick simple change. You also
> need phydev->tx_lpi_enabled. Anything else?

No. It's fine. Thx!

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-03-28 13:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 14:21 [PATCH net-next v2 0/8] Make SmartEEE support controllable Oleksij Rempel
2023-03-27 14:21 ` [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Oleksij Rempel
2023-03-27 16:41   ` Andrew Lunn
2023-03-27 14:21 ` [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support Oleksij Rempel
2023-03-27 14:21 ` [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling Oleksij Rempel
2023-03-27 14:21 ` [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Oleksij Rempel
2023-03-27 20:45   ` kernel test robot
2023-03-28  3:36   ` kernel test robot
2023-03-27 14:21 ` [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs Oleksij Rempel
2023-03-27 14:22 ` [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Oleksij Rempel
2023-03-28 12:05   ` Oleksij Rempel
2023-03-28 12:49     ` Andrew Lunn
2023-03-28 13:00       ` Oleksij Rempel
2023-03-27 14:22 ` [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations Oleksij Rempel
2023-03-27 14:22 ` [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Oleksij Rempel
2023-03-28  1:48   ` Wei Fang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).