On Mon, Mar 06, 2023 at 03:05:42PM +0100, Kevin Keijzer via coreboot wrote:
Hello,
I've been trying to figure out how predictable interface naming works, especially the "on-board index number", that the firmware apparently passes(?)
I'm currently working on a port for the ASRock B75M-ITX, which has a Realtek NIC as PCI device 03:00.0. The Linux kernel calls this device enp3s0, which makes sense and works fine. However, on my ASUS P8Z77-V and my Lenovo X230, the Intel NIC is called eno0, which makes more sense, because it's "ethernet onboard 0" and not a physical network card stuck in a PCI Express slot.
At first I thought that maybe this was an e1000e-specific way of naming interfaces, but at the office I have an old Gigabyte GA-G41M-ES2L-based file server, running coreboot, also with a Realtek NIC, also being PCI device 03:00.0, which is called eno0 by the kernel as well, with enp3s0 as altname. (So it's not that.)
I ended up reading about the interface (re)naming process, which seems to be handled by systemd-udevd [1]:
~~~~
It looks like my B75M-ITX currently uses option 3, while I want it to use option 1, like all my other machines do. So according to the documentation, interfaces called enoX or ensX use index numbers provided by the firmware. However, I have no idea how or where this is defined. I would expect something to be in devicetree.cb, but I can't see anything seemingly related anywhere.
So my question is: how does coreboot pass "index numbers for on-board devices" to the kernel / udev, and how can I define them properly on boards where this is not working the way it should?
I think you simply need to explicitly list the device in the device tree, and a SMBIOS type 41 entry will be generated automatically. See https://github.com/coreboot/coreboot/blob/73e9ac66ad8ff8f4b15389b5685f808ac2...
And for instance
https://github.com/coreboot/coreboot/blob/b5df65a9aaee50421913ace6d7a4b35e0d...
https://github.com/coreboot/coreboot/blob/b5df65a9aaee50421913ace6d7a4b35e0d...
Seems with CONFIG_SMBIOS_TYPE41_PROVIDED_BY_DEVTREE you can even control which NIC gets what index if you have more than one.