how to setup DPDK environment

  • check CPU info for huge page support
# whether supporting 2MB hugepage
cat /proc/cpuinfo |grep -i pse
# whether supporting 1GB hugepage
cat /proc/cpuinfo |grep -i pdpe1gb

  • download dpdk and pktgen
sudo apt-get install xz-utils
tar xf dpdk-17.02.1.tar.xz
tar xvfz pktgen-3.3.2.tar.gz

  • install build tools
sudo apt-get install make gcc

  • build dpdk
make install T=x86_64-native-linuxapp-gcc DESTDIR=/usr/local

  • configure environment variables and add them to ~/.bashrc
export RTE_SDK=/usr/local/share/dpdk
export RTE_TARGET=x86_64-native-linuxapp-gcc

  • configure boot parameter
# "hugepages=512" means 2MB x 512 = 1GB
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="hugepagesz=2MB hugepages=512 iommu=pt intel_iommu=on"
GRUB_CMDLINE_LINUX_DEFAULT="hugepagesz=1G hugepages=1 iommu=pt intel_iommu=on"
sudo update-grub
sudo sync;sync;reboot

if you won’t use direct-IO in VM, you don’t need two iommu options above.

alternative method in case of installing with Ubuntu dpdk package
You can edit /etc/dpdk/dpdk.conf to reserve hugepage instead of above steps
You can let your VM to have hugepage by adding this line to /etc/sysctl.conf

  • load kernel module
sudo modprobe uio
sudo modprobe uio_pci_generic
sudo insmod /usr/local/lib/modules/$(uname -r)/extra/dpdk/igb_uio.ko

according to your NIC model, you should choose a proper driver module

  • test DPDK installation, for example
sudo su -
dpdk-devbind --bind=igb_uio eth2
dpdk-devbind --bind=igb_uio eth4
cd /usr/local/share/dpdk/examples/helloworld
cd build/app
./helloworld -c 0xc -n 4

  • Additional Notes

in case of no /dev/hugepage, add this line to /etc/fstab and make a mount dir.

sudo mkdir /mnt/huge
sudo vi /etc/fstab
nodev /mnt/huge hugetlbfs defaults 0 0

check errors when a device cannot be used with IOMMU errors.

dmesg | grep -e DMAR -e IOMMU

if there is RMRR issue regarding IOMMU error, refer to
– add intel_iommu=off to GRUB_CMDLINE_DEFAULT in /etc/default/grub
– or, turn off RMRR option slot-by-slot in BIOS menu

Leave a Reply

Your email address will not be published. Required fields are marked *