[openwrt/openwrt] kernel: modules: add Mellanox Spectrum hotplug renaming script
LEDE Commits
lede-commits at lists.infradead.org
Mon Oct 6 10:06:32 PDT 2025
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/8edcd772db0086898b09d73d359bdc9d96b241ba
commit 8edcd772db0086898b09d73d359bdc9d96b241ba
Author: Til Kaiser <mail at tk154.de>
AuthorDate: Mon Dec 16 19:26:20 2024 +0100
kernel: modules: add Mellanox Spectrum hotplug renaming script
Currently, the interfaces of the Mellanox Spectrum Switch QSFP ports
are all labeled eth*. Their order doesn't match the faceplate and is
different for each model.
They could be named during boot, but this isn't sufficient because they
support port splitting. After such ports are split, their port naming
begins again with eth*, and the same is true after they are unsplit again.
A hotplug script is used here that reads from the sysfs file
phys_port_name, which contains p1, p2, p3, ... for unsplit ports
and p1s0, p1s1, p1s2 for split ports.
Signed-off-by: Til Kaiser <mail at tk154.de>
Link: https://github.com/openwrt/openwrt/pull/17251
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../kernel/linux/files/hotplug-mlxsw-spectrum-port-names.sh | 10 ++++++++++
package/kernel/linux/modules/netdevices.mk | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/package/kernel/linux/files/hotplug-mlxsw-spectrum-port-names.sh b/package/kernel/linux/files/hotplug-mlxsw-spectrum-port-names.sh
new file mode 100644
index 0000000000..7637725f67
--- /dev/null
+++ b/package/kernel/linux/files/hotplug-mlxsw-spectrum-port-names.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$ACTION" = "add" ]; then
+ read -r board_name < "/tmp/sysinfo/board_name"
+
+ if [[ "$board_name" = "mellanox-technologies-ltd-msn*" ]]; then
+ read -r port_name < "/sys/class/net/$DEVICENAME/phys_port_name"
+ [ -n "$port_name" ] && ip link set "$DEVICENAME" name "sw$port_name"
+ fi
+fi
diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk
index 0aed1655a9..522e76d180 100644
--- a/package/kernel/linux/modules/netdevices.mk
+++ b/package/kernel/linux/modules/netdevices.mk
@@ -1972,6 +1972,13 @@ define KernelPackage/mlxsw-spectrum/description
Spectrum/Spectrum-2/Spectrum-3/Spectrum-4 Ethernet Switch ASICs.
endef
+define KernelPackage/mlxsw-spectrum/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/net
+ $(INSTALL_DATA) \
+ ./files/hotplug-mlxsw-spectrum-port-names.sh \
+ $(1)/etc/hotplug.d/net/10-mlxsw-spectrum-port-names
+endef
+
$(eval $(call KernelPackage,mlxsw-spectrum))
More information about the lede-commits
mailing list