lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Struct packing/alignment problems


From: d99tibr
Subject: [lwip-users] Struct packing/alignment problems
Date: Fri, 23 Apr 2004 17:07:55 +0200
User-agent: Internet Messaging Program (IMP) 3.2.1

Hi.

I'am porting lwIP to a Texas instruments DSP (DM642) with a built in 100Mbps 
Ethernet interface.
I have a big problem with the non-aligned IP address fields. The compiler (Code 
Composer) does not support packing of structs, and there are no other compilers 
with support for this DSP.
When searching the archives I see that I'am not the first one with this 
problem. Others seems to have solved it by letting the driver pad the ethernet 
and ARP headers to ensure alignment.
However, the Ethernet interface in this DSP neatly transfers incomming packets 
to a user defined chain of buffers in the main memory using DMA. Same thing 
goes for outgoing packets. Manual padding of the headers would require me to do 
alot of unneccesary memory operations. At 100Mbps full duplex, that's quite a 
performance hit, and performance is very important in this project.

I considered solving the problem by changing the ip_addr struct from:
struct ip_addr {
  u32_t addr;
}
To something like:
struct ip_addr {
  u8_t addr0;
  u8_t addr1;
  u8_t addr2;
  u8_t addr3;
}

But I found that this struct is used in tons of places. That's alot of code to 
rewrite..
Have anyone solved this problem without introducing padding?

Regards,
Timmy Brolin

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




reply via email to

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