DPDK-L3fwd测试

来源:互联网 发布:传奇3数据库修改 编辑:程序博客网 时间:2024/06/05 20:06

0x01 DPDK运行要求




















注意:不同DPDK版本可能要求不同

0x02Centos 6.5 x86_64环境查看

Cpu信息:

运行lscpu,输出如下:



















socket:主板上插cpu的槽的数目;

core:就是我们平时说的“核“,每个物理CPU可以双核,四核等;

①物理CPU

cat /proc/cpuinfo |grep "physicalid"|sort |uniq|wc -l

②逻辑CPU

cat /proc/cpuinfo |grep"processor"|wc -l

③ CPU核数

cat /proc/cpuinfo |grep"cores"|uniq

 

网卡信息:

lspci


多队列网卡识别

lspci -vvv












Ethernetcontroller的条目内容,如果有MSI-X && Enable+ &&TabSize > 1,则该网卡是多队列网卡,如图4.4所示。

Message SignaledInterrupts(MSI)是PCI规范的一个实现,可以突破CPU256条interrupt的限制,使每个设备具有多个中断线变成可能,多队列网卡驱动给每个queue申请了MSI。MSI-X是MSI数组,Enable+指使能,TabSize是数组大小。

GCC版本






Linux内核信息



0x03 Linux 内核升级

因为DPDK对内核版本有要求,所以需升级内核版本,按照如下版本进行:

1、导入public key

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

2、安装ELRepo到CentOS-6.5中

rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

3、安装 kernel-lt(lt=long-term)

yum --enablerepo=elrepo-kernel installkernel-lt -y

或者安装kernel-ml(ml=mainline)

yum --enablerepo=elrepo-kernel installkernel-ml -y

4、编辑grub.conf文件,修改Grub引导顺序

复制代码

vim /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grubafter making changes to this file

# NOTICE: You do not have a /boot partition. This means that

#         all kernel and initrd paths are relative to /, eg.

#         root (hd0,0)

#         kernel /boot/vmlinuz-version ro root=/dev/sda1

#         initrd /boot/initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

hiddenmenu

title CentOS (3.10.28-1.el6.elrepo.x86_64)

       root (hd0,0)

       kernel /boot/vmlinuz-3.10.28-1.el6.elrepo.x86_64 roroot=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MDcrashkernel=auto LANG=en_US.UTF-8

 rd_NO_LVM rd_NO_DM rhgb quiet

       initrd /boot/initramfs-3.10.28-1.el6.elrepo.x86_64.img

title CentOS (2.6.32-431.3.1.el6.x86_64)

       root (hd0,0)

       kernel /boot/vmlinuz-2.6.32-431.3.1.el6.x86_64 roroot=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MDcrashkernel=auto LANG=en_US.UTF-8 r

d_NO_LVM rd_NO_DM rhgb quiet

       initrd /boot/initramfs-2.6.32-431.3.1.el6.x86_64.img

title CentOS (2.6.32-431.el6.x86_64)

       root (hd0,0)

       kernel /boot/vmlinuz-2.6.32-431.el6.x86_64 roroot=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MDcrashkernel=auto LANG=zh_CN.UTF-8 rd_NO

_LVM rd_NO_DM rhgb quiet

       initrd /boot/initramfs-2.6.32-431.el6.x86_64.img

复制代码

确认刚安装好的内核在哪个位置,然后设置default值(从0开始),一般新安装的内核在第一个位置,所以设置default=0。

5、重启,查看内核版本号

[root@dev ~]# uname -r

3.10.28-1.el6.elrepo.x86_64

 

还有源码安装:

0x04 DPDK中一些慨念

Port: 网卡

Socket: 物理CPU

Core: 逻辑核

Queue:队列,网卡的接收和发送队列;

0x05 DPDK环境构建

解压:tar xzvf dpdk-16.04.tar.gz

进入对应目录:


通过sh tools/setup.sh 构建DPDK环境,具体网上有很多范例;

0x06 L3fwd编译

进入cd examples/l3fwd中: make

./build/l3fwd -c 3 -- -p 0x3--config="(0,0,0),(1,0,1)"


如果直接执行会存在一些问题,需要修改几个代码,可能是系统硬件不服务要求的情况下导致:

因nb_lcores 这个值默认一个宏的值,比较大,而目前接收队列为1;因目前网卡不支持多队列,如果硬件环境满足要求,可能不存在问题;

还存在一个参数问题:

int rte_eth_tx_queue_setup

(

uint8_t 

port_id,

uint16_t 

tx_queue_id,

uint16_t 

nb_tx_desc,

unsigned int 

socket_id,

const struct rte_eth_txconf * 

tx_conf 

)

Parameters

port_id

The port identifier of the Ethernet device.

tx_queue_id

The index of the transmit queue to set up. The value must be in the range[0, nb_tx_queue - 1]previously supplied torte_eth_dev_configure().

所以需要注意;

0x07 L3fwd在实际环境中运行

./build/l3fwd -c 3 -- -p 0x3--config="(0,0,0),(1,0,1)"

程序能成功跑起来,但是具体lpm,hash表的配置,需进一步研究;

0 0
原创粉丝点击