linux - 如何让dpdk识别Linux虚拟化的网卡?

标签 linux networking virtualization nic dpdk

我的机器上有两个物理网卡。 基于this post ,似乎 dpdk 应该能够与虚拟 NIC 一起工作。

因此我在 Linux 中使用以下命令创建了 3 个虚拟接口(interface),其中 eno1d1 是我的物理 NIC 的名称。

sudo ifconfig eno1d1:0 10.10.1.107
sudo ifconfig eno1d1:1 10.10.1.207
sudo ifconfig eno1d1:2 10.10.2.107

但是,当我运行我的 dpdk 应用程序时,函数 rte_eth_dev_count 仍然只返回 2。

我需要做什么才能让 Dpdk 识别虚拟 NIC?

这里有一些关于我的 DPDK 版本的信息,这些信息记录在我的应用程序的开头。

Using DPDK version DPDK 16.11.0
DPDK: EAL: Detected 16 lcore(s)
DPDK: EAL: Probing VFIO support...
DPDK: EAL: PCI device 0000:09:00.0 on NUMA socket 0
DPDK: EAL:   probe driver: 15b3:1007 net_mlx4
DPDK: PMD: net_mlx4: PCI information matches, using device "mlx4_0" (VF: false)
DPDK: PMD: net_mlx4: 2 port(s) detected
DPDK: PMD: net_mlx4: port 1 MAC address is ec:b1:d7:85:3a:12
DPDK: PMD: net_mlx4: port 2 MAC address is ec:b1:d7:85:3a:13
DPDK: PMD: net_mlx4: 0xae6000: TX queues number update: 0 -> 1
DPDK: PMD: net_mlx4: 0xae6000: RX queues number update: 0 -> 1

这是我机器上的输出ifconfig

eno1      Link encap:Ethernet  HWaddr ec:b1:d7:85:1a:12  
          inet addr:128.110.153.148  Bcast:128.110.155.255  Mask:255.255.252.0
          inet6 addr: fe80::eeb1:d7ff:fe85:1a12/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15241610 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11238825 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4530541723 (4.5 GB)  TX bytes:8168066799 (8.1 GB)

eno1d1    Link encap:Ethernet  HWaddr ec:b1:d7:85:1a:13  
          inet addr:10.10.1.7  Bcast:10.10.1.255  Mask:255.255.255.0
          inet6 addr: fe80::eeb1:d7ff:fe85:1a13/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3787661978 errors:0 dropped:66084 overruns:0 frame:0
          TX packets:4758273664 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1905977969665 (1.9 TB)  TX bytes:3897938668285 (3.8 TB)

eno1d1:0  Link encap:Ethernet  HWaddr ec:b1:d7:85:1a:13  
          inet addr:10.10.1.107  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eno1d1:1  Link encap:Ethernet  HWaddr ec:b1:d7:85:1a:13  
          inet addr:10.10.1.207  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eno1d1:2  Link encap:Ethernet  HWaddr ec:b1:d7:85:1a:13  
          inet addr:10.10.2.107  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:62313 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62313 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:3557508 (3.5 MB)  TX bytes:3557508 (3.5 MB)

最佳答案

eno1d1:0 Link encap:Ethernet HWaddr ec:b1:d7:85:1a:13

那些不是虚拟 NIC,它们是网络别名,即不同的 Linux 内核 netdev 指的是同一个 NIC。由于 DPDK 不使用 Linux 内核,我们不能使用这些别名来运行 DPDK 应用程序。

尽管如此,我们在不使用物理 NIC 的情况下运行 DPDK 应用程序的选项很少:

在虚拟机中运行 DPDK

  1. 运行具有所需数量的 NIC 的虚拟机。
  2. 在虚拟机中,将 NIC 绑定(bind)到 UIO。
  3. 在虚拟机内,运行 DPDK,它应该可以与虚拟机内的 NIC 一起工作。

更多信息,请查看DPDK Poll Mode Driver for Emulated Virtio NIC .

使用 NIC 虚拟功能:

  1. 在主机上配置 SR-IOV 支持。
  2. 在主机 NIC 上配置一些虚拟功能 passing num_vfs to the MLX4 kernel module driver .
  3. 在主机上,将几个 NIV 虚拟功能绑定(bind)到 vfio-pci
  4. 在主机上运行 DPDK,它应该可以与 NIC 虚拟功能配合使用。

更多信息,请查看DPDK MLX4 Poll Mode DriverHowTo Configure SR-IOV for ConnectX-3

对于 SR-IOV 的一般描述,您可能会发现有用的 DPDK Intel Virtual Function Driver .请注意,Mellanox 内核模块的配置略有不同,您应该改用上面链接中描述的 num_vfs

使用DPDK虚拟设备

  1. 使用 libpcap 支持编译 DPDK。
  2. 配置主机以像往常一样运行 DPDK 应用程序(即启用大页面等)。
  3. 不要将任何 NIC 绑定(bind)到 UIO。
  4. 创建几个 TUN/TAP 接口(interface),将它们与物理 NIC 桥接。
  5. 像往常一样运行 DPDK 应用程序,但传递几个 --vdev 参数来创建几个虚拟设备,例如:

    testpmd -l 0-3 -n 4\ --vdev 'net_pcap0,iface=tun0' --vdev 'net_pcap1,iface=tun1' ...

更多信息,请查看DPDK libpcap Poll Mode Driver .

希望其中一个选项能满足您的需求。

关于linux - 如何让dpdk识别Linux虚拟化的网卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49963311/

相关文章:

linux - KVM 和 Libvirt : Bad CPU/Network performance of guest

java - HH 日期时间格式问题

linux - ./start-hbase.sh 不是独立启动的

powershell - 使用 PowerCLI 脚本从 ISO 镜像启动

windows - 除了从一个定义的 IP 之外,是否热阻止对 IIS 上 ASP.NET 站点中定义的 URL 的页面的访问?

python - 如何从 python 包中启动子模块?

c - 具有多个参数的 kvm super 调用

c - clutter1.0如何设置舞台或窗口的位置?

linux - 计算 linux 中的单词数

macos - 在系统级别的 Mac OS X Lion 上修改传出的 HTTP header