How to run DPDK in VMWare virtual machine?


1. Environmental preparation

VMware + Ubuntu 16.04 Server version


2. DPDK environment construction

2.1 vmware add two network cards

insert image description here
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)" .

The bridge NIC acts as the NIC on which DPDK runs. The NAT network card is used as the network card for the ssh connection.


2.2 Modify network card configuration information

insert image description here
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:
insert image description here

If not, we need to add new network card information to the file, use the command vim /etc/network/interfacesto open the file to add:
insert image description here

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/grubopen 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.

insert image description here


2.3 Modify the startup parameters of the ubuntu system

insert image description here
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/interruptsYou can check whether the system supports multi-queue network cards by executing .
insert image description here
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/
insert image description here

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.
insert image description here


3) You ./usertools/dpdk-setup.shcan compile
insert image description here
the 64-bit system by selecting 39.
insert image description here
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
insert image description here
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:
insert image description here
insert image description here

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
insert image description here
> show port info 0
**Bold style**


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

insert image description here
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

insert image description here

8. Common errors

Error message:
insert image description here
Reason: No environment variable is set; please refer to this article "Setting the environment variable of dpdk"
insert image description here
bitmask Please select 7, bit:111
insert image description here

Guess you like

Origin blog.csdn.net/locahuang/article/details/120356849