Page MenuHomeFreeBSD

axge: fix spurious link down from MII, frozen TX
Needs ReviewPublic

Authored by rkitover_gmail.com on Mar 3 2026, 1:11 PM.
Referenced Files
Unknown Object (File)
Tue, Mar 31, 10:05 AM
Unknown Object (File)
Fri, Mar 27, 11:29 PM
Unknown Object (File)
Thu, Mar 26, 6:46 PM
Unknown Object (File)
Thu, Mar 26, 5:07 AM
Unknown Object (File)
Thu, Mar 26, 3:52 AM
Unknown Object (File)
Thu, Mar 26, 3:38 AM
Unknown Object (File)
Wed, Mar 25, 9:51 PM
Unknown Object (File)
Wed, Mar 25, 9:49 PM

Details

Reviewers
adrian
pouria
Group Reviewers
USB
network
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 and restart TX. Do the same in a MII linkchg handler.

On actual link up, restart TX in case it went idle and down.

I have tested this patch with two of my USB-C hubs with this Ethernet
interface, and it gives me a stable permanent connection with no
interruptions to my internet connections.

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

Diff Detail

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

Event Timeline

Add Differential Review URL

Add Differential Review URL to commit message.

style.9

sys/dev/usb/net/if_axge.c
334

use bool for new_link and old_link

392–394

Up to your judgement, but try to not break strings as much as possible.

488

style: Do not test without a comparison, or with unary ! (except for booleans).

I think I can remove the frozen TX fix given that the link doesn't go down, I'll do that and test it out, then update this patch.

pouria, I still want your ure logs, with and without the patch, I need to figure out why it didn't work for you as intended.

Remove frozen TX handling, unneeded if link up

This revision is now accepted and ready to land.Tue, Mar 17, 7:21 PM

this is good work! i would like to figure out how to describe the "why" this extra stuff is necessary though, so lemme noodle on that a bit first.

(and yeah some if "be correct" and some is "usb stack race conditions sigh")

Hi Adrian,

thanks for getting back to this. I'm fine with removing these changes once MII is fixed, although they don't really hurt anything.

So ure, just merged, is the other common Ethernet dongle chipset, I'm also doing axe, an older 100Mbps interface, I will link it here.

That will cover the common set of dongle chips.

That leaves some pi models which use MII for Ethernet, but that would be hard to test, so I won't do those now.

The goal here is for a user to be able to use an Ethernet dongle with their laptop with an unsupported wifi chip.

I'm going to look at a couple of wifi chips too later, maybe more.

Add lock to serialize MII bus operations

This revision now requires review to proceed.Fri, Mar 27, 8:27 PM

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

Test Environments:
ASIX Elec. Corp. AX88179(ELECOM EDC-GUC3L-W)

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

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

Hi sanpei,

as far as USB Ethernet goes, the commonly available chipsets for dongles are axge, ure and axe.

Those are the ones I could buy dongles to teset for and we're dealing with those.

Do you know of other drivers that would benefit from this patch that you have access to hardware for?

I'm trying to get the C revision chip for ure so I can add support for it too.

I was able to obtain an axge(4) compatible USB3 adapter for ~6GBP from Amazon.

It may be able to support IEEE 1588 receive timestamping, if someone ports the required M_TSTMP support from ASIX's own out-of-tree source-available driver for Linux.

Due to work commitments, it appears @kevlo can't commit to it.

I'll send it at cost to someone who commits to doing this.

Hi bms,

I'll do it if you need this feature, I have a hub with this chip.

In D55631#1284650, @bms wrote:

I was able to obtain an axge(4) compatible USB3 adapter for ~6GBP from Amazon.

Is the chipset ax88279? If so, could you send me the link to the product so
I can buy one? Thanks.

It may be able to support IEEE 1588 receive timestamping, if someone ports the required M_TSTMP support from ASIX's own out-of-tree source-available driver for Linux.

Due to work commitments, it appears @kevlo can't commit to it.

I'll send it at cost to someone who commits to doing this.

PS: I bought a USB adapter ( AX88179A ) but were not able to repeat ( with stress tests for about two days ).

sys/dev/usb/net/if_axge.c
336–337

I'd do this tiny bit, to be consistent with axge_miibus_linkchg().

350

Evaluate to a boolean directly.

365

Ditto.

463

It is logically a boolean status. See also the definition of mtx_owned,

#define mtx_owned(m) 	(mtx_owner(m) == curthread)
469

Adjust accordingly.

Hi, @rkitover_gmail.com

Do you know of other drivers that would benefit from this patch that you have access to hardware for?

I have the old aue device(Buffalo/MELCO LUA2-TX/ 10-100M USB adapter).
But I have media link mismatch issue(Even connect 1Gbps port, media status is 10Base-TX...).
If I fix this issue. I will request this patch.

In D55631#1284650, @bms wrote:

I was able to obtain an axge(4) compatible USB3 adapter for ~6GBP from Amazon.

Is the chipset ax88279? If so, could you send me the link to the product so
I can buy one? Thanks.

Sure, but it was AX88179 I'm afraid: Tccmebius USB Ethernet Adapter, USB 3.0 to 10/100/1000 Gigabit Ethernet LAN Network Adapter looked to be the AX88179A_772D variant based on what it reported via usbconfig(8).

ASIX's out-of-tree is GPLv2 and dated 2022, the support code in ax_ptp.c appears to register a PHC clock with LinuxPTP for these devices.

I think the 2.5GBASE-T capable part you are referring to, AX88279, may be available from the same OEM, and it is also believed to support IEEE 1588 in a similar way. I do have another USB 3.x 2.5GBASE-T dongle but it's Realtek based.

Style fixes based on zlei's review

Style fixes based on zlei's review

I've made the changes you suggested zlei, I will update the axe and ure patches as well.

zlei, I updated the axe and ure patches based on your review.

Hi rkitover,

Do you know of other drivers that would benefit from this patch that you have access to hardware for?

The aue(4) driver would also benefit from applying this "Lock-mii-bus-operation" without the miibus_statchg/miibus_linkchg code.

I have tested the following patch:
https://people.freebsd.org/~sanpei/aue-only-Lock-mii-bus-operation.diff

Test Environment:

aue0 on uhub1
aue0: <LUA2-TX BUFFALO LUA2-TX, class 0/0, rev 1.10/1.01, addr 2> on usbus0
miibus1: <MII bus> on aue0
acphy0: <ACXXX 10/100 media interface> PHY 1 on miibus1
acphy0:  100baseFX, 100baseFX-FDX, none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ue0: <USB Ethernet> on aue0

Current Minor Issues on -CURRENT:

Media Status Mismatch:
While the dongle LED and switch indicate a 100baseTX/full-duplex connection, ifconfig consistently reports 10baseT/half-duplex[NG].

ifconfig Hang under Load:
Running multiple instances (e.g., 100) of /sbin/route -n monitor causes ifconfig to hang. This also occurs with ure (Lenovo USB-C to LAN), but does not happen with axge or axe drivers.

Note: Killing the route processes recovers the ifconfig responsiveness.

Despite these minor regressions in -CURRENT, the overall stability is improved. I hope the aue(4) driver will be included in this change.

sys/dev/usb/net/if_axgereg.h
205 ↗(On Diff #174721)

I'm not convinced this extra lock is required. It appears all the MII operations have been lock protected by sc_mtx already. Am I missing anything ? Can you elaborate this ?