From: Stephen Hemminger <stephen@networkplumber.org>
To: scott.k.mitch1@gmail.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v6 0/4] af_packet correctness, performance, cksum
Date: Thu, 5 Feb 2026 17:49:01 -0800 [thread overview]
Message-ID: <20260205174901.462eddb1@phoenix.local> (raw)
In-Reply-To: <20260206011141.2377-1-scott.k.mitch1@gmail.com>
On Thu, 5 Feb 2026 17:11:37 -0800
scott.k.mitch1@gmail.com wrote:
> 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
> - Patch 3: TX poll control to reduce syscall overhead
> - Patch 4: Software checksum offload support with shared rte_net
> utility
>
> v6 changes:
> - rte_net_ip_udptcp_cksum_mbuf doxygen EXPERIMENTAL tag
>
> v5 changes:
> - rte_net_ip_udptcp_cksum_mbuf moved to rte_net.c (avoid forced inline)
> - rte_net_ip_udptcp_cksum_mbuf remove copy arg, handle more mbuf types
> - af_packet and tap calling code consistent for sw cksum
>
> v4 changes:
> - Remove prefetch (perf results didn't show benefit)
> - Fix variable sytle for consistency (declare at start of method)
> - Add release notes for af_packet and documentation for fixes
>
> v3 changes:
> - Patch 4: Fix compile error due to implict cast with c++ compiler
>
> 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 bulk free, unlikely hint
> net/af_packet: tx poll control
> net/af_packet: add software checksum offload support
>
> doc/guides/nics/af_packet.rst | 6 +-
> doc/guides/nics/features/afpacket.ini | 2 +
> doc/guides/rel_notes/release_26_03.rst | 9 +-
> drivers/net/af_packet/rte_eth_af_packet.c | 253 +++++++++++++++-------
> drivers/net/tap/rte_eth_tap.c | 70 +-----
> lib/net/rte_net.c | 69 ++++++
> lib/net/rte_net.h | 25 +++
> 7 files changed, 292 insertions(+), 142 deletions(-)
>
Why are the header structures marked packed, that is bogus, BSD and Linux don't do it.
Windows probably does but Windows code seems to love packed even when it is not necessary.
This is failing compile on FreeBsd
OS: FreeBSD14-64
Target: x86_64-native-bsdapp-gcc
FAILED: lib/librte_net.a.p/net_rte_net.c.o
gcc -Ilib/librte_net.a.p -Ilib -I../lib -Ilib/net -I../lib/net -Ilib/eal/common -I../lib/eal/common -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/freebsd/include -I../lib/eal/freebsd/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/argparse -I../lib/argparse -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wvla -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-packed-not-aligned -Wno-missing-field-initializers -D_GNU_SOURCE -D__BSD_VISIBLE -fPIC -march=native -mno-avx512f -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -mpclmul -maes -DRTE_LOG_DEFAULT_LOGTYPE=lib.net -MD -MQ lib/librte_net.a.p/net_rte_net.c.o -MF lib/librte_net.a.p/net_rte_net.c.o.d -o lib/librte_net.a.p/net_rte_net.c.o -c ../lib/net/rte_net.c
../lib/net/rte_net.c: In function 'rte_net_ip_udptcp_cksum_mbuf':
../lib/net/rte_net.c:672:50: error: taking address of packed member of 'struct rte_udp_hdr' may result in an unaligned pointer value [-Werror=address-of-packed-member]
672 | l4_cksum = (unaligned_uint16_t *)&rte_pktmbuf_mtod_offset(mbuf,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
673 | struct rte_udp_hdr *, l4_offset)->dgram_cksum;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/net/rte_net.c:675:50: error: taking address of packed member of 'struct rte_tcp_hdr' may result in an unaligned pointer value [-Werror=address-of-packed-member]
675 | l4_cksum = (unaligned_uint16_t *)&rte_pktmbuf_mtod_offset(mbuf,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
676 | struct rte_tcp_hdr *, l4_offset)->cksum;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
next prev parent reply other threads:[~2026-02-06 1:49 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 18:13 [PATCH v1 0/3] net/af_packet: correctness fixes and improvements scott.k.mitch1
2026-01-27 18:13 ` [PATCH v1 1/3] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-01-27 18:39 ` Stephen Hemminger
2026-01-28 1:35 ` Scott Mitchell
2026-01-27 18:13 ` [PATCH v1 2/3] net/af_packet: RX/TX rte_memcpy, bulk free, prefetch scott.k.mitch1
2026-01-27 18:54 ` Stephen Hemminger
2026-01-28 1:23 ` Scott Mitchell
2026-01-28 9:49 ` Morten Brørup
2026-01-28 15:37 ` Scott Mitchell
2026-01-28 16:57 ` Stephen Hemminger
2026-01-27 18:13 ` [PATCH v1 3/3] net/af_packet: software checksum and tx poll control scott.k.mitch1
2026-01-27 18:57 ` Stephen Hemminger
2026-01-28 7:05 ` Scott Mitchell
2026-01-28 17:36 ` Stephen Hemminger
2026-01-28 18:59 ` Scott Mitchell
2026-01-27 20:45 ` [REVIEW] " Stephen Hemminger
2026-01-28 9:36 ` [PATCH v2 0/4] af_packet correctness, performance, cksum scott.k.mitch1
2026-01-28 9:36 ` [PATCH v2 1/4] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-01-28 16:59 ` Stephen Hemminger
2026-01-28 18:00 ` Scott Mitchell
2026-01-28 18:28 ` Stephen Hemminger
2026-01-28 9:36 ` [PATCH v2 2/4] net/af_packet: RX/TX unlikely, bulk free, prefetch scott.k.mitch1
2026-01-28 9:36 ` [PATCH v2 3/4] net/af_packet: tx poll control scott.k.mitch1
2026-01-28 9:36 ` [PATCH v2 4/4] net/af_packet: software checksum scott.k.mitch1
2026-01-28 18:27 ` Stephen Hemminger
2026-01-28 19:08 ` Scott Mitchell
2026-01-28 19:10 ` [PATCH v3 0/4] af_packet correctness, performance, cksum scott.k.mitch1
2026-01-28 19:10 ` [PATCH v3 1/4] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-01-28 19:10 ` [PATCH v3 2/4] net/af_packet: RX/TX unlikely, bulk free, prefetch scott.k.mitch1
2026-01-29 1:07 ` Stephen Hemminger
2026-02-02 5:29 ` Scott Mitchell
2026-01-28 19:10 ` [PATCH v3 3/4] net/af_packet: tx poll control scott.k.mitch1
2026-01-28 19:10 ` [PATCH v3 4/4] net/af_packet: software checksum scott.k.mitch1
2026-01-28 21:57 ` [REVIEW] " Stephen Hemminger
2026-02-02 7:55 ` Scott Mitchell
2026-02-02 16:58 ` Stephen Hemminger
2026-02-02 8:14 ` [PATCH v4 0/4] af_packet correctness, performance, cksum scott.k.mitch1
2026-02-02 8:14 ` [PATCH v4 1/4] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-02-02 8:14 ` [PATCH v4 2/4] net/af_packet: RX/TX bulk free, unlikely hint scott.k.mitch1
2026-02-02 8:14 ` [PATCH v4 3/4] net/af_packet: tx poll control scott.k.mitch1
2026-02-02 8:14 ` [PATCH v4 4/4] net/af_packet: add software checksum offload support scott.k.mitch1
2026-02-02 17:00 ` Stephen Hemminger
2026-02-02 18:47 ` Stephen Hemminger
2026-02-03 6:41 ` Scott Mitchell
2026-02-02 18:53 ` [PATCH v4 0/4] af_packet correctness, performance, cksum Stephen Hemminger
2026-02-03 7:07 ` [PATCH v5 " scott.k.mitch1
2026-02-03 7:07 ` [PATCH v5 1/4] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-02-03 7:07 ` [PATCH v5 2/4] net/af_packet: RX/TX bulk free, unlikely hint scott.k.mitch1
2026-02-03 7:07 ` [PATCH v5 3/4] net/af_packet: tx poll control scott.k.mitch1
2026-02-03 7:07 ` [PATCH v5 4/4] net/af_packet: add software checksum offload support scott.k.mitch1
2026-02-03 8:20 ` Scott Mitchell
2026-02-03 14:12 ` Stephen Hemminger
2026-02-04 2:59 ` Scott Mitchell
2026-02-03 14:13 ` Stephen Hemminger
2026-02-04 1:39 ` Scott Mitchell
2026-02-05 21:27 ` Stephen Hemminger
2026-02-06 1:11 ` [PATCH v6 0/4] af_packet correctness, performance, cksum scott.k.mitch1
2026-02-06 1:11 ` [PATCH v6 1/4] net/af_packet: fix thread safety and frame calculations scott.k.mitch1
2026-02-06 1:11 ` [PATCH v6 2/4] net/af_packet: RX/TX bulk free, unlikely hint scott.k.mitch1
2026-02-06 1:11 ` [PATCH v6 3/4] net/af_packet: tx poll control scott.k.mitch1
2026-02-06 1:11 ` [PATCH v6 4/4] net/af_packet: add software checksum offload support scott.k.mitch1
2026-02-06 1:49 ` Stephen Hemminger [this message]
2026-02-06 4:45 ` [PATCH v6 0/4] af_packet correctness, performance, cksum Scott Mitchell
2026-02-06 14:36 ` Morten Brørup
2026-02-06 16:11 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260205174901.462eddb1@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=scott.k.mitch1@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox