DPDK中L2fwd随笔

DPDK中L2fwd随笔


L2fwd是网络的二层转发,通过MAC地址进行发包。如官网中所述,在DPDK中至少有两个端口进行双向的发包和收包,同时目的端口和发送端口是相邻的,因此DPDK必须满足是偶数个的端口。即,若有四个端口,端口1和2互相发包和收包,端口3和4互相发包和收包。

测试过程:

[l2fwd] mount | grep /mnt/huge

[l2fwd] mkdir -p /mnt/huge

[l2fwd] mount -t hugetlbfs nodev /mnt/huge

[l2fwd]echo 1024 >>/sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages

 

[l2fwd] export RTE_SDK=/root/dpdk-16.07

[l2fwd] export RTE_TARGET=x86_64-native-linuxapp-gcc

[l2fwd] make

 

[build] ./l2fwd -c 0xf -n 3 -- -p 0x3 -q 1

 

-c  0xf    运行的十六机制掩码核心数。在这里指分配4core

-n 3 每个处理器的内存通道数

--  表示之后的为次参数;

-p  0x3 设置dpdk起点的端口数,0x3是指后两位为1,即起点两个端口;

-q 确定每个core的队列的数量,表示每个逻辑核心有一个队列。

以下是官网中对-q的描述:

The application uses onelcore to poll one or several ports, depending on the -q option, which specifiesthe number of queues per lcore.

For example, if the userspecifies -q 4, the application is able to poll four ports with one lcore. Ifthere are 16 ports on the target (and if the portmask argument is -p ffff ),the application will need four lcores to poll all the ports.

L2fwd代码运行过程:

(1)      参数传递,将输入的命令./l2fwd-c 0xf -n 3 -- -p 0x3 -q 1传入函数中,该过程在main()中进行。

/* init EAL */

 

ret = rte_eal_init(argc, argv);

if (ret < 0)

    rte_exit(EXIT_FAILURE, "InvalidEAL arguments\n");

 

argc -= ret;

argv += ret;

 

/* parse application arguments(after the EAL ones) */

 

ret = l2fwd_parse_args(argc, argv);

if (ret < 0)

    rte_exit(EXIT_FAILURE, "InvalidL2FWD arguments\n");

(2)      内存池的初始化(Mbuf Pool Initialization)

被驱动或者应用程序用于存储数据包的数据,第一次使用 rte_pktmbuf_pool_init(),这个函数是由mbufAPI提供的,也可以由开发者复制或扩展,第二次使用 rte_mempool_create()

(3)

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值