Read QCA8337's vendor status on each autonegotiated link check so the reported speed matches the PHY after SmartSpeed changes negotiation. Keep link down while that status is unresolved or encodes a reserved speed; PHYLIB then notifies its consumers when valid status returns. Forced mode continues to use the generic BMCR result. Suggested-by: Andrew Lunn Signed-off-by: Yongzhao Chen Assisted-by: LLM --- Andrew suggested this in his review of RFC v3 4/5, where he noted that read_status should report the real speed from the vendor register. Thanks, Andrew. I mentioned this change in the same thread: https://lore.kernel.org/netdev/20260924234814.1734-1-yongzhao.derek@gmail.com/ It does not depend on the qca8k series and applies to net-next on its own. Testing: a model test compiles this function with the real genphy_read_status(), phy_resolve_aneg_pause(), phy_read_status() and phy_check_link_status() and covers 10/100/1000 in both duplexes, unresolved and reserved speed codes, a speed change while the link stays up, forced mode, pause resolution and MDIO read errors. W=1 builds for arm64 are clean. The same function is in my OpenWrt Linux 6.18.52 build for a Redmi AX5400 (QCA8337), including the build used to test the at803x IPQ5018 fixes. I have not injected a real SmartSpeed downshift on a user port. drivers/net/phy/qcom/qca83xx.c | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/phy/qcom/qca83xx.c b/drivers/net/phy/qcom/qca83xx.c index bc70ed8efd8..b3f3183d4a4 100644 --- a/drivers/net/phy/qcom/qca83xx.c +++ b/drivers/net/phy/qcom/qca83xx.c @@ -92,6 +92,54 @@ static int qca83xx_probe(struct phy_device *phydev) return 0; } +static int qca8337_read_status(struct phy_device *phydev) +{ + int ret, ss; + + ret = genphy_read_status(phydev); + if (ret) + return ret; + if (phydev->autoneg == AUTONEG_DISABLE) + return 0; + + phydev->speed = SPEED_UNKNOWN; + phydev->duplex = DUPLEX_UNKNOWN; + phydev->pause = false; + phydev->asym_pause = false; + if (!phydev->link) + return 0; + + /* SmartSpeed can make the actual speed differ from the advertised modes. */ + ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); + if (ss < 0) + return ss; + if (!(ss & AT803X_SS_SPEED_DUPLEX_RESOLVED)) { + phydev->link = 0; + return 0; + } + + switch ((ss & AT803X_SS_SPEED_MASK) >> 14) { + case AT803X_SS_SPEED_10: + phydev->speed = SPEED_10; + break; + case AT803X_SS_SPEED_100: + phydev->speed = SPEED_100; + break; + case AT803X_SS_SPEED_1000: + phydev->speed = SPEED_1000; + break; + default: + phydev->link = 0; + return 0; + } + + phydev->duplex = ss & AT803X_SS_DUPLEX ? DUPLEX_FULL : DUPLEX_HALF; + if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) + phy_resolve_aneg_pause(phydev); + + return 0; +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -220,6 +268,7 @@ static struct phy_driver qca83xx_driver[] = { .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset, + .read_status = qca8337_read_status, .get_sset_count = qca83xx_get_sset_count, .get_strings = qca83xx_get_strings, .get_stats = qca83xx_get_stats, base-commit: 014d795c73837ea2339a4ea8e8f82c6e959b845d -- 2.43.0