net: phy: convert further flags in struct phy_device to bit-field
Subsystems (3)
Heiner Kallweit
maintainerPATCH 1/1 net: phy: convert further flags in struct phy_device to bit-field
This patch is a follow-up to 87e5808d52b6 ("net: phy: replace bool members in struct phy_device with bit-fields") and converts further flags to bit-fields.
--- include/linux/phy.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
include/linux/phy.h +8 -9
@@ -418,21 +418,20 @@ struct phy_device {/* The most recently read link state */ unsigned link:1; +/* forced speed & duplex (no autoneg) +* partner speed & duplex & pause (autoneg) +*/ + unsigned pause:1; + unsigned asym_pause:1; +int speed; +int duplex; +enum phy_state state;u32 dev_flags;phy_interface_t interface; -/* -* forced speed & duplex (no autoneg) -* partner speed & duplex & pause (autoneg) -*/ -int speed; -int duplex; -int pause; -int asym_pause; -/* Enabled Interrupts */ u32 interrupts;
Signature · 1 line
2.17.0
Quoted 3 lines · Heiner Kallweit
This patch is a follow-up to
87e5808d52b6("net: phy: replace bool members in structphy_devicewith bit-fields") and converts further flags to bit-fields.
This looks fine, but then you would also have to clean-up all code that does phydev->asym_pause = 1 and phydev->pause = 1 to use true/false instead, I am not sure there is much value in doing that for these fields considering that they are exposed to drivers so there is a risk of possible breakage.
Thanks!
Quoted 41 lines
Signed-off-by Heiner Kallweit <[email protected]>--- include/linux/phy.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)include/linux/phy.h +8
-9@@ -418,21 +418,20 @@ struct phy_device {/* The most recently read link state */ unsigned link:1; +/* forced speed & duplex (no autoneg) +* partner speed & duplex & pause (autoneg) +*/ + unsigned pause:1; + unsigned asym_pause:1; +int speed; +int duplex; +enum phy_state state;u32 dev_flags;phy_interface_t interface; -/* -* forced speed & duplex (no autoneg) -* partner speed & duplex & pause (autoneg) -*/ -int speed; -int duplex; -int pause; -int asym_pause; -/* Enabled Interrupts */ u32 interrupts;
Signature · 1 line
Florian
Heiner Kallweit
maintainerAm 25.05.2018 um 01:03 schrieb Florian Fainelli:
Quoted 11 lines · Heiner Kallweit
Quoted 3 lines
This patch is a follow-up to
87e5808d52b6("net: phy: replace bool members in structphy_devicewith bit-fields") and converts further flags to bit-fields.This looks fine, but then you would also have to clean-up all code that does
phydev->asym_pause= 1 andphydev->pause= 1 to use true/false instead, I am not sure there is much value in doing that for these fields considering that they are exposed to drivers so there is a risk of possible breakage.
I grepped over drivers/net and all assignments to pause / asym_pause use 0, 1, or the result of a logical operation only.
However you're right, there's one potential issue:
struct ethtool_pauseparam defines rx_pause and tx_pause as __u32 and mentions in the kernel doc only flag autoneg to be sanitized (even though rx_pause and tx_pause are called "flags").
So basically all drivers implementing ethtool callback set_pauseparam don't check user space input for both values.
However this could be easily fixed by implementing these checks in the core. In ethtool_set_pauseparam() we could do for autoneg, rx_pause and tx_pause: val = !!val to sanitize them.
How would you see it after adding this?
Heiner
Quoted 45 lines
Thanks!
Quoted 41 lines
Signed-off-by Heiner Kallweit <[email protected]>--- include/linux/phy.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)include/linux/phy.h +8
-9@@ -418,21 +418,20 @@ struct phy_device {/* The most recently read link state */ unsigned link:1; +/* forced speed & duplex (no autoneg) +* partner speed & duplex & pause (autoneg) +*/ + unsigned pause:1; + unsigned asym_pause:1; +int speed; +int duplex; +enum phy_state state;u32 dev_flags;phy_interface_t interface; -/* -* forced speed & duplex (no autoneg) -* partner speed & duplex & pause (autoneg) -*/ -int speed; -int duplex; -int pause; -int asym_pause; -/* Enabled Interrupts */ u32 interrupts;