Skip to content

Commit b85cbb5

Browse files
committed
drivers: ethernet: adin2111: Add calculation of EBO in OA mode
Calculate the EBO properly, so the total frame written to TX FIFO does not exceed maximum Ethernet frame length. Makes the TCP stack to work properly, otherwise packets > 1472 are dopped, as they would be padded by 64 more bytes and hence exceed maximum Ethernet frame size. Signed-off-by: Maciej Panek <[email protected]>
1 parent e2f9e42 commit b85cbb5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/ethernet/eth_adin2111.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,25 @@ static int eth_adin2111_send_oa_frame(const struct device *dev, struct net_pkt *
351351
uint16_t clen, len = net_pkt_get_len(pkt);
352352
uint32_t hdr;
353353
uint8_t chunks, i;
354-
int ret, txc, cur;
354+
int ret, txc, cur, ebo;
355355

356356
chunks = len / ctx->oa_cps;
357357

358358
if (len % ctx->oa_cps) {
359359
chunks++;
360360
}
361361

362+
if (chunks > 1) {
363+
/* we have to calculate EBO so we do not exceed maximum Ethernet frame length */
364+
ebo = (len % ctx->oa_cps) - 1;
365+
if (ebo < 0) {
366+
ebo += ctx->oa_cps;
367+
}
368+
} else {
369+
/* we have to pad to the minimum Ethernet frame length */
370+
ebo = ctx->oa_cps - 1;
371+
}
372+
362373
ret = eth_adin2111_reg_read(dev, ADIN2111_BUFSTS, &txc);
363374
if (ret < 0) {
364375
LOG_ERR("Cannot read txc");
@@ -380,7 +391,7 @@ static int eth_adin2111_send_oa_frame(const struct device *dev, struct net_pkt *
380391
}
381392
if (i == chunks) {
382393
hdr |= ADIN2111_OA_DATA_HDR_EV;
383-
hdr |= (ctx->oa_cps - 1) << ADIN2111_OA_DATA_HDR_EBO;
394+
hdr |= ebo << ADIN2111_OA_DATA_HDR_EBO;
384395
}
385396

386397
hdr |= eth_adin2111_oa_get_parity(hdr);

0 commit comments

Comments
 (0)