[PATCH net-next] net: dsa: honor "max-speed" for implicit PHYs on user ports

A. Sverdlin
2024-12-19T17:38:12Z

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

If the PHYs on user ports are not specified explicitly, but a common
user_mii_bus is being registered and scanned there is no way to limit
Auto Negotiation options currently. If a gigabit switch is deployed in a
way that the ports cannot support gigabit rates (4-wire PCB/magnetics,
for instance), there is no way to limit ports' AN not to advertise gigabit
options. Some PHYs take considerably longer time to AutoNegotiate in such
cases.

Provide a way to limit AN advertisement options by examining "max-speed"
property in the DT node of the corresponding user port and call
phy_set_max_speed() right before attaching the PHY to he port netdevice.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
net/dsa/user.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/net/dsa/user.c b/net/dsa/user.c
index 4a8de48a6f24..9e3f5b0f9af3 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -2625,6 +2625,13 @@ static int dsa_user_phy_connect(struct net_device *user_dev, int addr,

user_dev->phydev->dev_flags |= flags;

+ if (dp->dn) {
+ u32 max_speed;
+
+ if (!of_property_read_u32(dp->dn, "max-speed", &max_speed))
+ phy_set_max_speed(user_dev->phydev, max_speed);
+ }
+
return phylink_connect_phy(dp->pl, user_dev->phydev);
}

--
2.47.1