Disclaimer: This document is only for learning and exchange, do not use for other commercial purposes author: Chaoyang _tony
E-mail:linzhaolover@gmail.com
Create date:2013-12-28 23:38:47 Saturday
Last Change:2014-1-1 22:33:42 Wednesday
Reprint please indicate the source: Http://blog.csdn.net/linzhaolover
Intel DPDK Exchange Group Hope everybody joins each other to learn, QQ group number: 289784125
This article in conjunction with the Intel DPDK source to read, based on dpdk-1.5.1 version of the source code to explain, the source can go to the Http://dpdk.org/dev Web page to download; More official documentation please visit http://dpdk.org/
If you do not have an Intel network card, no corresponding Linux system, just want to use simple to understand DPDK, then you can choose to deploy a simple DPDK environment in VMware;
1, in VMware installation configuration suitable for DPDK running virtual machine; 1), the configuration requirements of virtual machines,
VCPU = 2 At least two CPUs, because DPDK is required to bind core, one is not run the normal operation of DPDK, such as your computer running, preferably more than a few;
memory=1024 is 1G, of course, the more the better, because to configure hugepage, or more points it;
System, I installed is rhel6.1, of course you can choose a higher version, but can not choose the lower version, afraid not support; http://blog.csdn.net/linzhaolover/article/details/8223568 this has RHEL6.3 6.4 6.5 of the download address;
System in the installed to update the kernel, I am currently using the virtual machine is linux-3.3.2, you'd better choose between 3.0 to 3.8, which kernel some people used, can run up DPDK;
Network card, give two bar,
VMware mounted Virtual machine system I don't have much to say here, there are a lot of tutorials on the web; 2, add DPDK supported network cards
Students Virtual network card, we should not be stingy, at least add two Intel network card bar, because a piece will report a mistake;
DPDK is out of Intel, currently seems to support only the Intel network card, in the installed virtual machine, we look at the current virtual machine network card is what kind of, with the LSPCI command to view;
# Lspci | grep Ethernet
02:01.0 Ethernet controller:advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev. 10) c3/>02:05.0 Ethernet controller:advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev. 10)
VMware installed virtual machines, the default network card is AMD, how do we correctly add Intel's network card ...
OK, first the virtual machine shutdown;
Then add a network card, then do not start the virtual machine, we also need to modify the current virtual machine configuration file,
My profile when in E:\Users\adm\Documents\Virtual machines\red hat Enterprise Linux 5\red hat 6.vmx
When you install the virtual machine, you should select its working directory, you will put your mouse on the left side of the VMware in the name of the virtual machines you created, will automatically display its working directory;
Open the configuration file in Notepad, and then add a row
Ethernet2.virtualdev = "e1000"
Since I am adding the 3rd block card, if starting from 0, just is eth2, add the appearance is
Ethernet2.virtualdev = "e1000"
ethernet2.present = "TRUE"
E1000 is a gigabit NIC in Intel's network card;
OK, restart the virtual machine, check the network card, a 82545em network card,
# Lspci | grep Ethernet
02:01.0 Ethernet controller:advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev. 10) c3/>02:05.0 Ethernet controller:advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev.)
02:06.0 Ethernet Control Ler:intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (Rev. 01)
2. Deploy DPDK
1), download the source code
Download the latest code from the DPDK website after the virtual machine is turned on
git clone GIT://DPDK.ORG/DPDK
2), set the environment variable
Enter the DPDK directory; Edit an environment variable file, then source;
Export rte_sdk= ' pwd '
#export rte_target=x86_64-default-linuxapp-gcc
export rte_target= i686-default-linuxapp-gcc
Because I am 32 virtual machine, so I choose i686, x86_64 that row of environment variables commented out;
I put the top 3 lines in the DPDKRC file, and then use source to enable these environment variables;
SOURCE DPKDRC
Note that you later if the new landing terminal, enter this directory, you have to source this file, in order to run the normal DPDK procedures;
3), using DPDK script to run DPDK;
Run the script for DPDK test;
Then run the script again
./tools/setup.sh
----------------------------------------------------------Step
1:select The DPDK environment to build
----- -----------------------------------------------------
[1] I686-DEFAULT-LINUXAPP-GCC
[2] I686-DEFAULT-LINUXAPP-ICC
[3] X86_64-DEFAULT-LINUXAPP-GCC
[4] X86_64-default-linuxapp-icc
Select 1
Mine is a 32-bit system, so I choose 1, using GCC to compile 32-bit source code; If you are a 64-bit virtual machine, please select 3
----------------------------------------------------------Step
2:setup Linuxapp Environment
------------ ----------------------------------------------
[5] Insert IGB UIO module
[6] Insert KNI module
[7] Setup Hugepage mappings for Non-numa systems
[8] Setup hugepage mappings to NUMA systems
[9] Display current Et Hernet Device Settings
[ten] Bind Ethernet device to IGB UIO module
After compiling OK,
Select 5
For Igb_uio.ko-driven installation, this driver is compiled, in the i686-default-linuxapp-gcc/kmod/directory; in fact, in the installation of Igb_ Before Uio.ko, the script installed the UiO module first, UiO is a user-driven implementation mechanism, DPDK some things based on the UiO implementation; Interested to know about UiO driver use http://blog.csdn.net/wenwuge_topsec/ article/details/9628409
Select 7
Set Hugepage,
Removing currently reserved hugepages
. Echo_tmp:line 2:/sys/devices/system/node/node?/hugepages/ Hugepages-2048kb/nr_hugepages: No file or directory
unmounting/mnt/huge and removing directory Input the number of
2MB Pages
example:to have 128MB of hugepages available, enter ' $ ' to
Reserve * 2MB pages number of
pages:64< C8/>reserving hugepages
Creating/mnt/huge and mounting as Hugetlbfs
Hint no nr_hugepage file, I did not ignore it, for the moment do not know why;
I've entered 64, 64 times 2M to allow you to enter the reserved memory size, and you can do a simple test for 128M.
Choose 9
Take a look at your current device
Option:9
network devices using Igb_uio driver
====================================
<none>
Network devices using kernel driver
=================================== 0000:02:01.0
' 79c970 [PCnet32 LANCE] ' Drv=pcnet32 unused= *active*
0000:02:05.0 ' 79c970 [PCnet32 LANCE] ' if=eth1
drv=pcnet32 unused= *Active* if=eth0 0000:02:06.0 ' 82545EM Gigabit Ethernet Controller (Copper) ' If=eth2 drv=e1000 Unused=igb_uio other
network devices< c10/>=====================
<none>
I have 3 virtual network card, only the last one is Intel's network card, see he has prompted the current network card driver is e1000 instead of using Igb_uio, next is to let you bind it;
Select Ten
Make Nic Bind
Option:10
network devices using Igb_uio driver
====================================
<none>
Network devices using kernel driver
=================================== 0000:02:01.0
' 79c970 [PCnet32 LANCE] ' Drv=pcnet32 unused= *active*
0000:02:05.0 ' 79c970 [PCnet32 LANCE] ' if=eth1
drv=pcnet32 unused= *Active* if=eth0 0000:02:06.0 ' 82545EM Gigabit Ethernet Controller (Copper) ' If=eth2 drv=e1000 Unused=igb_uio other
network devices< c9/>=====================
<none>
Enter PCI address the device to bind to IGB UIO driver:02:06.0
OK
Let you enter the address of the PCI, you just 0000:02:06.0, 0000 Colon After the number of input on the line, such as 02:06.0 remember punctuation to enter Ah,
Note that the binding can have a wrong hint as follows;
Enter PCI address by device to bind to IGB UIO driver:02:06.0 02:07.0 Routing
table indicates that interface 0000:02 : 06.0 is active. Not modifying
OK
is active, may be your current corresponding network card in the up state, so you have to execute down command to turn it off;
For example, my network card is eth2;
Ifconfig eth2 Down
Close and then rerun the above binding operation;
then select 9
Just look at the current network card status;
Option:9
network devices using Igb_uio driver
====================================
' 82545EM Gigabit Ethernet Controller (Copper) ' Drv=igb_uio unused=e1000 network devices
using kernel driver
===== ==============================
0000:02:01.0 ' 79c970 [PCnet32 LANCE] ' if=eth0
drv=pcnet32 unused= *active* 0000:02:05.0 ' 79c970 [PCnet32 LANCE] ' if=eth1 drv=pcnet32 unused= *active* Other network devices ==============
=======
<none>
See Drv=igb_uio Drive has helped pass, now the Intel network card to go is Igb_uio;
Select
Test the DPDK program.
Option:12
Enter hex bitmask of cores to execute TESTPMD app
in example:to execute app on cores 0 to 7, Enter 0xf F
bitmask:0x3
Because my virtual machine only 2 CPU, so according to the 16 in the mask to choose 0x3, enter the run a try;
Enter the start and send the package
Interactive-mode selected
configuring Port 0 (socket-1)
Checking link statuses ...
Port 0 Link up-speed 1000 mbps-full-duplex
done
testpmd>
testpmd> start
warning! Cannot handle a odd number of ports with the current port topology. Configuration must is changed to have a even number of ports, or relaunch application with--port-topology=chained
IO Packet FORWARDING-CRC stripping disabled-packets/burst=16
nb forwarding cores=1-nb forwarding Ports=1
RX qu Eues=1-rx desc=128-rx free threshold=0
RX threshold registers:pthresh=8 hthresh=8 wthresh=4
TX queues=1-t X desc=512-tx free threshold=0
TX threshold registers:pthresh=36 hthresh=0 wthresh=0
tx RS bit threshold=0- TXQ flags=0x0
Have a warning, what is the meaning of ...
January 1, 2014, 22:32:10 Wednesday
The above error, through the same learning DPDK classmate Frank resolved, because I only added 1 Intel network card, you add a piece of OK to enter stop stop;
Telling cores to stop
... Waiting for Lcores to finish ...
----------------------Forward Statistics for Port 0 ----------------------
rx-packets:0 rx-dropped:0 rx-total:0
tx-packets:0 tx-dropped:0 tx-total:0
------------------------------------------------------------- ---------------
+++++++++++++++ accumulated forward statistics for all ports+++++++++++++++
rx-packets:0 rx-dropped:0 rx-total:0
tx-packets:0 tx-dropped:0 tx-total:0
++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++ done
.
Why don't you have a packet? Who knows, tell me;
January 1, 2014, 22:38:16 Wednesday
There is no data on the problem solved, O (∩_∩) o~, the original is my network card mode to add the NAT mode, to modify the hostonly mode, hey, but I still have questions, only two models have any important difference?
----------------------Forward Statistics for Port 0 ----------------------
rx-packets:8890 rx-dropped: 0 rx-total:8890
tx-packets:8894 tx-dropped:0 tx-total:8894
------------------------------- ---------------------------------------------
----------------------Forward Statistics for Port 1 ------- ---------------
rx-packets:8895 rx-dropped:0 rx-total:8895
tx-packets:8889 tx-dropped : 0 tx-total:8889
----------------------------------------------------------------------------
+ ++++++++++++++ accumulated forward statistics for all ports+++++++++++++++ rx-packets:17785 rx-dropped:0< c21/>rx-total:17785
tx-packets:17783 tx-dropped:0 tx-total:17783
+++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++