From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796509746; b=R7VQJpjbGAtOwR/EbZeRuTdUhTe97/rzotgsLr9ZqbHjvBJDRbzvF5ugYWP7PcedaUcY w0yF/r6mGhIiCqnvEIVQkmV5brZHmN6pelfBpYBHYXcuZJDS6xdDsO2eLEXxi0p9/w67u SLmFKg9ORPusNQq5qnpUHnY8OPZbx5a9kUbu7KvarLLGHY+zlWhXp4bebbZRkZ6R7M8q3 zW3FOJ2jUDIbJ5eh/mNmSHkm/eeXqgYDSvCIw6p+PGjhoCCZOk7pxNpyHv08cGO9hP+Lc AolAoTRQUCLTWYOmE173zJ+EGEg7HUutUHmZpoelPIGoKvGRNP/xvnLE4w+992MTHUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796509746; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=WlHFEAK1hmZ9WZHy+auUFOPc2tcHsyUf0cKs1/fR16M=; b=smPKHMuB1BMlJlu31b24b+w9kyUrzaMXeiyHaImx60KOtTnBdlFSSpxmT9yD6BYEvIZa sjzBh5sX/5EGc+VtDL8Cdu1JaYSTAxtXbNJQjta3VVKNAiJjDGx6bods5kKPIhBnOHxdU 9rmM3z6vh1wJNHrLFm2u7xmTGVne+dun1C3F1YooZf8gdECj555F78iuv6AjfQgYNeyWd hydcJoTaIqxc4ZAthrsiRgxYf6X2O9a4z8lkANlxT7kRkS2QmVKO1UAKima/i+TNe+r1r DNgc4dpLSmASNnXcnUx9MJ31BAYofLN31Naka4IK4o7C6jOvtRxrbRMHRYgjFLzpXGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cJiYm3fN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1180D606A332; Sat, 5 Dec 2026 22:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cJiYm3fN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 047D51F0092B; Sat, 5 Dec 2026 22:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796509745; bh=WlHFEAK1hmZ9WZHy+auUFOPc2tcHsyUf0cKs1/fR16M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=cJiYm3fNYiJ3Lo4tVrOOREPavJvVTiHw+OLbeDQ/qcK0vXs1zsanQC9ZMIBvu/bNa zuTC3qx20yjhA/wefhnXF22Aw9uaqGhYPZKxwUaAB6NEDBWploVLJFVIt6FkhYNfZ+ 45QAgPCrxbnSEGlAr+VxFIfSGi+QkaXKI9WPXMZzu2tbuSMKV5QQpU6/EhI5l0sOLQ tFJB2h8TW6Lf/KEsVRo4L1nfJ4sNa1+g7yajbNSr1snKxyx7jU8D2ABwaWEyZtR5u/ uQXlfPpF69IR8grgy22rn9SLKlZBOU7S+Sz7gNUsuPFqm3mLdOpqEiZgTZ0xniW7l4 r7uZf+/vWZFQw== Subject: Re: [PATCH net-next v2 2/2] i40e: add devlink parameter for Flow Director ATR sample rate 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 Date: Sat, 05 Dec 2026 22:29:04 +0000 Message-ID: <179650974454.3148.3078408674524339053@kernel.org> In-Reply-To: <20261204213811.3397760-3-anthony.l.nguyen@intel.com> References: <20261204213811.3397760-3-anthony.l.nguyen@intel.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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