1. Environmental preparation
VMware + Ubuntu 16.04 Server version
2. DPDK environment construction
2.1 vmware add two network cards
To run DPDK, two network cards are needed, so we need to check whether our virtual machine already has two network cards, and add them if not; when adding a network card, it is recommended to set the network connection of the network card to "bridge mode (B)" .
2.2 Modify network card configuration information
1) Find the .vmx file on our virtual machine and open it;
2) Change ethernet0.virtualDev from e1000 to vmxnet3, because VMware's vmxnet3 supports multi-queue network cards;
3) Change ethernet0.vwakeOnPcktRcv to TRUE.
After the modification is complete, we use ifconfig to check whether the added network card is already in the list:
If not, we need to add new network card information to the file, use the command vim /etc/network/interfaces
to open the file to add:
interfaces file, when there is only one network card, there is only eth0 by default. If you add a new one, you need to add a new configuration. For example, if you add 3 network cards in the above figure, you need to configure eth1, eth2, and eth3.
Explanation: If you use the ifconfig command to view the network card information, instead of eth0, it displays es33 (or other names), then we can change es33 to eth0 by modifying the configuration file.
The specific operation is:
1) Use to vim /etc/default/grub
open the grub file;
2) In the GRUB_CMDLINE_LINUX parameter, add net.ifnames=0 biosdevname=0, so that the network card name starts from 0.
2.3 Modify the startup parameters of the ubuntu system
1) Physical machine
default_hugepages=1G hugepagesz=1G hugepages=20 isolcpus=0-7
2) Virtual machine
default_hugepages=1G hugepagesz=2M hugepages=1024 isolcpus=0-2
2.4 Check whether the system supports multi-queue network cards
cat /proc/interrupts
You can check whether the system supports multi-queue network cards by executing .
If you see an eth1 list similar to the red box in the above figure, it means that the multi-queue network card is supported.
3. Compile DPDK
1) DPDK download website: https://core.dpdk.org/download/
2) Choose the version at will, the direct subsystem interface of different versions will be different, here we recommend to choose dpdk 19.08.2. However, it should be noted that the interface differences between different versions of DPDK are still relatively large.
3) You ./usertools/dpdk-setup.sh
can compile
the 64-bit system by selecting 39.
After compiling, there will be an additional x86_64-native-linux-gcc folder.
4. Set the environment variables of DPDK
#export RTE_SDK=/home/dpdk
#export RTE_TARGET=x86_64-native-linux-gcc
5. Execute the testpmd test
Execute: # /usertools/dpdk-setup.sh
Then:
1) Select 43 to insert the IGB_UIO module, select the network card as vmxnet3 to load this module;
2) Select 44 to insert the VFIO module, select the network card as e1000 to load this module;
3) Select 49 to bind the igb_uio module, or exit ;
If 49 is executed, the following information will be prompted:
It can be solved by the following command:
# ifconfig eth0 down
# /usertools/dpdk-devbind.py --bind=igb_uio eth0
4) Select 53 to run testpmd
> show port info 0
6. Compile the DPDK program
1) Enter example/helloworld ;
2) You can directly execute make to compile, or you can compile with the following gcc command:
# gcc -o helloword main.c -I /usr/local/include/dpdk/ -ldpdk -lpthread -lnuma -ldl
After compiling, execute ./helloworld directly to run the program.
Seven, running DPDK case
Kni run:
./build/kni -l 4-7 -n 4 -- -P -p 0x3 -m --config="(0, 4, 6),(1, 5, 7)"
L3fwd running
# ./build/l3fwd -l 4-7 -n 4 -- -p 0x3 --config="(0, 0, 4),(1, 0, 5)" --parse-ptype
8. Common errors
Error message:
Reason: No environment variable is set; please refer to this article "Setting the environment variable of dpdk"
bitmask Please select 7, bit:111