OpenVSwitch with DPDK Enabled

masing-masing versi OpenVSwitch menyarankan untuk menggunakan versi DPDK yang berbeda pula. silahkan di cek di github openvswitch.

Versi yang digunakan sekarang adalah:

  • OpenVSwitch 2.10.1
  • DPDK 17.11.4
  • Centos 7.5

Install dan Update requirement:

yum -y update
yum -y install epel-release
yum -y update
yum -y install yum install -y numactl-devel automake gcc gcc-c++ elfutils-libelf-devel kernel-devel
reboot

Building DPDK:

cd /usr/src/
wget http://fast.dpdk.org/rel/dpdk-17.11.4.tar.xz
tar xf dpdk-17.11.4.tar.xz
export DPDK_DIR=/usr/src/dpdk-stable-17.11.4
cd $DPDK_DIR

export DPDK_TARGET=x86_64-native-linuxapp-gcc
export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
make install T=$DPDK_TARGET DESTDIR=install

Install OpenVSwitch requirement:

yum install wget openssl-devel  python-sphinx gcc make python-devel openssl-devel libpcap-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel -y

Building OpenVSwitch:

cd /usr/src
wget https://www.openvswitch.org/releases/openvswitch-2.10.1.tar.gz
tar -zxvf openvswitch-2.10.1.tar.gz
export OVS_DIR=/usr/src/openvswitch-2.10.1

cd $OVS_DIR
./boot.sh
./configure --with-dpdk=$DPDK_BUILD
make
make install

Enable Hugepage & IOMMU:

nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt default_hugepagesz=1G hugepagesz=1G hugepages=4"

echo 'vm.nr_hugepages=4' > /etc/sysctl.d/hugepages.conf 
grep HugePages_ /proc/meminfo
mount -t hugetlbfs none /dev/hugepages``

grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

Check Hugepage & IOMMU:

dmesg | grep -e DMAR -e IOMMU
cat /proc/cmdline | grep iommu=pt
cat /proc/cmdline | grep intel_iommu=on

Enable DPDK Driver:

export DPDK_DIR=/usr/src/dpdk-stable-17.11.4
modprobe vfio-pci
modprobe uio_pci_generic
cd $DPDK_DIR/x86_64-native-linuxapp-gcc
sudo modprobe uio
sudo insmod kmod/igb_uio.ko
/usr/bin/chmod a+x /dev/vfio
/usr/bin/chmod 0666 /dev/vfio/*

Add interface into DPDK (igb_uio):

$DPDK_DIR/usertools/dpdk-devbind.py --status
$DPDK_DIR/usertools/dpdk-setup.sh

dont forget to shutdown the interface first before bind into dpdk.

Start OpenVSwitch:

sudo pkill -9 ovs
sudo rm -rf /usr/local/var/run/openvswitch
sudo rm -rf /usr/local/etc/openvswitch/
sudo rm -f /usr/local/etc/openvswitch/conf.db
mkdir -p /usr/local/etc/openvswitch
mkdir -p /usr/local/var/run/openvswitch

ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
                     --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
                     --private-key=db:Open_vSwitch,SSL,private_key \
                     --certificate=db:Open_vSwitch,SSL,certificate \
                     --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
                     --pidfile --detach

export PATH=$PATH:/usr/local/share/openvswitch/scripts
export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
ovs-ctl --no-ovsdb-server --db-sock="$DB_SOCK" start

Check OpenVSwitch have DPDK enable:

ovs-vsctl get Open_vSwitch . dpdk_initialized
ovs-vswitchd --version
ovs-vsctl get Open_vSwitch . dpdk_version

Create sample bridge with interface from DPDK

ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
ovs-vsctl add-port br0 myportnameone -- set Interface myportnameone type=dpdk options:dpdk-devargs=0000:00:04.0

Comments are closed.