DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Scott Mitchell <scott.k.mitch1@gmail.com>
Cc: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com,
	mb@smartsharesystems.com
Subject: Re: [PATCH v10 0/8] net/af_packet fixes and Tx features
Date: Fri, 4 Dec 2026 11:28:13 -0800	[thread overview]
Message-ID: <20261204112813.295ff6c0@phoenix.local> (raw)
In-Reply-To: <20261204160128.17277-1-scott.k.mitch1@gmail.com>

On Fri,  4 Dec 2026 08:01:20 -0800
Scott Mitchell <scott.k.mitch1@gmail.com> wrote:

> Fixes for af_packet ring handling, then Tx features: non-blocking Tx
> and software checksum offload.
> 
> Patches 1-3 are fixes for stable, and 4 tests them. 5-8 are not for
> stable.
> 
> v10:
> * Frame size must hold a minimum Ethernet frame after the 66 byte Rx
>   offset (minimum 144), so the maximum Rx length can't wrap; documented
>   and tested with framesz=64. (Stephen)
> * Fixes tags of "fix maximum Rx packet length" corrected. (Stephen)
> * "clean up Tx and bulk free mbufs" commit message mentions its tests.
>   (Stephen)
> 
> v9:
> * tp_status helpers cast to (uint32_t __rte_atomic *). (Stephen)
> * The invalid ring parameter error prints blocksz, framesz and framecnt
>   instead of describing the constraints; af_packet.rst documents them,
>   including the 2GB blocksz limit. (Stephen)
> 
> v8:
> * Split as suggested: the memory ordering and frame address fixes are
>   separate stable patches; the test, ring parameter validation and Tx
>   cleanup are their own patches. Dropped unrelated changes from the
>   fixes (counter types, loop form).
> * tp_status uses rte_atomic_load/store_explicit with acquire/release
>   instead of fences, as libpcap and memif do. (Stephen)
> * New fix: the maximum Rx packet length and MTU used the Tx frame
>   offset, so packets up to 34 bytes over the real limit were silently
>   truncated.
> * Invalid ring parameters are rejected at probe, matching what
>   packet_set_ring() rejects, instead of logged as warnings; the hint
>   warnings are gone, so configurations the kernel accepts still work.
>   (Stephen)
> * The Tx kick runs on every burst, so a full ring drains on later
>   bursts once the kernel can send again. The ring full test now checks
>   this. (Stephen)
> * Removed poll() from Tx instead of adding the txpollnotrdy devarg. A
>   full ring returns a short count, so Tx no longer blocks. (Stephen)
> * Checksums are computed in the ring frame after the copy, so the
>   checksum code does not modify the mbuf. Dropped
>   rte_net_ip_udptcp_cksum_mbuf() and the tap conversion, and with them
>   the dependency on "test/cksum: fix EtherType of IPv6 TCP packet".
>   (Stephen, Morten) IPv6 extension headers are supported; packets with
>   tunnel offload flags are dropped.
> * Tests use ring geometry derived from the page size.
> 
> Scott Mitchell (8):
>   net/af_packet: fix frame status memory ordering
>   net/af_packet: fix frame address with unused block tail
>   net/af_packet: fix maximum Rx packet length
>   test/af_packet: add frame layout tests
>   net/af_packet: reject invalid ring parameters at probe
>   net/af_packet: clean up Tx and bulk free mbufs
>   net/af_packet: do not block in Tx when the ring is full
>   net/af_packet: add Tx checksum offload
> 
>  app/test/test_pmd_af_packet.c             | 1029 +++++++++++++++++++++
>  doc/guides/nics/af_packet.rst             |    8 +-
>  doc/guides/nics/features/af_packet.ini    |    2 +
>  doc/guides/rel_notes/release_27_03.rst    |    4 +
>  drivers/net/af_packet/rte_eth_af_packet.c |  245 +++--
>  5 files changed, 1212 insertions(+), 76 deletions(-)
> 

There are still some warnings from AI review.
I don't agree with all AI's proposed changes will leave it up to your
judgment about best way to address these.

Review: [PATCH v10 0/8] net/af_packet fixes and tx features
Applied to main (ddb3b0c, 27.03-rc0). All 8 commits build with
-Dwerror=true. Tests not run.

