In this article we are going to investigate Intel DPDK bring up in Oracle VirtualBox, namely:
- Configuring a virtual machine in Oracle VirtualBox to allow running Intel DPDK applications.
- Compiling and configuring Intel DPDK in the virtual machine.
- Compiling and running a simple Intel DPDK application in the virtual machine.
There are a number of reasons why someone might want to use Intel DPDK libraries set. Generally, it all comes down to the fact that networking has always been striving for fast packet processing, and of course for using minimum CPU resources. For more details, visit dpdk.org or Intel website.
Actually, only a limited number of NIC models of are supported by Intel DPDK, and they are quite expensive. Generally, it’s useful to have a possibility to develop and run Intel DPDK applications without a physical NIC. Running Intel DPDK in Oracle VirtualBox virtual machine allows anyone to play with DPDK, and to start developing DPDK applications even without having a network adapter supported by it.
Configuring a virtual machine in Oracle VirtualBox
First of all, create a new virtual machine in Oracle VirtualBox and install Linux on it (we used Ubuntu 12.04 and 14.04). Further, configure the virtual machine as follows:
1. Add two more virtual network adapters with “Intel PRO/1000 MT Server (82545EM)” type in order to provide virtual network hardware to the virtual machine that is supported by Intel DPDK.
2. Attach the newly created virtual network adapters to the physical NIC of the host OS as “Bridged Adapter”.
3. Add one more logical CPU core for the virtual machine. You can use it later for separating tx and rx packet processing.
4. Enable hardware virtualization in BIOS.
5. Enable CPU flags (SSE 4.1 / SSE 4.2) in VirtualBox virtual machine. To provide SSE 4.1 / SSE 4.2 support to guest OS, the host CPU has to support these instruction sets. Starting with Oracle VirtualBox 4.3.8, it is possible to enable these instructions for certain guest OSes using the following commands:
$ VBoxManage setextradata "VM name" VBoxInternal/CPUM/SSE4.1 1
$ VBoxManage setextradata "VM name" VBoxInternal/CPUM/SSE4.2 1
Note: These are per-VM settings and they are turned off by default.
Download and unpack Intel DPDK
You can execute these commands from console in order to download and unpack Intel DPDK:
wget http://dpdk.org/browse/dpdk/snapshot/dpdk-1.6.0r2.tar.gz
$ tar -xzvf dpdk-1.6.0r2.tar.gz
$ cd dpdk-1.6.0r2/
Build and configure Intel DPDK
setup.sh script, located in the “tools” subdirectory, allows the user to build and configure Intel DPDK.
Note: setup.sh script is to be run with root privileges.
Compiling Intel DPDK binaries: Possible issues
If during compilation you observe errors related to SSE flags (for example “SSE 4.2 instruction is not enabled”), try adding TOOLCHAIN_CFLAGS option for make tool. For example, edit setup.sh script as follows:
setup_target()
{
…
make TOOLCHAIN_CFLAGS=”-msse4.2 -mpopcnt” install T=${RTE_TARGET}
…
}
Note: To avoid L3 hash-related compilation error, do not use kernel version higher than 3.13.0.24 and lower than 3.14.X.X (for example, 3.13.0.30). No such issues are observed on kernel 3.13.0.24 and 3.14.X.X.
Use case for quick start setup script
The following example shows how to use the setup.sh script.
Before executing the setup.sh script, shut down interfaces which you are going to use by Intel DPDK.
$ ifconfig
…
eth1 Link encap:Ethernet HWaddr 08:00:27:c5:d3:68
inet addr:172.20.20.174 Bcast:172.20.20.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fec5:d368/64 Scope:Link
…
eth2 Link encap:Ethernet HWaddr 08:00:27:5d:86:7b
inet addr:172.20.20.83 Bcast:172.20.20.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe5d:867b/64 Scope:Link
…
$ sudo ifconfig eth1 down
$ sudo ifconfig eth2 down
Run the setup.sh script to build and configure Intel DPDK.
$ sudo ./tools/setup.sh
------------------------------------------------------------------------------
RTE_SDK exported as /home/user/projects/dpdk-1.6.0r2
------------------------------------------------------------------------------
----------------------------------------------------------
Step 1: Select the Intel DPDK environment to build
----------------------------------------------------------
[1] i686-default-linuxapp-gcc
[2] i686-default-linuxapp-icc
[3] x86_64-default-bsdapp-gcc
[4] x86_64-default-linuxapp-gcc
[5] x86_64-default-linuxapp-icc
[6] x86_64-ivshmem-linuxapp-gcc
[7] x86_64-ivshmem-linuxapp-icc
----------------------------------------------------------
Step 2: Setup linuxapp environment
----------------------------------------------------------
[8] Insert IGB UIO module
[9] Insert KNI module
[10] Setup hugepage mappings for non-NUMA systems
[11] Setup hugepage mappings for NUMA systems
[12] Display current Ethernet device settings
[13] Bind Ethernet device to IGB UIO module
----------------------------------------------------------
Step 3: Run test application for linuxapp environment
----------------------------------------------------------
[14] Run test application ($RTE_TARGET/app/test)
[15] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)
----------------------------------------------------------
Step 4: Other tools
----------------------------------------------------------
[16] List hugepage info from /proc/meminfo
----------------------------------------------------------
Step 5: Uninstall and system cleanup
----------------------------------------------------------
[17] Uninstall all targets
[18] Unbind NICs from IGB UIO driver
[19] Remove IGB UIO module
[20] Remove KNI module
[21] Remove hugepage mappings
[22] Exit Script
Option:
The following option illustrates the creation of the x86_64-default-linuxapp-gcc Intel DPDK library.
Option: 4
================== Installing x86_64-default-linuxapp-gcc
…
Build complete
------------------------------------------------------------------------------
RTE_TARGET exported as x86_64-default-linuxapp-gcc
------------------------------------------------------------------------------
Press enter to continue ...
This option demonstrates how to load Intel DPDK UIO kernel module.
Option: 8
Unloading any existing Intel DPDK UIO module
Loading uio module
Loading Intel DPDK UIO module
Press enter to continue ...
This option demonstrates how to setup hugepage mapping.
Option: 10
Removing currently reserved hugepages
Unmounting /mnt/huge and removing directory
Input the number of 2MB pages
Example: to have 128MB of hugepages available, enter '64' to
reserve 64 * 2MB pages
Number of pages: 64
Reserving hugepages
Creating /mnt/huge and mounting as hugetlbfs
Press enter to continue ...
The following option illustrates binding Ethernet device to IGB UIO kernel module.
Option: 13
Network devices using IGB_UIO driver
====================================
<none>
Network devices using kernel driver
===================================
0000:00:03.0 '82540EM Gigabit Ethernet Controller' if=eth0 drv=e1000 unused=igb_uio *Active*
0000:00:08.0 '82545EM Gigabit Ethernet Controller (Copper)' if=eth1 drv=e1000 unused=igb_uio
0000:00:09.0 '82545EM Gigabit Ethernet Controller (Copper)' if=eth2 drv=e1000 unused=igb_uio
Other network devices
=====================
<none>
Enter PCI address of device to bind to IGB UIO driver: eth1 eth2
OK
Press enter to continue ...
Compiling and running sample applications
When compiling an application in the Linux environment, the following variables must be exported:
- RTE_SDK – points to the Intel DPDK installation directory.
- RTE_TARGET – points to the Intel DPDK target environment directory.
Here is an example of compiling and running a simple “helloworld” application.
$ cd examples/helloworld
$ export RTE_SDK=/home/user/projects/dpdk-1.6.0r2
$ export RTE_TARGET=x86_64-default-linuxapp-gcc
$ make
CC main.o
LD helloworld
INSTALL-APP helloworld
INSTALL-MAP helloworld.map
$ sudo ./build/helloworld -c 0x03 -n 1
Finally the environment is ready, and you can go into deep network development using Intel DPDK. What’s nice is that you can run your VM on various host machines without any major issues.
Link: http://plvision.eu/blog/deploying-intel-dpdk-in-oracle-virtualbox/
Link: http://plvision.eu/blog/deploying-intel-dpdk-in-oracle-virtualbox/
Không có nhận xét nào :
Đăng nhận xét