Skip to content

Commit

Permalink
net: mii: Fix the Speed display when the network cable is not connected
Browse files Browse the repository at this point in the history
Two different models of usb card, the drivers are r8152 and asix. If no
network cable is connected, Speed = 10Mb/s. This problem is repeated in
linux 3.10, 4.19, 5.4, 6.12. This problem also exists on the latest
kernel. Both drivers call mii_ethtool_get_link_ksettings,
but the value of cmd->base.speed in this
function can only be SPEED_1000 or SPEED_100 or SPEED_10.
When the network cable is not connected, set cmd->base.speed
=SPEED_UNKNOWN.

Signed-off-by: Xiangqian Zhang <zhangxiangqian@kylinos.cn>
Link: https://patch.msgid.link/20250117094603.4192594-1-zhangxiangqian@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Xiangqian Zhang authored and Jakub Kicinski committed Jan 20, 2025
1 parent 19d7750 commit f6f2e94
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/mii.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ void mii_ethtool_get_link_ksettings(struct mii_if_info *mii,
lp_advertising = 0;
}

if (!(bmsr & BMSR_LSTATUS))
cmd->base.speed = SPEED_UNKNOWN;

mii->full_duplex = cmd->base.duplex;

ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
Expand Down

0 comments on commit f6f2e94

Please sign in to comment.