Series
------
Everything raised on v7 is addressed:

  - tp_status uses load-acquire/store-release, same as libpcap
  - the two fixes are separate small patches, tests split out
  - ring parameters are rejected at probe, warnings gone
  - sendto() kick is unconditional again; test brings the link back
    and checks the ring drains
  - txpollnotrdy devarg dropped, tx just returns short on a full ring
  - checksums computed in the ring frame; no lib/net API, no tap
    change, mbuf not touched

No errors found. Two warnings: truncated Rx frames (3/8) and the
missing fix tags on 7/8.


Patch 3/8
---------
The offset is right. For SOCK_RAW with a 14 byte MAC header
tpacket_rcv() gives

	netoff = TPACKET_ALIGN(TPACKET2_HDRLEN + 16) = 80
	macoff = netoff - 14 = 66

and for longer MAC headers macoff only gets smaller, so 66 is the
worst case.

Warning: truncated frames are still delivered as good packets

  The patch fixes what the driver advertises, but the kernel will
  still hand over anything larger than the slot with
  tp_snaplen < tp_len: a GRO aggregate on the underlying interface,
  or a peer with a larger MTU. Rx takes pkt_len from tp_snaplen and
  passes the cut-off packet up. Since this patch is about exactly
  that truncation, drop them here (or in a follow-up with the same
  Fixes/stable tags):

		if (unlikely(ppd->tp_snaplen < ppd->tp_len)) {
			pkt_q->rx_dropped_pkts++;
			goto release_frame;
		}

  placed before the mbuf allocation.

Info: stable impact. max_mtu drops by 34 for a given framesz, so a
  port that was created with framesz 1552..1583 and relied on MTU
  1500 now gets a smaller default MTU from rte_eth_dev_configure(),
  and an explicit mtu=1500 is refused. That is the correct outcome
  (those ports were truncating full-size frames) but it is a visible
  change in an LTS update and deserves a line in the commit message.


Patch 5/8
---------
The dropped "!blockcount" test is unreachable now: zero blocksz,
framesz and framecnt are rejected when the devargs are parsed, and
framecnt is a non-zero multiple of frames_per_block. No divide by
zero for the same reason.

