Search code examples
network-programmingdpdknetwork-interface

Running example gives "Error: number of ports must be even"


I am using DPDK and have set some huge pages. I am following the instructions to run the RX/TX callback example:

https://doc.dpdk.org/guides-18.08/sample_app_ug/rxtx_callbacks.html

After running this:

sudo ./build/examples/dpdk-rxtx_callbacks -l 1 -n 4

I get:

EAL: Detected CPU lcores: 16
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 'PA'
EAL: VFIO support initialized
TELEMETRY: No legacy callbacks, legacy socket not created
EAL: Error - exiting with code: 1
 Cause: Error: number of ports must be even

My NIC:

lspci | egrep -i --color 'network|ethernet'
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (14) I219-LM (rev 11)

DPDK supports I219:

https://core.dpdk.org/supported/nics/intel/

I've Google'd it seems this problem occurs when a NIC isn't supported.

Is there a difference between I219 and I219-LM, hence the error?


Solution

  • Unless you're really using DPDK 18.08, be sure to use latest documentation, although it doesn't mention the reason you're running into this snag either. The way rxtx_callbacks is written, it requires an even number of ports. "Port" can be read as "adapter." According to your lspci output, you only have a single I219. (Also not mentioned: you can specify your list of ports using multiple -a <port pci bus number> EAL options and, if none are specified, it will default to using all available adapters.)

    What it is programmed to do is receive on every even port and send the received packet(s) back out the corresponding odd port, i.e. port ^ 1. You can see those lines in the lcore_main function. There's no need to have it do that and you can change it to mirror the packets back out on the same port it received them on or simply never send the packets out. You'd have to also ease the restrictions in the setup section of the main function.

    I should also mention that it's necessary, but not sufficient to simply have an adapter show up in lspci. It should also be bound to a DPDK-compatible driver. See dpdk-devbind, which can show you the status of each adapter and also has commands to let you unbind / bind the adapter to a compatible driver.