From patchwork Mon Dec 12 08:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Xu X-Patchwork-Id: 120765 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 C81A9A034C; Mon, 12 Dec 2022 10:01:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA8E94021D; Mon, 12 Dec 2022 10:01:38 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) by mails.dpdk.org (Postfix) with ESMTP id 2E7DF40151 for ; Mon, 12 Dec 2022 10:01:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fzfj8rxJbjrnkl0F4VhKCkyqj0dzuPTzeLyUY9Vv3lRDar+pTON2gIbeqTPvcxepSM5+WKIC0UpUANaKBapQJjD0ZcbH9e1RIMM21urnyjYMUQqqUa9r1oZs77YLPQF7z7f6PpfOD455UUCdOGF5tbIC9waK5cLq9yLTG2w+shdIImVYwVTqUVAvCteMO5E+PCyAN8mqT4dTHemSUrLKPEA/MCBSS1Aa1pOKMitOuVNq0GfVP0X2IxX7/lsXWtEr/wsAx4Qsmp1930X5XOZPlq9NJLKY+S5NJ0QruocAXGm0ely2hk9qW/GNIQM2kg7ZT/bcUueix5cJFd+nMDP2PQ== 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=U+oSuNMdnywV9KSHyNg/3G67K63PlgNda9irbhy8Ma0=; b=TMZJqxoja42sHeVd2t1LxTELH1nQZ2t+B9pW6YgjTq54BLJds0k74QkdoVCLW7+4p2trGV2Vnxzkp7jwCy3VL51cFK4l060WWzIGw5vusufN/UU6TeY9ovC6HLticqbreOCSFI/hILb2X1ewdh8UekR5G5VtbwMu8qc+K8TRnPNuSTw0KNEpbV1A9yapMlkmanMBzfxHkcub5wqtkyLhmO4A/+WODfTHh8vasdNketQYyECo/PFleFfxjTJe+zZZF2FbzVEXxQclCpmxUBq6WusTsJH5p61M0LOVEaq6ym7DFvzoq0CU5OADVGnvTqhHJgOv1IRZ6c0pQaCnTObdTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=U+oSuNMdnywV9KSHyNg/3G67K63PlgNda9irbhy8Ma0=; b=LwXklnMZwiC3RFSkPr+2vC1RWdsKxibOQk/vMxjwYH8ClYAG/ldULAoECmOr3LeNqXEkdagSelZO9iyoBj/VYuZcesObLzCsrhAy/UVsR8Y9m79cj+dSYBN+7Vdkf5JF3pzjNXEqjOidjZ7BP7P7jvqeKFZjaVpiewj1ia1/qSAtrprL2ChedeZ1VWD/Ryz7TkdZW7gFsnZT1ZqMwdzPfw0HX6BpKVW4Vp4VkQzGt+CIAuhCmITiEHQ100SuNhBzRlwesInoblFYE4pGBoA/vf08U55Eai6eqYyCjvRUi4ThTlBwazxS8jq5yPwY+D2z+NvIwIe5+/zoJ6TGgglODg== Received: from BLAPR03CA0070.namprd03.prod.outlook.com (2603:10b6:208:329::15) by DM4PR12MB7694.namprd12.prod.outlook.com (2603:10b6:8:102::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Mon, 12 Dec 2022 09:01:34 +0000 Received: from BL02EPF0000C406.namprd05.prod.outlook.com (2603:10b6:208:329:cafe::79) by BLAPR03CA0070.outlook.office365.com (2603:10b6:208:329::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19 via Frontend Transport; Mon, 12 Dec 2022 09:01:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0000C406.mail.protection.outlook.com (10.167.241.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9 via Frontend Transport; Mon, 12 Dec 2022 09:01:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 12 Dec 2022 01:01:15 -0800 Received: from nvidia.com (10.126.231.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; Mon, 12 Dec 2022 01:01:11 -0800 From: Leo Xu To: CC: Bing Zhao , Ori Kam , Wenzhuo Lu , Beilei Xing , "Bernard Iremonger" , Thomas Monjalon , Ferruh Yigit , "Andrew Rybchenko" , Olivier Matz Subject: [PATCH 1/3] ethdev: add ICMPv6 id and sequence Date: Mon, 12 Dec 2022 10:59:20 +0200 Message-ID: <20221212085923.2314350-2-yongquanx@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221212085923.2314350-1-yongquanx@nvidia.com> References: <20221212085923.2314350-1-yongquanx@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C406:EE_|DM4PR12MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: 07697995-95f7-4013-4c2f-08dadc1f77e4 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xbw4ZiHK0SBtJOo40IQtik3JyTVKbuxMFtUvguboXqgtV0v93MtFDA5AXHHFWjwcKm6cqHE3d4yYUlZMOcwRzkgw2mX0OoQZSjrmQvsYwKvnBKvVFDpQgVmTniY8/fwUTOSxwl1mxDMUcNjEBipK0b2oRhLbs5o8PUh41HYgcZCOrRj6Eps/YB+scqhyUJx9D3GUiYHK/3K3ZQLHm8FsGe5BfFEvalkB7tWkuAjKyqVmZnNPnXZ0dOhVlxzf9cCgvew8OzsluoMGVCoaSjy0a/UtcnQQR6vaZrgzd3sOLzgl+kRVUNL9IXYhdZL08tj4XmRAGGdTNHQqhaYK2V/kwqZPhlhsdHjGL5uJGYRJ1siThEpDyk2GRk/kukmwgl0F4yqNTxhrXj1gyM76e0QacDUoyDgJJhUsuXpnWoQgXEiiyZWdlUyDE3toT2CDmspG635p4rFI1LYJCxCvLTUKOBuU7M+K6QSPtqoRjpc9EDLasLdibGoSbUFwQC2tEWvShNxkTOJG4/ijY9qYQlBI5PIziqDbpRF1CFbcSpoId5c2b1KJdnZ4VDqoYQv+lmF+mwpYqjashZGIrDPEyeluSYtxuFfI8CiXQhDYrSjI76/XqX0AVWZ0DDnBBR/Po1H2vdQ+ZQHwknPJqpMscfK6YZBPwL5oNr3oGCB0QCwP0Y1N+SkmzxxiajXxjACn8167Lc+a7IJs+P0Bd6AKknZyoQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199015)(46966006)(36840700001)(40470700004)(186003)(16526019)(36756003)(2906002)(47076005)(426003)(336012)(54906003)(1076003)(6916009)(316002)(40460700003)(83380400001)(7696005)(6666004)(40480700001)(86362001)(55016003)(2616005)(26005)(6286002)(478600001)(70206006)(82310400005)(82740400003)(70586007)(41300700001)(8676002)(4326008)(36860700001)(7636003)(8936002)(5660300002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 09:01:33.7862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07697995-95f7-4013-4c2f-08dadc1f77e4 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000C406.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7694 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 API support for ICMPv6 id and sequence. 1: Add two new pattern item types for ICMPv6 echo request and reply: RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY 2: Add new header file rte_icmp6.h for ICMPv6 packet definitions. 3: Enhance testpmd flow pattern to support ICMPv6 identifier and sequence. Example of ICMPv6 echo pattern in testpmd command: pattern eth / ipv6 / icmp6_echo_request / end pattern eth / ipv6 / icmp6_echo_reply / end pattern eth / ipv6 / icmp6_echo_request ident is 20 seq is 30 / end Signed-off-by: Leo Xu Signed-off-by: Bing Zhao --- app/test-pmd/cmdline_flow.c | 70 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 14 +++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 +++ lib/librte_ethdev/rte_flow.c | 4 ++ lib/librte_ethdev/rte_flow.h | 25 ++++++++ lib/librte_net/meson.build | 3 +- lib/librte_net/rte_icmp6.h | 48 ++++++++++++++ 7 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_icmp6.h diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index ce8035cb46..413ef905f2 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -375,6 +375,12 @@ enum index { ITEM_ICMP6, ITEM_ICMP6_TYPE, ITEM_ICMP6_CODE, + ITEM_ICMP6_ECHO_REQUEST, + ITEM_ICMP6_ECHO_REQUEST_ID, + ITEM_ICMP6_ECHO_REQUEST_SEQ, + ITEM_ICMP6_ECHO_REPLY, + ITEM_ICMP6_ECHO_REPLY_ID, + ITEM_ICMP6_ECHO_REPLY_SEQ, ITEM_ICMP6_ND_NS, ITEM_ICMP6_ND_NS_TARGET_ADDR, ITEM_ICMP6_ND_NA, @@ -1373,6 +1379,8 @@ static const enum index next_item[] = { ITEM_IPV6_EXT, ITEM_IPV6_FRAG_EXT, ITEM_ICMP6, + ITEM_ICMP6_ECHO_REQUEST, + ITEM_ICMP6_ECHO_REPLY, ITEM_ICMP6_ND_NS, ITEM_ICMP6_ND_NA, ITEM_ICMP6_ND_OPT, @@ -1629,6 +1637,20 @@ static const enum index item_icmp6[] = { ZERO, }; +static const enum index item_icmp6_echo_request[] = { + ITEM_ICMP6_ECHO_REQUEST_ID, + ITEM_ICMP6_ECHO_REQUEST_SEQ, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_icmp6_echo_reply[] = { + ITEM_ICMP6_ECHO_REPLY_ID, + ITEM_ICMP6_ECHO_REPLY_SEQ, + ITEM_NEXT, + ZERO, +}; + static const enum index item_icmp6_nd_ns[] = { ITEM_ICMP6_ND_NS_TARGET_ADDR, ITEM_NEXT, @@ -4432,6 +4454,54 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6, code)), }, + [ITEM_ICMP6_ECHO_REQUEST] = { + .name = "icmp6_echo_request", + .help = "match ICMPv6 echo request", + .priv = PRIV_ITEM(ICMP6_ECHO_REQUEST, + sizeof(struct rte_flow_item_icmp6_echo)), + .next = NEXT(item_icmp6_echo_request), + .call = parse_vc, + }, + [ITEM_ICMP6_ECHO_REQUEST_ID] = { + .name = "ident", + .help = "ICMPv6 echo request identifier", + .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo, + echo.identifier)), + }, + [ITEM_ICMP6_ECHO_REQUEST_SEQ] = { + .name = "seq", + .help = "ICMPv6 echo request sequence", + .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo, + echo.sequence)), + }, + [ITEM_ICMP6_ECHO_REPLY] = { + .name = "icmp6_echo_reply", + .help = "match ICMPv6 echo reply", + .priv = PRIV_ITEM(ICMP6_ECHO_REPLY, + sizeof(struct rte_flow_item_icmp6_echo)), + .next = NEXT(item_icmp6_echo_reply), + .call = parse_vc, + }, + [ITEM_ICMP6_ECHO_REPLY_ID] = { + .name = "ident", + .help = "ICMPv6 echo reply identifier", + .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo, + echo.identifier)), + }, + [ITEM_ICMP6_ECHO_REPLY_SEQ] = { + .name = "seq", + .help = "ICMPv6 echo reply sequence", + .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo, + echo.sequence)), + }, [ITEM_ICMP6_ND_NS] = { .name = "icmp6_nd_ns", .help = "match ICMPv6 neighbor discovery solicitation", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b0bbb6fcbe..282fa1176c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1260,6 +1260,20 @@ Matches any ICMPv6 header. - ``checksum``: ICMPv6 checksum. - Default ``mask`` matches ``type`` and ``code``. +Item: ``ICMP6_ECHO_REQUEST`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Matches an ICMPv6 echo request. + +- ``echo``: ICMP6 echo definition (``rte_icmp6.h``). + +Item: ``ICMP6_ECHO_REPLY`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Matches an ICMPv6 echo reply. + +- ``echo``: ICMP6 echo definition (``rte_icmp6.h``). + Item: ``ICMP6_ND_NS`` ^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index d711ca1f5c..6c370c033f 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4033,6 +4033,16 @@ This section lists supported pattern items and their attributes, if any. - ``type {unsigned}``: ICMPv6 type. - ``code {unsigned}``: ICMPv6 code. +- ``icmp6_echo_request``: match ICMPv6 echo request. + + - ``ident {unsigned}``: ICMPv6 echo request identifier. + - ``seq {unsigned}``: ICMPv6 echo request sequence number. + +- ``icmp6_echo_reply``: match ICMPv6 echo reply. + + - ``ident {unsigned}``: ICMPv6 echo reply identifier. + - ``seq {unsigned}``: ICMPv6 echo reply sequence number. + - ``icmp6_nd_ns``: match ICMPv6 neighbor discovery solicitation. - ``target_addr {ipv6 address}``: target address. diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 350c46420c..4f4c641111 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -128,6 +128,10 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(IPV6_EXT, sizeof(struct rte_flow_item_ipv6_ext)), MK_FLOW_ITEM(IPV6_FRAG_EXT, sizeof(struct rte_flow_item_ipv6_frag_ext)), MK_FLOW_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)), + MK_FLOW_ITEM(ICMP6_ECHO_REQUEST, + sizeof(struct rte_flow_item_icmp6_echo)), + MK_FLOW_ITEM(ICMP6_ECHO_REPLY, + sizeof(struct rte_flow_item_icmp6_echo)), MK_FLOW_ITEM(ICMP6_ND_NS, sizeof(struct rte_flow_item_icmp6_nd_ns)), MK_FLOW_ITEM(ICMP6_ND_NA, sizeof(struct rte_flow_item_icmp6_nd_na)), MK_FLOW_ITEM(ICMP6_ND_OPT, sizeof(struct rte_flow_item_icmp6_nd_opt)), diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 1b527f045a..fa21ed0c52 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -684,6 +685,20 @@ enum rte_flow_item_type { * @see struct rte_flow_item_quota */ RTE_FLOW_ITEM_TYPE_QUOTA, + + /** + * Matches an ICMPv6 echo request. + * + * See struct rte_flow_item_icmp6_echo. + */ + RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST, + + /** + * Matches an ICMPv6 echo reply. + * + * See struct rte_flow_item_icmp6_echo. + */ + RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY, }; /** @@ -1428,6 +1443,16 @@ static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = { }; #endif +/** + * RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST + * RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY + * + * Matches an ICMPv6 echo request or reply. + */ +struct rte_flow_item_icmp6_echo { + struct rte_icmp6_echo echo; +}; + /** * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS * diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build index 94d816e79f..5c5d0a03c6 100644 --- a/lib/librte_net/meson.build +++ b/lib/librte_net/meson.build @@ -17,7 +17,8 @@ headers = files('rte_ip.h', 'rte_mpls.h', 'rte_higig.h', 'rte_ecpri.h', - 'rte_geneve.h') + 'rte_geneve.h', + 'rte_icmp6.h') sources = files('rte_arp.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c') deps += ['mbuf'] diff --git a/lib/librte_net/rte_icmp6.h b/lib/librte_net/rte_icmp6.h new file mode 100644 index 0000000000..bf6956d7c9 --- /dev/null +++ b/lib/librte_net/rte_icmp6.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 NVIDIA Corporation & Affiliates + */ + +#ifndef _RTE_ICMP6_H_ +#define _RTE_ICMP6_H_ + +/** + * @file + * + * ICMP6-related defines + */ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * ICMP6 header + */ +struct rte_icmp6_hdr { + uint8_t type; + uint8_t code; + rte_be16_t checksum; +} __rte_packed; + +/** + * ICMP6 echo + */ +struct rte_icmp6_echo { + struct rte_icmp6_hdr hdr; + rte_be16_t identifier; + rte_be16_t sequence; +} __rte_packed; + +/* ICMP6 packet types */ +#define RTE_ICMP6_ECHO_REQUEST 128 +#define RTE_ICMP6_ECHO_REPLY 129 + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_ICMP6_H_ */ From patchwork Mon Dec 12 08:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Xu X-Patchwork-Id: 120766 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 781F6A034C; Mon, 12 Dec 2022 10:01:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91DE440A84; Mon, 12 Dec 2022 10:01:42 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) by mails.dpdk.org (Postfix) with ESMTP id 38E5040151 for ; Mon, 12 Dec 2022 10:01:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxodnKPQp+lHzpex+JNK3mgEnccSTjLzEftl4RXmKNBXCFufBYpwqLvniwImZ9ozJhNQgSxjM7LA9UCPivAetbHL9BM4Vac2gTuSf2WbVZiJHDXimSlwMsPFk/EmjmwKHebqZrqANrd6VXuXfHAnHHS8rYjMznT5pF9ywwd8de79mZrM7Gk1b1d4c6Gna8o3JGFalrfcSRyG5j2oeTfGONf29bMO7KVYjCw6kLnPtiJkWiMnnevc/NbhfhqMnXlWDNM9bWUAC/1dsDF9GmSPgoj0Fvnbi+Gfsr8GhuPDOFn2lLNcQFghG+IT6KCWvqquZqWKQcyTRQiuOLp5JN9COQ== 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=gK4nHoNZnz5rLQvJ5uKWURHC67v3nxhxJrMyROqPufA=; b=K8oTgpngzmESNA/zLqEuyYJxXAHSWxTFH0DDgBgWtashpdZwbCsa906Aw/C/J93V1gGty6PoSnKOkNr6vqVZVDtILdfWsVnZ6rNm5DhFrZd+jOsAo1kJ42nLgOq/Kvh/5mToEVk1mcvXhMfcDWKdeW5F3HMuihw8HIw4zn4vCpfkAFvEY1To0QizroJhOUCxIgLjmxGUYHFJBB5fDBF+vSQ8UbISH5ZxtVpbaz1+JYLkULq0ToHM4Jifs1Apl1WpmbvKqGR29KrAo1jC/yqmxQzeB7faiUPWb6uuOci5UPZ8XNEHt6MLh5NZKPmVlSPqAl2j+v6pgY5zrnIXDyhajw== 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=gK4nHoNZnz5rLQvJ5uKWURHC67v3nxhxJrMyROqPufA=; b=O1SuSJZhoC+BT6+C1llht27Td8/GqwXvKxrRZ8kzE+il4vSGn7eKiTmJKIHtIgpUEWzZfL3ONwdFDzWPoMBIMzHjCDhygCQWKIPuGR1kzKq075u1OLvdmfB3M/+wyc26Jyg9SNb8bhF48xr98P83KfwqYXEFSiM67wJKl1qnD8CVN/F+WoyHnwvEtWYuLorowfzSQ1WyYf0zJC/d978j+7al/AhT5dWVBO0QryvzgX/Fa424M0wxAYby32xRS/Z4cH9p21X24RuDa71K7STRz6Eve0sxePAl/UdZqOUZ2pF7yGZieC7y7QaUe/cY+PyChdyfKUZip2i8yrPf6XzoXg== Received: from BL1PR13CA0181.namprd13.prod.outlook.com (2603:10b6:208:2be::6) by CH2PR12MB4120.namprd12.prod.outlook.com (2603:10b6:610:7b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Mon, 12 Dec 2022 09:01:39 +0000 Received: from BL02EPF0000EE3D.namprd05.prod.outlook.com (2603:10b6:208:2be:cafe::8f) by BL1PR13CA0181.outlook.office365.com (2603:10b6:208:2be::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9 via Frontend Transport; Mon, 12 Dec 2022 09:01:39 +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 BL02EPF0000EE3D.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Mon, 12 Dec 2022 09:01:38 +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; Mon, 12 Dec 2022 01:01:18 -0800 Received: from nvidia.com (10.126.231.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; Mon, 12 Dec 2022 01:01:16 -0800 From: Leo Xu To: CC: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Subject: [PATCH 2/3] net/mlx5: add ICMPv6 id and sequence match support Date: Mon, 12 Dec 2022 10:59:21 +0200 Message-ID: <20221212085923.2314350-3-yongquanx@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221212085923.2314350-1-yongquanx@nvidia.com> References: <20221212085923.2314350-1-yongquanx@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000EE3D:EE_|CH2PR12MB4120:EE_ X-MS-Office365-Filtering-Correlation-Id: b0bb59c5-79fe-4343-6a54-08dadc1f7af4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FwnZc5RgvsSx6/90UfnKOZWKIxyJXnqgZwubl157FIVVQbxm6pigSH+FlB61bpIZA4Y9i6o56b+5+LPE4uJIgKWGCs6+lyxjI9Ojx0g8uOjy8Kb5yspSn1m2gSClUtkuZVe56zYoFhhvwszE4A2xBVMTP//tD8Mo1BbHqMlk1PSw851Erv0rfhQdzaNtv9Eo1DYfiBDB2NaB56dck9RHL2sYq4Xw4qljHdPHJWveYUdkQB9jXLcrthP3hnsMj1sgkX0r2HGAt3VhlQpZgVCWOK3A4aGUyXl0M8FkSoK7eMRrxyK+DEVX/cHMIg4+3qc6jGTqGAXzYWLXypEX3NqaUZhgDb36E5QfW12yZYuEFVoYnZTslKJA0C04UG9ymYHVUmnxRdsN5gdHOkg6gLcB1b82DYjEhBAP2VJMr3fLDZsknzN9DDjxOqoFuP5u0krfDj60kkwfbpLGVMjlNDpkqjryh2BZT0CvvGFZCGlDThof+LzAQuJALQWrDzF4CVKU7vpHY5vsgc0ymC4DAD3pro9YV4BahuXgVjqrYD5PPZP5oWU4elWwAc2aTHitASQfBBUXoF8ndLnIhgGBvgrbygK0TLzIxFD6N+GjKqaIP65ZlTobJpViiml5w3t6R/d9/fenYJHTLGYfcp5u4F72gAdIJzYThUUxwRoyPr3DMqA9gvDEtnodau+wBXKJXne90/BCXxcSzc1oZmoK+EfCSA== 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:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(54906003)(316002)(2906002)(6916009)(40460700003)(478600001)(36756003)(7636003)(356005)(83380400001)(82740400003)(36860700001)(82310400005)(107886003)(6286002)(55016003)(86362001)(336012)(6666004)(40480700001)(186003)(1076003)(7696005)(16526019)(426003)(47076005)(26005)(2616005)(70206006)(70586007)(5660300002)(8936002)(41300700001)(4326008)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 09:01:38.9094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0bb59c5-79fe-4343-6a54-08dadc1f7af4 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: BL02EPF0000EE3D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4120 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 --- doc/guides/nics/mlx5.rst | 2 +- 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 + 5 files changed, 144 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 328c728f13..d17bb1fe47 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -328,7 +328,7 @@ 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 +- 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`). diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 114451b872..bf6a3010ca 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2442,6 +2442,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 = { + .echo.hdr.type = 0xff, + .echo.hdr.code = 0xff, + .echo.identifier = RTE_BE16(0xffff), + .echo.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 322ffc5651..e9d763cd4c 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2333,6 +2333,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 49425087d6..1ecfd13d67 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6194,6 +6194,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); @@ -9165,6 +9176,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->echo.identifier) << 16) | + rte_be_to_cpu_16(icmp6_m->echo.sequence); + if (icmp6_header_data_m) { + icmp6_header_data_v = + (rte_be_to_cpu_16(icmp6_v->echo.identifier) << 16) | + rte_be_to_cpu_16(icmp6_v->echo.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. * @@ -12804,6 +12874,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 8d59e73581..f9ad862707 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4765,6 +4765,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: case RTE_FLOW_ITEM_TYPE_QUOTA: break; From patchwork Mon Dec 12 08:59:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Xu X-Patchwork-Id: 120767 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 9830BA034C; Mon, 12 Dec 2022 10:01:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99FFC42D1D; Mon, 12 Dec 2022 10:01:43 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062.outbound.protection.outlook.com [40.107.96.62]) by mails.dpdk.org (Postfix) with ESMTP id 9A19F40A89 for ; Mon, 12 Dec 2022 10:01:42 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eWJFbklWbIPXVlpzT9JJMShW7dn8YRe9BoTIwC9/CdzD6maghVHJvXC6U26t0+GR5kPKfpd7QBPMFGskZkxv07DqvPlIZoLIpzGf6InJYCng9Ii9uke9Vg1NNQFAv43zAbcYjKYDUYpbndnKP4lZb14/OjayqDCEjDm04h4j+TtbNY0EsajXh7TX+BjmXDSwDBEkbCpLZV0eCRSUh7P4t1oAK0dyGT30HB1K4AohKNkmyBFIQXTaAhXqhCfMThFr4MWpZ85O7ownIL5JYVJwUBgLb3PvLp+GMMBEJX5LOZVAGYdiwXX5I8Cw8zk0jlbucgR06podvgH2ILzxNprVqw== 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=DCt/pi/DbnxNOyCjwP63CddWBq4vZ6DbTdOCRHUKFfY=; b=D2ZXSkwbt++H7vNt4wJRYOXMP9uzHwdfnv5RiXLf/uwtBj3MXCcYrV9ZqoLaejsRrU8g8hSIZP79C52S4FYCuonAx0F3TOwWfLj0sQEJ1oTISH2tWDzpMpyBD8zqhtl2ZmsBFSGANNElsLIo5/OYGcOP3GwdBjehfbdw6jsy3BLHK1Cdyz8pT8r9SQ0iX3lVId1RkxrJpNp64/BGefNt2YbXpsmYIqcn9/nJ6+AIjmbGKvGuXwo9u+1izpBDelaLZjHrUWa1TzGDJGhQ3jy6f2NFjGNl+iUafyXi+iD0qyjpZYNBf/BdUcufTWLq3lNUZFNPNScT7z/fiHedvkmxbQ== 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=DCt/pi/DbnxNOyCjwP63CddWBq4vZ6DbTdOCRHUKFfY=; b=RWxWGP76XljymD/0LxI1q0APmTk+rvNHTM7n4wZFrYqrqIVq94Y8zvLpdxzyFtUC66T4S/rJJpTh3Ms8I5EQKJq8WTFnzqIzND0vU/ryFUBkbimlHIMlDfm7XUnch3OFSy6pyQYhVOBf/q7lWpIm+1DI138UAk/IUKgrZMrNvD5JZHP7OskPQs3Z3gHTtmHBvaGw2lOA1T158sEYhPRZyqdT2TW58X5PFwNljJYVkqSgJjkCq3JAixHV9+NtkK+AL5bktiI/zaf09I8gigNlf98AUFVwlswlHfbkHBd/n5uhbwsCznqEdObpi87TmIebz3ks+ByG77EH1kc24/PWxg== Received: from BL1PR13CA0267.namprd13.prod.outlook.com (2603:10b6:208:2ba::32) by DS7PR12MB6333.namprd12.prod.outlook.com (2603:10b6:8:96::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Mon, 12 Dec 2022 09:01:40 +0000 Received: from BL02EPF0000EE3E.namprd05.prod.outlook.com (2603:10b6:208:2ba:cafe::36) by BL1PR13CA0267.outlook.office365.com (2603:10b6:208:2ba::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9 via Frontend Transport; Mon, 12 Dec 2022 09:01:40 +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 BL02EPF0000EE3E.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Mon, 12 Dec 2022 09:01:40 +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; Mon, 12 Dec 2022 01:01:21 -0800 Received: from nvidia.com (10.126.231.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; Mon, 12 Dec 2022 01:01:18 -0800 From: Leo Xu To: CC: Shun Hao , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Subject: [PATCH 3/3] net/mlx5/hws: add ICMPv6 id and sequence match support Date: Mon, 12 Dec 2022 10:59:22 +0200 Message-ID: <20221212085923.2314350-4-yongquanx@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221212085923.2314350-1-yongquanx@nvidia.com> References: <20221212085923.2314350-1-yongquanx@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000EE3E:EE_|DS7PR12MB6333:EE_ X-MS-Office365-Filtering-Correlation-Id: 0072cda0-1953-4b74-db4e-08dadc1f7ba2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M+BgqPXbDUJQ6jsnGmbbwP8IEa26FP6AuBrP76oaI7xJsaahInXEmF2HA2MwS13WhCi4a0QuJw7jtgamfaT1cyAyhqfVcgnKwPWRD9X5E+nqUpMMiHwAYCne/1E8c00grY9ynnkbfYfQJRBAqq0C9SXocLjPY4bkLZfzcwPhP8wcW0xqrJPwhvtcUwEK+ywoOdtgzrum8rnvlcwBSb33WLbsMZhNyFWPiduNuqekeemw1ZsmebfJ8Url4WczHdfpnpZwhraMMF5CEdUkNvH1g6IFbc7z5qpJBEuqtI17KvBjgod/daUC6qURydBD66Yxr+JO+E5zIXoFhv0SDZZYYo4pY41xKznJc5S52wMrNKjT6IXM9rk1kRz7j5HZyvrePsAebfhqlkPSpk9oPYHW1BoBqave5eRiTLylRCsJOYhch93rCTNx/+z9+GaKQrcjcEqmYQvaQRV0LOgiIuupUykfDdYDP1i1Zu9lwlPxenez8bPB4vJTregJxMuRs4amaHrStulCfcdKSy0C7eiBJEOFlHYDCFDmK+Uabc2YpGqqTitoQPj+y64c73Zbd2VzwAh8H6c7Bvl30n2FXJsHRNw4nWdsXbTDz/16FjRxE1x5EVYbW1TnEoG/jgPtto8jmAq5POiJqCatN5pjvzOivlUaFt7QponW93R8HpIHT5TUMAqF30WkxXI6RJ/sS7ufIIQDCQEi7NnysYQ3c81X1Q== 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:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(40470700004)(46966006)(36840700001)(47076005)(86362001)(5660300002)(70586007)(107886003)(2616005)(356005)(186003)(2906002)(6666004)(478600001)(40480700001)(426003)(336012)(7636003)(16526019)(40460700003)(36756003)(8676002)(70206006)(82310400005)(7696005)(82740400003)(55016003)(6286002)(83380400001)(1076003)(54906003)(4326008)(36860700001)(316002)(41300700001)(26005)(8936002)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 09:01:40.0838 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0072cda0-1953-4b74-db4e-08dadc1f7ba2 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: BL02EPF0000EE3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6333 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 for HWS. 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 This patch also fixes these issues in ICMP definer. 1. Parsing inner ICMP item gets and overwrites the outer IP_PROTOCOL function, which will remove the outer L4 match incorrectly. Fix this by getting correct inner function. 2. Member order of mlx5_ifc_header_icmp_bits doesn't follow ICMP format. Reorder them to make it more consistent. Signed-off-by: Leo Xu Signed-off-by: Shun Hao --- drivers/net/mlx5/steering/mlx5dr_definer.c | 110 ++++++++++++++++++--- drivers/net/mlx5/steering/mlx5dr_definer.h | 6 +- 2 files changed, 102 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/steering/mlx5dr_definer.c b/drivers/net/mlx5/steering/mlx5dr_definer.c index 9bb0f3b117..96da706ee2 100644 --- a/drivers/net/mlx5/steering/mlx5dr_definer.c +++ b/drivers/net/mlx5/steering/mlx5dr_definer.c @@ -316,9 +316,9 @@ mlx5dr_definer_icmp_dw1_set(struct mlx5dr_definer_fc *fc, icmp_dw1 = (v->hdr.icmp_type << __mlx5_dw_bit_off(header_icmp, type)) | (v->hdr.icmp_code << __mlx5_dw_bit_off(header_icmp, code)) | - (v->hdr.icmp_cksum << __mlx5_dw_bit_off(header_icmp, cksum)); + (rte_be_to_cpu_16(v->hdr.icmp_cksum) << __mlx5_dw_bit_off(header_icmp, cksum)); - DR_SET_BE32(tag, icmp_dw1, fc->byte_off, fc->bit_off, fc->bit_mask); + DR_SET(tag, icmp_dw1, fc->byte_off, fc->bit_off, fc->bit_mask); } static void @@ -329,10 +329,10 @@ mlx5dr_definer_icmp_dw2_set(struct mlx5dr_definer_fc *fc, const struct rte_flow_item_icmp *v = item_spec; rte_be32_t icmp_dw2; - icmp_dw2 = (v->hdr.icmp_ident << __mlx5_dw_bit_off(header_icmp, ident)) | - (v->hdr.icmp_seq_nb << __mlx5_dw_bit_off(header_icmp, seq_nb)); + icmp_dw2 = (rte_be_to_cpu_16(v->hdr.icmp_ident) << __mlx5_dw_bit_off(header_icmp, ident)) | + (rte_be_to_cpu_16(v->hdr.icmp_seq_nb) << __mlx5_dw_bit_off(header_icmp, seq_nb)); - DR_SET_BE32(tag, icmp_dw2, fc->byte_off, fc->bit_off, fc->bit_mask); + DR_SET(tag, icmp_dw2, fc->byte_off, fc->bit_off, fc->bit_mask); } static void @@ -345,9 +345,50 @@ mlx5dr_definer_icmp6_dw1_set(struct mlx5dr_definer_fc *fc, icmp_dw1 = (v->type << __mlx5_dw_bit_off(header_icmp, type)) | (v->code << __mlx5_dw_bit_off(header_icmp, code)) | - (v->checksum << __mlx5_dw_bit_off(header_icmp, cksum)); + (rte_be_to_cpu_16(v->checksum) << __mlx5_dw_bit_off(header_icmp, cksum)); - DR_SET_BE32(tag, icmp_dw1, fc->byte_off, fc->bit_off, fc->bit_mask); + DR_SET(tag, icmp_dw1, fc->byte_off, fc->bit_off, fc->bit_mask); +} + +static void +mlx5dr_definer_icmp6_echo_dw1_mask_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {0xFF, 0xFF, 0x0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_request_dw1_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {RTE_ICMP6_ECHO_REQUEST, 0, 0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_reply_dw1_set(struct mlx5dr_definer_fc *fc, + __rte_unused const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6 spec = {RTE_ICMP6_ECHO_REPLY, 0, 0}; + mlx5dr_definer_icmp6_dw1_set(fc, &spec, tag); +} + +static void +mlx5dr_definer_icmp6_echo_dw2_set(struct mlx5dr_definer_fc *fc, + const void *item_spec, + uint8_t *tag) +{ + const struct rte_flow_item_icmp6_echo *v = item_spec; + rte_be32_t dw2; + + dw2 = (rte_be_to_cpu_16(v->echo.identifier) << __mlx5_dw_bit_off(header_icmp, ident)) | + (rte_be_to_cpu_16(v->echo.sequence) << __mlx5_dw_bit_off(header_icmp, seq_nb)); + + DR_SET(tag, dw2, fc->byte_off, fc->bit_off, fc->bit_mask); } static void @@ -1419,9 +1460,9 @@ mlx5dr_definer_conv_item_icmp(struct mlx5dr_definer_conv_data *cd, struct mlx5dr_definer_fc *fc; bool inner = cd->tunnel; - /* Overwrite match on outer L4 type ICMP */ + /* Overwrite match on L4 type ICMP */ if (!cd->relaxed) { - fc = &cd->fc[MLX5DR_DEFINER_FNAME_IP_PROTOCOL_O]; + fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)]; fc->item_idx = item_idx; fc->tag_set = &mlx5dr_definer_icmp_protocol_set; fc->tag_mask_set = &mlx5dr_definer_ones_set; @@ -1457,9 +1498,9 @@ mlx5dr_definer_conv_item_icmp6(struct mlx5dr_definer_conv_data *cd, struct mlx5dr_definer_fc *fc; bool inner = cd->tunnel; - /* Overwrite match on outer L4 type ICMP6 */ + /* Overwrite match on L4 type ICMP6 */ if (!cd->relaxed) { - fc = &cd->fc[MLX5DR_DEFINER_FNAME_IP_PROTOCOL_O]; + fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)]; fc->item_idx = item_idx; fc->tag_set = &mlx5dr_definer_icmp_protocol_set; fc->tag_mask_set = &mlx5dr_definer_ones_set; @@ -1479,6 +1520,48 @@ mlx5dr_definer_conv_item_icmp6(struct mlx5dr_definer_conv_data *cd, return 0; } +static int +mlx5dr_definer_conv_item_icmp6_echo(struct mlx5dr_definer_conv_data *cd, + struct rte_flow_item *item, + int item_idx) +{ + const struct rte_flow_item_icmp6_echo *m = item->mask; + struct mlx5dr_definer_fc *fc; + bool inner = cd->tunnel; + + if (!cd->relaxed) { + /* Overwrite match on L4 type ICMP6 */ + fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, inner)]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_icmp_protocol_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + DR_CALC_SET(fc, eth_l2, l4_type, inner); + + /* Set fixed type and code for icmp6 echo request/reply */ + fc = &cd->fc[MLX5DR_DEFINER_FNAME_ICMP_DW1]; + fc->item_idx = item_idx; + fc->tag_mask_set = &mlx5dr_definer_icmp6_echo_dw1_mask_set; + if (item->type == RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST) + fc->tag_set = &mlx5dr_definer_icmp6_echo_request_dw1_set; + else /* RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY */ + fc->tag_set = &mlx5dr_definer_icmp6_echo_reply_dw1_set; + DR_CALC_SET_HDR(fc, tcp_icmp, icmp_dw1); + } + + if (!m) + return 0; + + /* Set identifier & sequence into icmp_dw2 */ + if (m->echo.identifier || m->echo.sequence) { + fc = &cd->fc[MLX5DR_DEFINER_FNAME_ICMP_DW2]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_icmp6_echo_dw2_set; + DR_CALC_SET_HDR(fc, tcp_icmp, icmp_dw2); + } + + return 0; +} + static int mlx5dr_definer_conv_item_meter_color(struct mlx5dr_definer_conv_data *cd, struct rte_flow_item *item, @@ -1615,6 +1698,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_icmp6(&cd, items, i); item_flags |= MLX5_FLOW_LAYER_ICMP6; break; + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST: + case RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY: + ret = mlx5dr_definer_conv_item_icmp6_echo(&cd, items, i); + item_flags |= MLX5_FLOW_LAYER_ICMP6; + break; case RTE_FLOW_ITEM_TYPE_METER_COLOR: ret = mlx5dr_definer_conv_item_meter_color(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_METER_COLOR; diff --git a/drivers/net/mlx5/steering/mlx5dr_definer.h b/drivers/net/mlx5/steering/mlx5dr_definer.h index 9bf4bb3c13..b826b4468e 100644 --- a/drivers/net/mlx5/steering/mlx5dr_definer.h +++ b/drivers/net/mlx5/steering/mlx5dr_definer.h @@ -536,16 +536,16 @@ struct mlx5_ifc_header_icmp_bits { union { u8 icmp_dw1[0x20]; struct { - u8 cksum[0x10]; - u8 code[0x8]; u8 type[0x8]; + u8 code[0x8]; + u8 cksum[0x10]; }; }; union { u8 icmp_dw2[0x20]; struct { - u8 seq_nb[0x10]; u8 ident[0x10]; + u8 seq_nb[0x10]; }; }; };