From da47437f32583c377c1e98e737dfd450d2d6cc6f Mon Sep 17 00:00:00 2001 From: Roy Tang Date: Wed, 27 May 2020 15:10:51 -0500 Subject: [PATCH] Allow neutron sriov agent to set num_queues per vf Change-Id: I465c882ab2939e5c0297c889fddc6c93bf5a7b91 --- .../bin/_neutron-sriov-agent-init.sh.tpl | 33 +++++++++++++++++-- neutron/values.yaml | 3 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/neutron/templates/bin/_neutron-sriov-agent-init.sh.tpl b/neutron/templates/bin/_neutron-sriov-agent-init.sh.tpl index 0583ea149d..d98cfe8f2b 100644 --- a/neutron/templates/bin/_neutron-sriov-agent-init.sh.tpl +++ b/neutron/templates/bin/_neutron-sriov-agent-init.sh.tpl @@ -17,8 +17,10 @@ limitations under the License. #NOTE: Please limit "besteffort" to dev env with mixed hardware computes only # For prod env, the target nic should be there, if not, script should error out. set -ex +BESTEFFORT=false {{- if ( has "besteffort" .Values.conf.sriov_init ) }} set +e +BESTEFFORT=true {{- end }} {{- range $k, $sriov := .Values.network.interface.sriov }} @@ -48,6 +50,31 @@ echo "{{ $qos.share }}" > /sys/class/net/{{ $sriov.device }}/device/sriov/{{ $qo echo "1" > /sys/class/net/{{ $sriov.device }}/device/sriov/qos/apply {{- end }} +# Set number of queues is best effort in case where VF is already binded, +# NIC will not allow to set, in such case, a node reboot will allow all +# VF to set properly. +{{- if hasKey $sriov "queues_per_vf" }} +set +e +{{- range $v, $qvf := $sriov.queues_per_vf }} +SMOKE=',' +MIRROR=' ' +SKIPLIST={{ $qvf.exclude_vf }} +SKIPLIST=${SKIPLIST//$SMOKE/$MIRROR} + +NUMVF={{ $sriov.num_vfs }} +for vf in `seq 0 $[$NUMVF - 1]` +do + if ! ( echo ${SKIPLIST[@]} | grep -q -w "$vf" ); then + echo "{{ $qvf.num_queues }}" > /sys/class/net/{{ $sriov.device }}/device/sriov/$vf/num_queues + fi +done + +{{- end }} +if ! $BESTEFFORT; then + set -e +fi +{{- end }} + {{- if $sriov.mtu }} ip link set dev {{ $sriov.device }} mtu {{ $sriov.mtu }} {{- end }} @@ -76,6 +103,6 @@ host = $(hostname --fqdn) EOF {{- end }} -{{- if ( has "besteffort" .Values.conf.sriov_init ) }} -exit 0 -{{ end }} +if $BESTEFFORT; then + exit 0 +fi diff --git a/neutron/values.yaml b/neutron/values.yaml index f443fa5fd4..a70803de84 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -120,6 +120,9 @@ network: # qos: # - vf_num: 0 # share: 10 + # queues_per_vf: + # - num_queues: 16 + # exclude_vf: 0,11,21 server: ingress: public: true