Skip to content

Commit

Permalink
drivers: ethernet: adin2111: Proper calculation of EBO in eth_adin211…
Browse files Browse the repository at this point in the history
…1_send_oa_frame

Calculate the EBO correctly, 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]>
  • Loading branch information
panekmaciej committed Aug 30, 2024
1 parent 6ead73d commit 7625880
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/ethernet/eth_adin2111.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,24 @@ static int eth_adin2111_send_oa_frame(const struct device *dev, struct net_pkt *
uint16_t clen, len = net_pkt_get_len(pkt);
uint32_t hdr;
uint8_t chunks, i;
int ret, txc, cur;
int ret, txc, cur, ebo;

chunks = len / ctx->oa_cps;

if (len % ctx->oa_cps) {
chunks++;
}

Check failure on line 361 in drivers/ethernet/eth_adin2111.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

drivers/ethernet/eth_adin2111.c:361 trailing whitespace
if (chunks > 1) {
//we have to calculate EBO so we do not exceed maximum Ethernet frame length

Check failure on line 363 in drivers/ethernet/eth_adin2111.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

drivers/ethernet/eth_adin2111.c:363 do not use C99 // comments
ebo = (len % ctx->oa_cps) - 1;
if (ebo < 0) {
ebo += ctx->oa_cps;
}
} else {
//we have to pad to the minimum Ethernet frame length

Check failure on line 369 in drivers/ethernet/eth_adin2111.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

drivers/ethernet/eth_adin2111.c:369 do not use C99 // comments
ebo = ctx->oa_cps - 1;

Check notice on line 370 in drivers/ethernet/eth_adin2111.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/ethernet/eth_adin2111.c:370 - + if (chunks > 1) { - //we have to calculate EBO so we do not exceed maximum Ethernet frame length + // we have to calculate EBO so we do not exceed maximum Ethernet frame length ebo = (len % ctx->oa_cps) - 1; if (ebo < 0) { ebo += ctx->oa_cps; } } else { - //we have to pad to the minimum Ethernet frame length + // we have to pad to the minimum Ethernet frame length
}

ret = eth_adin2111_reg_read(dev, ADIN2111_BUFSTS, &txc);
if (ret < 0) {
Expand All @@ -380,7 +391,7 @@ static int eth_adin2111_send_oa_frame(const struct device *dev, struct net_pkt *
}
if (i == chunks) {
hdr |= ADIN2111_OA_DATA_HDR_EV;
hdr |= (ctx->oa_cps - 1) << ADIN2111_OA_DATA_HDR_EBO;
hdr |= ebo << ADIN2111_OA_DATA_HDR_EBO;
}

hdr |= eth_adin2111_oa_get_parity(hdr);
Expand Down

0 comments on commit 7625880

Please sign in to comment.