[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] again... Zero Copy Ethernet interface
From: |
Jakob Stoklund Olesen |
Subject: |
Re: [lwip-devel] again... Zero Copy Ethernet interface |
Date: |
Wed, 07 Jan 2009 09:48:23 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
Piero 74 wrote:
> I cannot imagine a implementation for sending operation using zero copy...
> i can see TWO problems:
> - first, as already someone said above, i have to solve problem of lwip
> which wants to free pbuf after low_level_output... a solution could be
> (if a RTOS is used) waiting on semaphore until emac isr unlocks it,
> after DMA sending packet. In this way CPU will be avalaible for other
> tasks (threads) during DMA sending
I have implemented zero-copy DMA transmission like this:
err_t
low_level_output(struct pbuf *pb)
{
if (can_direct_dma(pb)) {
if (queue_dma_transfer(pb)) {
pbuf_ref(pb);
return ERR_OK;
}
else {
return ERR_IF;
}
}
else {
pb = flat_copy_pbuf(pb);
if (queue_dma_transfer(pb)) {
return ERR_OK;
}
else {
pbuf_free(pb);
return ERR_IF;
}
}
}
dma_done(dma_transfer *tr)
{
pbuf_free(tr->pb);
}
This seems to work. If anybody knows why it shouldn't, please let me know.
I can DMA from any memory region, but I can only do limited
scatter-gather DMA. A pbuf that is too fragmented must be copied to
continuous memory.
Anyway, calling pbuf_ref() in low_level_output prevents the pbuf from
being deleted before DMA is completed.
> - second (correlated to similar problem for rx), when lwip send a
> packet, this is allocated in pbuf RAM, in lwip heap, (if i'm right...),
> but, again, my DMA wants packet in specific region (emac RAM)... so,
> pbuf ram needs relocation in fixed memory region too, but i think is
> difficoult to change lwip code for this...
If you want all sent pbufs to be in DMA-able memory, it seems to me that
you must place the entire lwip memory pool in DMA-able memory. This can
be done in mem.c, and possibly memp.c
Even if you do that, a pbuf with the PBUF_ROM flag set can have payload
anywhere.
/stoklund
- Re: [lwip-devel] again... Zero Copy Ethernet interface, (continued)
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Alain M., 2009/01/06
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Jonathan Larmour, 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, address@hidden, 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Alain M., 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, address@hidden, 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Alain M., 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Jakob Stoklund Olesen, 2009/01/08
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Simon Goldschmidt, 2009/01/08
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Piero 74, 2009/01/08
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Alain M., 2009/01/08
- Re: [lwip-devel] again... Zero Copy Ethernet interface,
Jakob Stoklund Olesen <=
- RE: [lwip-devel] again... Zero Copy Ethernet interface, bill, 2009/01/07
- Re: [lwip-devel] again... Zero Copy Ethernet interface, Jakob Stoklund Olesen, 2009/01/07
- RE: [lwip-devel] again... Zero Copy Ethernet interface, bill, 2009/01/23
- [lwip-devel] Re: again... Zero Copy Ethernet interface, Jakob Stoklund Olesen, 2009/01/24