Skip to content

airoha: fix USXGMII data path on speed changes - #22536

Closed
rchen14b wants to merge 1 commit into
openwrt:mainfrom
rchen14b:airoha-pcs-usxgmii-fix
Closed

rchen14b wants to merge 1 commit into
openwrt:mainfrom
rchen14b:airoha-pcs-usxgmii-fix

Conversation

@rchen14b

Copy link
Copy Markdown
Contributor

Summary

Fix two bugs in the AN7581 PCS driver that break USXGMII data path
when phylink renegotiates speed.

Patch 620 — Rate adaptation not updated for USXGMII:
The rate adaptation register writes in airoha_pcs_link_up() were
inside the forced-mode-only branch (neg_mode != PHYLINK_PCS_NEG_INBAND).
USXGMII always uses in-band autoneg, so these registers were never
updated on speed changes. This causes PSE flooding that also breaks
1G switch ports sharing the same Frame Engine.

Fix: move USXGMII rate adaptation out of the forced-mode guard.

Patch 621 — RX data path not reinitialized on speed change:
When phylink renegotiates speed within the same interface mode (e.g.
10G → 2.5G → 10G), only link_up() is called — not pcs_config().
The existing TXPCS-only reset in an7581_pcs_phya_link_up() is
insufficient. The RX deserialization, FIFOs, and PMA digital logic
remain configured for the old speed, silently dropping all packets.

Fix: add a full PCS/PMA global digital reset (CDR re-lock + all reset
lines except REF_RST_N) for USXGMII and 10GBASE-R speed changes.

Guard the reset with a needs_full_init flag set by pcs_config()
after bringup() runs. This skips the global reset on the first
link_up() after boot/re-probe, when bringup() already did a full
PCS/PMA init and the PHY firmware may still be loading. Firing a
global reset during PHY init can corrupt USXGMII autoneg state.

Both bugs are in the upstream pcs-an7581.c driver and affect any
AN7581 board with USXGMII PHYs (RTL8261N, AS21xxx).

Test results

  • Gemtek W1700K (AN7581 + dual RTL8261N on USXGMII)
  • Boot with 1G device on lan2: link comes up at 1G, no dead link
  • Boot with 10G device on lan2: link comes up at 10G
  • Cable replug: global reset fires, link recovers in ~3s
  • Verified with debug logging: "skipping global reset" on boot,
    "performing global digital reset" on replug

Test plan

  • Build for airoha target
  • Boot with cable plugged in — verify no permanent link failure
  • Unplug/replug cable — verify link recovers
  • Test with both 1G and 10G devices on USXGMII ports

Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
@github-actions github-actions Bot added the target/airoha pull request/issue for airoha target label Mar 21, 2026
@Ansuel

Ansuel commented Mar 24, 2026 •

Copy link
Copy Markdown
Member

I'm a bit confused by these patch... in inband rate adaption should not be forced... the soc in theory should select the rate adaption internally based on the speed. For the reset it might be ok but i don't like the implementation at all... especially the 50 times loop and double cdr reset?

my test were done with sfp usxgmii inband.

@Ansuel

Ansuel commented Apr 22, 2026

Copy link
Copy Markdown
Member

@rchen14b any news for this? Can you give me some simple repro step?

OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 14, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
OpenWRT-fanboy pushed a commit to OpenWRT-fanboy/OpenW1700k that referenced this pull request May 15, 2026
Add two kernel patches to fix USXGMII speed change handling in the
Airoha PCS driver:

Patch 620: Move USXGMII rate adaptation out of the forced-mode-only
branch in airoha_pcs_link_up(). USXGMII uses in-band autonegotiation,
so the rate adaptation registers were never updated on speed changes,
causing PSE flooding that also broke 1G switch ports.

Patch 621: Add global digital reset to AN7581 link_up for USXGMII and
10GBASE-R. When phylink renegotiates speed within the same interface
mode, only link_up() is called. The existing TXPCS-only reset is
insufficient - the RX data path must also be reinitialized via a
full PCS/PMA digital reset sequence.

Guard the global reset with a USXGMII PCS link status check to avoid
resetting during initial boot when PHY firmware is still loading. A
global PCS reset during PHY init can corrupt USXGMII autoneg state
permanently, leaving the link stuck at 1G or dead. This also handles
runtime PHY resets where the same vulnerable window exists.
@rchen14b rchen14b closed this Jun 1, 2026
@rchen14b
rchen14b deleted the airoha-pcs-usxgmii-fix branch June 1, 2026 23:34
@rchen14b

rchen14b commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor Author

This patch is no longer needed, the issue was caused by the RTL8261N phy, tested with rchen14b@0879b5b and rchen14b@d773be7

And no longer has any boot up brick issue or the speed neg issue.

@Ansuel

Ansuel commented Jun 2, 2026 via email

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/airoha pull request/issue for airoha target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants