<div dir="ltr"><div>Hi everyone,</div><div>I'm trying to use a secondary process to rx/tx packets through a NIC and running into segfaults due to some data structures not being populated on the secondary. I've figured out a solution, but it involves the use of internal APIs and I wanted to check with the community if there's a better way to do this.</div><div><br></div><div>I'm using DPDK 24.11 LTS for this test. The test code is at <a href="https://gist.github.com/praetorian20/0c1b69abbc7843d958da72fdf611a5d7">https://gist.github.com/praetorian20/0c1b69abbc7843d958da72fdf611a5d7</a>. I'll describe the steps I'm following here.</div><div><br></div><div>Primary process:</div><div><ol><li>Command line: sudo LD_LIBRARY_PATH=/path/to/dpdk/shared/libs/ ./test-ethdev --main-lcore 0 --file-prefix=mpdemo --socket-mem=1024 -d /path/to/dpdk/shared/libs/dpdk/pmds-25.0 --proc-type primary</li><li>Calls rte_eal_init</li><li>Registers message handler using 
<span class="gmail-pl-c1">rte_mp_action_register</span></li><li><span class="gmail-pl-c1">Waits indefinitely for CTRL+C</span></li></ol><div>Secondary process:</div><div><ol><li>Command line: Same as primary, except --proc-type=secondary</li><li>Calls rte_eal_init</li><li>Registers message handler using 
<span class="gmail-pl-c1">rte_mp_action_register</span></li><li><span class="gmail-pl-c1">Creates a mempool using </span><span class="gmail-pl-c1">rte_pktmbuf_pool_create</span>

</li><li><span class="gmail-pl-c1">Sends request message to primary using </span>
<span class="gmail-pl-c1">rte_mp_request_async</span></li></ol><div>Primary process (upon receiving the async request):</div><div><ol><li>Look up the mempool created by the secondary</li><li>Get port id for a particular ethdev using PCI address</li><li>Call <span class="gmail-pl-c1">rte_eth_dev_configure</span>, 
<span class="gmail-pl-c1">rte_eth_rx_queue_setup, </span>
<span class="gmail-pl-c1">rte_eth_tx_queue_setup and </span>
<span class="gmail-pl-c1">rte_eth_dev_start</span> to start the ethdev</li><li>Send response to secondary</li></ol><div>Secondary process (upon receiving response):</div><div><ol><li>Call 
<span class="gmail-pl-c1">rte_eth_dev_get_port_by_name</span> to fetch port id</li><li>Call 
<span class="gmail-pl-c1">rte_eth_dev_attach_secondary</span> and 
<span class="gmail-pl-c1">rte_eth_dev_probing_finish</span> to initialize data structures. Without this the next step has segv because rte_eth_fp_ops.rxq.data is nullptr</li><li>Call rte_eth_rx_burst to receive packets</li></ol><div><br></div><div>The above works but I have a few questions whether this process can be improved. I'm using an Nvidia ConnectX6 NIC (mlx5 driver) in case that matters.</div><div><br></div><div><ul><li>Are there public APIs I can call instead of 
<span class="gmail-pl-c1">rte_eth_dev_attach_secondary</span> and 
<span class="gmail-pl-c1">rte_eth_dev_probing_finish</span>?</li><li>Is it possible to perform <span class="gmail-pl-c1">rte_eth_dev_configure, tx/rx queue setup and </span>
<span class="gmail-pl-c1">rte_eth_dev_start</span> from the secondary process? These functions return various error codes when I try this.</li><li>When I call rte_eth_dev_start on the primary, it's sending a message to the secondary that goes unhandled. Is this a problem, and possibly the reason for the unpopulated rte_eth_fp_ops on the secondary? This is the error message I see from the primary:</li></ul></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">EAL: Fail to recv reply for request /var/run/dpdk/mpdemo/mp_socket_1094695_b7080eff23acd4:common_mlx5_mp<br>mlx5_net: port 2 failed to request stop/start Rx/Tx (5)</blockquote><div><br></div><div> Thanks for all your help,</div><div>Ashish</div></div></div></div></div></div>