[PATCH RFC net-next 3/6] net: phylink: add phylink managed MAC Wake-on-Lan support
Russell King (Oracle)
linux at armlinux.org.uk
Sun Sep 28 02:32:20 PDT 2025
On Sun, Sep 28, 2025 at 09:59:04AM +0100, Russell King (Oracle) wrote:
> Add core phylink Wake-on-Lan support.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel at armlinux.org.uk>
> ---
> drivers/net/phy/phylink.c | 77 +++++++++++++++++++++++++++++++++++++--
> include/linux/phylink.h | 26 +++++++++++++
> 2 files changed, 99 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 9d7799ea1c17..9a3783e719bc 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -93,6 +93,9 @@ struct phylink {
> u8 sfp_port;
>
> struct eee_config eee_cfg;
> +
> + u32 wolopts_mac;
> + u8 wol_sopass[SOPASS_MAX];
> };
>
> #define phylink_printk(level, pl, fmt, ...) \
> @@ -2575,11 +2578,17 @@ EXPORT_SYMBOL_GPL(phylink_rx_clk_stop_unblock);
> * can also bring down the link between the MAC and PHY.
> * - If Wake-on-Lan is active, but being handled by the MAC, the MAC
> * still needs to receive packets, so we can not bring the link down.
> + *
> + * Note: when phylink managed Wake-on-Lan is in use, @mac_wol is ignored.
> + * (struct phylink_mac_ops.mac_set_wol populated.)
> */
> void phylink_suspend(struct phylink *pl, bool mac_wol)
> {
> ASSERT_RTNL();
>
> + if (phylink_mac_supports_wol(pl))
> + mac_wol = !!pl->wolopts_mac;
> +
> if (mac_wol && (!pl->netdev || pl->netdev->ethtool->wol_enabled)) {
> /* Wake-on-Lan enabled, MAC handling */
> mutex_lock(&pl->state_mutex);
> @@ -2673,6 +2682,17 @@ void phylink_resume(struct phylink *pl)
> }
> EXPORT_SYMBOL_GPL(phylink_resume);
>
> +static bool phylink_mac_supports_wol(struct phylink *pl)
> +{
> + return !!pl->mac_ops->mac_wol_set;
> +}
> +
> +static bool phylink_phy_supports_wol(struct phylink *pl,
> + struct phy_device *phydev)
> +{
> + return phydev && (pl->config->wol_phy_legacy || phy_can_wakeup(phydev));
> +}
> +
Yes, these need to be earlier.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
More information about the linux-arm-kernel
mailing list