lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] byte alignment


From: Tyrel Newton
Subject: [lwip-users] byte alignment
Date: Mon, 03 May 2010 23:18:38 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4

For the system I'm using, when an Ethernet frame is transmitted, it has to be copied into a 32-bit aligned contiguous buffer within the mac. This means that ideally, the beginning of the Ethernet frame (i.e. the destination address) will be aligned on a 32-bit boundary so that it can be copied verbatim with aligned reads/writes. Now, I realize this makes the contained IP/TCP frames unaligned and I've read that setting the ETH_PAD_SIZE=2 improves performance on 32-bit machines by (presumably) making the contained IP/TCP frames 32-bit aligned (assuming MEM_ALIGNMENT=4).

For my case, it would seem that un-aligning the contained IP/TCP frames would be better so that the final copy to the mac is aligned at the start of the Ethernet frame. I'm wondering about the validity of this statement and if it has any merit performances wise. If the Ethernet frame being sent is not 32-bit aligned, I basically have to do byte reads to a temporary buffer which is then written to the mac.

My other question is about actually getting the pbuf->payload to be 32-bit aligned at the start of the generated Ethernet frame. I would think that setting ETH_PAD_SIZE=0 and MEM_ALIGNMENT=4 would produce 32-bit aligned Ethernet frames in the resulting PBUF_RAM-type pbufs. However, this doesn't seem to be the case in my testing as the p->payload in PBUF_RAM-type pbufs appear to always be 16-bit aligned with the aforementioned settings. What settings do I need to create 32-bit aligned Ethernet frames for output? Btw, I'm using malloc/free as provided by my libc build.

Thanks,
Tyrel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]