From patchwork Wed Dec 27 09:07:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bing Zhao X-Patchwork-Id: 135609 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 CE437437A9; Wed, 27 Dec 2023 10:08:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D53E402F1; Wed, 27 Dec 2023 10:08:16 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) by mails.dpdk.org (Postfix) with ESMTP id 0877A402EA for ; Wed, 27 Dec 2023 10:08:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nl2Pwt86d+dtYrcWqolyc9mDQO02BFOCxWdm3eR8oNc5Yf1ly/zdDH5uXDEO09aUCzF2xaRbHXgjUfUwxJujwUFtgWexVMkU8XJRA8bEwkRpjNz5djlRLDe/4iJbgtNN2GgGc6LN5nRGUYGgKgvSdcMhHRvH9jNlGq5SEYepKVLOuVkP0rLD1o/pAeU/DhvSdwX0RLw0KeXz/pin4Ji0mF5TtlKlved/zgBHs93irUMdeGqDaTm17TdCoOU/Kf18FFamnVRh79KYyMBITxjcETPaGXhyGwTVYpLRGtNztr+apIfuqgjtmON5snzX5Rk1gK5uGxyffNQr3nqU7BDAAA== 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=AMcekYJnCTzJGPxsuGYVL8CmAr+kWP8PfAdlUuGn8HE=; b=A+Kvg6ZTSD/x/rjBY8qOAANZgP6WL6ZjZXxNtv7Mz0SpTium2B6Pkzmj7qewYkt3+kMOIEJ5vjEKXp3oX6w3ey8NNig1M96JAZ1zhnlpgFQINz/ZzULubLEO2o3tllU2ZVB8LHVeDJXAFopSPkWSRgWwpHgtvQXcX+jRUUiKwkNYUfOyyPb25DmJJIQxf8gzyH9zySITVgZ6COPdtWytmbPurdMPojsmq948Z6qerbJrWYza00g0mcYMA4Vo6mOWhl/j9RYrucyc+cuMk/SnXldh6AaxdIoyeaZ0UDU2DJ58tZB+MNPgqOPZG8lPUbjtReQJjolUFjB5bk+tXqCUeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=intel.com 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 (0) 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=AMcekYJnCTzJGPxsuGYVL8CmAr+kWP8PfAdlUuGn8HE=; b=Ul4nClVSiKIbdrvRCC80IoTjecBkwTobs8omCDTNFUB+wQOSN/k+PLQ7E0Riw7GVO3Tvjut0Q1azaIFdVSMJUuE5VB+0URrbVx9uJspZO/PVCLtu7FWAiorrxxLoP10YRqydf0X86w1ZPpUc0jq0uunv/gD1PNE50ZncFC515R6U6kZP8WMRW/5NEffOgmxcKcAF8X+Nza6f52+zoTejIfwV0cfwvSOy73MV3+YV1P2mTzsBhegvjvS1EVRT7DJmAXqk6woDhGIw6iE8jWDGg11ShRBnuN3hNELiFuzIjgsGeU9mc9iQjJ3uc4axkHsd0KD0tpf8BiqLVjMP2xYnqQ== Received: from MN2PR04CA0015.namprd04.prod.outlook.com (2603:10b6:208:d4::28) by PH7PR12MB7818.namprd12.prod.outlook.com (2603:10b6:510:269::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Wed, 27 Dec 2023 09:08:10 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:d4:cafe::12) by MN2PR04CA0015.outlook.office365.com (2603:10b6:208:d4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27 via Frontend Transport; Wed, 27 Dec 2023 09:08:10 +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 MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.14 via Frontend Transport; Wed, 27 Dec 2023 09:08:10 +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.41; Wed, 27 Dec 2023 01:07:56 -0800 Received: from nvidia.com (10.126.230.35) 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.41; Wed, 27 Dec 2023 01:07:53 -0800 From: Bing Zhao To: , , , , , , , , , , , Subject: [PATCH 1/8] ethdev: introduce NAT64 action Date: Wed, 27 Dec 2023 11:07:24 +0200 Message-ID: <20231227090731.2569427-2-bingz@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231227090731.2569427-1-bingz@nvidia.com> References: <20231227090731.2569427-1-bingz@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] 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: MN1PEPF0000ECDB:EE_|PH7PR12MB7818:EE_ X-MS-Office365-Filtering-Correlation-Id: 2129b843-0cf8-4c38-9e05-08dc06bb591a 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: bhIAARpUm8jVBqtqwCEr7rhvBHJk8PnSz/9XdUmF8zLjczLXvXRYSddC3wLdzE3qBqBraaL7olXJCERJCgmdvswTpOkPebj82ZyYnErXo4J7mvynru7p613oNtq7HxouPI2Tz0lFP58joDx1Ftsjq3iqkdP5G91IZY0e7u2ZDoH1TRme8ttG52B6EOvI+aOFXFfKEZxRgHXnjL1J9mbXHIFTXc/2uPdfZGLKTy4IMyz+BFD4KzCU0tJObLwjm3aWh6Ht2jGid9N0DMxs+oyNYa4V8TT0gEqgNdSRz9Y3GJJi5bauAQH9gJNjXb5L9g+81lz6+M3tlw1G/fPwyAjJX+7DWYjOuQ/T1a6c14jru+j+XymFJ8OQ1AGHDjkvTwm4hRxAc4nArFhSh51MPgk5e7tabHhmDu7GX4VCbdUAyd4BOKGOP3nzlEqab/8tXt/CAjQGBX4y0n12bTs+Uh5FtSwxJ6t1udBGAqZY78MBao6TSYVJNu3+HLKyMkOkj0udw1im50FC9sv8sNyR/MI6eEGTyl/bZ3nVVizp/TMV01j2OBxk7iOcJRdyVN0om/1BA1bW/k43Lfxp4zfkJDx+eerUm9fFA1NYrExumEeT7fAsAtrkK71kD9BkJbcYTbr0Cr7g+tyk5YOE8C1UsA/cElgj2dKysLmz2C/XjocgThhZhS7sbnMCBSxOUn8epYUkJlkH7g2eEp6ESoOt7L7Svmd0WUNYdE2S33BvIWsZaSyBKKuhx7ubuWuycCvEexWeyMLeXNvAONKWf/uY5mHjd0WkBiW1mtVU3DFiXX44yNOTkPijxmxViZNwY4OZf1TeXZLyFLY1kLtAjAp78GObqg== 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:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(230273577357003)(230173577357003)(82310400011)(451199024)(186009)(64100799003)(1800799012)(40470700004)(36840700001)(46966006)(110136005)(6636002)(70206006)(70586007)(7696005)(966005)(478600001)(6666004)(16526019)(336012)(426003)(6286002)(36756003)(83380400001)(2616005)(1076003)(26005)(55016003)(921011)(82740400003)(5660300002)(356005)(2906002)(41300700001)(8936002)(86362001)(8676002)(47076005)(7636003)(316002)(40460700003)(36860700001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2023 09:08:10.1460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2129b843-0cf8-4c38-9e05-08dc06bb591a 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7818 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 In order to support the communication between IPv4 and IPv6 nodes in the network, different technologies are used, like dual-stacks, tunneling and NAT64. In some IPv4-only clients, it is hard to deploy new software and(or) hardware to support IPv6 protocol. NAT64 is a choice and it will also reduce the unnecessary overhead of the traffic in the network. The NAT64 gateways take the responsibility of the packet headers translation between the IPv6 clouds and IPv4-only clouds. The commit introduce the NAT64 flow action to offload the software involvement to the hardware. This action should support the offloading of the IP headers' translation. The following fields should be reset correctly in the translation. - Version - Traffic Class / TOS - Flow Label (0 in v4) - Payload Length / Total length - Next Header - Hop Limit / TTL The PMD needs to support the basic conversion of the fields above, and the well-known prefix will be used when translating IPv4 address to IPv6 address. Another modify fields can be used after the NAT64 to support other modes with different prefix and offset. The ICMP* and transport layers protocol is out of the scope of NAT64 rte_flow action. Reference links: - https://datatracker.ietf.org/doc/html/rfc6146 - https://datatracker.ietf.org/doc/html/rfc6052 - https://datatracker.ietf.org/doc/html/rfc6145 Signed-off-by: Bing Zhao --- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 8 ++++++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 806cb033ff..f8a47a055a 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -170,6 +170,7 @@ mark = meter = meter_mark = modify_field = +nat64 = nvgre_decap = nvgre_encap = of_copy_ttl_in = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 627b845bfb..f87628e9dc 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3506,6 +3506,14 @@ The packets will be received by the kernel driver sharing the same device as the DPDK port on which this action is configured. +Action: ``NAT64`` +^^^^^^^^^^^^^^^^^ + +This action does the header translation between IPv4 and IPv6. Besides +converting the IP addresses, other fields in the IP header are handled as +well. The ``type`` field should be provided as defined in the +``rte_flow_action_nat64`` when creating the action. + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 549e329558..502df3bfd1 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -268,6 +268,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { sizeof(struct rte_flow_action_indirect_list)), MK_FLOW_ACTION(PROG, sizeof(struct rte_flow_action_prog)), + MK_FLOW_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index affdc8121b..da2afaef83 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3022,6 +3022,13 @@ enum rte_flow_action_type { * @see struct rte_flow_action_prog. */ RTE_FLOW_ACTION_TYPE_PROG, + + /** + * Support the NAT64 translation. + * + * @see struct rte_flow_action_nat64 + */ + RTE_FLOW_ACTION_TYPE_NAT64, }; /** @@ -4150,6 +4157,26 @@ rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) *RTE_FLOW_DYNF_METADATA(m) = v; } +/** + * NAT64 translation type for IP headers. + */ +enum rte_flow_nat64_type { + RTE_FLOW_NAT64_6TO4 = 0, /**< IPv6 to IPv4 headers translation. */ + RTE_FLOW_NAT64_4TO6 = 1, /**< IPv4 to IPv6 headers translation. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_NAT64 + * + * Specify the NAT64 translation type. + */ +struct rte_flow_action_nat64 { + enum rte_flow_nat64_type type; +}; + /** * Definition of a single action. *