【问题标题】:How can I get dpdk to recognize a NIC virtualized by Linux?如何让 dpdk 识别 Linux 虚拟化的 NIC?
【发布时间】:2018-04-22 06:48:02
【问题描述】:

我的机器上有两个物理网卡。 基于this post,dpdk 似乎应该能够使用虚拟网卡。

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

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 识别虚拟网卡?

这是关于我的 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)

【问题讨论】:

标签: linux networking virtualization nic dpdk


【解决方案1】:

eno1d1:0 链路封装:以太网 HWaddr ec:b1:d7:85:1a:13

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

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

在虚拟机中运行 DPDK

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

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

使用网卡虚拟功能:

  1. 在主机上配置 SR-IOV 支持。
  2. 在主机网卡passing num_vfs to the MLX4 kernel module driver上配置几个虚拟功能。
  3. 在主机上,将几个 NIV 虚拟功能绑定到 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 绑定到 UIO。
  4. 创建几个 TUN/TAP 接口,用物理网卡桥接它们。
  5. 像往常一样运行 DPDK 应用程序,但传递少量 --vdev 参数以创建少量虚拟设备,例如:

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

欲了解更多信息,请查看DPDK libpcap Poll Mode Driver

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

【讨论】:

    【解决方案2】:

    您不是在谈论相同类型的虚拟 NIC。 That post 指的是虚拟机的网卡(例如,virtio 或模拟的 e1000),而您试图让 DPDK 在 Linux 虚拟网卡上侦听。

    在那篇文章中,Zhandos Zhylkaidar 只是说您可以在虚拟机中运行 DPDK,在这种情况下,DPDK 看到的 NIC 不一定是物理 NIC。

    【讨论】:

    • 这看起来像是评论而不是答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-24
    • 2023-01-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-16
    相关资源
    最近更新 更多