Commit 7e400ff3 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller
Browse files

net: bcmgenet: 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.

Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8baddaa9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;