lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Problem with custom buffers when MEM_ALIGNMENT=4 and ETH_PA


From: Mason
Subject: [lwip-devel] Problem with custom buffers when MEM_ALIGNMENT=4 and ETH_PAD_SIZE=2
Date: Tue, 25 Oct 2011 16:07:01 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1

Hello,

My driver manages cache-line aligned RX buffers.

I want the IP and TCP headers to be 4-byte aligned, because my checksum
routine processes 4 bytes at a time, and I don't want to special-case
the first 2 bytes. Thus, I've defined ETH_PAD_SIZE=2

e.g. the payload of the first packet is stored at 0x82751742

I've also defined MEM_ALIGNMENT=4 because... well, I don't know what
MEM_ALIGNMENT is supposed to mean in lwip, but accessing a 4-byte word
on an unaligned address throws a bus error.

Moreover, I'm using custom pbufs, and I have a problem in pbuf_alloced_custom

    p->pbuf.payload = LWIP_MEM_ALIGN((void *)((u8_t *)payload_mem + offset));

which sets payload to 0x82751744, which is incorrect.

I'm not sure how to fix this, but it seems payload should not
be LWIP_MEM_ALIGNed?

--- pbuf.c.orig 2011-08-24 11:02:34.484375000 +0200
+++ pbuf.c      2011-10-25 16:03:44.015625000 +0200
@@ -376,7 +376,7 @@

   p->pbuf.next = NULL;
   if (payload_mem != NULL) {
-    p->pbuf.payload = LWIP_MEM_ALIGN((void *)((u8_t *)payload_mem + offset));
+    p->pbuf.payload = (u8_t *)payload_mem + offset;
   } else {
     p->pbuf.payload = NULL;
   }

Probably not appropriate, but again, I'm not sure what MEM_ALIGNMENT
really means.

-- 
Regards.



reply via email to

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