l2fwd 测试

来源:互联网 发布:windows怎么更新系统 编辑:程序博客网 时间:2024/06/11 10:39

环境如下:

  • Ubuntu 16.04
  • cpu 4 core
  • Intel Corporation 82545EM Gigabit Ethernet Controller * 2个
  • dpdk-17.02.1

提示: 测试需要root权限

一. dpdk 环境搭建

1.1. 编译 dpdk

cd dpdkmake config T=x86_64-native-linuxapp-gccmakemake install T=x86_64-native-linuxapp-gcc

1.2. 设置环境变量

编辑.profile.bashrc,添加:

export RTE_SDK=/root/dpdkexport RTE_TARGET=x86_64-native-linuxapp-gcc

1.3. 加载内核模块

modprobe uioinsmod x86_64-native-linuxapp-gcc/kmod/igb_uio.ko

1.4. 设置 hugepage

mkdir -p /mnt/hugemount -t hugetlbfs nodev /mnt/hugeecho 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages

1.5. 绑定网卡

先查看网卡状态,确保网卡处于 down 状态

root@zengxl:/root/dpdk# ./usertools/dpdk-devbind.py --statusNetwork devices using DPDK-compatible driver============================================<none>Network devices using kernel driver===================================0000:02:01.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens33 drv=e1000 unused=igb_uio *Active*0000:02:06.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens38 drv=e1000 unused=igb_uio 0000:02:07.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens39 drv=e1000 unused=igb_uio Other network devices=====================<none>Crypto devices using DPDK-compatible driver===========================================<none>Crypto devices using kernel driver==================================<none>Other crypto devices====================<none>

绑定

root@zengxl:/root/dpdk# ./usertools/dpdk-devbind.py --bind=igb_uio ens38root@zengxl:/root/dpdk# ./usertools/dpdk-devbind.py --bind=igb_uio ens39

二. 测试

./build/l2fwd -c 0xc -n 2 -- -q 1 -p 0x3EAL: Detected 4 lcore(s)EAL: No free hugepages reported in hugepages-1048576kBEAL: Probing VFIO support...EAL: PCI device 0000:02:01.0 on NUMA socket -1EAL:   probe driver: 8086:100f net_e1000_emEAL: PCI device 0000:02:06.0 on NUMA socket -1EAL:   probe driver: 8086:100f net_e1000_emEAL: PCI device 0000:02:07.0 on NUMA socket -1EAL:   probe driver: 8086:100f net_e1000_emMAC updating enabledLcore 2: RX port 0Lcore 3: RX port 1Initializing port 0... done: Port 0, MAC address: 00:0C:29:75:1E:19Initializing port 1... done: Port 1, MAC address: 00:0C:29:75:1E:23Checking link statusdonePort 0 Link Up - speed 1000 Mbps - full-duplexPort 1 Link Up - speed 1000 Mbps - full-duplexL2FWD: entering main loop on lcore 3L2FWD:  -- lcoreid=3 portid=1L2FWD: entering main loop on lcore 2L2FWD:  -- lcoreid=2 portid=0Port statistics ====================================Statistics for port 0 ------------------------------Packets sent:                   301034Packets received:               336559Packets dropped:                     0Statistics for port 1 ------------------------------Packets sent:                   336559Packets received:               301034Packets dropped:                     0Aggregate statistics ===============================Total packets sent:             637593Total packets received:         637593Total packets dropped:               0====================================================^CSignal 2 received, preparing to exit...Closing port 0... DoneClosing port 1... DoneBye...

参考

http://dpdk.org/doc