首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >DPDK pdump未能热插拔添加设备

DPDK pdump未能热插拔添加设备
EN

Stack Overflow用户
提问于 2020-07-08 12:39:04
回答 1查看 2.3K关注 0票数 0

我正在尝试使用dpdk在dpdk控制下从NIC捕获tx数据包。

设置

  • DPDK 18.11.4
  • config/common_base中,CONFIG_RTE_LIBRTE_PMD_PCAP=yCONFIG_RTE_LIBRTE_PDUMP=y已经设置好了
  • 重建后,CONFIG_RTE_LIBRTE_PMD_PCAP=yCONFIG_RTE_LIBRTE_PDUMP=y也在x86_64-native-linuxapp-gcc/.config中设置。
  • 在主进程的init和rte_pdump_uninit()中调用rte_pdump_uninit()和破坏函数
  • DPDK接口
代码语言:javascript
运行
复制
Network devices using DPDK-compatible driver
============================================
0000:03:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' drv=igb_uio unused=ixgbe,uio_pci_generic

Network devices using kernel driver
===================================
0000:03:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' if=ens1f1 drv=ixgbe unused=igb_uio,uio_pci_generic
0000:05:00.0 'I210 Gigabit Network Connection 1533' if=enp5s0 drv=igb unused=igb_uio,uio_pci_generic *Active*
0000:06:00.0 'I210 Gigabit Network Connection 1533' if=enp6s0 drv=igb unused=igb_uio,uio_pci_generic

输出

初生过程

代码语言:javascript
运行
复制
EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:03:00.1 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:05:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: PCI device 0000:06:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
INFO: eth dev count 1.
Port 0 MAC: 9c 69 b4 60 90 1c

WARNING: Too many lcores enabled. Only 1 used.

Core 0 forwarding packets. [Ctrl+C to quit]
EAL: failed to parse device "vdev:net_pcap_tx_0"
EAL: Failed to hotplug add device on primary

二次过程

sudo ./build/app/dpdk-pdump -- --pdump 'port=0,queue=*,tx-dev=./tx.pcap'运行

代码语言:javascript
运行
复制
EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket_16018_96447662088dc
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:03:00.1 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:05:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: PCI device 0000:06:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: Failed to hotplug add device
EAL: Error - exiting with code: 1
  Cause: vdev creation failed

期望值

我怎么才能得到正确的dpdk-pdump?

编辑更新2020/7/12

在修改skeleton(将port修改为0并添加rte_pdump_init/uninit())之后,它仍然无法工作。

PS:skeletonmy program是用共享库构建的。

骨架码

代码语言:javascript
运行
复制
static __attribute__((noreturn)) void
lcore_main(void)
{
    uint16_t port;

    /*
     * Check that the port is on the same NUMA node as the polling thread
     * for best performance.
     */
    RTE_ETH_FOREACH_DEV(port)
        if (rte_eth_dev_socket_id(port) > 0 &&
                rte_eth_dev_socket_id(port) !=
                        (int)rte_socket_id())
            printf("WARNING, port %u is on remote NUMA node to "
                    "polling thread.\n\tPerformance will "
                    "not be optimal.\n", port);

    printf("\nCore %u forwarding packets. [Ctrl+C to quit]\n",
            rte_lcore_id());

    /* Run until the application is quit or killed. */
    for (;;) {
        /*
         * Receive packets on a port and forward them on the paired
         * port. The mapping is 0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2, etc.
         */
        port = 0;

        /* Get burst of RX packets, from first port of pair. */
        struct rte_mbuf *bufs[BURST_SIZE];
        const uint16_t nb_rx = rte_eth_rx_burst(port, 0,
                bufs, BURST_SIZE);

        if (unlikely(nb_rx == 0))
            continue;

        /* Send burst of TX packets, to second port of pair. */
        const uint16_t nb_tx = rte_eth_tx_burst(port ^ 1, 0,
                bufs, nb_rx);

        /* Free any unsent packets. */
        if (unlikely(nb_tx < nb_rx)) {
            uint16_t buf;
            for (buf = nb_tx; buf < nb_rx; buf++)
                rte_pktmbuf_free(bufs[buf]);
        }
    }
}