Info: one geometry case still gets through. The mmap length and the
  tx map offset are computed in 32 bits:

	mmap(NULL, 2 * req->tp_block_size * req->tp_block_nr, ...
	tx_queue->map = rx_queue->map +
			req->tp_block_size * req->tp_block_nr;

  The kernel limits the frame count, not the byte size, so
  blocksz * blockcount >= 2 GB is accepted by setsockopt() and then
  wraps here. Pre-existing, but this is the patch that says probe
  rejects bad ring parameters:

	(uint64_t)blocksize * (framecount / frames_per_block) >
		UINT_MAX / 2

  added to the same condition closes it.


Patch 7/8
---------
Warning: this is a bug fix but is not tagged as one

  A tx_burst that sleeps in poll() with no timeout is a bug, and the
  commit message describes it as one. It needs a Fixes: tag for the
  commit that added the poll() and Cc: stable@dpdk.org.

  As ordered it will not backport cleanly, because it sits on top of
  the 6/8 cleanup. Move it ahead of 6/8, next to the other fixes, so
  the stable patch is just the removal of the poll() block.


Patch 8/8
---------
Checked af_packet_tx_cksum() against the lib/net helpers: every read
is bounded by pkt_len before it happens (l4_off + header, then
l4_end from the IP length), IPv4 IHL must equal l3_len, UDP zero
checksum is handled by rte_ipv4_udptcp_cksum(), and the IPv6
extension header case builds the pseudo-header from the real L4
length and protocol. rte_vlan_insert() bumps l2_len, so the offsets
are still right after a tag is inserted. Nothing to change.

Info: the driver acts on mbuf checksum flags whether or not the
  application enabled the offloads in txmode. That is harmless
  (flags without the offload are an application bug) and saves the
  per-queue flag v7 had. Fine as is.

      parent reply	other threads:[~2026-12-04 19:28 UTC|newest]

Thread overview: 109+ 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           ` [PATCH v6 0/4] af_packet correctness, performance, cksum Stephen Hemminger
2026-02-06  4:45             ` Scott Mitchell
2026-02-06 14:36             ` Morten Brørup
2026-02-06 16:11               ` Stephen Hemminger
2026-12-01 22:24           ` [PATCH v7 0/4] net/af_packet: " Scott Mitchell
2026-12-01 22:24             ` [PATCH v7 1/4] net/af_packet: fix thread safety and frame calculations Scott Mitchell
2026-12-01 22:24             ` [PATCH v7 2/4] net/af_packet: RX/TX bulk free, unlikely hint Scott Mitchell
2026-12-01 22:24             ` [PATCH v7 3/4] net/af_packet: tx poll control Scott Mitchell
2026-12-01 22:24             ` [PATCH v7 4/4] net/af_packet: add software checksum offload support Scott Mitchell
2026-12-01 23:22               ` Scott Mitchell
2026-12-01 22:32             ` [PATCH v7 0/4] net/af_packet: correctness, performance, cksum Scott Mitchell
2026-12-02  7:09             ` Stephen Hemminger
2026-12-02  8:01             ` Morten Brørup
2026-12-02 16:11               ` Scott Mitchell
2026-12-02 17:17             ` [PATCH v8 0/8] net/af_packet fixes and Tx features Scott Mitchell
2026-12-02 17:17               ` [PATCH v8 1/8] net/af_packet: fix frame status memory ordering Scott Mitchell
2026-12-02 17:26                 ` Stephen Hemminger
2026-12-02 19:08                   ` Scott Mitchell
2026-12-02 17:17               ` [PATCH v8 2/8] net/af_packet: fix frame address with unused block tail Scott Mitchell
2026-12-02 17:17               ` [PATCH v8 3/8] net/af_packet: fix maximum Rx packet length Scott Mitchell
2026-12-02 17:18               ` [PATCH v8 4/8] test/af_packet: add frame layout tests Scott Mitchell
2026-12-02 17:18               ` [PATCH v8 5/8] net/af_packet: reject invalid ring parameters at probe Scott Mitchell
2026-12-02 17:29                 ` Stephen Hemminger
2026-12-02 19:11                   ` Scott Mitchell
2026-12-02 17:18               ` [PATCH v8 6/8] net/af_packet: clean up Tx and bulk free mbufs Scott Mitchell
2026-12-02 17:18               ` [PATCH v8 7/8] net/af_packet: do not block in Tx when the ring is full Scott Mitchell
2026-12-02 17:18               ` [PATCH v8 8/8] net/af_packet: add Tx checksum offload Scott Mitchell
2026-12-03 16:42               ` [PATCH v9 0/8] net/af_packet fixes and Tx features Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 1/8] net/af_packet: fix frame status memory ordering Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 2/8] net/af_packet: fix frame address with unused block tail Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 3/8] net/af_packet: fix maximum Rx packet length Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 4/8] test/af_packet: add frame layout tests Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 5/8] net/af_packet: reject invalid ring parameters at probe Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 6/8] net/af_packet: clean up Tx and bulk free mbufs Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 7/8] net/af_packet: do not block in Tx when the ring is full Scott Mitchell
2026-12-03 16:42                 ` [PATCH v9 8/8] net/af_packet: add Tx checksum offload Scott Mitchell
2026-12-03 18:31                 ` [PATCH v9 0/8] net/af_packet fixes and Tx features Stephen Hemminger
2026-12-03 19:58                   ` Scott Mitchell
2026-12-04 16:01                 ` [PATCH v10 " Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 1/8] net/af_packet: fix frame status memory ordering Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 2/8] net/af_packet: fix frame address with unused block tail Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 3/8] net/af_packet: fix maximum Rx packet length Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 4/8] test/af_packet: add frame layout tests Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 5/8] net/af_packet: reject invalid ring parameters at probe Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 6/8] net/af_packet: clean up Tx and bulk free mbufs Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 7/8] net/af_packet: do not block in Tx when the ring is full Scott Mitchell
2026-12-04 16:01                   ` [PATCH v10 8/8] net/af_packet: add Tx checksum offload Scott Mitchell
2026-12-04 19:28                   ` Stephen Hemminger [this message]

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=20261204112813.295ff6c0@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=scott.k.mitch1@gmail.com \
    --cc=thomas@monjalon.net \
    /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