dpdk快速编译使用

QuickStart

环境

dpdk: dpdk-17.11

运行前配置

配置系统HugePages

#mkdir /mnt/huge_1GB/
#vim /etc/fstab
nodev                /mnt/huge_1GB   hugetlbfs       defaults        0 0
#vim /etc/default/grub
default_hugepagesz=1G hugepagesz=1G hugepages=4"
#grub2-mkconfig -o /boot/grub2/grub.cfg
#reboot
#cat /proc/meminfo  | grep Hug
AnonHugePages:     88064 kB
HugePages_Total:       4
HugePages_Free:        4
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

加载uio驱动

#modprobe uio_pci_generic
#modprobe uio
#lsmod  | grep uio
uio_pci_generic        16384  0
uio                    20480  1 uio_pci_generic

build dpdk

#cd /data/sandbox/dpdk-17.11
#make install  T=x86_64-native-linuxapp-gcc
或者指定目录:
#make install  T=x86_64-native-linuxapp-gcc DESTDIR=/opt/dpdk
#cd x86_64-native-linuxapp-gcc/

绑定网卡到uio驱动

  • dpdk的应用程序要使用某块网卡是,需要使用tools/pci_unbind.py将网卡绑定到驱动uio_pci_generic
  • 在dpdk对网卡的称呼是port, 就是网口。

先把eth0 设备down掉,才能,将eth0绑定成功

#ifdown eth0

#ethtool -i eth1
driver: igb

将eth0网卡绑定到uio驱动:

#python usertools/dpdk-devbind.py --bind=uio_pci_generic eth0  //eth0绑定到驱动uio_pci_generic

使用 usertools/dpdk-devbind.py 查看网卡状态:

[root@jiangyi02.xxx /data/sandbox/dpdk-17.11]
#python usertools/dpdk-devbind.py --status

Network devices using DPDK-compatible driver
============================================
0000:01:00.0 '82580 Gigabit Network Connection 150e' drv=uio_pci_generic unused=

Network devices using kernel driver
===================================
0000:01:00.1 '82580 Gigabit Network Connection 150e' if=eth1 drv=igb unused=uio_pci_generic
0000:06:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' if=ens6f0 drv=ixgbe unused=uio_pci_generic
0000:06:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' if=ens6f1 drv=ixgbe unused=uio_pci_generic

编译一个简单的DPDK程序

编译之前,首先,声明环境变量: RTE_SDK RTE_TARGET

其中RTE_SDK是DPDK的安装目录,RTE_TARGET是DPDK目标环境目录。

[root@jiangyi02.xxx /data/sandbox/dpdk-17.11]
#export RTE_SDK=/data/sandbox/dpdk-17.11

[root@jiangyi02.xxx /data/sandbox/dpdk-17.11]
#export RTE_TARGET=x86_64-native-linuxapp-gcc

在examples目录里面编译一个简单的应用:

cd examples/helloworld/
make
[root@jiangyi02.xxx /data/sandbox/dpdk-17.11/examples/helloworld/build]
#./helloworld
EAL: Detected 24 lcore(s)
EAL: Probing VFIO support...
EAL: PCI device 0000:01:00.0 on NUMA socket 0
EAL:   probe driver: 8086:150e net_e1000_igb
EAL: PCI device 0000:01:00.1 on NUMA socket 0
EAL:   probe driver: 8086:150e net_e1000_igb
EAL: PCI device 0000:06:00.0 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:06:00.1 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
hello from core 1
hello from core 2
hello from core 3
hello from core 4
hello from core 5
hello from core 6
hello from core 7
hello from core 8
hello from core 9
hello from core 10
hello from core 11
hello from core 12
hello from core 13
hello from core 14
hello from core 15
hello from core 16
hello from core 17
hello from core 18
hello from core 19
hello from core 20
hello from core 21
hello from core 22
hello from core 23
hello from core 0

Docs

http://doc.dpdk.org/guides/linux_gsg/index.html

https://www.jianshu.com/p/dcb6ccc83ea5

posted @ 2019-05-07 16:43  苏小北1024  阅读(1276)  评论(0编辑  收藏  举报