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

Configure Feed

Select the types of activity you want to include in your feed.

net: bcmasp: Add support for PHY-based Wake-on-LAN

If available, interrogate the PHY to find out whether we can use it for
Wake-on-LAN. This can be a more power efficient way of implementing that
feature, especially when the MAC is powered off in low power states.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251013172306.2250223-1-florian.fainelli@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Florian Fainelli and committed by
Jakub Kicinski
e1f5bb19 e5b670e5

+32 -2
+32 -2
drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c
··· 163 163 static void bcmasp_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 164 164 { 165 165 struct bcmasp_intf *intf = netdev_priv(dev); 166 + struct bcmasp_priv *priv = intf->parent; 167 + struct device *kdev = &priv->pdev->dev; 168 + u32 phy_wolopts = 0; 166 169 167 - wol->supported = BCMASP_SUPPORTED_WAKE; 168 - wol->wolopts = intf->wolopts; 170 + if (dev->phydev) { 171 + phy_ethtool_get_wol(dev->phydev, wol); 172 + phy_wolopts = wol->wolopts; 173 + } 174 + 175 + /* MAC is not wake-up capable, return what the PHY does */ 176 + if (!device_can_wakeup(kdev)) 177 + return; 178 + 179 + /* Overlay MAC capabilities with that of the PHY queried before */ 180 + wol->supported |= BCMASP_SUPPORTED_WAKE; 181 + wol->wolopts |= intf->wolopts; 182 + 183 + /* Return the PHY configured magic password */ 184 + if (phy_wolopts & WAKE_MAGICSECURE) 185 + return; 186 + 169 187 memset(wol->sopass, 0, sizeof(wol->sopass)); 170 188 189 + /* Otherwise the MAC one */ 171 190 if (wol->wolopts & WAKE_MAGICSECURE) 172 191 memcpy(wol->sopass, intf->sopass, sizeof(intf->sopass)); 173 192 } ··· 196 177 struct bcmasp_intf *intf = netdev_priv(dev); 197 178 struct bcmasp_priv *priv = intf->parent; 198 179 struct device *kdev = &priv->pdev->dev; 180 + int ret = 0; 181 + 182 + /* Try Wake-on-LAN from the PHY first */ 183 + if (dev->phydev) { 184 + ret = phy_ethtool_set_wol(dev->phydev, wol); 185 + if (ret != -EOPNOTSUPP && wol->wolopts) 186 + return ret; 187 + } 199 188 200 189 if (!device_can_wakeup(kdev)) 201 190 return -EOPNOTSUPP; 191 + 192 + if (wol->wolopts & ~BCMASP_SUPPORTED_WAKE) 193 + return -EINVAL; 202 194 203 195 /* Interface Specific */ 204 196 intf->wolopts = wol->wolopts;