-2

I was studying DMA proxy and DMA proxy channels. Basically they are like letting Userspace application to write tx, read rx kernel data-structures. and let the device to access virtual memory data structures since devices understand physical addresses.

This code https://github.com/mstuehn/dma_proxy/blob/master/dma_proxy_test.c

and this article that I am reading https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space

And from this Thesis http://www.diva-portal.org/smash/get/diva2:22746/FULLTEXT01.pdf it says this

in Linux the kernel uses virtual memory address but most hardware systems use physical address for bus addressing. For hardware to be able to access data structures residing in kernel virtual memory space these structures have to be mapped to physical memory address. Its not sufficient to use simple address conversion methods since some system memory management unit have to be re-programmed and bounce buffers have to be used (probably in system memory management unit -- please clarify).

I think I have some grasp of dma proxy drivers and associated Userspace application(What I am guessing is it is used in embedded Linux systems).

But What's the point of all of this for example if I am looking at NIC card, then whatever I suppose to get with the mmap call in Userspace application and Kernel implementation of MMAP in proxy driver will have kernel data structure. in case of NIC card the RX/TX will be the device specific data structures representation in kernel memory space since geting struct ethhdr / struct iphdr / struct tcphdr / etc. from return of mmap is not possible since the above paragraph from thesis says conversion of virtual addresses to Userspace addresses is probably not possible (basically it says physical address. I am assuming this from the text read )

So basically I am not fully getting the use of dma proxy drivers. I need some explanation to clear this out and how can the return of mmap calls be used in applications i.e. server applications in embedded Linux systems

Ti1
  • 3
  • 1

1 Answers1

0

What's the point of all of this for example if I am looking at NIC card, then whatever I suppose to get with the mmap call in Userspace application and Kernel implementation of MMAP in proxy driver will have kernel data structure.

What do kernel data structures have to do with it? If you are using DMA to get data from a NIC then surely you are getting raw data (ethernet frames, for example). The layout of such data is defined by the applicable network protocol and whatever higher-level protocols apply to the payload.

The kernel sources do define C structure types whose layouts map the fields of ethernet headers, IP headers, TCP headers, etc, but these follow the externally-defined layout of the data, not the other way around.

in case of NIC card the RX/TX will be the device specific data structures representation in kernel memory space

The formats of network transmissions are not device-specific (generally speaking).

since geting struct ethhdr / struct iphdr / struct tcphdr / etc. from return of mmap is not possible since the above paragraph from thesis says conversion of virtual addresses to Userspace addresses is probably not possible (basically it says physical address. I am assuming this from the text read)

Irrelevant (see above). Nevertheless, the quoted thesis excerpt says nothing at all like what you describe. It's not talking about user space versus kernel space at all, but rather about hardware programming interfaces vs kernel code. It is expressing some of the complications involved in writing (kernel-space) drivers.

how can the return of mmap calls be used in applications

The driver provides an interface to userspace in the form of a character device. Mmapping an appropriate range of bytes from that device into a program's memory space provides access to whatever data the driver exposes that way. In the case of an interface for DMA, that would presumably be the contents of the (physical) memory involved in the DMA transfer.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • this github code it uses `DMA Engine/AXI DMA driver` as device `AXI` must be some device. PCI network cards driver also uses DMA buffers.every device has its DMA. so why in the code I could not find which device is used pci/usb.It uses call 2 `dmam_alloc_coherent(pchannel_p->proxy_device_p, sizeof(..), &pchannel_p->interface_phys_addr, GFP_KERNEL);` this `pchannel_p->proxy_device` is general device.does it mean for pci network char dma proxy driver I should specify `pci_dev` instead of `pchannel_p->proxy_device` which is `struct device *proxy_device_p;` in call to dmam_alloc_coherent – Ti1 Apr 11 '21 at 15:31
  • https://github.com/mstuehn/dma_proxy/blob/master/dma_proxy.c – Ti1 Apr 11 '21 at 17:12
  • If you have a new question, @Ti1, then you should pose it as one. – John Bollinger Apr 12 '21 at 01:38
  • Seems another account of that 666 group of AI or so. They simply ignore any advice to read books. – 0andriy Apr 20 '21 at 22:36