Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phylink: add phylink managed wake-on-lan PHY speed control

Some drivers, e.g. stmmac, use the speed_up()/speed_down() APIs to
gain additional power saving during Wake-on-LAN where the PHY is
managing the state.

Add support to phylink for this, which can be enabled by the MAC
driver. Only change the PHY speed if the PHY is configured for
wake-up, but without any wake-up on the MAC side, as MAC side
means changing the configuration once the negotiation has
completed.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vBrR7-0000000BLza-2PjK@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
dc1a2a9c b79fbd86

+14
+12
drivers/net/phy/phylink.c
··· 2576 2576 return phydev && (pl->config->wol_phy_legacy || phy_can_wakeup(phydev)); 2577 2577 } 2578 2578 2579 + static bool phylink_phy_pm_speed_ctrl(struct phylink *pl) 2580 + { 2581 + return pl->config->wol_phy_speed_ctrl && !pl->wolopts_mac && 2582 + pl->phydev && phy_may_wakeup(pl->phydev); 2583 + } 2584 + 2579 2585 /** 2580 2586 * phylink_suspend() - handle a network device suspend event 2581 2587 * @pl: a pointer to a &struct phylink returned from phylink_create() ··· 2631 2625 } else { 2632 2626 phylink_stop(pl); 2633 2627 } 2628 + 2629 + if (phylink_phy_pm_speed_ctrl(pl)) 2630 + phylink_speed_down(pl, false); 2634 2631 } 2635 2632 EXPORT_SYMBOL_GPL(phylink_suspend); 2636 2633 ··· 2672 2663 void phylink_resume(struct phylink *pl) 2673 2664 { 2674 2665 ASSERT_RTNL(); 2666 + 2667 + if (phylink_phy_pm_speed_ctrl(pl)) 2668 + phylink_speed_up(pl); 2675 2669 2676 2670 if (test_bit(PHYLINK_DISABLE_MAC_WOL, &pl->phylink_disable_state)) { 2677 2671 /* Wake-on-Lan enabled, MAC handling */
+2
include/linux/phylink.h
··· 157 157 * @lpi_timer_default: Default EEE LPI timer setting. 158 158 * @eee_enabled_default: If set, EEE will be enabled by phylink at creation time 159 159 * @wol_phy_legacy: Use Wake-on-Lan with PHY even if phy_can_wakeup() is false 160 + * @wol_phy_speed_ctrl: Use phy speed control on suspend/resume 160 161 * @wol_mac_support: Bitmask of MAC supported %WAKE_* options 161 162 */ 162 163 struct phylink_config { ··· 179 178 180 179 /* Wake-on-Lan support */ 181 180 bool wol_phy_legacy; 181 + bool wol_phy_speed_ctrl; 182 182 u32 wol_mac_support; 183 183 }; 184 184