From patchwork Wed Jul 8 10:52:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 73491 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68B1BA00BE; Wed, 8 Jul 2020 04:58:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F374F1DCE2; Wed, 8 Jul 2020 04:58:37 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id D7A3D1DC54 for ; Wed, 8 Jul 2020 04:58:34 +0200 (CEST) IronPort-SDR: r/s70x3O88yapvTBp+e+p0Nyr/NKZFgEnhQHWWEsQg1HHfij6lvcYLqy37IfMCsDjedEy8HO5b KA/rU1vJbxnQ== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="212675579" X-IronPort-AV: E=Sophos;i="5.75,326,1589266800"; d="scan'208";a="212675579" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 19:58:33 -0700 IronPort-SDR: IxzDDGzt0gg8cHrKEtctOig5avtLg9Bk3x4esXe/Bm+kBEIuKxhg5j+on6DZYp2nlANUSYjAxB Alb5J/ZhLl4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,326,1589266800"; d="scan'208";a="268359186" Received: from dpdk-zhirun-dev.sh.intel.com ([10.67.118.152]) by fmsmga008.fm.intel.com with ESMTP; 07 Jul 2020 19:58:31 -0700 From: Zhirun Yan To: qi.z.zhang@intel.com Cc: yahui.cao@intel.com, simei.su@intel.com, xiao.w.wang@intel.com, dev@dpdk.org, Zhirun Yan Date: Wed, 8 Jul 2020 10:52:28 +0000 Message-Id: <20200708105228.43104-1-zhirun.yan@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/ice: add support for src MAC filter on FDIR X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch enables FDIR with src mac filter and change the logic for only supporting ether type field without IP pattern. Application may set ether type with IP. It is redundant for flow, ignore ether type except for ICE_FLTR_PTYPE_NON_IP_L2. Also, remove redundant code for checking next_type. Signed-off-by: Zhirun Yan Acked-by: Qi Zhang Acked-by: Qi Zhang --- drivers/net/ice/ice_fdir_filter.c | 63 +++++++++++++------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index c0f89db83..48d3fdec8 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -19,10 +19,10 @@ #define ICE_FDIR_MAX_QREGION_SIZE 128 #define ICE_FDIR_INSET_ETH (\ - ICE_INSET_ETHERTYPE) + ICE_INSET_DMAC | ICE_INSET_SMAC | ICE_INSET_ETHERTYPE) #define ICE_FDIR_INSET_ETH_IPV4 (\ - ICE_INSET_DMAC | \ + ICE_FDIR_INSET_ETH | \ ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \ ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO) @@ -1620,9 +1620,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; uint32_t vtc_flow_cpu; - - enum rte_flow_item_type next_type; uint16_t ether_type; + enum rte_flow_item_type next_type; for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { if (item->last) { @@ -1640,50 +1639,40 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, eth_mask = item->mask; next_type = (item + 1)->type; - if (next_type == RTE_FLOW_ITEM_TYPE_END && - (!eth_spec || !eth_mask)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, "NULL eth spec/mask."); - return -rte_errno; - } - if (eth_spec && eth_mask) { - if (!rte_is_zero_ether_addr(ð_spec->src) || - !rte_is_zero_ether_addr(ð_mask->src)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "Src mac not support"); - return -rte_errno; - } - - if (rte_is_broadcast_ether_addr(ð_mask->dst)) { + if (!rte_is_zero_ether_addr(ð_mask->dst)) { input_set |= ICE_INSET_DMAC; rte_memcpy(&filter->input.ext_data.dst_mac, - ð_spec->dst, - RTE_ETHER_ADDR_LEN); - } else if (eth_mask->type == RTE_BE16(0xffff)) { + ð_spec->dst, + RTE_ETHER_ADDR_LEN); + } + + if (!rte_is_zero_ether_addr(ð_mask->src)) { + input_set |= ICE_INSET_SMAC; + rte_memcpy(&filter->input.ext_data.src_mac, + ð_spec->src, + RTE_ETHER_ADDR_LEN); + } + + /* Ignore this field except for ICE_FLTR_PTYPE_NON_IP_L2 */ + if (eth_mask->type == RTE_BE16(0xffff) && + next_type == RTE_FLOW_ITEM_TYPE_END) { + input_set |= ICE_INSET_ETHERTYPE; ether_type = rte_be_to_cpu_16(eth_spec->type); + if (ether_type == RTE_ETHER_TYPE_IPV4 || - ether_type == RTE_ETHER_TYPE_IPV6) { + ether_type == RTE_ETHER_TYPE_IPV6) { rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "Unsupported ether_type."); + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported ether_type."); return -rte_errno; } - input_set |= ICE_INSET_ETHERTYPE; rte_memcpy(&filter->input.ext_data.ether_type, - ð_spec->type, - sizeof(eth_spec->type)); + ð_spec->type, + sizeof(eth_spec->type)); flow_type = ICE_FLTR_PTYPE_NON_IP_L2; - } else { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM, - item, - "Invalid dst mac addr mask or ethertype mask"); } } break;