SRIOV: Limit number of vfs to n-1 created by default

This PS udpates the sriov init script to by default create the
max number of vfs supported by the card -1. Which works round
issues encoutered with many cards that prevents ther theroretical
max being attainable.

Change-Id: I01f8ce1f36b6053a5ef68119d87b67050ffe99d1
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2018-09-18 12:40:13 -05:00 committed by Pete Birley
parent 8e4ee070e6
commit a5d6be32c7
1 changed files with 13 additions and 1 deletions

View File

@ -22,7 +22,19 @@ set -ex
if [ "x{{ $sriov.num_vfs }}" != "x" ]; then
echo "{{ $sriov.num_vfs }}" > /sys/class/net/{{ $sriov.device }}/device/sriov_numvfs
else
NUM_VFS=$(cat /sys/class/net/{{ $sriov.device }}/device/sriov_totalvfs)
#NOTE(portdirect): Many NICs have difficulty creating more than n-1 over their
# claimed limit, by default err on the side of caution and account for this
# limitation.
TOT_NUM_VFS=$(cat /sys/class/net/{{ $sriov.device }}/device/sriov_totalvfs)
if [[ "$TOT_NUM_VFS" -le "0" ]]; then
NUM_VFS="$TOT_NUM_VFS"
else
if [[ "$((TOT_NUM_VFS - 1 ))" -le "1" ]]; then
NUM_VFS=1
else
NUM_VFS="$((TOT_NUM_VFS - 1 ))"
fi
fi
echo "${NUM_VFS}" > /sys/class/net/{{ $sriov.device }}/device/sriov_numvfs
fi
{{- if $sriov.mtu }}