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 bcf06e0b4b)
This commit is contained in:
waleed mousa 2018-12-13 07:58:08 -05:00
parent 608096fb3c
commit 9c35d04913
4 changed files with 6 additions and 119 deletions

View File

@ -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

View File

@ -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(
}
}
}

View File

@ -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',

View File

@ -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