<div dir="ltr"><font face="monospace">Hello,</font><div><font face="monospace">I'm developing a PMD for a NIC that I'm developing at the moment.</font></div><div><font face="monospace">(DPDK version 20.11)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">The NIC should forward packets between a network device (based on dpaa2 HW) and a PCIe device.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">I'm running l2fwd application in order to develop the PMD, with the following command:<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">./dpdk-l2fwd -c 0x3 --vdev=my_pmd0 -- -p 0x3 -T 0 </font></div><div><font face="monospace"><br></font></div><div><font face="monospace">The application uses 2 lcores:</font></div><div><ul style="margin-top:0px;margin-right:0px;margin-left:30px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;list-style-position:initial;box-sizing:inherit;color:rgb(35,38,41)"><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit"><font face="monospace">Lcore 0: RX port 0 TX port 1.</font></li><li style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit"><font face="monospace">Lcore 1: RX port 1 TX port 0.</font></li></ul><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41)"><font face="monospace">Where port 0 is the physical one, and net_dpaa2 PMD is attached to this port.</font></p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41)"><span style="font-family:monospace">Port 1 is the virtual one (pci device), and my PMD is attached to it.</span></p></div><div><font face="monospace"><br></font></div><div><font face="monospace">The problem I'm experiencing is related to the tx_pkt_burst callback.<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">When the tx_pkt_burst callback is called, I start the DMA operations to write the packets, but the problem is that I need to wait for the DMA operations to finish in order to do some more work.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">I don't want to lock the lcore in my tx_pkt_burst function waiting for the DMA operation to finish, I want to release it as soon as possible, so it will go back polling the physical port.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Another issue is that I need to poll the PCI for new available write buffers.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">I would like to handle all the TX related software work using one core, including polling for new write buffers, starting the DMA operations once new packets arrive and polling DMA until the operation finishes, then doing some more software work.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Is there a "correct" way to handle this?</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">What I've tried:</font></div><div><font face="monospace">tx_pkt_burst just stores the new packets in an array, and rx_pkt_burst handles all the TX tasks (polling for new write buffers, Starts DMA operations, and polls the DMA operations status).<br></font></div><div><font face="monospace">This works, but:</font></div><div><ul><li><font face="monospace">The workload is not symmetric, the RX lcore does all the "heavy lifting", while the TX lcore does almost nothing.</font></li><li><font face="monospace">spinlocks are needed since 2 lcores access the same data.</font></li><li><font face="monospace">Less efficient caches.</font></li></ul><font face="monospace"> <br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">What I've though:</font></div><div><ul><li><font face="monospace">Using <span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;font-size:13px">rte_eal_alarm_set to poll the </span></font><span style="font-family:monospace">tx_pkt_burst function, for example:</span></li></ul><pre class="gmail-lang-c gmail-s-code-block" style="margin-top:0px;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px">uint16_t my_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,<br>         uint16_t nb_pkts)<br>{<br><br> /* Save mbufs in an array and return number of saved mbufs */<br>}<br><br>void tx_poll(void *param)<br>{<br> /* Check for new write buffers*/<br><br> /* Start DMA operations for new mbufs from my_tx_pkt_burst */<br> <br> /* Check DMA status for prev. operations, and do<br>  * some more work if needed<br>  */<br>  <br>  <br> /* Call this function again in 1us */<br> rte_eal_alarm_set(1, tx_poll, param);<br>}<br></pre><pre class="gmail-lang-c gmail-s-code-block" style="margin-top:0px;padding:12px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><br></pre></div><div><div style="font-family:Verdana;font-size:12px">Best regards,</div>Alvaro</div><div><span style="font-family:monospace"><br></span></div><div><div><br></div></div></div>