Adding a udev rule to save sriov interface name before configuring switchdev
After moving mlnx interfaces to switchdev mode in sriov, it will reset that interface and may change its name and also will need ifup in order to get back the previous configuration. So adding a udev rule and ifup command the save the interface name and its configuration Change-Id: Ib4f384da344344f9e2ec666b0d8dbae441f24568 Closes-Bug: 1816710
This commit is contained in:
parent
105e75fcfd
commit
cd31dd2da9
@ -62,14 +62,32 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do
|
|||||||
File.write("/sys/bus/pci/drivers/mlx5_core/unbind",vfs_pci)
|
File.write("/sys/bus/pci/drivers/mlx5_core/unbind",vfs_pci)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Saving the name of sriov interface to udev rules
|
||||||
|
udev_file_path = "/etc/udev/rules.d/70-persistent-net.rules"
|
||||||
|
sriov_interface_mac = File.read(sriov_interface_mac_path).strip
|
||||||
|
udev_data_line = get_udev_data_line(sriov_interface_mac)
|
||||||
|
File.write(udev_file_path, udev_data_line, mode: 'a')
|
||||||
|
%x{/usr/sbin/udevadm control --reload-rules}
|
||||||
|
%x{/usr/sbin/udevadm trigger}
|
||||||
|
|
||||||
# Changing the mode of sriov interface to switchdev mode
|
# Changing the mode of sriov interface to switchdev mode
|
||||||
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} mode switchdev}
|
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} mode switchdev}
|
||||||
|
%x{/usr/sbin/ifup #{sriov_get_interface}}
|
||||||
if get_interface_device == "0x1013" || get_interface_device == "0x1015"
|
if get_interface_device == "0x1013" || get_interface_device == "0x1015"
|
||||||
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} inline-mode transport}
|
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} inline-mode transport}
|
||||||
end
|
end
|
||||||
%x{/usr/sbin/ethtool -K #{sriov_get_interface} hw-tc-offload on}
|
%x{/usr/sbin/ethtool -K #{sriov_get_interface} hw-tc-offload on}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_udev_data_line(mac)
|
||||||
|
'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="' + "#{mac}" + '", NAME="' + "#{sriov_get_interface}" + "\"\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def sriov_interface_mac_path
|
||||||
|
"/sys/class/net/#{sriov_get_interface}/address"
|
||||||
|
end
|
||||||
|
|
||||||
def sriov_numvfs_path
|
def sriov_numvfs_path
|
||||||
"/sys/class/net/#{sriov_get_interface}/device/sriov_numvfs"
|
"/sys/class/net/#{sriov_get_interface}/device/sriov_numvfs"
|
||||||
end
|
end
|
||||||
|
@ -91,6 +91,7 @@ then
|
|||||||
fi
|
fi
|
||||||
interface_pci=$(grep PCI_SLOT_NAME /sys/class/net/eth0/device/uevent | cut -d'=' -f2)
|
interface_pci=$(grep PCI_SLOT_NAME /sys/class/net/eth0/device/uevent | cut -d'=' -f2)
|
||||||
/usr/sbin/devlink dev eswitch set pci/\"$interface_pci\" mode switchdev
|
/usr/sbin/devlink dev eswitch set pci/\"$interface_pci\" mode switchdev
|
||||||
|
/usr/sbin/ifup eth0
|
||||||
if [[ \"$(/usr/sbin/devlink dev eswitch show pci/\"$interface_pci\")\" =~ \"mode switchdev\" ]]
|
if [[ \"$(/usr/sbin/devlink dev eswitch show pci/\"$interface_pci\")\" =~ \"mode switchdev\" ]]
|
||||||
then
|
then
|
||||||
echo \"PCI device $interface_pci set to mode switchdev.\"
|
echo \"PCI device $interface_pci set to mode switchdev.\"
|
||||||
|
@ -22,6 +22,7 @@ then
|
|||||||
fi
|
fi
|
||||||
interface_pci=$(grep PCI_SLOT_NAME /sys/class/net/<%=$interface%>/device/uevent | cut -d'=' -f2)
|
interface_pci=$(grep PCI_SLOT_NAME /sys/class/net/<%=$interface%>/device/uevent | cut -d'=' -f2)
|
||||||
/usr/sbin/devlink dev eswitch set pci/"$interface_pci" mode switchdev
|
/usr/sbin/devlink dev eswitch set pci/"$interface_pci" mode switchdev
|
||||||
|
/usr/sbin/ifup <%=$interface%>
|
||||||
if [[ "$(/usr/sbin/devlink dev eswitch show pci/"$interface_pci")" =~ "mode switchdev" ]]
|
if [[ "$(/usr/sbin/devlink dev eswitch show pci/"$interface_pci")" =~ "mode switchdev" ]]
|
||||||
then
|
then
|
||||||
echo "PCI device $interface_pci set to mode switchdev."
|
echo "PCI device $interface_pci set to mode switchdev."
|
||||||
|
Loading…
Reference in New Issue
Block a user