From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>, 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>,
Marcin Wojtas <marcin.s.wojtas@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
UNGLinuxDriver@microchip.com
Subject: Re: [PATCH net-next 05/10] net: phylink: add EEE management
Date: Thu, 2 Jan 2025 16:39:26 +0000 [thread overview]
Message-ID: <Z3bBPtKpTqARV8gR@shell.armlinux.org.uk> (raw)
In-Reply-To: <928c2613-b028-4073-818c-5cf38bd304ca@gmail.com>
On Sun, Dec 15, 2024 at 12:38:24AM +0100, Heiner Kallweit wrote:
> On 09.12.2024 15:23, 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 EEE configuration should the PHY go
> > away.
> >
> > It will also call into the MAC driver when LPI needs to be enabled or
> > disabled, with the expectation that the MAC have LPI disabled during
> > probe.
> >
> > Support for phylink managed EEE is enabled by populating both tx_lpi
> > MAC operations method pointers.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> > drivers/net/phy/phylink.c | 123 ++++++++++++++++++++++++++++++++++++--
> > include/linux/phylink.h | 44 ++++++++++++++
> > 2 files changed, 163 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> > index 03509fdaa1ec..750356b6a2e9 100644
> > --- a/drivers/net/phy/phylink.c
> > +++ b/drivers/net/phy/phylink.c
> > @@ -81,12 +81,19 @@ struct phylink {
> > unsigned int pcs_state;
> >
> > bool link_failed;
> > + bool mac_supports_eee;
> > + bool phy_enable_tx_lpi;
> > + bool mac_enable_tx_lpi;
> > + bool mac_tx_clk_stop;
> > + u32 mac_tx_lpi_timer;
> >
> > struct sfp_bus *sfp_bus;
> > bool sfp_may_have_phy;
> > DECLARE_PHY_INTERFACE_MASK(sfp_interfaces);
> > __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support);
> > u8 sfp_port;
> > +
> > + struct eee_config eee_cfg;
> > };
> >
> > #define phylink_printk(level, pl, fmt, ...) \
> > @@ -1563,6 +1570,47 @@ static const char *phylink_pause_to_str(int pause)
> > }
> > }
> >
> > +static void phylink_deactivate_lpi(struct phylink *pl)
> > +{
> > + if (pl->mac_enable_tx_lpi) {
> > + pl->mac_enable_tx_lpi = false;
> > +
> > + phylink_dbg(pl, "disabling LPI\n");
> > +
> > + pl->mac_ops->mac_disable_tx_lpi(pl->config);
> > + }
> > +}
> > +
> > +static void phylink_activate_lpi(struct phylink *pl)
> > +{
> > + if (!test_bit(pl->cur_interface, pl->config->lpi_interfaces)) {
> > + phylink_dbg(pl, "MAC does not support LPI with %s\n",
> > + phy_modes(pl->cur_interface));
> > + return;
> > + }
> > +
> > + phylink_dbg(pl, "LPI timer %uus, tx clock stop %u\n",
> > + pl->mac_tx_lpi_timer, pl->mac_tx_clk_stop);
> > +
> > + pl->mac_ops->mac_enable_tx_lpi(pl->config, pl->mac_tx_lpi_timer,
> > + pl->mac_tx_clk_stop);
> > +
> > + pl->mac_enable_tx_lpi = true;
> > +}
> > +
> > +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);
> > +}
> > +
>
> Something similar we may need in phylib too. An example is cpsw MAC driver which
> doesn't support EEE. Issues have been reported if the PHY's on both sides negotiate
> EEE, workaround is to use property eee-broken-xxx in the respective DT's to disable
> PHY EEE advertisement. I'm thinking of adding a simple phy_disable_eee() which can
> be called by MAC drivers to clear EEE supported and advertising bitmaps.
>
> A similar case is enetc (using phylink) which doesn't support EEE. See following in
> enetc.c:
>
> /* disable EEE autoneg, until ENETC driver supports it */
> memset(&edata, 0, sizeof(struct ethtool_keee));
> phylink_ethtool_set_eee(priv->phylink, &edata);
>
> Russell, do you plan to change this driver too, based on phylink extensions?
> I think already now, based on the quoted code piece, several (all?) eee-broken-xxx
> properties can be removed under arch/arm64/boot/dts/freescale .
At the moment, phylink-managed EEE is opt-in, so what you get without
this patch is what you get with the patch but no driver changes. This
allows existing drivers that support EEE and that use phylink to
continue to support EEE, and those that don't to continue in their
current situation (if they use work-arounds to disable EEE, then
those will continue to work.)
Rather than adding something explicit to phylink to disable EEE, I
would much rather we work towards a situation where, if a driver
uses phylink, then if EEE is supported, the EEE methods and other
configuration get populated. If not, then phylink disables EEE on
the PHY.
However, we can only get there once we have EEE implemented on all
the phylink-using drivers that currently support 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-02 16:39 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 14:22 [PATCH net-next 00/10] net: add phylink managed EEE support Russell King (Oracle)
2024-12-09 14:23 ` [PATCH net-next 01/10] net: mdio: add definition for clock stop capable bit Russell King (Oracle)
2024-12-10 2:21 ` Andrew Lunn
2024-12-09 14:23 ` [PATCH net-next 02/10] net: phy: add support for querying PHY clock stop capability Russell King (Oracle)
2024-12-10 3:00 ` Andrew Lunn
2024-12-09 14:23 ` [PATCH net-next 03/10] net: phy: add configuration of rx clock stop mode Russell King (Oracle)
2024-12-10 3:03 ` Andrew Lunn
2024-12-10 3:11 ` Andrew Lunn
2024-12-10 9:51 ` Russell King (Oracle)
2024-12-10 23:15 ` Andrew Lunn
2024-12-09 14:23 ` [PATCH net-next 04/10] net: phylink: add phylink_link_is_up() helper Russell King (Oracle)
2024-12-10 3:03 ` Andrew Lunn
2024-12-09 14:23 ` [PATCH net-next 05/10] net: phylink: add EEE management Russell King (Oracle)
2024-12-10 3:18 ` Andrew Lunn
2024-12-13 9:37 ` Simon Horman
2024-12-14 23:38 ` Heiner Kallweit
2025-01-02 16:39 ` Russell King (Oracle) [this message]
2024-12-09 14:23 ` [PATCH net-next 06/10] net: phylink: allow MAC driver to validate eee params Russell King (Oracle)
2024-12-10 3:21 ` Andrew Lunn
2024-12-10 9:58 ` Russell King (Oracle)
2024-12-10 13:58 ` Russell King (Oracle)
2024-12-09 14:23 ` [PATCH net-next 07/10] net: mvneta: convert to phylink EEE implementation Russell King (Oracle)
2024-12-10 3:25 ` Andrew Lunn
2024-12-13 10:04 ` Simon Horman
2024-12-13 10:22 ` Simon Horman
2024-12-13 10:51 ` Russell King (Oracle)
2024-12-09 14:23 ` [PATCH net-next 08/10] net: mvpp2: add " Russell King (Oracle)
2024-12-10 3:27 ` Andrew Lunn
2024-12-09 14:23 ` [PATCH net-next 09/10] net: lan743x: use netdev in lan743x_phylink_mac_link_down() Russell King (Oracle)
2024-12-10 3:28 ` Andrew Lunn
2024-12-09 14:24 ` [PATCH net-next 10/10] net: lan743x: convert to phylink managed EEE Russell King (Oracle)
2024-12-10 3:37 ` Andrew Lunn
2024-12-10 10:07 ` Russell King (Oracle)
2024-12-10 14:57 ` kernel test robot
2024-12-12 1:31 ` kernel test robot
2024-12-09 18:35 ` [PATCH net-next 00/10] net: add phylink managed EEE support Christian Marangi
2024-12-09 18:59 ` Russell King (Oracle)
2024-12-11 12:07 ` Russell King (Oracle)
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=Z3bBPtKpTqARV8gR@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=UNGLinuxDriver@microchip.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=kuba@kernel.org \
--cc=marcin.s.wojtas@gmail.com \
--cc=netdev@vger.kernel.org \
--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).