DPDK轮询是怎么做的?

DPDK how polling is done?

我对 DPDK 的理解是 NIC 的环形缓冲区被映射到用户空间地址,那里的数据在轮询的基础上得到处理。 (如有错误请指正)

那么,周期性轮询是如何进行的呢?后台是否有进程运行通过PMD(polling mode driver)提供的API周期性的进行轮询?

轮询在循环中直接完成,即:

main() {
    // Init ports
    ...
    // Main loop
    while(!quit_flag) {
        // Receive a burst of packets (poll)
        nb_rx = rte_eth_rx_burst(...);

        // Process packets
        ...

        // Send a burst of packets
        rte_eth_tx_burst(..., nb_rx);
    }
}

当然,它可以在单独的线程上完成(在 DPDK 中我们称它们为 lcores),但想法保持不变:应用程序模型由开发人员决定。

DPDK repo

中有很多例子

DPDK 也有一些框架来促进事件驱动或管道应用程序架构的实现。
有关详细信息,请参阅 DPDK Programmers Guide