This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Testing VFIO with NIC
liujing2 edited this page Oct 18, 2018
·
1 revision
This document shows how to test VFIO passthrough manually using NIC as example.
- Edit grub to enable
intel_iommu=on
- Host kernel needs setup following config.
CONFIG_VFIO_IOMMU_TYPE1=m
CONFIG_VFIO=m
CONFIG_VFIO_PCI=m
- Install vfio by
sudo modprobe vfio-pci
$ lspci -nn -D |grep Ethernet
0000:00:19.0 Ethernet controller [0200]: Intel Corporation Ethernet Connection I217-LM [8086:153a] (rev 04)
$ lspci -n -s 00:19.0
00:19.0 0200: 8086:153a (rev 04)
$ echo 8086 153a | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id
$ ls /dev/vfio
8 vfio
00:03.0 Ethernet controller: Intel Corporation Ethernet Connection I217-LM (rev 04)
Subsystem: Dell Device 05a4
Physical Slot: 3
Flags: bus master, fast devsel, latency 0, IRQ 9
Memory at 90020000 (32-bit, non-prefetchable) [size=128K]
Memory at 90002000 (32-bit, non-prefetchable) [size=4K]
I/O ports at 1000 [disabled] [size=32]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [e0] PCI Advanced Features
Kernel driver in use: e1000e
Kernel modules: e1000e
dmesg
root@clr-19bebbac82a145bb8c96500c89dbfd8a ~ # qemu-system-x86_64: PCI: Bug - unimplemented PCI INTx routing (pci-lite-host)
qemu-system-x86_64: PCI: Bug - unimplemented PCI INTx routing (pci-lite-host)
[ 61.853366] pci 0000:00:03.0: [8086:153a] type 00 class 0x020000
[ 61.853439] pci 0000:00:03.0: calling quirk_f0_vpd_link+0x0/0x70 @ 149
[ 61.853443] pci 0000:00:03.0: quirk_f0_vpd_link+0x0/0x70 took 0 usecs
[ 61.853619] pci 0000:00:03.0: reg 0x10: [mem 0x00000000-0x0001ffff]
[ 61.853679] pci 0000:00:03.0: reg 0x14: [mem 0x00000000-0x00000fff]
[ 61.853739] pci 0000:00:03.0: reg 0x18: [io 0x0000-0x001f]
[ 61.854432] pci 0000:00:03.0: PME# supported from D0 D3hot D3cold
[ 61.854790] pci 0000:00:03.0: BAR 0: assigned [mem 0x90020000-0x9003ffff]
[ 61.854820] pci 0000:00:03.0: BAR 1: assigned [mem 0x90002000-0x90002fff]
[ 61.854846] pci 0000:00:03.0: BAR 2: assigned [io 0x1000-0x101f]
[ 61.854880] pci 0000:00:03.0: calling quirk_e100_interrupt+0x0/0x1a0 @ 149
[ 61.854884] pci 0000:00:03.0: quirk_e100_interrupt+0x0/0x1a0 took 0 usecs
[ 61.897438] calling e1000_init_module+0x0/0x1000 [e1000e] @ 201
[ 61.897439] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[ 61.897440] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 61.897503] e1000e 0000:00:03.0: enabling device (0000 -> 0002)
[ 61.898778] e1000e 0000:00:03.0: can't derive routing for PCI INT A
[ 61.898780] e1000e 0000:00:03.0: PCI INT A: no GSI
[ 61.899676] e1000e 0000:00:03.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
[ 61.990046] e1000e 0000:00:03.0 0000:00:03.0 (uninitialized): registered PHC clock
[ 62.073233] e1000e 0000:00:03.0 eth0: (PCI Express:2.5GT/s:Width x1) 98:90:96:c0:e6:6c
[ 62.073235] e1000e 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[ 62.073279] e1000e 0000:00:03.0 eth0: MAC: 11, PHY: 12, PBA No: FFFFFF-0FF
[ 62.073310] initcall e1000_init_module+0x0/0x1000 [e1000e] returned 0 after 171737 usecs
[ 62.074469] e1000e 0000:00:03.0 ens3: renamed from eth0
[ 62.295674] IPv6: ADDRCONF(NETDEV_UP): ens3: link is not ready
[ 63.834653] e1000e: ens3 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
[ 63.834658] e1000e 0000:00:03.0 ens3: 10/100 speed: disabling TSO
[ 63.834812] IPv6: ADDRCONF(NETDEV_CHANGE): ens3: link becomes ready
root@clr-19bebbac82a145bb8c96500c89dbfd8a ~ # ifconfig
ens3 Link encap:Ethernet HWaddr 98:90:96:C0:E6:6C
inet addr:10.238.145.45 Bcast:10.238.145.255 Mask:255.255.254.0
inet6 addr: fe80::9a90:96ff:fec0:e66c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:221 errors:0 dropped:3 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:120062 (117.2 Kb) TX bytes:9392 (9.1 Kb)
Memory:90020000-90040000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
root@clr-19bebbac82a145bb8c96500c89dbfd8a ~ # ping 10.238.156.121
PING 10.238.156.121 (10.238.156.121) 56(84) bytes of data.
64 bytes from 10.238.156.121: icmp_seq=1 ttl=61 time=1.04 ms
64 bytes from 10.238.156.121: icmp_seq=2 ttl=61 time=0.966 ms