Skip to content

Instantly share code, notes, and snippets.

@tom-code
Last active September 21, 2017 18:35
Show Gist options
  • Save tom-code/da15afdf3ebea8a53a7275a28a0eef6d to your computer and use it in GitHub Desktop.
Save tom-code/da15afdf3ebea8a53a7275a28a0eef6d to your computer and use it in GitHub Desktop.
sr-iov
https://www.kernel.org/doc/Documentation/vfio.txt
root@sax13 ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens2f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e0 brd ff:ff:ff:ff:ff:ff
3: ens2f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e1 brd ff:ff:ff:ff:ff:ff
4: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether fc:15:b4:0d:62:60 brd ff:ff:ff:ff:ff:ff
5: ens2f2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e2 brd ff:ff:ff:ff:ff:ff
6: ens2f3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e3 brd ff:ff:ff:ff:ff:ff
7: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fc:15:b4:0d:62:64 brd ff:ff:ff:ff:ff:ff
8: macvlan0@eno2: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 2a:84:3a:eb:23:38 brd ff:ff:ff:ff:ff:ff
[root@sax13 ~]# echo "4" > /sys/class/net/ens2f3/device/sriov_numvfs
[root@sax13 ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens2f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e0 brd ff:ff:ff:ff:ff:ff
3: ens2f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e1 brd ff:ff:ff:ff:ff:ff
4: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether fc:15:b4:0d:62:60 brd ff:ff:ff:ff:ff:ff
5: ens2f2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e2 brd ff:ff:ff:ff:ff:ff
6: ens2f3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:35:58:e3 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state auto
vf 1 MAC 00:00:00:00:00:00, spoof checking on, link-state auto
vf 2 MAC 00:00:00:00:00:00, spoof checking on, link-state auto
vf 3 MAC 00:00:00:00:00:00, spoof checking on, link-state auto
7: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fc:15:b4:0d:62:64 brd ff:ff:ff:ff:ff:ff
8: macvlan0@eno2: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 2a:84:3a:eb:23:38 brd ff:ff:ff:ff:ff:ff
9: enp33s16f3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 8a:c1:f7:89:4c:6e brd ff:ff:ff:ff:ff:ff
10: enp33s16f7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fa:5b:98:15:4b:f1 brd ff:ff:ff:ff:ff:ff
11: enp33s17f3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether c6:54:1e:3d:a2:e8 brd ff:ff:ff:ff:ff:ff
12: enp33s17f7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether ba:ad:4f:c6:72:34 brd ff:ff:ff:ff:ff:ff
lspci | grep Virtual
21:10.3 Ethernet controller: Intel Corporation I350 Ethernet Controller Virtual Function (rev 01)
21:10.7 Ethernet controller: Intel Corporation I350 Ethernet Controller Virtual Function (rev 01)
21:11.3 Ethernet controller: Intel Corporation I350 Ethernet Controller Virtual Function (rev 01)
21:11.7 Ethernet controller: Intel Corporation I350 Ethernet Controller Virtual Function (rev 01)
lspci -n | grep 21:11.7
21:11.7 0200: 8086:1520 (rev 01)
modprobe vfio-pci
echo "0000:21:11.7" > /sys/bus/pci/devices/0000:21:11.7/driver/unbind
echo "8086 1520" >/sys/bus/pci/drivers/vfio-pci/new_id
qemu-system-x86_64 -enable-kvm -m 2G -vnc :5 -device vfio-pci,host=21:11.7 NGPE_NODE_7.1-latest.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment