DPDK入门实践3——ethtool-app和exception-path

ethtool

ethtool这个例子展示了一个命令行交互的例子,这个例子包含了两个部分,一个是跑在slavecore上的packet映射,另一个是跑在master core上的Ethtool shell前端程序。主程序通过命令ethtool跑起来之后, 通过函数ethapp_main中list_prompt_commands列出的命令行进入子函数

The application is console-driven using the cmdline DPDK interface:
EthApp>
From this interface the available commands and descriptions of what they do as follows: • drvinfo: Print driver info
• eeprom: Dump EEPROM to file
• module-eeprom: Dump plugin module EEPROM to file
• link: Print port link states
• macaddr: Gets/sets MAC address • mtu: Set NIC MTU
• open: Open port
• pause: Get/set port pause state
• portstats: Print port statistics
• regs: Dump port register(s) to file
• ringparam: Get/set ring parameters
• rxmode: Toggle port Rx mode
• stop: Stop port
• validate: Check that given MAC address is valid unicast address • vlan: Add/remove VLAN id
• quit: Exit program

注意在运行程序之前需要绑定dpdk网卡,使用./usertools/dpdk-setup.sh 中24或者25选项

[24] Bind Ethernet/Crypto device to IGB UIO module
[25] Bind Ethernet/Crypto device to VFIO module

用完之后,记得unbind网卡

exception-path

这个例子展示了用DPDK为数据包创建通过Linux kernel的exception path通路。这里使用虚拟的TAP网络接口来实现,该应用为每个NIC端口创建两个线程,一个线程从port读数据并不作修改的写到线程指定的TAP接口。第二个线程从一个TAP接口读数据并不作修改的写到NIC端口上。要进行吞吐量测量,必须设置内核桥以在桥之间适当地转发数据。目前,我还不知道该如何模拟这两个桥之间的数据转发?难道就是往该NIC网卡打数据流?
这里有两个有效的执行命令,帮助理解参数:

.build/exception_path [EAL options] -- -p PORTMASK -i IN_CORES -o OUT_CORES
./build/exception_path -l 0-3 -n 4 -- -p 3 -i 3 -o c
./build/exception_path -l 0-3 -n 4 -- -p 2 -i 1 -o 2

其中--前面的参数是rte_eal_init解析的,--后面的参数是通过application的parse_args(argc, argv);函数来解析的。
注意,这个例子里面要添加两块网卡,这样才能相互之间传递数据包,如下所示我添加了两块网卡到igb-uio模块:

按照如下命令运行程序,结果如图所示,暂时没有外部数据流打到dpdk绑定的网卡上。

此时,查看 ip a,可以看到该程序创建的四个网卡:

在这个例子里,有两个关键的函数 rte_eth_rx_burst 和 rte_eth_tx_burst 分别完成Retrieve a burst of input packets from a receive queue of an Ethernet device. 和 Send a burst of output packets on a transmit queue of an Ethernet device.

posted @   JaneySJ  阅读(651)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
历史上的今天:
2017-01-13 neutron openvswitch agent实现安全组的方法
点击右上角即可分享
微信分享提示