Data Plane Kit on Virtual Machine
RidgeRun Data Plane Kit RidgeRun documentation is currently under development. |
For scenarios where the hardware available does not include a compatible DPDK NIC (Network Interface Controller), a Virtual Machine can be used to simulate a system with a compatible one. This is useful to test DPDK features, even when a compatible NIC is not physically available. In this section we are going to look at how to setup a virtual machine that emulates a 64 bit Ubuntu System with a DPDK compatible NIC. We are going through a step by step tutorial to create the virtual machine. We will also show a DPDK sample application (Ethtool) that is able to query and change Ethernet card parameters on command line.
Download Ubuntu ISO image
For this tutorial we are going to use Ubuntu 20.04.6 LTS Desktop version. Newer versions can be used in its desktop and server version. You can download Ubuntu ISO image from https://ubuntu.com/download/alternative-downloads. For this tutorial, the downloaded file's name is "ubuntu-20.04.6-desktop-amd64.iso". Save this file for steps 11 and 12 of the Create and configurate virtual machine segment.
Create and configurate virtual machine
1. First, install VirtualBox software. It can be downloaded on different systems. To do it on an Ubuntu system, you can run this command:
sudo apt-get install virtualbox
2. After installing VirtualBox, open it and create a new virtual machine by clicking on "New":
2. Define the virtual machine's name, folder location, Operative system and OS architecture. In this example, the machine's name is "rdpk-vm", it is going to be saved at "/home/ridgerun/VirutalBox VMs" and is going to run a Linux 64-bit Ubuntu distribution. You can choose any location in your filesystem and the name of your preference.
3. Select the RAM (Random Access Memoory) size. It is important to give at least the recommended size (Specified in this window), so the Virtual Machine runs properly. It is not recommended to give the whole available RAM size so the host computer keeps running normally.
4. Select the creation of a new virtual hard disk as shown below. This is going to create a file that will act as a hard disk for the virtual machine.
5. Select VDI (VirtualBox Disk Image) as the hard disk file's type as shown below.
6. Select Dynamically allocated size for the new virtual hard disk as shown below.
7. Define the hard disk file location, name and it's maximun size as shown below. The size will depend on your host computer's resources but for this example it is not required to have more than 30GB or even less.
8. After this process is completed, a new virtual machine should be on VirtualBox's main screen as shown below. Click once on it and then click on settings.
9. A window like the one below should pop up after clicking on settings. Click on "System" and then "Processor" and select at least half of the CPUs available on the bar. This is important because the DPDK sample application that will be run needs at least two CPUs on the Virtual machine so it can use one.
10. Staying on the settings window, configure a network adapter for the virtual machine. The settings below show how to do it. It is important to mention that the adapter type is important because it needs to be compatible with DPDK. For this example, we chose "Intel PRO/1000 MT Desktop (82540EM)", a DPDK-compatible NIC.
11. After the NIC is configured, click on "OK" and save the settings. At the VirtualBox main screen, click once on the virtual machine and click on the green bottom start. A screen like the one below should come up. Click on the folder icon next to the "Empty" box to choose the iso image downloaded before (ubuntu-20.04.6-desktop-amd64.iso).
12. After selecting the iso image downloaded in the host filesystem, a screen like the one below should appear. Click on the iso image added and click on "choose" at the bottom left corner.
13. Follow the Ubuntu installation and configuration process that will show up after. As a tip, if the message "Please remove the installation medium, then press Enter." pops up, just click on the screen and hit the enter key. After the installation is done, a screen like the one below should be on the virtual machine.
Installing DPDK Dependencies
The virtual machine is set. We can start the process to run the DPDK sample application, "Ethtool". First, start the DPDK installation by getting its dependencies. Open a terminal on the Virtual machine and run the following commands.
# Update repositories sudo apt-get update # Install compilers and interpreters sudo apt-get install python3 python3-pip build-essential # Install building system sudo apt-get install ninja-build pip3 install meson==0.53.2 sudo pip3 install meson==0.53.2 # Install tools pip3 install pyelftools sudo pip3 install pyelftools sudo apt-get install libnuma-dev
Compiling DPDK
First, download DPDK from this link. For the case of this page, we are going to select the 23.11.1 LTS (Long Term Support) but newer or older versions could be used if available. It is possible to download 23.11.1 version it using the following command:
wget https://fast.dpdk.org/rel/dpdk-23.11.1.tar.xz
Then, uncompress the file and prepare the environment for compilation:
tar xf dpdk-23.11.1.tar.xz cd dpdk-stable-23.11.1
Proceed with the compilation. By default, it is installed into /usr/local
as prefix:
meson builddir -Dexamples=all ninja -C builddir sudo ninja -C builddir install
Binding the virtual machine's NIC to DPDK compatible driver
For testing the DPDK installation, first, load the UIO modules:
sudo modprobe uio sudo modprobe uio_pci_generic
The UIO (Userspace IO) modules allow userspace applications to access hardware devices.
Then, it is possible to search if the device can be used for DPDK by listing it:
cd usertools python3 ./dpdk-devbind.py -s
It should give a similar output to the following:
Network devices using kernel driver ======================= 0000:00:03.0 '82540EM Gigabit Ethernet Controller 100e' if=enp0s3 drv=e1000 unused=vfio-pci *Active* No 'Baseband' devices detected ================== No 'Crypto' devices detected ================ No 'DMA' devices detected ============= No 'Eventdev' devices detected ================== No 'Mempool' devices detected ================= No 'Compress' devices detected ================== No 'Misc (rawdev)' devices detected ======================= No 'Regex' devices detected =============== No 'ML' devices detected ============
The output above shows the Ethernet card: '82540EM Gigabit Ethernet Controller 100e'
, which is, in this case, a laptop ethernet card.
After listing, it is possible to unbind the kernel from the Ethernet card:
NIC=enp2s0 sudo ifconfig $NIC down
where NIC=enp2s0
is the network interface, obtained by using ip addr
command. The command from above releases the interface.
Then, bind it to DPDK:
PCIE_ID=0000:00:03.0 sudo python3 ./dpdk-devbind.py --bind=uio_pci_generic ${PCIE_ID}
where PCIE_ID=0000:00:03.0
is obtained using the python3 dpdk-devbind.py -s
command (shown above).
To check the binding, re-execute:
cd usertools python3 ./dpdk-devbind.py -s
the output shows the binding:
python3 ./dpdk-devbind.py -s Network devices using DPDK-compatible driver ============================================ 0000:00:03.0 '82540EM Gigabit Ethernet Controller 100e' drv=uio_pci_generic unused=e1000,vfio-pci No 'Baseband' devices detected ===================================
Running Ethtool sample aplication
Move to the usertools directory and reserve hugepages for DPDK to run properly using the dpdk-hugepages.py python script.
cd usertools sudo python3 ./dpdk-hugepages.py --pagesize 2M --setup 256M --node 0
Move to the examples directory to run the sample application from here
cd .. cd builddir/examples/
Run the sample application binary.
sudo ./dpdk-ethtool
The output should be similar to this:
EAL: Detected CPU lcores: 4 EAL: Detected NUMA nodes: 1 EAL: Detected static linkage of DPDK EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'PA' EAL: VFIO support initialized EAL: Probe PCI driver: net_e1000_em (8086:100e) device: 0000:00:03.0 (socket -1) TELEMETRY: No legacy callbacks, legacy socket not created Number of NICs: 1 Init port 0.. EthApp> drvinfo firmware version get error: (Operation not supported) Port 0 driver: net_e1000_em (ver: DPDK 23.11.1) firmware-version: bus-info: 0000:00:03.0 EthApp> quit Closing port 0... Done
Notes
- For a computer with an incompatible NIC the error: "No available NIC ports!" should come up with an output like the following:
sudo ./dpdk-ethtool
EAL: Detected CPU lcores: 8 EAL: Detected NUMA nodes: 1 EAL: Detected static linkage of DPDK EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'PA' EAL: VFIO support initialized Number of NICs: 0 EAL: Error - exiting with code: 1 Cause: No available NIC ports!
- You can check a list of the main compatible NICs in the Compatible Hardware section.