* [PATCH net-next] net: phy: convert further flags in struct phy_device to bit-field
@ 2018-05-24 20:15 Heiner Kallweit
2018-05-24 23:03 ` Florian Fainelli
0 siblings, 1 reply; 3+ messages in thread
From: Heiner Kallweit @ 2018-05-24 20:15 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/phy.h | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6cd090984..cc66f2834 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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;
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net: phy: convert further flags in struct phy_device to bit-field
2018-05-24 20:15 [PATCH net-next] net: phy: convert further flags in struct phy_device to bit-field Heiner Kallweit
@ 2018-05-24 23:03 ` Florian Fainelli
2018-05-25 6:22 ` Heiner Kallweit
0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2018-05-24 23:03 UTC (permalink / raw)
To: Heiner Kallweit, Andrew Lunn, David Miller; +Cc: netdev@vger.kernel.org
On 05/24/2018 01:15 PM, Heiner Kallweit wrote:
> 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.
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!
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> include/linux/phy.h | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 6cd090984..cc66f2834 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -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;
>
>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net: phy: convert further flags in struct phy_device to bit-field
2018-05-24 23:03 ` Florian Fainelli
@ 2018-05-25 6:22 ` Heiner Kallweit
0 siblings, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2018-05-25 6:22 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, David Miller; +Cc: netdev@vger.kernel.org
Am 25.05.2018 um 01:03 schrieb Florian Fainelli:
> On 05/24/2018 01:15 PM, Heiner Kallweit wrote:
>> 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.
>
> 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.
>
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
> Thanks!
>
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> include/linux/phy.h | 17 ++++++++---------
>> 1 file changed, 8 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/linux/phy.h b/include/linux/phy.h
>> index 6cd090984..cc66f2834 100644
>> --- a/include/linux/phy.h
>> +++ b/include/linux/phy.h
>> @@ -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;
>>
>>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-25 6:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-24 20:15 [PATCH net-next] net: phy: convert further flags in struct phy_device to bit-field Heiner Kallweit
2018-05-24 23:03 ` Florian Fainelli
2018-05-25 6:22 ` Heiner Kallweit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox