Predict/force PCI slot id given by the kernel to NICs
Good day all, I am working on a Proliant server model which have 6 physical pci slots. They are going to be used for NICs with either 2 or 4 interfaces and installed in an arbitrarily order in the slots. By this I mean that the a certain box will only have a card/s on only certain slots. I need to write a program to its able to predict/read what bus id (slot id) the kernel gives to each interface for every card. The program should be able to relate the bus id to the slot where it is physically installed at. I understand that some cards obtain a different bus id's even do they are connected on the same physical pci slot. So if I could find a way where the program is able to control/predict what bus id is given to them by the kernel to each slot, that would solve my problem. The reason for this is because, by identifying the slot where a certain card is installed, I can use that bus id to change the udev rule naming for the card's interfaces. For example, Card at slot 1? rename its interfaces to s1pX where 'p' stands for port. I just need help being pointed to the right direction. Will I find all my answers at pci.h? The man page for lspci sends me to this file. Let me know if I need to be more clear. Thanks for your time. Jaime
On Tue, May 20, 2014 at 03:55:09PM -0500, Jaime Arrocha wrote:
Good day all,
I am working on a Proliant server model which have 6 physical pci slots. They are going to be used for NICs with either 2 or 4 interfaces and installed in an arbitrarily order in the slots. By this I mean that the a certain box will only have a card/s on only certain slots.
I need to write a program to its able to predict/read what bus id (slot id) the kernel gives to each interface for every card. The program should be able to relate the bus id to the slot where it is physically installed at.
The kernel already gives you this information in sysfs, if the BIOS provides it.
I understand that some cards obtain a different bus id's even do they are connected on the same physical pci slot. So if I could find a way where the program is able to control/predict what bus id is given to them by the kernel to each slot, that would solve my problem.
You can't do that, the BIOS picks the bus ids, and they can be random for all it cares. You can not pick them at all, that's not how PCI works, sorry.
The reason for this is because, by identifying the slot where a certain card is installed, I can use that bus id to change the udev rule naming for the card's interfaces.
udev already does this in a persistent way, using the bus id and slot number, if present, by default, why do you have to add any additional logic here?
For example, Card at slot 1? rename its interfaces to s1pX where 'p' stands for port.
Already done, look at the default naming scheme udev provides for network devices :) Hope this helps, greg k-h
On Tue, 20 May 2014 15:55:09 -0500, Jaime Arrocha said:
I am working on a Proliant server model which have 6 physical pci slots. They are going to be used for NICs with either 2 or 4 interfaces and installed in an arbitrarily order in the slots. By this I mean that the a certain box will only have a card/s on only certain slots.
I need to write a program to its able to predict/read what bus id (slot id) the kernel gives to each interface for every card. The program should be able to relate the bus id to the slot where it is physically installed at.
Have whatever installer program (anaconda for RH-based, etc) call an exit script that does an 'lspci | grep your_nic_card_here'? and scribble in the /etc/udev/rules.d file?
participants (3)
-
Greg KH -
Jaime Arrocha -
Valdis.Kletnieks@vt.edu