Re: DMA from device to device

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

 



On Tue, Oct 28, 2008 at 04:02:49PM +0000, bramp wrote:
> Hello,
> This is perhaps a generic PCI/DMA question, but if it is possible I
> later wish to try to hack the linux kernel to achieve what I want.
> 
> Basically my question is this:
> Can one PCI device DMA directly to another PCI device? Say for example
> I have two network cards having packets routed between them. The OS
> can pull the header from the card, check the destination, and then ask
> the PCI device to DMA the remainder of the packet to the outgoing
> interface.
> 
> >From looking at linux's API, and googling, I have been unable to find
> my answer, and only found examples of DMA from a device into memory.

Yes, it's possible and one historical example is I2O.
Another current example is drivers/scsi/sym53c8xx_2/
Look for mmio_base and ram_base in sym_glue.c
Willy (sym2 driver maintainer) explain once that the chip actually fetchs
it's "script" (aka instruction stream) across the PCI bus instead of
directly via some other path. So the core logic need to know the bus
address instead of a DMA mapped address (view into Host physical address).


> I also wonder what would happen if my destination device is memory
> mapped (I think is the correct term), and I try and DMA from a device
> into that mapped location.

"Memory Mapped" just means we create a CPU virtual address which maps to
a given PCI Bus address range. Nothing changes on the PCI bus.
Just make sure CPU accesses are coordinated (ie syncronized) 
with the DMA accesses.

In general, the same things that apply to DMA transactions also apply to
peer-to-peer transaction. ie transaction ordering rules and address routing.


> thanks for any reply
> Andrew
> 
> P.S  I'd be grateful if people could point me in the direction of
> resources I could read. Thus far I have gone over the documentation in
> the kernel, and a couple of articles on lwn, as well as Wikipedia.

Look for "peer-to-peer" in PCI specs and possibly in MindShare's
"PCI Local Bus Architecture" books (I don't have a copy here.)

This bit from the PCI 2.3 spec is probably of interest to you:
7. Peer-to-peer transactions crossing multiple host bridges
    PCI host bridges may, but are not required to, support PCI peer-to-peer transactions
    that traverse multiple PCI host bridges.

hth,
grant
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux