You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the fsl_enet based port with a register-level ENET, LAN8741 and
eDMA driver that builds without the vendor SDK.
- NXP_MCXE_ENET_IRQ: polled (0) or interrupt driven (1). The receive
interrupt lets poll() return at once on an empty ring; send() sleeps in
wfi when the transmit ring is full.
- NXP_MCXE_ENET_EDMA: copy frames between the rings and wolfIP buffers
with an eDMA channel, memcpy for short frames or on error.
- NXP_MCXE_ENET_STATS: frame and DWT cycle counters for throughput
profiling, read with nxp_mcxe_enet_stats_get().
- A full transmit ring waits for the oldest frame instead of failing,
since wolfIP does not retry a dropped ACK.
- config.h: RXBUF_SIZE and TXBUF_SIZE can be overridden by the build.
wolfIP_poll() takes up to 128 frames from each device per call. On a slow
CPU under a line-rate UDP flood the socket buffer fills after a few
datagrams, and the rest of the batch is processed only to be dropped before
the application can read. A smaller budget lets the application drain the
socket between batches.
eth_poll() released an errored frame (FIFO overrun, CRC error) and returned
0, which wolfIP takes as an empty ring, so poll_devices() stopped and left
the rest of the ring for the next poll. Under a line-rate flood while the
CPU was also transmitting, the MAC refilled each freed descriptor with
another overrun fragment and the ring stayed full: in a UDP bidir test 71k
polls returned 4k good frames and 93% of received frames overflowed the
FIFO. Release errored frames and look at the next descriptor, returning on
a good frame, an empty ring, or after one pass over the ring.
UDP bidir at 80 MHz: board rx 2.9 -> 19.1 Mbit/s.
The checksums added one 16-bit word at a time, byte swapping each, and
transport_checksum was a quarter of the CPU time on a Cortex-M4 at line
rate. csum_add() adds 32-bit words in host byte order into a 64-bit sum,
four per iteration, through memcpy so the buffer need not be aligned.
csum_fold() folds to 16 bits once and swaps back to network order (the
one's complement sum is byte order independent, RFC 1071 2(B)). The
transport, ICMP, IP header and multicast checksums all use them.
MCX E247 at 80 MHz: udp-rx 43.4 -> 56.0, udp-tx 41.7 -> 49.6, tcp-rx
27.0 -> 29.2, tcp-tx 25.6 -> 28.7 Mbit/s. Matches a byte-wise RFC 1071
reference for every length 0-1600 at four alignments; unit, multicast,
asan, ubsan and ipv6 unit tests pass.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical timeout flaws can leave eth_send() blocked indefinitely and allow an active eDMA transfer to access buffers after ownership changes, risking hangs and data corruption.
Replaces the NXP MCX E247 port’s SDK-based Ethernet driver with a standalone implementation, adding optional interrupt-driven operation and throughput-focused data handling.
Changes:
Programs the MAC, PHY, descriptor rings, and optional eDMA directly.
Adds driver statistics and configurable socket buffers and poll budget.
Consolidates core checksum routines into shared word-based helpers.
File
Description
src/wolfip.c
Shares optimized checksum helpers and allows poll-budget overrides.
src/port/nxp_mcxe_enet/README.md
Documents standalone operation, build options, and memory requirements.
src/port/nxp_mcxe_enet/nxp_mcxe_enet.h
Exposes configuration options, statistics, and interrupt APIs.
src/port/nxp_mcxe_enet/nxp_mcxe_enet.c
Implements direct hardware initialization and ring-based receive/transmit paths.
src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h
Defines hardware registers without SDK dependencies.
src/port/nxp_mcxe_enet/config.h
Allows applications to override receive and transmit buffer sizes.
Scan targets checked:wolfip-src, wolfip-bugs Not reviewed (no scan target covers them):src/port/nxp_mcxe_enet/README.md Coverage: 4 of 5 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
A timed-out eDMA copy returned while the channel could still be pending
or running, and its buffers then changed hands (the receive descriptor
back to the MAC, the transmit buffer to the MAC). edma_stop() now keeps
a channel that has not started from starting (clears START) and
cancels a running one with CR.CX, then waits until it is idle. If it
does not become idle, the eDMA is not used again and all copies use
memcpy.
tx_wait() slept in wfi until the transmit interrupt. DWT_CYCCNT stops
while the core sleeps, so a transmitter that never raised the interrupt
would never time out. It now polls the descriptor within the 5 ms
limit, and the transmit interrupt, which only woke that wfi, is no
longer enabled.
Tested on the FRDM-MCXE247: the wolfBoot test-app speed suite passes
at unchanged rates, and with the copy timeout forced to 20 cycles all
411124 copies were cancelled and redone by the CPU with no errors.
eth_send() rejects frames over 1518 bytes, but LINK_MTU was 1536, so
wolfIP accepted 1519-1536 byte packet-socket frames that the driver
then refused forever, blocking the socket's transmit queue. Set
LINK_MTU to 1518 and check it against ENET_MAX_FRAME_LEN at build
time; the socket buffer defaults stay at 1536 bytes.
Scan targets checked:wolfip-src, wolfip-bugs Not reviewed (no scan target covers them):src/port/nxp_mcxe_enet/README.md, src/test/unit/unit.c, src/test/unit/unit_tests_proto.c Coverage: 2 of 6 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_enet/config.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_board.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h
Findings: 1 1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical issues remain: the PHY helper include order breaks compilation/linking, and failed eDMA cancellation can leave DMA accessing caller-owned buffers after return, risking stack corruption.
Scan targets checked:wolfip-src, wolfip-bugs Not reviewed (no scan target covers them):src/port/nxp_mcxe_enet/README.md, src/test/unit/unit.c, src/test/unit/unit_tests_proto.c Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_enet/nxp_mcxe_enet.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The timeout recovery uses global eDMA cancellation that can race with channel switching and abort an unrelated application's transfer.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Avoid cancelling unrelated transfers on the shared eDMA controller
src/port/nxp_mcxe_enet/nxp_mcxe_enet.c:252
CR.CX cancels the controller's currently executing channel, not the channel identified by ch. The ENET channel can finish after the ACTIVE read and another application's eDMA channel can start before this write, causing the timeout recovery to abort an unrelated transfer. Reserving only NXP_MCXE_ENET_EDMA_CH does not prevent this race. Avoid global cancellation when the controller is shared—for example, prevent further starts of this channel and wait for it to become inactive before using the memcpy fallback—or require exclusive ownership of the entire controller.
CR.CX cancels whichever channel the controller is executing, not the
driver's channel: the copy can finish after the ACTIVE read and an
application channel start before the write, which then aborts the
application's transfer.
After a timeout, set CR.HALT so the controller starts no channel, wait
for a running copy to finish by itself, withdraw one not started by
clearing START, and clear HALT again unless it was already set. Other
channels are delayed, not cancelled. The receive buffer is still handed
back only once the channel is idle.
Tested on the FRDM-MCXE247 with every copy forced to time out
(EDMA_TIMEOUT_US 0): the network speed test passes on the memcpy
fallback. Normal build rates unchanged.
- phy_wait_link() reads ANAR and ANLPAR with mdio_read() and polls
again when either read fails, instead of deriving the speed and
duplex from a data register that does not hold the value.
- nxp_mcxe_enet_init() without link blocks for up to about 10 s (5 s
auto-negotiation in the PHY bring-up, then 5 s for the link), not 5 s.
Documented in the header.
Tested on the FRDM-MCXE247: network speed test unchanged.
- Restart the MAC after an ENET DMA bus error, including one raised
while the restart runs; report the count with
nxp_mcxe_enet_bus_errors(). After a failed re-init, poll() and
send() drop traffic until a call succeeds.
- Remove the eDMA copy option: it was no faster for receive and 2-4%
slower for transmit than memcpy.
- Read the core clock live (SIRC range included) for timeouts and
stats, and set the MDIO clock from it before each transfer;
us_to_cycles() scales milliseconds and the remainder separately so
long delays do not overflow.
- Keep the PHY address found on the bus. For a parallel-detected link,
read the resolved speed from PSCSR on a LAN8710/8720/8740/8741/8742,
matched by model; other PHYs get 100 Mbit/s half duplex.
- Check NXP_MCXE_ENET_SYSMPU_RGD against SYSMPU_RGD_NUM, only when the
driver programs the system MPU, and WOLFIP_POLL_BUDGET >= 1.
- Document the init return codes and blocking time, and that the MAC
keeps the speed and duplex found at init until it is called again.
Scan targets checked:wolfip-src, wolfip-bugs Not reviewed (no scan target covers them):src/port/nxp_mcxe_enet/README.md, src/test/unit/unit.c, src/test/unit/unit_tests_proto.c Coverage: 2 of 6 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_enet/nxp_mcxe_enet.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_board.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h, src/wolfip.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The driver lacks declarations for memcpy() and memset(), causing strict C99 build failures, and MDIO read failures can stall initialization for roughly 90 seconds.
If MDIO stopped completing after the PHY reset write, each of the
MDIO_TIMEOUT reset and auto-negotiation polls waited for the 1 ms MDIO
timeout, blocking init for about 90 s. The first timeout now makes later
MDIO transfers fail at once until nxp_mcxe_enet_init() runs again.
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
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.
Adds a standalone driver for mcxe247, eliminating sdk dependency.
Driver is interrupt-driven and optimized for throughput.
Goes with wolfSSL/wolfBoot#991