net: phy: improve generic EEE ethtool functions
authorHeiner Kallweit <hkallweit1@gmail.com>
Tue, 27 Nov 2018 21:30:14 +0000 (22:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Dec 2018 23:13:25 +0000 (15:13 -0800)
commitd1420bb9951592c6de4148de7441bfa93ce4eed5
treea96567a03060800fe8a5dca87abe1c5ff0e42a46
parent79dfab43a976b76713c40222987c48e32510ebc1
net: phy: improve generic EEE ethtool functions

So far the two functions consider neither member eee_enabled nor
eee_active. Therefore network drivers have to do this in some kind
of glue code. I think this can be avoided.

Getting EEE parameters:
When not advertising any EEE mode, we can't consider EEE to be enabled.
Therefore interpret "EEE enabled" as "we advertise at least one EEE
mode". It's similar with "EEE active": interpret it as "EEE modes
advertised by both link partner have at least one mode in common".

Setting EEE parameters:
If eee_enabled isn't set, don't advertise any EEE mode and restart
aneg if needed to switch off EEE. If eee_enabled is set and
data->advertised is empty (e.g. because EEE was disabled), advertise
everything we support as default. This way EEE can easily switched
on/off by doing ethtool --set-eee <if> eee on/off, w/o any additional
parameters.

The changes to both functions shouldn't break any existing user.
Once the changes have been applied, at least some users can be
simplified.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c