From nobody Thu Apr 9 12:07:35 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52A3D3446C0 for ; Mon, 2 Mar 2026 11:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451649; cv=none; b=acWxQgG4ePPI08ZuRolLoqwb7vB/QWGYMf1Uu0h2SmUTLAdoHnGfN2qtP7Fd4nPpmRXOdRFPmfPFw2Fd7tp4GMHkYoTN6Tj67zI7y0myzXB+VfZl3pYhxMKCfvJnqoMFELLh3avAQtXjmt0X+jRAz07ZNgmc3IL+yEoooxL6jZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451649; c=relaxed/simple; bh=c2KF/gaurLuOL9n21+yl+uvd1IemrDLGiIKtJu0QIBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dGgPTzJP9RseTTGQ2e3JCTjt8+85/FMyK9n48k/Ag/eZnkWCeebwYdMj2+Quz/X42CBEoHOMabxJZTgp3hU5OReD+Q8bXY4/j+zKNQnRQ4HpQY6C0aM/LeRbM/DjQp2F8Co0XF79SNpAxfKGJiltVsn5gWB74D8szB95BIfqdQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iVHBly3C; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iVHBly3C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772451647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ncsRh6apqUu7E9HPi27BmsmzD0caQNYcAoNEUyrUMUo=; b=iVHBly3CxFUpX/f1Gttbs1TXszINjLvftuzjCis/sNuRzkimBQXnTz+xScWLKtfLztOpKm MpY7Q/tApAxq+wV9sWBTEH/ePpAzfTKIceOLzgIXcwZ/teBYzMaSj82kswTXj4H3u7Ujhh yeyJCRTaXC2BcWnCCTil3ofdlMkgXl8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-1xsk06_QN0qcax7gYv94nA-1; Mon, 02 Mar 2026 06:40:37 -0500 X-MC-Unique: 1xsk06_QN0qcax7gYv94nA-1 X-Mimecast-MFC-AGG-ID: 1xsk06_QN0qcax7gYv94nA_1772451635 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 35E891800259; Mon, 2 Mar 2026 11:40:35 +0000 (UTC) Received: from ShadowPeak.redhat.com (unknown [10.44.32.50]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C4E621955F22; Mon, 2 Mar 2026 11:40:31 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: jacob.e.keller@intel.com, Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC iwl-next 1/4] iavf: rename IAVF_VLAN_IS_NEW to IAVF_VLAN_ADDING Date: Mon, 2 Mar 2026 12:40:22 +0100 Message-ID: <20260302114025.1017985-2-poros@redhat.com> In-Reply-To: <20260302114025.1017985-1-poros@redhat.com> References: <20260302114025.1017985-1-poros@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Rename the IAVF_VLAN_IS_NEW state to IAVF_VLAN_ADDING to better describe what the state represents: an ADD request has been sent to the PF and is waiting for a response. This is a pure rename with no behavioral change, preparing for a cleanup of the VLAN filter state machine. Signed-off-by: Petr Oros Reviewed-by: Aleksandr Loktionov Tested-by: Rafal Romanowski --- drivers/net/ethernet/intel/iavf/iavf.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index a87e0c6d4017ad..8e6db72828ae14 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -158,7 +158,7 @@ struct iavf_vlan { enum iavf_vlan_state_t { IAVF_VLAN_INVALID, IAVF_VLAN_ADD, /* filter needs to be added */ - IAVF_VLAN_IS_NEW, /* filter is new, wait for PF answer */ + IAVF_VLAN_ADDING, /* ADD sent to PF, waiting for response */ IAVF_VLAN_ACTIVE, /* filter is accepted by PF */ IAVF_VLAN_DISABLE, /* filter needs to be deleted by PF, then marked INACT= IVE */ IAVF_VLAN_INACTIVE, /* filter is inactive, we are in IFF_DOWN */ diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index 88156082a41da6..5114934fe81fa6 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -746,7 +746,7 @@ static void iavf_vlan_add_reject(struct iavf_adapter *a= dapter) =20 spin_lock_bh(&adapter->mac_vlan_list_lock); list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { - if (f->state =3D=3D IAVF_VLAN_IS_NEW) { + if (f->state =3D=3D IAVF_VLAN_ADDING) { list_del(&f->list); kfree(f); adapter->num_vlan_filters--; @@ -812,7 +812,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter) if (f->state =3D=3D IAVF_VLAN_ADD) { vvfl->vlan_id[i] =3D f->vlan.vid; i++; - f->state =3D IAVF_VLAN_IS_NEW; + f->state =3D IAVF_VLAN_ADDING; if (i =3D=3D count) break; } @@ -874,7 +874,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter) vlan->tpid =3D f->vlan.tpid; =20 i++; - f->state =3D IAVF_VLAN_IS_NEW; + f->state =3D IAVF_VLAN_ADDING; } } =20 @@ -2911,7 +2911,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *ad= apter, =20 spin_lock_bh(&adapter->mac_vlan_list_lock); list_for_each_entry(f, &adapter->vlan_filter_list, list) { - if (f->state =3D=3D IAVF_VLAN_IS_NEW) + if (f->state =3D=3D IAVF_VLAN_ADDING) f->state =3D IAVF_VLAN_ACTIVE; } spin_unlock_bh(&adapter->mac_vlan_list_lock); --=20 2.52.0 From nobody Thu Apr 9 12:07:35 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 562C435DA4E for ; Mon, 2 Mar 2026 11:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451647; cv=none; b=NxQfn43Rvyk2hsJ7Yiklpyz5r0/AGJ5FrYB2V5hYxxNpaDNZ7BIclopEdUEoqLm/1yOEeGWh+a1cema0QtHzsOuu5jLnoA2i884s+NtylYFs5a14td5o1APlYsxaRKH8PhmcgCladBHqwSv37yMcEThCr18l6pZjFXc+gLLqQqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451647; c=relaxed/simple; bh=mI1A18vSDW1o9zQUAm3erDWQSHIuxk4SnhkGnxBKLfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WP0UrH21kytfQ8tziqff/t9RHcW0+UzViVp9iM+1ehAsC3FKWLLLtfX2YVdUjUFnuszbgtb1zMk77ywRVm7bW5Jhg3kQszqVQl57oFGNAMc7S+UG60SLzYMjh4c1aS04sH0xZI2AdkhBhQP3wf+nm9Goq6f3qEv617ZdvqRdh4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GwNTeZ25; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GwNTeZ25" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772451645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Be86IjUFHq6eNQwodapk2HrGH0te+YM55AbW5FS4mBU=; b=GwNTeZ254818wLHqSjjGwDj6x4wxZPx9zi9x7UQQPd8H1jfIz7sPaC0IVYP+4JKtUxWfZZ QZqP+pkcKN1G+Pm7Kjpl0pVhxxuFz/hYE2VtFUMQChkjF/Gaa9mvrHFbIfJPMHX/1gW0iT snbvwwXjBF8JNq3cv7zYprWSgc4320A= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-WdU3gTpGOVuO9dmRlBj78g-1; Mon, 02 Mar 2026 06:40:42 -0500 X-MC-Unique: WdU3gTpGOVuO9dmRlBj78g-1 X-Mimecast-MFC-AGG-ID: WdU3gTpGOVuO9dmRlBj78g_1772451640 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79DEE18001C6; Mon, 2 Mar 2026 11:40:40 +0000 (UTC) Received: from ShadowPeak.redhat.com (unknown [10.44.32.50]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9AB3A1956053; Mon, 2 Mar 2026 11:40:35 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: jacob.e.keller@intel.com, Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC iwl-next 2/4] iavf: stop removing VLAN filters from PF on interface down Date: Mon, 2 Mar 2026 12:40:23 +0100 Message-ID: <20260302114025.1017985-3-poros@redhat.com> In-Reply-To: <20260302114025.1017985-1-poros@redhat.com> References: <20260302114025.1017985-1-poros@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" When a VF goes down, the driver currently sends DEL_VLAN to the PF for every VLAN filter (ACTIVE -> DISABLE -> send DEL -> INACTIVE), then re-adds them all on UP (INACTIVE -> ADD -> send ADD -> ADDING -> ACTIVE). This round-trip is unnecessary because: 1. The PF disables the VF's queues via VIRTCHNL_OP_DISABLE_QUEUES, which already prevents all RX/TX traffic regardless of VLAN filter state. 2. The VLAN filters remaining in PF HW while the VF is down is harmless - packets matching those filters have nowhere to go with queues disabled. 3. The DEL+ADD cycle during down/up creates race windows where the VLAN filter list is incomplete. With spoofcheck enabled, the PF enables TX VLAN filtering on the first non-zero VLAN add, blocking traffic for any VLANs not yet re-added. Remove the entire DISABLE/INACTIVE state machinery: - Remove IAVF_VLAN_DISABLE and IAVF_VLAN_INACTIVE enum values - Remove iavf_restore_filters() and its call from iavf_open() - Remove VLAN filter handling from iavf_clear_mac_vlan_filters(), rename it to iavf_clear_mac_filters() - Remove DEL_VLAN_FILTER scheduling from iavf_down() - Remove all DISABLE/INACTIVE handling from iavf_del_vlans() VLAN filters now stay ACTIVE across down/up cycles. Only explicit user removal (ndo_vlan_rx_kill_vid) or PF/VF reset triggers VLAN filter deletion/re-addition. Signed-off-by: Petr Oros Reviewed-by: Aleksandr Loktionov --- drivers/net/ethernet/intel/iavf/iavf.h | 6 +-- drivers/net/ethernet/intel/iavf/iavf_main.c | 39 ++----------------- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 33 +++------------- 3 files changed, 12 insertions(+), 66 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 8e6db72828ae14..1ad00690622c8e 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -159,10 +159,8 @@ enum iavf_vlan_state_t { IAVF_VLAN_INVALID, IAVF_VLAN_ADD, /* filter needs to be added */ IAVF_VLAN_ADDING, /* ADD sent to PF, waiting for response */ - IAVF_VLAN_ACTIVE, /* filter is accepted by PF */ - IAVF_VLAN_DISABLE, /* filter needs to be deleted by PF, then marked INACT= IVE */ - IAVF_VLAN_INACTIVE, /* filter is inactive, we are in IFF_DOWN */ - IAVF_VLAN_REMOVE, /* filter needs to be removed from list */ + IAVF_VLAN_ACTIVE, /* PF confirmed, filter is in HW */ + IAVF_VLAN_REMOVE, /* filter queued for DEL from PF */ }; =20 struct iavf_vlan_filter { diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethe= rnet/intel/iavf/iavf_main.c index bceaf4b1b85d5f..f1ab68f5f4050b 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -823,27 +823,6 @@ static void iavf_del_vlan(struct iavf_adapter *adapter= , struct iavf_vlan vlan) spin_unlock_bh(&adapter->mac_vlan_list_lock); } =20 -/** - * iavf_restore_filters - * @adapter: board private structure - * - * Restore existing non MAC filters when VF netdev comes back up - **/ -static void iavf_restore_filters(struct iavf_adapter *adapter) -{ - struct iavf_vlan_filter *f; - - /* re-add all VLAN filters */ - spin_lock_bh(&adapter->mac_vlan_list_lock); - - list_for_each_entry(f, &adapter->vlan_filter_list, list) { - if (f->state =3D=3D IAVF_VLAN_INACTIVE) - f->state =3D IAVF_VLAN_ADD; - } - - spin_unlock_bh(&adapter->mac_vlan_list_lock); - adapter->aq_required |=3D IAVF_FLAG_AQ_ADD_VLAN_FILTER; -} =20 /** * iavf_get_num_vlans_added - get number of VLANs added @@ -1262,13 +1241,12 @@ static void iavf_up_complete(struct iavf_adapter *a= dapter) } =20 /** - * iavf_clear_mac_vlan_filters - Remove mac and vlan filters not sent to PF - * yet and mark other to be removed. + * iavf_clear_mac_filters - Remove MAC filters not sent to PF yet and mark + * others to be removed. * @adapter: board private structure **/ -static void iavf_clear_mac_vlan_filters(struct iavf_adapter *adapter) +static void iavf_clear_mac_filters(struct iavf_adapter *adapter) { - struct iavf_vlan_filter *vlf, *vlftmp; struct iavf_mac_filter *f, *ftmp; =20 spin_lock_bh(&adapter->mac_vlan_list_lock); @@ -1287,11 +1265,6 @@ static void iavf_clear_mac_vlan_filters(struct iavf_= adapter *adapter) } } =20 - /* disable all VLAN filters */ - list_for_each_entry_safe(vlf, vlftmp, &adapter->vlan_filter_list, - list) - vlf->state =3D IAVF_VLAN_DISABLE; - spin_unlock_bh(&adapter->mac_vlan_list_lock); } =20 @@ -1387,7 +1360,7 @@ void iavf_down(struct iavf_adapter *adapter) iavf_napi_disable_all(adapter); iavf_irq_disable(adapter); =20 - iavf_clear_mac_vlan_filters(adapter); + iavf_clear_mac_filters(adapter); iavf_clear_cloud_filters(adapter); iavf_clear_fdir_filters(adapter); iavf_clear_adv_rss_conf(adapter); @@ -1404,8 +1377,6 @@ void iavf_down(struct iavf_adapter *adapter) */ if (!list_empty(&adapter->mac_filter_list)) adapter->aq_required |=3D IAVF_FLAG_AQ_DEL_MAC_FILTER; - if (!list_empty(&adapter->vlan_filter_list)) - adapter->aq_required |=3D IAVF_FLAG_AQ_DEL_VLAN_FILTER; if (!list_empty(&adapter->cloud_filter_list)) adapter->aq_required |=3D IAVF_FLAG_AQ_DEL_CLOUD_FILTER; if (!list_empty(&adapter->fdir_list_head)) @@ -4487,8 +4458,6 @@ static int iavf_open(struct net_device *netdev) iavf_add_filter(adapter, adapter->hw.mac.addr); spin_unlock_bh(&adapter->mac_vlan_list_lock); =20 - /* Restore filters that were removed with IFF_DOWN */ - iavf_restore_filters(adapter); iavf_restore_fdir_filters(adapter); =20 iavf_configure(adapter); diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index 5114934fe81fa6..d62c0d6394149e 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -911,22 +911,12 @@ void iavf_del_vlans(struct iavf_adapter *adapter) spin_lock_bh(&adapter->mac_vlan_list_lock); =20 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { - /* since VLAN capabilities are not allowed, we dont want to send - * a VLAN delete request because it will most likely fail and - * create unnecessary errors/noise, so just free the VLAN - * filters marked for removal to enable bailing out before - * sending a virtchnl message - */ if (f->state =3D=3D IAVF_VLAN_REMOVE && !VLAN_FILTERING_ALLOWED(adapter)) { list_del(&f->list); kfree(f); adapter->num_vlan_filters--; - } else if (f->state =3D=3D IAVF_VLAN_DISABLE && - !VLAN_FILTERING_ALLOWED(adapter)) { - f->state =3D IAVF_VLAN_INACTIVE; - } else if (f->state =3D=3D IAVF_VLAN_REMOVE || - f->state =3D=3D IAVF_VLAN_DISABLE) { + } else if (f->state =3D=3D IAVF_VLAN_REMOVE) { count++; } } @@ -959,13 +949,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) vvfl->vsi_id =3D adapter->vsi_res->vsi_id; vvfl->num_elements =3D count; list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { - if (f->state =3D=3D IAVF_VLAN_DISABLE) { - vvfl->vlan_id[i] =3D f->vlan.vid; - f->state =3D IAVF_VLAN_INACTIVE; - i++; - if (i =3D=3D count) - break; - } else if (f->state =3D=3D IAVF_VLAN_REMOVE) { + if (f->state =3D=3D IAVF_VLAN_REMOVE) { vvfl->vlan_id[i] =3D f->vlan.vid; list_del(&f->list); kfree(f); @@ -1007,8 +991,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) vvfl_v2->vport_id =3D adapter->vsi_res->vsi_id; vvfl_v2->num_elements =3D count; list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { - if (f->state =3D=3D IAVF_VLAN_DISABLE || - f->state =3D=3D IAVF_VLAN_REMOVE) { + if (f->state =3D=3D IAVF_VLAN_REMOVE) { struct virtchnl_vlan_supported_caps *filtering_support =3D &adapter->vlan_v2_caps.filtering.filtering_support; struct virtchnl_vlan *vlan; @@ -1022,13 +1005,9 @@ void iavf_del_vlans(struct iavf_adapter *adapter) vlan->tci =3D f->vlan.vid; vlan->tpid =3D f->vlan.tpid; =20 - if (f->state =3D=3D IAVF_VLAN_DISABLE) { - f->state =3D IAVF_VLAN_INACTIVE; - } else { - list_del(&f->list); - kfree(f); - adapter->num_vlan_filters--; - } + list_del(&f->list); + kfree(f); + adapter->num_vlan_filters--; i++; if (i =3D=3D count) break; --=20 2.52.0 From nobody Thu Apr 9 12:07:35 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC62B3603ED for ; Mon, 2 Mar 2026 11:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451651; cv=none; b=RXdU2w+sPcwIWefjrhzfp+YyPAOeTgkgMV0BfQEXBvYwHcQheIipLUOuZWsfXyznyYgPhZpFCR7WTPnCtw0722gjQzISABUEvHB6Sx/EDOZJ+ceoqyPNaowuuqjWnNL7kItN61MEKkRU3jaVCzbYJd9bhdRja73H1+C/hTkZRm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451651; c=relaxed/simple; bh=K+JT0hUFt2U3gKTuWEWnh0uuCjs1QJ1qcLNTp8jLe5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mEFP0BO1T9sOiQtWoP5WxFizL/tiZK6xgd9a76AR8zmC2RNSUCBAESKtdUUztPF4K43J9r1oa6Uqe6G6HbriKmbwZ8vrlXhMXsC1CI9EzWh/Nd8fM7PcIeAj2QM1cbXTNeeZ0Ca9lhF+rYgVL5gAIL8Bse34oBrlQIK5KIKqRj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y//vpHIP; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y//vpHIP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772451648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Bb+I9g2d7bQxdwADL6SA7iVdzmM7hNyUv0fUe9nErk=; b=Y//vpHIPGEn5rYPe4mIwNVm/OsrbvaCMaKOlZdwm+PIArrgWetfnGlQCpkRHATiC60QlS9 zD1EILFjr/UDTFrREtmftd8zyGTrk5r1UOgI7Yu+bsgGeOLqyACJ6r088w7sliMuBwdleD BNZDC/fk6jIfm68QpjkS2+cjpkAH0cE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-87jLJdzeMBKVrMfpdPhnSA-1; Mon, 02 Mar 2026 06:40:45 -0500 X-MC-Unique: 87jLJdzeMBKVrMfpdPhnSA-1 X-Mimecast-MFC-AGG-ID: 87jLJdzeMBKVrMfpdPhnSA_1772451644 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0CDDB19560AD; Mon, 2 Mar 2026 11:40:44 +0000 (UTC) Received: from ShadowPeak.redhat.com (unknown [10.44.32.50]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD3D11956053; Mon, 2 Mar 2026 11:40:40 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: jacob.e.keller@intel.com, Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC iwl-next 3/4] iavf: wait for PF confirmation before removing VLAN filters Date: Mon, 2 Mar 2026 12:40:24 +0100 Message-ID: <20260302114025.1017985-4-poros@redhat.com> In-Reply-To: <20260302114025.1017985-1-poros@redhat.com> References: <20260302114025.1017985-1-poros@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" The VLAN filter DELETE path was asymmetric with the ADD path: ADD waits for PF confirmation (ADD -> ADDING -> ACTIVE), but DELETE immediately frees the filter struct after sending the DEL message without waiting for the PF response. This is problematic because: - If the PF rejects the DEL, the filter remains in HW but the driver has already freed the tracking structure, losing sync. - Race conditions between DEL pending and other operations (add, reset) cannot be properly resolved if the filter struct is already gone. Add IAVF_VLAN_REMOVING state to make the DELETE path symmetric: REMOVE -> REMOVING (send DEL) -> PF confirms -> kfree -> PF rejects -> ACTIVE In iavf_del_vlans(), transition filters from REMOVE to REMOVING instead of immediately freeing them. The new DEL completion handler in iavf_virtchnl_completion() frees filters on success or reverts them to ACTIVE on error. Update iavf_add_vlan() to handle the REMOVING state: if a DEL is pending and the user re-adds the same VLAN, queue it for ADD so it gets re-programmed after the PF processes the DEL. The !VLAN_FILTERING_ALLOWED early-exit path still frees filters directly since no PF message is sent in that case. Signed-off-by: Petr Oros --- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_main.c | 9 +++-- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 37 +++++++++++++------ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 1ad00690622c8e..f9ad814d18b1da 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -161,6 +161,7 @@ enum iavf_vlan_state_t { IAVF_VLAN_ADDING, /* ADD sent to PF, waiting for response */ IAVF_VLAN_ACTIVE, /* PF confirmed, filter is in HW */ IAVF_VLAN_REMOVE, /* filter queued for DEL from PF */ + IAVF_VLAN_REMOVING, /* DEL sent to PF, waiting for response */ }; =20 struct iavf_vlan_filter { diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethe= rnet/intel/iavf/iavf_main.c index f1ab68f5f4050b..212a23ead20c57 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -782,10 +782,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *= adapter, adapter->num_vlan_filters++; iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER); } else if (f->state =3D=3D IAVF_VLAN_REMOVE) { - /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed. - * We can safely only change the state here. - */ + /* DEL not yet sent to PF, cancel it */ f->state =3D IAVF_VLAN_ACTIVE; + } else if (f->state =3D=3D IAVF_VLAN_REMOVING) { + /* DEL already sent to PF, re-add after completion */ + f->state =3D IAVF_VLAN_ADD; + iavf_schedule_aq_request(adapter, + IAVF_FLAG_AQ_ADD_VLAN_FILTER); } =20 clearout: diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index d62c0d6394149e..9f2b64bb4ed9e7 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -948,12 +948,10 @@ void iavf_del_vlans(struct iavf_adapter *adapter) =20 vvfl->vsi_id =3D adapter->vsi_res->vsi_id; vvfl->num_elements =3D count; - list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { + list_for_each_entry(f, &adapter->vlan_filter_list, list) { if (f->state =3D=3D IAVF_VLAN_REMOVE) { vvfl->vlan_id[i] =3D f->vlan.vid; - list_del(&f->list); - kfree(f); - adapter->num_vlan_filters--; + f->state =3D IAVF_VLAN_REMOVING; i++; if (i =3D=3D count) break; @@ -990,7 +988,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) =20 vvfl_v2->vport_id =3D adapter->vsi_res->vsi_id; vvfl_v2->num_elements =3D count; - list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { + list_for_each_entry(f, &adapter->vlan_filter_list, list) { if (f->state =3D=3D IAVF_VLAN_REMOVE) { struct virtchnl_vlan_supported_caps *filtering_support =3D &adapter->vlan_v2_caps.filtering.filtering_support; @@ -1005,9 +1003,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) vlan->tci =3D f->vlan.vid; vlan->tpid =3D f->vlan.tpid; =20 - list_del(&f->list); - kfree(f); - adapter->num_vlan_filters--; + f->state =3D IAVF_VLAN_REMOVING; i++; if (i =3D=3D count) break; @@ -2370,10 +2366,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *a= dapter, ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); wake_up(&adapter->vc_waitqueue); break; - case VIRTCHNL_OP_DEL_VLAN: - dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n", - iavf_stat_str(&adapter->hw, v_retval)); - break; case VIRTCHNL_OP_DEL_ETH_ADDR: dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n", iavf_stat_str(&adapter->hw, v_retval)); @@ -2896,6 +2888,27 @@ void iavf_virtchnl_completion(struct iavf_adapter *a= dapter, spin_unlock_bh(&adapter->mac_vlan_list_lock); } break; + case VIRTCHNL_OP_DEL_VLAN: + case VIRTCHNL_OP_DEL_VLAN_V2: { + struct iavf_vlan_filter *f, *ftmp; + + spin_lock_bh(&adapter->mac_vlan_list_lock); + list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, + list) { + if (f->state =3D=3D IAVF_VLAN_REMOVING) { + if (v_retval) { + /* PF rejected DEL, filter is still in HW */ + f->state =3D IAVF_VLAN_ACTIVE; + } else { + list_del(&f->list); + kfree(f); + adapter->num_vlan_filters--; + } + } + } + spin_unlock_bh(&adapter->mac_vlan_list_lock); + } + break; case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: /* PF enabled vlan strip on this VF. * Update netdev->features if needed to be in sync with ethtool. --=20 2.52.0 From nobody Thu Apr 9 12:07:35 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 373A2364930 for ; Mon, 2 Mar 2026 11:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451654; cv=none; b=ddZDDijOgDOVCtStdRghJ7oTdgUc710pQKilRQHbCdtKahEx3PjhW97k7NlVnK+kbJCGEmfLeX+tzt8JwdrhW6iv6b7CwoaG/KUaOq1ltF3IsITIH5tDC5rXbkzSiudiyzjxN+Pty+KDSOEYZ/KH7wXGGnqUcsHEThWb42cETto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772451654; c=relaxed/simple; bh=aHe7LDf+K8E9ZqlW4z5TwFGHnXHVNwK8jkl8jq649qQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IK047htqKP/rX++Yl4/JEWyNHTOIH+9FlHGDZnAxePEAaPXyN34UwUY5aLlS2Pm0lN52m0UX3u/L9HcevffNZBRBDODh2wUQ1ij1LzxhwtTocmL2aYs0nGXn5qsCp6bhA02EDnArkWiUBUj7UDViBAkP3kvdUNT08bZ5WgyDDNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UserYUUO; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UserYUUO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772451652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GboqBNjOxLnkJWlCgoSfV3V8BCKz0Frnmh0ecySpFw=; b=UserYUUOaHVZkt5v0v5mXwgEA6+/yUJuJ2AjFf7IRgkW1VMYwVRbR3TuK2pb6jiLfWYH3N 5fnnjd5WpvcVvZwKxBjenmCTsf4MXQJvNPJUMSqaHzDL/bqHNTxtWxYfKlg27QDk8ZtCIP JDmqnSIM3ObweXcWs8+xN5tQZGqbof0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-6LHR4HLJPYyz3bgR0kwY0Q-1; Mon, 02 Mar 2026 06:40:49 -0500 X-MC-Unique: 6LHR4HLJPYyz3bgR0kwY0Q-1 X-Mimecast-MFC-AGG-ID: 6LHR4HLJPYyz3bgR0kwY0Q_1772451647 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9915F195608F; Mon, 2 Mar 2026 11:40:47 +0000 (UTC) Received: from ShadowPeak.redhat.com (unknown [10.44.32.50]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 70AEB1955D85; Mon, 2 Mar 2026 11:40:44 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: jacob.e.keller@intel.com, Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC iwl-next 4/4] iavf: harden VLAN filter state machine race handling Date: Mon, 2 Mar 2026 12:40:25 +0100 Message-ID: <20260302114025.1017985-5-poros@redhat.com> In-Reply-To: <20260302114025.1017985-1-poros@redhat.com> References: <20260302114025.1017985-1-poros@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Address remaining race windows in the VLAN filter state machine that were identified during cross-state analysis of ADD and DEL paths. 1. Add VIRTCHNL_OP_ADD_VLAN to the success completion handler. The V1 ADD_VLAN opcode had no success handler -- filters sent via V1 stayed in ADDING state permanently. Add a fallthrough case so V1 filters also transition ADDING -> ACTIVE on PF confirmation. Critically, add an `if (v_retval) break` guard: the error switch in iavf_virtchnl_completion() does NOT return after handling errors, it falls through to the success switch. Without this guard, a PF-rejected ADD would incorrectly mark ADDING filters as ACTIVE, creating a driver/HW mismatch where the driver believes the filter is installed but the PF never accepted it. For V2, this is harmless: iavf_vlan_add_reject() in the error block already kfree'd all ADDING filters, so the success handler finds nothing to transition. 2. Skip DEL on filters already in REMOVING state. In iavf_del_vlan(), if a filter is in IAVF_VLAN_REMOVING (DEL already sent to PF, waiting for response), do not overwrite to REMOVE and schedule a redundant DEL. The pending DEL's completion handler will either kfree the filter (PF confirms) or revert to ACTIVE (PF rejects). Without this, the sequence DEL(pending) -> user-del -> second DEL could result in PF returning an error for the second DEL (filter already gone), causing the completion handler to incorrectly revert a deleted filter back to ACTIVE. Signed-off-by: Petr Oros --- drivers/net/ethernet/intel/iavf/iavf_main.c | 5 ++++- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethe= rnet/intel/iavf/iavf_main.c index 212a23ead20c57..9bcf34f581e748 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -816,11 +816,14 @@ static void iavf_del_vlan(struct iavf_adapter *adapte= r, struct iavf_vlan vlan) list_del(&f->list); kfree(f); adapter->num_vlan_filters--; - } else { + } else if (f->state !=3D IAVF_VLAN_REMOVING) { f->state =3D IAVF_VLAN_REMOVE; iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER); } + /* If REMOVING, DEL is already sent to PF; completion + * handler will free the filter when PF confirms. + */ } =20 spin_unlock_bh(&adapter->mac_vlan_list_lock); diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index 9f2b64bb4ed9e7..d5264e1d5d5699 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -2877,9 +2877,13 @@ void iavf_virtchnl_completion(struct iavf_adapter *a= dapter, spin_unlock_bh(&adapter->adv_rss_lock); } break; + case VIRTCHNL_OP_ADD_VLAN: case VIRTCHNL_OP_ADD_VLAN_V2: { struct iavf_vlan_filter *f; =20 + if (v_retval) + break; + spin_lock_bh(&adapter->mac_vlan_list_lock); list_for_each_entry(f, &adapter->vlan_filter_list, list) { if (f->state =3D=3D IAVF_VLAN_ADDING) --=20 2.52.0