Skip to content

!arch/arm/stm32: use the netdev upper half in all Ethernet drivers. - #21937

Open
raiden00pl wants to merge 6 commits into
apache:masterfrom
raiden00pl:stm32-eth-refactor-upper-half
Open

raiden00pl wants to merge 6 commits into
apache:masterfrom
raiden00pl:stm32-eth-refactor-upper-half

Conversation

@raiden00pl

@raiden00pl raiden00pl commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Convert the STM32 Ethernet drivers to the netdev lower half API, and use
the common v1 driver for the F7:

  • common/stm32/stm32_eth_m3m4_v1.c: F1, F2, F4, F7 (the F7 has the same
    MAC IP; its copy in stm32f7/ is removed),
  • common/stm32/stm32_eth_v2.c: H5, H7, N6.

Both drivers use the same design:

  • frames are sent and received in place: each DMA descriptor owns one
    IOB and a frame spans several descriptors, so the static frame buffers
    and the copies are gone,
  • frames are received in the interrupt work (NETDEV_RX_DIRECT),
  • when no IOB is free, the received frame is dropped,
  • a frame that the MAC cuts because the RX ring has no free descriptor
    (v1) is counted as dropped, not as an error; v2 receives in store and
    forward mode, so such a frame is dropped in the MTL RX queue,
  • with a D-Cache (F7, H7, N6), the TX IOBs are cleaned and the RX IOBs
    invalidated; the IOBs must fill whole D-Cache lines, because the RX DMA
    corrupts other data in the lines of its buffers, also in write-through
    mode.

The v1 driver gets the D-Cache maintenance, the MDC clock range up to
216 MHz and, on the F7, the MAC address from the unique ID of the old F7
driver. STM32_ETHMAC selects ARCH_HAVE_NETDEV_STATISTICS.
The series also adds Ethernet support to nucleo-f207zg, and an Ethernet
section to the STM32 porting guide.

Impact

BREAKING CHANGE: the RX/TX rings take their buffers from the IOB pool, so
configurations with too few IOBs fail to build. Quick fix: set
CONFIG_IOB_NBUFFERS=100 and CONFIG_IOB_THROTTLE=8. With a D-Cache,
CONFIG_IOB_ALIGNMENT and CONFIG_IOB_BUFSIZE must be multiples of the
D-Cache line size. All in-tree STM32 Ethernet defconfigs are updated.

Testing

iperf between the board and a Linux host on the same LAN, optimized builds
(netnsh with NETUTILS_IPERF, NETINIT_DHCPC, NET_ETH_PKTSIZE=1514), Mbit/s,
median of 3 runs. The UDP test restarts the board iperf server and floods
it from the host at 50 Mbit/s for 5 s, 50 times; no board crashed.

Board TCP board to host TCP host to board UDP 50 Mbit/s offered
nucleo-f207zg 33.6 20.7 27.9
nucleo-f767zi 59.7 27.9 35.0
nucleo-h743zi 62.6 33.7 52.3
nucleo-n657x0-q 51.6 26.4 52.3
stm32h573i-dk 41.1 23.2 47.0
stm32n6570-dk 158.5 39.3 52.3

nucleo-f767zi: TCP measured with these commits on master 482be65, UDP
with a -O0 build.

nucleo-n657x0-q was loaded into AXISRAM2: the Ethernet DMA does not
receive into the FLEXRAM at 0x34000400 where the board loads today.

stm32n6570-dk runs a 1 Gbit/s RGMII link (RTL8211F); the others are
100 Mbit/s RMII.

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: arm Issues related to ARM (32-bit) architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

jerpelea
jerpelea previously approved these changes Nov 19, 2026
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@raiden00pl is this pr ready for merging?

@raiden00pl

Copy link
Copy Markdown
Member Author

not yet. I want all the fixes I’ve found for the network-related code to be merged, and then I’ll run tests on all the hardware affected by this PR to be sure that nothing is broken

@raiden00pl
raiden00pl dismissed stale reviews from jerpelea and xiaoxiang781216 via 4bf54de November 20, 2026 08:34
@raiden00pl
raiden00pl force-pushed the stm32-eth-refactor-upper-half branch 2 times, most recently from 4bf54de to 2070c3d Compare November 23, 2026 11:44
jerpelea
jerpelea previously approved these changes Nov 23, 2026
Add the RMII pins of the LAN8742A PHY and a netnsh configuration.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
@raiden00pl
raiden00pl force-pushed the stm32-eth-refactor-upper-half branch from 750239c to be39c05 Compare November 24, 2026 11:49
@raiden00pl
raiden00pl marked this pull request as ready for review November 24, 2026 12:46
@raiden00pl

Copy link
Copy Markdown
Member Author

ready for review

hartmannathan
hartmannathan previously approved these changes Nov 24, 2026
…iver.

Convert stm32_eth_m3m4_v1.c to the lower half API.  Frames are sent and
received in place: each DMA descriptor owns one IOB and a frame spans
several descriptors, so the static frame buffers are gone.  The frames
are received in the interrupt work (NETDEV_RX_DIRECT).

BREAKING CHANGE: the RX/TX rings now take their buffers from the IOB
pool. Configurations with too few IOBs fail to build. Quick fix: set
CONFIG_IOB_NBUFFERS=100 and CONFIG_IOB_THROTTLE=8.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
Convert stm32_ethernet.c to the lower half API.  Frames are sent and
received in place: each DMA descriptor owns one IOB and a frame spans
several descriptors, so the static frame buffers are gone.  The frames
are received in the interrupt work (NETDEV_RX_DIRECT): with the upper
half work queue the TCP receive rate was 12 % below the old driver.

BREAKING CHANGE: the RX/TX rings now take their buffers from the IOB pool.
Configurations with too few IOBs fail to build.  Quick fix: set
CONFIG_IOB_NBUFFERS=100 and CONFIG_IOB_THROTTLE=8.  With the D-Cache,
CONFIG_IOB_ALIGNMENT and CONFIG_IOB_BUFSIZE must be multiples of 32.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
Convert stm32_eth_v2.c (STM32H5, STM32H7, STM32N6) to the lower half API.
Frames are sent and received in place: each DMA descriptor owns one IOB
and a frame spans several descriptors, so the static frame buffers are
gone.  The frames are received in the interrupt work (NETDEV_RX_DIRECT).

BREAKING CHANGE: the RX/TX rings now take their buffers from the IOB pool.
Configurations with too few IOBs fail to build.  Quick fix: set
CONFIG_IOB_NBUFFERS=100 and CONFIG_IOB_THROTTLE=8.  With the D-Cache,
CONFIG_IOB_ALIGNMENT and CONFIG_IOB_BUFSIZE must be multiples of the
D-Cache line size.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
Note in the STM32 porting guide that the Ethernet drivers use the netdev
upper half and how to size the IOB pool for them.  Point the Ethernet
driver page to the lower half interface.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
The F7 Ethernet MAC is the same IP as the F2/F4 one.  Build
stm32_eth_m3m4_v1.c for the F7 and remove the F7 copy.  The common driver
gets the D-Cache maintenance of the F7 driver, the MDC clock range up to
216 MHz and, on the F7, the MAC address from the unique ID.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: raiden00pl <raiden00@railab.me>
@raiden00pl
raiden00pl force-pushed the stm32-eth-refactor-upper-half branch from be39c05 to a9f4f97 Compare November 24, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Documentation Improvements or additions to documentation Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Port STM32 network drivers to common netdev upper-half

4 participants