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 AFDCE4415C; Wed, 5 Jun 2024 10:10:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99FF040A6D; Wed, 5 Jun 2024 10:10:34 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) by mails.dpdk.org (Postfix) with ESMTP id 96DAD40693 for ; Wed, 5 Jun 2024 10:10:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7htJQwaMpRBcn8jtbXJvakRxVYcU377M0XZSp82zHVj4eE63ydpHfiZJFxoxw98C0CIMteLu7BleJ1JSIa3zPTG74hA7cDIzi+tFD8jS5e1zHM7uun+veAbCbxql5aNqqrZ0FWVUQMbs3U7GTMKquSxYVBVvUG+y4RT4M5cN4LNSQlENjGFtd9PfcdM0AqSlrVbISpOyrtjsZ4jsLaZwCnG0mNZ9aW0R/PKgx6DSxQZMAYAP0k+mPgnTSH3ORll1VcRpYm4Jndqpjl8sv/B4FOlHNwqZbHRiaKiu2Y7PdMNF6yCuqVENEI7b0U3QzuT6IEHkrtEwM73oi20IbEaWQ== 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=C1qbLL2IXZzMhDWw5tEAHOmm00+yN5d/VYUFkd86yy4=; b=m6oZ1Zls10aYzSuteU83FALI0o69Hnv9aQz4HE1HC+4VsGbcpsqpDwtxOhdm4xnvuVMs5PulOdHtmmImYpHLR3KC3zPuoBlRDCOGWQImB4w7TFxo1MaRtK5jllMRBiuuCpDHXMfNfT9N5haEihSUMa8bUNNVwlzz7v5NE7NYJC4znPPEeSyunEJGl/NbgmAY05BD3yGS450tXw49rup3EnbFjzFHbm5sABQVrrtB4yk9wuh7t5N88ToX9OfyvPRIl8zmom7Mrap+Hxid7F04brFV+nwEJuGn8PJi5C2BDl4TpuP45JVmGQEwxyjP8i05rK9+GasB3fyflt1dZbPL8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=C1qbLL2IXZzMhDWw5tEAHOmm00+yN5d/VYUFkd86yy4=; b=od8yTAruNbLDrY9bznD5swDxebdvGKd4MsmIrPf0Ydn3v1T+MJTpuHKaw1uEKzfyD43hT0wy0F872obj60ChLLxrMOIZZUWXC3BOYUI6CsJZdRkZe8Wbnofi/4EybzEsK1amIYg5e8haj2SUTtefuqem0smu6MCSvPnwvtdVU4aWHr6Y6RYiwA29ENu0WBZAejU6gu7OApODKhigfVUHkffoJxZkLJOw7YiRh4SvyvZ6uyufADunyXlDsvqlhdSrJvoNQN+hxEbfUGQPOKblbA8AkzzTjx3ZEIrX6sUGre9YughzliLekineZfLYSnNTaumlEBDxHiCaglShTArOHA== Received: from BL1PR13CA0231.namprd13.prod.outlook.com (2603:10b6:208:2bf::26) by DS7PR12MB6240.namprd12.prod.outlook.com (2603:10b6:8:94::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Wed, 5 Jun 2024 08:10:29 +0000 Received: from MN1PEPF0000F0E3.namprd04.prod.outlook.com (2603:10b6:208:2bf:cafe::57) by BL1PR13CA0231.outlook.office365.com (2603:10b6:208:2bf::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.15 via Frontend Transport; Wed, 5 Jun 2024 08:10:28 +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 MN1PEPF0000F0E3.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 5 Jun 2024 08:10:28 +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.1544.4; Wed, 5 Jun 2024 01:10:13 -0700 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.1544.4; Wed, 5 Jun 2024 01:10:10 -0700 From: Gavin Li To: , , , , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [V3 1/2] net: extend VXLAN header to support more extensions Date: Wed, 5 Jun 2024 11:09:52 +0300 Message-ID: <20240605080953.534998-2-gavinl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605080953.534998-1-gavinl@nvidia.com> References: <20240604062746.355383-2-gavinl@nvidia.com> <20240605080953.534998-1-gavinl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E3:EE_|DS7PR12MB6240:EE_ X-MS-Office365-Filtering-Correlation-Id: 757d5b52-ebda-4a6a-ad64-08dc8536f672 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; ARA:13230031|376005|82310400017|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vnA2zOBw9txOwtj7fNwFDa9w40lyy+QfD5H7UuyIkhSsrS7UZ3JPLBCwYOtW?= =?us-ascii?Q?nfvPb9zvbOiSdsUcABG40ToqF5F8jxfR2EJzsh+RNFcnT8OcAnob4feo0ztY?= =?us-ascii?Q?N3mBGq8+cDs+aVDYbsJpVcIA3kLA6UsqHNvQRoULY1W5jkH4dkb23GH25q0Z?= =?us-ascii?Q?MCBaMNJaGo8610VYaeqGlzrhLAbQXlk21yWriMZSH3oZn9tSfDK2kOQPK4j6?= =?us-ascii?Q?Wzp9gxomDARzHUSBGwsgIWMv+IEwxDgvYsTzczSFyacpX7VSls3UOnONuUzc?= =?us-ascii?Q?wrVBbLAceVnTANbwagfUrxkkxpGdFM1YWWni1BZhn/Q6Hqy95BLw/7hOtj1P?= =?us-ascii?Q?x6CK1SHnMqKZ6pN+EMoicooxjynL7EaxeHDo+USVivtVaemlr6RoExYEkFLq?= =?us-ascii?Q?FYJ/dG6+idwNdloa6QrMhs4OOQVcloGvm7gABdEeVsJBFAXOemOkM/KQDsbF?= =?us-ascii?Q?X2oLEDW8X7XF61oJfqEoZk2Qlh0fBROPUOglCF4AZ1N/Y/6WK0BAjHjgIlAy?= =?us-ascii?Q?TcVIY8s98O57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?= 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)(376005)(82310400017)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 08:10:28.7175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 757d5b52-ebda-4a6a-ad64-08dc8536f672 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: MN1PEPF0000F0E3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6240 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 VXLAN and VXLAN-GPE were supported with similar header structures. In order to add VXLAN-GBP, which is another extension to VXLAN, both extensions are merged in the original VXLAN header structure for an easier usage. More VXLAN extensions may be added in the future in the same single structure. VXLAN and VXLAN-GBP use the same UDP port (4789), while VXLAN-GPE uses a different port (4790). The three protocols have the same header length and overall a similar header structure as below. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|R|R|R|I|R|R|R| Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 1: VXLAN Header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|R|Ver|I|P|B|O| Reserved |Next Protocol | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 2: VXLAN-GPE Header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 3: VXLAN-GBP Extension Both GPE and GBP are extending VXLAN by using some reserved bits. It means the packets can be processed with the same pattern and most of the code can be reused. The old field names are kept with the use of anonymous unions. The Group Policy ID (GBP) and the Next Protocol (GPE) fields are overlapping so they are in a union as well. Another improvement is defining and documenting each bit. Instead of adding flow items, a single VXLAN flow item is more flexible as it uses the same header anyway. GBP can be matches with the G bit. GPE can be matched with the UDP port number. VXLAN-GPE flow item and specific header are marked as deprecated. A removal of the deprecated structures and macros may be proposed later. Signed-off-by: Gavin Li Signed-off-by: Thomas Monjalon --- lib/ethdev/rte_flow.h | 20 +++++++++-- lib/net/rte_vxlan.h | 83 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 13 deletions(-) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 6e8ab1d4c7..b27d5aa94c 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -355,6 +355,9 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_GENEVE, /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_VXLAN + * * Matches a VXLAN-GPE header. * * See struct rte_flow_item_vxlan_gpe. @@ -1103,7 +1106,12 @@ static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = { /** * RTE_FLOW_ITEM_TYPE_VXLAN. * - * Matches a VXLAN header (RFC 7348). + * Matches a VXLAN header (RFC 7348), + * including GPE (draft-ietf-nvo3-vxlan-gpe-13.txt) + * and GBP (draft-smith-vxlan-group-policy-05.txt). + * + * GPE is distinguished with its UDP port. + * UDP port may be specified with ``rte_eth_dev_udp_tunnel_port_add()``. */ struct rte_flow_item_vxlan { union { @@ -1346,6 +1354,9 @@ static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = { #endif /** + * @deprecated + * @see rte_flow_item_vxlan + * * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05). * * Matches a VXLAN-GPE header. @@ -1367,7 +1378,12 @@ struct rte_flow_item_vxlan_gpe { }; }; -/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */ +/** + * @deprecated + * @see rte_flow_item_vxlan_mask + * + * Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. + */ #ifndef __cplusplus static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = { .hdr.vni = "\xff\xff\xff", diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h index 997fc784fc..8ce93ae569 100644 --- a/lib/net/rte_vxlan.h +++ b/lib/net/rte_vxlan.h @@ -23,27 +23,80 @@ extern "C" { /** VXLAN default port. */ #define RTE_VXLAN_DEFAULT_PORT 4789 +/** VXLAN GPE port. */ #define RTE_VXLAN_GPE_DEFAULT_PORT 4790 /** * VXLAN protocol header. * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and - * Reserved fields (24 bits and 8 bits) + * extensions (Generic Protocol Extension, Group Based Policy). */ __extension__ /* no named member in struct */ struct rte_vxlan_hdr { union { + rte_be32_t vx_flags; /**< flags (8 bits) + extensions (24 bits). */ struct { - rte_be32_t vx_flags; /**< flags (8) + Reserved (24). */ - rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */ - }; + union { + uint8_t flags; /**< Default is I bit, others are extensions. */ + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t flag_g:1, /**< GBP bit. */ + flag_rsvd:1, /* Reserved. */ + flag_ver:2, /**< GPE Protocol Version. */ + flag_i:1, /**< VNI bit. */ + flag_p:1, /**< GPE Next Protocol bit. */ + flag_b:1, /**< GPE Ingress-Replicated BUM. */ + flag_o:1; /**< GPE OAM Packet bit. */ +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t flag_o:1, + flag_b:1, + flag_p:1, + flag_i:1, + flag_ver:2, + flag_rsvd:1, + flag_g:1; +#endif + } __rte_packed; + }; /* end of 1st byte */ + union { + uint8_t rsvd0[3]; /* Reserved for extensions. */ + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t rsvd0_gbp1:1, /* Reserved. */ + flag_d:1, /**< GBP Don't Learn bit. */ + rsvd0_gbp2:2, /* Reserved. */ + flag_a:1, /**< GBP Applied bit. */ + rsvd0_gbp3:3; /* Reserved. */ +#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint8_t rsvd0_gbp3:3, + flag_a:1, + rsvd0_gbp2:2, + flag_d:1, + rsvd0_gbp1:1; +#endif + union { + uint16_t policy_id; /**< GBP Identifier. */ + struct { + uint8_t rsvd0_gpe; /* Reserved. */ + uint8_t proto; /**< GPE Next protocol. */ + /* 0x01 : IPv4 + * 0x02 : IPv6 + * 0x03 : Ethernet + * 0x04 : Network Service Header + */ + } __rte_packed; + }; + } __rte_packed; + }; + } __rte_packed; + }; /* end of 1st 32-bit word */ + union { + rte_be32_t vx_vni; /**< VNI (24 bits) + reserved (8 bits). */ struct { - uint8_t flags; /**< Should be 8 (I flag). */ - uint8_t rsvd0[3]; /**< Reserved. */ - uint8_t vni[3]; /**< VXLAN identifier. */ - uint8_t rsvd1; /**< Reserved. */ - }; - }; + uint8_t vni[3]; /**< VXLAN Identifier. */ + uint8_t rsvd1; /* Reserved. */ + } __rte_packed; + }; /* end of 2nd 32-bit word */ } __rte_packed; /** VXLAN tunnel header length. */ @@ -52,6 +105,9 @@ struct rte_vxlan_hdr { /** + * @deprecated + * @see rte_vxlan_hdr + * * VXLAN-GPE protocol header (draft-ietf-nvo3-vxlan-gpe-05). * Contains the 8-bit flag, 8-bit next-protocol, 24-bit VXLAN Network * Identifier and Reserved fields (16 bits and 8 bits). @@ -75,7 +131,12 @@ struct rte_vxlan_gpe_hdr { }; } __rte_packed; -/** VXLAN-GPE tunnel header length. */ +/** + * @deprecated + * @see RTE_ETHER_VXLAN_HLEN + * + * VXLAN-GPE tunnel header length. + */ #define RTE_ETHER_VXLAN_GPE_HLEN (sizeof(struct rte_udp_hdr) + \ sizeof(struct rte_vxlan_gpe_hdr)) -- 2.34.1