<div dir="ltr">Thank you for taking time to provide a nice reply. The upshot here is that DPDK<div>already uses DMA in a smart way to move packet data into TXQs. I presume the</div><div>reverse also happens: NIC uses DMA to move packets out of its HW RXQs into </div><div>the host machine's memory using the mempool associated with it.<br><br><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 11, 2023 at 6:26 AM Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com">dmitry.kozliuk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2023-01-08 16:05 (UTC-0500), fwefew 4t4tg:<br>
> Consider a valid DPDK TXQ with its mempool of rte_mbufs. Application code<br>
> will allocate a mbuf from the pool and prepare it with headers, data, and<br>
> so on.<br>
> <br>
> When the mbuf(s) are enqueued to the NIC with rte_eth_tx_burst() does DPDK<br>
> DMA the memory into the NIC? Is this an optimization worth considering?<br>
<br>
DPDK is SW running on CPU.<br>
DMA is a way for HW to access RAM bypassing CPU (thus it is "direct").<br>
<br>
What happens in rte_eth_tx_burst():<br>
DPDK fills the packet descriptor and requests the NIC to send the packet.<br>
The NIC subsequently and asynchronously uses DMA to read the packet data.<br>
<br>
Regarding optimizations:<br>
1. Even if the NIC has some internal buffer where it stores packet data<br>
before sending it to the wire, those buffers are not usually exposed.<br>
2. If the NIC has on-board memory to store packet data,<br>
this would be implemented by a mempool driver working with such memory.<br>
<br>
> DPDK provides a DMA example here:<br>
> <a href="http://doc.dpdk.org/api/examples_2dma_2dmafwd_8c-example.html" rel="noreferrer" target="_blank">http://doc.dpdk.org/api/examples_2dma_2dmafwd_8c-example.html</a><br>
> <br>
> Now, to be fair, ultimately whether or not DMA helps must be evidenced by a<br>
> benchmark. Still, is there any serious reason to make mempools and its<br>
> bufs DMA into and out of the NIC?<br>
<br>
DMA devices in DPDK allow the CPU to initiate an operation on RAM<br>
that will be performed asynchronously by some special HW.<br>
For example, instead of memset() DPDK can tell DMA device<br>
to zero a memory block and avoid spending CPU cycles<br>
(but CPU will need to ensure zeroing completion later).<br>
</blockquote></div>