Data Plane Kit using Virtual NIC Device

From RidgeRun Developer Wiki






Alongside Poll Mode Drivers (PMDs) for both physical and virtual hardware, DPDK also offers pure-software PMDs. One of these is the libpcap-based PMD, which facilitates the reading and writing of packets through libpcap. This capability extends to both files stored on disk and physical NIC devices utilizing standard Linux kernel drivers.


Warning
This feature allows DPDK to be used with unsupported NICs. However, it's important to note that since the standard Linux driver is employed, the low-latency benefits of DPDK may be limited.


Installation

1. Install the required package.

sudo apt install libpcap-dev

2. Rebuild DPDK to include the support for libpcap.

cd <dpdk installation path>
mkdir build
meson build

# To include the examples
meson -Dexamples=all build

ninja -C build
sudo ninja install -C build

As part of the log from the meson build command, you should see pcap included as part of the dependencies and in the drivers enabled.

...

Run-time dependency libpcap found: YES 1.10.1

...

===============
Drivers Enabled
===============

...

net:
        af_packet, ark, atlantic, avp, axgbe, bnx2x, bnxt, bond, 
        cnxk, cpfl, cxgbe, dpaa, dpaa2, e1000, ena, enetc, 
        enetfec, enic, failsafe, fm10k, gve, hinic, hns3, i40e, 
        iavf, ice, idpf, igc, ionic, ixgbe, memif, netvsc, 
        nfp, ngbe, null, octeontx, octeon_ep, pcap, pfe, qede, 
        ring, sfc, softnic, tap, thunderx, txgbe, vdev_netvsc, vhost, 
        virtio, vmxnet3,

Usage

To use the pcap driver with a unsupported NIC, you have to use the vdev flag as part of the EAL arguments, following this format:

./<dpdk app> [other EAL options] --vdev 'net_pcap0,iface=<physical network interface>' --vdev 'net_pcap1,iface=<physical network interface>' ... --vdev 'net_pcapN,iface=<physical network interface>' -- [app options]

Where <physical network interface> is the available NIC name, connected to the Linux kernel. To check the name, you can use the script dpdk-devdind.py included with DPDK.

python3 <dpdk installation path>/usertools/dpdk-devbind.py -s

You should see a similar output, where in this case the physical network interface of interest is enp2s0:

Network devices using kernel driver
===================================
0000:00:14.3 'Cannon Lake PCH CNVi WiFi a370' if=wlo1 drv=iwlwifi unused= *Active*
0000:02:00.0 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller 8168' if=enp2s0 drv=r8169 unused=

...

Example

Take for example one of the ethtool sample application, included with DPDK:

# Set hugepages
sudo python3 ./usertools/dpdk-hugepages.py --pagesize 2M --setup 1G --node 0

# Running the tool
sudo build/examples/dpdk-ethtool --vdev 'net_pcap0,iface=enp2s0'

Result

This example is console-driven, in this case, these commands are tested: drvinfo, link. In this link is the full list of commands.

EAL: Detected CPU lcores: 12
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'
Number of NICs: 1
Init port 0..
EthApp> drvinfo
firmware version get error: (Operation not supported)
Port 0 driver: net_pcap (ver: DPDK 23.11.2)
firmware-version: 
bus-info: net_pcap0
EthApp> link
Port 0: Up

EthApp> quit
Closing port 0... Done