Commit graph zephyr/drivers/ethernet
Author SHA1 Message Date
Benjamin Cabé
95ce9e7bb4 drivers: ethernet: w6100: Skip no-op SLIRCLR write
SLIRCLR is write-1-to-clear, so writing zero clears nothing. Skip the
SPI write when slir is zero.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-23 17:16:19 -07:00
Fin Maaß
680606c525 drivers: ethernet: don't use NET_ETH_PTYPE_PTP for timestamping
As we now use net_pkt_set_tx_timestamping for
every tx packet that needs timestamping,
we no longer need to also check if the ptype is
NET_ETH_PTYPE_PTP.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-23 18:15:38 +02:00
Benjamin Cabé
cd2fb185ac drivers: ethernet: sy1xx_mac: Use memcpy for TX linearize
Replace the byte-at-a-time per-fragment linearization loop with memcpy
and an equivalent up-front bounds check.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:58 +01:00
Benjamin Cabé
055c4bb8c0 drivers: ethernet: sy1xx_mac: Use memcpy for TX DMA copy
Replace the byte-at-a-time copy into the TX DMA buffer with memcpy.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:58 +01:00
Benjamin Cabé
5bfb26c0b1 drivers: ethernet: numaker: Cache last-descriptor check
Call synopGMAC_is_last_tx_desc() once and reuse the result instead of
evaluating it twice with identical arguments.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:48 +01:00
Benjamin Cabé
1f9200b6aa drivers: ethernet: wch: Snapshot RX descriptor status
Read the volatile RX descriptor status word once per frame and reuse
it. After OWN reads clear, the descriptor is CPU-owned and stable.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:34 +01:00
Benjamin Cabé
0c1f3e3133 drivers: ethernet: adin2111: Zero only the TX buffer pad
The whole SPI burst buffer was cleared even though the header and
payload are written unconditionally afterwards. Zero only the trailing
pad.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:22 +01:00
Benjamin Cabé
45a4e5b224 drivers: ethernet: adin2111: Hoist loop-invariant OA RX header
The OA data chunk header is constant across chunks. Compute it once
before the loop instead of on every iteration; the transmitted bytes
are unchanged.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:22 +01:00
Benjamin Cabé
d34c1c7295 drivers: ethernet: oa_tc6: Hoist loop-invariant RX header
The RX chunk request header is constant across chunks. Compute it once
before the receive loop; the SPI traffic is unchanged.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:12 +01:00
Benjamin Cabé
29d8ba7f01 drivers: ethernet: mchp_gmac_g1: Collapse RX descriptor writes
Replace the three read-modify-write operations on the RX descriptor
address word with one read and write producing the same value.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 14:12:01 +01:00
Venkatesh Odela
91d808ec34 drivers: mdio: xlnx_gem: extend MDIO idle timeout
Replace fixed retry polling (~500 us) with WAIT_FOR() and a configurable
idle timeout defaulting to 1 s, so slow PHY bring-up on some platforms
can complete before read/write operations fail with -ETIMEDOUT

Signed-off-by: Venkatesh Odela <venkatesh.odela@amd.com>
2026-07-22 11:04:37 +01:00
Fin Maaß
3df5fa4d3f drivers: ethernet: stm32: ptp: use BUILD_ASSERT
use BUILD_ASSERT for checking constant values.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-21 14:10:18 -04:00
Fin Maaß
a87d486e19 net: ethernet: remove ETHERNET_PTP from caps
net_eth_get_ptp_clock can be used instead to
check if ptp is supported, so remove ETHERNET_PTP.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-21 14:07:22 -04:00
Benjamin Cabé
e88ca1047e drivers: ethernet: xmc4xxx: Cache RX fragment in refill
Read dev_data->rx_frag_list[tail] once into a local when preparing
each RX DMA descriptor instead of dereferencing it twice.

Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-21 10:17:17 -04:00
Venkatesh Odela
51643b9984 drivers: ethernet: xilinx_axienet: avoid memcpy in TX and RX path
TX path: build a dma_block_config chain from net_pkt->frags and pass it
directly to dma_config(), eliminating net_pkt_read() into a static
buffer.

RX path: reserve one networking-stack net_buf per RX DMA descriptor via
net_pkt_get_reserve_rx_data(); on completion link the buf into a net_pkt
via net_pkt_frag_add() and pass it to net_recv_data() without memcpy.

