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 5D855A0548 for ; Thu, 2 Dec 2021 17:04:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 518EE4067B; Thu, 2 Dec 2021 17:04:00 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2069.outbound.protection.outlook.com [40.107.244.69]) by mails.dpdk.org (Postfix) with ESMTP id 1F6BC4067B for ; Thu, 2 Dec 2021 17:03:59 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MvpcXO2TZKquGfi726jjOnSD8ZxFwCPFUVxyneFupfOR6STaH5ZAAQhY9RuxKNu1kn14MzQHR4aUGOaAhjkNmQ1gHca41HJ61z0QphFuQgp/w4hw94xswFvIpAi1iO5CUuBzqkYNy4E+dyX/RAxYUXOY1BakVlAxeekGGx7Su5IPqZ3DHKTOJf8a2e2ffmc2kM/9M2GBTmeGR3rh5E2y/8t+RpMTqEnBqGcSRveZ+8JYF2v3CrFFcRXHg93CG3z3oNTeM1vyrVL4Zh6EZeLfR3Dz2zh25CSZ1Asuh6BHDn+BIip1yzX+iYQu9OMs45QOpNV/vkEHaYd8D2hF/U9MDQ== 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=dvoxo1URBrP4cfuSa5CHNg3xiPPQQgycyDkdZ1OVKgQ=; b=nCn8Hy+ouAH64ZI01vMSzYiMqj/v2OmDUuaACjaM34Z0h4uvK/vOgri758HBA8pmC6ttEG5qoypFtNBq4nl+754iyYU0f3+vgr43q+SXdWWEVjoACWKDkrS/2YVYR737UHb13W47xqQQDuf/AfVMSHAavG/fYbOaFbXt0rg3SsGLqn5uys9kxqry3XL0JoBJU7+KfSqgice4MwzDqZd5k/0yAWlARB9arjvhMSrmv5dqdRs2kf/D/PwgtWZ4lSfBWdb1IyWzu/2OFcs1FdS6KRNMLyEg5zhApCBp2lXzh3b8sa1uaa8jagdV1ueO4RY4hBeYeOMBCxmZwX97JDuOLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) 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=dvoxo1URBrP4cfuSa5CHNg3xiPPQQgycyDkdZ1OVKgQ=; b=sJ7HHScQfE4lBcJp2cdEx63rjCkopwjTp6eG7m7ZN17DEIBkMBYeCT5B2ohattXUG+PPFbu4wpUcrS78Vk+5F6ypfuk3PN9q9YA3jZQ+lqoCeRR9FwGBnIKEscGltWMBCjSWA3SaOBL0EZ9//zrIrbxPpyR05IAunQ3ggwsxaYwdGhL+G7a9zNOMrZHlrl5tzx4a1v468DilryDFr8RP+7zDUe0eM+7TVMMLZ14J67cvPiAN4o5hZJFO4UCs1O/8t0gDMlCddGlZpE6R+DC5MCWgXdpXSWiF5fSRv8NYH1XhxuSeMop5ckUPWunEhlb0qDHLJzT1x8nZ18hit0u/iA== Received: from BN0PR08CA0025.namprd08.prod.outlook.com (2603:10b6:408:142::10) by DM6PR12MB3948.namprd12.prod.outlook.com (2603:10b6:5:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Thu, 2 Dec 2021 16:03:57 +0000 Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::53) by BN0PR08CA0025.outlook.office365.com (2603:10b6:408:142::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Thu, 2 Dec 2021 16:03:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) 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.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4755.13 via Frontend Transport; Thu, 2 Dec 2021 16:03:56 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 2 Dec 2021 16:03:31 +0000 Received: from nvidia.com (172.20.187.5) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Thu, 2 Dec 2021 08:03:28 -0800 From: Gregory Etelson To: , CC: Viacheslav Ovsiienko , Matan Azrad , Shahaf Shuler , Ori Kam , Yongseok Koh Subject: [PATCH 19.11 4/6] net/mlx5: fix GRE protocol type translation Date: Thu, 2 Dec 2021 18:03:14 +0200 Message-ID: <20211202160314.26638-1-getelson@nvidia.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e44bd87c-7dc0-496c-e839-08d9b5ad587b X-MS-TrafficTypeDiagnostic: DM6PR12MB3948: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:85; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QuTRhSPHRyiVAdSP/9Aqpbq25R57UjPtm/0tl0pz224y0R1HKTyM4+Vv0ZDwfjX/u+voMwwSCvoWm30dwvgaD8JVsv34tJiFoLADJg5B0haJgHKSGU+DKju0KL1cOHboj5+H/Ra9O9+5rT9HIktMKxWgs0dJSSo5BSeNDLvQD9rAGOR/2kxeIOES/4vWkZrKG7spi2CbsKW1SBB7rbGsGRJnGzUumFM/2nYVSme1J3TKyBcmVdNNqn9Vq1qRocCMpEJNjOsRKdTgka58z9uSBaVk1kBQjs2P3ELOTuVCcEIljf+YxmT54vhS/pL3AHOCDgTl/mjV7WPr8u1ncZ3Rx7KbW39EPrdX89R7G3yNmeIlSTbz16T0OW/GjqHfkNqSLL5moPOJ3IdoxjhpzV9326+MZxuwNRpdzusIH69gVZf5YM+9QKBs3SYYMJYNm4TU1tb4zTgv5WCUHvH3qdpwqCobGru3OJHXEmXeGI8YqevLz2Tgbty/g+g55zOFHMBVFwf4Y772Aw3BunWYVGG1d8wsWC9PkW7hdb+chCtroTZcuJoExt560EOUpgm7rJvJYqVdViyYt27HS3k8jOUQNg5BWHts74aT2HHIRmksNRAckrzHYlNWBtWOPi0ek+9Kb9glxsRiyNeX+efxb2qe6Z+PQNKKUYQr7z2TiJ7DN7T67eiwDSS6AOkh6ev3qNR+LSttL8TCOmIQy3njJAw1IZc6uiBcYULgZyD5zpdzRaCwDHOCvL4ioC/Ntk9GY2Dt X-Forefront-Antispam-Report: CIP:216.228.112.35; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid02.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(7049001)(2616005)(107886003)(1076003)(36860700001)(47076005)(55016003)(16526019)(83380400001)(186003)(82310400004)(40460700001)(7636003)(6286002)(356005)(4326008)(26005)(426003)(336012)(86362001)(2906002)(5660300002)(508600001)(36756003)(110136005)(7696005)(54906003)(70206006)(8676002)(8936002)(6666004)(70586007)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 16:03:56.6219 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e44bd87c-7dc0-496c-e839-08d9b5ad587b 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.35]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3948 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 [ upstream commit be26e81bfc1cb681d3ee0764aa6733000869984a ] 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. Fixes: fc2c498ccb94 ("net/mlx5: add Direct Verbs translate items") Cc: stable@dpdk.org Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- 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 8dec8d9ff5..edbdba3e23 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5875,18 +5875,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 { @@ -5903,26 +5904,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, @@ -5940,6 +5932,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); } /** @@ -5951,13 +5953,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; @@ -5984,7 +5986,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) @@ -7788,11 +7790,10 @@ __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 = flow->rss.level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4; 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, @@ -7800,11 +7801,10 @@ __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 = flow->rss.level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4; last_item = MLX5_FLOW_LAYER_GRE; + tunnel_item = items; break; case RTE_FLOW_ITEM_TYPE_VXLAN: flow_dv_translate_item_vxlan(match_mask, match_value, @@ -7892,6 +7892,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); + } assert(!flow_dv_check_valid_spec(matcher.mask.buf, dev_flow->dv.value.buf)); /* -- 2.34.0