lwip-devel
[Top][All Lists]
Advanced

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

RE: [lwip-devel] again... Zero Copy Ethernet interface


From: bill
Subject: RE: [lwip-devel] again... Zero Copy Ethernet interface
Date: Wed, 7 Jan 2009 09:14:40 -0500

Thanks Jakob, this is helpful.  Is 'can_direct_dma' just a check for
'pb->next == NULL' or are you supporting DMAing the pbuf chains making up
the whole packet?

Bill

> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On
> Behalf Of Jakob Stoklund Olesen
> Sent: Wednesday, January 07, 2009 3:48 AM
> To: lwip-devel
> Subject: Re: [lwip-devel] again... Zero Copy Ethernet interface
> 
> 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
> 
> 
> _______________________________________________
> lwip-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-devel





reply via email to

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