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 8C4EDA0501; Fri, 8 Apr 2022 11:12:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B03B8427ED; Fri, 8 Apr 2022 11:12:16 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 9BB724003F for ; Fri, 8 Apr 2022 11:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649409132; x=1680945132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nEOZophGGsjvDkLH9gPASlA7vBv4R9F7U1O68BvK2LY=; b=E1W3D5TjTZHN6a+V5wco8CXMDWlHiWzTJj8uqyEJdKYhbSN7O3SWIjxw 41jkyk9wifIy3FBe+PD+kqya3Gb8HPKzKWObSvvPd9KER9ZkU2Fl3lrsa YkjEwb8pNN4Qloq0CWbIlmmYDyzZasVA0C9GN4pK9TRptssIfxub+2WQp 5AIHLzC+pwtU9WDx5j0IiE4HnBVw3bwOAY3AMRO3cpbdUzu8HuT7Ff3Qh vz2gsATjKwfGt5JUlAGD7tlKbeJpn30dbIQv5vcKM2iwRKhyHPr+SVd/Q aG8HAjqp1ibfjXlG+leY7EAYTOxxzdnm0A91PVE1I8AVcSHhWvussy89F Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="286539912" X-IronPort-AV: E=Sophos;i="5.90,244,1643702400"; d="scan'208";a="286539912" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 02:12:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,244,1643702400"; d="scan'208";a="723322874" Received: from dpdk-jf-ntb-v2.sh.intel.com ([10.67.119.111]) by orsmga005.jf.intel.com with ESMTP; 08 Apr 2022 02:12:10 -0700 From: Junfeng Guo To: qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com Cc: dev@dpdk.org, junfeng.guo@intel.com Subject: [PATCH v3 3/3] net/iavf: enable Protocol Agnostic Flow Offloading FDIR Date: Fri, 8 Apr 2022 17:12:18 +0800 Message-Id: <20220408091218.240922-4-junfeng.guo@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220408091218.240922-1-junfeng.guo@intel.com> References: <20220408080245.173253-4-junfeng.guo@intel.com> <20220408091218.240922-1-junfeng.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This patch enabled Protocol Agnostic Flow Offloading FDIR in AVF. Signed-off-by: Junfeng Guo --- doc/guides/rel_notes/release_22_07.rst | 4 ++ drivers/net/iavf/iavf_fdir.c | 67 ++++++++++++++++++++++++++ drivers/net/iavf/iavf_generic_flow.c | 6 +++ drivers/net/iavf/iavf_generic_flow.h | 3 ++ 4 files changed, 80 insertions(+) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 42a5f2d990..43eab0b6d5 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Intel iavf driver.** + + * Added Protocol Agnostic Flow Offloading support in AVF Flow Director. + Removed Items ------------- diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index e9a3566c0d..f236260502 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -194,6 +194,7 @@ IAVF_INSET_TUN_TCP_DST_PORT) static struct iavf_pattern_match_item iavf_fdir_pattern[] = { + {iavf_pattern_raw, IAVF_INSET_NONE, IAVF_INSET_NONE}, {iavf_pattern_ethertype, IAVF_FDIR_INSET_ETH, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4, IAVF_FDIR_INSET_ETH_IPV4, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_udp, IAVF_FDIR_INSET_ETH_IPV4_UDP, IAVF_INSET_NONE}, @@ -720,6 +721,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, struct virtchnl_proto_hdrs *hdrs = &filter->add_fltr.rule_cfg.proto_hdrs; enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END; + const struct rte_flow_item_raw *raw_spec, *raw_mask; const struct rte_flow_item_eth *eth_spec, *eth_mask; const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask; const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask; @@ -746,6 +748,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, enum rte_flow_item_type next_type; uint8_t tun_inner = 0; uint16_t ether_type, flags_version; + uint8_t item_num = 0; int layer = 0; uint8_t ipv6_addr_mask[16] = { @@ -763,8 +766,72 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, RTE_FLOW_ERROR_TYPE_ITEM, item, "Not support range"); } + item_num++; switch (item_type) { + case RTE_FLOW_ITEM_TYPE_RAW: { + raw_spec = item->spec; + raw_mask = item->mask; + + if (item_num != 1) + return -rte_errno; + + if (raw_spec->length != raw_mask->length) + return -rte_errno; + + uint16_t pkt_len = 0; + uint16_t tmp_val = 0; + uint8_t tmp = 0; + int i, j; + + pkt_len = raw_spec->length; + + for (i = 0, j = 0; i < pkt_len; i += 2, j++) { + tmp = raw_spec->pattern[i]; + if (tmp >= 'a' && tmp <= 'f') + tmp_val = tmp - 'a' + 10; + if (tmp >= 'A' && tmp <= 'F') + tmp_val = tmp - 'A' + 10; + if (tmp >= '0' && tmp <= '9') + tmp_val = tmp - '0'; + + tmp_val *= 16; + tmp = raw_spec->pattern[i + 1]; + if (tmp >= 'a' && tmp <= 'f') + tmp_val += (tmp - 'a' + 10); + if (tmp >= 'A' && tmp <= 'F') + tmp_val += (tmp - 'A' + 10); + if (tmp >= '0' && tmp <= '9') + tmp_val += (tmp - '0'); + + hdrs->raw.spec[j] = tmp_val; + + tmp = raw_mask->pattern[i]; + if (tmp >= 'a' && tmp <= 'f') + tmp_val = tmp - 'a' + 10; + if (tmp >= 'A' && tmp <= 'F') + tmp_val = tmp - 'A' + 10; + if (tmp >= '0' && tmp <= '9') + tmp_val = tmp - '0'; + + tmp_val *= 16; + tmp = raw_mask->pattern[i + 1]; + if (tmp >= 'a' && tmp <= 'f') + tmp_val += (tmp - 'a' + 10); + if (tmp >= 'A' && tmp <= 'F') + tmp_val += (tmp - 'A' + 10); + if (tmp >= '0' && tmp <= '9') + tmp_val += (tmp - '0'); + + hdrs->raw.mask[j] = tmp_val; + } + + hdrs->raw.pkt_len = pkt_len / 2; + hdrs->tunnel_level = 0; + hdrs->count = 0; + return 0; + } + case RTE_FLOW_ITEM_TYPE_ETH: eth_spec = item->spec; eth_mask = item->mask; diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_generic_flow.c index ddc1fdd22b..e1a611e319 100644 --- a/drivers/net/iavf/iavf_generic_flow.c +++ b/drivers/net/iavf/iavf_generic_flow.c @@ -48,6 +48,12 @@ const struct rte_flow_ops iavf_flow_ops = { .query = iavf_flow_query, }; +/* raw */ +enum rte_flow_item_type iavf_pattern_raw[] = { + RTE_FLOW_ITEM_TYPE_RAW, + RTE_FLOW_ITEM_TYPE_END, +}; + /* empty */ enum rte_flow_item_type iavf_pattern_empty[] = { RTE_FLOW_ITEM_TYPE_END, diff --git a/drivers/net/iavf/iavf_generic_flow.h b/drivers/net/iavf/iavf_generic_flow.h index f6af176073..52eb1caf29 100644 --- a/drivers/net/iavf/iavf_generic_flow.h +++ b/drivers/net/iavf/iavf_generic_flow.h @@ -180,6 +180,9 @@ #define IAVF_INSET_L2TPV2 \ (IAVF_PROT_L2TPV2 | IAVF_L2TPV2_SESSION_ID) +/* raw pattern */ +extern enum rte_flow_item_type iavf_pattern_raw[]; + /* empty pattern */ extern enum rte_flow_item_type iavf_pattern_empty[]; -- 2.25.1