summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-31 19:41:50 +0100
committerDamjan Marion <damarion@cisco.com>2019-01-31 19:44:14 +0100
commitf4901f3d1d4f2a3c689a946b927bcee680a297ed (patch)
treee8fd1acb9ace3f44089a59c578fcd344b71518c0
parente82c73a96ea68268804b3f8b3db8cca738cbfe64 (diff)
extras: vfctl script - bind VF to vfio-pci after VF is created
Change-Id: If6ed71a5f7217363d8e1b2f7a7f20fe4cfdb58af Signed-off-by: Damjan Marion <damarion@cisco.com>
-rwxr-xr-xextras/scripts/vfctl10
1 files changed, 10 insertions, 0 deletions
diff --git a/extras/scripts/vfctl b/extras/scripts/vfctl
index 21868b021bb..9fe6c8b02e7 100755
--- a/extras/scripts/vfctl
+++ b/extras/scripts/vfctl
@@ -4,6 +4,15 @@ function die() {
echo "ERROR: $*" >&2
exit 1
}
+function pci-unbind() {
+ echo $1 | sudo tee /sys/bus/pci/devices/$1/driver/unbind > /dev/null
+}
+function pci-bind() {
+ pci-unbind $1
+ echo $2 | sudo tee /sys/bus/pci/devices/$1/driver_override > /dev/null
+ echo $1 | sudo tee /sys/bus/pci/drivers/$2/bind > /dev/null
+ echo | sudo tee /sys/bus/pci/devices/$1/driver_override > /dev/null
+}
function show_vfs() {
path=$1
@@ -92,6 +101,7 @@ function create () {
sudo ip link set dev ${netdev} vf ${vfid} mac ${mac}
sudo ip link set dev ${netdev} vf ${vfid} trust on
sudo ip link set dev ${netdev} vf ${vfid} spoofchk off
+ pci-bind ${vf} vfio-pci
done
[ $(cat ${path}/sriov_numvfs) -gt 0 ] && show_vfs ${path} ${netdev}