mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
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>
67 lines
1.4 KiB
Bash
Executable File
67 lines
1.4 KiB
Bash
Executable File
#!/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
|