Skip to content

Instantly share code, notes, and snippets.

@aagontuk
Last active June 22, 2025 10:07
Show Gist options
  • Select an option

  • Save aagontuk/7b076a32f1eea116b99ae353414e8763 to your computer and use it in GitHub Desktop.

Select an option

Save aagontuk/7b076a32f1eea116b99ae353414e8763 to your computer and use it in GitHub Desktop.
DPDK resources

Issues

MLX Specific

Using DPDK with Mellanox devices

  1. Install mellanox ofed driver [REQUIRED].
  2. Compile DPDK
  3. Done!

Refs:

See devices:

$ mst status -s

Find the DPDK port number attached to a specific PCIE:

  • Use: testpmd -l 8-15 -n 4 -b -- --rxq=2 --txq=2

Port number are probed based on physical PCIE address: https://stackoverflow.com/a/68457392

Handy tools

  • ethtool - query and change device configuration.
  • mst - Mellanox NIC too.
  • mlxconfig - Configure mellanox devices.

Generating packets with packetgen

sudo ./usr/local/bin/pktgen -n 1 -b 0000:07:00.0 -- -T -P -m 1.1 -f send_pktgen.pkt

send_ptkgen.pkt

stop 1
set 1 proto udp
set 1 sport 1212
set 1 dport 2323
set 1 src mac 9c:dc:71:5d:90:e1
set 1 dst mac 9c:dc:71:56:fd:d5
set 1 src ip 10.10.1.1/24
set 1 dst ip 10.10.1.2
set 1 size 64

Using port 1 to send packets.

  • Receiving packets
sudo ./usr/local/bin/pktgen -n 1 -b 0000:07:00.0 -- -T -P -m 1.1 -f -f recv_pktgen.pkt

recv_pktgen.pkt

stop 1
set 1 proto udp
set 1 dport 1212
set 1 sport 2323
set 1 src mac 9c:dc:71:56:fd:d5
set 1 dst mac 9c:dc:71:5d:90:e1
set 1 src ip 10.10.1.2
set 1 dst ip 10.10.1.1/24
set 1 size 64

Receive packets from port 1

Adjust the dpdk port, ip and macs.

issue: Can't receive packets more that 500 MBit/s. Improved by increasing packet size. With 1500 byte packets got 13GBit/s. Increased all the way to (max MTU supported by NIC)/2 which is 32Kbytes. Still same results.

@aagontuk
Copy link
Author

aagontuk commented Aug 26, 2022

Configuring Mellanox NICs with DPDK:

  • Install Mellanox OFED driver
  • Install DPDK
  • Find out the DPDK port number for the PCIE device using testpmd by adding the control port with -b option.

Refs: https://dpdk.readthedocs.io/en/v17.11/nics/mlx5.html

@aagontuk
Copy link
Author

How to find out the DPDK port number mapped to an interface (Needed for bifurcated drivers)

Run testpmd with -b option to specifying the control link PCIE address.

@aagontuk
Copy link
Author

aagontuk commented Mar 18, 2023

set 0 rate 50 - 50% of the link rate
set 0 count 50 - Send 50 packets
set 0 seq_cnt 2 - This will generate 2 different sequence of packets.
sequence 0 0 dst 02:00:00:00:00:00 src b8:00:00:00:00:00 dst 10.10.1.2 src 10.10.1.1/24 sport 1234 dport 5656 ipv4 udp vlan 0 size 64 - Configure sequence 0
sequence 1 0 dst 02:00:00:00:00:00 src b8:00:00:00:00:00 dst 10.10.1.2 src 10.10.1.1/24 sport 1235 dport 5656 ipv4 udp vlan 0 size 64 - Configure sequence 1 [Only source port is different in this case]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment