Skip to content

Commit 46ded70

Browse files
ffainellikuba-moo
authored andcommitted
net: bcmgenet: Correct overlaying of PHY and MAC Wake-on-LAN
Some Wake-on-LAN modes such as WAKE_FILTER may only be supported by the MAC, while others might be only supported by the PHY. Make sure that the .get_wol() returns the union of both rather than only that of the PHY if the PHY supports Wake-on-LAN. When disabling Wake-on-LAN, make sure that this is done at both the PHY and MAC level, rather than doing an early return from the PHY driver. Fixes: 7e400ff ("net: bcmgenet: Add support for PHY-based Wake-on-LAN") Fixes: 9ee09ed ("net: bcmgenet: Properly overlay PHY and MAC Wake-on-LAN capabilities") Signed-off-by: Florian Fainelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c2933b2 commit 46ded70

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,27 @@ void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4141
{
4242
struct bcmgenet_priv *priv = netdev_priv(dev);
4343
struct device *kdev = &priv->pdev->dev;
44+
u32 phy_wolopts = 0;
4445

45-
if (dev->phydev)
46+
if (dev->phydev) {
4647
phy_ethtool_get_wol(dev->phydev, wol);
48+
phy_wolopts = wol->wolopts;
49+
}
4750

4851
/* MAC is not wake-up capable, return what the PHY does */
4952
if (!device_can_wakeup(kdev))
5053
return;
5154

5255
/* Overlay MAC capabilities with that of the PHY queried before */
5356
wol->supported |= WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER;
54-
wol->wolopts = priv->wolopts;
55-
memset(wol->sopass, 0, sizeof(wol->sopass));
57+
wol->wolopts |= priv->wolopts;
5658

59+
/* Return the PHY configured magic password */
60+
if (phy_wolopts & WAKE_MAGICSECURE)
61+
return;
62+
63+
/* Otherwise the MAC one */
64+
memset(wol->sopass, 0, sizeof(wol->sopass));
5765
if (wol->wolopts & WAKE_MAGICSECURE)
5866
memcpy(wol->sopass, priv->sopass, sizeof(priv->sopass));
5967
}
@@ -70,7 +78,7 @@ int bcmgenet_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
7078
/* Try Wake-on-LAN from the PHY first */
7179
if (dev->phydev) {
7280
ret = phy_ethtool_set_wol(dev->phydev, wol);
73-
if (ret != -EOPNOTSUPP)
81+
if (ret != -EOPNOTSUPP && wol->wolopts)
7482
return ret;
7583
}
7684

0 commit comments

Comments
 (0)