Are devices on pci bus always probed in the same order?

848 views Asked by At

I have 2 wireless pci cards (same model, but can work under 2 different modes) on the bus. They share the same driver. What I want to do is to hack the driver like this: check the pci index, the first probed device (index 0) will be configured as mode A, the next one (index 1) will be configured as mode B.

so I want to know if they are probed in the same order every time the system init.

If the probe order is random, is there any other way can do that?


I tried this: plug the same card into difference slots, and check what I got under /sys/devices/pci0000:00. the result are all the same. so the kernel know nothing about the physical slot at all? I was thinking maybe the kernel know which physical slot the card was mounted on. pity..

1

There are 1 answers

2
0andriy On

To answer: No, they are not in general.

To what you are trying to resolve: No need to do that since it's fixed in modern kernels Linux systems, The name of network interface is linked to the physical slot of the device. You will always have same names until you physically move the cards.

Correction. Initially I thought that this is provided by kernel. No, it's provided by user space helper, i.e. udev.

  1. Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)
  2. Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)
  3. Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0)
  4. Names incorporating the interfaces's MAC address (example: enx78e7d1ea46da)
  5. Classic, unpredictable kernel-native ethX naming (example: eth0)

Origin: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

Example:

% ip link list dev enp0s20u2c2
42: enp0s20u2c2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 4a:06:8b:65:72:36 brd ff:ff:ff:ff:ff:ff
% ls -l /sys/class/net/enp0s20u2c2
lrwxrwxrwx 1 root root 0 Dec 23 14:59 /sys/class/net/enp0s20u2c2 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:2.0/net/enp0s20u2c2