: Configure OVS and DPDK on the Host
Focus
Focus

Configure OVS and DPDK on the Host

Table of Contents

Configure OVS and DPDK on the Host

After installing the necessary components to support OVS and DPDK, you must configure the host to use OVS and DPDK.
  1. Log in to the KVM host CLI.
  2. If you are replacing or reconfiguring an existing OVS-DPDK setup, execute the following commands to reset any previous configuration. Repeat the command for each interface.
    rm /usr/local/var/run/openvswitch/
    <interface-name>
  3. Configure initial huge pages for OVS.
    echo 16384 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
  4. Mount huge pages for QEMU:
    mkdir /dev/hugepages mkdir /dev/hugepages/libvirt mkdir /dev/hugepages/libvirt/qemu mount -t hugetlbfs hugetlbfs /dev/hugepages/libvirt/qemu
  5. Use the following command to kill any currently existing OVS daemon.
    killall ovsdb-server ovs-vswitchd
  6. Create directories for the OVS daemon.
    mkdir -p /usr/local/etc/openvswitch
    mkdir -p /usr/local/var/run/openvswitch
  7. Clear old directories.
    rm -f /var/run/openvswitch/vhost-user*
    rm -f /usr/local/etc/openvswitch/conf.db
  8. Initialize the configuration database.
    ovsdb-tool create /usr/local/etc/openvswitch/conf.db\
    /usr/local/share/openvswitch/vswitch.ovsschema
  9. Create an OVS DB server.
    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
  10. Initialize OVS.
    ovs-vsctl --no-wait init
  11. Start the database server.
    export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
  12. Install the igb_uio module (network device driver) for DPDK.
    cd ~/dpdk-2.2.0/x86_64-native-linuxapp-gcc/kmod modprobe uio insmod igb_uio.ko cd ~/dpdk-2.2.0/tools/
  13. Enable DPDK on interfaces using PCI-ID or interface name.
    ./dpdk_nic_bind.py --bind=igb_uio <your first data interface>
    ./dpdk_nic_bind.py --bind=igb_uio <your second data interface>
  14. Start the OVS daemon in DPDK mode. You can change the number of cores for ovs-vswitchd. By changing -c 0x1 to -c 0x3, you can have two core run this daemon.
    ovs-vswitchd --dpdk -c 0x3 -n 4 -- unix:$DB_SOCK --pidfile --detach
    echo 50000 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
  15. Create the OVS bridge and attach ports to the OVS bridge.
    ovs-vsctl add-br ovs-br0 -- set bridge ovs-br0 datapath_type=netdev
    ovs-vsctl add-port ovs-br0 dpdk0 -- set Interface dpdk0 type=dpdk
    ovs-vsctl add-br ovs-br1 -- set bridge ovs-br1 datapath_type=netdev
    ovs-vsctl add-port ovs-br1 dpdk1 -- set Interface dpdk1 type=dpdk
  16. Create DPDK vhost user ports for OVS.
    ovs-vsctl add-port ovs-br0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhostuser
    ovs-vsctl add-port ovs-br1 vhost-user2 -- set Interface vhost-user2 type=dpdkvhostuser
  17. Set the number of hardware queues of the NIC used by the host.
    ovs-vsctl set Open_vSwitch . other_config:n-dpdk-rxqs=8
    ovs-vsctl set Open_vSwitch . other_config:n-dpdk-txqs=8
  18. Set the CPU mask used for OVS.
    ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0xffff
  19. Set the necessary permissions for DPDK vhost user ports. In the example below, 777 is used to give read, write, and executable permissions.
    chmod 777 /usr/local/var/run/openvswitch/vhost-user1
    chmod 777 /usr/local/var/run/openvswitch/vhost-user2
    chmod 777 /dev/hugepages/libvirt/qemu

Recommended For You