lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [patch #7658] Make pbuf_free() send PBUF_POOL pbufs to Ethe


From: Timmy Brolin
Subject: [lwip-devel] [patch #7658] Make pbuf_free() send PBUF_POOL pbufs to Ethernet driver directly.
Date: Wed, 02 Nov 2011 20:18:56 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1

URL:
  <http://savannah.nongnu.org/patch/?7658>

                 Summary: Make pbuf_free() send PBUF_POOL pbufs to Ethernet
driver directly.
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: brolin
            Submitted on: ons  2 nov 2011 20.18.55
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

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 it
returns false, and 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. It can
also simplify the Ethernet driver.

The pbuf might be in a somewhat random shape when it is offered to the
Ethernet driver, so the DMA_RING_REPLENISH() function is responsible for
restoring the pbuf struct content to default "newly allocated" state,
including incrementing "ref" to "1".




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?7658>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/




reply via email to

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