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

net: mvneta: speed down the PHY, if WoL used, to save energy

Some PHYs connected to this ethernet hardware support the WoL feature.
But when WoL is enabled and the machine is powered off, the PHY remains
waiting for a magic packet at max speed (i.e. 1Gbps), which is a waste of
energy.

Slow down the PHY speed before stopping the ethernet if WoL is enabled,
and save some energy while the machine is powered off or sleeping.

Tested using an Armada 370 based board (LS421DE) equipped with a Marvell
88E1518 PHY.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel González Cabanelas and committed by
David S. Miller
61b5cc20 b0f46a97

+11
+11
drivers/net/ethernet/marvell/mvneta.c
··· 3611 3611 MVNETA_CAUSE_LINK_CHANGE); 3612 3612 3613 3613 phylink_start(pp->phylink); 3614 + 3615 + /* We may have called phy_speed_down before */ 3616 + phylink_speed_up(pp->phylink); 3617 + 3614 3618 netif_tx_start_all_queues(pp->dev); 3615 3619 3616 3620 clear_bit(__MVNETA_DOWN, &pp->state); ··· 3625 3621 unsigned int cpu; 3626 3622 3627 3623 set_bit(__MVNETA_DOWN, &pp->state); 3624 + 3625 + if (device_may_wakeup(&pp->dev->dev)) 3626 + phylink_speed_down(pp->phylink, false); 3628 3627 3629 3628 phylink_stop(pp->phylink); 3630 3629 ··· 4096 4089 4097 4090 phylink_ethtool_get_wol(pp->phylink, &wol); 4098 4091 device_set_wakeup_capable(&pp->dev->dev, !!wol.supported); 4092 + 4093 + /* PHY WoL may be enabled but device wakeup disabled */ 4094 + if (wol.supported) 4095 + device_set_wakeup_enable(&pp->dev->dev, !!wol.wolopts); 4099 4096 4100 4097 return err; 4101 4098 }