Subject: Re: DMA operation
To: Nitin P Mahajan <Nitin@soc-soft.com>
From: Jochen Kunz <jkunz@unixag-kl.fh-kl.de>
List: tech-net
Date: 03/17/2004 17:50:15
On Wed, 17 Mar 2004 19:01:36 +0530
"Nitin P Mahajan" <Nitin@soc-soft.com> wrote:

> What I am not trying to understand is , do I need to allocate and
> create DMA map for the complete TxFD from the DMA frame work or I need
> to create DMA map only for the the Buffer pointed by BuffData from the
> DMA framework using the bus_dma framework.
You need to create a DMA map for the descriptors and the buffer. You
give the chip an address of the descriptor. You need to give the
_physical_ address of the descriptor to the chip. In order to get the
physical address you need a DMA map. (And possibly other things like
bounce buffer or I/O MMU setup need to be done. But this is hidden
inside bus_dma(9)) The same for the buffer. You need to write the
physical address of the buffer in the descriptor...

Usually you allocate a chunk of DMA memory and an associated DMA map at
driver attach time with bus_dmamem_alloc(9), bus_dmamem_map(9),
bus_dmamap_create(9) and bus_dmamap_load(9). You place all descriptos in
that memory. So you have one DMA map that you have to use for all
decriptors. The different discriptors are at different offsets inside
this single DMA map.=20

When you transmit a packet you get a mbuf(9) chain from the network
stack. So you have to use bus_dmamap_load_mbuf(9) to prepare the mbuf(9)
chain for DMA operation. Then you have to loop through all segments in
that DMA map and programm the TX buffer descriptors with the physical
addresses of the elements of the mbuf(9) chain. I.e. your hardware needs
to be able to do scatter-gather DMA. If it isn't you have to copy the
data from the mbuf(9) chain into a bounce buffer.

You are a bit to early. I am currently extending my "NetBSD Device
Driver Writing Guide" with two chapters about the iee(4) Ethernet
driver. :-)
--=20


tsch=FC=DF,
       Jochen

Homepage: http://www.unixag-kl.fh-kl.de/~jkunz/