标签:
续前节,
测试小程序
1. 想编译测试程序首先需要设置两个环境变量,为什么呢,因为测试程序的Makefile里用了。。。 rpm装了打包好的devel包,这个rpm也会自带这两个环境变量。就是说写第三方程序的时候,习惯上,约定了这两个环境变量。
[root@dpdk tools]# cat ~/env.sh export RTE_SDK=/root/dpdk-16.07 export RTE_TARGET=x86_64-native-linuxapp-gcc [root@dpdk tools]#
2. 文档里说:The UIO drivers and hugepages must be setup prior to running an application.
UIO包括:uio_pci_generic, uio, igb_uio, vfio_pci
vfio_pci 在host里我已经学会怎么玩了。uio不知道是啥,好想要和igb_uio放在一起用
sudo modprobe uio
sudo insmod kmod/igb_uio.ko
[root@dpdk tools]# locate igb_uio.ko /root/dpdk-16.07/build/build/lib/librte_eal/linuxapp/igb_uio/.igb_uio.ko.cmd /root/dpdk-16.07/build/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko /root/dpdk-16.07/build/kmod/igb_uio.ko /root/dpdk-16.07/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/.igb_uio.ko.cmd /root/dpdk-16.07/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko /root/dpdk-16.07/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko [root@dpdk tools]#
我觉得弄一下 uio_pci_generic
首先,有一个非常好用的工具 tools/dpdk-devbind.sh . (我就是客气一下,我并没有觉得特别好用,当然也觉得难用,因为我根本就没怎么用)
(1) 现运行这个命令,看一看
[root@dpdk tools]# ./dpdk-devbind.py --status Network devices using DPDK-compatible driver ============================================ <none> Network devices using kernel driver =================================== 0000:00:03.0 ‘Virtio network device‘ if= drv=virtio-pci unused= 0000:00:04.0 ‘Ethernet Connection (3) I218-V‘ if=ens4 drv=e1000e unused= *Active* Other network devices ===================== <none>
(2)加载驱动 uio_pci_generic
[root@dpdk tools]# modprobe uio_pci_generic
(3) 再运行看一下,然后发现unused发生了变化,可是也没什么大不了的。
[root@dpdk tools]# ./dpdk-devbind.py --status Network devices using DPDK-compatible driver ============================================ <none> Network devices using kernel driver =================================== 0000:00:03.0 ‘Virtio network device‘ if= drv=virtio-pci unused=uio_pci_generic 0000:00:04.0 ‘Ethernet Connection (3) I218-V‘ if=ens4 drv=e1000e unused=uio_pci_generic *Active* Other network devices ===================== <none>
(4)把网卡从原驱动e1000e上面解绑,和vfio_pci的操作没有区别。
[root@dpdk tools]# lspci -nn -s 00:04.0 00:04.0 Ethernet controller [0200]: Intel Corporation Ethernet Connection (3) I218-V [8086:15a3] (rev 03) [root@dpdk tools]# echo 0000:00:04.0 > /sys/bus/pci/devices/0000\:00\:04.0/driver/unbind
[root@dpdk tools]# ./dpdk-devbind.py --status Network devices using DPDK-compatible driver ============================================ <none> Network devices using kernel driver =================================== 0000:00:03.0 ‘Virtio network device‘ if= drv=virtio-pci unused=uio_pci_generic Other network devices ===================== 0000:00:04.0 ‘Ethernet Connection (3) I218-V‘ unused=uio_pci_generic
(5) 绑到 uio_pci_generic 上面去。
[root@dpdk tools]# echo ‘0000:00:04.0‘ > /sys/bus/pci/drivers/uio_pci_generic/bind
[root@dpdk tools]# ./dpdk-devbind.py --status Network devices using DPDK-compatible driver ============================================ 0000:00:04.0 ‘Ethernet Connection (3) I218-V‘ drv=uio_pci_generic unused= Network devices using kernel driver =================================== 0000:00:03.0 ‘Virtio network device‘ if= drv=virtio-pci unused=uio_pci_generic Other network devices ===================== <none>
(6) 至此,绑完了就。就文档说(4)和(5)可以用一条命令搞定。并没有测试。
./tools/dpdk-devbind.py --bind=uio_pci_generic 04:00.1
大页,我早已经在虚拟机里设置好了。
3. EAL库。就是dpdk的程序都可以接受命令行参数。其他是可选的,只有一个-c mask是比较主要的,用掩码觉得运行程序的逻辑核。
[root@dpdk build]# ./helloworld -c 1 |grep hello hello from core 0 [root@dpdk build]# ./helloworld -c 2 |grep hello hello from core 1 [root@dpdk build]# ./helloworld -c 4 |grep hello hello from core 2 [root@dpdk build]# ./helloworld -c 3 |grep hello hello from core 0 hello from core 1 [root@dpdk build]# ./helloworld -c 6 |grep hello hello from core 2 hello from core 1 [root@dpdk build]#
4. 给mask参数之前,你必须知道你的cpu结构。
这么多年都是这样的。
[root@dpdk build]# cat /proc/cpuinfo
后来觉得可视性不好,于是写了个脚本整理了一下输出结果。可是那又怎么样呢? 依然很土。
然后,对,刚刚,dpdk的文档里介绍了这个:lstopo (pkg: hwloc). 输出结果是酱紫的!
牛逼的!我还能说什么。。。 还有nographic版本:
[tong@T7 ~]$ lstopo-no-graphics Machine (7927MB) Package L#0 + L3 L#0 (4096KB) L2 L#0 (256KB) + L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0 PU L#0 (P#0) PU L#1 (P#1) L2 L#1 (256KB) + L1d L#1 (32KB) + L1i L#1 (32KB) + Core L#1 PU L#2 (P#2) PU L#3 (P#3) HostBridge L#0 PCI 8086:1616 GPU L#0 "card1" GPU L#1 "renderD129" GPU L#2 "controlD65" PCI 8086:15a3 PCIBridge PCI 8086:095b Net L#3 "wlan0" PCIBridge PCI 10de:1347 GPU L#4 "card0" GPU L#5 "renderD128" GPU L#6 "controlD64" PCI 8086:9c83 Block(Disk) L#7 "sda" Block(Disk) L#8 "sdb" [tong@T7 ~]$
标签:
原文地址:http://www.cnblogs.com/hugetong/p/5914938.html