udev-builtin-net_id: name auxiliary sub-function (SF) host network devices
Some drivers (currently mlx5_core) expose sub-functions (SFs) of a PCI Physical Function as auxiliary devices. Each SF carries a host network interface that sits below the aux device in sysfs: /sys/devices/.../<PF BDF>/mlx5_core.sf.<idx>/net/eth<N> Because the network device's immediate parent is the aux device and not a PCI device, names_pci() bails out and these interfaces fall through to the kernel-assigned eth<N> name, which is not stable across reboots, module reloads or topology changes. The naming applies when the SF network device's direct sysfs parent is the aux device that exposes sfnum, i.e. the kernel driver passes the aux device to SET_NETDEV_DEV(). mlx5_core does so. ice's ice_sf_cfg_netdev() currently passes the parent PF's PCI device, so ice SF network devices sit as siblings of the PF rather than below the aux device and fall outside this precondition; pending a kernel change in ice to mirror mlx5's SET_NETDEV_DEV(netdev, &adev->dev), they continue to receive the kernel-assigned name as they do today. The aux device exposes 'sfnum', the user-defined sub-function number (the value passed to "devlink port add ... sfnum N"), which is stable and unique within its parent PF. The aux device's direct sysfs parent is the PF's PCI device. Treat an SF host network device analogously to an SR-IOV VF host network device: walk to the parent PCI function, derive the base name from there, then append a single-character "S<sfnum>" suffix. Lowercase 's' is already taken (slot) and the existing grammar uses one character per token, so 'S' is the best option. E.g. for an SF whose parent PF is at PCI 0000:c1:00.0 and which was added with "sfnum 88": ID_NET_NAME_PATH=enp193s0f0S88 ID_NET_NAME_SLOT=enp193s0f0S88 This is parallel to how SR-IOV VFs get a "v<N>" suffix on top of the parent PF's name. Gate the new behaviour behind NAMING_SUBFUNC and NAMING_V261. Document the new suffix in both the ID_NET_NAME_SLOT and ID_NET_NAME_PATH grammars in systemd.net-naming-scheme(7) and add a v261 history entry. Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ static const NamingScheme naming_schemes[] = {
|
||||
{ "v258", NAMING_V258 },
|
||||
{ "v259", NAMING_V259 },
|
||||
{ "v260", NAMING_V260 },
|
||||
{ "v261", NAMING_V261 },
|
||||
/* … add more schemes here, as the logic to name devices is updated … */
|
||||
|
||||
EXTRA_NET_NAMING_MAP
|
||||
|
||||
@@ -44,6 +44,9 @@ typedef enum NamingSchemeFlags {
|
||||
NAMING_USE_INTERFACE_PROPERTY = 1 << 20, /* Use INTERFACE udev property, rather than sysname, when no renaming is requested. */
|
||||
NAMING_DEVICETREE_ALIASES_WLAN = 1 << 21, /* Generate names from devicetree aliases for WLAN devices */
|
||||
NAMING_MCTP = 1 << 22, /* Use "mc" prefix for MCTP devices */
|
||||
NAMING_SUBFUNC = 1 << 23, /* Generate names for auxiliary sub-function (SF) network
|
||||
* devices (e.g. mlx5_core SFs), based on the parent PF's
|
||||
* PCI path and the user-defined sfnum, with an "S" suffix. */
|
||||
|
||||
/* And now the masks that combine the features above */
|
||||
NAMING_V238 = 0,
|
||||
@@ -67,6 +70,7 @@ typedef enum NamingSchemeFlags {
|
||||
NAMING_V258 = NAMING_V257 | NAMING_USE_INTERFACE_PROPERTY,
|
||||
NAMING_V259 = NAMING_V258 | NAMING_DEVICETREE_ALIASES_WLAN,
|
||||
NAMING_V260 = NAMING_V259 | NAMING_MCTP,
|
||||
NAMING_V261 = NAMING_V260 | NAMING_SUBFUNC,
|
||||
|
||||
EXTRA_NET_NAMING_SCHEMES
|
||||
|
||||
|
||||
Reference in New Issue
Block a user