Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10779C61DA4 for ; Thu, 9 Mar 2023 05:10:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8DCED6125F; Thu, 9 Mar 2023 05:10:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8DCED6125F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1678338624; bh=QZ1UT+6QDkNgR+0fQQddjnHbD7v1ZYICS6R34Yn/0hU=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=8r04qOpYrichyTVEC28ZcFb/PpisgoC36AqgUGLxUk/bItb+FYYA9kWas1qvWBZYF gBhAciSeFQoYb59C3M4zMWkl2wRth899QLLb1mYZWN0V9F5MuLd9eOi9r+B1Zdsqj0 1Z5UlUifA1xOPEDXEv3b6Zy/gbozWFhfLNyipYoVVqHRNvbAj4Sov6kwdPiSxhr16S dLppAcngens+58S/aaR6k78zLX9rZHhTeBNkW2bWISfhKM+BZ+mwPea1BUj09Q1JAR mRBwxeJXo0LJ47rXamhaLfgzQ2VYrUpJDr405ZIe3gB7FrHuGG6PXZazpnvhtA9s74 vVfVwu70bTa7w== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tk_RR4KLyMnT; Thu, 9 Mar 2023 05:10:23 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 6ED9B61237; Thu, 9 Mar 2023 05:10:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6ED9B61237 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id C50A01BF2F6 for ; Thu, 9 Mar 2023 05:10:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9C96F41850 for ; Thu, 9 Mar 2023 05:10:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9C96F41850 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7cRO8zpAv0RH for ; Thu, 9 Mar 2023 05:10:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 662BF4184C Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by smtp4.osuosl.org (Postfix) with ESMTPS id 662BF4184C for ; Thu, 9 Mar 2023 05:10:17 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="333823748" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="333823748" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 21:10:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="709710012" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="709710012" Received: from dpdk-jf-ntb-v2.sh.intel.com ([10.67.119.39]) by orsmga001.jf.intel.com with ESMTP; 08 Mar 2023 21:10:15 -0800 From: Junfeng Guo To: intel-wired-lan@lists.osuosl.org Date: Thu, 9 Mar 2023 13:10:11 +0800 Message-Id: <20230309051011.1165676-1-junfeng.guo@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678338617; x=1709874617; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uPEf4F+KXLDuImBHIguuIJ/dzZcRoMQCG48Gcw335UM=; b=Kv5Nz4fLjslqg5o/CYJRzN46ZDE/miZtJ1ryurvd8P1C2SMQUEwon76w qRZ5NkKkHDSDcN8DttHgtwi9AtfjfZ/2jbyyy+qxPJfPe2Bi322jMqpZg pUe3deQgN8EqQJvCgz5sLMNjkRAY8d+f7aD7A93QpULq6h0ZycQSdQdfj ZnmvSA75L0iH2uBz/jMGKUpg2i5MKlQisjh8RvobEoA8fcgOCY9jpLns7 TYLG/TrTQk7K+lWvIQYMw+6vM5Q4kNsUNVpEXgR2HMNYKPW7tB+fLxK62 4Y47SCrQR3qcxXh5ZQOebvrbABdWvInmbaVcSBhU49LosiVGWuemnAbE3 A==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Kv5Nz4fL Subject: [Intel-wired-lan] [PATCH net] ice: add profile conflict check for AVF FDIR X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including: IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP} IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP} For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then. To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check. Fixes: 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF") Signed-off-by: Junfeng Guo --- .../ethernet/intel/ice/ice_virtchnl_fdir.c | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c index e6ef6b303222..1431789c194e 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c @@ -541,6 +541,71 @@ static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) } } +/** + * ice_vc_fdir_has_prof_conflict + * @vf: pointer to the VF structure + * @conf: FDIR configuration for each filter + * + * Check if @conf has conflicting profile with existing profiles + * + * Return: true on success, and false on error. + */ +static bool +ice_vc_fdir_has_prof_conflict(struct ice_vf *vf, + struct virtchnl_fdir_fltr_conf *conf) +{ + struct ice_fdir_fltr *desc; + + list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) { + struct virtchnl_fdir_fltr_conf *existing_conf = + to_fltr_conf_from_desc(desc); + struct ice_fdir_fltr *a = &existing_conf->input; + struct ice_fdir_fltr *b = &conf->input; + + enum ice_fltr_ptype flow_type_a = a->flow_type; + enum ice_fltr_ptype flow_type_b = b->flow_type; + + /* No need to compare two rules with different tunnel type */ + if (existing_conf->ttype != conf->ttype) + continue; + + /* No need to compare two rules with same protocol */ + if (flow_type_a == flow_type_b) + continue; + + switch (flow_type_a) { + case ICE_FLTR_PTYPE_NONF_IPV4_UDP: + case ICE_FLTR_PTYPE_NONF_IPV4_TCP: + case ICE_FLTR_PTYPE_NONF_IPV4_SCTP: + if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) + return true; + break; + case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: + if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_UDP || + flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_TCP || + flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_SCTP) + return true; + break; + case ICE_FLTR_PTYPE_NONF_IPV6_UDP: + case ICE_FLTR_PTYPE_NONF_IPV6_TCP: + case ICE_FLTR_PTYPE_NONF_IPV6_SCTP: + if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_OTHER) + return true; + break; + case ICE_FLTR_PTYPE_NONF_IPV6_OTHER: + if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_UDP || + flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_TCP || + flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_SCTP) + return true; + break; + default: + break; + } + } + + return false; +} + /** * ice_vc_fdir_write_flow_prof * @vf: pointer to the VF structure @@ -677,6 +742,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr, enum ice_fltr_ptype flow; int ret; + ret = ice_vc_fdir_has_prof_conflict(vf, conf); + if (ret) { + dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf->vf_id); + return ret; + } + flow = input->flow_type; ret = ice_vc_fdir_alloc_prof(vf, flow); if (ret) { -- 2.25.1 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan