From 6b5ab531a2a2a13bef6a54a0e2a78ffe4008bdb4 Mon Sep 17 00:00:00 2001 From: Raju Lakkaraju Date: Tue, 23 Apr 2024 15:47:28 +0530 Subject: [PATCH] Wake-ON-LAN PHY reconfiguration --- drivers/net/phy/mxl-gpy.c | 4 ++++ drivers/net/phy/phy_device.c | 5 +++++ include/linux/phy.h | 1 + 3 files changed, 10 insertions(+) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index b2d36a3a96f1..9b97facc9b03 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -680,6 +680,7 @@ static int gpy_set_wol(struct phy_device *phydev, struct net_device *attach_dev = phydev->attached_dev; int ret; + phydev->wolopts = 0; if (wol->wolopts & WAKE_MAGIC) { /* MAC address - Byte0:Byte1:Byte2:Byte3:Byte4:Byte5 * VPSPEC2_WOL_AD45 = Byte0:Byte1 @@ -748,9 +749,12 @@ static int gpy_set_wol(struct phy_device *phydev, if (ret & (PHY_IMASK_MASK & ~PHY_IMASK_LSTC)) phy_trigger_machine(phydev); + phydev->wolopts = wol->wolopts; return 0; } + phydev->wolopts = wol->wolopts; + /* Disable the link state change interrupt */ return phy_clear_bits(phydev, PHY_IMASK, PHY_IMASK_LSTC); } diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 616bd7ba46cb..9740f08ad98e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2038,6 +2038,11 @@ int phy_suspend(struct phy_device *phydev) if (phydev->suspended) return 0; + if (phydev->wolopts) { + wol.wolopts = phydev->wolopts; + phy_ethtool_set_wol(phydev, &wol); + } + phy_ethtool_get_wol(phydev, &wol); phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); /* If the device has WOL enabled, we cannot suspend the PHY */ diff --git a/include/linux/phy.h b/include/linux/phy.h index 3ddfe7fe781a..c88ffa7ac89b 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -766,6 +766,7 @@ struct phy_device { u8 mdix; u8 mdix_ctrl; + u32 wolopts; int pma_extable; -- 2.34.1