lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Memory alignment and DMA controllers


From: address@hidden
Subject: Re: [lwip-users] Memory alignment and DMA controllers
Date: Mon, 15 Jan 2018 20:31:21 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 12.01.2018 13:20, Will Wykeham wrote:
[..]
The possible ways of fixing it that I have come up with are:

(1)
Change the argument in pbuf_alloc where it passes the pointer to 
pbuf_init_alloced_pbuf from:
LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset))
To:
LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF)) + offset
This aligns the data space after the pbuf, and then adds on the offset. The 
payload pointer starts of unaligned, but becomes aligned when wound back by 14 
bytes.
This is fine as long as the 'layer' value is correct, but my understanding is 
that it is a conservative maximum and when more stack layers are involved it 
may be an over estimate, so we're not guaranteed the payload pointer will be 
wound back to where it needs to be. Also, that's me patching the stack which 
I'd rather not do.
[..]
Am I missing something or is this just a limitation of how the stack works?

That's still a 'todo', unfortunately. Mainly because never really
started working on it. I guess in most devices it either works or high
ethernet throughput is not the main goal.

Let's start working on this. Your solution 1 looks good, let's try that.
Are you working with the git master version of lwIP? That would ensure
we could share the code.

As an addition, you need to flush the cache before TX. To do that
safely, your buffers need to start on a cache line (not only on a 32 bit
boundary), so we need another define for alignment.

In the end, you always need to implement a memcpy fallback in your
driver. A netif needs to be able to send*all*  packets, as you never
know how bogus an lwIP callback application allocates a pbuf. This is
also true when forwarding a packet , e.g. from PPP to ETH.

Simon




reply via email to

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