2009-10-05 09:14:53     bfin_mac: checksum offloading ignored?

Document created by Aaronwu Employee on Aug 19, 2013
Version 1Show Document
  • View in full screen mode

2009-10-05 09:14:53     bfin_mac: checksum offloading ignored?

Stefan Wanja (GERMANY)

Message: 80834   

 

Hello,

 

we are having dropped packets due to checksum errors in the kernel. We are still wondering why we get those, but while digging into the code we saw, that the hardware supplied checksum is ignored in pskb_trim_rcsum because the length of the skb is always 4 more, than the given length in the ip header. This leads to a complete recalculation of the checksum, which seems like a huge waste of processing power.

 

The 4 extra bytes in the length are probably the ethernet FCS, which is also copied by the hardware. This again is not needed for the tcp checksum.

 

Does anybody know, why the hardware checksum is discarded? Is this on purpose or a bug?

 

We are using the uclinux-dist 2009R1-RC6 release and a bf527.

 

Kind regards,

 

Stefan

QuoteReplyEditDelete

 

 

2009-10-05 11:13:29     Re: bfin_mac: checksum offloading ignored?

Robin Getz (UNITED STATES)

Message: 80851   

 

Stefan:

 

The person who wrote that code is out for a few more days - back on Friday.

 

-Robin

QuoteReplyEditDelete

 

 

2009-10-13 06:54:33     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81139   

 

This is because the ASTP bit is not set in bfin_mac OPMODE register. So, both FCS and padding may be copied to skb.

 

I would try to set this bit to see any difference.

QuoteReplyEditDelete

 

 

2009-10-14 05:48:15     Re: bfin_mac: checksum offloading ignored?

Stefan Wanja (GERMANY)

Message: 81196   

 

The processor documentation of the bf527 says, that ASTP strips only frames that are shorter than 64 Byte and have no special type. So we can not use this to get rid of the FCS.

 

Can't we just subtract the FCS from length and checksum?

 

Anyway, when we get to the point where we can use the hardware generated checksum, we get to a problem when the error blackfin.uclinux.org/gf/project/uclinux-dist/forum/ occurs. Because then TCP wouldn't even realize that the checksum doesn't suit the data and violate it's end to end guarantee.

 

So as long as the other bug exists, it should not be used.

 

Kind regards,

 

Stefan

QuoteReplyEditDelete

 

 

2009-10-14 06:04:56     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81197   

 

The HRM says:

 

If ASTP = 1, both the pad and the FCS bytes are removed from the received data.

 

Frame length (RX_FRLEN)

The number of bytes in the frame. If the ASTP bit is set, the pad and FCS are not included in the length.

 

 

 

But, actually this bit doesn't remove the extra 4 bytes you saw. It looks the HRM doesn't tell the truth?

QuoteReplyEditDelete

 

 

2009-10-14 06:10:39     Re: bfin_mac: checksum offloading ignored?

Stefan Wanja (GERMANY)

Message: 81198   

 

My document (ADSP-BF52x Blackfin Processor Hardware Reference, page 19-18) says exactly the following:

 

RX Automatic Pad Stripping

If the ASTP bit in the MAC operating mode register is set, the pad bytes

and FCS are stripped from any IEEE-type frame which was lengthened

(padded) to reach the minimum Ethernet frame length of 64 bytes. This

applies to frames where the Ethernet length/type field is less than 46 bytes,

since the Ethernet header and FCS add 18 bytes. When pad stripping

occurs, only the first Length/Type + 14 bytes are written to memory via

DMA, and the frame length reported in the RX status register and in the

RX status DMA buffer will be Length/Type + 14 rather than the actual

number of received bytes.

Pad bytes are never stripped from typed Ethernet frames. Typed Ethernet

frames are frames with a length/type field that takes the type interpretation

because it is greater than or equal to 0x600 (1536).

 

Yeah, but as you have said, the bits are not removed (which is correct with this specification).

QuoteReplyEditDelete

 

 

2009-10-14 06:43:00     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81199   

 

Frame length (RX_FRLEN)

The number of bytes in the frame.

 

 

 

The HRM doesn't say if the RX_FRLEN includes the FCS or not clearly. This is still a problem of the HRM.

QuoteReplyEditDelete

 

 

2009-10-14 06:53:31     Re: bfin_mac: checksum offloading ignored?

Stefan Wanja (GERMANY)

Message: 81200   

 

Yes, it is unclear there. But on page 19-14 it says:

 

Frame Reception and Filtering

Frame data written to memory normally includes the Ethernet header

(destination MAC address, source MAC address, and length/type field),

the Ethernet payload, and the Frame Check Sequence (FCS) checksum,

but not the preamble. If the RXDWA bit in EMAC_SYSCTL is 1, then the first

16-bit word is all-zero to pad the frame.

 

Here it says, that the FCS is part of the written data...

QuoteReplyEditDelete

 

 

2009-10-15 00:32:00     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81225   

 

Frame length (RX_FRLEN)

The number of bytes in the frame.

 

Actually the RXFRLEN doesn't include the other part of the written data " Ethernet header". So, part of the written data doesn't mean part of the len.

QuoteReplyEditDelete

 

 

2009-10-16 02:29:31     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81322   

 

I just figure out the extra 4 byte in skb->len is not a bug. The hardware generated ip payload checksum on bfin mac includes these extra 4 bytes. Current implementation just forewards the checksum to up stack as well as the length used to generate the checksum correctly, although this doesn't help to save processor power.

 

So, the feature to add hardware generated ip payload checksum support to bfin mac driver is not done. I will reopen this task.

QuoteReplyEditDelete

 

 

2009-10-16 09:05:57     Re: bfin_mac: checksum offloading ignored?

Stefan Wanja (GERMANY)

Message: 81361   

 

Yes, thank you for getting back in this. I think just subtracting the FCS from the hardware generated checksum together with reducing the length by 4 Byte should be all that is to do.

 

Kind regards,

 

Stefan

QuoteReplyEditDelete

 

 

2009-10-19 04:56:43     Re: bfin_mac: checksum offloading ignored?

Sonic Zhang (CHINA)

Message: 81429   

 

Yes. Both should be deduced.

Attachments

    Outcomes