From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3791DC76195 for ; Mon, 27 Mar 2023 14:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbjC0OYQ (ORCPT ); Mon, 27 Mar 2023 10:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B6697D8E for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hj-Kt; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IK-7Q; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkik-PV; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Date: Mon, 27 Mar 2023 16:21:55 +0200 Message-Id: <20230327142202.3754446-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Andrew Lunn --- 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, s= truct ethtool_eee *data) return -EIO; =20 mutex_lock(&phydev->lock); - ret =3D genphy_c45_ethtool_get_eee(phydev, data); + if (phydev->drv->get_eee) + ret =3D phydev->drv->get_eee(phydev, data); + else + ret =3D genphy_c45_ethtool_get_eee(phydev, data); mutex_unlock(&phydev->lock); =20 return ret; @@ -1590,7 +1593,10 @@ int phy_ethtool_set_eee(struct phy_device *phydev, s= truct ethtool_eee *data) return -EIO; =20 mutex_lock(&phydev->lock); - ret =3D genphy_c45_ethtool_set_eee(phydev, data); + if (phydev->drv->set_eee) + ret =3D phydev->drv->set_eee(phydev, data); + else + ret =3D genphy_c45_ethtool_set_eee(phydev, data); mutex_unlock(&phydev->lock); =20 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) --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F85C76195 for ; Mon, 27 Mar 2023 14:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233026AbjC0OYN (ORCPT ); Mon, 27 Mar 2023 10:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87E017D8A for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hm-Kr; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IT-N2; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkit-Qe; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support Date: Mon, 27 Mar 2023 16:21:56 +0200 Message-Id: <20230327142202.3754446-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 unsigned autoneg:1; /* The most recently read link state */ --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68AD8C761A6 for ; Mon, 27 Mar 2023 14:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233006AbjC0OYL (ORCPT ); Mon, 27 Mar 2023 10:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87ED97D8C for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hi-L1; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjX-0076IH-SB; Mon, 27 Mar 2023 16:22:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkj2-RP; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling Date: Mon, 27 Mar 2023 16:21:57 +0200 Message-Id: <20230327142202.3754446-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 unsigned autoneg:1; /* The most recently read link state */ --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7502C76195 for ; Mon, 27 Mar 2023 14:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233109AbjC0OY1 (ORCPT ); Mon, 27 Mar 2023 10:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8D257D96 for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hl-Ky; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IQ-J2; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjB-SC; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Date: Mon, 27 Mar 2023 16:21:58 +0200 Message-Id: <20230327142202.3754446-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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, in= t **vclock_index) } EXPORT_SYMBOL(ethtool_get_phc_vclocks); =20 +int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee) +{ + const struct ethtool_ops *ops =3D dev->ethtool_ops; + struct phy_device *phydev =3D dev->phydev; + int ret; + + if (ops->get_eee) + ret =3D ops->get_eee(dev, eee); + else + ret =3D -EOPNOTSUPP; + + if (ret =3D=3D -EOPNOTSUPP) { + if (phydev && phydev->is_smart_eee_phy) + ret =3D 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 =3D dev->ethtool_ops; + struct phy_device *phydev =3D dev->phydev; + int ret; + + if (ops->set_eee) + ret =3D ops->set_eee(dev, eee); + else + ret =3D -EOPNOTSUPP; + + if (ret =3D=3D -EOPNOTSUPP) { + if (phydev && phydev->is_smart_eee_phy) + ret =3D phy_ethtool_set_eee(phydev, eee); + } + + return ret; +} + const struct ethtool_phy_ops *ethtool_phy_ops; =20 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); =20 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 =20 +#include + #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 =3D reply_base->dev; int ret; =20 - if (!dev->ethtool_ops->get_eee) - return -EOPNOTSUPP; ret =3D ethnl_ops_begin(dev); if (ret < 0) return ret; - ret =3D dev->ethtool_ops->get_eee(dev, &data->eee); + ret =3D __ethtool_get_eee(dev, &data->eee); ethnl_ops_complete(dev); =20 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 =3D req_info->dev->ethtool_ops; + struct net_device *dev =3D req_info->dev; + + if ((ops->get_eee && ops->set_eee) || + (dev->phydev && dev->phydev->is_smart_eee_phy)) + return 1; =20 - return ops->get_eee && ops->set_eee ? 1 : -EOPNOTSUPP; + return -EOPNOTSUPP; } =20 static int @@ -136,7 +141,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct g= enl_info *info) bool mod =3D false; int ret; =20 - ret =3D dev->ethtool_ops->get_eee(dev, &eee); + ret =3D __ethtool_get_eee(dev, &eee); if (ret < 0) return ret; =20 @@ -153,7 +158,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct g= enl_info *info) if (!mod) return 0; =20 - ret =3D dev->ethtool_ops->set_eee(dev, &eee); + ret =3D __ethtool_set_eee(dev, &eee); return ret < 0 ? ret : 1; } =20 --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A63CC6FD1D for ; Mon, 27 Mar 2023 14:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233075AbjC0OYS (ORCPT ); Mon, 27 Mar 2023 10:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C41B76BA for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hp-Kw; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IZ-Ss; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjK-T0; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs Date: Mon, 27 Mar 2023 16:21:59 +0200 Message-Id: <20230327142202.3754446-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 + if (phydev->drv->phy_id =3D=3D ATH8035_PHY_ID || + phydev->drv->phy_id =3D=3D ATH8031_PHY_ID) { + if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) + phydev->is_smart_eee_phy =3D true; + } + if (priv->vddio) { ret =3D regulator_enable(priv->vddio); if (ret < 0) --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DD3CC76195 for ; Mon, 27 Mar 2023 14:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233088AbjC0OYV (ORCPT ); Mon, 27 Mar 2023 10:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232919AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 649DE422F for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hk-Kt; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IN-Cv; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjT-Th; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Date: Mon, 27 Mar 2023 16:22:00 +0200 Message-Id: <20230327142202.3754446-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 @@ =20 #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 =20 #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) =20 if (phydev->drv->phy_id =3D=3D ATH8035_PHY_ID || phydev->drv->phy_id =3D=3D ATH8031_PHY_ID) { - if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) + if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) { phydev->is_smart_eee_phy =3D true; + priv->tx_lpi_on =3D true; + priv->tx_lpi_timer =3D + AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US; + } } =20 if (priv->vddio) { @@ -959,10 +975,12 @@ static int at803x_get_features(struct phy_device *phy= dev) static int at803x_smarteee_config(struct phy_device *phydev) { struct at803x_priv *priv =3D phydev->priv; + u64 tx_lpi_timer_raw; + u64 tx_lpi_timer_ns; u16 mask =3D 0, val =3D 0; int ret; =20 - 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; =20 + tx_lpi_timer_ns =3D priv->tx_lpi_timer * NSEC_PER_USEC; + tx_lpi_timer_raw =3D + DIV_ROUND_CLOSEST_ULL(tx_lpi_timer_ns, + AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS); + val =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + tx_lpi_timer_raw)); + + ret =3D phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL2, + val); + if (ret) + return ret; + + val =3D 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); } =20 static int at803x_clk_out_config(struct phy_device *phydev) @@ -1072,10 +1108,6 @@ static int at803x_config_init(struct phy_device *phy= dev) if (ret < 0) return ret; =20 - ret =3D at803x_smarteee_config(phydev); - if (ret < 0) - return ret; - ret =3D at803x_clk_out_config(phydev); if (ret < 0) return ret; @@ -1359,6 +1391,16 @@ static int at803x_config_aneg(struct phy_device *phy= dev) return ret; } =20 + /* only after PHY is attached we will be able to see if MAC supports + * EEE + */ + if (phydev->mac_supports_eee) + priv->tx_lpi_on =3D false; + + ret =3D at803x_smarteee_config(phydev); + if (ret < 0) + return ret; + return __genphy_config_aneg(phydev, ret); } =20 @@ -1617,6 +1659,72 @@ static int at803x_cable_test_start(struct phy_device= *phydev) return 0; } =20 +static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *d= ata) +{ + struct at803x_priv *priv =3D 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 =3D phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL2); + tx_timer_raw =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + ret)); + if (ret < 0) + return ret; + + ret =3D phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3); + if (ret < 0) + return ret; + + tx_timer_raw |=3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + ret)); + tx_timer_ns =3D tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; + data->tx_lpi_timer =3D DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); + + data->tx_lpi_enabled =3D !!(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 *d= ata) +{ + struct at803x_priv *priv =3D 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 =3D data->tx_lpi_timer; + priv->tx_lpi_on =3D data->tx_lpi_enabled; + ret =3D 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[] =3D { .set_tunable =3D at803x_set_tunable, .cable_test_start =3D at803x_cable_test_start, .cable_test_get_status =3D at803x_cable_test_get_status, + .get_eee =3D at803x_get_eee, + .set_eee =3D at803x_set_eee, }, { /* Qualcomm Atheros AR8030 */ .phy_id =3D ATH8030_PHY_ID, --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E5FCC77B61 for ; Mon, 27 Mar 2023 14:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233098AbjC0OYY (ORCPT ); Mon, 27 Mar 2023 10:24:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E01A7D94 for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Ho-L2; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IX-RR; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkjc-UV; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations Date: Mon, 27 Mar 2023 16:22:01 +0200 Message-Id: <20230327142202.3754446-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 - val =3D 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 =3D FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + tx_lpi_timer_raw)); + + if (phydev->state =3D=3D PHY_RUNNING && + phy_check_valid(phydev->speed, phydev->duplex, + phydev->supported_eee)) { + val |=3D AT803X_MMD3_SMARTEEE_CTL3_LPI_EN; + } =20 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 =3D tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; data->tx_lpi_timer =3D DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); =20 - data->tx_lpi_enabled =3D !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + data->tx_lpi_enabled =3D priv->tx_lpi_on; =20 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); } =20 +static void at8035_link_change_notify(struct phy_device *phydev) +{ + struct at803x_priv *priv =3D phydev->priv; + + if (phydev->mac_supports_eee || !phydev->is_smart_eee_phy) + return; + + if (phydev->state =3D=3D 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[] =3D { .cable_test_get_status =3D at803x_cable_test_get_status, .get_eee =3D at803x_get_eee, .set_eee =3D at803x_set_eee, + .link_change_notify =3D at8035_link_change_notify, }, { /* Qualcomm Atheros AR8030 */ .phy_id =3D ATH8030_PHY_ID, --=20 2.30.2 From nobody Mon Feb 9 04:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B88BC76195 for ; Mon, 27 Mar 2023 14:24:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232970AbjC0OYI (ORCPT ); Mon, 27 Mar 2023 10:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjC0OXr (ORCPT ); Mon, 27 Mar 2023 10:23:47 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875D47D84 for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hq-Kw; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjZ-0076If-Bh; Mon, 27 Mar 2023 16:22:05 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkjl-VA; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Date: Mon, 27 Mar 2023 16:22:02 +0200 Message-Id: <20230327142202.3754446-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Wei Fang --- 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/ethern= et/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 =3D 0; fep->full_duplex =3D 0; =20 + if (fep->quirks & FEC_QUIRK_HAS_EEE) + phy_dev->mac_supports_eee =3D true; phy_dev->mac_managed_pm =3D true; =20 phy_attached_info(phy_dev); --=20 2.30.2