DPDK 安装指导
Ubuntu18.04篇
1.概述
此文档介绍DPDK在ubuntu上的安装步骤和FAQ
1.1 介绍
待补充
1.2 简介
待补充
2.DPDK安装
2.1 软件版本
DPDK:dpdk-19.08.2
ubuntu版本:18.04
linux内核:5.4.0-150-generic
2.2 系统环境准备
依赖工具安装
sudo apt install build-essential
#编译程序必须的软件包,如果想在Ubuntu中编译c/c++程序,只需要安装该软件包
sudo apt-get install libnuma-dev
配置大页内存,开启immon功能
sudo vim /etc/default/grub
在GRUB_CMDLINE_LINUX末尾追加:
GRUB_CMDLINE_LINUX="find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US hugepages=512 intel_iommu=on iommu=pt"
重新生成引导配置
sudo grub-mkconfig -o /boot/grub/grub.cfg
重启并验证
cat /proc/meminfo |grep -i HugePages
dmesg | grep DMAR
2.3 编译安装DPDK
设置环境变量
cd dpdk-stable-19.08.2
export RTE_SDK=`pwd`
export RTE_TARGET=x86_64-native-linuxapp-gcc
===============================================================================
运行dpdk-setup.sh 编译
sunny@ubuntu:~/dpdk-stable-19.08.2$ cd usertools/
sunny@ubuntu:~/dpdk-stable-19.08.2/usertools$ ./dpdk-setup.sh
===============================================================================
Option: 编译选项选择36
[36] x86_64-native-linuxapp-gcc
Option: 36
回显:
===============================================================================
加载驱动,选择43
[43] Insert IGB UIO module
Option: 43
回显:
#Unloading any existing DPDK UIO module
#Loading uio module
#Loading DPDK UIO module
===============================================================================
配置大页内存46
[46] Setup hugepage mappings for non-NUMA systems
Option: 46
回显:
#Removing currently reserved hugepages
#Unmounting /mnt/huge and removing directory
Number of pages: 512
#Reserving hugepages
#Creating /mnt/huge and mounting as hugetlbfs
===============================================================================
查看网卡状态48,“0000:03:00.0”即网卡PCI地址,后续配置用”03:00.0”就可以
[48] Display current Ethernet/Baseband/Crypto device settings
Option: 48
回显:
#Network devices using DPDK-compatible driver
============================================
#0000:03:00.0 'VMXNET3 Ethernet Controller 07b0' drv=igb_uio unused=vmxnet3,vfio-pci
#Network devices using kernel driver
===================================
#0000:02:01.0 '82545EM Gigabit Ethernet Controller (Copper) 100f' if=ens33 drv=e1000 unused=igb_uio,vfio-pci *Active*
#No 'Baseband' devices detected
===============================================================================
绑定网卡49
需要先将网卡down:
---------------------------------sunny@ubuntu:~/dpdk-stable-19.08.2/usertools$ ifconfig ens160 down
[49] Bind Ethernet/Baseband/Crypto device to IGB UIO module
Option: 49
回显:
Enter PCI address of device to bind to IGB UIO driver: 03:00.0
OK
===============================================================================
运行测试程序53
[53] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)
Option: 53
# Enter hex bitmask of cores to execute testpmd app on
# Example: to execute app on cores 0 to 7, enter 0xff
bitmask: 7
#Launching app
#EAL: Detected 4 lcore(s)
#EAL: Detected 1 NUMA nodes
。。。。。。。。。。。。。。。
#Configuring Port 0 (socket 0)
#Port 0: 00:0C:29:71:E5:57
#Checking link statuses...
#Done
在命令行启动网卡
testpmd> start
io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled, MP allocation mode: native
Logical Core 1 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
io packet forwarding packets/burst=32
nb forwarding cores=1 - nb forwarding ports=1
port 0: RX queue number: 1 Tx queue number: 1
Rx offloads=0x0 Tx offloads=0x0
RX queue: 0
RX desc=0 - RX free threshold=0
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
RX Offloads=0x0
TX queue: 0
TX desc=0 - TX free threshold=0
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX offloads=0x0 - TX RS bit threshold=0
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 335 RX-dropped: 0 RX-total: 335
TX-packets: 335 TX-dropped: 0 TX-total: 335
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 335 RX-dropped: 0 RX-total: 335
TX-packets: 335 TX-dropped: 0 TX-total: 335
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Done.
===============================================================================
环境搭建完成,60退出
[60] Exit Script
Option: 60
3.FAQ
1、如果编译安装过程中,绑定网卡可能会遇到python执行不了
解决方法:可能的原因是你本地安装的是python3,但是绑定网卡的执行程序调用的是python,可以去usertools目录下,修改dpdk-devbind.py文件,把第一行的python修改为python3
2、参考连接如下:但是要注意第三步的环境变量配置需要修改为 export RTE_TARGET=x86_64-native-linuxapp-gcc
https://blog.csdn.net/qq_18854309/article/details/125034702?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169406703816800188541549%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=169406703816800188541549&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-125034702-null-null.142^v93^chatsearchT3_2&utm_term=dpdk%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA&spm=1018.2226.3001.4187
3、查看网卡的总线信息,先安装工具apt install ethtool
ethtool -i eth0
driver: vmxnet3
version: 1.4.16.0-k-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:0b:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no