mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Vecera <ivecera@redhat.com>
To: intel-wired-lan@osuosl.org, Petr Oros <poros@redhat.com>,
	netdev@vger.kernel.org
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Henry Tieman <henry.w.tieman@intel.com>,
	Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
	Jesse Brandeburg <jbrandeb@kernel.org>,
	Preethi Banala <preethi.banala@intel.com>,
	Kiran Patil <kiran.patil@intel.com>,
	Dan Nowlin <dan.nowlin@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH iwl-net 07/10] ice: take the switch rule AQ error from the response descriptor
Date: Sat, 03 Oct 2026 11:55:47 +0200	[thread overview]
Message-ID: <9B559EBB-75B5-43C6-AA5F-304E2AED20AE@redhat.com> (raw)
In-Reply-To: <20261002130752.2597259-8-poros@redhat.com>

On October 2, 2026 3:07:49 PM GMT+02:00, Petr Oros <poros@redhat.com> wrote:
>ice_aq_sw_rules() decides whether a rule removal failed with ENOENT by
>reading hw->adminq.sq_last_status after ice_aq_send_cmd() returned. That
>field is shared by every admin queue user and is only stable while the
>send queue lock is held. Another AQ command completing in between can
>overwrite it, so a failed removal is reported as a generic error, and a
>successful one can even be turned into -ENOENT, because the check is
>not limited to the failure case. A caller that sees -ENOENT keeps its
>rule bookkeeping while the rule is gone from the hardware.
>
>ice_vsi_sync_fltr() has the same problem with ENOSPC. It checks
>sq_last_status only after it has freed the list of filters it tried to
>add. Every entry is a separate devres allocation, so freeing a list of
>thousands of entries takes seconds, and by then the value usually
>belongs to a different command, so the MAC filter overflow handling is
>never entered. With debug prints of the error and sq_last_status added
>to both places:
>
>  ice_aq_sw_rules: opc 0x2a0 status -5 aq 16
>  ice 0000:04:00.0 enp4s0f0np0: Failed to add MAC filters err -5 aq 0
>
>Use the retval of the descriptor that ice_aq_send_cmd() copies back,
>only when the command failed, translate ENOSPC on add to -ENOSPC and
>let ice_vsi_sync_fltr() check the return code instead of
>sq_last_status.
>
>i40e fixed the same kind of race in commit 53a9e346e159 ("i40e: Fix race
>condition while adding/deleting MAC/VLAN filters").
>
>Fixes: ca1fdb885e5f ("ice: return correct error code from ice_aq_sw_rules")
>Assisted-by: LLM
>Signed-off-by: Petr Oros <poros@redhat.com>
>---
> drivers/net/ethernet/intel/ice/ice_main.c   |  4 +---
> drivers/net/ethernet/intel/ice/ice_switch.c | 13 ++++++++++---
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
>index 8a21f87eb6ca21..ceb9fec2af21e7 100644
>--- a/drivers/net/ethernet/intel/ice/ice_main.c
>+++ b/drivers/net/ethernet/intel/ice/ice_main.c
>@@ -396,8 +396,6 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
> 	struct device *dev = ice_pf_to_dev(vsi->back);
> 	struct net_device *netdev = vsi->netdev;
> 	bool promisc_forced_on = false;
>-	struct ice_pf *pf = vsi->back;
>-	struct ice_hw *hw = &pf->hw;
> 	u32 changed_flags = 0;
> 	int err;
> 
>@@ -450,7 +448,7 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
> 		 * should go into promiscuous mode. There should be some
> 		 * space reserved for promiscuous filters.
> 		 */
>-		if (hw->adminq.sq_last_status == LIBIE_AQ_RC_ENOSPC &&
>+		if (err == -ENOSPC &&
> 		    !test_and_set_bit(ICE_FLTR_OVERFLOW_PROMISC,
> 				      vsi->state)) {
> 			promisc_forced_on = true;
>diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
>index 239d4d9633baa6..ae96a2003d5c5e 100644
>--- a/drivers/net/ethernet/intel/ice/ice_switch.c
>+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
>@@ -1959,9 +1959,16 @@ ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
> 	desc.flags |= cpu_to_le16(LIBIE_AQ_FLAG_RD);
> 	cmd->num_rules_fltr_entry_index = cpu_to_le16(num_rules);
> 	status = ice_aq_send_cmd(hw, &desc, rule_list, rule_list_sz, cd);
>-	if (opc != ice_aqc_opc_add_sw_rules &&
>-	    hw->adminq.sq_last_status == LIBIE_AQ_RC_ENOENT)
>-		status = -ENOENT;
>+	if (status) {
>+		enum libie_aq_err aq_err = le16_to_cpu(desc.retval) & 0xff;
>+
>+		if (opc != ice_aqc_opc_add_sw_rules &&
>+		    aq_err == LIBIE_AQ_RC_ENOENT)
>+			status = -ENOENT;
>+		else if (opc == ice_aqc_opc_add_sw_rules &&
>+			 aq_err == LIBIE_AQ_RC_ENOSPC)
>+			status = -ENOSPC;
>+	}
> 
> 	if (!status) {
> 		if (opc == ice_aqc_opc_add_sw_rules)

Reviewed-by: Ivan Vecera <ivecera@redhat.com>


  reply	other threads:[~2026-10-03  9:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 13:07 [PATCH iwl-net 00/10] ice: port missing i40e fixes Petr Oros
2026-10-02 13:07 ` [PATCH iwl-net 01/10] ice: replay UDP tunnel ports after a core or global reset Petr Oros
2026-10-03  9:52   ` Ivan Vecera
2026-10-05 10:24   ` Loktionov, Aleksandr
2026-11-07  4:51   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 02/10] ice: fix IRQ freeing in ice_vsi_req_irq_msix() error path Petr Oros
2026-10-03  9:53   ` Ivan Vecera
2026-10-05 10:24   ` Loktionov, Aleksandr
2026-11-07  4:52   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 03/10] ice: stop the LAN Tx queues when ice_vsi_open() fails Petr Oros
2026-10-03  9:54   ` Ivan Vecera
2026-10-05 12:03     ` Petr Oros
2026-11-07  4:52   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 04/10] ice: restore the default XPS map after a netdev TC change Petr Oros
2026-10-03  9:55   ` Ivan Vecera
2026-10-05 10:25   ` Loktionov, Aleksandr
2026-11-07  4:53   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 05/10] ice: report VF tx_dropped with tx_errors instead of tx_discards Petr Oros
2026-10-03  9:55   ` Ivan Vecera
2026-11-02 10:52     ` Romanowski, Rafal
2026-10-05 10:26   ` Loktionov, Aleksandr
2026-10-02 13:07 ` [PATCH iwl-net 06/10] ice: keep adding MAC filters after one that already exists Petr Oros
2026-10-03  9:55   ` Ivan Vecera
2026-10-05 10:26   ` Loktionov, Aleksandr
2026-11-07  4:53   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 07/10] ice: take the switch rule AQ error from the response descriptor Petr Oros
2026-10-03  9:55   ` Ivan Vecera [this message]
2026-10-05 10:27   ` Loktionov, Aleksandr
2026-11-07  4:54   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 08/10] ice: detect a PF reset that does not complete Petr Oros
2026-10-03  9:55   ` Ivan Vecera
2026-10-05 10:27   ` Loktionov, Aleksandr
2026-11-07  4:55   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 09/10] ice: program multicast magic wake before tearing down the main VSI Petr Oros
2026-10-03  9:56   ` Ivan Vecera
2026-10-05 10:27   ` Loktionov, Aleksandr
2026-11-07  4:55   ` Nowlin, Alexander
2026-10-02 13:07 ` [PATCH iwl-net 10/10] ice: fix unsigned stat widths Petr Oros
2026-10-02 13:12   ` Loktionov, Aleksandr
2026-10-03  9:56   ` Ivan Vecera
2026-11-07  4:56   ` Nowlin, Alexander

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=9B559EBB-75B5-43C6-AA5F-304E2AED20AE@redhat.com \
    --to=ivecera@redhat.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dan.nowlin@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=henry.w.tieman@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=intel-wired-lan@osuosl.org \
    --cc=jbrandeb@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kiran.patil@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=preethi.banala@intel.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=stephen@networkplumber.org \
    /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

all inboxes | Powered by JetHome®