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 AF2FEA0548 for ; Thu, 2 Dec 2021 17:00:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A15DA406FF; Thu, 2 Dec 2021 17:00:56 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2069.outbound.protection.outlook.com [40.107.223.69]) by mails.dpdk.org (Postfix) with ESMTP id 6FB0D40DDA for ; Thu, 2 Dec 2021 17:00:54 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TDGjBCvp32yayvbIXEDfYWt6OyXzk9nMOHl69iTmeRZtF50q4l5VZNHgKtP3yiF6BHWuUSwm2+FlnNvGw+etRdgQbsO3Rvcpc6HzqcUDturxwgpXlELUTt5Tl3s1/EFnWxKx1TH1QJ67IzrQf16ukH9cjGkfd9Y5Op//ib1M5/F+KWC08JZTaWnWbE2FU5CyynhHAsDLtiegbLKk4phttS6t12B/1VSQ2wzV0/Xt37EuAVh6RCCGSfN70z6TA9PMbpBVlN7zixsn7q+EdprPLS9YDOWuGfdddpNuYgq1od488IQZ4gE+oHN8zjshtr5A/bPytSYhIisp+1TiSIA79Q== 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=bDdvG6MjnHKFE1arewu/vF9LEf14yMO7Fn69dX3+vZk=; b=B+STKvgUyr2P52mkDbnLuG5Y+gH+K4qUK8toq3lKMXLEf8kSxhBPqZTeJSiXNf48iXdzGnUxvKKjKtIitgDazTIpHC+7sXtWuK4V18SG9Ai3k5b4qY8YgRaorsr3nQNErL2R+MVKYaCJc4FW65/pgAGWevKSFuGBNpjjAT3EVrqpDvC8S4glf6GREkY3rTiw4Z5lB6woQKRzOyW448+ajZqSyUmeFcY1wMl7FMi2s4eXsZsSVbBOXDY+x4XhxZfZrmA5g/7jeKNd5+W1O64iv8YoxDHG0Zg0lLaKAmehg9glJ+9freoBGY4pdtsZ2TMGlbJj3T/CkNO093V4EOdifw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) 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=bDdvG6MjnHKFE1arewu/vF9LEf14yMO7Fn69dX3+vZk=; b=lNmGRw6Whqpj4jwrE0ilYk3qD2GG56OLQkFJ/czIEui4nMGoxT8NKdhM8MfY5g5grTh66Dj8piTGEaGbS8LdB+apQbYZNL1eEhfT3H6R1UvKISCfv8ByEi78EkuOpizR8aRXl+M1BcVQhyu06aVMGgzrqcAocwJpvS910v4JDG+dvcA+XpAXjGGALkMdos8hsPJ4Dj4yVInCQrz+X404HDPeAcjrulIc2gOUl4cz2LlSA+i1V0KLvfYQvGtcD8w4u4MffFiPw8IiCC5/MHdpHI/gEcVNU0zkVo0WhIPTAcgwseGSN0D5iDeteMQfv+yIk41JejYOjmXhSwC5dvawRA== Received: from MWHPR1201CA0017.namprd12.prod.outlook.com (2603:10b6:301:4a::27) by PH0PR12MB5417.namprd12.prod.outlook.com (2603:10b6:510:e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Thu, 2 Dec 2021 16:00:52 +0000 Received: from CO1NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4a:cafe::55) by MWHPR1201CA0017.outlook.office365.com (2603:10b6:301:4a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24 via Frontend Transport; Thu, 2 Dec 2021 16:00:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) 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.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT055.mail.protection.outlook.com (10.13.175.129) 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:00:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 2 Dec 2021 16:00:51 +0000 Received: from nvidia.com (172.20.187.6) 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:00:49 -0800 From: Gregory Etelson To: , CC: Viacheslav Ovsiienko , Matan Azrad , Shahaf Shuler , Moti Haimovsky Subject: [PATCH 19.11 3/6] net/mlx5: fix GENEVE protocol type translation Date: Thu, 2 Dec 2021 18:00:16 +0200 Message-ID: <20211202160019.26453-3-getelson@nvidia.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211202160019.26453-1-getelson@nvidia.com> References: <20211202160019.26453-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: 4a4b9aa3-3179-44bf-5ed0-08d9b5acea66 X-MS-TrafficTypeDiagnostic: PH0PR12MB5417: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:288; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NuLOyV/0SOsOVZraHDIjOfPkOQeIb1URqFNR8w07+ZXSnkfS7URNhAIMPhcs2QjLkjdO2A1z59t/Ylkf36glm2/q/Fa1yZU/OU68qsrQctfDktHmU9N85TW97i4OUt4ZAku1Vad6YPvcej5aZigVOU4K4Iw1EJB7+1wpk9My18qh8DdhrRL1Z25T+i5KRp3tCb7AU3UoraG4FtVqsvwoOabgLRY01D1/48NmaBT8oH2bf0SC6cXHJQ/GyiEOLptgR7KLasr8d1KhvnCNGEGDikBJBqRkonD6vRnMYnp+mlHu4Ot84It0uL5rqbocbAJ9DHr5zkPdURCbiQfRnmxVo04LHa65Q0DTTF/USPUtWFHTFz9u+CNMGuqL1PsHfw/H3gKS7g4KPtUKbRjAW+YTdMTFKIx6+fwGm+fO96uTtVVnvjGYVyCgO9IEB121NMJuzn1r3kdY73tPfaaei+NS3Qe4iAr7co6lfrV2dClNKz1O59EtCp7HxJ0p2rDxbAEWbYqvFueHNa8FgeOfTfLyjtYwNLQ0Xu/GZxGldysteQuDLvib9jYuanlaN2nVbqGMfAMX7B0577ykLc0Uv1bh7LRuwo6Nz4hQ2dYd45ux52AVuAC0wIFflMkJ/HMoaegKiIJrQAtmAhnpW6xBS380aZpPSDiJvf0LIK6EO9xMZHMNjCgv0vj9ei7RYV8Q2kI9F064CRQIXWHzuniMkn5wnyONDSbgYsLXC8NKEloHpy3I5HVCzmhAjUJF104U7UXJcpp0L2ZFevIsAJ9DnyELeA== X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(186003)(2616005)(7636003)(70206006)(70586007)(7696005)(6666004)(16526019)(336012)(82310400004)(426003)(55016003)(40460700001)(26005)(7049001)(1076003)(36756003)(110136005)(8676002)(54906003)(47076005)(316002)(8936002)(2906002)(4326008)(86362001)(36860700001)(5660300002)(508600001)(83380400001)(107886003)(6286002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2021 16:00:52.0122 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a4b9aa3-3179-44bf-5ed0-08d9b5acea66 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5417 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 690391dd0e8bc7a8d02a3aba844ffc3dffe7aecd ] When application creates several flows to match on GENEVE tunnel without explicitly specifying GENEVE 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 GENEVE protocol type, if application did not specify any without explicitly specifying GENEVE protocol type value in flow rules, protocol type value. Fixes: e59a5dbcfd07 ("net/mlx5: add flow match on GENEVE item") Cc: stable@dpdk.org Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 78 ++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f124f42c9c..8dec8d9ff5 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -75,6 +75,20 @@ static int flow_dv_tbl_resource_release(struct rte_eth_dev *dev, struct mlx5_flow_tbl_resource *tbl); +static inline uint16_t +mlx5_translate_tunnel_etypes(uint64_t pattern_flags) +{ + if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2) + return RTE_ETHER_TYPE_TEB; + else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4) + return RTE_ETHER_TYPE_IPV4; + else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6) + return RTE_ETHER_TYPE_IPV6; + else if (pattern_flags & MLX5_FLOW_LAYER_MPLS) + return RTE_ETHER_TYPE_MPLS; + return 0; +} + /** * Initialize flow attributes structure according to flow items' types. * @@ -6132,49 +6146,39 @@ flow_dv_translate_item_vxlan_gpe(void *matcher, void *key, static void flow_dv_translate_item_geneve(void *matcher, void *key, - const struct rte_flow_item *item, int inner) + const struct rte_flow_item *item, + uint64_t pattern_flags) { + static const struct rte_flow_item_geneve empty_geneve = {0,}; const struct rte_flow_item_geneve *geneve_m = item->mask; const struct rte_flow_item_geneve *geneve_v = item->spec; - void *headers_m; - void *headers_v; + /* GENEVE flow item validation allows single tunnel item */ + 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); - uint16_t dport; uint16_t gbhdr_m; uint16_t gbhdr_v; - char *vni_m; - char *vni_v; - size_t size, i; + char *vni_m = MLX5_ADDR_OF(fte_match_set_misc, misc_m, geneve_vni); + char *vni_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, geneve_vni); + size_t size = sizeof(geneve_m->vni), i; + 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); - } - dport = MLX5_UDP_PORT_GENEVE; if (!MLX5_GET16(fte_match_set_lyr_2_4, headers_v, udp_dport)) { MLX5_SET(fte_match_set_lyr_2_4, headers_m, udp_dport, 0xFFFF); - MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_dport, dport); + MLX5_SET(fte_match_set_lyr_2_4, headers_v, udp_dport, + MLX5_UDP_PORT_GENEVE); + } + if (!geneve_v) { + geneve_v = &empty_geneve; + geneve_m = &empty_geneve; + } else { + if (!geneve_m) + geneve_m = &rte_flow_item_geneve_mask; } - if (!geneve_v) - return; - if (!geneve_m) - geneve_m = &rte_flow_item_geneve_mask; - size = sizeof(geneve_m->vni); - vni_m = MLX5_ADDR_OF(fte_match_set_misc, misc_m, geneve_vni); - vni_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, geneve_vni); memcpy(vni_m, geneve_m->vni, size); for (i = 0; i < size; ++i) vni_v[i] = vni_m[i] & geneve_v->vni[i]; - MLX5_SET(fte_match_set_misc, misc_m, geneve_protocol_type, - rte_be_to_cpu_16(geneve_m->protocol)); - MLX5_SET(fte_match_set_misc, misc_v, geneve_protocol_type, - rte_be_to_cpu_16(geneve_v->protocol & geneve_m->protocol)); gbhdr_m = rte_be_to_cpu_16(geneve_m->ver_opt_len_o_c_rsvd0); gbhdr_v = rte_be_to_cpu_16(geneve_v->ver_opt_len_o_c_rsvd0); MLX5_SET(fte_match_set_misc, misc_m, geneve_oam, @@ -6186,6 +6190,16 @@ flow_dv_translate_item_geneve(void *matcher, void *key, MLX5_SET(fte_match_set_misc, misc_v, geneve_opt_len, MLX5_GENEVE_OPTLEN_VAL(gbhdr_v) & MLX5_GENEVE_OPTLEN_VAL(gbhdr_m)); + protocol_m = rte_be_to_cpu_16(geneve_m->protocol); + protocol_v = rte_be_to_cpu_16(geneve_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, geneve_protocol_type, protocol_m); + MLX5_SET(fte_match_set_misc, misc_v, geneve_protocol_type, + protocol_m & protocol_v); } /** @@ -7806,11 +7820,10 @@ __flow_dv_translate(struct rte_eth_dev *dev, tunnel_item = items; break; case RTE_FLOW_ITEM_TYPE_GENEVE: - flow_dv_translate_item_geneve(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_GENEVE; + tunnel_item = items; break; case RTE_FLOW_ITEM_TYPE_MPLS: flow_dv_translate_item_mpls(match_mask, match_value, @@ -7876,6 +7889,9 @@ __flow_dv_translate(struct rte_eth_dev *dev, if (item_flags & MLX5_FLOW_LAYER_VXLAN_GPE) flow_dv_translate_item_vxlan_gpe(match_mask, match_value, tunnel_item, item_flags); + else if (item_flags & MLX5_FLOW_LAYER_GENEVE) + flow_dv_translate_item_geneve(match_mask, match_value, + tunnel_item, item_flags); assert(!flow_dv_check_valid_spec(matcher.mask.buf, dev_flow->dv.value.buf)); /* -- 2.34.0