Page MenuHomeFreeBSD

axe: fix spurious link flaps from MII
Needs ReviewPublic

Authored by rkitover_gmail.com on Wed, Mar 18, 7:04 PM.
Referenced Files
F151759199: D55925.id174390.diff
Fri, Apr 10, 11:46 AM
Unknown Object (File)
Wed, Apr 8, 11:46 PM
Unknown Object (File)
Wed, Apr 8, 9:56 AM
Unknown Object (File)
Wed, Apr 8, 9:56 AM
Unknown Object (File)
Wed, Apr 8, 9:56 AM
Unknown Object (File)
Wed, Apr 8, 9:56 AM
Unknown Object (File)
Mon, Apr 6, 4:28 PM
Unknown Object (File)
Sun, Apr 5, 1:21 PM
Subscribers

Details

Reviewers
adrian
pouria
zlei
Summary

A race condition in the MII layer causes spurious link down events, see:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252165

. In statchg, on link down, check if the PHY reports the link as
actually down using the BMSR register, if not, force the status of the
link to back up. Do the same in a MII linkchg handler.

I have tested this patch with an ASIX AX88772B USB 2.0 interface, and it
fixes the link flaps.

Differential Review:

Signed-off-by: Rafael Kitover <rkitover@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71896
Build 68779: arc lint + arc unit

Event Timeline

Environment:

Hardware: ASIX Electronics Corp. AX88772 (BUFFALO LUA3-U2-ATX, 100Base Ethernet)
Tested on: Raspberry Pi 4(16-current), Raspberry Pi Zero 2W(15.0-RELEASE), Pine64(15.0-RELEASE)

Description:
I am experiencing a "link flapping" issue where the connection repeatedly toggles between UP and DOWN. Unfortunately, this issue persists even after applying the latest patch.

The logs show frequent "spurious link down" messages[OK] and link state changes[NG], as seen below:

Log Output:

Mar 23 16:01:29 generic syslogd: last message repeated 9 times
Mar 23 16:01:29 generic kernel: ue0: link state changed to DOWN
Mar 23 16:01:29 generic kernel: ue0: link state changed to UP
Mar 23 16:01:30 generic kernel: axe0: spurious link down (PHY link up), overriding
Mar 23 16:01:31 generic syslogd: last message repeated 1 times
Mar 23 16:01:31 generic kernel: ue0: link state changed to DOWN
Mar 23 16:01:31 generic kernel: axe0: spurious link down (PHY link up), overriding
Mar 23 16:01:31 generic syslogd: last message repeated 2 times
Mar 23 16:01:31 generic kernel: ue0: link state changed to UP
Mar 23 16:01:31 generic kernel: ue0: link state changed to DOWN
Mar 23 16:01:31 generic kernel: axe0: spurious link down (PHY link up), overriding
Mar 23 16:01:31 generic kernel: ue0: link state changed to UP
Mar 23 16:01:32 generic kernel: axe0: spurious link down (PHY link up), overriding
Mar 23 16:01:40 generic syslogd: last message repeated 10 times
Mar 23 16:01:40 generic kernel: ue0: link state changed to DOWN
Mar 23 16:01:40 generic kernel: ue0: 3 link states coalesced
Mar 23 16:01:40 generic kernel: ue0: link state changed to UP
Mar 23 16:01:42 generic kernel: axe0: spurious link down (PHY link up), overriding

Notes:
I also use a ure driver dongle (Lenovo USB-C to LAN). In that case, the similar issue was successfully resolved by the ure patch, but the axe driver (AX88772) still exhibits this behavior.

Please let me know if you need any further debug information.

FYI: My testing methodology

Setup:

  • Machine A (Remote): Run ping [Unassigned Local IP].
  • Machine B (Target): Run the route -n monitor command in four separate instances.

Note: In my environment, the link issue only occurs while route -n monitor is running. If the command is not active, the connection remains stable.

Thank you for testing,

I'll run some tests and try to find the issue.

I have reproduced the bug on my laptop.

sanpei,

I added a lock for the MII bus, and it seems to have fixed this problem.

Can you please try the current patch?

I've updated the axge patch with this fix.

I will try new patch with axe and axge and report it. Thanks!!

I have tested the updated if_axe driver with several devices.
In my environments, the issues with link flaps have been resolved(even added changing axe_miibus_statchg, there is "no" spurious link down message. I don't know why??) .

Test Environments:
ASIX AX88772 (BUFFALO LUA3-U2-ATX)

  • Raspberry Pi 4 (16-CURRENT/arm64)
  • Raspberry Pi Zero 2W and Pine64 (15.0-RELEASE/arm64)
  • Intel PC (14.3-RELEASE/amd64)

ASIX AX88178 (BUFFALO LUA3-U2-AGT)

  • Intel PC (14.3-RELEASE/amd64)

I would appreciate it if these changes could be merged into -CURRENT, stable/15, and stable/14.
(I haven't tested arm64 with 14.4-RELEASE yet, but I can do so if needed.)

FYI: I am also testing updated if_axge and if_ure drivers. So far, they are stable and show no signs of link flapping[OK]. After finishing the test, I will report it each thread.