lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] MEM_ALIGNMENT and problems with it


From: Fabian Koch
Subject: [lwip-devel] MEM_ALIGNMENT and problems with it
Date: Wed, 12 Feb 2014 15:43:49 +0100

Hey,

we are upgrading from 1.3.2 to 1.4.1 at the moment and ran into some problems regarding Alignment.

After I read http://lwip.wikia.com/wiki/Porting_for_an_OS, I found that me misunderstood what the #define MEM_ALIGNMENT actually is meant to be.
This is set to our cache line length up until now, because we take PBufs directly from lwip via pbuf_alloc(PBUF_RAW...); and feed them to our communication processor. These must be aligned to the cache lengths or it won't work.
We have two processor families, so our MEM_ALIGNMENT is set to 16 and 32 respectively. Not the "4" that you expect according to the Wiki.

Now, with 1.3.2 this worked pretty flawlessly.
With 1.4.1 it only stumbled over one single LWIP_ASSERT() and I have the feeling that the assert is wrong, because all other checks for MEM_ALIGNMENT do work also with 1.4.1 and if I take that assert out of the compilation, all seems to work.

The line is in tcp_out.c, line 778:
  LWIP_ASSERT("seg->tcphdr not aligned", ((mem_ptr_t)seg->tcphdr % MEM_ALIGNMENT) == 0);

seg is created right above that line via tcp_create_segment, which makes a memp_alloc() which takes alignment into account and the tcphdr is set to seg->p->payload, where p was also created with mem alignment in place.

I don't really understand why seg->tcphdr must be aligned and if that check is correct.

any comments?

kind regards,
Fabian

reply via email to

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