From 6423b4cbb966a3617eff32d245e806bb12bc26da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Tue, 21 Feb 2023 16:27:04 +0100 Subject: [PATCH] rt1020 driver check frame crc/truncated (#2080) Co-authored-by: Jean-Francois Simon --- src/tcpip/driver_nxpimxrt1020.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/tcpip/driver_nxpimxrt1020.c b/src/tcpip/driver_nxpimxrt1020.c index f2cbe3d1..5a677d52 100644 --- a/src/tcpip/driver_nxpimxrt1020.c +++ b/src/tcpip/driver_nxpimxrt1020.c @@ -1,4 +1,11 @@ -#include "mip.h" +#include "tcpip.h" + +/* + * Todo + * This driver doesn't support 10M line autoconfiguration yet. + * Packets aren't sent if the link negociated 10M line. + * todo: MAC back auto reconfiguration. + */ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_IMXRT1020) struct imx_rt1020_enet { @@ -231,8 +238,11 @@ void ENET_IRQHandler(void) { else { // Frame received, loop for (uint32_t i = 0; i < 10; i++) { // read as they arrive but not forever if (rx_buffer_descriptor[s_rt1020_rxno].control & BIT(15)) break; // exit when done - uint32_t len = (rx_buffer_descriptor[s_rt1020_rxno].length); - mg_tcpip_qwrite(rx_buffer_descriptor[s_rt1020_rxno].buffer, len > 4 ? len - 4 : len, s_ifp); + // Process if CRC OK and frame not truncated + if (!(rx_buffer_descriptor[s_rt1020_rxno].control & (BIT(2) | BIT(0)))) { + uint32_t len = (rx_buffer_descriptor[s_rt1020_rxno].length); + mg_tcpip_qwrite(rx_buffer_descriptor[s_rt1020_rxno].buffer, len > 4 ? len - 4 : len, s_ifp); + } rx_buffer_descriptor[s_rt1020_rxno].control |= BIT(15); // Inform DMA RX is empty if (++s_rt1020_rxno >= ENET_RXBD_NUM) s_rt1020_rxno = 0; }