{"id":2227310,"url":"http://patchwork.ozlabs.org/api/patches/2227310/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260423130405.139568-5-jtornosm@redhat.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260423130405.139568-5-jtornosm@redhat.com>","list_archive_url":null,"date":"2026-04-23T13:04:05","name":"[net,v4,4/4] ice: skip unnecessary VF reset when setting trust","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a9e00ee88ce05244879d69d8321ffe17123d2fee","submitter":{"id":93070,"url":"http://patchwork.ozlabs.org/api/people/93070/?format=json","name":"Jose Ignacio Tornos Martinez","email":"jtornosm@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260423130405.139568-5-jtornosm@redhat.com/mbox/","series":[{"id":501193,"url":"http://patchwork.ozlabs.org/api/series/501193/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=501193","date":"2026-04-23T13:04:02","name":"Fix i40e/ice/iavf VF bonding after netdev lock changes","version":4,"mbox":"http://patchwork.ozlabs.org/series/501193/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2227310/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2227310/checks/","tags":{},"related":[],"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256\n header.s=default header.b=Dic1PCFn;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1bsn3gsnz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 23:05:01 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 2A177402D2;\n\tThu, 23 Apr 2026 13:05:00 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id abcjq20h5Inr; Thu, 23 Apr 2026 13:04:59 +0000 (UTC)","from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 6A7284030F;\n\tThu, 23 Apr 2026 13:04:59 +0000 (UTC)","from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])\n by lists1.osuosl.org (Postfix) with ESMTP id 676F6206\n for <intel-wired-lan@lists.osuosl.org>; Thu, 23 Apr 2026 13:04:57 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp3.osuosl.org (Postfix) with ESMTP id 4CC7E6059E\n for <intel-wired-lan@lists.osuosl.org>; Thu, 23 Apr 2026 13:04:57 +0000 (UTC)","from smtp3.osuosl.org ([127.0.0.1])\n by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id Fw6et_B1HjwT for <intel-wired-lan@lists.osuosl.org>;\n Thu, 23 Apr 2026 13:04:51 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp3.osuosl.org (Postfix) with ESMTPS id 8C76960B36\n for <intel-wired-lan@lists.osuosl.org>; Thu, 23 Apr 2026 13:04:51 +0000 (UTC)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-380-gryGd0IUPd6ToVTN0eyAgA-1; Thu,\n 23 Apr 2026 09:04:45 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 76A0A1935303; Thu, 23 Apr 2026 13:04:42 +0000 (UTC)","from fedora.redhat.com (unknown [10.44.32.35])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 4036E19560AB; Thu, 23 Apr 2026 13:04:37 +0000 (UTC)"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections - client-ip=140.211.166.142;\n helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6A7284030F","OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8C76960B36"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org;\n\ts=default; t=1776949499;\n\tbh=hNxPm0l1Sh7y0ewMYZbtJKVp2OY0iO3QRahnfY38HjY=;\n\th=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id:\n\t List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\t From;\n\tb=Dic1PCFnkIqc8/o4L0GztUAM41HrVUqBc4Iult0Jfi1yGZ1bdI4MIybB5FupQuUCx\n\t Xr9yOPBX3esKzUbMTYxCyWj0B38z/z40Hr1XXE7P/glL/JVt1ZW+9u0nAWLA9Bpiol\n\t ZVaI41IDVwpG4JfyPsvY7WVoXIURHDYli+HpcU6B54cF5nfYJ13BGatRRi57JIZJND\n\t 6d89lS0B5KPqV4xctxPhu3UoP/2egeCLvYpWAcuqgEHjtol+fokQy669EtU1ZEttdW\n\t 45DGe9hlRgiZk2tAEqrgZyV3rpYSVGFln1qL2QYDXjEMqXI/4nKmjpb1VWd6PZ4fuW\n\t XT9HOtP4PLHwg==","Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=jtornosm@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp3.osuosl.org 8C76960B36","X-MC-Unique":"gryGd0IUPd6ToVTN0eyAgA-1","X-Mimecast-MFC-AGG-ID":"gryGd0IUPd6ToVTN0eyAgA_1776949482","From":"Jose Ignacio Tornos Martinez <jtornosm@redhat.com>","To":"netdev@vger.kernel.org","Cc":"intel-wired-lan@lists.osuosl.org, przemyslaw.kitszel@intel.com,\n aleksandr.loktionov@intel.com, jacob.e.keller@intel.com, horms@kernel.org,\n jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com,\n davem@davemloft.net, edumazet@google.com, kuba@kernel.org,\n pabeni@redhat.com, Jose Ignacio Tornos Martinez <jtornosm@redhat.com>","Date":"Thu, 23 Apr 2026 15:04:05 +0200","Message-ID":"<20260423130405.139568-5-jtornosm@redhat.com>","In-Reply-To":"<20260423130405.139568-1-jtornosm@redhat.com>","References":"<20260423130405.139568-1-jtornosm@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","X-Mimecast-MFC-PROC-ID":"MnXGOP_7jSAfP4xv52G9WYWht6ia3YVFK0AP_wncd-I_1776949482","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-Mailman-Original-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com;\n s=mimecast20190719; t=1776949490;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=hNxPm0l1Sh7y0ewMYZbtJKVp2OY0iO3QRahnfY38HjY=;\n b=Elh+3OeFvqIl4ZvNclOeZV6aLq5o0L1YxG0mKp0ylv1r9Xm7dGcfnrAexI7xoZRo/sKMEx\n hL9+7MK+KfEDhFQsFjL85jdILYJ1bBIvfc7xBcZZCwoJNegZCq7axBESxgOm/woj+DNrKm\n E76nSZOrc0HLyHjfhbQKPdHT2Z8zqok=","X-Mailman-Original-Authentication-Results":["smtp3.osuosl.org;\n dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","smtp3.osuosl.org;\n dkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Elh+3OeF"],"Subject":"[Intel-wired-lan] [PATCH net v4 4/4] ice: skip unnecessary VF reset\n when setting trust","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"Similar to the i40e fix, ice_set_vf_trust() unconditionally calls\nice_reset_vf() when the trust setting changes. While the delay is smaller\nthan i40e this reset is still unnecessary in most cases.\n\nAdditionally, the original code has a race condition: it deletes MAC LLDP\nfilters BEFORE resetting the VF. During this deletion, the VF is still\nACTIVE and can add new MAC LLDP filters concurrently, potentially\ncorrupting the filter list.\n\nWhen granting trust, no reset is needed - we can just set the capability\nflag to allow privileged operations.\n\nWhen revoking trust, we need to:\n1. Clear the capability flag to block privileged operations\n2. Disable promiscuous mode if it was enabled (trusted VFs can enable it)\n3. Only reset if MAC LLDP filters exist (to clean them up)\n\nWhen we do reset (MAC LLDP case), we fix the race condition by resetting\nfirst to clear VF state (which blocks new MAC LLDP filter additions), then\ndelete existing filters safely. During cleanup, vf->trusted remains true so\nice_vf_is_lldp_ena() works properly. Only after cleanup do we set\nvf->trusted = false.\n\nWhen we don't reset, we manually handle capability flag and promiscuous\nmode via helper function.\n\nThe ice driver already has logic to clean up MAC LLDP filters when\nremoving trust. After this cleanup, the VF reset is only necessary if\nthere were actually filters to remove (num_mac_lldp was non-zero).\n\nThis saves time and eliminates unnecessary service disruption when\nchanging VF trust settings in most cases, while properly handling filter\ncleanup.\n\nFixes: 2296345416b0 (\"ice: receive LLDP on trusted VFs\")\nSigned-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>\n---\nv4:\n    - Address AI review (sashiko.dev) from Simon Horman:\n      vf->trusted ordering bug\n    - Fix upstream race condition when comparing with i40e code\n    - Apply capability flag and promiscuous mode fixes from i40e AI review\n    - Add helper function ice_setup_vf_trust() for non-reset path\n    - Export ice_vf_clear_all_promisc_modes() for code reuse \nv3: https://lore.kernel.org/all/20260414110006.124286-5-jtornosm@redhat.com/\n\n drivers/net/ethernet/intel/ice/ice_sriov.c  | 41 +++++++++++++++++++--\n drivers/net/ethernet/intel/ice/ice_vf_lib.c |  2 +-\n drivers/net/ethernet/intel/ice/ice_vf_lib.h |  1 +\n 3 files changed, 39 insertions(+), 5 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c\nindex 7e00e091756d..d0da7f6adc23 100644\n--- a/drivers/net/ethernet/intel/ice/ice_sriov.c\n+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c\n@@ -1364,6 +1364,34 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)\n \treturn __ice_set_vf_mac(ice_netdev_to_pf(netdev), vf_id, mac);\n }\n \n+/**\n+ * ice_setup_vf_trust - Enable/disable VF trust mode without reset\n+ * @vf: VF to configure\n+ * @setting: trust setting\n+ *\n+ * Manually handle capability flag and promiscuous mode when changing trust\n+ * without performing a VF reset.\n+ * When reset is performed, this is not necessary as the reset procedure\n+ * already handles this.\n+ **/\n+static void ice_setup_vf_trust(struct ice_vf *vf, bool setting)\n+{\n+\tstruct ice_vsi *vsi;\n+\n+\tif (setting) {\n+\t\tset_bit(ICE_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);\n+\t} else {\n+\t\tclear_bit(ICE_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);\n+\n+\t\tif (test_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states) ||\n+\t\t    test_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) {\n+\t\t\tvsi = ice_get_vf_vsi(vf);\n+\t\t\tif (vsi)\n+\t\t\t\tice_vf_clear_all_promisc_modes(vf, vsi);\n+\t\t}\n+\t}\n+}\n+\n /**\n  * ice_set_vf_trust\n  * @netdev: network interface device structure\n@@ -1399,11 +1427,16 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)\n \n \tmutex_lock(&vf->cfg_lock);\n \n-\twhile (!trusted && vf->num_mac_lldp)\n-\t\tice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false);\n-\n+\t/* Reset only if revoking trust with MAC LLDP filters */\n+\tif (!trusted && vf->num_mac_lldp) {\n+\t\tice_reset_vf(vf, ICE_VF_RESET_NOTIFY);\n+\t\twhile (vf->num_mac_lldp)\n+\t\t\tice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false);\n+\t} else {\n+\t\tice_setup_vf_trust(vf, trusted);\n+\t}\n \tvf->trusted = trusted;\n-\tice_reset_vf(vf, ICE_VF_RESET_NOTIFY);\n+\n \tdev_info(ice_pf_to_dev(pf), \"VF %u is now %strusted\\n\",\n \t\t vf_id, trusted ? \"\" : \"un\");\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c\nindex c8bc952f05cd..81bbf30e5c29 100644\n--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c\n+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c\n@@ -623,7 +623,7 @@ ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,\n  *\n  * Clear all promiscuous/allmulticast filters for a VF\n  */\n-static int\n+int\n ice_vf_clear_all_promisc_modes(struct ice_vf *vf, struct ice_vsi *vsi)\n {\n \tstruct ice_pf *pf = vf->pf;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h\nindex 7a9c75d1d07c..a3501bd92311 100644\n--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h\n+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h\n@@ -310,6 +310,7 @@ bool ice_is_any_vf_in_unicast_promisc(struct ice_pf *pf);\n void\n ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,\n \t\t\t u8 *ucast_m, u8 *mcast_m);\n+int ice_vf_clear_all_promisc_modes(struct ice_vf *vf, struct ice_vsi *vsi);\n int\n ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);\n int\n","prefixes":["net","v4","4/4"]}