From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 864A3A056A; Thu, 11 Mar 2021 09:51:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B71840689; Thu, 11 Mar 2021 09:51:35 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 94A544003D for ; Thu, 11 Mar 2021 09:51:33 +0100 (CET) IronPort-SDR: 1L2a7T0jxiSccnLUfn+R8pZ1Zi0CL1vyx8lfyQn0rPtPxsP4tYUJaaXIhpQkk4u4X1hCpT5QUx PnD1cFJXEzdA== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="175748026" X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="175748026" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2021 00:51:28 -0800 IronPort-SDR: gGBmQ/5z1L65YVmEyxXE+5UgWhYKMH1QlHurH6vTMAJKO/gH6YpF5UBCMdivmPft5eOkgkTYUu lNmyjFnqW+Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="377296381" Received: from npg-dpdk-cvl-jeffguo-01.sh.intel.com ([10.67.111.128]) by fmsmga007.fm.intel.com with ESMTP; 11 Mar 2021 00:51:25 -0800 From: Jeff Guo To: qi.z.zhang@intel.com, beilei.xing@intel.com, jingjing.wu@intel.com Cc: yuying.zhang@intel.com, dev@dpdk.org, jia.guo@intel.com Date: Thu, 11 Mar 2021 16:45:47 +0800 Message-Id: <20210311084547.19658-1-jia.guo@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] net/iavf: fix FDIR configure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The refine configure of TCP/UDP flow item should not affact other flow configure which not include L4 layer. Fix and clean the refinement function. Fixes: 61abc5f611a0 ("net/iavf: support TCP/UDP flow item without input set") Signed-off-by: Jeff Guo --- drivers/net/iavf/iavf_fdir.c | 54 +++++++++++++----------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index 4e864b4b9c..d057fc515d 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -456,35 +456,16 @@ iavf_fdir_parse_action(struct iavf_adapter *ad, return 0; } -static bool -iavf_fdir_refine_input_set(const uint64_t input_set, - const uint64_t input_set_mask, - struct iavf_fdir_conf *filter) +#define IAVF_IPPROTO_TCP 6 +#define IAVF_IPPROTO_UDP 17 + +static void +iavf_fdir_refine_proto_hdr(struct virtchnl_proto_hdr *hdr, + uint8_t proto_id) { - struct virtchnl_proto_hdr *hdr, *hdr_last; struct rte_flow_item_ipv4 ipv4_spec; struct rte_flow_item_ipv6 ipv6_spec; - int last_layer; - uint8_t proto_id; - - if (input_set & ~input_set_mask) - return false; - else if (input_set) - return true; - - last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1; - /* Last layer of TCP/UDP pattern isn't less than 2. */ - if (last_layer < 2) - return false; - hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer]; - if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP) - proto_id = 6; - else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP) - proto_id = 17; - else - return false; - hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1]; switch (hdr->type) { case VIRTCHNL_PROTO_HDR_IPV4: VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT); @@ -492,17 +473,19 @@ iavf_fdir_refine_input_set(const uint64_t input_set, ipv4_spec.hdr.next_proto_id = proto_id; rte_memcpy(hdr->buffer, &ipv4_spec.hdr, sizeof(ipv4_spec.hdr)); - return true; + break; case VIRTCHNL_PROTO_HDR_IPV6: VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT); memset(&ipv6_spec, 0, sizeof(ipv6_spec)); ipv6_spec.hdr.proto = proto_id; rte_memcpy(hdr->buffer, &ipv6_spec.hdr, sizeof(ipv6_spec.hdr)); - return true; + break; default: - return false; + break; } + + return; } static int @@ -530,6 +513,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask; struct rte_ecpri_common_hdr ecpri_common; uint64_t input_set = IAVF_INSET_NONE; + uint8_t proto_id; enum rte_flow_item_type next_type; uint16_t ether_type; @@ -746,6 +730,9 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, sizeof(udp_spec->hdr)); } + proto_id = IAVF_IPPROTO_UDP; + iavf_fdir_refine_proto_hdr(&filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer - 1], proto_id); + filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer; break; @@ -790,6 +777,9 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, sizeof(tcp_spec->hdr)); } + proto_id = IAVF_IPPROTO_TCP; + iavf_fdir_refine_proto_hdr(&filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer - 1], proto_id); + filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer; break; @@ -1016,12 +1006,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, return -rte_errno; } - if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, - "Invalid input set"); - return -rte_errno; - } + if (input_set & ~input_set_mask) + return -EINVAL; filter->input_set = input_set; -- 2.20.1