Hello,
I integrated the very last sources of the Ethernet stack to a project and I think that MAC driver file "EMAC_stm32f4xx.c" is now not compatible with IP fragmentation. When a UDP fragmented frame is sent, the UDP checksum is calculated by the stack because the offload calculation applies only on one Ethernet frame. But is such a case, UDP checksum calculation offload must be deactived to avoid a bad UDP checksum put in the last fragmented frame by hardware. I modified the file as follow in order to not crush the UDP checksum previously calculated by the software :
static int32_t SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags) { uint8_t *dst = Emac.frame_end; uint32_t ctrl; uint16_t fragOfs, prot; // Added to fix bug ... fragOfs = (((uint16_t)frame[20]) << 8) | frame[21]; // Added to fix bug prot = (((uint16_t)frame[12]) << 8) | frame[13]; // Added to fix bug ... #if (EMAC_CHECKSUM_OFFLOAD != 0) // Original code : // if (Emac.tx_cks_offload) { ctrl |= DMA_TX_CIC; } // Correction in case of fragmented frame : if ((prot == 0x0800) && ((fragOfs & (IP4_MF_FLAG | IP4_FRAG_MASK)) != 0) { // fragmented frame, only IP checksum is calculated if (Emac.tx_cks_offload) { ctrl |= DMA_TX_CIC & 0x00400000U; } }
Yes you're right. The problem exists also in fragmented ICMP checksum calculation. We will correct the drivers.