[PATCH v2 0/4] af_packet correctness, performance, cksum

scott.k.mitch1
2026-01-28T09:36:15Z

From: Scott <scott.k.mitch1@gmail.com>

This series fixes critical thread safety bugs in the af_packet PMD
and adds performance optimizations.

Patch 1 fixes two major correctness issues:
- Thread safety: tp_status was accessed without memory barriers,
violating the kernel's PACKET_MMAP protocol. On aarch64 and other
weakly-ordered architectures, this causes packet corruption due to
missing memory ordering. The fix matches the kernel's memory model:
volatile unaligned reads/writes with explicit rte_smp_rmb/wmb
barriers and __may_alias__ protection.

- Frame calculations: Fixed incorrect frame overhead and address
calculations that caused memory corruption when frames don't evenly
divide blocks.

Patches 2-4 add performance improvements:
- Patch 2: Bulk mbuf freeing, unlikely annotations, and prefetching
- Patch 3: TX poll control to reduce syscall overhead
- Patch 4: Software checksum offload support with shared rte_net
utility

v2 changes:
- Patch 1: Rewrote to use volatile + barriers instead of C11 atomics
to match kernel's memory model. Added dependency on patch-160274
for __rte_may_alias attribute.
- Patch 4: Refactored to use shared rte_net_ip_udptcp_cksum_mbuf()
utility function, eliminating code duplication with tap driver.

Scott Mitchell (4):
net/af_packet: fix thread safety and frame calculations
net/af_packet: RX/TX unlikely, bulk free, prefetch
net/af_packet: tx poll control
net/af_packet: software checksum

doc/guides/nics/af_packet.rst | 6 +-
drivers/net/af_packet/rte_eth_af_packet.c | 257 ++++++++++++++++------
drivers/net/tap/rte_eth_tap.c | 61 +----
lib/net/rte_net.h | 90 ++++++++
4 files changed, 283 insertions(+), 131 deletions(-)

--
2.39.5 (Apple Git-154)