lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Understanding pbuf's


From: Martin Osterloh
Subject: Re: [lwip-users] Understanding pbuf's
Date: Tue, 17 Apr 2012 09:09:14 -0400

Hi Simon,

Thanks for the clarification. My driver is DMA based so your 2nd option is my way to go.

I was also wondering: To pre-allocate pbufs, do I have to that in pbuf_init() (which is currently empty) or does LwiP take care of that internally? 

Thanks again!

-Martin

On Thu, Apr 12, 2012 at 4:45 PM, address@hidden <address@hidden> wrote:
Martin Osterloh wrote:
My NIC driver provides an interrupt function that is called every time a frame is received.
My intuition tells me that I have to allocate a pbuf now (of the frame's length).

But how do i actually fill in the blanks in the pbufs (in case there is a chain).
Basically, there are 2 approaches:
a) in the interupt, call pbuf_alloc(PBUF_POOL) and copy the received data into the pbuf chain by copying into each pbuf until all data is copied - this method is to be used for non-DMA enabled MACs where you have to use memcpy() anyway.
b) pre-allocate pbufs and set up your MAC-DMA engine to directly put the RX data into p->payload - ATTENTION: if your MAC doesn't support scattering a packet among multiple regions, PBUF_POOL pbufs must be big enough to hold a complete packet.

... and that's it... aside from ensuring SYS_ARCH_PROTECT is correctly set up to protect pbuf_alloc() against them main loop (if you call it from an ISR).

Hope that helps,
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]