<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 31 Jul 2024 at 14:35, Ferruh Yigit <<a href="mailto:ferruh.yigit@amd.com">ferruh.yigit@amd.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">On 7/30/2024 6:36 AM, Prashant Upadhyaya wrote:<br>
> <br>
> <br>
> <br>
> On Mon, 29 Jul 2024 at 23:13, Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com" target="_blank">dmitry.kozliuk@gmail.com</a><br>
> <mailto:<a href="mailto:dmitry.kozliuk@gmail.com" target="_blank">dmitry.kozliuk@gmail.com</a>>> wrote:<br>
> <br>
> 2024-07-29 22:18 (UTC+0530), Prashant Upadhyaya:<br>
> > Hi,<br>
> ><br>
> > I have 4 ethernet interfaces available as PCI devices.<br>
> > The PCI addresses are known.<br>
> > When I start my DPDK application, it starts up properly and<br>
> assigns the<br>
> > port numbers to them as 0, 1, 2, 3 expectedly.<br>
> ><br>
> > However, is there a way I can force that a particular PCI address<br>
> should be<br>
> > identified as port 0 by DPDK, another one as port 1 and so forth ?<br>
> > Does passing the arguments like -a <address1> -a <address2> to<br>
> rte_eal_init<br>
> > ensure that, or is there any other way, or is there no way ?<br>
> ><br>
> > I am on 24.03<br>
> ><br>
> > Regards<br>
> > -Prashant<br>
> <br>
> Hi,<br>
> <br>
> Why do you need specific port numbers assigned to devices?<br>
> <br>
> If you're going to use devices for different purposes,<br>
> you'd better have an application-level configuration<br>
> to specify PCI addresses to use for each purpose.<br>
> Iterate devices to match the address and find the port number.<br>
> <br>
> It is also possible to disable automatic probing with "-a 0:0.0",<br>
> then to use rte_dev_probe() + rte_dev_event_callback_register()<br>
> to add devices and to get their port numbers.<br>
> However, this API, strictly speaking, does not guarantee<br>
> that the numbers will be assigned sequentially.<br>
> One advantage of using hot-plug is that you can build devargs<br>
> from within the application (or from configuration).<br>
> <br>
> Refer to "rte_dev.h" in any case.<br>
> Multiple "-a" don't work the way you've described.<br>
> <br>
> <br>
> <br>
> Thanks Dmitry. Ok, so if I have the port number with me, and I know it<br>
> corresponds to a PCI device, how do I find out the PCI address of this<br>
> device corresponding to this port number. I believe I can<br>
> do rte_eth_dev_info_get to get the struct rte_eth_dev_info and from<br>
> there the rte_device, but what after that ? I saw some references<br>
> to RTE_DEV_TO_PCI but that macro isn't available for compilation after<br>
> DPDK is installed as it is an internal header file and thus not a macro<br>
> for application usage and wouldn't compile at application level.<br>
> <br>
> <br>
<br>
Hi Prashant,<br>
<br>
For PCI bus, most of the times ethdev device name is PCI ID, so you can<br>
use 'rte_eth_dev_get_name_by_port(port_id, name)' API to get PCI ID for<br>
port.<br>
<br>
But there are cases this is not true, like single PCI ID creates<br>
multiple ethdev etc... for this case, PCI ID can be get from device name:<br>
rte_eth_dev_info_get(port_id, *dev_info)<br>
name = rte_dev_name(dev_info->device)<br>
<br><br></blockquote><div><br></div><div>Thanks Ferruh, this was helpful.</div><div><br></div><div>Regards</div><div>-Prashant</div><div><br></div></div></div>