【DPDK】Integrate Open vSwitch with DPDK
要将Open vSwitch(OVS)与DPDK集成,您必须安装所需的组件,然后配置OVS。DPDK默认是为KVM的vm-series防火墙启用的。
1. Install QEMU, DPDK, and OVS on Ubuntu
在您可以在OVS上启用DPDK之前,您必须安装QEMU 2.5.0、DPDK 2.2.0和OVS 2.5.1。完成以下步骤来安装组件。
1.1 Build and Install OVS-DPDK on Ubuntu 16.04
Step1:Log in to the KVM host CLI.
Step2:Install QEMU 2.5.0 by executing the following commands:
1 apt-get install build-essential gcc pkg-config glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev
2 apt-get build-dep qemu
3 apt-get install qemu-kvm libvirt-bin
4 wget http://wiki.qemu.org/download/qemu-2.5.0.tar.bz2
5 tar xjvf qemu-2.5.0.tar.bz2
6 cd qemu-2.5.0
7 ./configure
8 make
9 make install
Step3:Install dpdk-2.2.0.
1.Execute the following commands:
1 wget http://dpdk.org/browse/dpdk/snapshot/dpdk-2.2.0.tar.gz
2 tar xzvf dpdk-2.2.0.tar.gz
3 cd dpdk-2.2.0
4 vi config/common_linuxapp
2.Change CONFIG_RTE_APP_TEST=y to CONFIG_RTE_APP_TEST=n ”
3.Change CONFIG_RTE_BUILD_COMBINE_LIBS=n to CONFIG_RTE_BUILD_COMBINE_LIBS=y
4.Execute the following command:
vi GNUmakefile
5.Change ROOTDIRS-y := lib drivers app to ROOTDIRS-y := lib drivers
6.Execute the following command:
make install T=x86_64-native-linuxapp-gcc
Step4:
Install OVS 2.5.1 by executing the following commands:
1 wget http://openvswitch.org/releases/openvswitch-2.5.1.tar.gz
2 tar xzvf openvswitch-2.5.1.tar.gz
3 cd openvswitch-2.5.1
4 ./configure –with-dpdk=”/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/”
5 make
6 make install
1.2 Configure OVS and DPDK on the Host
在安装必要的组件以支持OVS和DPDK之后,您必须配置主机以使用OVS和DPDK。
Step1: Log in to the KVM host CLI.
Step2: 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>
Step3: Configure initial huge pages for OVS.
echo 16384 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Step4: Mount huge pages for QEMU:
1 mkdir /dev/hugepages 2 mkdir /dev/hugepages/libvirt 3 mkdir /dev/hugepages/libvirt/qemu 4 mount -t hugetlbfs hugetlbfs /dev/hugepages/libvirt/qemu
Step5: Use the following command to kill any currently existing OVS daemon.
killall ovsdb-server ovs-vswitchd
Step6: Create directories for the OVS daemon.
1 mkdir -p /usr/local/etc/openvswitch 2 mkdir -p /usr/local/var/run/openvswitch
Step7: Clear old directories.
1 rm -f /var/run/openvswitch/vhost-user* 2 rm -f /usr/local/etc/openvswitch/conf.db
Step8: Initialize the configuration database.
1 ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
Step9: 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
Step10: Initialize OVS.
ovs-vsctl --no-wait init
Step11: Start the database server.
export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
Step12: Install the igb_uio module (network device driver) for DPDK.
1 cd ~/dpdk-2.2.0/x86_64-native-linuxapp-gcc/kmod 2 modprobe uio 3 insmod igb_uio.ko 4 cd ~/dpdk-2.2.0/tools/
Step13: Enable DPDK on interfaces using PCI-ID or interface name.
1 ./dpdk_nic_bind.py --bind=igb_uio <your first data interface> 2 ./dpdk_nic_bind.py --bind=igb_uio <your second data interface>
Step14: 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.
1 ovs-vswitchd --dpdk -c 0x3 -n 4 -- unix:$DB_SOCK --pidfile --detach 2 echo 50000 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
Step15: Create the OVS bridge and attach ports to the OVS bridge.
1 ovs-vsctl add-br ovs-br0 -- set bridge ovs-br0 datapath_type=netdev 2 ovs-vsctl add-port ovs-br0 dpdk0 -- set Interface dpdk0 type=dpdk 3 ovs-vsctl add-br ovs-br1 -- set bridge ovs-br1 datapath_type=netdev 4 ovs-vsctl add-port ovs-br1 dpdk1 -- set Interface dpdk1 type=dpdk
Step16: Create DPDK vhost user ports for OVS.
1 ovs-vsctl add-port ovs-br0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhostuser 2 ovs-vsctl add-port ovs-br1 vhost-user2 -- set Interface vhost-user2 type=dpdkvhostuser
Step17: Set the number of hardware queues of the NIC used by the host.
1 ovs-vsctl set Open_vSwitch . other_config:n-dpdk-rxqs=8 2 ovs-vsctl set Open_vSwitch . other_config:n-dpdk-txqs=8
Step18: Set the CPU mask used for OVS.
ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0xffff
Step19: Set the necessary permissions for DPDK vhost user ports. In the example below, 777 is used to give read, write, and executable permissions.
1 chmod 777 /usr/local/var/run/openvswitch/vhost-user1 2 chmod 777 /usr/local/var/run/openvswitch/vhost-user2 3 chmod 777 /dev/hugepages/libvirt/qemu

浙公网安备 33010602011771号