Skip to content

Commit

Permalink
net: bcmgenet: Add support for PHY-based Wake-on-LAN
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed May 13, 2023
1 parent 8baddaa commit 7e400ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
struct bcmgenet_priv *priv = netdev_priv(dev);
struct device *kdev = &priv->pdev->dev;

if (dev->phydev) {
phy_ethtool_get_wol(dev->phydev, wol);
if (wol->supported)
return;
}

if (!device_can_wakeup(kdev)) {
wol->supported = 0;
wol->wolopts = 0;
Expand All @@ -63,6 +69,14 @@ int bcmgenet_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
struct device *kdev = &priv->pdev->dev;
int ret;

/* Try Wake-on-LAN from the PHY first */
if (dev->phydev) {
ret = phy_ethtool_set_wol(dev->phydev, wol);
if (ret != -EOPNOTSUPP)
return ret;
}

if (!device_can_wakeup(kdev))
return -ENOTSUPP;
Expand Down

0 comments on commit 7e400ff

Please sign in to comment.