Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: anthony.l.nguyen@intel.com
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
	netdev@vger.kernel.org, mheib@redhat.com,
	przemyslaw.kitszel@intel.com, jiri@resnulli.us, horms@kernel.org,
	corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/2] i40e: add devlink parameter for Flow Director ATR sample rate
Date: Sat, 05 Dec 2026 22:29:04 +0000	[thread overview]
Message-ID: <179650974454.3148.3078408674524339053@kernel.org> (raw)
In-Reply-To: <20261204213811.3397760-3-anthony.l.nguyen@intel.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] Writing atr_sample_rate=0 through devlink adds a second,
  undocumented way to turn ATR on and off, and the driver's existing ATR…
- [Medium] i40e_atr_sample_rate_set() requests a full hardware Flow
  Director table flush (__I40E_FD_FLUSH_REQUESTED) every time the value…
- [Medium] i40e: unsynchronized FD flush race in
  i40e_atr_sample_rate_set()
- [Low] The new atr_sample_rate entry in
  Documentation/networking/devlink/i40e.rst says "The sampling interval…

--

i40e: add devlink parameter for Flow Director ATR sample rate

This adds a runtime devlink parameter, atr_sample_rate. It sets
pf->atr_sample_rate, which i40e_atr() uses as the Flow Director ATR
sampling interval. Writing 0 disables ATR sampling and requests a Flow
Director table flush, and the parameter is documented in
Documentation/networking/devlink/i40e.rst.

> diff --git a/Documentation/networking/devlink/i40e.rst b/Documentation/networking/devlink/i40e.rst
> index 51c887f0dc833..d280c17fe987b 100644
> --- a/Documentation/networking/devlink/i40e.rst
> +++ b/Documentation/networking/devlink/i40e.rst
> @@ -40,6 +40,27 @@ Parameters

[ ... ]

> +    * - ``atr_sample_rate``
> +      - runtime
> +      - Controls how frequently Flow Director ATR updates flow steering
> +        information for active TCP flows.
> +
> +        ATR programs Flow Director entries based on sampled TCP packets
> +        per Tx queue. The sampling interval is the number of TCP packets
> +        transmitted on each queue between ATR updates.

[Severity: Low]
Is this description accurate for every TCP packet? In i40e_atr(), the
interval check is skipped for SYN packets. It is also skipped for FIN/RST
packets when I40E_FLAG_HW_ATR_EVICT_ENA is clear:

drivers/net/ethernet/intel/i40e/i40e_txrx.c:i40e_atr() {
    ...
	/* sample on all syn/fin/rst packets or once every atr sample rate */
	if (!th->fin &&
	    !th->syn &&
	    !th->rst &&
	    (tx_ring->atr_count < sample_rate))
		return;

	tx_ring->atr_count = 0;
    ...
}

Each of those packets programs an FD descriptor regardless of the rate and
resets atr_count. With many short connections, raising the value won't
reduce programming as much as this text suggests.

The parameter also has no effect while the flow-director-atr priv flag is
off, because i40e_atr() returns before it reads the rate:

	/* make sure ATR is enabled */
	if (!test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags))
		return;

Could the documentation mention both cases?

[ ... ]

> diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
> index 229179ccc1319..8af2487776f28 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
> @@ -33,12 +33,58 @@ static int i40e_max_mac_per_vf_get(struct devlink *devlink,
>  	return 0;
>  }
>  
> +static int i40e_atr_sample_rate_set(struct devlink *devlink,
> +				    u32 id,
> +				    struct devlink_param_gset_ctx *ctx,
> +				    struct netlink_ext_ack *extack)
> +{
> +	struct i40e_pf *pf = devlink_priv(devlink);
> +	u32 sample_rate = ctx->val.vu32;
> +
> +	WRITE_ONCE(pf->atr_sample_rate, sample_rate);
> +
> +	/* Setting rate to 0 disables sampling but does not remove
> +	 * existing ATR entries. Flush them so stale filters do not
> +	 * persist on devices without HW ATR eviction.
> +	 */
> +	if (!sample_rate) {
> +		set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
> +		set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
> +	}

[Severity: Medium]
Can the flush requested here be lost, or finish before the ATR entries
it is meant to remove have reached the table?

i40e_atr_sample_rate_set() runs under the devlink instance lock only.
i40e_fdir_flush_and_replay() runs from the service task and i40e_atr()
runs in the Tx path. Neither of them takes that lock. The flush ends
with:

	if (!disable_atr && !pf->fd_tcp4_filter_cnt)
		clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
	clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);

Consider this ordering:

  1. CPU0 in i40e_fdir_flush_and_replay() has replayed the sideband
     filters and clears __I40E_FD_ATR_AUTO_DISABLED.
  2. CPU2 in i40e_atr() sees __I40E_FD_ATR_AUTO_DISABLED clear and
     the old non-zero pf->atr_sample_rate, and queues an ATR filter
     program descriptor.
  3. CPU1 in i40e_atr_sample_rate_set() writes 0 and sets both
     __I40E_FD_ATR_AUTO_DISABLED and __I40E_FD_FLUSH_REQUESTED.
  4. CPU0 clears __I40E_FD_FLUSH_REQUESTED.

