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, [email protected] <[email protected]> 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
> [email protected]
> https://lists.nongnu.org/**mailman/listinfo/lwip-users<https://lists.nongnu.org/mailman/listinfo/lwip-users>
>
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to