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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>