Procházet zdrojové kódy

board/nvidia/bf3: set eth names according to doc

Set the names of the Ethernet interfaces that are exposed from a first
boot so they are aligned with those described by Mellanox/NVIDIA
documentation for the BF3.

Those tmfifo and oob interface names are describeded at:
  https://docs.nvidia.com/networking/display/bluefielddpuosv460/host-side+interface+configuration

When running the native Ubuntu on the BF3 board, the following udev
rules are set:
$ cat /etc/udev/rules.d/91-tmfifo_net.rules
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/platform/MLNXBF01:00/virtio1/net/eth[0-9]", NAME="tmfifo_net0"

$ cat /etc/udev/rules.d/92-oob_net.rules
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/platform/MLNXBF17:00/net/e*", NAME="oob_net0", RUN+="/sbin/sysctl -w net.ipv4.conf.oob_net0.arp_notify=1"

The default CX ports of the BF3 are:
ubuntu@bf$ ip link show p0
4: p0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode
   DEFAULT group default qlen 1000
    link/ether a0:88:c2:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    altname enp3s0f0np0
ubuntu@bf$ ip link show p1
5: p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode
   DEFAULT group default qlen 1000
    link/ether a0:88:c2:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    altname enp3s0f1np1

Signed-off-by: Vincent Jardin <vjardin@free.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
Vincent Jardin před 6 měsíci
rodič
revize
b77e468559

+ 66 - 0
board/nvidia/bf3/rootfs_overlay/etc/init.d/S04ifnames

@@ -0,0 +1,66 @@
+#!/bin/sh
+# Rename the board's interfaces according to Mellanox/NVIDIA's documentation
+
+DESC="bf3 interface renaming"
+DAEMON=ifnames
+
+rename_interface() {
+	bus_info=$1
+	new_name=$2
+	alt_name=$3
+
+	# Find the current interface name based on bus-info
+	iface=$(find /sys/class/net -type l -exec sh -c '
+	for i; do
+		[ "$(basename "$(readlink -f "$i"/device)")" = "$0" ] && basename "$i"
+	done
+	' "$bus_info" {} +)
+
+	# Rename the interface if found
+	if [ -n "$iface" ]; then
+		ip link set "$iface" name "$new_name"
+		printf "%s to %s" "$iface" "$new_name"
+
+		# Set altname if provided
+		if [ -n "$alt_name" ]; then
+			ip link property add dev "$new_name" altname "$alt_name"
+			printf "/%s" "$alt_name"
+		fi
+		printf "; "
+	else
+		echo "$bus_info not found"
+	fi
+}
+
+case "$1" in
+	start)
+		printf "Starting %s [%s]: " "$DESC" "$DAEMON"
+		# Initialize success flag
+		rename_allok=0
+		rename_interface "0000:03:00.0" "p0" "enp3s0f0np0" || rename_allok=1
+		rename_interface "0000:03:00.1" "p1" "enp3s0f1np1" || rename_allok=1
+		rename_interface "MLNXBF17:00" "oob_net0" "enamlnxbf17i0" || rename_allok=1
+		rename_interface "virtio1" "tmfifo_net0" || rename_allok=1
+
+		if [ "$rename_allok" -eq 0 ]; then
+			echo "OK"
+		else
+			echo "FAIL"
+		fi
+		;;
+
+	stop)	;;
+
+	restart)
+		# Optional: Handle restart by calling start after stop
+		$0 stop
+		$0 start
+		;;
+
+	*)
+		echo "Usage: $0 {start|stop|restart}"
+		exit 1
+		;;
+esac
+
+exit 0

+ 3 - 0
configs/nvidia_bf3_defconfig

@@ -3,11 +3,14 @@ BR2_cortex_a78=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_11=y
 BR2_GLOBAL_PATCH_DIR="board/nvidia/bf3/patches"
 BR2_DOWNLOAD_FORCE_CHECK_HASHES=y
+BR2_ROOTFS_OVERLAY="board/nvidia/bf3/rootfs_overlay"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.11.6"
 BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/nvidia/bf3/linux.config"
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+BR2_PACKAGE_LIBMNL=y
+BR2_PACKAGE_IPROUTE2=y
 BR2_TARGET_ROOTFS_INITRAMFS=y
 # BR2_TARGET_ROOTFS_TAR is not set