引用網址:https://blog.csdn.net/cloudvtech/article/details/80221236
一、前言
DPDK(Intel Data Plane Development Kit)是Intel提供的数据平面开发工具集,专注于网络应用中数据包的高性能处理。DPDK应用程序运行在用户空间,利用自身提供的数据平面库来收发数据包,绕过了Linux内核协议栈对数据包处理过程。DPDK其实也是网络开发框架和开发库、高效数据结构、众多Linux系统优化方法的合集。
转载自https://blog.csdn.net/cloudvtech
二、DPDK的核心思想
2.1 用户态网络驱动
使用Linux的UIO技术,PMD批量收发数据,避免终端爆炸;线程绑定CPU core,避免调度开销;避免内核态和用户态的数据拷贝;用户态程序的稳定性更好
2.2 高效内存使用
使用大页减少TLB cache miss,高效的m_buf管理,使得多种网络处理更高效
2.3 环形队列
提供无锁队列,提高信息交互效率
2.4 向量化指令
提升内存读取效率,分摊指令开销
转载自https://blog.csdn.net/cloudvtech
三、DPDK 17.08.1在CentOS 7.2.1511的安装
3.1 系统设置
1. OS: http://vault.centos.org/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso
2. H/W:
1 NUMA node with 4 CPU cores
4 GB memory
3 NICs
40 GB disk
3.2 依赖安装
yum makecache
yum install -y gcc gcc-c++ kernel-devel kernel-headers kernel.x86_64 net-tools
yum install -y numactl-devel.x86_64 numactl-libs.x86_64
yum install -y libpcap.x86_64 libpcap-devel.x86_64
yum install -y pciutils
3.3 设置大页内存
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
mkdir /mnt/huge
chmod 777 /mnt/huge
in /etc/fstab
huge /mnt/huge hugetlbfs defaults 0 0
cat /proc/meminfo | grep Huge
3.4 安装DPDK
wget http://fast.dpdk.org/rel/dpdk-17.08.1.tar.xz
xz -d dpdk-17.08.1.tar.xz
tar -xvf dpdk-17.08.1.tar
cd dpdk-stable-17.08.1/
3.4.1 patch
3.4.2 编译
export RTE_SDK=/root/dpdk-stable-17.08.1
export RTE_TARGET=x86_64-native-linuxapp-gcc
make config T=x86_64-native-linuxapp-gcc
sed -ri 's,(PMD_PCAP=).*,\1y,' build/.config
make
cd $RTE_SDK
make install T=x86_64-native-linuxapp-gcc
3.5 安装kernel module
modprobe uio_pci_generic
modprobe uio
modprobe vfio-pci
insmod build/kmod/igb_uio.ko
3.6 查看驱动bind状态
3.7 bind NIC
现有的NIC如下:
ifconfig eno33554960 down
ifconfig eno50332184 down
./usertools/dpdk-devbind.py --bind=igb_uio 02:02.0
./usertools/dpdk-devbind.py --bind=igb_uio 02:03.0
查看bind之后状态:
./usertools/dpdk-devbind.py --status-dev net
转载自https://blog.csdn.net/cloudvtech
四、基于DPDK的简单测试
4.1 编译运行hellowrold程序
make -C examples RTE_SDK=$(pwd) RTE_TARGET=build O=$(pwd)/build/examples
./build/examples/helloworld/build/helloworld
4.2 PMD测试
export RTE_TARGET=build/
[26] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)
4.3 testpmd参数测试
build/app/testpmd -l 3,0,2 --socket-mem 1024 --log-level=8 -- -i
testpmd> set nbcore 2
Number of forwarding cores set to 2
testpmd> show config fwd
io packet forwarding - ports=2 - cores=2 - streams=2 - NUMA support enabled, MP over anonymous pages disabled
Logical Core 2 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
Logical Core 3 (socket 0) forwards packets on 1 streams:
RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
testpmd> show config cores
List of forwarding lcores: 2 3
testpmd> start
io packet forwarding - ports=2 - cores=2 - streams=2 - NUMA support enabled, MP over anonymous pages disabled
Logical Core 1 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
Logical Core 2 (socket 0) forwards packets on 1 streams:
RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
io packet forwarding - CRC stripping enabled - packets/burst=32
nb forwarding cores=2 - nb forwarding ports=2
RX queues=1 - RX desc=128 - RX free threshold=0
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX queues=1 - TX desc=512 - TX free threshold=0
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX RS bit threshold=0 - TXQ flags=0x0
testpmd> show port stats all
######################## NIC statistics for port 0 ########################
RX-packets: 1649080 RX-missed: 0 RX-bytes: 122036704
RX-errors: 0
RX-nombuf: 0
TX-packets: 258545 TX-errors: 0 TX-bytes: 17993146
Throughput (since last show)
Rx-pps: 97242
Tx-pps: 35178
############################################################################
######################## NIC statistics for port 1 ########################
RX-packets: 267012 RX-missed: 0 RX-bytes: 19670724
RX-errors: 0
RX-nombuf: 0
TX-packets: 1661125 TX-errors: 0 TX-bytes: 116279790
Throughput (since last show)
Rx-pps: 37156
Tx-pps: 95331
############################################################################
留言列表