设备驱动程序中的 Rx 描述符 dma 映射实际上意味着什么,它是否意味着将物理 NIC 上的数据包映射到内存中的结构对象

Rx descriptor dma mapping in device driver what that actually means, Does it mean mapping of packets at physical NIC to struct object in memory

我正在查看 realtek r8169 驱动程序,但有点卡在这一行中

    tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES,
                     &tp->RxPhyAddr, GFP_KERNEL);

从书Linux device driver,它只是说它是...Function handles both the allocation and the mapping of the buffer, ...arguments are device structure and the size of buffer needed

那是什么意思:分配我可以理解,但是 mapping

是什么意思

这是否意味着我在 pdev 中所拥有的代表设备的 rx 描述符与我在 dma_alloc_coherent 中的 returns 中所拥有的相同,即 tp->RxDescArray 作为软件对象的描述符? tp->RxDescArray 在驱动中是RxDesc类型,如下

    struct RxDesc {
        __le32 opts1;
        __le32 opts2;
        __le64 addr;
     };

如果这就是映射:意味着我在 pdev 中表示的物理设备上的设备 rx 描述符与我在软件对象中具有的相同 tp->RxDescArray 就是映射的含义。那么谁定义了RxDesc的结构,这是数据表中包含的东西吗?如果是那么在哪个部分?数据表中有许多部分。应该更清楚 `

更新 也想知道这条线是做什么的

  tp->RxDescArray[NUM_RX_DESC - 1].opts1 |= cpu_to_le32(RingEnd);

tp->RxDescArray 是 RxDesc 类型(不是 RxDesc 的数组)这个语句是否标记变量 RxDescArray 的 end 意味着接下来会发生什么 end 地址

更新 2

我需要有关我是否有来自英特尔 E1000E 驱动程序或来自 RealTek 的 r8169 驱动程序的数据表的信息,然后我如何创建 Rx Descrptor 结构,在上面的代码中它执行类似这样的操作

    struct RxDesc {
    __le32 opts1;
    __le32 opts2;
    __le64 addr;
     }

什么是 opts1、opts2 和 addr?这个驱动程序的作者是如何想到创建这个结构的。只有他有很多十六进制值的数据表

RingEnd 标记网卡环形缓冲区的结束。以便 NIC DMA 引擎知道从哪里跳转到环形缓冲区的开始。

DMA 访问由 IOMMU 转换,在 Intel 系统上在 Intel® Virtualization Technology for Directed I/O (VT-d) specification 中进行了描述。

函数dma_alloc_coherent分配内存并将映射引入到DMA页表中,以便设备可以访问内存。返回的地址不是内存的虚拟地址或物理地址,而是一个 I/O 虚拟地址 (IOVA),设备可以使用它来访问内存。 IOVA在设备执行DMA时,由IOMMU翻译成物理内存地址。

IOMMU 阻止任何设备访问尚未映射到该特定设备的 I/O 地址 space 的物理内存。