Subject: Re: [PATCH v3] Renesas Ethernet AVB driver

From: Sergei Shtylyov <[email-masked]>
Date: Fri, 24 Apr 2015 21:27:03 +0300

On 04/24/2015 12:03 PM, David Laight wrote:

>> Sent: 22 April 2015 22:39
>> On 04/22/2015 11:42 PM, David Miller wrote:

>>>>      Hmm, I've been digging in the net core, and was unable to see where TX
>>>>      skb's get their NET_IP_ALIGN bytes reserved. Have I missed something?
>>>>      Probably need to print out skb's fields...

>>> NET_IP_ALIGN is for receive, not transmit.

>>      But when I print 'skb->data' from the ndo_start_xmit() method (in the
>> 'sh_eth' driver), all addresses end with 2, so it looks like NET_IP_ALIGN gets
>> added somewhere...

> For a locally generated message:
> The TCP userdata is likely to be 4 byte aligned.
> The TCP and IP headers are multiples of 4 bytes.
> The MAC header is 14 bytes.
> So you end up with a buffer that starts on a 4n+2 boundary or an initial
> short fragment that is 4n+2 bytes long.

> If a message is being forwarded the alignment probably depends on where
> it came from.

    Thanks for the detailed reply, though it came a bit late. :-)

> If you have ethernet hardware that requires tx or rx buffers to be on

    The RX buffers can be adjusted with skb_resrerve(), it's only the TX 
buffers that need to be copied...

> 4n boundaries you should send it back as 'not fit for purpose'.

    I'm afraid we can't. :-)
    However, my colleague has suggested a scheme minimizing the copying:
only up to 3 first bytes need to be copied to the driver's internal buffers, 
the rest can be sent from an skb itself. That would require substantial 
changes to the driver though...

> 	David

WBR, Sergei