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 9B672A0032 for ; Sun, 14 Nov 2021 16:36:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3DDC41153; Sun, 14 Nov 2021 16:36:47 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) by mails.dpdk.org (Postfix) with ESMTP id 3BEEC41151; Sun, 14 Nov 2021 16:36:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecqBCQBo5rJomOTQgTiAVl0VTFEx0HmJcN4PEyPptSgfepP2iUt3nDiQHe+5ctUItbeuNZSlqsc4mfdWDNJDnORMtqMk6Z9JsSw/WLc0XmjP8T+fgIOv7uf4Ip6G9P1enQ89661/AJLRYGxOhhTIUOMKog8XlSpEguHHzRUuUmKS5wmZI9eSJohXn145w8N8LddJnA1YUm+9OxRr3WXel1tNr3LOEWUHh5jkB3AVJJVu6mT82TZ9xu8ldJGXnNuc2g02kTD3HTuE5zgC3AFuoVmTGa6Xgr9A9pIEnwyowx0vdk9uzKBuHXqITmUgXV+ozCl2yMCoXMN5AKByWlfvtQ== 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=cpSRU2JGdKFaJfjUonu2gEHg+ONqTf+qwud/SbttK88=; b=CXl+ZYQWOUG3Ig52D+viTft++0+9WWWe9hNQkwd9L7XU9hxalus+ks6Yiy2oIgre+aXoTe9wPmMSe8F55qs6gRnJjksO/WmGbJGm2MBSa87A/5vCwIIcmKAWESUeH7zxiNw65gwWB32SdKVbzRBseUWy5a1WSgd7Vwx3dV15KI1c/D2HozyGpzwmYHfV25OdzjGpI7mcx30QoU9AYEuVNfzAWNnGHNc9QcZaTziL1IPHqT9LZ26ddTzJlmOz00xA1lTOzQK8rRc7t4VO6yYACbIKIk3FqqvskqUCfU2rr02KEKWbESWSq/hGCgbDjJ4UBSGoGM5FEKuWwQdAdeVB5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=cpSRU2JGdKFaJfjUonu2gEHg+ONqTf+qwud/SbttK88=; b=sDxcxNjIiMH/YnQPr5ryKGhPxr+oXcclUBw/7IHR5ohreK4acCv1vdyctzD9WUyIFf67G4HVIHP317oN7kBp38euVKBly/fbWv7BekMxIZ+gmIWsejQkwu4UeoMifYEsunLCXP3s+U6WVSYtv55s1LWyHcYCwelWmwF5rKSCTp0Z5GIisVtT79xCv4qyVOXmgXdYuMB6Gstylt6hXhOWBHctdOuGCeVJFHDt39Gm/7E99P3rzRhQQucAIgOe8SxCwQG1EuvhlTXRjYS+bi9t4MF6waxBQqfR2xtYU88YLbQdxtzxdHhUusm8NSdDgwgc0Qa0CV4Gg89v+Oi/NdLxDA== Received: from DM6PR05CA0049.namprd05.prod.outlook.com (2603:10b6:5:335::18) by BYAPR12MB2615.namprd12.prod.outlook.com (2603:10b6:a03:61::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Sun, 14 Nov 2021 15:36:43 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::e0) by DM6PR05CA0049.outlook.office365.com (2603:10b6:5:335::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.15 via Frontend Transport; Sun, 14 Nov 2021 15:36:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 15:36:42 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 14 Nov 2021 15:36:40 +0000 From: Gregory Etelson To: , CC: , , , "Viacheslav Ovsiienko" , Yongseok Koh , "Ori Kam" Subject: [PATCH 5/5] net/mlx5: fix GRE protocol type translation Date: Sun, 14 Nov 2021 17:36:16 +0200 Message-ID: <20211114153617.25085-5-getelson@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211114153617.25085-1-getelson@nvidia.com> References: <20211114153617.25085-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70e80bb9-1298-4343-a62b-08d9a7848f0c X-MS-TrafficTypeDiagnostic: BYAPR12MB2615: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:462; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ACk+4eEiN2qIQzMZ7XyqVrr+GPLULqyY05d1ceojSZ8Qu+EZBYkKPbSRnqmS3mclWkwzEQUx6POPaxDKK26oSLSh9T9rbomDzXH5C0ahxAQeGy4UdKm0ZiWWQuSHiZmRsoMpemOB/to9XGycNYBW86UziCM+SybJ2r9foZF3z4Gtkpa3HLRDQ+KyS6pp5R28JfWePZt0kq54fSzInbMu68eQfHtGPb4FwrIowp0VoCK6yNMrVo6UUUJO+UqYD1HXdi7Fdw4azcZ02HLi8/7ZU+AAFd2T4VtiwIlsW9ESJXv0Lyiwwt4APxyRVBDQH0x7lxjoE46fmXPGW82aGZArKmOy+Rb43Ag90WiR08WYMlFEKtPzKt1w7v6Di/OnKmEU0HwoL2EyAMktIH2UOhFdTrkIibWwi/avKcij0vXgbLNsVJwuLk0dD2X5xNwU264GDQKXxMMhPoRD8HxC4uPa/iXkmpmfZqTNSfb/H60AdAxBFyeu8bYLrsJ0Xxo5IRoUNTlyY5bJwpOHy0PmfVfIcLSLG93CTqfKhlTb8GIZpk7x9MyEl7rigxyEAqdqFF3uA0hhUq3QC028hechGejpYVkAWQeFhWihgfd6FUy+bgseM/4oadDAlfgn8AeU2tOloeO5W2lzN6FnGX2wp4y/ifUPxtMDNtq7pRTTWQ6J0kFivU8Lstngg2C7Xs30rLEWWnHsShy430dnjPaDZIdtDA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(2616005)(110136005)(1076003)(6286002)(26005)(8936002)(55016002)(47076005)(86362001)(7049001)(54906003)(336012)(7696005)(2906002)(36756003)(426003)(36860700001)(6666004)(8676002)(70206006)(83380400001)(316002)(107886003)(5660300002)(356005)(450100002)(186003)(7636003)(508600001)(70586007)(16526019)(4326008)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 15:36:42.5869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70e80bb9-1298-4343-a62b-08d9a7848f0c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2615 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When application creates several flows to match on GRE tunnel without explicitly specifying GRE protocol type value in flow rules, PMD will translate that to zero mask. RDMA-CORE cannot distinguish between different inner flow types and produces identical matchers for each zero mask. The patch extracts inner header type from flow rule and forces it in GRE protocol type, if application did not specify any without explicitly specifying GRE protocol type value in flow rules, protocol type value. Cc: stable@dpdk.org Fixes: fc2c498ccb94 ("net/mlx5: add Direct Verbs translate items") Signed-off-by: Gregory Etelson --- drivers/net/mlx5/mlx5_flow_dv.c | 70 +++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index bce504391d..287a17d956 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -8730,18 +8730,19 @@ flow_dv_translate_item_gre_key(void *matcher, void *key, * Flow matcher value. * @param[in] item * Flow pattern to translate. - * @param[in] inner - * Item is inner pattern. + * @param[in] pattern_flags + * Accumulated pattern flags. */ static void flow_dv_translate_item_gre(void *matcher, void *key, const struct rte_flow_item *item, - int inner) + uint64_t pattern_flags) { + static const struct rte_flow_item_gre empty_gre = {0,}; const struct rte_flow_item_gre *gre_m = item->mask; const struct rte_flow_item_gre *gre_v = item->spec; - void *headers_m; - void *headers_v; + void *headers_m = MLX5_ADDR_OF(fte_match_param, matcher, outer_headers); + void *headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers); void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters); void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters); struct { @@ -8758,26 +8759,17 @@ flow_dv_translate_item_gre(void *matcher, void *key, uint16_t value; }; } gre_crks_rsvd0_ver_m, gre_crks_rsvd0_ver_v; + uint16_t protocol_m, protocol_v; - if (inner) { - headers_m = MLX5_ADDR_OF(fte_match_param, matcher, - inner_headers); - headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers); - } else { - headers_m = MLX5_ADDR_OF(fte_match_param, matcher, - outer_headers); - headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers); - } MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_protocol, 0xff); MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, IPPROTO_GRE); - if (!gre_v) - return; - if (!gre_m) - gre_m = &rte_flow_item_gre_mask; - MLX5_SET(fte_match_set_misc, misc_m, gre_protocol, - rte_be_to_cpu_16(gre_m->protocol)); - MLX5_SET(fte_match_set_misc, misc_v, gre_protocol, - rte_be_to_cpu_16(gre_v->protocol & gre_m->protocol)); + if (!gre_v) { + gre_v = &empty_gre; + gre_m = &empty_gre; + } else { + if (!gre_m) + gre_m = &rte_flow_item_gre_mask; + } gre_crks_rsvd0_ver_m.value = rte_be_to_cpu_16(gre_m->c_rsvd0_ver); gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(gre_v->c_rsvd0_ver); MLX5_SET(fte_match_set_misc, misc_m, gre_c_present, @@ -8795,6 +8787,16 @@ flow_dv_translate_item_gre(void *matcher, void *key, MLX5_SET(fte_match_set_misc, misc_v, gre_s_present, gre_crks_rsvd0_ver_v.s_present & gre_crks_rsvd0_ver_m.s_present); + protocol_m = rte_be_to_cpu_16(gre_m->protocol); + protocol_v = rte_be_to_cpu_16(gre_v->protocol); + if (!protocol_m) { + /* Force next protocol to prevent matchers duplication */ + protocol_m = 0xFFFF; + protocol_v = mlx5_translate_tunnel_etypes(pattern_flags); + } + MLX5_SET(fte_match_set_misc, misc_m, gre_protocol, protocol_m); + MLX5_SET(fte_match_set_misc, misc_v, gre_protocol, + protocol_m & protocol_v); } /** @@ -8806,13 +8808,13 @@ flow_dv_translate_item_gre(void *matcher, void *key, * Flow matcher value. * @param[in] item * Flow pattern to translate. - * @param[in] inner - * Item is inner pattern. + * @param[in] pattern_flags + * Accumulated pattern flags. */ static void flow_dv_translate_item_nvgre(void *matcher, void *key, const struct rte_flow_item *item, - int inner) + unsigned long pattern_flags) { const struct rte_flow_item_nvgre *nvgre_m = item->mask; const struct rte_flow_item_nvgre *nvgre_v = item->spec; @@ -8839,7 +8841,7 @@ flow_dv_translate_item_nvgre(void *matcher, void *key, .mask = &gre_mask, .last = NULL, }; - flow_dv_translate_item_gre(matcher, key, &gre_item, inner); + flow_dv_translate_item_gre(matcher, key, &gre_item, pattern_flags); if (!nvgre_v) return; if (!nvgre_m) @@ -13434,10 +13436,9 @@ flow_dv_translate(struct rte_eth_dev *dev, MLX5_FLOW_LAYER_OUTER_L4_UDP; break; case RTE_FLOW_ITEM_TYPE_GRE: - flow_dv_translate_item_gre(match_mask, match_value, - items, tunnel); matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc); last_item = MLX5_FLOW_LAYER_GRE; + tunnel_item = items; break; case RTE_FLOW_ITEM_TYPE_GRE_KEY: flow_dv_translate_item_gre_key(match_mask, @@ -13445,10 +13446,9 @@ flow_dv_translate(struct rte_eth_dev *dev, last_item = MLX5_FLOW_LAYER_GRE_KEY; break; case RTE_FLOW_ITEM_TYPE_NVGRE: - flow_dv_translate_item_nvgre(match_mask, match_value, - items, tunnel); matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc); last_item = MLX5_FLOW_LAYER_GRE; + tunnel_item = items; break; case RTE_FLOW_ITEM_TYPE_VXLAN: flow_dv_translate_item_vxlan(dev, attr, @@ -13597,6 +13597,16 @@ flow_dv_translate(struct rte_eth_dev *dev, else if (item_flags & MLX5_FLOW_LAYER_GENEVE) flow_dv_translate_item_geneve(match_mask, match_value, tunnel_item, item_flags); + else if (item_flags & MLX5_FLOW_LAYER_GRE) { + if (tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE) + flow_dv_translate_item_gre(match_mask, match_value, + tunnel_item, item_flags); + else if (tunnel_item->type == RTE_FLOW_ITEM_TYPE_NVGRE) + flow_dv_translate_item_nvgre(match_mask, match_value, + tunnel_item, item_flags); + else + MLX5_ASSERT(false); + } #ifdef RTE_LIBRTE_MLX5_DEBUG MLX5_ASSERT(!flow_dv_check_valid_spec(matcher.mask.buf, dev_flow->dv.value.buf)); -- 2.33.1