Skip to content

Support DPDK 23.11 (bindgen 0.73, 21.11+ ethdev API, whole-archive static linking) - #5

Open
safiyat wants to merge 8 commits into
codilime:masterfrom
safiyat:dpdk-23.11
Open

safiyat wants to merge 8 commits into
codilime:masterfrom
safiyat:dpdk-23.11

Conversation

@safiyat

@safiyat safiyat commented Oct 26, 2026

Copy link
Copy Markdown

This makes dpdk-sys and dpdk build and run against DPDK 23.11 LTS with a current toolchain (clang 18, a recent stable Rust). Each commit fixes one build or runtime failure seen on the way, so it can be reviewed commit by commit.

Build fixes (dpdk-sys)

  • Bump bindgen 0.47 → 0.73 (and clang to 2.x, so both share clang-sys 1.x).
    • bindgen 0.47 panics on the _Complex _Float16 builtin that clang 15+ exposes.
    • rustfmt_bindings is gone upstream; rustfmt is now the default.
  • Skip rte_crc_generic.h in the all-in-one header. 23.11 ships it next to rte_crc_x86.h, and including both redefines the CRC functions.
  • Find rte_get_main_lcore in the bindgen output (dpdk.rs). Since DPDK 21.x it is an exported function rather than static inline, so it never appears among the generated wrappers. main_lcore_name is declared for check-cfg.
  • Build the static-inline wrappers with -mrtm on x86_64.
    • The wrappers include the TSX helpers (rte_xbegin, rte_try_tm, ...).
    • With -march=native on a CPU without RTM, GCC refuses to inline _xbegin.
    • DPDK gates these paths on rte_rtm_supported() at runtime, so emitting RTM code is safe.
  • Make Rust-incompatible packed/aligned types opaque.
    • bindgen emits packed + align for __tile1024i_str and rte_avp_desc.
    • rte_arp_ipv4 and rte_arp_hdr are packed structs that contain the aligned rte_ether_addr.
    • rustc rejects both, so these types are now opaque.
    • Debug is skipped for rte_flow_item_gtp_psc, whose packed field has none.
  • Define _GNU_SOURCE for bindgen, clang and the wrapper build. This sets RTE_HAS_CPUSET, so rte_lcore_cpuset and rte_thread_set_affinity (used by LCoreId::launch) are declared.

ethdev API port (dpdk)

  • Use the RTE_ETH_* names for link status and MQ modes.
  • Read link_status through the new anonymous union in rte_eth_link.
  • Replace rxmode.max_rx_pkt_len with rxmode.mtu.
  • Build rss_hf from RTE_ETH_FLOW_* bits. The RTE_ETH_RSS_* constants are RTE_BIT64() macros, which bindgen can't expand.

Linking

  • Link the DPDK static libraries with +whole-archive, as DPDK's own static pkg-config does.
    • Bus drivers and PMDs register themselves through constructors, so a plain static link drops them.
    • Without this, EAL can't even parse a PCI address (-a 0000:xx:yy.z fails with "failed to parse device"), and no ports are found.
    • The hard-coded ibverbs/mlx5 special case is removed, because the system-library list below covers it.
  • Link only DPDK's direct system dependencies, dynamically.
    • They come from Libs.private and Requires.private in libdpdk.pc and libdpdk-libs.pc, each resolved with pkg-config --libs.
    • pkg-config --static --libs libdpdk is too broad: it also pulls in the static-only dependencies of DPDK's dependencies (for example -lsystemd and dbus through libpcap, plus the RDMA providers), which a dynamic link doesn't need and which often aren't installed.

Compatibility

  • Requires DPDK 21.11 or newer. The ethdev renames (RTE_ETH_*, rxmode.mtu) don't exist in older releases. If supporting older DPDK matters, this could go behind a feature or version check instead.
  • Requires Rust 1.61 or newer, for the +whole-archive link modifier.

safiyat and others added 8 commits October 23, 2026 15:48
bindgen 0.47 panics on the _Complex _Float16 builtin that clang 15+
exposes, so bump it to 0.73 (and the clang crate to 2.x so both share
clang-sys 1.x). rustfmt_bindings was removed upstream; rustfmt is now the
default formatter.

DPDK 23.11 ships rte_crc_generic.h next to rte_crc_x86.h; including both
in the all-in-one header redefines the CRC functions, so skip it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since DPDK 21.x rte_get_main_lcore is an exported function rather than
static inline, so it is absent from the generated lib.rs. Also look in
dpdk.rs, and declare main_lcore_name for check-cfg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dpdk-sys wraps every static inline, including the TSX helpers
(rte_xbegin, rte_try_tm, ...). With -march=native on a CPU without RTM,
GCC refuses to inline _xbegin. DPDK gates these paths on
rte_rtm_supported() at runtime, so enabling RTM codegen is safe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bindgen emits packed+align reprs for __tile1024i_str and rte_avp_desc,
and packed structs containing the aligned rte_ether_addr for
rte_arp_ipv4/rte_arp_hdr; rustc rejects both. Make them opaque. Also
skip Debug for rte_flow_item_gtp_psc, whose packed field has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Define _GNU_SOURCE for bindgen, clang and the wrapper build, so
  RTE_HAS_CPUSET is set and rte_lcore_cpuset/rte_thread_set_affinity
  are declared.
- Use the RTE_ETH_* names (link status, MQ modes).
- Read link_status through the new anonymous union in rte_eth_link.
- Replace rxmode.max_rx_pkt_len with rxmode.mtu.
- Build rss_hf from RTE_ETH_FLOW_* bits, since RTE_ETH_RSS_* are
  RTE_BIT64() macros bindgen cannot expand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Md Safiyat Reza <reza.safiyat@gmail.com>
Signed-off-by: Md Safiyat Reza <reza.safiyat@gmail.com>
Port::socket_id() panicked when rte_eth_dev_socket_id() returned
SOCKET_ID_ANY (-1), as it does for a VF passed through to a VM. It now
returns Option<SocketId>, and UninitPort::init places RX pools and rings
on SOCKET_ID_ANY when the node is unknown. Requested RSS hash types are
masked with flow_type_rss_offloads, since VFs often support fewer and
rte_eth_dev_configure rejects the rest.

Signed-off-by: Md Safiyat Reza <reza.safiyat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant