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: Will Wykeham
Subject: Re: [lwip-users] Memory alignment and DMA controllers
Date: Tue, 16 Jan 2018 09:38:57 +0000

So you're saying that a memcpy/memmove fallback is always going to need to be coded up, and the goal of the stack is to minimise how often it has to get called? That makes sense.

 

Is there anything in the stack itself that has expectations about memory alignment, or is this just for driver interfacing?

 

Cache wise - cache line alignment shouldn't be needed for safety, you just may end up having to flush more than you otherwise would to get everything into memory.

 

Yes, I'm on git master.

 

Will

 

 

From: lwip-users [mailto:address@hidden On Behalf Of address@hidden
Sent: Mon 15 January 2018 19:31
To: address@hidden
Subject: Re: [lwip-users] Memory alignment and DMA controllers

 

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


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



PA Consulting Services Limited is registered in England and Wales under registered number 414220. Its registered office is at 10 Bressenden Place, London, SW1E 5DN, United Kingdom.
If you are not the intended recipient of this email, please notify the sender as soon as possible and delete it from your systems. Please do not disclose the contents of this email to anyone else.

reply via email to

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