From patchwork Tue Dec 1 08:32:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yuying" X-Patchwork-Id: 84653 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 25D96A04DB; Tue, 1 Dec 2020 09:37:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C519C982; Tue, 1 Dec 2020 09:37:27 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B3E0EC956 for ; Tue, 1 Dec 2020 09:37:25 +0100 (CET) IronPort-SDR: 6gPy6TOczkliNjWpu1msq9a/nHZIuueBDdJO7m8gLPcSVOMib7uHyHMijPbSiG9xY6h/OcA2W/ FPf0gKrg2u0A== X-IronPort-AV: E=McAfee;i="6000,8403,9821"; a="169290026" X-IronPort-AV: E=Sophos;i="5.78,384,1599548400"; d="scan'208";a="169290026" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2020 00:37:23 -0800 IronPort-SDR: mGsKYMIWyF5CQavf4P3Uva9qbwgTh1BcdNhaypa0PLFUhzJi3LjEMxwxQvEPURo1oKYcLWYnz8 ZRMKKCxZFgMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,384,1599548400"; d="scan'208";a="481016456" Received: from dpdk-yyzhang2.sh.intel.com ([10.67.117.129]) by orsmga004.jf.intel.com with ESMTP; 01 Dec 2020 00:37:21 -0800 From: Yuying Zhang To: dev@dpdk.org, qi.z.zhang@intel.com, jingjing.wu@intel.com Cc: Yuying Zhang Date: Tue, 1 Dec 2020 08:32:07 +0000 Message-Id: <20201201083207.70668-1-yuying.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1] net/iavf: support FDIR TCP/UDP pattern without input set 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 adds an input set refinement function to support outer and inner TCP/UDP patterns without input set for flow director filter. Signed-off-by: Yuying Zhang Acked-by: Qi Zhang --- drivers/net/iavf/iavf_fdir.c | 67 ++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index 7054bde0b..2c57313e4 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -448,9 +448,56 @@ iavf_fdir_parse_action(struct iavf_adapter *ad, return 0; } +static int +iavf_fdir_refine_input_set(const uint64_t input_set, + const uint64_t input_set_mask, + struct iavf_fdir_conf *filter) +{ + 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 -rte_errno; + else if (input_set) + return 0; + + last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1; + 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 -rte_errno; + + 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); + memset(&ipv4_spec, 0, sizeof(ipv4_spec)); + ipv4_spec.hdr.next_proto_id = proto_id; + rte_memcpy(hdr->buffer, &ipv4_spec.hdr, + sizeof(ipv4_spec.hdr)); + return 0; + 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 0; + default: + return -rte_errno; + } +} + static int iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, const struct rte_flow_item pattern[], + const uint64_t input_set_mask, struct rte_flow_error *error, struct iavf_fdir_conf *filter) { @@ -924,6 +971,13 @@ 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; + } + filter->input_set = input_set; return 0; @@ -941,7 +995,6 @@ iavf_fdir_parse(struct iavf_adapter *ad, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); struct iavf_fdir_conf *filter = &vf->fdir.conf; struct iavf_pattern_match_item *item = NULL; - uint64_t input_set; int ret; memset(filter, 0, sizeof(*filter)); @@ -950,19 +1003,11 @@ iavf_fdir_parse(struct iavf_adapter *ad, if (!item) return -rte_errno; - ret = iavf_fdir_parse_pattern(ad, pattern, error, filter); + ret = iavf_fdir_parse_pattern(ad, pattern, item->input_set_mask, + error, filter); if (ret) goto error; - input_set = filter->input_set; - if (!input_set || input_set & ~item->input_set_mask) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, - "Invalid input set"); - ret = -rte_errno; - goto error; - } - ret = iavf_fdir_parse_action(ad, actions, error, filter); if (ret) goto error;