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 9F54F43A1A; Wed, 31 Jan 2024 10:38:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8CAF1427E5; Wed, 31 Jan 2024 10:38:55 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.72]) by mails.dpdk.org (Postfix) with ESMTP id D7113427E0 for ; Wed, 31 Jan 2024 10:38:53 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R70805DO2A3uuaBzwIECqblwiSM+h7YP48H1ivN3iJhxRuprf6ZQafdOe/pymUB7/K5SKdDS4JhFzCbMPSWzM7hliSBtRadhVLKbR8cby86q81Gm5OHfeDn1awaeLTVuosuCcf9eM/MJwEY5UOwEd+VxMTzRkAoqCid9JylOwMfeykSone/SzRMSqU9jqVxzdU0gIqqAttl2Y8LgZfjwJXEaxYYz50My/X+K1VTjy4g1XPGPmHExT3BTOJttdslYEZqEh/hSnYirjFyccHNfdV7X3Vgy2DwedQphF+ieQCjmxzysLlOmMW2/Ow8NfmQ8/oZ/ezrTFqP2zL/QruGdBA== 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=hPWz4UByh/xdY7LJhLiwkVeNo13XqYN+6OhDtBh4pg0=; b=GKPmSdGHVrNRXbHmNM80RKAQl/z2BArZSl9jE8xY8iEay4jqSzb461B0AZBygVjIQT1NiJpE0rhp3OPi+boODkZ+kh82vtx4vyonfbeqQUPEGoa9nhFqMYaFO9lxnmTDZSZNtuRwvXm0QRxPqRnEZN1Aj7qtZvstYBhGnMOqtyX0Y1HXkQYsBe9+3hU/eWADojXwpmG024exiBsOPSkKbrtc1udDyoki7cDL2twxdrO5mPx/SwA8FEOylroF5WFeanbkrtlvDlt3HYSFJsdpyuQn8Jc0GcMamI6tfZOx6u5A0xLa2ee7LO3Y8T+eiQA6Z1hBvcdiyy7f2kDoVDNd8g== 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=hPWz4UByh/xdY7LJhLiwkVeNo13XqYN+6OhDtBh4pg0=; b=klKN7aBifgPgVsBw4nLctVBv64vkTutEqQ33gFXBRPhfJXrGjwBlBbcv3hmiZpiSzrMn3uPo4PY34t/MVFVdm9YxbSFjhAwMB6+2X28fo/XJBvoXijklEi0079qTQHE40DLiRhB2OnK1FeJs/i27qiY13kdA8vsPCtzhWV1+d1jhJpGPrVBqwSBB9uisE+KwWKnOIMqFjbK6+Uy40Cxz/qra2n57qEyCZKNUEH2MnDIlnaKgr3ETv3Z1obRgGoSPJfqsC+f4cYJMSWthRhGSxTCQ73pB/5DfIOlVERCIV15J1Jq9WbKObjKFdGYm+eROvbE1MWzjiXKvNEHMSB952Q== Received: from BLAPR03CA0063.namprd03.prod.outlook.com (2603:10b6:208:329::8) by MW3PR12MB4586.namprd12.prod.outlook.com (2603:10b6:303:53::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 09:38:50 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:208:329:cafe::a) by BLAPR03CA0063.outlook.office365.com (2603:10b6:208:329::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.24 via Frontend Transport; Wed, 31 Jan 2024 09:38:49 +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 MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Wed, 31 Jan 2024 09:38:49 +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, 31 Jan 2024 01:38:33 -0800 Received: from nvidia.com (10.126.231.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, 31 Jan 2024 01:38:30 -0800 From: Bing Zhao To: , , , , , , , , , , , Subject: [PATCH v2 1/2] ethdev: introduce NAT64 action Date: Wed, 31 Jan 2024 11:38:03 +0200 Message-ID: <20240131093804.357465-2-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240131093804.357465-1-bingz@nvidia.com> References: <20231227090731.2569427-1-bingz@nvidia.com> <20240131093804.357465-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] 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: MN1PEPF0000F0E4:EE_|MW3PR12MB4586:EE_ X-MS-Office365-Filtering-Correlation-Id: f32c02ff-153b-4ef2-bd7e-08dc22406e12 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: 4atTsptpx6y4SvsIw5khuIA+Gs5KbTGaUbtSaMEDYno/GKl/hUVG9HmVw3vkJ6XdtNcagreBFOJ/KZkQONa3SlrqDXWhylDIYPSb6T6XrW+uuYp4cNfp2+Fd4CMOF6al77bvV5ETOfXGfU9yCrpXdfI303EaUoGw7n+O9CNpxf7AAsF22yTb/3WwQAfeS9+6uskuThSMHtng16EKfF+zgKw9ynwelGNwOOK0/SU7uwMku/Ftm8OJue7PtpBndCiFcSUgM5iC+wWiHJH17Jw74rOqSzbLmyRpna3Srh7xxEv4SryAvsoSdslaEyMArkft5FJNT6v/xq7AsHR6CbQhDhVwToR31fwrd6Acl944Di18mK1R4CzknhkPztkI0E3X481z/IX6WcgaqhDpcnPidzGdCT4/WxPkrJhDjTGq0LgwGAYtODIYqdkrC8jcQ5HKPM4iq9CmAxXi+2ZBw/pGO0L35gvUQa8lo6pfQX8UHtFjXR/4ESv70GJl3aJfR+8zlVbSSg7zqgHBQcIv0HUTEB1lyC2Ll9zoJkJTi3C2CtlHm8BGrZUa9DoLG90xTMqYj+5mvz44s3MJNgH2KuyQKqHued42ewGCsN8pcQc41sUntPOSeabXv19V4/xPIc4HV/BkJbOrKotfQIhRlz2Rh0K3PeQRChJQs5KD/0kl5dmhHbEdYa5VD2uZECHu28dhQoHHloOvnReiefy3L2EZxFU44laWFfxOrAv5uWGw9Ao9NSg1wszYAjSxs4NtBYJyfMAaN8YTZQY1TzQxBKg1Z2PthozpH3NKTngyKcpjOMqhNAuCyPQArl5SFwO+YsQKm8oAfTG8vNQbdpWF8vzl8w== 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)(376002)(396003)(136003)(346002)(39860400002)(230922051799003)(230173577357003)(230273577357003)(451199024)(1800799012)(82310400011)(186009)(64100799003)(46966006)(36840700001)(40470700004)(41300700001)(83380400001)(47076005)(6286002)(2616005)(426003)(336012)(16526019)(26005)(1076003)(356005)(7636003)(36860700001)(8936002)(8676002)(5660300002)(2906002)(478600001)(966005)(7696005)(70586007)(6666004)(82740400003)(110136005)(316002)(6636002)(70206006)(921011)(86362001)(36756003)(40480700001)(40460700003)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 09:38:49.7397 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f32c02ff-153b-4ef2-bd7e-08dc22406e12 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: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4586 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 6d50236292..4db7e41193 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -171,6 +171,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 900fdaefb6..7af329bd93 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3520,6 +3520,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 3f58d792f9..156545454c 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -271,6 +271,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 1267c146e5..1dded812ec 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3051,6 +3051,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, }; /** @@ -4180,6 +4187,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. * -- 2.34.1