is there a way to find out the PCI bus number of an Ethernet interface or vice versa. I am looking to write a Bash/Python script which gives some thing like
pci_address = some_function(eth0)
where pci_address is sys:bus:slot:function
. How can these two elements be related to each other?
lshw
andlspci
are both capable of showing that information. As you have found out already, you can dolshw -class network -businfo
. For instance, here's my output:What you also could use is
lspci -D
and pipe it togrep
to filter out the ethernet controller specifically. Here's my example:Note that with the transition to systemd, one could use of Predictable Interface Naming to just look at the interface name to find out PCI information.
This information is available in sysfs, no helpers like
lshw
/lspci
/ethtool
/udevadm
are needed:ethtool will also show you pci for an interface (bus-info:)
It looks you can tie them together by the IRQ.
will print the ethernet devices including Interrupt.
eg.
while
gives the PCI info with IRQ
eg.
since I see both are 43 I can infer that
eth2
matches04:00.0
Another solution, using
udevadm
{0..10}
– checks the initerfaces frometh0
…eth10
Therefore you could use this command
Example output
Therefore the address is
Or in your case with a single command
or in a script
Call the script with
Output is
Sorry but
PCI_SLOT_NAME
inuevent
isn't a PCI slot number, it is the bus.On HP H/W you can use bus number to look up the PCI slot number from the output of
hplog -i
.But I can't find similar utility for Oracle Linux on Sun H/W like M2s You can get some information using
lspci -vmm
& looking for PhySlot entries.This is for older systems before Dell's biosdevnames.