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 4B910A00BE; Fri, 11 Feb 2022 02:46:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9330641203; Fri, 11 Feb 2022 02:46:04 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2042.outbound.protection.outlook.com [40.107.237.42]) by mails.dpdk.org (Postfix) with ESMTP id 8147F426D3 for ; Fri, 11 Feb 2022 02:46:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fSKCzMy9or2l4HdEnbR0LWqM/p7AOjwVpCXznTCpdhyhQJa3rFgoregDoaE9Hl2dFWxYkZQrxmKj6mBlEPBOpM66pQBxBl/karoq00L41IvpzaEjR+VMEKDj6INXQisrVAjrIk2A4E3QeBtWjtSp0La9nW/fvjtZlUrkN09l6Sz6jg/+DFMdFaYv9F0f4do6ekjNU1sVOSJ/wZT06qJbAbqVtzLadCP0puPuTLdRNLiZOo2De0EkyJl92BhSdqyg3Roc178Di7GEqInqGvYVrNjfNJwBe3f6s9dNPUwcJ7q22DmZm8SYX/KXmTNbpW+1AK7dRo2wjoH1Z2hk0rjymA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=utg5CV7mIIkeRWyQmA1aX9P0WjWYfuO7drip8NkiSZs=; b=mHAbLN9NOUKR2bgkHHYbzmNPtWnubaeIV+froGMxtWQjmv9LW/aWxaS1B7Kk36U1x9yNpIYgrA9RLm8E6kz+HnX0l7v+/x8291rMB7R92eSA05c9Lv3wZcUP66dU07M2UBTY08NcqZTL8kpczAI4MdYCVASxetT5mKhEU422N7MFOm5DltJZHt4oRP8RnS9DlOAqxslVrpniZeKAG2A9sft73YLuteVThdL8VuqTNu1HQ4eB2b0DM3dVptrUnM93H2dZqOYEl91WtUDgt4mY9IOqgB+mO4n8MBC0+NrO6eqgXTMWZfsMyRweOoG+JGBmbEl9sjXcTxE/0mQZV2tByQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=utg5CV7mIIkeRWyQmA1aX9P0WjWYfuO7drip8NkiSZs=; b=OxbnsctU11imDPxzz7Ks90zdeHBBUUaOflbrwYrqxp1fHyRmUqcSOFtaKeo4nsAwAhnxvZH7JsfVKt7qjCd+AO2Eg0Srk/4Nlyej/WfIvA86RolzlqYk8lBSDmHJjt1/5rTm0NdnlB2qDEuk3aQwTDduEi+csyOUPPn4LH6LiwTmUn75rbHX9BHZV7nkux2rG6AY7qg/6XOH6ELB612Au3LZboiCiWTPot5hkCwtQwr34+GLASK83SMvQ24AIBUnGgMHHF59Z3D0ymzsBEg5XvD1LFadn63P3qMXZrU3dSEqibjYtDYpOca+oXHkj1pjhp64hDDHIEwKdSope7ME9A== Received: from BN6PR19CA0094.namprd19.prod.outlook.com (2603:10b6:404:133::32) by BYAPR12MB3624.namprd12.prod.outlook.com (2603:10b6:a03:aa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 01:46:00 +0000 Received: from BN8NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:404:133:cafe::98) by BN6PR19CA0094.outlook.office365.com (2603:10b6:404:133::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Fri, 11 Feb 2022 01:45:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT047.mail.protection.outlook.com (10.13.177.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Fri, 11 Feb 2022 01:45:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 11 Feb 2022 01:45:57 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 10 Feb 2022 17:45:55 -0800 From: Sean Zhang To: , , Matan Azrad , Viacheslav Ovsiienko CC: Subject: [v2 4/4] net/mlx5: support matching optional fields of GRE Date: Fri, 11 Feb 2022 03:45:30 +0200 Message-ID: <20220211014530.77711-5-xiazhang@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220211014530.77711-1-xiazhang@nvidia.com> References: <20220126084404.40178-1-xiazhang@nvidia.com> <20220211014530.77711-1-xiazhang@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5a80257-d3bf-4ed5-cf69-08d9ed004109 X-MS-TrafficTypeDiagnostic: BYAPR12MB3624:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ag54VwVS1QBTXkLDPgR/lbQBj6GzxHicFqKYkFkBQxNNE2n0K4NhDDE3nY5G7o1e7f8hItkyCxAno5L95BZwMvwor7P2NjjSEzIs5NlWpqG3z2VXoxfjcuXZYpz1vLGfLMbZe0CS6d4bZZROPD4QXyckWSA3Cyzf0eK909usmxmmNnVKncPcngvJzsa9KdQ6irQQObGMeVWZMUe7XGZ+KnTNfQLkrMBBCkP9sowmrwSnBRbh3DQrXzXcboCurM7FTS6JhIa7rACSK0X38Pn7P7TUhv72Rfo6Gz5UrnKQU/igEECc9pTlsF1fdgqQVEvb0bzh+bbr5Z5FreLWS/AV0sQ22y8uoDZEWleYGPT66slmmsIrN593AYXSluR6mXUvbuEc8ulFf3RYQ3FeD01s8aSOB5EGVWT4LHdBrsHPO6L8rxvGWGrFfayK6vTH73o/h7O3VIpfPKz9Hy05zx8//D8rt6MBux3Zhd1xHpprJD/LzHlwUAAwfxDSxQyCNlvjmMZH89qC/t5/+C82nPvJSdlx2OlLEVGCOiiof2TNt+qcea0eyYaAGcbdW2/YTdU7nsoC+/XcVnFe81L5mqsLFCFaXAhm5B97lchMIiug05L+LGJOF/1U6bQ5QEwJUuktjkVyyUONRrEiNkGBIW78HtRrSOeQX/09vJlysUqCHyZGwpkUPb5Je7AOMJ5GihjD1w99QnoYZ+gBALC7Mgyj3g== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(81166007)(30864003)(83380400001)(47076005)(5660300002)(356005)(2906002)(110136005)(6286002)(1076003)(36756003)(16526019)(336012)(426003)(26005)(186003)(2616005)(55016003)(6666004)(70206006)(508600001)(8676002)(8936002)(36860700001)(82310400004)(86362001)(70586007)(7696005)(316002)(6636002)(40460700003)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 01:45:59.0484 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5a80257-d3bf-4ed5-cf69-08d9ed004109 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3624 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 adds matching on the optional fields (checksum/key/sequence) of GRE header. The matching of checksum and sequence fields requests support from rdma-core with capability of misc5 and tunner_header 0-3. For patterns without checksum and sequence specified, keep using misc for matching as before, but for patterns with checksum or sequence, validate capability first and then use misc5 for the matching. Signed-off-by: Sean Zhang --- doc/guides/nics/mlx5.rst | 8 +++ drivers/common/mlx5/mlx5_devx_cmds.c | 3 + drivers/net/mlx5/linux/mlx5_os.c | 2 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 108 +++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 130 +++++++++++++++++++++++++++++++++++ 7 files changed, 258 insertions(+) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index daa7f2a..abd6b8b 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -508,6 +508,14 @@ Limitations from the reference "Clock Queue" completions, the scheduled send timestamps should not be specified with non-zero MSB. +- Match on GRE header supports the following fields: + + - c_rsvd0_v: C bit, K bit, S bit + - protocol type + - Checksum + - Key + - Sequence + Statistics ---------- diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 2e807a0..77436ed 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -1043,6 +1043,9 @@ struct mlx5_devx_obj * attr->flow.tunnel_header_0_1 = MLX5_GET (flow_table_nic_cap, hcattr, ft_field_support_2_nic_receive.tunnel_header_0_1); + attr->flow.tunnel_header_2_3 = MLX5_GET + (flow_table_nic_cap, hcattr, + ft_field_support_2_nic_receive.tunnel_header_2_3); attr->pkt_integrity_match = mlx5_devx_query_pkt_integrity_match(hcattr); attr->inner_ipv4_ihl = MLX5_GET (flow_table_nic_cap, hcattr, diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index aecdc5a..7f59cfb 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1383,6 +1383,8 @@ } if (config->hca_attr.flow.tunnel_header_0_1) sh->tunnel_header_0_1 = 1; + if (config->hca_attr.flow.tunnel_header_2_3) + sh->tunnel_header_2_3 = 1; #endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso && diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 737ad68..5faca7a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1154,6 +1154,7 @@ struct mlx5_dev_ctx_shared { uint32_t meter_aso_en:1; /* Flow Meter ASO is supported. */ uint32_t ct_aso_en:1; /* Connection Tracking ASO is supported. */ uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */ + uint32_t tunnel_header_2_3:1; /* tunnel_header_2_3 is supported. */ uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */ uint32_t reclaim_mode:1; /* Reclaim memory. */ uint32_t dr_drop_action_en:1; /* Use DR drop action. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index d7cb1eb..7f0af38 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2815,6 +2815,114 @@ struct mlx5_flow_tunnel_info { } /** + * Validate GRE optional item. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] item + * Item specification. + * @param[in] item_flags + * Bit flags to mark detected items. + * @param[in] attr + * Flow rule attributes. + * @param[in] gre_item + * Pointer to gre_item + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + uint64_t item_flags, + const struct rte_flow_attr *attr, + const struct rte_flow_item *gre_item, + struct rte_flow_error *error) +{ + const struct rte_flow_item_gre *gre_spec = gre_item->spec; + const struct rte_flow_item_gre *gre_mask = gre_item->mask; + const struct rte_flow_item_gre_opt *spec = item->spec; + const struct rte_flow_item_gre_opt *mask = item->mask; + struct mlx5_priv *priv = dev->data->dev_private; + int ret = 0; + + struct rte_flow_item_gre_opt nic_mask = { + .checksum_rsvd = { + .checksum = RTE_BE16(UINT16_MAX), + .reserved1 = 0x0, + }, + .key = { + .key = RTE_BE32(UINT32_MAX), + }, + .sequence = { + .sequence = RTE_BE32(UINT32_MAX), + }, + }; + + if (!(item_flags & MLX5_FLOW_LAYER_GRE)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "No preceding GRE header"); + if (item_flags & MLX5_FLOW_LAYER_INNER) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "GRE option following a wrong item"); + if (!spec || !mask) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "At least one field gre_option(checksum/key/sequence) must be specified"); + if (!gre_mask) + gre_mask = &rte_flow_item_gre_mask; + + if (mask->checksum_rsvd.checksum) + if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x8000)) && + !(gre_spec->c_rsvd0_ver & RTE_BE16(0x8000))) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Checksum bit must be on"); + + if (mask->key.key) + if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) && + !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000))) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, "Key bit must be on"); + + if (mask->sequence.sequence) + if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x1000)) && + !(gre_spec->c_rsvd0_ver & RTE_BE16(0x1000))) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Sequence bit must be on"); + + if (mask->checksum_rsvd.checksum || mask->sequence.sequence) { + if (priv->sh->steering_format_version == + MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5 || + ((attr->group || attr->transfer) && + !priv->sh->misc5_cap) || + (!(priv->sh->tunnel_header_0_1 && + priv->sh->tunnel_header_2_3) && + !attr->group && !attr->transfer)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Checksum/Sequence not supported"); + } + + ret = mlx5_flow_item_acceptable + (item, (const uint8_t *)mask, + (const uint8_t *)&nic_mask, + sizeof(struct rte_flow_item_gre_opt), + MLX5_ITEM_RANGE_NOT_ACCEPTED, error); + + return ret; +} + +/** * Validate GRE item. * * @param[in] item diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 7fec79a..667b241 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1537,6 +1537,12 @@ int mlx5_flow_validate_item_gre_key(const struct rte_flow_item *item, uint64_t item_flags, const struct rte_flow_item *gre_item, struct rte_flow_error *error); +int mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + uint64_t item_flags, + const struct rte_flow_attr *attr, + const struct rte_flow_item *gre_item, + struct rte_flow_error *error); int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item, uint64_t item_flags, uint64_t last_item, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index ef9c66e..bd3fcdc 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7101,6 +7101,13 @@ struct mlx5_list_entry * gre_item = items; last_item = MLX5_FLOW_LAYER_GRE; break; + case RTE_FLOW_ITEM_TYPE_GRE_OPTION: + ret = mlx5_flow_validate_item_gre_option(dev, items, item_flags, + attr, gre_item, error); + if (ret < 0) + return ret; + last_item = MLX5_FLOW_LAYER_GRE; + break; case RTE_FLOW_ITEM_TYPE_NVGRE: ret = mlx5_flow_validate_item_nvgre(items, item_flags, next_protocol, @@ -8822,6 +8829,119 @@ struct mlx5_list_entry * } /** + * Add GRE optional items to matcher and to the value. + * + * @param[in, out] matcher + * Flow matcher. + * @param[in, out] key + * Flow matcher value. + * @param[in] item + * Flow pattern to translate. + * @param[in] gre_item + * Pointer to gre_item. + * @param[in] pattern_flags + * Accumulated pattern flags. + */ +static void +flow_dv_translate_item_gre_option(void *matcher, void *key, + const struct rte_flow_item *item, + const struct rte_flow_item *gre_item, + uint64_t pattern_flags) +{ + const struct rte_flow_item_gre_opt *option_m = item->mask; + const struct rte_flow_item_gre_opt *option_v = item->spec; + const struct rte_flow_item_gre *gre_m = gre_item->mask; + const struct rte_flow_item_gre *gre_v = gre_item->spec; + static const struct rte_flow_item_gre empty_gre = {0}; + struct rte_flow_item gre_key_item; + uint16_t c_rsvd0_ver_m, c_rsvd0_ver_v; + uint16_t protocol_m, protocol_v; + uint32_t *tunnel_header_v[4]; + uint32_t *tunnel_header_m[4]; + void *misc5_m; + void *misc5_v; + + if (!(option_m->sequence.sequence || + option_m->checksum_rsvd.checksum)) { + flow_dv_translate_item_gre(matcher, key, gre_item, + pattern_flags); + gre_key_item.spec = &option_v->key.key; + gre_key_item.mask = &option_m->key.key; + flow_dv_translate_item_gre_key(matcher, key, &gre_key_item); + return; + } + + if (!gre_v) { + gre_v = &empty_gre; + gre_m = &empty_gre; + } else { + if (!gre_m) + gre_m = &rte_flow_item_gre_mask; + } + + misc5_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters_5); + misc5_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_5); + tunnel_header_v[0] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_v, tunnel_header_0); + tunnel_header_m[0] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_m, tunnel_header_0); + tunnel_header_v[1] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_v, tunnel_header_1); + tunnel_header_m[1] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_m, tunnel_header_1); + tunnel_header_v[2] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_v, tunnel_header_2); + tunnel_header_m[2] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_m, tunnel_header_2); + tunnel_header_v[3] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_v, tunnel_header_3); + tunnel_header_m[3] = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5, + misc5_m, tunnel_header_3); + + protocol_v = gre_v->protocol; + protocol_m = gre_m->protocol; + if (!protocol_m) { + /* Force next protocol to prevent matchers duplication */ + uint16_t ether_type = + mlx5_translate_tunnel_etypes(pattern_flags); + if (ether_type) { + protocol_v = rte_be_to_cpu_16(ether_type); + protocol_m = UINT16_MAX; + } + } + c_rsvd0_ver_v = gre_v->c_rsvd0_ver; + c_rsvd0_ver_m = gre_m->c_rsvd0_ver; + + + if (option_m->sequence.sequence) { + c_rsvd0_ver_v |= RTE_BE16(0x1000); + c_rsvd0_ver_m |= RTE_BE16(0x1000); + } + + if (option_m->key.key) { + c_rsvd0_ver_v |= RTE_BE16(0x2000); + c_rsvd0_ver_m |= RTE_BE16(0x2000); + } + + if (option_m->checksum_rsvd.checksum) { + c_rsvd0_ver_v |= RTE_BE16(0x8000); + c_rsvd0_ver_m |= RTE_BE16(0x8000); + } + + *tunnel_header_v[0] = (c_rsvd0_ver_v | protocol_v << 16) & + (c_rsvd0_ver_m | protocol_m << 16); + *tunnel_header_m[0] = c_rsvd0_ver_m | protocol_m << 16; + *tunnel_header_v[1] = option_v->checksum_rsvd.checksum & + option_m->checksum_rsvd.checksum; + *tunnel_header_m[1] = option_m->checksum_rsvd.checksum; + *tunnel_header_v[2] = option_v->key.key & option_m->key.key; + *tunnel_header_m[2] = option_m->key.key; + *tunnel_header_v[3] = option_v->sequence.sequence & + option_m->sequence.sequence; + *tunnel_header_m[3] = option_m->sequence.sequence; +} + +/** * Add NVGRE item to matcher and to the value. * * @param[in, out] matcher @@ -12697,6 +12817,7 @@ struct mlx5_list_entry * }; const struct rte_flow_item *integrity_items[2] = {NULL, NULL}; const struct rte_flow_item *tunnel_item = NULL; + const struct rte_flow_item *gre_item = NULL; if (!wks) return rte_flow_error_set(error, ENOMEM, @@ -13469,12 +13590,18 @@ struct mlx5_list_entry * matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc); last_item = MLX5_FLOW_LAYER_GRE; tunnel_item = items; + gre_item = items; break; case RTE_FLOW_ITEM_TYPE_GRE_KEY: flow_dv_translate_item_gre_key(match_mask, match_value, items); last_item = MLX5_FLOW_LAYER_GRE_KEY; break; + case RTE_FLOW_ITEM_TYPE_GRE_OPTION: + matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc); + last_item = MLX5_FLOW_LAYER_GRE; + tunnel_item = items; + break; case RTE_FLOW_ITEM_TYPE_NVGRE: matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc); last_item = MLX5_FLOW_LAYER_GRE; @@ -13634,6 +13761,9 @@ struct mlx5_list_entry * else if (tunnel_item->type == RTE_FLOW_ITEM_TYPE_NVGRE) flow_dv_translate_item_nvgre(match_mask, match_value, tunnel_item, item_flags); + else if (tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE_OPTION) + flow_dv_translate_item_gre_option(match_mask, match_value, + tunnel_item, gre_item, item_flags); else MLX5_ASSERT(false); } -- 1.8.3.1