lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] byte alignment


From: Simon Goldschmidt
Subject: Re: [lwip-users] byte alignment
Date: Tue, 04 May 2010 11:38:57 +0200

What you're seeing is basically a misdesign of the ethernet MAC or its DMA 
engine: you can either spend too many processor cycles on copying the data 
to/from unaligned memory or spend too many processor cycles on accessing 
unaligned TCP/IP headers. Which solution is better depends on your processor, 
you might have to check that.

I have the same problem but I am a bit better off since I can do 16-bit DMA 
copy on unaligned data - still, it makes the DMA copy slower.

As to the aligned pbuf payload: I think the code currently relies on mem_malloc 
returning aligned data (and that should be OK with your current settings), so 
you might want to check the return values of your libc malloc.

Simon


Tyrel Newton wrote:
> 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
> 
> 
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01




reply via email to

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