From patchwork Sun Feb 5 13:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Xu X-Patchwork-Id: 123056 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 026EE41BDB; Sun, 5 Feb 2023 14:42:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5A3242686; Sun, 5 Feb 2023 14:42:55 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) by mails.dpdk.org (Postfix) with ESMTP id 128B240A7D for ; Sun, 5 Feb 2023 14:42:54 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1Is1vTfCSXzOaUP24t/MJt/XmMrEYY7P6eyVC/jwctrYsnmIam0CrlMcuXUFfYcbgZ/3Gs6bczCw9zeuezaXMVtOQVcqxN5FCFIl2U3CebhtlqEkPqj1ZQh2GwpxQ5ebGRNJzyUdvRDEJj7KffVs5yrkWtRQ37K/8BNoD7Ribi42MuOjsxlJ4TOHi4twp9OlYyfSFf+dkMAJfDZIJwTThfg68SKb317bey0TK+JITrNs7nsCYg7Um2PIYE9+gmOQu3zkfB/D3emcGbYXFJNr6zMeo5fCecKyHBpUcGziwnczevNvmeGKmkQxZj63y6Ah/yrsytO0fwxA+VfebMK9g== 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=Tf+dKMxkP5M4zIXCTbvfggEvxFgXaHbF7v9/AC941oM=; b=JJWydirrT0JcHjb/ITGeHDPnLWxTopqtXbbTRxRAl03uHIKDT4pCFJuGODE3on4j7BmcbE6Es59eIXgxmr3QJdp7jefsXhdheLL0HCKLpWb8sfsQC8UbXGRcHvmdVWglZ3s9thjD1Z6WQuL3D3PNOeVrE4afWvaTRiKRCyWgxAQJgHorQqrigV6/A5uW/Id0hGTAMEyMw4T+uCbUiIrvvzFTDERQIPiJHpJtOrevuznD7YryMbD0M/icvWLKtYHkYa2JegKv9IpJuDLfxOb0Vb6B6uK81uYHU88AaWOIeW73c7hKrEFO+Ye78+3TdVQ7A+O2cTm9IhxbQQXv4LvxvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=Tf+dKMxkP5M4zIXCTbvfggEvxFgXaHbF7v9/AC941oM=; b=taRMgeRP8mFy2O3MPkbhiG7KZ0yU0tCdDQnxEeeUmT0+iTfzyVFI6jqEZA/yZx0ymAGalTBEds1qA8mV/QcX05J8RO+5TxNkMSBVrSysISc8AyiICiYJkUvucWUJhXU71fL6KeqlAYWz8FXaEanzNkeTC3o7qBFKbWRdLVDHuOEHu2YFQaenUScSoBWsOJKFdcRO+10AHRAjAfVuNY5n2+yA7+JItdeWSo9WI7bucMSzwKEcXl38YUDGqWBauUEznQrgHlvdxxp7xsyEFymlrR5Kto7dAtLfpjLHQ07P2UKGS5YX6k4F+lC6z0zs4to0E6J2CFuA8MNjKghICpHMxw== Received: from MW4PR04CA0033.namprd04.prod.outlook.com (2603:10b6:303:6a::8) by SN7PR12MB7251.namprd12.prod.outlook.com (2603:10b6:806:2ab::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sun, 5 Feb 2023 13:42:52 +0000 Received: from CO1PEPF00001A60.namprd05.prod.outlook.com (2603:10b6:303:6a:cafe::cd) by MW4PR04CA0033.outlook.office365.com (2603:10b6:303:6a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Sun, 5 Feb 2023 13:42:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF00001A60.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.21 via Frontend Transport; Sun, 5 Feb 2023 13:42:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 5 Feb 2023 05:42:36 -0800 Received: from nvidia.com (10.126.230.37) 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.36; Sun, 5 Feb 2023 05:42:34 -0800 From: Leo Xu To: CC: Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH v3 2/3] net/mlx5: add ICMPv6 ID and sequence match support Date: Sun, 5 Feb 2023 15:41:53 +0200 Message-ID: <20230205134154.408984-3-yongquanx@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230205134154.408984-1-yongquanx@nvidia.com> References: <20221220074403.1015411-1-yongquanx@nvidia.com> <20230205134154.408984-1-yongquanx@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF00001A60:EE_|SN7PR12MB7251:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e27d1ef-c016-402c-da8e-08db077ee096 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d82+xN2Tqbyr8Q1ztkBmkffIs4SbctYYFVXND9KsinYa8rThQuF1VnI/pEiSqNWildc7Li9ZbKZWDPjiIbWWroe6Czgv30dR/pQRiLayo6ZF3QLMPigE8gfoT4oN9J6IKrOx/b9E3HB4bHhYgLpJPCXrK3r3yFJQmgpJFhtemlIpyjZHxP3V2w9htPTZwVPr4GEWmf3vvLvDsUyFa4LZxhaYCoO+75oeZeaWgmfFmtIZdCVZMgyAk47e4mpWoTuw+32cJ49iR3yhpJncGAHEX0VZNUMNEEDFTK6eWSinLRNKRtqyw0g46a+xbWgc8qTdseAzs/+ncqFQexyUzfHKYeg+R6tcqiGzSHW5TdNdzLOmdHZBVb/+LTVlsfpV+MvBshzgKdW62lJwzr+HUKvZR9iBORD1zzd/62re3oah2NidwXePYblFCnFlyHMsX06d2l9Oezgdz6Ac9BYdRqLZMyG+k5ikNi+ecC0yIyODNMNlPSDgcCSKm6K4kO8SqHwtHv810N6Y7eVLQpxhnAhRBF+PcYm7wbra4DPGKzLBbE/ORpAb2WP04jVvypGEbcfavoxbDS5R2eJxFl6qEXLOuIEZFU1Bos7ydO5SJA1u4LCT4XAuk/xPX8Uv+n8ZxptVGZ/MDVZvUXwaM47nlVO8bL0C4+Ba+tcO0oFEb4k1RiLPNy4hHdun6T4hDX9uuVF+W/5hYBnI9Utd0WAiLjcJYw== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199018)(36840700001)(40470700004)(46966006)(82310400005)(40460700003)(316002)(107886003)(55016003)(40480700001)(6666004)(1076003)(2616005)(478600001)(26005)(16526019)(6286002)(4326008)(8676002)(6916009)(70206006)(7696005)(186003)(54906003)(356005)(86362001)(7636003)(36756003)(82740400003)(70586007)(47076005)(336012)(426003)(83380400001)(36860700001)(5660300002)(41300700001)(8936002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2023 13:42:51.6594 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e27d1ef-c016-402c-da8e-08db077ee096 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF00001A60.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7251 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 ICMPv6 ID and sequence match support. Since type and code of ICMPv6 echo is already specified by ITEM type: RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY mlx5 pmd will set appropriate type and code automatically: Echo request: type(128), code(0) Echo reply: type(129), code(0) type and code provided by application will be ignored. Signed-off-by: Leo Xu Acked-by: Viacheslav Ovsiienko --- doc/guides/nics/features/mlx5.ini | 2 + doc/guides/nics/mlx5.rst | 4 +- doc/guides/rel_notes/release_23_03.rst | 4 ++ drivers/net/mlx5/mlx5_flow.c | 61 +++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_dv.c | 76 ++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 2 + 7 files changed, 151 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini index 62fd330e2b..eb016f34da 100644 --- a/doc/guides/nics/features/mlx5.ini +++ b/doc/guides/nics/features/mlx5.ini @@ -69,6 +69,8 @@ gtp = Y gtp_psc = Y icmp = Y icmp6 = Y +icmp6_echo_request = Y +icmp6_echo_reply = Y integrity = Y ipv4 = Y ipv6 = Y diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index f137f156f9..9c6f1cca19 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -405,8 +405,8 @@ Limitations - The input buffer, providing the removal size, is not validated. - The buffer size must match the length of the headers to be removed. -- ICMP(code/type/identifier/sequence number) / ICMP6(code/type) matching, IP-in-IP and MPLS flow matching are all - mutually exclusive features which cannot be supported together +- ICMP(code/type/identifier/sequence number) / ICMP6(code/type/identifier/sequence number) matching, + IP-in-IP and MPLS flow matching are all mutually exclusive features which cannot be supported together (see :ref:`mlx5_firmware_config`). - LRO: diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 3f5c7af3b6..cac69e3173 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -74,6 +74,10 @@ New Features * Added flow items to match ICMPv6 echo request and reply packets. Matching patterns can include ICMP identifier and sequence numbers. +* **Updated Mellanox mlx5 driver.** + + * Added support for matching on ICMPv6 ID and sequence fields. + Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f5e2831480..b38062c70e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2352,6 +2352,67 @@ mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item, return 0; } +/** + * Validate ICMP6 echo request/reply item. + * + * @param[in] item + * Item specification. + * @param[in] item_flags + * Bit-fields that holds the items detected until now. + * @param[in] ext_vlan_sup + * Whether extended VLAN features are supported or not. + * @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_icmp6_echo(const struct rte_flow_item *item, + uint64_t item_flags, + uint8_t target_protocol, + struct rte_flow_error *error) +{ + const struct rte_flow_item_icmp6_echo *mask = item->mask; + const struct rte_flow_item_icmp6_echo nic_mask = { + .hdr.base.type = 0xff, + .hdr.base.code = 0xff, + .hdr.identifier = RTE_BE16(0xffff), + .hdr.sequence = RTE_BE16(0xffff), + }; + const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); + const uint64_t l3m = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 : + MLX5_FLOW_LAYER_OUTER_L3_IPV6; + const uint64_t l4m = tunnel ? MLX5_FLOW_LAYER_INNER_L4 : + MLX5_FLOW_LAYER_OUTER_L4; + int ret; + + if (target_protocol != 0xFF && target_protocol != IPPROTO_ICMPV6) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "protocol filtering not compatible" + " with ICMP6 layer"); + if (!(item_flags & l3m)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "IPv6 is mandatory to filter on" + " ICMP6"); + if (item_flags & l4m) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "multiple L4 layers not supported"); + if (!mask) + mask = &nic_mask; + ret = mlx5_flow_item_acceptable + (item, (const uint8_t *)mask, + (const uint8_t *)&nic_mask, + sizeof(struct rte_flow_item_icmp6_echo), + MLX5_ITEM_RANGE_NOT_ACCEPTED, error); + if (ret < 0) + return ret; + return 0; +} + /** * Validate ICMP item. * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index e376dcae93..86311b0b08 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2322,6 +2322,10 @@ int mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, struct rte_flow_error *error); +int mlx5_flow_validate_item_icmp6_echo(const struct rte_flow_item *item, + uint64_t item_flags, + uint8_t target_protocol, + struct rte_flow_error *error); int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 7ca909999b..2ac9587761 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7370,6 +7370,17 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, item_ipv6_proto = IPPROTO_ICMPV6; last_item = MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + ret = mlx5_flow_validate_item_icmp6_echo(items, + item_flags, + next_protocol, + error); + if (ret < 0) + return ret; + item_ipv6_proto = IPPROTO_ICMPV6; + last_item = MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_TAG: ret = flow_dv_validate_item_tag(dev, items, attr, error); @@ -10269,6 +10280,65 @@ flow_dv_translate_item_icmp6(void *key, const struct rte_flow_item *item, icmp6_v->code & icmp6_m->code); } +/** + * Add ICMP6 echo request/reply item to the value. + * + * @param[in, out] key + * Flow matcher value. + * @param[in] item + * Flow pattern to translate. + * @param[in] inner + * Item is inner pattern. + * @param[in] key_type + * Set flow matcher mask or value. + */ +static void +flow_dv_translate_item_icmp6_echo(void *key, const struct rte_flow_item *item, + int inner, uint32_t key_type) +{ + const struct rte_flow_item_icmp6_echo *icmp6_m; + const struct rte_flow_item_icmp6_echo *icmp6_v; + uint32_t icmp6_header_data_m = 0; + uint32_t icmp6_header_data_v = 0; + void *headers_v; + void *misc3_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_3); + uint8_t icmp6_type = 0; + struct rte_flow_item_icmp6_echo zero_mask; + + memset(&zero_mask, 0, sizeof(zero_mask)); + headers_v = inner ? MLX5_ADDR_OF(fte_match_param, key, inner_headers) : + MLX5_ADDR_OF(fte_match_param, key, outer_headers); + if (key_type & MLX5_SET_MATCHER_M) + MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, 0xFF); + else + MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, + IPPROTO_ICMPV6); + MLX5_ITEM_UPDATE(item, key_type, icmp6_v, icmp6_m, &zero_mask); + /* Set fixed type and code for icmpv6 echo request or reply */ + icmp6_type = (item->type == RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST ? + RTE_ICMP6_ECHO_REQUEST : RTE_ICMP6_ECHO_REPLY); + if (key_type & MLX5_SET_MATCHER_M) { + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_type, 0xFF); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_code, 0xFF); + } else { + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_type, icmp6_type); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_code, 0); + } + if (icmp6_v == NULL) + return; + /* Set icmp6 header data (identifier & sequence) accordingly */ + icmp6_header_data_m = + (rte_be_to_cpu_16(icmp6_m->hdr.identifier) << 16) | + rte_be_to_cpu_16(icmp6_m->hdr.sequence); + if (icmp6_header_data_m) { + icmp6_header_data_v = + (rte_be_to_cpu_16(icmp6_v->hdr.identifier) << 16) | + rte_be_to_cpu_16(icmp6_v->hdr.sequence); + MLX5_SET(fte_match_set_misc3, misc3_v, icmpv6_header_data, + icmp6_header_data_v & icmp6_header_data_m); + } +} + /** * Add ICMP item to the value. * @@ -13381,6 +13451,12 @@ flow_dv_translate_items(struct rte_eth_dev *dev, wks->priority = MLX5_PRIORITY_MAP_L4; last_item = MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + flow_dv_translate_item_icmp6_echo(key, items, tunnel, key_type); + wks->priority = MLX5_PRIORITY_MAP_L4; + last_item = MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_TAG: flow_dv_translate_item_tag(dev, key, items, key_type); last_item = MLX5_FLOW_ITEM_TAG; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 20c71ff7f0..dbf935ca26 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4731,6 +4731,8 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, case RTE_FLOW_ITEM_TYPE_GRE_OPTION: case RTE_FLOW_ITEM_TYPE_ICMP: case RTE_FLOW_ITEM_TYPE_ICMP6: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: case RTE_FLOW_ITEM_TYPE_CONNTRACK: break; case RTE_FLOW_ITEM_TYPE_INTEGRITY: