lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] IP header alignment problems


From: Małowidzki , Marek
Subject: [lwip-devel] IP header alignment problems
Date: Wed, 13 Jan 2010 15:17:24 +0100

Hi,
 
there was such a topic some time ago, I know, and I have read it thoroughly. However, the discussion did not suggest a solution so I would like to ask once again for possible ideas/directions.
 
The problem is that our system (Hitachi SH3) requires access alignment (doubly even addresses for double words and singly even for words) so the IP header must be aligned as well. We copy packets from Ethernet controller using DMA (for max performance) and, as our hardware team has told me, the destination address also needs to be doubly even. Of course, as whole MAC frames are copied, there is no chance for the IP header to be properly aligned. (In fact, this is IP addresses that cause problems.)
 
Our device is a simple two-interface, say, router. Packet processing speed is key.
 
Our current workaroud is copying a MAC frame to a pbuf, then copying headers (MAC+IP) to another memory area with a 2-byte shift so that the IP header will be properly aligned. LwIP processes the header copy. If the packet should be routed through our device, we drop the header copy and use the original (whole) packet. Of course, copying causes overhead.
 
Question: is any other approach possible? We would like to avoid modifications to LwIP (i.e., make necessary changes as small as possible). Maybe compiler hints that "this particular double word may be improperly aligned so generate slower but more flexible code" or so?
 
Also, I think that if LwIP used macros for accessing IP header fields (instead of using a structure), we would be able to modify accesses for IP addresses (read & compose two words). Is anyone aware whether other IP stacks employ this approach (we don not plan to migrate from LwIP, too much investments already made, I am just curious)?
 
Best regards & thanks for ideas,
 
Marek
 

reply via email to

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