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 710A4A04A8; Wed, 26 Jan 2022 09:44:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 815BB427E0; Wed, 26 Jan 2022 09:44:34 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) by mails.dpdk.org (Postfix) with ESMTP id B1C174272E for ; Wed, 26 Jan 2022 09:44:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QrdEX/z5Las9+rN/Tuj3pWTPsm3QJDQIEXPSKUxKkqCP3dTuVIrnblWmAYofsjA3uZn3CYtjXA0USJy44R+J/cvaus4SG/dDQL0YPF/VSJKTpBQm4iHTFsnywYw0m9S2TX9tsCGNu5F+p2DZPBz404+ayoFJuC99en6JKgAQTUVhoplb89u6lQE2wU56UW0UBYlghOIKr/O2H4Vz5FYWlJxE95DhpVGIKIL+WikirR9y/amv7XLvtUN7PyC4uEEUn8+xzM3bfLYyfNzqLPohnaeoOA0093VBg8jXrl/+UNX0mg4Ruu70/jmjEXqwhtgJfcb6MKt5mevUypt3CFwl1Q== 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=i6YR73Y0pU3HgL9g63e0QtPEDcDBB/eEC2/ufMGjRHw=; b=nvzfJ3wL0/md2RVOLj3uJ3BIJ+dua9x/BXmDi52d/JRT84bo/9lHTYkRruuyNALVaptZkV+OvAmSyVC8Q2fQvAMhZ7I8MDkuxb5MUc/3r3Xe9KZN3kPLqPUVZoVMmwrMJGl0OhcLWy4oyytmhclTmiP4ec5OohMvZxvduXeHkjs4l7A6PWIDslBM8znQmc3LPHkny1g0EaqJDv0bekAyguN9IizsFkHylM5TxNBDrkf/27oK7AuP0LcqaEDv8c2HtcTsb/vTu8BkcGrQj5/2oDau08nc9RbfavHSi7x83Y1KIKQoH0DSvIAfoFSRrN/Ozb9taH984IiUB32MVwY2mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) 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=i6YR73Y0pU3HgL9g63e0QtPEDcDBB/eEC2/ufMGjRHw=; b=K5S/D3mBe29V8/bqMYBV9cNT7lmvjfsIbDn7WbcjyGwxV0keFU8r5U0rguxAWproHCFJ9uAKaQC5qqo1D/duEfUYRQe9YUd9MUfYe8bB0x+VzxapcXpVqrsX8lLjxZCAkDfUc40EJlZrakJ3EPERvjKYdO/AthnuMrlN3eLK06RsSgeQULuv/3q6EUalFrxthTcVn1FqxFTvI+GtBtCMKhYrJnEuxQJpcfCumksc2Z7vnWaZ0KhfaqG9n3wRiPnf5qKyEl+Sf5J7SUcPQHLMhAk1e1YCijnc7NMtWcp6zeXz0nNNW6kQOSqHrRnokNKDC8o4ZCt2zFva2t4H8L60hg== Received: from DS7PR03CA0169.namprd03.prod.outlook.com (2603:10b6:5:3b2::24) by CO6PR12MB5475.namprd12.prod.outlook.com (2603:10b6:5:354::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Wed, 26 Jan 2022 08:44:29 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::c4) by DS7PR03CA0169.outlook.office365.com (2603:10b6:5:3b2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10 via Frontend Transport; Wed, 26 Jan 2022 08:44:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Wed, 26 Jan 2022 08:44:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 26 Jan 2022 08:44:28 +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; Wed, 26 Jan 2022 00:44:27 -0800 From: Sean Zhang To: , Matan Azrad , "Viacheslav Ovsiienko" CC: Subject: [v1 4/4] net/mlx5: support matching optional fields of GRE Date: Wed, 26 Jan 2022 10:44:04 +0200 Message-ID: <20220126084404.40178-5-xiazhang@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220126084404.40178-1-xiazhang@nvidia.com> References: <20211230030817.15264-2-xiazhang@nvidia.com> <20220126084404.40178-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: drhqmail203.nvidia.com (10.126.190.182) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3c786b5-ecc8-468b-95a3-08d9e0a81112 X-MS-TrafficTypeDiagnostic: CO6PR12MB5475: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: GbXSp7aDvIJjVImG3zmyp8NtmwJDSdcsFWMCccZYmcr1bIbuReoGy7TRwQlpkfdRoMSSkareb8Hk6cmwkCncX7D3mdIa78cl5vwmpiXHNIW253DH4M27SpvpsUzCNvGQAcNuWHWndZZDUlppoodIsJSaUih31HyvfmJcFkYcegzE9DbPG4P4LqrkZdAQKciwXHpYgWD4Q7hQr5zrGbdW+FrCfSPkIM8FqlvIq0YC+kaQrRN9bJ7rovYgnTVLHbH75rkfM4gM8ODs2FK04klfepzhHiGLMXURVcdarmvt9AbzUM+4zUXeZLwYUfVeMpiD2SUkqay/EA91wD38GGZFa/a+lTOsntHbFa+BZ5xB/X1uTpRJn7a+9LDQrvZ/icjrwwpFVjMQx5EnW62aaub1TTe36VPwk5RhUIx2mcXLuId6bmdTQpAa9wh+FirTTUeAwqdtmUeybhbP/ilZUNG3+1voj1QLSIu4vG1/4Fp9QOVofE7wmuS0hg01aXc3IPWxWKgs+B1bxgF9Gc6Z75S/vB2Otos7SWCaosxZgE9EilZMkuaLAJhAew8xeWM1PwICTmnzKZPLdRgHcKUlezNzfqvfkB4BT5csvKs3DIKOTtrvy3RHWf3Oid5I57uZ4TtpfTgsSEnIiXg/x1Wze7ZQZaEXI1J0zODggw80KIMygJpRrx3I1P1uufJ0fGt0ir9vgbJh+tDuq5Il3FhGPlfbTw== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(110136005)(55016003)(6636002)(5660300002)(8676002)(356005)(30864003)(316002)(2906002)(8936002)(70206006)(70586007)(81166007)(6286002)(4326008)(6666004)(82310400004)(47076005)(1076003)(2616005)(508600001)(83380400001)(86362001)(16526019)(36756003)(26005)(186003)(426003)(336012)(40460700003)(36860700001)(7696005)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 08:44:29.3631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3c786b5-ecc8-468b-95a3-08d9e0a81112 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.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5475 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 --- 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 | 106 +++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 146 +++++++++++++++++++++++++++++++++++ 6 files changed, 264 insertions(+) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 7cd3d4f..5d21480 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -1027,6 +1027,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 36f0fbf..6dbbb1f 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1385,6 +1385,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 b55f581..32b1c7b 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1150,6 +1150,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 b7cf414..9e608ba 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2802,6 +2802,112 @@ 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; + + 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 (!gre_mask) + gre_mask = &rte_flow_item_gre_mask; + + struct rte_flow_item_gre_opt gre_option_default_mask = { + .checksum = { + .checksum = 0xffff, + }, + .key = { + .key = 0xffffffff, + }, + .sequence = { + .sequence = 0xffffffff, + }, + }; + + if (!mask) + mask = &gre_option_default_mask; + + if (spec && mask->checksum.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 (spec && 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 (spec && 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 (spec && (mask->checksum.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 *)&gre_option_default_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 8c131d6..210cc26 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1523,6 +1523,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 8022d7d..4536ddb 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7112,6 +7112,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, @@ -8833,6 +8840,135 @@ 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; + + struct rte_flow_item_gre_opt gre_option_default_mask = { + .checksum = { + .checksum = 0xffff, + }, + .key = { + .key = 0xffffffff, + }, + .sequence = { + .sequence = 0xffffffff, + }, + }; + + if (!option_v) + return; + if (!option_m) + option_m = &gre_option_default_mask; + + if (!(option_m->sequence.sequence || option_m->checksum.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 = 0xFFFF; + } + } + 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.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.checksum & + option_m->checksum.checksum; + *tunnel_header_m[1] = option_m->checksum.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 @@ -12708,6 +12844,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, @@ -13480,12 +13617,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; @@ -13645,6 +13788,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