From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796195863; b=Pju3x104UBy7CAXqFGiZcFs2oASCPXVqn+0uCpQz45j7Xvo1XRKuLvMiR/ADGsKbFnp+ JW5acDyR56+SvbWH6a5amuNZv+c+R4spjrVO5SFw6AvzAxrMpptq1P3FapUE421ARfVPs rsv2rjWNt+uq70x488CyrEkz7+v9Y4cenUGTRNlL0mhq0LpGU4z6Zq1m8iIwhO8ATmp7E vPBUMG5tenydmA4SpSiYeP5MJ//lFtPZtWJKB4Vuyt36CejHzizsRJF4Oi5YiObKBTLg/ DA+PiQahKGDp1UWnevPP71sEQWko8pKoS3SoySecQ/NHj2FLhhdLl/O5uWJz8Y5n61w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796195863; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=PAQCnQyGemj3e+gWd4mz3pq8r5fZBDK6TfwrbAMidk8=; b=kMn+DwlcRCvvxHSQ0H7C6CeSyn/6keZrooONxoQZNsiHcH0F32cPLfVZlKXOPpao9iV3 8qnurZX7AUUW/wIy572w6fPWHVxOC39TkgErs+mlqvg0CBTXuVJ/ieGuKRoQvhw/d5VPu 9zGjjrsZryjKs69n50+APMPFP7RICPYFDq300Ve7bZdGLDYWekSWNJqCduNh/eQBJcViL TbVdNqtVCeXQa9PAPwf4YLhVs/n9Xv0NEPNOP5sV1wauSJSBA7uAZXPKweGmcE6ZjoUmY K/0qifu3MTftVusITJd4TXX3Qnl6D1KtAmBVhyw9t4Yf2JOyvflRSR9x48EkTFh+JCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hi56eEGy; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17376606A33A for ; Wed, 2 Dec 2026 07:17:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 17376606A33A 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.a=rsa-sha256 header.s=mimecast20190719 header.b=hi56eEGy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796195863; 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=PAQCnQyGemj3e+gWd4mz3pq8r5fZBDK6TfwrbAMidk8=; b=hi56eEGy52dnDQdrcuacodkryVrN+dOkPXpk9kuToRIr4J2tjt+1tj8xpvX7yd1cG7/PiX BoW/N0GG7L88Ml4CoAI3EsxVt5n0g5SoEGsuHa6fwhSUGHjsrzF3TtgsyLS+NhjwtmMX0o sR64XvvCOaZpkInaEfaZkm3lVE6T9sY= 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-31-zwRR6zgSPlqSFBnFYNTXcw-1; Wed, 2 Dec 2026 07:17:13 +0000 X-MC-Unique: zwRR6zgSPlqSFBnFYNTXcw-1 X-Mimecast-MFC-AGG-ID: zwRR6zgSPlqSFBnFYNTXcw_1796195831 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 D71F91828B2C; Wed, 2 Dec 2026 07:17:10 +0000 (UTC) Received: from poros-thinkpadp16vgen1.tpbc.com (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B189A18088A5; Wed, 2 Dec 2026 07:17:04 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Aleksandr Loktionov , Simon Horman , Michal Swiatkowski , Grzegorz Nitka , Paul Menzel , Wojciech Drewek , Marcin Szycik , Martyna Szapar-Mudlaw , Ivan Vecera , Alice Michael , Jacob Keller , Jesse Brandeburg , Patryk Holda , Rinitha S , Aaron Ma , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session Date: Wed, 2 Dec 2026 08:16:39 +0100 Message-ID: <20261202071642.2527605-4-poros@redhat.com> In-Reply-To: <20261202071642.2527605-1-poros@redhat.com> References: <20261202071642.2527605-1-poros@redhat.com> 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 A switchdev session leaves the uplink filters out of sync with its netdev. ice_eswitch_setup_env() removes the multicast promisc rules, and ice_eswitch_release_env() removes the default VSI (DFLT) Rx rule that a promiscuous uplink needs. ice_set_rx_mode() ignores the uplink during the session and nothing syncs it when the session ends, so these rules are not installed again, and flag changes made meanwhile are lost. Let the eswitch own the uplink promisc configuration during a session. While the new ICE_VSI_ESWITCH_UPLINK bit is set, ice_vsi_sync_fltr() leaves the promisc configuration of the uplink alone. Its address list filters are still installed again during a session that starts with the uplink up, an older behavior this patch does not change. When the session ends, after is_running is cleared, ice_eswitch_resync_uplink() clears the bit and queues a full filter sync, which programs the uplink from the netdev flags. As before this patch, nothing retries a failed promisc step on its own. A full barrier in ice_set_rx_mode() orders the flag change of its caller before the is_running test, so a change made while the session ends is not lost. The is_running accesses use READ_ONCE() and WRITE_ONCE(), they are read locklessly in the Tx path. ice_vsi_sync_fltr() releases ICE_CFG_BUSY with clear_bit_unlock() now, like the new sections, so the stores it makes in its section are ordered before the next one takes the bit. ice_eswitch_setup_env() drops a filter sync that is still pending, so a session that a reset creates again does not run the sync queued when the old one ended. Also subscribe a promiscuous VSI to multicast when it already holds the DFLT rule, and enable VLAN pruning on every promisc off, because it can be off without our DFLT rule after a session or with LAG. When the driver is removed during a session, the session ends in ice_remove(), and the sync queued there needs "ice: stop the service task before the PF is unloaded". This does not restore the uplink VLAN filters that ice_eswitch_setup_env() removes, a separate problem that now also shows when promisc is cleared after a promiscuous session. It does not change the unicast filter that ice_eswitch_release_env() adds back either, which is for the permanent MAC address even if the PF uses another one. Found by AI code review, starting with the Sashiko review of v4, and reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes: ip link set $PF promisc on devlink dev eswitch set pci/$BDF mode switchdev echo 1 > /sys/class/net/$PF/device/sriov_numvfs echo 0 > /sys/class/net/$PF/device/sriov_numvfs after which unknown unicast no longer reaches the PF, and with this patch it does again. Also tested on that E810-C with promisc changed before, during and after sessions, allmulti across a session, and PF resets and driver removal during sessions. LAG and switchdev setup errors were not tested. No kernel selftests cover this. Fixes: 1a1c40df2e80 ("ice: set and release switchdev environment") Fixes: 2571a3fa6251 ("ice: Prohibit rx mode change in switchdev mode") Fixes: 5c07be96d8b3 ("ice: Avoid setting default Rx VSI twice in switchdev setup") Fixes: 776fe19953b0 ("ice: block default rule setting on LAG interface") Signed-off-by: Petr Oros --- v7: - The is_running accesses use READ_ONCE() and WRITE_ONCE(), and ice_vsi_sync_fltr() releases ICE_CFG_BUSY with clear_bit_unlock(), like the new sections. v6: - ice_eswitch_setup_env() drops a pending filter sync, so a session that a reset creates again does not run the sync queued at the end of the old one. - Full barrier in ice_set_rx_mode() before the is_running test. - The message no longer counts the address filters among what a session leaves uninstalled, it says that the address list filters of a session that starts with the uplink up are still installed again and that nothing retries a failed promisc step on its own, and it names the dependency on patch 1 and the permanent MAC address filter. - Dropped Ivan's Reviewed-by because of the code changes. All after the Sashiko reviews of v5. v6: https://lore.kernel.org/all/20261130132107.1177185-4-poros@redhat.com/ v5: https://lore.kernel.org/all/20261127085714.1207361-4-poros@redhat.com/ v4: https://lore.kernel.org/all/20260708125755.706263-3-poros@redhat.com/ v3: https://lore.kernel.org/all/20260701133601.2118382-3-poros@redhat.com/ v2: https://lore.kernel.org/all/20260622113428.2565255-3-poros@redhat.com/ v1: https://lore.kernel.org/all/deef5756e534ef06c12d910c5305d3fd205d30a0.1781786935.git.poros@redhat.com/ --- drivers/net/ethernet/intel/ice/ice.h | 3 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 49 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_main.c | 28 +++++++++-- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 432da05c48c08a..39e261f216b561 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -321,6 +321,7 @@ enum ice_vsi_state { ICE_VSI_MMAC_FLTR_CHANGED, ICE_VSI_PROMISC_CHANGED, ICE_VSI_REBUILD_PENDING, + ICE_VSI_ESWITCH_UPLINK, /* eswitch owns the promisc config */ ICE_VSI_STATE_NBITS /* must be last */ }; @@ -931,7 +932,7 @@ static inline struct ice_vsi *ice_find_vsi(struct ice_pf *pf, u16 vsi_num) */ static inline bool ice_is_switchdev_running(struct ice_pf *pf) { - return pf->eswitch.is_running; + return READ_ONCE(pf->eswitch.is_running); } #define ICE_FD_STAT_CTR_BLOCK_COUNT 256 diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c index 44ef1fcfc6e4a5..e91f126bc8a67d 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c @@ -10,6 +10,34 @@ #include "devlink/devlink.h" #include "ice_tc_lib.h" +/** + * ice_eswitch_resync_uplink - hand the uplink filters back after switchdev + * @uplink_vsi: the uplink VSI + */ +static void ice_eswitch_resync_uplink(struct ice_vsi *uplink_vsi) +{ + struct ice_pf *pf = uplink_vsi->back; + + while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state)) + usleep_range(1000, 2000); + + /* VLAN changes during the session may have added these */ + ice_fltr_clear_vlan_vsi_promisc(&pf->hw, uplink_vsi, + ICE_MCAST_VLAN_PROMISC_BITS); + ice_fltr_clear_vsi_promisc(&pf->hw, uplink_vsi->idx, + ICE_MCAST_PROMISC_BITS, 0); + uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI; + + clear_bit(ICE_VSI_ESWITCH_UPLINK, uplink_vsi->state); + set_bit(ICE_VSI_PROMISC_CHANGED, uplink_vsi->state); + set_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state); + set_bit(ICE_VSI_MMAC_FLTR_CHANGED, uplink_vsi->state); + clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state); + + set_bit(ICE_FLAG_FLTR_SYNC, pf->flags); + ice_service_task_schedule(pf); +} + /** * ice_eswitch_setup_env - configure eswitch HW filters * @pf: pointer to PF struct @@ -28,6 +56,15 @@ static int ice_eswitch_setup_env(struct ice_pf *pf) if (ice_down(uplink_vsi)) return -ENODEV; + /* the eswitch owns the uplink promisc config until the resync */ + while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state)) + usleep_range(1000, 2000); + set_bit(ICE_VSI_ESWITCH_UPLINK, uplink_vsi->state); + /* drop a pending sync, the address lists are unsynced below */ + clear_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state); + clear_bit(ICE_VSI_MMAC_FLTR_CHANGED, uplink_vsi->state); + clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state); + ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx); ice_vsi_cfg_sw_lldp(uplink_vsi, true, false); @@ -77,6 +114,8 @@ static int ice_eswitch_setup_env(struct ice_pf *pf) if (if_running) ice_up(uplink_vsi); + ice_eswitch_resync_uplink(uplink_vsi); + return -ENODEV; } @@ -312,12 +351,13 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf) netif_keep_dst(uplink_vsi->netdev); - pf->eswitch.is_running = true; + WRITE_ONCE(pf->eswitch.is_running, true); return 0; err_br_offloads: ice_eswitch_release_env(pf); + ice_eswitch_resync_uplink(uplink_vsi); return -ENODEV; } @@ -330,7 +370,12 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf) ice_eswitch_br_offloads_deinit(pf); ice_eswitch_release_env(pf); - pf->eswitch.is_running = false; + WRITE_ONCE(pf->eswitch.is_running, false); + + /* after is_running is cleared, so no rx mode change is lost, its + * test_and_set_bit() pairs with smp_mb() in ice_set_rx_mode() + */ + ice_eswitch_resync_uplink(pf->eswitch.uplink_vsi); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index b05eda1bf50ae7..3230ee88fafcba 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -394,6 +394,10 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) } } err = 0; + /* the eswitch owns the uplink promisc config during a session */ + if (test_bit(ICE_VSI_ESWITCH_UPLINK, vsi->state)) + goto exit; + /* check for changes in promiscuous modes */ if (changed_flags & IFF_ALLMULTI) { if (vsi->current_netdev_flags & IFF_ALLMULTI) { @@ -438,6 +442,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) ICE_MCAST_PROMISC_BITS); if (err) goto out_promisc; + } else if (ice_is_vsi_dflt_vsi(vsi)) { + /* still the default VSI, so subscribe it */ + err = ice_set_promisc(vsi, + ICE_MCAST_PROMISC_BITS); + if (err) + goto out_promisc; } } else { /* Clear Rx filter to remove traffic from wire */ @@ -450,11 +460,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) IFF_PROMISC; goto out_promisc; } - if (vsi->netdev->features & - NETIF_F_HW_VLAN_CTAG_FILTER) - vlan_ops->ena_rx_filtering(vsi); } + /* pruning can be off even without our DFLT rule */ + if (vsi->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) + vlan_ops->ena_rx_filtering(vsi); + /* disable allmulti here, but only if allmulti is not * still enabled for the netdev */ @@ -478,7 +489,7 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi) set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); exit: - clear_bit(ICE_CFG_BUSY, vsi->state); + clear_bit_unlock(ICE_CFG_BUSY, vsi->state); return err; } @@ -6054,7 +6065,14 @@ static void ice_set_rx_mode(struct net_device *netdev) struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_vsi *vsi = np->vsi; - if (!vsi || ice_is_switchdev_running(vsi->back)) + if (!vsi) + return; + + /* order the flag change of the caller before the is_running test, + * pairs with test_and_set_bit() in ice_eswitch_resync_uplink() + */ + smp_mb(); + if (ice_is_switchdev_running(vsi->back)) return; /* Set the flags to synchronize filters -- 2.56.1