Getting network port ID by ethdev port ID

Stephen Hemminger stephen at networkplumber.org
Tue Jun 6 17:32:06 CEST 2023


On Tue, 6 Jun 2023 11:16:21 +0400 (+04)
Ivan Malov <ivan.malov at arknetworks.am> wrote:

> In general, I agree that there might not be too many vendors
> that provide multi-port adapters. But in what comes to
> bifurcated model = I'm not sure that I understand why
> we confine our discussion to it. What I mean is not
> Linux interface IDs. I mean enumerating physical
> ports on the network card and providing mappings
> to the application, like "physical port 0 maps
> to PF 0". My hunch is that this information
> can be available in vendors that do not use
> the bifurcated model; they might be able to
> retrieve it from their internals just like
> any other aspect of card configuration.
> 
> When you suggest that I stick with using PCI information, do
> you mean precisely "/sys/class/net/<iface>/dev_port" et al?
> If yes, unfortunately, it seems like these fields are not
> filled the same way for different vendors, sometimes they
> aren't supported at all. So, I'm not pushing to add such
> means to DPDK, but it might be useful to applications.

I meant look in /sys/devices/pci0000:00/0000:00:01.1/ etc.

But after looking deeper, it gets messy, so probably does need to be in
EAL to handle FreeBSD and Windows.

There is a multitude of different values possible.
 - acpi_index - which comes from BIOS
 - dev_port - only available if device has multiple ports
 - pci_slot - comes from hotplug
 - dev_id - old kernels with ipoib

These all do not depend on a bifurcated driver. All devices even
dedicated ones will have this. Probably more likely to see a dual
port dedicated NIC.

If some one makes a new API (rte_ethdev_slot_info_get)? it could
provide both slot and port in slot information.



More information about the dev mailing list