如何解决如何使用一个 NIC 设置循环转发到 TX 数据包并在 DPDK testpmd 中自行接收它们?
我想实现这样的场景:
- 在 NIC 的 RXQ 0 中收到一个数据包
- NIC 获取它并将其放入 TXQ 0
- 通过某种方式(NIC 的努力?),数据包将被发送到 NIC 的 RXQ 0,然后返回到步骤 1。
我认为转发模式 tx_first
正是我所需要的。
网卡: PMD:MLX5 版本:5.0-1.0.0.0
DPDK 版本:20.11.1
完整的命令行
./testpmd.sh 0 11-12 1 1 testpmd0 3b:00.0
#testpmd.sh
#if [ $# -ne 6 ]
#then
# echo $0" <socket_id> <core_list> <core_num> <queue_num> <prefix>"
# exit 255
#fi
./build/app/dpdk-testpmd -l $2 -n 4 \
--socket-mem=2048,2048 \
-a $6,txq_inline=200,txq_mpw
--file-prefix=$5 \
-- \
-i \
--mbcache=512 \
--txonly-multi-flow \
--rxd=2048 --txd=2048 \
--rxq=$4 --txq=$4 \
--nb-cores=$3 \
--port-topology=loop \
--numa --socket-num=$1 --port-numa-config=0,$1 --ring-numa-config=0,3,$1
但是在我设置命令行参数 --port-topology=loop
并尝试了 start tx_first
流是:
testpmd> start tx_first
io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled,MP allocation mode: native
Logical Core 12 (socket 0) forwards packets on 1 streams:
RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
我得到了统计数据:
testpmd> show fwd stats all
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 6 RX-dropped: 0 RX-total: 6
TX-packets: 38 TX-dropped: 0 TX-total: 38
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 6 RX-dropped: 0 RX-total: 6
TX-packets: 38 TX-dropped: 0 TX-total: 38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#32 same packets like this
restore info: - no tunnel info - no outer header - no miss group
src=04:3F:72:CB:21:46 - dst=02:00:00:00:00:00 - type=0x0800 - length=64 - nb_segs=1 - sw ptype: L2_ETHER L3_IPV4 L4_UDP - l2_len=14 - l3_len=20 - l4_len=8 - Send queue=0x0
ol_flags: PKT_RX_L4_CKSUM_UNKNOWN PKT_RX_IP_CKSUM_UNKNOWN PKT_RX_OUTER_L4_CKSUM_UNKNOWN
# discrete but same packets received
testpmd> port 0/queue 0: received 1 packets
restore info: - no tunnel info - no outer header - no miss group
src=F4:74:88:8C:11:86 - dst=01:80:C2:00:00:00 - type=0x0069 - length=119 - nb_segs=1 - hw ptype: L2_ETHER - sw ptype: L2_ETHER - l2_len=14 - Receive queue=0x0
ol_flags: PKT_RX_L4_CKSUM_UNKNOWN PKT_RX_IP_CKSUM_UNKNOWN PKT_RX_OUTER_L4_CKSUM_UNKNOWN
port 0/queue 0: sent 1 packets
restore info: - no tunnel info - no outer header - no miss group
src=F4:74:88:8C:11:86 - dst=01:80:C2:00:00:00 - type=0x0069 - length=119 - nb_segs=1 - hw ptype: L2_ETHER - sw ptype: L2_ETHER - l2_len=14 - Send queue=0x0
ol_flags: PKT_RX_L4_CKSUM_UNKNOWN PKT_RX_IP_CKSUM_UNKNOWN PKT_RX_OUTER_L4_CKSUM_UNKNOWN
port 0/queue 0: received 1 packets
restore info: - no tunnel info - no outer header - no miss group
src=F4:74:88:8C:11:86 - dst=01:80:C2:00:00:00 - type=0x0069 - length=119 - nb_segs=1 - hw ptype: L2_ETHER - sw ptype: L2_ETHER - l2_len=14 - Receive queue=0x0
ol_flags: PKT_RX_L4_CKSUM_UNKNOWN PKT_RX_IP_CKSUM_UNKNOWN PKT_RX_OUTER_L4_CKSUM_UNKNOWN
网卡没有接收它发送的 Tx 数据包,为什么?
解决方法
为了将 DPDK 应用程序 dpdk-tespmd
设置为环回模式,它需要 2 DPDK ports
和 --port-topology=loop
。
但是如果只有 1 个物理 NIC 端口,则有几个选项可以将 DPDK 接口设置为环回模式
- TX 和 RX 交叉连接的物理收发器
- 在
fabric loopback mode
中配置嵌入式交换机的 NIC - 如果连接到外部开关,在开关上启用
MAC|PHY loopback
。
一旦配置为以上3种模式中的任何一种,运行以下命令
- 设置 eth-peer 0 [所需的 DST MAC 地址]
- 设置 fwd macswp
- 开始 tx_first
验证相同的无物理网卡启动 testpmd 作为 ./build/app/testpmd -l 2-3 --vdev=net_tap0,iface=testDpdk0 -- -i --rxq=1 --txq=1
。为 RX 数据包 set verbose 2
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。