Repository navigation
Conversation
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.
Contributor
There was a problem hiding this comment.
🟢 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
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
*_eth_link_update()after an init that failed beforemac_init()returnsEINVAL(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