配置虚拟机环境
- 多张网卡,一张网卡是无法运行DPDK的,至少要两张。
- 多核CPU,可以在实现多个DPDK逻辑调度核lcore。
安装DPDK
1.在DPDK官网下载DPDK的压缩包:http://core.dpdk.org/download, 我下载的是稳定版本18.05.1
.
2.进入root权限,解压下载的安装包到用户目录下。
tar xJf ddpdk-stable-18.05.1.tar.xz
cd dpdk-stable-18.05.1/
3.配置环境变量
make config T=x86_64-native-linuxapp-gcc
sed -ri 's,(PMD_PCAP=).*,1y,' build/.config
4.安装
make
运行DPDK
1.设置环境变量
export RTE_SDK=/home/liuhy/dpdk-stable-18.05.1/
export RTE_TARGET=build
2.编译example程序
make -C examples
3.配置大页表
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
echo 64 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
4.运行helloworld,效果如下:
root@liuhy-VirtualBox:/home/liuhy/dpdk-stable-18.05.1/examples/helloworld/build# ./helloworld -c f
EAL: Detected 4 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Probing VFIO support...
EAL: PCI device 0000:00:03.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:08.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:09.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:0a.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 8086:100e net_e1000_em
hello from core 1
hello from core 2
hello from core 3
hello from core 0