<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 30 Jul 2024 at 13:45, Bruce Richardson <<a href="mailto:bruce.richardson@intel.com">bruce.richardson@intel.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 Tue, Jul 30, 2024 at 11:06:56AM +0530, Prashant Upadhyaya wrote:<br>
> On Mon, 29 Jul 2024 at 23:13, Dmitry Kozlyuk<br>
> <[1]<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>
> Hi,<br>
> Why do you need specific port numbers assigned to devices?<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>
> 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>
> Refer to "rte_dev.h" in any case.<br>
> Multiple "-a" don't work the way you've described.<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>
> Regards<br>
> -Prashant<br>
> <br>
The PCI device id is used as the device name in that case so rte_dev_name<br>
should get you what you want.<br>
<br>
I'd also +1 the suggestion of having your app hotplug in the devices<br>
post-init, if you want specific devices to have specific ids. Although it<br>
is not guaranteed, DPDK does currently assign the ids sequentially. I've<br>
used this approach myself in the past in some test apps where I wanted<br>
ports in a particular sequence.<br>
<br>
/Bruce<br></blockquote><div><br></div><div>Thanks Bruce, makes sense.</div><div><br></div><div>Regards</div><div>-Prashant</div><div> </div></div></div>