diff --git a/lib/puppet/provider/sriov_vf_config/numvfs.rb b/lib/puppet/provider/sriov_vf_config/numvfs.rb index 2ef4f63e5..d5238efcf 100644 --- a/lib/puppet/provider/sriov_vf_config/numvfs.rb +++ b/lib/puppet/provider/sriov_vf_config/numvfs.rb @@ -62,14 +62,32 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do File.write("/sys/bus/pci/drivers/mlx5_core/unbind",vfs_pci) 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 %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" %x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} inline-mode transport} end %x{/usr/sbin/ethtool -K #{sriov_get_interface} hw-tc-offload on} 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 "/sys/class/net/#{sriov_get_interface}/device/sriov_numvfs" end diff --git a/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb b/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb index fb3192fba..75a76f0f8 100644 --- a/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb +++ b/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb @@ -91,6 +91,7 @@ then fi 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/ifup eth0 if [[ \"$(/usr/sbin/devlink dev eswitch show pci/\"$interface_pci\")\" =~ \"mode switchdev\" ]] then echo \"PCI device $interface_pci set to mode switchdev.\" diff --git a/templates/switchdev/switchdev.epp b/templates/switchdev/switchdev.epp index 1d3292564..af13764f2 100644 --- a/templates/switchdev/switchdev.epp +++ b/templates/switchdev/switchdev.epp @@ -22,6 +22,7 @@ then fi 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/ifup <%=$interface%> if [[ "$(/usr/sbin/devlink dev eswitch show pci/"$interface_pci")" =~ "mode switchdev" ]] then echo "PCI device $interface_pci set to mode switchdev."