The request from step 3 is dropped, and the entry from step 2 stays in
the FD table. With pf->atr_sample_rate at 0, i40e_atr() returns before
it would send the FIN/RST remove descriptor for that flow. On parts
without I40E_FLAG_HW_ATR_EVICT_ENA, nothing removes the entry. This is
the stale filter that the comment in this function says the flush
should prevent. The entry keeps steering the flow to the queue that was
picked when the flow was sampled.

A stale entry can also survive when no flush is already in progress.
Nothing here waits for Tx contexts that already read the old rate. An
i40e_atr() call that is past the rate check can still write a
FILTER_PROG descriptor. Descriptors already queued on a Tx ring can
also be fetched by the NIC after the CLEARFDTABLE write in
i40e_fdir_flush_and_replay().

i40e_set_priv_flags() requests the flush with the same two set_bit()
calls, so part of this may predate the patch. Should
i40e_fdir_flush_and_replay() consume the request with
test_and_clear_bit() before it clears the table? A request that arrives
during the flush would then trigger another flush. Does the zero-rate
path also need something like synchronize_net() and a Tx ring drain
before it requests the flush?

[Severity: Medium]
The comment says the flush is for devices without HW ATR eviction. Should
this code check I40E_FLAG_HW_ATR_EVICT_ENA, the previous rate, and
I40E_FLAG_FD_ATR_ENA before it sets __I40E_FD_FLUSH_REQUESTED?

As written, every write of 0 requests a full flush. That includes:

  - writing 0 when the rate is already 0
  - writing 0 while ATR is already off through the priv flag
  - writing 0 on a device that has HW eviction

The devlink core calls ->set without comparing the old and new values. Each
of these writes therefore runs i40e_fdir_flush_and_replay() again.

That function clears the whole FD table, including user ntuple/sideband
rules. It replays them only after the clear completes:

drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_fdir_flush_and_replay() {
    ...
	/* flush all filters */
	wr32(&pf->hw, I40E_PFQF_CTL_1,
	     I40E_PFQF_CTL_1_CLEARFDTABLE_MASK);
    ...
		/* replay sideband filters */
		i40e_fdir_filter_restore(i40e_pf_get_main_vsi(pf));
    ...
}

Between the clear and the replay, the user's rules don't steer or drop
matching Rx traffic.

While the flag is set, i40e_add_fdir_ethtool() and i40e_del_fdir_entry()
both return -EBUSY. The flush is rate-limited by I40E_MIN_FD_FLUSH_INTERVAL
and i40e_fdir_reinit_subtask() skips it while __I40E_DOWN is set, so the
flag can stay set for a long time.

For comparison, the existing priv flag path in i40e_set_priv_flags() only
requests the flush when ATR actually goes from enabled to disabled:

	if (test_bit(I40E_FLAG_FD_ATR_ENA, changed_flags) &&
	    !test_bit(I40E_FLAG_FD_ATR_ENA, new_flags)) {
		set_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);
		set_bit(__I40E_FD_FLUSH_REQUESTED, pf->state);
	}

[Severity: Medium]
The commit message says the parameter lets administrators tune the rate:

  "without rebuilding the driver or disabling ATR functionality entirely."

Writing 0 does disable ATR and also flushes the FD table. Should the commit
message say so?

The disable is only recorded in __I40E_FD_ATR_AUTO_DISABLED, and the rest of
the driver treats that bit as a temporary out-of-space state. For example,
i40e_fdir_flush_and_replay() clears it when the flush requested here
completes:

		i40e_fdir_filter_restore(i40e_pf_get_main_vsi(pf));
		if (!disable_atr && !pf->fd_tcp4_filter_cnt)
			clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state);

i40e_reenable_fdir_atr() and the ntuple-off path in i40e_set_ntuple() also
clear it.

Once the bit is cleared, i40e_update_pf_stats() reports ATR as active:

	if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags) &&
	    !test_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state))
		nsd->fd_atr_status = true;

ethtool -S then shows port.fdir_atr_status as 1, and the flow-director-atr
priv flag still shows on. Meanwhile, i40e_atr() programs no filters because
of the new check:

	sample_rate = READ_ONCE(pf->atr_sample_rate);
	if (!sample_rate)
		return;

Is it intended that neither the priv flag nor the ATR status counter
reflects atr_sample_rate == 0? A user could turn the priv flag on and still
get no ATR because the devlink value is 0.

> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204213811.3397760-1-anthony.l.nguyen%40intel.com

      reply	other threads:[~2026-12-05 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 21:38 [PATCH net-next v2 0/2][pull request] i40e: add runtime-tunable ATR sample rate Tony Nguyen
2026-12-04 21:38 ` [PATCH net-next v2 1/2] i40e: move ATR sample rate from ring to PF level Tony Nguyen
2026-12-05 22:29   ` netdev-bot+sashiko
2026-12-04 21:38 ` [PATCH net-next v2 2/2] i40e: add devlink parameter for Flow Director ATR sample rate Tony Nguyen
2026-12-05 22:29   ` netdev-bot+sashiko [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=179650974454.3148.3078408674524339053@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=mheib@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=willemb@google.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