Signed-off-by: Venkatesh Odela <venkatesh.odela@amd.com>
2026-07-20 16:44:16 -05:00
Fin Maaß
89526b5fe1 drivers: ethernet: dw_mac: split checksum
split the checksum Kconfigs into a user
changable Kconfig and a hidden one, that
will have the combined status, which we
then use in the driver. That way we don't
include the checksum offloading stuff,
when we don't need it.

Signed-off-by: Fin Maaß <info@finmaass.de>
2026-07-20 08:34:07 -05:00
Fin Maaß
db0ea8068f drivers: ethernet: dwc_mac: 1000: put two fragments in tx desc
put two tx fragments in one descriptor.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-20 08:34:07 -05:00
Fin Maaß
82de44bb89 ethernet: dwc_mac: 1000: use ring mode
use ring mode for the 1000 mac.

Signed-off-by: Fin Maaß <info@finmaass.de>
2026-07-20 08:34:07 -05:00
Fin Maaß
cde893abe1 drivers: dwc_mac: use a fifo for keeping the reference in tx
as net_pkt_frag_ref, will not only unref
the current net buf but also all net bufs
after it, we are now keeping the reference of the
net_pkt.
This will also make it easier to add ptp support later,
because there we need the net_pkt at that point.
the ptp code btw also uses a k_fifo for it.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-20 08:34:07 -05:00
Fin Maaß
b08c81d954 drivers: dwc_mac: 1000: try refill in irq
try refilling rx in the interrupt if possible

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-20 08:34:07 -05:00
Fin Maaß
0bfee83f10 drivers: ethernet: dwc_mac: rename REG_READ/WRITE
rename REG_READ/WRITE to DWMAC_REG_READ/WRITE,
so we don't have conflicts, like we got on the esp32.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-20 08:34:07 -05:00
Philipp Steiner
ad90d7c6d7 net: sockets: packet: require RX timestamp marker
Make AF_PACKET SO_TIMESTAMPING reporting depend only on
net_pkt_is_rx_timestamping(). This removes the timestamp-value heuristic
and makes the RX timestamp marker the single source of truth for whether
packet timestamp control data is valid.

Update in-tree Ethernet drivers that store RX timestamps to set the marker
before handing packets to the stack, and document the migration requirement
for out-of-tree drivers. Keep test coverage for the unmarked-packet case so
unmarked timestamps are not reported to socket applications.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-07-20 08:29:24 -05:00
Philipp Steiner
0fef1a0059 drivers: ethernet: stm32: reject stale PTP RX timestamps
The STM32 HAL keeps the last RX timestamp in its RX descriptor list. If a
later packet has no RX timestamp context descriptor,
HAL_ETH_PTP_GetRxTimestamp() can return the previously cached value and
make Zephyr mark the packet as timestamped with stale data.

Poison the HAL RX timestamp cache before HAL_ETH_ReadData() and only accept
the timestamp if the HAL refreshes it with a non-sentinel value for the
packet currently being processed. This bases timestamp validity on
descriptor state instead of PHC age, which can falsely reject valid
timestamps when RX handling is delayed under heavy traffic.

PTP timestamping can consume an additional RX context descriptor on
STM32H5, so make the RX descriptor count configurable there and default it
to 8 when the STM32 PTP clock is enabled. Also select no-cache memory for
STM32 Ethernet whenever the architecture supports it.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-07-20 08:29:24 -05:00
Fin Maaß
05ddfe5926 ethernet: xmc4xxx: remove checking phy
remove checking phy dev in
init. the phy is only needed in the iface init,
and the iface init doesn't check if the
regular init was successfull.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-16 10:43:34 -04:00
Anas Nashif
9416429ab2 drivers: eth: w6100: reject header <= 2 before length subtraction
Same underflow as eth_w5500: a device-supplied header of 0-2 wraps
rx_len to a huge value. Reject before subtracting.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-16 14:29:09 +02:00
Anas Nashif
b7c7ec3259 drivers: eth: enc28j60: reject short RSV frame length before subtraction
frm_len = sys_get_le16(info) - 4 underflows to ~65532 when the
status-vector length is <= 4, causing enc28j60_read_packet to allocate
and copy ~64 KB. Reject the frame when the length is too small to hold
the CRC.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-16 14:29:09 +02:00
Anas Nashif
2fcee0dbff drivers: eth: adin2111: bound RX fsize against DMA buffer size
The FSIZE register is 32-bit and was used directly as the SPI burst-read
length into ctx->buf (sized CONFIG_ETH_ADIN2111_BUFFER_SIZE). A large
device-reported value could overflow the buffer.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-16 14:29:09 +02:00
Anas Nashif
7c4ea9a9d5 drivers: eth: w5500: reject header <= 2 before length subtraction
The header value read from the chip was used as-is in:
  rx_len = sys_get_be16(header) - 2
