diff options
author | Charles Hardin <charles.hardin@chargepoint.com> | 2022-10-10 13:30:10 -0700 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-10-31 21:11:24 +0100 |
commit | a0961675d370ebe1308b8c11db46871aeed9948c (patch) | |
tree | 2e950403e242366f66ec31856d4a60a61df5d577 /src | |
parent | 0cf16924933a6fe1f038f3ec9a6b4bfa7795e1eb (diff) | |
download | systemd-a0961675d370ebe1308b8c11db46871aeed9948c.tar.gz |
udev-builtin-net_id: support getting usb path off the host
To support predictable interface names in various embeeded systems
add support for an additional naming scheming using the USB host
interface. Several asics have usb controllers that are platform
devices and not children of a pci interface. These embedded systems
should be able to enumerate interfaces by udev path as well to support
configurations and policies.
Signed-off-by: Charles Hardin <charles.hardin@chargepoint.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/netif-naming-scheme.c | 1 | ||||
-rw-r--r-- | src/shared/netif-naming-scheme.h | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-net_id.c | 19 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c index 18748e5376..b6a97527d8 100644 --- a/src/shared/netif-naming-scheme.c +++ b/src/shared/netif-naming-scheme.c @@ -25,6 +25,7 @@ static const NamingScheme naming_schemes[] = { { "v250", NAMING_V250 }, { "v251", NAMING_V251 }, { "v252", NAMING_V252 }, + { "v253", NAMING_V253 }, /* … add more schemes here, as the logic to name devices is updated … */ EXTRA_NET_NAMING_MAP diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h index 4fa9170969..bb893870e9 100644 --- a/src/shared/netif-naming-scheme.h +++ b/src/shared/netif-naming-scheme.h @@ -38,6 +38,7 @@ typedef enum NamingSchemeFlags { 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 */ + NAMING_USB_HOST = 1 << 16, /* Generate names for usb host */ /* And now the masks that combine the features above */ NAMING_V238 = 0, @@ -51,6 +52,7 @@ typedef enum NamingSchemeFlags { NAMING_V250 = NAMING_V249 | NAMING_XEN_VIF, NAMING_V251 = NAMING_V250 | NAMING_BRIDGE_MULTIFUNCTION_SLOT, NAMING_V252 = NAMING_V251 | NAMING_DEVICETREE_ALIASES, + NAMING_V253 = NAMING_V252 | NAMING_USB_HOST, EXTRA_NET_NAMING_SCHEMES diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 7504123700..557e459191 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -1202,9 +1202,24 @@ static int builtin_net_id(sd_device *dev, sd_netlink **rtnl, int argc, char *arg return 0; } - /* get PCI based path names, we compose only PCI based paths */ - if (names_pci(dev, &info, &names) < 0) + /* get PCI based path names */ + r = names_pci(dev, &info, &names); + if (r < 0) { + /* + * check for usb devices that are not off pci interfaces to + * support various on-chip asics that have usb ports + */ + if (r == -ENOENT && + naming_scheme_has(NAMING_USB_HOST) && + names_usb(dev, &names) >= 0 && names.type == NET_USB) { + char str[ALTIFNAMSIZ]; + + if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.usb_ports)) + udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str); + } + return 0; + } /* plain PCI device */ if (names.type == NET_PCI) { |