DPDK testpmd运行失败:未探测到以太网设备(Ubuntu 22.04)
DPDK testpmd未探测到绑定网卡的排查与解决
问题场景
Ubuntu 22.04系统,使用dpdk-stable-21.11.5版本,已完成编译安装。两块网卡绑定vfio-pci/uio_pci_generic/igb_uio驱动后,运行dpdk-testpmd提示未探测到以太网设备。
设备绑定信息
Network devices using DPDK-compatible driver ============================================ 0000:03:00.0 'Device 125c' drv=vfio-pci unused=igc,igb_uio,uio_pci_generic 0000:04:00.0 'Device 125c' drv=vfio-pci unused=igc,igb_uio,uio_pci_generic Network devices using kernel driver =================================== 0000:02:00.0 'Device 125c' if=enp2s0 drv=igc unused=igb_uio,vfio-pci,uio_pci_generic *Active* 0000:05:00.0 'Device 125c' if=enp5s0 drv=igc unused=igb_uio,vfio-pci,uio_pci_generic No 'Baseband' devices detected ============================== No 'Crypto' devices detected ============================ No 'DMA' devices detected ========================= No 'Eventdev' devices detected ============================== No 'Mempool' devices detected ============================= No 'Compress' devices detected ============================== No 'Misc (rawdev)' devices detected =================================== No 'Regex' devices detected ===========================
testpmd运行日志
EAL: Detected CPU lcores: 4 EAL: Detected NUMA nodes: 1 EAL: Detected static linkage of DPDK EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'VA' EAL: VFIO support initialized TELEMETRY: No legacy callbacks, legacy socket not created testpmd: No probed ethernet devices testpmd: create a new mbuf pool <mb_pool_0>: n=171456, size=2176, socket=0 testpmd: preferred mempool ops selected: ring_mp_mc Done No commandline core given, start packet forwarding io packet forwarding - ports=0 - cores=0 - streams=0 - NUMA support enabled, MP allocation mode: native io packet forwarding packets/burst=32 nb forwarding cores=1 - nb forwarding ports=0 Press enter to exit Telling cores to stop... Waiting for lcores to finish... +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++ RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 0 TX-dropped: 0 TX-total: 0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Done. Bye...
排查与解决步骤
确认网卡驱动编译状态
设备ID125c对应Intel I225系列网卡,DPDK 21.11.5版本的igc驱动支持该型号。进入DPDK源码目录,执行:cat build/.config | grep RTE_DRIVER_IGC确保输出为
CONFIG_RTE_DRIVER_IGC=y。若为n,重新编译DPDK并添加参数:meson setup build -D RTE_DRIVER_IGC=y ninja -C build配置VFIO权限与IOMMU
使用vfio-pci驱动时,需确保系统配置正确:- 加载vfio-pci模块:
modprobe vfio-pci - 检查IOMMU状态:
dmesg | grep -i iommu,确认输出包含IOMMU enabled。未启用则在GRUB启动参数中添加intel_iommu=on(Intel CPU)或amd_iommu=on(AMD CPU),执行update-grub后重启。 - 修正NUMA节点匹配:执行
echo 0 > /sys/bus/pci/devices/0000:03:00.0/numa_node(替换为你的网卡PCI地址)。
- 加载vfio-pci模块:
强制指定PCI设备启动testpmd
启动testpmd时直接指定绑定的网卡PCI地址,避免自动探测失败:dpdk-testpmd -l 0-1 -n 4 --device 0000:03:00.0 --device 0000:04:00.0 --其中
-l指定使用的CPU核心范围,-n指定内存通道数,根据自身系统调整。验证环境变量与网卡状态
- 确认DPDK环境变量设置正确:
export RTE_SDK=/path/to/dpdk-stable-21.11.5 export RTE_TARGET=x86_64-native-linux-gcc - 检查网卡是否被占用:
lsof | grep enp3s0(替换为网卡原接口名),终止占用进程后重新绑定:dpdk-devbind.py -u 0000:03:00.0 dpdk-devbind.py -b vfio-pci 0000:03:00.0
- 确认DPDK环境变量设置正确:
内容的提问来源于stack exchange,提问作者Hikaricat
相关产品推荐
相关产品推荐