A value of 0, 1, or 2 underflows the uint16_t, causing an extremely
large allocation followed by a NULL fragment dereference.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-16 14:29:09 +02:00
Tony Han
dae6d18e5c drivers: ethernet: sam_gmac: fix phy-connection-type value for rgmii
The value 2 of "phy-connection-type" is for "gmii" and it is misused
for "rgmii".
Fix the value the driver and update "phy-connection-type" from "gmii"
to "rgmii" in the dts file for sama7g54-ek board.

Signed-off-by: Tony Han <tony.han@microchip.com>
2026-07-14 09:51:19 -04:00
Tim Pambor
7a620d9d87 ethernet: dwc_mac: do not discard pkts with dribbling error
Packets with dribbling error flag set but with valid CRC
should not be discarded, as they are valid.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-07-10 08:54:44 -05:00
Fin Maaß
8b95b99ce0 drivers: ethernet: stm32: combine mac addr load
loading the mac address for stm32 is
the same for all 4 stm32 ethernet drivers,
combine that into a shared function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-09 10:34:27 -05:00
Fin Maaß
2501329f25 drivers: ethernet: dwc_mac: add vlan support
add vlan support to the dwc_mac drivers.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-08 17:18:14 +01:00
Fin Maaß
f0a64261dc drivers: ethernet: dwc_mac: 1000: make sure last bit is not removed
When enabling CONFIG_NET_L2_ETHERNET_RESERVE_HEADER
and increasing CONFIG_NET_BUF_DATA_SIZE a net_pkt can
just contain one fragment, for that we need to make sure, that
the first and last bit can be set at the same time.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-08 09:56:32 +02:00
Alberto Escolar Piedras
a148f403a7 drivers: ethernet: sensry: Remove unused variable
The variable ret was not used, and the compiler warned as much.
Let's just remove it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-07-06 15:09:28 -04:00
Tim Pambor
da7c9df028 ethernet: dwc_mac: collect ethernet stats
Support collection of the most common ethernet statistics.
This currently does not utilize any hardware statistics counters,
but rather collects the stats in software.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-07-06 11:30:11 -04:00
Himanshu Seth
441d734e0a drivers: ethernet: microchip: Add G1 Ethernet Driver
Add G1 Ethernet driver for Microchip Ethernet Peripherals.

Signed-off-by: Himanshu Seth <himanshu.seth@microchip.com>
2026-07-01 05:21:40 -04:00
Himanshu Seth
900b43641b drivers: mdio: microchip: Add G1 MDIO Driver
Add G1 Mdio driver for Microchip MDIO Peripherals.

Signed-off-by: Himanshu Seth <himanshu.seth@microchip.com>
2026-07-01 05:21:40 -04:00
Fin Maaß
d37c847222 drivers: ethernet: esp32: align dt structure
align the devicetree structure
with the recently added more generic
Synopsys ethernet driver, as the esp32
also uses the same IP from Synopsys, so we
can add support for the esp32 in that driver
easier.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-30 18:22:15 -04:00
Erwan SZYMANSKI
5ef4eaea55 drivers: ethernet: eth_stm32_hal_common: cleanup clang-format
Pass the file in clang-format to clean it up

Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
2026-06-30 18:21:43 -04:00
Erwan SZYMANSKI
c8340837d8 drivers: ethernet: eth_stm32_hal_common: multi instances support
Adapt the driver to support Ethernet controller multi instances.
This adaptation is aligned with Zephyr method used for other
drivers.
Now, for each MAC node in DT targetting this driver, a probe
will be processed while a single one was done before.

Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
2026-06-30 18:21:43 -04:00
Erwan SZYMANSKI
6908e87bde drivers: ethernet: eth_stm32_hal_common: switch REF_CLK macro to generic
The STM32 ETH HAL for STM32MP13 will be corrected in the following PR:
https://github.com/zephyrproject-rtos/hal_stm32/pull/366

