DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bing Zhao <bingz@nvidia.com>
Cc: <viacheslavo@nvidia.com>, <dev@dpdk.org>, <rasland@nvidia.com>,
	<orika@nvidia.com>, <dsosnowski@nvidia.com>,
	<suanmingm@nvidia.com>, <matan@nvidia.com>, <thomas@monjalon.net>
Subject: Re: [PATCH v7] ethdev: support inline calculating masked item value
Date: Tue, 13 Oct 2026 08:45:47 -0700	[thread overview]
Message-ID: <20261013084547.642a11ab@phoenix.local> (raw)
In-Reply-To: <20261013134950.310252-1-bingz@nvidia.com>

On Tue, 13 Oct 2026 16:49:50 +0300
Bing Zhao <bingz@nvidia.com> wrote:

> In the asynchronous API definition and some drivers, the
> rte_flow_item spec value may not be calculated by the driver due to the
> reason of speed of light rule insertion rate and sometimes the input
> parameters will be copied and changed internally.
> 
> After copying, the spec and last will be protected by the keyword
> const and cannot be changed in the code itself. And also the driver
> needs some extra memory to do the calculation and extra conditions
> to understand the length of each item spec. This is not efficient.
> 
> To solve the issue and support usage of the following fix, a new OP
> was introduced to calculate the spec and last values after applying
> the mask inline.
> 
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Reviewed-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
> ---

Semi-automated AI review had some feedback.
I assume mlx5 will come as followon so complaints about just this patch
are not really valid. And not concerned about its complaints
about going over flow twice when copying.

[PATCH v7] ethdev: support inline calculating masked item value

Applies to main, builds with -Dwerror=true.

Warning

1. GENEVE_OPT option_len is masked, data length is not.

rte_flow_conv_item_mask_size() returns offsetof(..., data), so
option_len is ANDed with the mask. The default
rte_flow_item_geneve_opt_mask has option_len = 0, while the deep
copy of data is sized from the unmasked spec->option_len. The output
is a spec with option_len == 0 pointing at option_len * 4 bytes of
data; the new test asserts exactly that. mlx5 sizes the option data
from spec->option_len (mlx5_flow.c, data_len = spec->option_len * 4),
so a driver switched to this op loses the option length.

option_len is a length, not a match value. Leave it unmasked:

	case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
		return offsetof(struct rte_flow_item_geneve_opt,
				option_len);

and change the test to assert option_len is preserved.

2. TAG index is a selector, same reasoning as COMPARE.

rte_flow_item_tag.index picks the register, it is not matched
against packet data. mlx5 takes it from the unmasked spec on purpose
(mlx5_flow_dv.c: "When set mask, the index should be from spec").
With a template mask that has index == 0, this op returns index 0,
i.e. a different tag. Exclude it:

	case RTE_FLOW_ITEM_TYPE_TAG:
		return offsetof(struct rte_flow_item_tag, index);

Update the "Not masked" list in rte_flow.h, the comment above
rte_flow_conv_item_mask_size() and the rte_flow_conv_pattern()
doxygen to match, and add a TAG case to the test.

3. No user of the new op.

The commit message refers to "the following fix", but nothing in
this submission or in tree uses RTE_FLOW_CONV_OP_PATTERN_MASKED.
Send it as a series with the driver change that consumes it, so the
semantics above can be checked against a real caller.

4. Commit message needs rewriting. Suggested body:

  Drivers translating async flow rules get const spec/last and must
  copy each item to apply the mask, which needs per-item knowledge
  of the spec size.

  Add RTE_FLOW_CONV_OP_PATTERN_MASKED to rte_flow_conv(). It copies
  the pattern like RTE_FLOW_CONV_OP_PATTERN and ANDs each copied
  spec and last with the item mask. Pointed-to data (RAW pattern,
  GENEVE_OPT data), selector fields, FLEX, COMPARE and PMD private
  items are not masked.

Info

5. RAW pattern bytes are deep-copied into the writable output buffer
and spec.length is already masked, so masking the copied pattern
with mask->pattern for that length is straightforward. If it is left
out on purpose, say why in the commit message.

6. The insertion-rate argument needs numbers. rte_flow_conv() walks
the pattern twice (validate, copy) and masks byte by byte; show it
is not slower than the driver-local copy it replaces, or drop the
claim.

      reply	other threads:[~2026-10-13 15:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  7:54 [PATCH 1/2] lib/ethdev: support inline calculating masked item value Bing Zhao
2025-11-17 17:25 ` Stephen Hemminger
2026-02-05  8:45   ` Bing Zhao
2026-02-05 16:42 ` Stephen Hemminger
2026-02-09  4:23   ` Bing Zhao
2026-02-09 14:17     ` Bing Zhao
2026-02-09 18:58       ` Stephen Hemminger
2026-02-09 21:46         ` Thomas Monjalon
2026-02-13 13:31 ` [PATCH v2] " Bing Zhao
2026-02-13 19:50   ` Stephen Hemminger
2026-06-03  8:19   ` [PATCH v3] ethdev: " Bing Zhao
2026-06-03  9:28     ` [PATCH v4] " Bing Zhao
2026-06-08 14:49       ` Dariusz Sosnowski
2026-06-08 15:45       ` Stephen Hemminger
2026-06-09  5:23         ` Bing Zhao
2026-06-10  5:27       ` [PATCH v5] " Bing Zhao
2026-06-10 15:46         ` Stephen Hemminger
2026-06-11  4:55         ` Bing Zhao
2026-06-11  4:56           ` Bing Zhao
2026-10-07 16:57         ` [PATCH v6] " Bing Zhao
2026-10-08  7:17           ` Bing Zhao
2026-10-08 15:27           ` Stephen Hemminger
2026-10-13 13:49           ` [PATCH v7] " Bing Zhao
2026-10-13 15:45             ` 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=20261013084547.642a11ab@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.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