From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Bryan Whitehead <bryan.whitehead@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Marcin Wojtas <marcin.s.wojtas@gmail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
UNGLinuxDriver@microchip.com, Vladimir Oltean <olteanv@gmail.com>
Subject: Re: [PATCH RFC net-next 04/10] net: phylink: add EEE management
Date: Wed, 15 Jan 2025 15:55:21 +0000 [thread overview]
Message-ID: <Z4faaYXMD13tSlT5@shell.armlinux.org.uk> (raw)
In-Reply-To: <E1tXhUp-000n0Y-BA@rmk-PC.armlinux.org.uk>
On Tue, Jan 14, 2025 at 02:02:19PM +0000, Russell King (Oracle) wrote:
> Add EEE management to phylink, making use of the phylib implementation.
> This will only be used where a MAC driver populates the methods and
> capabilities bitfield, otherwise we keep our old behaviour.
>
> Phylink will keep track of the EEE configuration, including the clock
> stop abilities at each end of the MAC to PHY link, programming the PHY
> appropriately and preserving the LPI configuration should the PHY go
> away.
>
> Phylink will call into the MAC driver when LPI needs to be enabled or
> disabled, with the requirement that the MAC have LPI disabled prior
> to the netdev being brought up (in other words, it will only call
> mac_disable_tx_lpi() if it has already called mac_enable_tx_lpi().)
>
> Support for phylink managed EEE is enabled by populating both tx_lpi
> MAC operations method pointers, and filling in both LPI interfaces
> and capabilities. If the methods are provided but the LPI interfaces
> or capabilities remain empty, this indicates to phylink that EEE is
> implemented by the driver but the hardware it is driving does not
> support EEE, and thus the ethtool set_eee() and get_eee() methods will
> return EOPNOTSUPP.
>
> No validation of the LPI timer value is performed by this patch.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> drivers/net/phy/phylink.c | 133 ++++++++++++++++++++++++++++++++++++--
> include/linux/phylink.h | 45 +++++++++++++
> 2 files changed, 174 insertions(+), 4 deletions(-)
In discussion with Herner, it came to my attention that the way I'm
restricting EEE modes in this patch is actually buggy. I've been
intending to update this patch once Herner's patch set has been merged,
but this morning, Jakub asked for changes to it.
So, rather than waiting for that, I'm intending to use a different
solution - rather than waiting for Herner's patch set and adapting mine
to it. So, the patch below will change the way EEE modes are restricted
in such a way that this is independent of Herner's series. We
basically apply our own restriction to the supported modes after
calling phylib's get_eee() method, and restrict the advertised modes
before attaching the PHY and before calling phylib's set_eee() method.
Once Herner's patch set is merged, maybe I can manipulate the
eee disabled modes mask instead, and leave this to phylib to deal
with.
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index c430ac2e5e9f..b561a8228612 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -60,6 +60,7 @@ struct phylink {
u8 act_link_an_mode; /* Active MLO_AN_xxx mode */
u8 link_port; /* The current non-phy ethtool port */
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(supported_lpi);
/* The link configuration settings */
struct phylink_link_state link_config;
@@ -1623,19 +1624,6 @@ static void phylink_activate_lpi(struct phylink *pl)
pl->mac_ops->mac_enable_tx_lpi, ERR_PTR(err));
}
-static void phylink_phy_restrict_eee(struct phylink *pl, struct phy_device *phy)
-{
- __ETHTOOL_DECLARE_LINK_MODE_MASK(eee_supported);
-
- /* Convert the MAC's LPI capabilities to linkmodes */
- linkmode_zero(eee_supported);
- phylink_caps_to_linkmodes(eee_supported, pl->config->lpi_capabilities);
-
- /* Mask out EEE modes that are not supported */
- linkmode_and(phy->supported_eee, phy->supported_eee, eee_supported);
- linkmode_and(phy->advertising_eee, phy->advertising_eee, eee_supported);
-}
-
static void phylink_link_up(struct phylink *pl,
struct phylink_link_state link_state)
{
@@ -2242,10 +2230,16 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
phy->eee_cfg.tx_lpi_enabled = pl->eee_cfg.tx_lpi_enabled;
phy->eee_cfg.tx_lpi_timer = pl->eee_cfg.tx_lpi_timer;
+ /* Convert the MAC's LPI capabilities to linkmodes */
+ linkmode_zero(pl->supported_lpi);
+ phylink_caps_to_linkmodes(pl->supported_lpi,
+ pl->config->lpi_capabilities);
+
/* Restrict the PHYs EEE support/advertisement to the modes
* that the MAC supports.
*/
- phylink_phy_restrict_eee(pl, phy);
+ linkmode_and(phy->advertising_eee, phy->advertising_eee,
+ pl->supported_lpi);
} else if (pl->mac_supports_eee_ops) {
/* MAC supports phylink EEE, but wants EEE always disabled. */
phy_disable_eee(phy);
@@ -3188,8 +3182,13 @@ int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_keee *eee)
if (pl->mac_supports_eee_ops && !pl->mac_supports_eee)
return ret;
- if (pl->phydev)
+ if (pl->phydev) {
ret = phy_ethtool_get_eee(pl->phydev, eee);
+ /* Restrict supported linkmode mask */
+ if (ret == 0 && pl->mac_supports_eee_ops)
+ linkmode_and(eee->supported, eee->supported,
+ pl->supported_lpi);
+ }
return ret;
}
@@ -3232,6 +3231,10 @@ int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_keee *eee)
ret = -EOPNOTSUPP;
if (pl->phydev) {
+ /* Restrict advertisement mask */
+ if (pl->mac_supports_eee_ops)
+ linkmode_and(eee->advertised, eee->advertised,
+ pl->supported_lpi);
ret = phy_ethtool_set_eee(pl->phydev, eee);
if (ret == 0)
eee_to_eeecfg(&pl->eee_cfg, eee);
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-01-15 15:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 13:58 [PATCH RFC net-next 00/10] net: add phylink managed EEE support Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 01/10] net: mdio: add definition for clock stop capable bit Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 02/10] net: phy: add support for querying PHY clock stop capability Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 03/10] net: phylink: add phylink_link_is_up() helper Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 04/10] net: phylink: add EEE management Russell King (Oracle)
2025-01-15 15:55 ` Russell King (Oracle) [this message]
2025-01-14 14:02 ` [PATCH RFC net-next 05/10] net: mvneta: convert to phylink EEE implementation Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 06/10] net: mvpp2: add " Russell King (Oracle)
2025-01-15 14:53 ` Maxime Chevallier
2025-01-15 15:46 ` Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 07/10] net: lan743x: use netdev in lan743x_phylink_mac_link_down() Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 08/10] net: lan743x: convert to phylink managed EEE Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 09/10] net: stmmac: convert to phylink managed EEE support Russell King (Oracle)
2025-01-14 14:02 ` [PATCH RFC net-next 10/10] net: dsa: allow use of " Russell King (Oracle)
2025-01-14 19:26 ` Vladimir Oltean
2025-01-14 20:02 ` Russell King (Oracle)
2025-01-14 20:28 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z4faaYXMD13tSlT5@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=marcin.s.wojtas@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).