As we want to have a "instance agnostic" approach on each Ethernet
controller device reference, we need to avoid to point on ETH1, ETH2
or more generally ETHx registers. This is up to the HAL to handle it.

Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
2026-06-30 18:21:43 -04:00
Erwan SZYMANSKI
b9dc330f6d drivers: ethernet: eth_stm32_hal_common: remove unused random MAC
To prepare the multi instances implementation of eth_stm32_hal
drivers, singletons implementations are cleaned.
Removes this portion of code handling the
zephyr,random-mac-address DT property because it is unused and
managed directly in the framework now.

Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
2026-06-30 18:21:43 -04:00
Erwan SZYMANSKI
aa991e8330 drivers: ethernet: eth_stm32_hal: Rework static buf, desc and phy
To prepare the support of the second Ethernet port, need to
remove some static declarations of phy_dev, dma_buf or dma_desc
present in the original code.
The best option here is to pass more elements in
eth_stm32_hal_dev_cfg and eth_stm32_hal_dev_data to better
handle it in v1 and v2 APIs.

When multi instance will be completed, we will have to get
the ressources owned by each eth device reference, this is the
reason of this implementation.

Important: for SoC reference supporting multiple Ethernet ports
(this is the case for the STM32MP13), some HAL functions
prototypes differs. This is what is managed in the original
driver by using STM32_ETH_ARGS macro. We complete this by
implementing ETH_STM32_HAL_GET_CB_DEVDATA macro. The goal of
this one is to point either on the right dev_data reference
in multi instance API case, or to point on a static dev_data
reference if singleton API is used.

Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
2026-06-30 18:21:43 -04:00
Etienne Carriere
5ac025caa8 drivers: ethernet: stm32: Clean MAC address size assertions
Remove the assertion in eth_stm32_hal_v1.c recently introduce between byte
array sizes storing MAC address value. It was useless since both byte
array sizes are based on NET_ETH_ADDR_LEN macro. Moreover the assertion
may produce a build warning as reported (and fixed) in eth_stm32_hal_v2.c
by commit 0ee22dc998 ("drivers: ethernet: stm32: fix clang error").

Factorize the 2 build assertions in eth_stm32_hal2.c with an explicit
comment why it's used.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 11:54:09 -04:00
Fin Maaß
60f93b475d ethernet: dwc_mac: 1000: add hardware checksum offloading
add support for hardware checksum offloading for the
dwc_ether_mac10_100_1000_universal core.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-29 14:04:40 -05:00
Fin Maaß
0e6098bd3d drivers: ethernet: dwc_mac: 1000: frag pointer in struct dwmac_priv
put the grag pointer inside the cached struct dwmac_priv.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-29 14:04:40 -05:00
Philipp Steiner
01e00a5ae1 drivers: ethernet: stm32: skip HAL restart on link down
Handle PHY link-down callbacks by clearing the network carrier and
returning before changing MAC/HAL state. Keep the HAL stop/config/start
sequence for link-up events where speed or duplex may have changed.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-06-29 13:58:09 -05:00
Immo Birnbaum
8194fe082b drivers: ethernet: xlnx_gem: remove legacy MDIO/PHY code
Remove the legacy MDIO and PHY support for the GEM MAC which
dates back to 2021 and doesn't use the MDIO/PHY frameworks
provided by Zephyr nowadays, as those didn't exist back then.

Signed-off-by: Immo Birnbaum <mail@birnbaum.immo>
2026-06-27 18:47:26 +02:00
Immo Birnbaum
fd9cd01ef7 drivers: ethernet: xlnx_gem: switch over to new MDIO driver
Remove all data/functions/function calls relating to the now
removed legacy MDIO/PHY support directly integrated into the
GEM device driver. Switch over to using the standard MDIO/PHY
interfaces which will now refer to the new separate MDIO
driver and the separated PHY drivers.

Consistently update the qemu_cortex_a9 board definition with
the matching MDIO and PHY nodes, qemu_cortex_a9 is currently
the only Zynq-based target where an enabled GEM instance is
specified by default.

Signed-off-by: Immo Birnbaum <mail@birnbaum.immo>
2026-06-27 18:47:26 +02:00
Immo Birnbaum
92c799f65a drivers: mdio: add MDIO driver for Xilinx GEM
Separate the MDIO functionality from the Xilinx GEM MAC driver
into a separate driver conforming with the standard MDIO API.

Signed-off-by: Immo Birnbaum <mail@birnbaum.immo>
2026-06-27 18:47:26 +02:00