static void
signal_handler(int signum)
{
    if (signum == SIGINT || signum == SIGTERM) {
        printf("\nSignal %d received, preparing to exit...\n",
                signum);
        /* uninitialize packet capture framework */
        rte_pdump_uninit();
        /* exit with the expected status */
        signal(signum, SIG_DFL);
        kill(getpid(), signum);
    }
}

/*
 * The main function, which does initialization and calls the per-lcore
 * functions.
 */
int
main(int argc, char *argv[])
{
    struct rte_mempool *mbuf_pool;
    unsigned nb_ports;
    uint16_t portid;

    signal(SIGINT, signal_handler);
    signal(SIGTERM, signal_handler);

    /* Initialize the Environment Abstraction Layer (EAL). */
    int ret = rte_eal_init(argc, argv);
    if (ret < 0)
        rte_exit(EXIT_FAILURE, "Error with EAL initialization\n");

    argc -= ret;
    argv += ret;
    rte_pdump_init(NULL);
    /* Check that there is an even number of ports to send/receive on. */
    nb_ports = rte_eth_dev_count_avail();
    // if (nb_ports < 2 || (nb_ports & 1))
    //  rte_exit(EXIT_FAILURE, "Error: number of ports must be even\n");

    /* Creates a new mempool in memory to hold the mbufs. */
    mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports,
        MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());

    if (mbuf_pool == NULL)
        rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");

    /* Initialize all ports. */
    RTE_ETH_FOREACH_DEV(portid)
        if (port_init(portid, mbuf_pool) != 0)
            rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu16 "\n",
                    portid);

    if (rte_lcore_count() > 1)
        printf("\nWARNING: Too many lcores enabled. Only 1 used.\n");

    /* Call lcore_main on the master core only. */
    lcore_main();

    return 0;
}

初生过程

代码语言:javascript
运行
复制
EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:03:00.1 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:05:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: PCI device 0000:06:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
Port 0 MAC: 9c 69 b4 60 90 1c

WARNING: Too many lcores enabled. Only 1 used.

Core 0 forwarding packets. [Ctrl+C to quit]
EAL: Failed to hotplug add device on secondary

第二过程

命令sudo ./build/app/dpdk-pdump -- --pdump 'port=0,queue=*,tx-dev=./tx.pcap'

代码语言:javascript
运行
复制
EAL: Detected 24 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket_27816_cdf9e536de2e0
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:03:00.1 on NUMA socket 0
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:05:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: PCI device 0000:06:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1533 net_e1000_igb
EAL: failed to parse device "vdev:net_pcap_tx_0"
EAL: failed to parse device "vdev:net_pcap_tx_0"
EAL: Failed to hotplug add device
EAL: Error - exiting with code: 1
  Cause: vdev creation failed

我也尝试过dpdk-pdump 9.4示例,错误消息是相似的。

初生过程

代码语言:javascript
运行
复制
testpmd>
Port 0: link state change event
EAL: Failed to hotplug add device on secondary

第二过程

代码语言:javascript
运行
复制
EAL: failed to parse device "vdev:net_pcap_rx_0"
EAL: failed to parse device "vdev:net_pcap_rx_0"
EAL: Failed to hotplug add device
EAL: Error - exiting with code: 1
  Cause: vdev creation failed:create_mp_ring_vdev:722
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-13 04:31:30

我可以让它正常工作,没有问题。以下是以下步骤:

  1. 下载18.11.4 http://static.dpdk.org/rel/dpdk-18.11.4.tar.gz
  2. 启用PCAP PMD构建DPDK
  3. 修改主干main:在rte_pdump_init(NULL)后面添加rte_eal_init
  4. 修改框架lcore_main:用for (port = 0; port < 2; port++)修改RTE_ETH_FOREACH_DEV(port)
  5. 牛头:LD_FLAGS="-lrte_pmd_pcap" make
  6. 运行主
  7. 运行pdump备用程序(如果在主目录中传递白名单,则在这里传递相同的内容)
代码语言:javascript
运行
复制
EAL: request: eal_dev_mp_request
EAL: msg: eal_dev_mp_request
EAL: request: bus_vdev_mp
EAL: msg: bus_vdev_mp
EAL: msg: bus_vdev_mp
EAL: reply: eal_dev_mp_request
EAL: msg: eal_dev_mp_request
Port 2 MAC: 02 70 63 61 70 00
EAL: request: mp_pdump
EAL: msg: mp_pdump
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62795017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档