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@xxxxxxxxxxxxxx> --- drivers/net/cpsw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index 31ca61a230e9..3aafebaad49d 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); -- 2.39.2