|
From: | Bill Auerbach |
Subject: | Re: [lwip-users] Understanding pbuf's |
Date: | Tue, 17 Apr 2012 13:20:18 -0400 |
Martin, >Thanks for your reply. I am currently also using a
generic queue to store pointers to pbufs. >But I still don't understand how this correlates to
"pre-allocation". >Maybe, I misunderstand the meaning but I do not allocate
any pbufs. All I have is a queue >of pbuf pointers. In the ISR, all I can do is then
update the reference to the newly >received frame's payload. If you do not allocate pbufs, what do the pbuf pointers
point to that are in your queue? I do the same – in the DMA RX (which interrupts when
the packet data is ready to be DMAd) I DMA into the pbuf payload – but that
pbuf was preallocated and in the array of pbuf pointers. That payload pointer
is set by pbuf_alloc. I don’t have to allocate in the RX ISR –
I only need to kick off the DMA and update to the next index in the array. Bill From:
address@hidden
[mailto:address@hidden On Behalf
Of Martin Osterloh Bill, Thanks for your reply. I am currently also using a generic
queue to store pointers to pbufs. But I still don't understand how this correlates to
"pre-allocation". Maybe, I misunderstand the meaning but I do not allocate any
pbufs. All I have is a queue of pbuf pointers. In the ISR, all I can do is then
update the reference to the newly received frame's payload. What am I missing something? Thanks again, -Martin On Tue, Apr 17, 2012 at 10:46 AM, Bill Auerbach <address@hidden>
wrote: >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? I
create an array of pbuf pointers in ethernetif_init. The ISR adds a RX
packet to a pbuf next in line in the array using a circular queue using
the array index in and out slot. Then my low_level_input (which is polled
in my case) removes the new RX pbuf(s) and uses pbuf_alloc to replace
it/them. I then return the new RX pbuf. lwIP will free this packet
when it’s done. The size of the array depends on how much memory
you want to tie up in pbufs as they will always be allocated for keeping the
array full.
|
[Prev in Thread] | Current Thread | [Next in Thread] |