how to configure openvswitch with dpdk on ubuntu 16.04

  • if you want to run DPDK-app in VM, configure /etc/default/grub to enable VT-d in BIOS settings
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="iommu=pt intel_iommu=on"
sudo update-grub

  • install ovs-dpdk
sudo apt-get install openvswitch-switch-dpdk uvtool dpdk-igb-uio-dkms
sudo systemctl enable dpdk
sudo systemctl start dpdk

  • change default ovs-vswitchd to ovs-dpdk
sudo update-alternatives --set ovs-vswitchd /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk

  • configure ovs-dpdk
# enable DPDK
ovs-vsctl set Open_vSwitch . "other_config:dpdk-init=true"
# run on core3 
ovs-vsctl set Open_vSwitch . "other_config:dpdk-lcore-mask=0x8"
ovs-vsctl set Open_vSwitch . "other_config:pmd-cpu-mask=0x8"
# optimize while comparing the effect 
ovs-vsctl set Open_vSwitch . other_config:n-dpdk-rxqs=2
# allocate 2G huge pages (not Numa node aware)
ovs-vsctl set Open_vSwitch . "other_config:dpdk-alloc-mem=1024"
# allocate 2G huge pages (Numa node aware)
ovs-vsctl set Open_vSwitch . "other_config:dpdk-socket-mem=512,512"
# group/permissions for vhost-user sockets (required to work with libvirt/qemu)
ovs-vsctl set Open_vSwitch . \
   "other_config:dpdk-extra=--vhost-owner libvirt-qemu:kvm --vhost-perm 0666"
# verify options
ovs-vsctl get Open_vSwitch . other_config 
# remove options
ovs-vsctl remove Open_vSwitch . other_config pmd-cpu-mask

  • bind NICs to dpdk pmd in /etc/dpdk/dpdk.conf
pci 0000:02:00.0    uio_pci_generic
pci 0000:03:00.0    uio_pci_generic
pci 0000:06:00.0    uio_pci_generic
pci 0000:07:00.0    uio_pci_generic
pci 0000:08:00.0    uio_pci_generic

  • restart dpdk and ovs-vswitchd, then check ovs is being invoked with dpdk
sudo service dpdk restart
sudo service openvswitch-switch restart
ps ax | grep dpdk

  • configure ovs-dpdk while creating bridges and ports
# ovs expects DPDK device names to start with "dpdk" and end with a portid.
# vswitchd should print (in the log file) the number of dpdk devices found.
# once first DPDK port is added to ovs-vswitchd, it creates a polling thread
# and polls dpdk devices in continuous loop. Thus, you can check with top
# that CPU utilization for that thread is always 100%
# ref:

ovs-vsctl add-br br-wan -- set bridge br-wan datapath_type=netdev
ovs-vsctl add-port br-wan dpdk0 -- set Interface dpdk0 type=dpdk \
ovs-vsctl add-br br-lan-office -- set bridge br-lan-office datapath_type=netdev
ovs-vsctl add-port br-lan-office dpdk1 -- set Interface dpdk1 type=dpdk \
ovs-vsctl add-br br-lan-server -- set bridge br-lan-server datapath_type=netdev
ovs-vsctl add-port br-lan-server dpdk3 -- set Interface dpdk3 type=dpdk \

you can omit configuring vhost-user interface since openstack automatically configures vhost-user front-end when it launches an instance.

ovs-vsctl add-port br-wan vhost-user-1 -- set Interface vhost-user-1 type=dpdkvhostuser

  • configure openstack for ovs-dpdk
# add to /etc/neutron/plugins/ml2/openvswitch_agent.ini
# restart openvswitch agent and check the status
sudo service neutron-openvswitch-agent restart
sudo service neutron-openvswitch-agent status
# set hugepage property to a flavor and provision a new VM with that flavor
sudo openstack flavor set m1.small --property hw:mem_page_size=large

  • verify statistics of dpdk interface
sudo ovs-appctl dpif-netdev/pmd-stats-show

  • QoS rate limiting (i.e. take some caution since it’s a little confusing)

for traffic that egresses from a switch, OVS supports traffic shaping (i.e. shaping means queueing packets)
for traffic that ingresses into a switch, OVS supports traffic policing (i.e. policing means dropping packets)
keep in mind that ‘egress shaping and ingress policing’.

refer to below URLs for further details

# below settings are not valid anymore, since it has changed from ovs 2.6
# but this information is useful if you are using ovs prior to version 2.6
# ref:

# add dpdk option to /etc/default/openvswitch-switch
DPDK_OPTS='--dpdk -c 0x3 -n 4'

# add huge page option to /etc/dpdk/dpdk.conf

# verify PCI addresses of interfaces
sudo dpdk-devbind --s

# assign binding info to /etc/dpdk/interfaces according to your NIC settings
# eth1 (WAN)
pci 0000:03:00.0    uio_pci_generic
# eth3 (LAN-Office)
pci 0000:05:00.0    uio_pci_generic
# eth5 (LAN-Server)
pci 0000:06:00.0    uio_pci_generic

# add uio and uio_pci_generic to /etc/modules to load at boot time

Leave a Reply

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