ubuntu 14.04.6(64bit) 安装DPDK19.11.1LTS和 PKTGEN(非模块)

PKTGEN一种是linux系统自带的内核模块,另一种是依赖于dpdk的pktgen程序集,ubuntu 14.04.6带的pktgen模块版本是2.75,本文不记录内核模块的用法。

 

用的小主机,BIOS有HPET的设置,具体配置(Advanced->...(杂项) -> High Precision Timer 选择Enable)

这个回头再研究,看看怎么回事。

 

安装物理机用的Ubuntu desktop的iso做的u盘,安装时没有联网,否则会下载一些包,时间太长。

内核4.4.0和gcc 4.8.4,版本应该够,

root@mnffgw:/home/sc# ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

 

检查机器是否支持NUMA

  grep -i numa /var/log/dmesg

[    0.000000] No NUMA configuration found

这个情况说明你是non-NUMA架构,在指定大页面内存的时候用单个。

 

下载DPDK

wget http://fast.dpdk.org/rel/dpdk-19.11.1.tar.xz

xz -d dpdk-19.11.1.tar.xz

 tar xvf dpdk-19.11.1.tar

 

回到上一级,make config T=x86_64-native-linuxapp-gcc

make(下面有坑,先安装其他包)

碰到问题和解决:

/root/dpdk/dpdk-stable-19.11.1/lib/librte_eal/linux/eal/eal_memory.c:32:18: fatal error: numa.h: No such file or directory
 #include <numa.h>

apt-get install  libnuma-dev

 

DPDK参考资料:

 

img

 

图片引用自:https://www.cnblogs.com/qcloud1001/p/9585724.html  (此文DPDK的解释很好,值得多读读)

make install

 

装载模块,在build目录

modprobe uio【可以配置到/etc/modules里,开机自动加载】

insmod kmod/igb_uio.ko 【这两个ko可以配置到/etc/rc.local里,需要带绝对路径指明文件位置,开机自动加载】

insmod kmod/rte_kni.ko

设置大页内存

cat /proc/cpuinfo | grep pdpe1gb ,如果有显示,则支持1G大内存页
默认支持2M内存页cat /proc/cpuinfo |grep pse如果有显示,则支持2M内存页

我的内存只有4G,准备给大页内存2G,

我的cpu只有4个核,用第3、4个核。

命令是临时的,需要的话用配置文件,启动时配置好。

mkdir -p /mnt/huge【开机自启配置到/etc/rc.local】
mount -t hugetlbfs nodev /mnt/huge【通过/etc/fstab增加nodev /mnt/huge hugetlbfs defaults   0     0挂载配置】
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages【通过/etc/sysctl.conf增加vm.nr_hugepages=1024配置】设置多了不要紧,会自动算的。

grep -i huge /proc/meminfo可以查看huge的情况。

查找捆绑网卡

./usertools/dpdk-devbind.py --status

Network devices using kernel driver
===================================
0000:01:00.0 'I211 Gigabit Network Connection 1539' if=eth0 drv=igb unused=igb_uio *Active*
0000:02:00.0 'I211 Gigabit Network Connection 1539' if=eth1 drv=igb unused=igb_uio 
0000:03:00.0 'I211 Gigabit Network Connection 1539' if=eth2 drv=igb unused=igb_uio 
0000:04:00.0 'I211 Gigabit Network Connection 1539' if=eth3 drv=igb unused=igb_uio 

No 'Baseband' devices detected
==============================

Crypto devices using kernel driver
==================================
0000:00:1a.0 'Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine 0f18' if= drv=mei_txe unused=igb_uio 

No 'Eventdev' devices detected
==============================

No 'Mempool' devices detected
=============================

No 'Compress' devices detected
==============================

No 'Misc (rawdev)' devices detected
===================================

准备绑定eth2,3

 

考虑命令配置在/etc/rc.local中,启动后有效

Network devices using DPDK-compatible driver
============================================
0000:03:00.0 'I211 Gigabit Network Connection 1539' drv=igb_uio unused=
0000:04:00.0 'I211 Gigabit Network Connection 1539' drv=igb_uio unused=

Network devices using kernel driver
===================================
0000:01:00.0 'I211 Gigabit Network Connection 1539' if=eth0 drv=igb unused=igb_uio *Active*
0000:02:00.0 'I211 Gigabit Network Connection 1539' if=eth1 drv=igb unused=igb_uio 

No 'Baseband' devices detected
==============================

Crypto devices using kernel driver
==================================
0000:00:1a.0 'Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine 0f18' if= drv=mei_txe unused=igb_uio 

