eth_mchp_get_stats() accesses the vendor member of struct net_stats_eth
as an embedded structure, but it is a pointer to an array of key-value
pairs. The driver fails to build with
CONFIG_NET_STATISTICS_ETHERNET_VENDOR=y.
The driver provides no vendor statistics and the pointer is already
NULL because the device data is zero-initialized, so remove the block.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
adin2111_port_send() declares the port data pointer when
CONFIG_NET_STATISTICS_ETHERNET is enabled, but nothing uses it since
commit 18c00a714f ("drivers: ethernet: remove redundant tx stats").
Building the driver with Ethernet statistics enabled fails with
-Werror=unused-variable.
Remove the variable.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The NXP S32K3 series integrates the same DWC Ethernet QoS controller as
the MCXE31x, with the same interrupt lines and clock domains and without
a reset line, but is described by the nxp,s32-gmac compatible and uses
the RTD HAL headers. Extend the driver to also support the S32K3 series.
The NXP S32 GMAC driver does not support PTP, so use the dwc_mac driver
by default on S32K3 if PTP support is required.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The NXP S32 GMAC MDIO driver was tied to the SoC family, so it was
enabled on any S32 SoC with a snps,dwmac-mdio node regardless of the
Ethernet driver in use. Depend on ETH_NXP_S32_GMAC instead, so the MDIO
driver is only built together with the S32 GMAC Ethernet driver and is
left out when the generic dwc_mac driver is selected, which brings its
own driver for the same node.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The transmit DMA runs with a single beat burst length and completes
each frame, including its transmit status writeback, before touching
the next descriptor. Every frame then pays descriptor and data fetch
latency as dead time on the wire. Raise the burst length to 16 beats
and enable operate on second frame so the DMA prepares the next frame
while the current one transmits. Measured on MCXN947 at 100 Mbit full
duplex this moves a saturating UDP upload from 84.8 to 95.5 Mbps of
goodput, the theoretical maximum for the wire at that frame size.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
The transmit path holds one frame in flight and rebuilds the
descriptor list on every send, so the wire idles between frames and
loaded senders see -EBUSY drops. Drive the descriptors as the
persistent ring the hardware supports: program the ring length once,
stage each frame at the head, advance the tail pointer, and reclaim
completed frames in order from the interrupt. The transmit watchdog
guards the oldest outstanding frame, the carrier-loss abort reclaims
every outstanding frame after the queue flush, and each frame reads
its PTP timestamp from its own last descriptor.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
use a mutex for the generic ethernet phy instead of a semaphore.
Benefit of the mutex is that it is recursive .
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
STM32MP13 uses a 32-bit AXI4 DMA bus master interface, not the 32-bit
AHB interface used by the other series with a 32-bit data bus. Reusing
the AHB DMA_SYSBUS_MODE value on STM32MP13 left the AXI4-only bits
(burst length and outstanding request limits) unset.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
smsc_write_tx_fifo() pads the last fragment up to a DWORD and copies
whole words out of the staging buffer, so a frame whose length is not a
multiple of four reads up to three bytes past the end of tx_buf. A
1514 byte frame, the largest one accepted, reads two bytes too far.
Size the buffer to the padded length instead.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
eth_tx() read net_pkt_get_len(pkt) bytes into a fixed
NET_ETH_MAX_FRAME_SIZE staging buffer without checking the length.
net_pkt_read() takes no destination size, so a packet larger than the
buffer overwrites memory behind it. The interface MTU is not bounded by
what the link can transmit (an IPv6 RA MTU option raises it up to 0xffff),
which makes such packets reachable from the network.
Drop oversized frames before any TX_DATA_PORT write, so the TX FIFO is
not left holding a command word without its payload.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The STM32 RCC applies a kernel clock source selection from
clock_control_on() now, so stop inspecting struct stm32_pclken to pick
between on() and configure() and enable every clocks entry the same way
in the HAL driver and in the DWC MAC glue.
Built for nucleo_h743zi with both drivers.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add a driver for the WIZnet W5100S standalone 10/100 Ethernet
controller with an SPI interface. The driver uses socket 0 in MACRAW
mode as the raw Ethernet MAC for the Zephyr networking stack.
The W5100S uses a flat register map with an opcode-first SPI frame and
supports N-byte burst read and write operations. Read link state from
PHYSR0 and program the source MAC after unlocking NETLCKR.
Add the concrete binding on top of the shared WIZnet Ethernet helper,
wire the build, extend build_all SPI coverage, and add the release note
entry for the new compatible.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
A failed read leaves its destination untouched, and every caller used
the value anyway. Check the reads and stop instead.
- wiznet_command(): S0_CR, the poll exit condition
- wiznet_tx(): S0_TX_WR, the TX ring offset
- wiznet_rx(): S0_RX_RSR and S0_RX_RD, the RX ring pointer, and the
frame body, which frees the packet it had already allocated
- wiznet_check_for_ir(): S0_IR, written back to clear the interrupt.
Reports no interrupt, so the poll thread checks the link instead
- wiznet_set_config(): S0_MR, written back to toggle MAC filtering
- w5500_init() and w6100_init(): RTR
- w6100_clear_pending(): SLIR, written back to clear the interrupt
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
The reset and interrupt lines come from the devicetree, so a build that
declares either needs the GPIO driver. Only the W6300 asked for it, and
it asked unconditionally.
Take GPIO on each controller when its own compatible carries one of the
two properties. The W6100 and the W6300 mark int-gpios required, so for
those the condition always holds.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
The WIZnet drivers carried identical thread, timeout and period options
under a per-chip prefix. Replace them with one ETH_WIZNET_ set.
The per-instance config then no longer needs to carry those values, so
read them where they are used and drop them from the device macro.
Only the reset timings stay in the struct, since those differ per chip.
Guard the shared options with ETH_WIZNET, which every driver in this
directory takes, rather than a list of the drivers that has to grow with
each new chip. ETH_WIZNET_CORE stays for the shared implementation,
which the W6300 does not use.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
Move the W6100 driver onto the shared MACRAW core and describe the
register and interrupt differences through the per-chip tables. The
build_all SPI overlay now covers the W6100 path.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
Add a shared MACRAW framework for the WIZnet standalone Ethernet
controllers and move the W5500 driver onto it.
The shared layer keeps the packet path and common control flow in one
place while the chip driver supplies the SPI framing and register layout.
This reduces the duplicated W5500-specific code without changing the
observable behavior of the driver.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
Move the existing W5500, W6100, and W6300 drivers under
`drivers/ethernet/wiznet` and route the parent Kconfig and CMakeLists.txt
through a vendor subdirectory.
Fold the per-chip Kconfig fragments into a single `wiznet/Kconfig` file so
the subtree matches the layout used by other vendor directories under
`drivers/ethernet`.
No functional change is intended.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
DWC Ethernet QoS cores from version 5.00 on can signal MDIO transaction
completion with a MAC interrupt. As it is optional in the IP
configuration, use it only if MDIOIE sticks after enabling it and poll
the busy bit otherwise.
Tested on frdm_mcxe31b, which supports the MDIO completion interrupt.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The VSC8541 MAC-interface pad edge rate depends on the VDDMAC supply
voltage and board-level signal-integrity requirements. The driver
currently leaves the setting at its reset default, so boards cannot
select the value recommended for their electrical design.
Add a microchip,pad-edge-rate devicetree property accepting values 0
through 7. Default it to 7 to preserve existing behavior, and program
the selected value into page 2 register 27 after the PHY software
reset.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
The generic dwc_mac driver handles the NuMaker EMAC, and both
in-tree boards now describe the MDIO controller and the PHY that it
needs. Remove the NuMaker Ethernet driver, its Kconfig option and the
phy-addr property that only it used.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
This driver accesses the PHY through the MAC itself and provides no
MDIO driver, so it cannot serve a devicetree with the MDIO node
enabled. Depend on that node being disabled, which leaves such boards
to the dwc_mac driver.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add a dwc_mac platform glue driver for the Synopsys DesignWare MAC
integrated in the Nuvoton NuMaker M467 and M55M1 SoCs, where the IP
is named EMAC.
When the devicetree carries no MAC address, the driver derives one
from the chip's unique ID read through hwinfo and spreads it over
the address the way the NuMaker Ethernet driver does, so a board
that relied on the generated address keeps the one it had.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add the platform glue that brings up the Synopsys DesignWare MAC found
on the RK3588, along with the rockchip,rk3588-gmac binding.
Bus init asserts the CRU reset line, programs the RGMII interface select,
clock direction and TX/RX delays through the system and PHP GRF syscon
regions, then deasserts reset. Because the RGMII transmit clock is
divided down in the PHP GRF instead of being driven by the MAC, the
divider is reprogrammed from the platform link speed change hook.
DMA descriptors use the linker nocache region. The driver depends on
64BIT and derives the GMAC instance id from the register address rather
than the devicetree instance number.
Signed-off-by: Yanzhao Cui <cuiyanzhao@kylinos.cn>
Some platforms feed the MAC from a clock whose divider depends on the
negotiated link speed, so that clock has to be reprogrammed every time
the PHY reports a new speed. There is currently no way for the platform
glue to learn about a speed change.
Add a dwmac_platform_link_speed_changed() hook, called by the QoS core
from the PHY link state callback right after MAC_CONF has been updated.
The default implementation is empty and weak, so platforms that do not
need it are unaffected.
Signed-off-by: Yanzhao Cui <cuiyanzhao@kylinos.cn>
The STM32C5 integrates the same DesignWare Ethernet MAC QoS IP core as
the H5 and H7 series, in version 5.40 with a 32-bit AHB master and MII
and RMII support, so the glue only has to select the PHY interface for
it.
The HAL based driver stays the default, unless PTP is enabled.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The MDIO driver derives the MDC divider from the MAC CSR clock, which
the glue took as the first entry of the devicetree clocks array. That
holds for every STM32 series supported so far, but ties the driver to
the order of a property whose entries are named.
Look the gate up by its "stm-eth" name instead, the way the PTP clock
index already does. Every in-tree ethernet node names it, so a series
that does not gets a build error rather than a silently wrong rate.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The STM32N6 integrates the DesignWare Ethernet MAC QoS IP core in
version 5.20, with MII, RMII and RGMII support and a 64-bit AXI4 master
instead of the 32-bit AHB master of the other series.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The bus mode register was left at its reset value, so the AHB master
issued undefined length bursts and did not align them. Utilize fixed
length bursts with address aligned beats instead.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The bus mode register was left at its reset value, so the AHB master
issued undefined length bursts and did not align them. Utilize fixed
length bursts with address aligned beats instead.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The bus mode register was left at its reset value, so the AHB master
issued undefined length bursts and did not align them. Utilize fixed
length bursts with address aligned beats instead.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The DMA bus mode register was only ever written for the software reset
and the descriptor size, which left the programmable burst length at
its reset value of one beat, so the DMA moved a single beat per bus
transaction. Set it to 32 beats, which is what the vendor drivers of
every platform this core supports use.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The slim ring buffer API is now header-only and always available and the
tree has already migrated from the _claim/_finish API, so the RING_BUFFER
symbol no longer gates any code.
Remove the now-redundant "select RING_BUFFER" and CONFIG_RING_BUFFER=y
entries across drivers, subsystems, samples and tests.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
RCTL.BAM (bit 15) is required for the 8254x MAC to accept Ethernet
broadcast frames. Multicast promiscuous mode (RCTL.MPE) does not cover
broadcasts, so ARP, DHCP and other broadcast traffic is dropped in
hardware.
Set RCTL_BAM when programming RCTL at interface bring-up. With this
change, QEMU e1000 in TAP mode can complete ARP/DHCP and pass traffic.
Signed-off-by: Yuan Bian <bianyuan@kylinos.cn>
The DMA master of this IP is AHB, so say so next to the data bus width
rather than giving the width alone.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Hold the Ethernet MAC in reset while the pads, the PHY interface and
the clocks are configured, and release it once the setup is done. The
PHY interface selection is sampled when the MAC leaves reset, so it
has to be in place before that.
The MCXE31x has no reset line for the MAC, so its clocks are gated for
the same purpose there.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The GEM driver cast pointers to and from uint32_t in several places,
which truncates on 64-bit targets such as the ZynqMP Cortex-A53 and
warns with -Wpointer-to-int-cast / -Wint-to-pointer-cast there.
Signed-off-by: Iustin Stolniceanu <iustin.stolniceanu@analog.com>
The HAL based stm32 ethernet driver has no support for PTP on the
stm32mp13, so use the dwc_mac driver when PTP support is needed,
like on the stm32f1, f2 and f4.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The STM32MP13 has two instances of the MAC, so rework the glue to
define a device per enabled devicetree instance, with the pins,
clocks, descriptor rings, MAC address configuration and interrupt in
a per-instance configuration wrapped around the core's one.
The PHY interface of each MAC is selected in SYSCFG_PMCSETR, which is
a set-only register with SYSCFG_PMCCLRR as its clear-only counterpart.
Both are written directly, as the PMCCLRR bits read back as the current
configuration and the read-modify-write the LL helpers do on it would
clear the bits of the other MAC. Which set of bits a MAC uses is
derived from its register address rather than its devicetree instance
number, so a board enabling only the second MAC keeps working. MII,
RMII and RGMII are supported, with st,ext-phyclk selecting the MAC
kernel clock as the RMII reference or RGMII 125 MHz clock.
The descriptor rings go into the nocache section like on the other
series, which the MMU maps strongly ordered, with the physical
addresses the core expects on MMU platforms filled in.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Thanks to the bindings reorganization, a variable is now generated
properly for `zephyr,dsa-port`: use it!
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
ETHER_EVENT_RX_COMPLETE is driven by the EDMAC's FR (Frame Received)
bit in EESR, a level/sticky status bit meaning "at least one frame
arrived", not a count. If several frames complete reception between
two interrupt services, the ISR still only gives rx_sem one credit.
The RX thread drained exactly one frame per credit, so under bursty
traffic completed-but-undrained frames piled up in the 8-entry RX
descriptor ring until it filled, causing the EDMAC to genuinely drop
incoming frames.
Drain the RX ring in a loop per wakeup instead of assuming one credit
equals one frame; the loop is inherently bounded by the ring size.
Also fix a related bug this exposed: renesas_ra_eth_rx() fell through
to call R_ETHER_RxBufferUpdate() with an uninitialized buffer pointer
whenever R_ETHER_Read() legitimately reported no data available; it
now returns NULL immediately in that case.
Signed-off-by: Henrik Maier <hwmaier@gmail.com>
renesas_ra_eth_tx() used k_sem_take(&ctx->tx_sem, K_NO_WAIT), so once
the TX descriptor ring filled up under sustained bulk traffic, every
subsequent send() returned -ENOBUFS immediately. Zephyr's net_if_tx()
only logs a rate-limited warning on a negative send() status and
drops the packet, with no retry or backoff. TCP was left to detect
and recover the loss itself via duplicate-ACK fast retransmit or,
when a burst overran the ring by more than one frame, a full RTO
timeout - both cap achievable throughput well below link rate.
Use K_MSEC(ETHER_TX_TIMEOUT_MS), a pre-existing but previously-unused
timeout constant, so the driver blocks briefly for a descriptor to
free up instead of dropping immediately. This gives real backpressure
so TCP's sending rate gets throttled to the actual link drain rate.
Signed-off-by: Henrik Maier <hwmaier@gmail.com>
renesas_ra_eth_tx() called R_ETHER_Write() twice for every packet:
once unconditionally, and again after taking the TX semaphore. The
first call bypassed the semaphore gate entirely, transmitting from
the buffer before the descriptor slot was actually reserved. Move
the semaphore take before the single R_ETHER_Write() call.
Signed-off-by: Henrik Maier <hwmaier@gmail.com>
The networking stack splits TCP transmit packets into separate
net_buf fragments for protocol headers and payload.
no memcopy TX in xilinx_axienet requires one DMA SG entry per fragment,
so the maximum fragment count must reflect how the stack actually
builds packets.
Signed-off-by: Venkatesh Odela <venkatesh.odela@amd.com>
A frame handed to the ENET QoS transmit DMA when the link goes down is
never written back, so the completion interrupt that returns the packet
and frees the single transmit slot never arrives. The slot stays taken
across the link coming back, every later send on the interface fails
with -EBUSY, and the packet and its fragments are gone from their pools
for good, so a handful of link transitions exhaust the buffer pool and
the interface stops transmitting.
Give the driver a claim and release pair so that completion and
abandonment race for the packet and exactly one of them returns it, and
arm a transmit watchdog, CONFIG_ETH_NXP_ENET_QOS_TX_TIMEOUT_MS, that
takes the descriptors back, flushes the transmit queue and reinitializes
the ring when the DMA does not finish. Abandon an outstanding frame from
the PHY callback on carrier loss, and program speed and duplex with the
transmitter and receiver disabled before the carrier is announced, so
the MAC configuration write cannot land on a frame the stack has already
handed to the DMA.
Publish the packet, arm the watchdog and start the DMA as one step under
irq_lock so an abort can never observe a half-built submission, and flush
the transmit queue with a bounded wait.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Every RX descriptor writeback clobbers RDES0, which in read format is
the buffer address: the writeback formats alias it with the VLAN tag or
the timestamp low word. The success path restores it before handing the
descriptor back to the DMA, but the four drop paths (errored frame,
packet alloc failure, bad length, fragment alloc failure) re-arm the
descriptor with whatever the writeback left there, so the next use of
that slot makes the DMA write into flash or reserved address space and
receive stops permanently. Restore the reserved buffer's address on
every drop path, as the success path does.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Add support for the Analog Devices ADIN1140 10BASE-T1S MAC-PHY:
ethernet driver, MDIO bus driver and PHY driver.
Signed-off-by: Raluca Bozdog <raluca.bozdog@analog.com>
Co-authored-by: Jason Murphy <jason.murphy@analog.com>
Advertise ETHERNET_HW_VLAN when CONFIG_NET_VLAN is enabled. The
capability is an acceptance gate that permits VLAN interfaces on the
iface. The L2 keeps inserting the tag in software, so the transmit
path needs no offload change.
Account for the four extra bytes a single VLAN tag adds to a frame in
the transmit size cap and the receive buffer capacity assert. The MAC
recognizes the VLAN type and extends its own receive length limit by
the same four bytes, so no length register needs adjusting.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Enable the receive checksum offload engine through the MAC_CONFIGURATION
IPC bit so the MAC verifies the IPv4 header and the TCP and UDP checksums
of incoming frames, and advertise ETHERNET_HW_RX_CHKSUM_OFFLOAD so the
stack does not repeat the check in software. Because the stack then trusts
the offload, drop any frame the engine flags with an IP header or payload
checksum error in the RDES1 write-back status, which is valid only when
the receive status word is present.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>