Get pci slot number in driver

John Baldwin jhb at freebsd.org
Thu Sep 3 23:07:12 UTC 2015


On Monday, August 24, 2015 08:17:02 AM Nomad Esst via freebsd-hackers wrote:
> Is it possible to find out the pci slot number on which the card is mounted in driver? I tried pci_get_slot but it's always 0.Any ideas about doing this?
> regards

It depends on what you mean by slot.  If you mean the label of the physical
slot in a chassis / motherboard, then there is no reliable way to determine
this.  (There are some PCI extended capabilities that I've never seen in the
wild that can communicate this.  There are various firmware tables ($PIR and
SMBIOS) on x86 that can in theory tell you this, but it's a crap shoot whether
the tables are correct or a pack of lies.  If you want to determine the "device"
field of a PCI device's (bus, device, function) config space access, you can
use pci_get_slot() (FreeBSD calls it a slot even though the standard name in
the PCI spec is "device" for legacy reasons as in original PCI a physical
slot did have a unique "device" address on a given bus).

-- 
John Baldwin


More information about the freebsd-drivers mailing list