From 161c13cc95a54b7658a7a8b67247464a0754df31 Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Thu, 25 Jun 2020 14:29:12 -0500 Subject: [PATCH] Adapt link name script for reuse native NIC port Uplink rep NIC port won't be re-created when goes to switchdev mode, rename native NIC port when driver loads. Signed-off-by: Bodong Wang Signed-off-by: Vladimir Sokolovsky --- kernel-boot/82-net-setup-link.rules | 11 +++++++++-- kernel-boot/vf-net-link-name.sh | 16 +++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/kernel-boot/82-net-setup-link.rules b/kernel-boot/82-net-setup-link.rules index 5c73a5f..2c09533 100644 --- a/kernel-boot/82-net-setup-link.rules +++ b/kernel-boot/82-net-setup-link.rules @@ -1,3 +1,10 @@ SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}!="", ATTR{phys_port_name}!="", \ - IMPORT{program}="/lib/udev/vf-net-link-name.sh $attr{phys_switch_id} $attr{phys_port_name}" \ - NAME="$env{NAME}", RUN+="/sbin/ethtool -L $env{NAME} combined 4" + IMPORT{program}="/lib/udev/vf-net-link-name.sh $attr{phys_port_name} $attr{phys_switch_id}" \ + NAME="$env{NAME}", GOTO="net_setup_skip_link_name" + +SUBSYSTEM=="net", ACTION=="add", ATTR{phys_port_name}!="", \ + IMPORT{program}="/lib/udev/vf-net-link-name.sh $attr{phys_port_name}" \ + NAME="$env{NAME}" + +LABEL="net_setup_skip_link_name" +RUN+="/sbin/ethtool -L $env{NAME} combined 4" diff --git a/kernel-boot/vf-net-link-name.sh b/kernel-boot/vf-net-link-name.sh index 6ca6fa4..b910687 100755 --- a/kernel-boot/vf-net-link-name.sh +++ b/kernel-boot/vf-net-link-name.sh @@ -1,16 +1,16 @@ #!/bin/bash -SWID=$1 +SWID=$2 # might be pf0vf1 so only get vf number -PORT=${2##*f} -PORT_NAME=$2 +PORT=${1##*f} +PORT_NAME=$1 # need the PATH for BF ARM lspci to work PATH=/bin:/sbin:/usr/bin:/usr/sbin is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0` if [ $is_bf -eq 1 ]; then - echo NAME=`echo ${2} | sed -e "s/vf-1/hpf/;s/\(pf[[:digit:]]\+\)p.*/\1m0/"` + echo NAME=`echo ${1} | sed -e "s/\(pf[[:digit:]]\+\)$/\1hpf/"` exit 0 fi @@ -25,6 +25,10 @@ if [ -n "$ID_NET_NAME_PATH" ]; then exit fi +if [ -z "$SWID" ]; then + exit 0 +fi + # for SF mdev devices function get_sf_rep_name() { b=`udevadm info -q property -p /sys/bus/pci/devices/$1/net/* | grep "ID_PATH=" | cut -d- -f2 | cut -d: -f2` @@ -85,7 +89,9 @@ function get_pci_port_name() { # for vf rep get parent slot/path. parent_phys_port_name=${PORT_NAME%vf*} -parent_phys_port_name=${parent_phys_port_name//f} +parent_phys_port_name=${parent_phys_port_name//pf} +((parent_phys_port_name&=0x7)) +parent_phys_port_name="p$parent_phys_port_name" # try at most two times for cnt in {1..2}; do for pci in `ls -l /sys/class/net/*/device | cut -d "/" -f9-`; do