lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Ang.: Automatic Rx DMA ring replenish


From: address@hidden
Subject: [lwip-users] Ang.: Automatic Rx DMA ring replenish
Date: Sun, 30 Oct 2011 20:06:35 +0100

There is however one condition for this to work: There cannot be any pbuf_pool allocations anywhere else in lwip, since that pool will always be empty.

It is true that some CPUs only supports a limited number of Rx buffer descriptors.
But lets say you have 10kB RAM dedicated to pbuf_pool, and each pbuf is 256Bytes. (reasonably typical values for lwip I think?)
In that case you will only need 40 rx descriptors anyway. Should be ok on many, but perhaps not all CPUs.

This approach also solves a inherent problem for DMA based drivers:
Lets say the rx isr work like this:
1: Take any filled pbufs from the rx ring, and send them to lwip.
2: Allocate new pbufs to fill the rx ring.

Now what happens if the rx ring becomes empty, and there are no pbufs available to allocate?
There would not be any more rx interrupts, so the rx ring will never be refilled. The only way to recover is to add an extra timer routine which tries to refill the rx ring at a certain interval.
My suggested modification of pbuf_free avoids this problem completely by automatically refilling the rx ring whenever a pbuf becomes available.

/Timmy Brolin

----- Reply message -----
Från: "Simon Goldschmidt" <address@hidden>
Datum: sön, okt 30, 2011 18:13
Rubrik: [lwip-users] Automatic Rx DMA ring replenish
Till: "Mailing list for lwIP users" <address@hidden>

"address@hidden" <address@hidden> wrote:

> What if I make the Rx DMA buffer descriptor ring large enough to hold all POOL pbufs. At start-up all POOL pbufs are allocated and put in the Rx DMA ring.
> pbuf_free() is modified so that whenever a POOL pbuf is freed it is immediately put in the Rx DMA ring.
>
> This should improve performance, as well as simplify the ethernet driver a bit.

If it works for your hardware, good enough. The modification would probably be calling your custom free function instead of memp_free from pbuf_free.

However, I don't think that will work with many DMA enabled MACs: the ones I've worked with have the RX descriptors in internal memory, so the ring can't be made larger. And because RX packets are sometimes buffered (i.e. TCP OOS data), you will want to have many more PBUF_POOL pbufs than fit into your DMA ring (depending on its size and the expected throughput, of course).

However, I guess providing a way to change memory allocation/deallocation to use custom functions would be a good thing to support many different types of zero copy MACs without having to change the lwIP code for every hardware, so I guess it's well worth a try for your target!

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



reply via email to

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