In Linux kernel space, given a struct net_device *
how can I get the associated PCI address?
Seems like I found a way. Assuming the network driver creating the net_device
does SET_NETDEV_DEV()
, then it's possible to get the associated struct pci_dev *pdev = to_pci_dev(netdev->dev.parent)
and with that pdev->bus->number
which is the PCI bus id, and PCI_SLOT(pdev->devfn)
which is the PCI device id.
Thanks for all the comments btw, extremely useful.