No 'Eventdev' devices detected
==============================

No 'Mempool' devices detected
=============================

No 'Compress' devices detected
==============================

No 'Misc (rawdev)' devices detected
===================================

检查得知已经绑定

然后设置环境变量到/etc/profile

#dpdk
export RTE_SDK=/root/dpdk/dpdk-stable-19.11.1
export RTE_TARGET=x86_64-native-linuxapp-gcc

最优配置的链接:https://doc.dpdk.org/guides/linux_gsg/nic_perf_intel_platform.html

 

dpdk下example下的helloword可以运行,

运行example下ethtool

运行检查的port就是绑定uio驱动的端口重新编号为port 0 ,port 1

 

有些网卡不支持,这个地方放有点晚了,我曾经因为网卡进坑。

https://core.dpdk.org/supported/nics/

 

dpdk pktgen资料链接:https://pktgen-dpdk.readthedocs.io/en/latest/

安装个git工具,apt-get install git

下载Pktgen-DPDK,git clone https://github.com/pktgen/Pktgen-DPDK.git

据说要下载一下头文件,apt-get install linux-headers-4.4.0-142-generic
apt-get install libpcap-dev

make                下面有坑,有些包要先装

提示少了#include <lua.h>

据说此处需要lua5.3

wget http://www.lua.org/ftp/lua-5.3.5.tar.gz,安装,make linux install(写lua的老师们怎么想的,readme用的是doc/*.html,切记用make linux install)

发现没有readline.h,

apt-get install libreadline-dev

回到Pktgen-DPDK

还是lua没正确安装才有

"Lua pkg-config was not found"
"Get lua-5.3 from lua.org and build it on your system"
"Also install lua 5.3 into /usr/local/include and /usr/local/lib"
"Make sure the library in /usr/local/lib is called liblua.a"
"Lua pkg-config was not found"
"Get lua-5.3 from lua.org and build it on your system"
"Also install lua 5.3 into /usr/local/include and /usr/local/lib"
"Make sure the library in /usr/local/lib is called liblua.a"

 

先用个命令行跑一下,

./app/x86_64-native-linuxapp-gcc/pktgen -l 1-3 -n 1 -- -P -m "[2].0,[3].1"

在pktgen下,运行start 0,开始跑,stop 0,停止。

 

 

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
运行 DPDK 的 Kernel Network Interface (KNI) 需要以下步骤: 1. 编译 DPDK 库和示例程序。 2. 加载 DPDK 驱动程序。 3. 配置 KNI 接口。 4. 运行示例程序。 下面给出详细说明和示例: 1. 编译 DPDK 库和示例程序。 下载 DPDK 19.11.4 版本,并解压缩: ``` tar -xvf dpdk-19.11.4.tar.xz cd dpdk-19.11.4 ``` 设置环境变量: ``` export RTE_SDK=`pwd` export RTE_TARGET=x86_64-native-linuxapp-gcc ``` 编译 DPDK 库和示例程序: ``` make config T=x86_64-native-linuxapp-gcc make ``` 2. 加载 DPDK 驱动程序。 使用 DPDK 的 KNI 接口需要加载 DPDK 驱动程序,可以使用以下命令加载: ``` sudo modprobe uio sudo insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ``` 3. 配置 KNI 接口。 为了使用 KNI 接口,需要在 DPDK 的 EAL 中设置 KNI 接口的名称和数量: ``` sudo $RTE_SDK/usertools/dpdk-devbind.py -b igb_uio 0000:01:00.0 sudo $RTE_SDK/usertools/dpdk-devbind.py -b igb_uio 0000:01:00.1 sudo $RTE_SDK/usertools/dpdk-devbind.py --status sudo $RTE_SDK/usertools/dpdk-setup.sh ``` 其中,第一行和第二行将网络设备绑定到 DPDK 的驱动程序上。第三行是检查绑定结果。第四行是配置 KNI 接口的名称和数量。 4. 运行示例程序。 DPDK 示例程序提供了 kni 示例,可以使用以下命令运行: ``` sudo ./examples/kni/build/kni -c 0x1 -n 4 -- -P -p 0x3 --config="(0,0,1),(1,0,2)" ``` 其中,-c 0x1 表示使用核心 1 运行程序,-n 4 表示使用 4 个内存通道,-P 表示启用了包括 KNI 在内的所有端口,-p 0x3 表示使用了两个物理端口,--config="(0,0,1),(1,0,2)" 表示将这两个物理端口连接起来。 这样,就可以使用 kni 示例程序进行 KNI 接口的测试了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值