From 9c35d0491343c8db7c5aba4b5fd75bd170ef1b2d Mon Sep 17 00:00:00 2001 From: waleed mousa Date: Thu, 13 Dec 2018 07:58:08 -0500 Subject: [PATCH] Configure switchedv while there is no vfs bounded When configuring vf-lag, it will not work properly when configuring switchdev capability while there are some vfs bounded. So removing all the binding codes as it's not needed anymore. Closes-Bug: 1809733 Change-Id: I135cef33bece6fd31363e093e53617caac413ce0 (cherry picked from commit bcf06e0b4bc84fa1b4b1cfc1d93a19a27bd0bed4) --- lib/puppet/provider/sriov_vf_config/numvfs.rb | 60 +------------------ manifests/host/sriov/numvfs_persistence.pp | 7 ++- ...pleo_host_sriov_numvfs_persistence_spec.rb | 29 --------- templates/switchdev/switchdev.epp | 29 --------- 4 files changed, 6 insertions(+), 119 deletions(-) diff --git a/lib/puppet/provider/sriov_vf_config/numvfs.rb b/lib/puppet/provider/sriov_vf_config/numvfs.rb index 1e9abfb8c..2ef4f63e5 100644 --- a/lib/puppet/provider/sriov_vf_config/numvfs.rb +++ b/lib/puppet/provider/sriov_vf_config/numvfs.rb @@ -47,26 +47,10 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do end def _apply_hw_offload - # Changing the mode of virtual functions to hw-offload + # Changing the mode of virtual functions to support hw-offload - bond_enabled = get_bond_enabled vendor_id = File.read(vendor_path).strip - # Adding the VF LAG - if vendor_id == "0x15b3" and bond_enabled - bond_masters = get_bond_masters - bond_master_hash = {} - bond_masters.each do |bond| - bond_interfaces = get_bond_interfaces(bond) - bond_master_hash[bond] = bond_interfaces - end - # Removing the slaves from the bond interfaces - bond_master_hash.each do |bond, bond_interfaces| - bond_interfaces.each do |bond_interface| - %x{echo "-#{bond_interface}" > /sys/class/net/#{bond}/bonding/slaves} - end - end - end # Setting the number of vfs _set_numvfs @@ -84,20 +68,6 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do %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} - if vendor_id == "0x15b3" - # Binding virtual functions - vfs_pcis.each do|vfs_pci| - File.write("/sys/bus/pci/drivers/mlx5_core/bind",vfs_pci) - end - end - if vendor_id and bond_enabled - # Adding the slaves back to the bond interfaces - bond_master_hash.each do |bond, bond_interfaces| - bond_interfaces.each do |bond_interface| - %x{echo "+#{bond_interface}" > /sys/class/net/#{bond}/bonding/slaves} - end - end - end end def sriov_numvfs_path @@ -136,32 +106,6 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do %x{cat /sys/class/net/#{sriov_get_interface}/device/device}.strip end - def get_bond_enabled - if %x{lsmod | grep bonding}.strip.length > 0 - true - else - false - end - end - - def bond_masters_path - "/sys/class/net/bonding_masters" - end - - def get_bond_masters - if File.file?(bond_masters_path) - File.read(bond_masters_path).split() - end - end - - def get_bond_interfaces_path(bond) - "/sys/class/net/#{bond}/bonding/slaves" - end - - def get_bond_interfaces(bond) - if File.file?(get_bond_interfaces_path(bond)) - File.read(get_bond_interfaces_path(bond)).split() - end - end end + diff --git a/manifests/host/sriov/numvfs_persistence.pp b/manifests/host/sriov/numvfs_persistence.pp index 9ec247ab4..066105978 100644 --- a/manifests/host/sriov/numvfs_persistence.pp +++ b/manifests/host/sriov/numvfs_persistence.pp @@ -74,9 +74,11 @@ define tripleo::host::sriov::numvfs_persistence( 'count' => "${count}" }) } else { - $vfdef_str = "${content_string}[ \"${interface}\" == \"\$1\" ] && echo ${count} > /sys/class/net/${interface}/device/sriov_numvfs\n" + $vfdef_str = "${content_string}[ \"${interface}\" == \"\$1\" ] \ +&& echo ${count} > /sys/class/net/${interface}/device/sriov_numvfs\n" } - $udev_str = "${udev_rules}KERNEL==\"${interface}\", RUN+=\"/etc/sysconfig/allocate_vfs %k\"\n" + $udev_str = "${udev_rules}KERNEL==\"${interface}\", \ +RUN+=\"/etc/sysconfig/allocate_vfs %k\"\n" tripleo::host::sriov::numvfs_persistence{"mapped ${interface}": vf_defs => delete_at($vf_defs, 0), content_string => $vfdef_str, @@ -84,4 +86,3 @@ define tripleo::host::sriov::numvfs_persistence( } } } - diff --git a/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb b/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb index 0f5f654a6..fb3192fba 100644 --- a/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb +++ b/spec/defines/tripleo_host_sriov_numvfs_persistence_spec.rb @@ -75,18 +75,6 @@ if [ \"eth0\" == \"$1\" ] then exec 1> >(logger -s -t $(basename $0)) 2>&1 vendor_id=\"$(cat /sys/class/net/eth0/device/vendor)\" - if [[ $vendor_id == \"0x15b3\" && $(/sbin/lsmod | grep bonding) ]] - then - declare -A bonds - for bond in `cat /sys/class/net/bonding_masters` - do - bonds[$bond]=`cat \"/sys/class/net/$bond/bonding/slaves\"` - for bond_interface in ${bonds[$bond]} - do - echo \"-$bond_interface\" > \"/sys/class/net/$bond/bonding/slaves\" - done - done - fi if [ \"$(cat /sys/class/net/eth0/device/sriov_numvfs)\" == \"0\" ] then echo 10 > /sys/class/net/eth0/device/sriov_numvfs @@ -116,23 +104,6 @@ then /usr/sbin/devlink dev eswitch set pci/\"$interface_pci\" inline-mode transport fi /usr/sbin/ethtool -K eth0 hw-tc-offload on - if [ $vendor_id == \"0x15b3\" ] - then - for pci in $vfs_pci_list - do - echo \"$pci\" > /sys/bus/pci/drivers/mlx5_core/bind - done - fi - if [[ $vendor_id == \"0x15b3\" && $(/sbin/lsmod | grep bonding) ]] - then - for bond in \"${!bonds[@]}\" - do - for bond_interface in ${bonds[$bond]} - do - echo \"+$bond_interface\" > \"/sys/class/net/$bond/bonding/slaves\" - done - done - fi fi\n[ \"eth1\" == \"\$1\" ] && echo 8 > /sys/class/net/eth1/device/sriov_numvfs\n", :group => 'root', :mode => '0755', diff --git a/templates/switchdev/switchdev.epp b/templates/switchdev/switchdev.epp index 9981ccb98..1d3292564 100644 --- a/templates/switchdev/switchdev.epp +++ b/templates/switchdev/switchdev.epp @@ -6,18 +6,6 @@ if [ "<%=$interface%>" == "$1" ] then exec 1> >(logger -s -t $(basename $0)) 2>&1 vendor_id="$(cat /sys/class/net/<%=$interface%>/device/vendor)" - if [[ $vendor_id == "0x15b3" && $(/sbin/lsmod | grep bonding) ]] - then - declare -A bonds - for bond in `cat /sys/class/net/bonding_masters` - do - bonds[$bond]=`cat "/sys/class/net/$bond/bonding/slaves"` - for bond_interface in ${bonds[$bond]} - do - echo "-$bond_interface" > "/sys/class/net/$bond/bonding/slaves" - done - done - fi if [ "$(cat /sys/class/net/<%=$interface%>/device/sriov_numvfs)" == "0" ] then echo <%=$count%> > /sys/class/net/<%=$interface%>/device/sriov_numvfs @@ -47,21 +35,4 @@ then /usr/sbin/devlink dev eswitch set pci/"$interface_pci" inline-mode transport fi /usr/sbin/ethtool -K <%=$interface%> hw-tc-offload on - if [ $vendor_id == "0x15b3" ] - then - for pci in $vfs_pci_list - do - echo "$pci" > /sys/bus/pci/drivers/mlx5_core/bind - done - fi - if [[ $vendor_id == "0x15b3" && $(/sbin/lsmod | grep bonding) ]] - then - for bond in "${!bonds[@]}" - do - for bond_interface in ${bonds[$bond]} - do - echo "+$bond_interface" > "/sys/class/net/$bond/bonding/slaves" - done - done - fi fi