* [PATCH RFC] net: mdio_bus: make check in mdiobus_prevent_c45_scan more granular
@ 2024-01-02 14:38 Heiner Kallweit
2024-01-02 15:18 ` Russell King (Oracle)
0 siblings, 1 reply; 3+ messages in thread
From: Heiner Kallweit @ 2024-01-02 14:38 UTC (permalink / raw)
To: Russell King, Andrew Lunn; +Cc: netdev@vger.kernel.org
Matching on OUI level is a quite big hammer. So let's make matching
more granular.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
This is what I'm thinking of. Maybe the problem of misbehaving
on c45 access affects certain groups of PHY's only.
Then we don't have to blacklist all PHY's from this vendor.
What do you think?
---
drivers/net/phy/mdio_bus.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6cf73c156..848d5d2d6 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -621,19 +621,27 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus)
*/
static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)
{
- int i;
+ const struct {
+ u32 phy_id;
+ u32 phy_id_mask;
+ } id_list[] = {
+ { MICREL_OUI << 10, GENMASK(31, 10) },
+ };
+ int i, j;
for (i = 0; i < PHY_MAX_ADDR; i++) {
struct phy_device *phydev;
- u32 oui;
phydev = mdiobus_get_phy(bus, i);
if (!phydev)
continue;
- oui = phydev->phy_id >> 10;
- if (oui == MICREL_OUI)
- return true;
+ for (j = 0; j < ARRAY_SIZE(id_list); j++) {
+ u32 mask = id_list[j].phy_id_mask;
+
+ if ((phydev->phy_id & mask) == (id_list[j].phy_id & mask))
+ return true;
+ }
}
return false;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] net: mdio_bus: make check in mdiobus_prevent_c45_scan more granular
2024-01-02 14:38 [PATCH RFC] net: mdio_bus: make check in mdiobus_prevent_c45_scan more granular Heiner Kallweit
@ 2024-01-02 15:18 ` Russell King (Oracle)
2024-01-02 15:47 ` Heiner Kallweit
0 siblings, 1 reply; 3+ messages in thread
From: Russell King (Oracle) @ 2024-01-02 15:18 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Andrew Lunn, netdev@vger.kernel.org
On Tue, Jan 02, 2024 at 03:38:05PM +0100, Heiner Kallweit wrote:
> Matching on OUI level is a quite big hammer. So let's make matching
> more granular.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> This is what I'm thinking of. Maybe the problem of misbehaving
> on c45 access affects certain groups of PHY's only.
> Then we don't have to blacklist all PHY's from this vendor.
> What do you think?
> ---
> drivers/net/phy/mdio_bus.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 6cf73c156..848d5d2d6 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -621,19 +621,27 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus)
> */
> static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)
> {
> - int i;
> + const struct {
> + u32 phy_id;
> + u32 phy_id_mask;
> + } id_list[] = {
> + { MICREL_OUI << 10, GENMASK(31, 10) },
> + };
Do we need a new structure? Would struct mdio_device_id do (which
actually has exactly the same members with exactly the same names in
exactly the same order.)
Also, as this is not static, the compiler will need to generate code
to initialise the structure, possibly storing a copy of it in the
.data segment and memcpy()ing it onto the kernel stack. I suggest
marking it static to avoid that unnecessary hidden code complexity.
> + for (j = 0; j < ARRAY_SIZE(id_list); j++) {
> + u32 mask = id_list[j].phy_id_mask;
> +
> + if ((phydev->phy_id & mask) == (id_list[j].phy_id & mask))
if (phy_id_compare(phydev->phy_id, id_list[j].phy_id,
id_list[j].phy_id_mask))
Or it could be:
const struct mdio_device_id *id = id_list + j;
if (phy_id_compare(phydev->phy_id, id->phy_id,
id->phy_id_mask))
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] net: mdio_bus: make check in mdiobus_prevent_c45_scan more granular
2024-01-02 15:18 ` Russell King (Oracle)
@ 2024-01-02 15:47 ` Heiner Kallweit
0 siblings, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2024-01-02 15:47 UTC (permalink / raw)
To: Russell King (Oracle); +Cc: Andrew Lunn, netdev@vger.kernel.org
On 02.01.2024 16:18, Russell King (Oracle) wrote:
> On Tue, Jan 02, 2024 at 03:38:05PM +0100, Heiner Kallweit wrote:
>> Matching on OUI level is a quite big hammer. So let's make matching
>> more granular.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> This is what I'm thinking of. Maybe the problem of misbehaving
>> on c45 access affects certain groups of PHY's only.
>> Then we don't have to blacklist all PHY's from this vendor.
>> What do you think?
>> ---
>> drivers/net/phy/mdio_bus.c | 18 +++++++++++++-----
>> 1 file changed, 13 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
>> index 6cf73c156..848d5d2d6 100644
>> --- a/drivers/net/phy/mdio_bus.c
>> +++ b/drivers/net/phy/mdio_bus.c
>> @@ -621,19 +621,27 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus)
>> */
>> static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)
>> {
>> - int i;
>> + const struct {
>> + u32 phy_id;
>> + u32 phy_id_mask;
>> + } id_list[] = {
>> + { MICREL_OUI << 10, GENMASK(31, 10) },
>> + };
>
> Do we need a new structure? Would struct mdio_device_id do (which
> actually has exactly the same members with exactly the same names in
> exactly the same order.)
>
> Also, as this is not static, the compiler will need to generate code
> to initialise the structure, possibly storing a copy of it in the
> .data segment and memcpy()ing it onto the kernel stack. I suggest
> marking it static to avoid that unnecessary hidden code complexity.
>
Both good points. I missed the static declaration.
>> + for (j = 0; j < ARRAY_SIZE(id_list); j++) {
>> + u32 mask = id_list[j].phy_id_mask;
>> +
>> + if ((phydev->phy_id & mask) == (id_list[j].phy_id & mask))
>
> if (phy_id_compare(phydev->phy_id, id_list[j].phy_id,
> id_list[j].phy_id_mask))
>
> Or it could be:
>
> const struct mdio_device_id *id = id_list + j;
>
> if (phy_id_compare(phydev->phy_id, id->phy_id,
> id->phy_id_mask))
>
This looks best to me.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-02 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 14:38 [PATCH RFC] net: mdio_bus: make check in mdiobus_prevent_c45_scan more granular Heiner Kallweit
2024-01-02 15:18 ` Russell King (Oracle)
2024-01-02 15:47 ` Heiner Kallweit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).