kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Predict/force PCI slot id given by the kernel to NICs
Date: Wed, 21 May 2014 06:18:37 +0900	[thread overview]
Message-ID: <20140520211837.GB1585@kroah.com> (raw)
In-Reply-To: <CAFGHVq0F6=PzXNk1zaZL7hvTDr9hZmZw=YqMfccLy+vVggzvCg@mail.gmail.com>

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

  reply	other threads:[~2014-05-20 21:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 20:55 Predict/force PCI slot id given by the kernel to NICs Jaime Arrocha
2014-05-20 21:18 ` Greg KH [this message]
2014-05-20 21:21 ` Valdis.Kletnieks at vt.edu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140520211837.GB1585@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).