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 8654f98b13
commit 575504fee3
4 changed files with 34 additions and 44 deletions

View File

@ -10,8 +10,11 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do
def create
if File.file?(sriov_numvfs_path)
_set_numvfs
_apply_hw_offload
if ovs_mode == "switchdev"
_apply_hw_offload
else
_set_numvfs
end
else
warning("#{sriov_numvfs_path} doesn't exist. Check if #{sriov_get_interface} is a valid network interface supporting SR-IOV")
end
@ -44,29 +47,27 @@ Puppet::Type.type(:sriov_vf_config).provide(:numvfs) do
end
def _apply_hw_offload
# Changing the mode of virtual functions to hw-offload
if ovs_mode == "switchdev"
cur_value = File.read(vendor_path).strip
if cur_value == "0x15b3"
vfs_pcis = get_vfs_pcis
# Unbinding virtual functions
vfs_pcis.each do|vfs_pci|
File.write("/sys/bus/pci/drivers/mlx5_core/unbind",vfs_pci)
end
end
# Changing the mode of sriov interface to switchdev mode
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} mode switchdev}
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}
if cur_value == "0x15b3"
# Binding virtual functions
vfs_pcis.each do|vfs_pci|
File.write("/sys/bus/pci/drivers/mlx5_core/bind",vfs_pci)
end
# Changing the mode of virtual functions to support hw-offload
vendor_id = File.read(vendor_path).strip
# Setting the number of vfs
_set_numvfs
# Applying the hardware offloading
if vendor_id == "0x15b3"
vfs_pcis = get_vfs_pcis
# Unbinding virtual functions
vfs_pcis.each do|vfs_pci|
File.write("/sys/bus/pci/drivers/mlx5_core/unbind",vfs_pci)
end
end
# Changing the mode of sriov interface to switchdev mode
%x{/usr/sbin/devlink dev eswitch set pci/#{get_interface_pci} mode switchdev}
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 sriov_numvfs_path

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

@ -68,19 +68,20 @@ describe 'tripleo::host::sriov::numvfs_persistence' do
it 'configures persistence' do
is_expected.to contain_file('/etc/sysconfig/allocate_vfs').with(
:ensure => 'file',
:content => "Hashbang\nset -eux
:content => "Hashbang\nset -ex
set -o pipefail
if [ \"eth0\" == \"$1\" ]
then
exec 1> >(logger -s -t $(basename $0)) 2>&1
vendor_id=\"$(cat /sys/class/net/eth0/device/vendor)\"
if [ \"$(cat /sys/class/net/eth0/device/sriov_numvfs)\" == \"0\" ]
then
echo 10 > /sys/class/net/eth0/device/sriov_numvfs
else
exit 0
fi
if [ \"$(cat /sys/class/net/eth0/device/vendor)\" == \"0x15b3\" ]
if [ $vendor_id == \"0x15b3\" ]
then
vfs_pci_list=$(grep PCI_SLOT_NAME /sys/class/net/eth0/device/virtfn*/uevent | cut -d'=' -f2)
for pci in $vfs_pci_list
@ -103,13 +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 [ \"$(cat /sys/class/net/eth0/device/vendor)\" == \"0x15b3\" ]
then
for pci in $vfs_pci_list
do
echo \"$pci\" > /sys/bus/pci/drivers/mlx5_core/bind
done
fi
fi\n[ \"eth1\" == \"\$1\" ] && echo 8 > /sys/class/net/eth1/device/sriov_numvfs\n",
:group => 'root',
:mode => '0755',

View File

@ -1,17 +1,18 @@
<%- | String $content_string = '', String $interface = '', String $count = '' | -%>
<%=$content_string%>set -eux
<%=$content_string%>set -ex
set -o pipefail
if [ "<%=$interface%>" == "$1" ]
then
exec 1> >(logger -s -t $(basename $0)) 2>&1
vendor_id="$(cat /sys/class/net/<%=$interface%>/device/vendor)"
if [ "$(cat /sys/class/net/<%=$interface%>/device/sriov_numvfs)" == "0" ]
then
echo <%=$count%> > /sys/class/net/<%=$interface%>/device/sriov_numvfs
else
exit 0
fi
if [ "$(cat /sys/class/net/<%=$interface%>/device/vendor)" == "0x15b3" ]
if [ $vendor_id == "0x15b3" ]
then
vfs_pci_list=$(grep PCI_SLOT_NAME /sys/class/net/<%=$interface%>/device/virtfn*/uevent | cut -d'=' -f2)
for pci in $vfs_pci_list
@ -34,11 +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 [ "$(cat /sys/class/net/<%=$interface%>/device/vendor)" == "0x15b3" ]
then
for pci in $vfs_pci_list
do
echo "$pci" > /sys/bus/pci/drivers/mlx5_core/bind
done
fi
fi