udev: net_id: Use devicetree aliases when available
Devicetree firmware contains an "aliases" node, containing various aliases for devices described by the firmware. For ethernet devices, these are named "ethernet0", "ethernet1", etc. They provide a convenient means of numbering ethernet devices, especially on systems with no other stable number other than the address. In particular, U-Boot already uses these aliases to name its ethernet devices. Previously, there have been attempts (such as [1]) to add support for these aliases to Linux. However, these patches have been rejected because it is the maintainers' view that naming policy be left to userspace. Well, systemd is userspace, so here we are. In terms of implementation, apparently there can be multiple device trees at once. I have decided to dodge this problem for now, and just use /proc/device-tree. If it is desired to support multiple device trees later, then the scheme can be modified to include the device tree's index. For example, /sys/firmware/devicetree/base2/aliases/ethernet3 might be named enb2d3. For the moment we only support "ethernetX" aliases. Future patches might want to also handle "canX" and "wifiX". It is common on boards with only one ethernet device to use an alias of just "ethernet". In this case, the index is an implicit 0. In case the author of the firmware made a mistake, we check to ensure that aliases of "ethernet" and "ethernet0" do not both exist. [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/1399390594-1409-1-git-send-email-boris.brezillon@free-electrons.com/ Closes: #17625
This commit is contained in:
committed by
Lennart Poettering
parent
d9c6956ee4
commit
65c2ad985a
@@ -24,6 +24,7 @@ static const NamingScheme naming_schemes[] = {
|
||||
{ "v249", NAMING_V249 },
|
||||
{ "v250", NAMING_V250 },
|
||||
{ "v251", NAMING_V251 },
|
||||
{ "v252", NAMING_V252 },
|
||||
/* … add more schemes here, as the logic to name devices is updated … */
|
||||
|
||||
EXTRA_NET_NAMING_MAP
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef enum NamingSchemeFlags {
|
||||
NAMING_REPLACE_STRICTLY = 1 << 12, /* Use udev_replace_ifname() for NAME= rule */
|
||||
NAMING_XEN_VIF = 1 << 13, /* Generate names for Xen netfront devices */
|
||||
NAMING_BRIDGE_MULTIFUNCTION_SLOT = 1 << 14, /* Use PCI hotplug slot information associated with bridge, but only if PCI device is multifunction */
|
||||
NAMING_DEVICETREE_ALIASES = 1 << 15, /* Generate names from devicetree aliases */
|
||||
|
||||
/* And now the masks that combine the features above */
|
||||
NAMING_V238 = 0,
|
||||
@@ -49,6 +50,7 @@ typedef enum NamingSchemeFlags {
|
||||
NAMING_V249 = NAMING_V247 | NAMING_SLOT_FUNCTION_ID | NAMING_16BIT_INDEX | NAMING_REPLACE_STRICTLY,
|
||||
NAMING_V250 = NAMING_V249 | NAMING_XEN_VIF,
|
||||
NAMING_V251 = NAMING_V250 | NAMING_BRIDGE_MULTIFUNCTION_SLOT,
|
||||
NAMING_V252 = NAMING_V251 | NAMING_DEVICETREE_ALIASES,
|
||||
|
||||
EXTRA_NET_NAMING_SCHEMES
|
||||
|
||||
|
||||
Reference in New Issue
Block a user