summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2024-04-04 20:39:57 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-05 11:54:26 +0200
commit20ece44e01aa3faba86685db12293d00df9229ac (patch)
tree31b27e7b584d23cda3c24e8b3a99ebf4ccc6aaa9 /drivers/net
parentad753cf0f5ceeda48faf26e4d36b455f545fef75 (diff)
downloadbarebox-20ece44e01aa3faba86685db12293d00df9229ac.tar.gz
barebox-20ece44e01aa3faba86685db12293d00df9229ac.tar.xz
net: cpsw: report correct frame size to network stack
If the NIC reports that there is a computed CRC appended to the frame content, we need to subtract its size from the total length before passing that further down the network stack. This fixes a WARN_ON_ONCE reported by the network stack when built with #define DEBUG, because the expected size as indicated by the IP header is not the same as what's reported by the driver. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240404184001.1532897-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/cpsw.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 31ca61a230..3aafebaad4 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -51,10 +51,12 @@
#define CPDMA_DESC_EOP BIT(30)
#define CPDMA_DESC_OWNER BIT(29)
#define CPDMA_DESC_EOQ BIT(28)
+#define CPDMA_DESC_PASS_CRC BIT(26)
#define CPDMA_DESC_TO_PORT_EN BIT(20)
#define CPDMA_FROM_TO_PORT_SHIFT 16
#define CPDMA_RX_SOURCE_PORT(__status__) \
(((__status__) >> CPDMA_FROM_TO_PORT_SHIFT) & 0x7)
+#define CPDMA_DESC_CRC_LEN 4
#define SLIVER_SIZE 0x40
@@ -865,8 +867,11 @@ static int cpdma_process(struct cpsw_slave *slave, struct cpdma_chan *chan,
status = readl(&desc->hw_mode);
- if (len)
+ if (len) {
*len = status & 0x7ff;
+ if (status & CPDMA_DESC_PASS_CRC)
+ *len -= CPDMA_DESC_CRC_LEN;
+ }
if (dma)
*dma = readl(&desc->hw_buffer);