Skip to content

Latest commit

 

History

History
53 lines (44 loc) · 2.19 KB

README.md

File metadata and controls

53 lines (44 loc) · 2.19 KB

vfio-e1000

Simple Intel 1GbE network driver implementation using VFIO.

Binding vfio-pci driver

  • Before using VFIO, you need to bind vfio-pci driver to the NIC like the following.
% lspci -nn | grep -i Ether
86:00.0 Ethernet controller [0200]: Intel Corporation 82574L Gigabit Network Connection [8086:10d3]
% sudo modprobe vfio-pci
% echo 0000:86:00.0 | sudo tee -a /sys/bus/pci/devices/0000:86:00.0/driver/unbind
% echo 8086 10d3 | sudo tee -a /sys/bus/pci/drivers/vfio-pci/new_id
% sudo chown -R group:user /dev/vfio/66

Compile

  • gcc -o e1000 e1000.c
    • Use INTx, dump received packets
  • gcc -o e1000 e1000.c -DPOLL
    • polling instead of interrupts
  • gcc -o e1000 e1000.c -DMSIX -DTXINT -DECHO
    • use MSIX, enable Tx interrupt, echo received packets
  • For more detail, see the source

Usage

  • ./e1000 <segment:bus:device.function>
    • for example, ./e1000 0000:01:00.0

Note

  • If you get out of memory error, probably you need to increase the memlock limits.
    • VFIO automatically lock the DMA memory region so as not to be moved.
    • Check current memlock liimit: prlimit -l
    • Temporary increase the limit: sudo prlimit --memlock=-1 ./e1000 0000:01:00.0
    • To make the configuration permanent, edit /etc/security/limits.conf
  • I only tested this with 82574L on Intel CPU.

Requirements

  • IOMMU (VT-d for Intel)
    • VFIO supports no IOMMU mode, but this driver currently does not.

Reference

License

MIT