Skip to content

aurix: follow-up fixes to the TC3xx/TC4xx GETH ports - #195

Open
Frauschi wants to merge 3 commits into
wolfSSL:masterfrom
Frauschi:aurix-ports-followup
Open

Frauschi wants to merge 3 commits into
wolfSSL:masterfrom
Frauschi:aurix-ports-followup

Conversation

@Frauschi

Copy link
Copy Markdown
Member

Follow-up to #181 from review: link_update() could write MAC registers after a failed init, and a PHY forced to a fixed mode read as link down.

Changes

  • Store the PHY address only after the MAC is initialised, and clear it when init starts, so *_eth_link_update() after an init that failed before mac_init() returns EINVAL (both ports)
  • aurix_phy_link() reports a forced-mode PHY's speed and duplex from BMCR instead of link down when autonegotiation is disabled
  • *_eth_get_stats() comment: tx counts frames handed to the DMA, rx_dropped every frame the driver discards
  • No change to the TC4xx RX re-arm: the TC4xx RDES3 read format has bits 0-29 reserved, so there is no BUF1V to set

tc3xx_eth_init() and tc4xx_eth_init() stored s_phy_addr straight after
the PHY reset, before refclk_present() and mac_init(). When init then
failed with ENOCLK, a later *_eth_link_update() passed its s_phy_addr
guard and, once the PHY reported a link, mac_set_link() wrote speed and
duplex into a MAC that was never initialised.

The assignment now follows mac_init() on TC3xx and the MDIO re-setup
after it on TC4xx, and init clears s_phy_addr on entry, so a retry that
fails early does not inherit the address from an attempt that got
further. Gating link_update() on s_started instead would break init's
own link wait, which runs before s_started is set. As a consequence
*_eth_phy_addr() also returns -1 after an ENOCLK failure, and its
comment says so.
The tx count from *_eth_get_stats() is frames handed to the DMA, not
completions. rx_dropped counts every frame the driver discards: besides
errored and oversize frames that includes frames larger than the
caller's buffer, frames split across descriptors and context
descriptors. The header comments now say so.
aurix_phy_link() required BMSR.ANEGDONE, which a PHY with
autonegotiation disabled never sets, so a PHY switched to a forced mode
after init read as link down while frames still flowed. On a TC4D7 lite
kit with the PHY forced to 100 Mbit full duplex, BMSR reads 0x784d
(link up, AN not complete) and tc4xx_eth_link_update() returned 0 on
every poll.

With the link up and AN not done, it now reads BMCR. If ANEG_EN is
clear, it reports the forced speed and duplex from BMCR; if it is set,
negotiation is still running and it reports no link as before. The
extra MDIO read happens only on that path.

On the TC4D7 kit, forced 100/full now reads as link up, and forcing
10/half drops the link, brings it back at 10/half and reprograms the
MAC through link_update(), with ping still answered.
@Frauschi Frauschi self-assigned this Nov 13, 2026
Copilot AI balanced review requested due to automatic review settings November 13, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the PHY initialization safety and forced-mode link-reporting changes.

No open issues 🎉

What changed in this PR

This follow-up to #181 fixes initialization safety and forced-mode PHY link reporting in the AURIX TC3xx and TC4xx Ethernet ports.

Changes:

  • Clear the stored PHY address at initialization start and publish it only after MAC setup, preventing link updates after early initialization failures.
  • Read speed and duplex from BMCR for forced-mode PHY links when auto-negotiation is incomplete.
  • Clarify PHY-address availability and transmit/drop counter semantics in API comments.
File Description
src/​port/​common/​aurix_phy.h Adds forced-mode speed and duplex resolution.
src/​port/​aurix_tc4xx/​tc4xx_eth.h Clarifies PHY-address and statistics documentation.
src/​port/​aurix_tc4xx/​tc4xx_eth.c Delays PHY-address publication until MAC and MDIO setup complete.
src/​port/​aurix_tc3xx/​tc3xx_eth.h Clarifies PHY-address and statistics documentation.
src/​port/​aurix_tc3xx/​tc3xx_eth.c Delays PHY-address publication until MAC setup completes.

Review effort: Balanced

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #195

Scan targets checked: wolfip-src, wolfip-bugs
Coverage: 5 of 5 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi Nov 13, 2026
@Frauschi
Frauschi requested a review from danielinux November 13, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants