Skip to content

Commit

Permalink
vDPA NIC configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Milleri <[email protected]>
  • Loading branch information
lmilleri committed Jan 24, 2023
1 parent 7ae4429 commit 110adc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ contents:
set -eux
input="/etc/sriov_config.json"
minId=-1
maxId=-1
extract_min_max_ids() {
range=$(jq -c '.vfRange' -r <<< $group)
ids=(${range//-/ })
length=${#ids[@]}
minId=-1
maxId=-1
if [[ length -eq 2 ]]; then
minId=${ids[0]}
maxId=${ids[1]}
elif [[ length -eq 1 ]]; then
minId=${ids[0]}
maxId=$minId
fi
}
if [ ! -f $input ]; then
echo "File /etc/sriov_config.json not exist."
exit
Expand All @@ -25,11 +43,25 @@ contents:
echo "load VF driver for $pci_addr"
VfDirs=$(ls /sys/bus/pci/devices/${pci_addr} | grep virtfn)
# load VF driver
# load VF driver and configure vdpa if needed
for VfDir in $VfDirs
do
VfPciAddr=$(basename "$( readlink -f /sys/bus/pci/devices/${pci_addr}/$VfDir )")
echo $VfPciAddr > /sys/bus/pci/drivers_probe
# extract VF id from VfDir
vfid=${VfDir:6}
# check if vfid in VF group range
jq -c '.vfGroups[]' <<< "$iface" | while read group;
do
extract_min_max_ids
vdpaType=$(jq -c '.vdpaType' -r <<< $group)
if [ $vfid -le $maxId ] && [ $vfid -ge $minId ] && [ $vdpaType == "virtio" ]; then
vdpa_cmd="vdpa dev add name vdpa:"${VfPciAddr}" mgmtdev pci/"${VfPciAddr}
eval $vdpa_cmd
fi
done
done
fi
done
1 change: 1 addition & 0 deletions pkg/utils/switchdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func WriteSwitchdevConfFile(newState *sriovnetworkv1.SriovNetworkNodeState) (upd
Name: iface.Name,
PciAddress: iface.PciAddress,
NumVfs: iface.NumVfs,
VfGroups: iface.VfGroups,
}

if iface.EswitchMode == sriovnetworkv1.ESwithModeSwitchDev {
Expand Down

0 comments on commit 110adc2

Please sign in to comment.