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: address@hidden
Subject: Re: [lwip-users] Understanding pbuf's
Date: Thu, 12 Apr 2012 22:45:36 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

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



reply via email to

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