From: Stephen Hemminger <stephen@networkplumber.org>
To: liujie5@linkdatatechnology.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v9 19/23] net/sxe2: add mbuf validation in Tx debug mode
Date: Fri, 26 Jun 2026 11:21:14 -0700 [thread overview]
Message-ID: <20260626112114.1eddd05e@phoenix.local> (raw)
In-Reply-To: <20260626064751.361466-1-liujie5@linkdatatechnology.com>
On Fri, 26 Jun 2026 14:47:51 +0800
liujie5@linkdatatechnology.com wrote:
> From: Jie Liu <liujie5@linkdatatechnology.com>
>
> Introduce the `sxe2_txrx_check_mbuf` helper function to validate outgoing
> mbufs when `RTE_ETHDEV_DEBUG_TX` is enabled. This helps developers catch
> malformed mbufs (e.g., invalid segment lengths, bad offload flags, or
> unaligned buffers) before passing them to the hardware rings, avoiding
> potential hardware hangs or silent packet drops.
>
> The validation is fully wrapped inside `RTE_ETHDEV_DEBUG_TX` conditional
> compilation blocks to ensure zero performance overhead in standard
> production builds.
>
> Signed-off-by: Jie Liu <liujie5@linkdatatechnology.com>
> ---
I don't think I was clear enough before, the verbose description is:
Current state (v9):
The new sxe2_txrx_check_mbuf() helper added in 19/23 is called only
from sxe2_tx_pkts_prepare(), which is the driver's tx_prepare
callback. It is not called from any tx_burst path (sxe2_tx_pkts, the
vec paths, the poll path).
The commit message claims the validation is "fully wrapped inside
RTE_ETHDEV_DEBUG_TX conditional compilation blocks to ensure zero
performance overhead in standard production builds." This is not what
the code does. There is no #ifdef RTE_ETHDEV_DEBUG_TX anywhere in the
new file or around the new call site. In fact the patch *removes* an
existing #ifdef RTE_ETHDEV_DEBUG_TX that previously gated
rte_validate_tx_offload() in the same loop, making that always-on too.
The new function is marked __rte_unused both in the header
declaration and in the .c definition, even though it has exactly one
caller. That attribute was likely a leftover from an earlier draft
where the function was only conditionally referenced.
The validation itself (595 lines) re-derives outer/inner L2/L3/L4
lengths from the packet bytes and compares them against what the mbuf
header declares - i.e., it's verifying that the application
correctly set mbuf->l2_len, l3_len, outer_l2_len, etc. before
submitting. Much of this overlaps what rte_validate_tx_offload() and
rte_net_intel_cksum_prepare() already check, both of which are called
in the same tx_prepare loop.
Desired state:
tx_burst should not contain validation checks for application errors.
The fast path runs once per packet at line rate, and any branch that
exists to catch a caller bug is paid on every well-behaved packet
forever. For driver assumptions that an application must satisfy,
the three sensible options are:
1. RTE_ASSERT() - compiles out in release builds, surfaces the
assumption to static analyzers, and fires for users running
debug builds.
2. unlikely() with drop-and-counter - if the check is cheap and
the assumption can be violated in production. The bad packet
is dropped, a queue stat is incremented, but the burst loop
continues.
3. Document the assumption in the API contract and don't check it
at runtime.
tx_prepare is where validation belongs, and an unconditional check
there is acceptable - tx_prepare is opt-in, and an application that
calls it has already agreed to pay for inspection. The 595-line
function as written is mostly fine in that context. What's wrong is:
(a) The commit message says one thing and the code does another.
The author should either add the #ifdef RTE_ETHDEV_DEBUG_TX
they claimed to add, or rewrite the commit message to describe
what the patch actually does.
(b) Driver-specific tx_prepare validation should cover sxe2-
specific hardware constraints (descriptor count limits, buffer
alignment, segment size limits) - not redo the generic offload-
flag and length-consistency checks that rte_validate_tx_offload()
and rte_net_intel_cksum_prepare() perform. As currently written,
every packet going through tx_prepare gets its offload flags
validated roughly twice.
(c) __rte_unused on the function should be dropped.
Redo this with one of the above and resubmit
next prev parent reply other threads:[~2026-06-26 18:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <220260625133139.207632-1-liujie5@linkdatatechnology.com>
2026-06-26 6:38 ` [PATCH v9 00/23] net/sxe2: added Linkdata sxe2 ethernet driver liujie5
2026-06-26 18:18 ` Stephen Hemminger
2026-06-26 6:38 ` [PATCH v9 01/23] net/sxe2: remove software statistics devargs liujie5
2026-06-26 6:39 ` [PATCH v9 02/23] net/sxe2: add Rx framework and packet types callback liujie5
2026-06-26 6:39 ` [PATCH v9 03/23] net/sxe2: support AVX512 vectorized path for Rx and Tx liujie5
2026-06-26 6:40 ` [PATCH v9 04/23] net/sxe2: add AVX2 vector data " liujie5
2026-06-26 6:40 ` [PATCH v9 05/23] net/sxe2: add link update callback liujie5
2026-06-26 6:41 ` [PATCH v9 06/23] net/sxe2: support L2 filtering and MAC config liujie5
2026-06-26 6:41 ` [PATCH v9 07/23] drivers: support RSS feature liujie5
2026-06-26 6:42 ` [PATCH v9 08/23] net/sxe2: support TM hierarchy and shaping liujie5
2026-06-26 6:42 ` [PATCH v9 09/23] net/sxe2: support IPsec inline protocol offload liujie5
2026-06-26 6:43 ` [PATCH v9 10/23] net/sxe2: support statistics and multi-process liujie5
2026-06-26 6:43 ` [PATCH v9 11/23] drivers: interrupt handling liujie5
2026-06-26 6:44 ` [PATCH v9 12/23] net/sxe2: add NEON vec Rx/Tx burst functions liujie5
2026-06-26 6:44 ` [PATCH v9 13/23] drivers: add support for VF representors liujie5
2026-06-26 6:45 ` [PATCH v9 14/23] net/sxe2: add support for custom UDP tunnel ports liujie5
2026-06-26 6:45 ` [PATCH v9 15/23] net/sxe2: support firmware version reading liujie5
2026-06-26 6:46 ` [PATCH v9 16/23] net/sxe2: implement get monitor address liujie5
2026-06-26 6:46 ` [PATCH v9 17/23] common/sxe2: add shared SFP module definitions liujie5
2026-06-26 6:47 ` [PATCH v9 18/23] net/sxe2: support SFP module info and EEPROM access liujie5
2026-06-26 6:47 ` [PATCH v9 19/23] net/sxe2: add mbuf validation in Tx debug mode liujie5
2026-06-26 18:21 ` Stephen Hemminger [this message]
2026-06-26 6:48 ` [PATCH v9 20/23] common/sxe2: add callback for memory event handling liujie5
2026-06-26 6:48 ` [PATCH v9 21/23] net/sxe2: add private devargs parsing liujie5
2026-06-26 6:49 ` [PATCH v9 22/23] net/sxe2: implement private dump info liujie5
2026-06-26 6:49 ` [PATCH v9 23/23] net/sxe2: update sxe2 feature matrix docs liujie5
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=20260626112114.1eddd05e@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=liujie5@linkdatatechnology.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