puppet-tripleo/templates/switchdev/switchdev.epp
waleed mousa 10237e999d hw ovs offload - On some machines representor ports not created after reboot
On some machines it's failing to run the devlink and ethtool commands
without the full path of these commands

Closes-Bug: #1745821
Change-Id: If2f7c7a46fb1b52cce9ffbfa31a3161fc07f1334
2018-01-29 11:32:24 +00:00

45 lines
1.6 KiB
Plaintext

<%- | String $content_string = '', String $interface = '', String $count = '' | -%>
<%=$content_string%>set -eux
set -o pipefail
if [ "<%=$interface%>" == "$1" ]
then
exec 1> >(logger -s -t $(basename $0)) 2>&1
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" ]
then
vfs_pci_list=$(grep PCI_SLOT_NAME /sys/class/net/<%=$interface%>/device/virtfn*/uevent | cut -d'=' -f2)
for pci in $vfs_pci_list
do
echo "$pci" > /sys/bus/pci/drivers/mlx5_core/unbind
done
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
if [[ "$(/usr/sbin/devlink dev eswitch show pci/"$interface_pci")" =~ "mode switchdev" ]]
then
echo "PCI device $interface_pci set to mode switchdev."
else
echo "Failed to set PCI device $interface_pci to mode switchdev."
exit 1
fi
interface_device=$(cat /sys/class/net/<%=$interface%>/device/device)
if [ "$interface_device" == "0x1013" ] || [ "$interface_device" == "0x1015" ]
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