|
From: | web |
Subject: | Re: [lwip-users] Automatic Rx DMA ring replenish |
Date: | Wed, 02 Nov 2011 18:09:39 +0100 |
On 30 okt 2011 18:13 "Simon Goldschmidt" <address@hidden> wrote:"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. I have tested this method on my hardware and it works nicely. This is my suggestion for how it can be implemented in LwIP: In pbuf.c, function pbuf_free(), change this: /* is this a pbuf from the pool? */ if (type == PBUF_POOL) { memp_free(MEMP_PBUF_POOL, p); To this: if (type == PBUF_POOL) { if( !DMA_RING_REPLENISH( p ) ) { memp_free(MEMP_PBUF_POOL, p); } In opt.h, add this: #ifndef DMA_RING_REPLENISH #define DMA_RING_REPLENISH( p ) 0 #endif In lwipopts.h, the feature can be enabled by a define like this: #define DMA_RING_REPLENISH( p ) MAC_ReplenishRx( p ) The way it works is that whenever a PBUF_POOL is deallocated, it is first offered to the Ethernet driver via the function DMA_RING_REPLENISH(). If the Ethernet driver wants the pbuf, it returns true. If however the Ethernet driver does not want the pbuf at this time (DMA ring is already full), then the pbuf is is freed normally using memp_free(). By offering the pbuf to the Ethernet driver directly, the entire memp_free(), context switch, pbuf_alloc() sequence is bypassed, saving CPU cycles. Regards, Timmy Brolin |
[Prev in Thread] | Current Thread | [Next in Thread] |