安装 DPDK(Ubuntu 1804 LTS)
环境参数
Intel x86
Ubuntu 18.04 LTS
Python 3.6
DPDK 18.08a
NICs virtio controller
环境依赖准备
# 自动解决必要依赖包安装的工具
sudo apt-get install build-essential
# 更新系统
sudo apt-get update -y && sudo apt-get upgrade -y
# Kernel Header
sudo apt-get install linux-headers-$(uname -r)
# GCC
sudo apt-get install gcc -y
# C++
sudo apt-get install g++ -y
# Pcap
sudo apt-get install libpcap-dev -y
# NUMA
sudo apt-get install libnuma-dev -y
sudo apt-get install numactl -y
# Network Tools
sudo apt-get install net-tools -y
安装 DPDK
下述使用 dpdk-setup.py tool 来进行安装。
sudo cd /opt
sudo wget http://fast.dpdk.org/rel/dpdk-18.08.tar.gz
sudo tar -zxvf dpdk-18.08.tar.gz
sudo cd /opt/dpdk-18.08/usertools
$ sudo ./dpdk-setup.py
------------------------------------------------------------------------------
RTE_SDK exported as /opt/dpdk-18.08
------------------------------------------------------------------------------
----------------------------------------------------------
Step 1: Select the DPDK environment to build
----------------------------------------------------------
[1] arm-armv7a-linuxapp-gcc
[2] arm64-armv8a-linuxapp-clang
[3] arm64-armv8a-linuxapp-gcc
[4] arm64-dpaa-linuxapp-gcc
[5] arm64-dpaa2-linuxapp-gcc
[6] arm64-stingray-linuxapp-gcc
[7] arm64-thunderx-linuxapp-gcc
[8] arm64-xgene1-linuxapp-gcc
[9] i686-native-linuxapp-gcc
[10] i686-native-linuxapp-icc
[11] ppc_64-power8-linuxapp-gcc
[12] x86_64-native-bsdapp-clang
[13] x86_64-native-bsdapp-gcc
[14] x86_64-native-linuxapp-clang
[15] x86_64-native-linuxapp-gcc
[16] x86_64-native-linuxapp-icc
[17] x86_x32-native-linuxapp-gcc
----------------------------------------------------------
Step 2: Setup linuxapp environment
----------------------------------------------------------
[18] Insert IGB UIO module
[19] Insert VFIO module
[20] Insert KNI module
[21] Setup hugepage mappings for non-NUMA systems
[22] Setup hugepage mappings for NUMA systems
[23] Display current Ethernet/Crypto device settings
[24] Bind Ethernet/Crypto device to IGB UIO module
[25] Bind Ethernet/Crypto device to VFIO module
[26] Setup VFIO permissions
----------------------------------------------------------
Step 3: Run test application for linuxapp environment
----------------------------------------------------------
[27] Run test application ($RTE_TARGET/app/test)
[28] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)
----------------------------------------------------------
Step 4: Other tools
----------------------------------------------------------
[29] List hugepage info from /proc/meminfo
----------------------------------------------------------
Step 5: Uninstall and system cleanup
----------------------------------------------------------
[30] Unbind devices from IGB UIO or VFIO driver
[31] Remove IGB UIO module
[32] Remove VFIO module
[33] Remove KNI module
[34] Remove hugepage mappings
[35] Exit Script
Option:
Setup DPDK environment:15
Build complete [x86_64-native-linuxapp-gcc]
Installation cannot run with T defined and DESTDIR undefined
------------------------------------------------------------------------------
RTE_TARGET exported as x86_64-native-linuxapp-gcc
------------------------------------------------------------------------------
Load UIO module:18
Unloading any existing DPDK UIO module
Loading uio module
Loading DPDK UIO module
Setup HugePage Numbers:22
Removing currently reserved hugepages
Unmounting /mnt/huge and removing directory
Input the number of 2048kB hugepages for each node
Example: to have 128MB of hugepages available per node in a 2MB huge page system,
enter '64' to reserve 64 * 2MB pages on each node
Number of pages for node0: 512
Number of pages for node1: 512
Reserving hugepages
Creating /mnt/huge and mounting as hugetlbfs
Show HugePage:29
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 1024
HugePages_Free: 1024
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Show NICs:23
Network devices using DPDK-compatible driver
============================================
<none>
Network devices using kernel driver
===================================
0000:00:03.0 'Virtio network device 1000' if=ens3 drv=virtio-pci unused=igb_uio *Active*
0000:00:07.0 'Virtio network device 1000' if=ens7 drv=virtio-pci unused=igb_uio
Bind device to IGB UIO module:24
Enter PCI address of device to bind to IGB UIO driver: 0000:00:07.0
OK
测试
$ cat dpdk.rc
export RTE_SDK=/opt/dpdk-18.08
export RTE_TARGET=x86_64-native-linuxapp-gcc
export DPDK_BUILD=${DPDK_DIR}/${RTE_TARGET}
export LD_LIBRARY_PATH=${RTE_SDK}/${RTE_TARGET}/lib:/usr/local/lib:/usr/lib:
$ source dpdk.rc
$ cd dpdk-18.08/examples/helloworld
$ make
$ ./build/helloworld
EAL: Detected 4 lcore(s)
EAL: Detected 2 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: No free hugepages reported in hugepages-1048576kB
EAL: Probing VFIO support...
EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles !
EAL: PCI device 0000:00:03.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 1af4:1000 net_virtio
EAL: PCI device 0000:00:07.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 1af4:1000 net_virtio
hello from core 1
hello from core 2
hello from core 3
hello from core 0
附 1:Enable pcap
NOTE: libpcap headers are required.
# DPDK config
$ cd dpdk-18.08/x86_64-native-linuxapp-gcc
$ sed -ri 's,(PMD_PCAP=).*,\1y,' .config
$ sed -ri 's,(PDUMP=).*,\1y,' .config
$ make
# Pdmp tool
$ cd dpdk-18.08/app/pdump
$ make && make install