Skip to content

Commit d8c0a67

Browse files
GeorgeCGVMaureenHelm
authored andcommitted
drivers: ethernet: adin2111: fix generic spi frame reception
Fixes a bug that results in double RX buffer read from ADIN when generic SPI protocol is used. Actual frame size to be read must be RX_FSIZE - HEADER. If we read less amount of bytes, then ADIN raises an IRQ or signals via Pn_RX_RDY that there is another frame available, as we fail to read the whole frame. The fix for "Still some length to go 2" is still present, we drop the CRC32 bytes from the frame prior allocation and network stack pass. Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
1 parent 42b116e commit d8c0a67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/ethernet/eth_adin2111.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ static int adin2111_read_fifo(const struct device *dev, const uint16_t port_idx)
557557

558558
/* burst read must be in multiples of 4 */
559559
padding_len = ((fsize % 4) == 0) ? 0U : (ROUND_UP(fsize, 4U) - fsize);
560-
/* actual frame length is FSIZE - FRAME HEADER - CRC32 */
561-
fsize_real = fsize - (ADIN2111_FRAME_HEADER_SIZE + sizeof(uint32_t));
560+
/* actual available frame length is FSIZE - FRAME HEADER */
561+
fsize -= ADIN2111_FRAME_HEADER_SIZE;
562562

563563
/* spi header */
564564
*(uint16_t *)cmd_buf = htons((ADIN2111_READ_TXN_CTRL | rx_reg));
@@ -574,7 +574,7 @@ static int adin2111_read_fifo(const struct device *dev, const uint16_t port_idx)
574574
const struct spi_buf tx_buf = { .buf = cmd_buf, .len = sizeof(cmd_buf) };
575575
const struct spi_buf rx_buf[3] = {
576576
{.buf = NULL, .len = sizeof(cmd_buf) + ADIN2111_FRAME_HEADER_SIZE},
577-
{.buf = ctx->buf, .len = fsize_real},
577+
{.buf = ctx->buf, .len = fsize},
578578
{.buf = NULL, .len = padding_len }
579579
};
580580
const struct spi_buf_set tx = { .buffers = &tx_buf, .count = 1U };
@@ -590,6 +590,9 @@ static int adin2111_read_fifo(const struct device *dev, const uint16_t port_idx)
590590
return ret;
591591
}
592592

593+
/* remove CRC32 and pass to the stack */
594+
fsize_real = fsize - sizeof(uint32_t);
595+
593596
pkt = net_pkt_rx_alloc_with_buffer(iface, fsize_real, AF_UNSPEC, 0,
594597
K_MSEC(CONFIG_ETH_ADIN2111_TIMEOUT));
595598
if (!pkt) {

0 commit comments

Comments
 (0)