[v5,2/8] net: add smaller fields for VXLAN

Message ID 20230126161904.864517-3-ferruh.yigit@amd.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series start cleanup of rte_flow_item_* |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Jan. 26, 2023, 4:18 p.m. UTC
  From: Thomas Monjalon <thomas@monjalon.net>

The VXLAN and VXLAN-GPE headers were including reserved fields
with other fields in big uint32_t struct members.

Some more precise definitions are added as union of the old ones.

The new struct members are smaller in size and in names.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/net/rte_vxlan.h | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)
  

Patch

diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h
index 929fa7a1dd01..997fc784fc84 100644
--- a/lib/net/rte_vxlan.h
+++ b/lib/net/rte_vxlan.h
@@ -30,9 +30,20 @@  extern "C" {
  * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and
  * Reserved fields (24 bits and 8 bits)
  */
+__extension__ /* no named member in struct */
 struct rte_vxlan_hdr {
-	rte_be32_t vx_flags; /**< flag (8) + Reserved (24). */
-	rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+	union {
+		struct {
+			rte_be32_t vx_flags; /**< flags (8) + Reserved (24). */
+			rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+		};
+		struct {
+			uint8_t    flags;    /**< Should be 8 (I flag). */
+			uint8_t    rsvd0[3]; /**< Reserved. */
+			uint8_t    vni[3];   /**< VXLAN identifier. */
+			uint8_t    rsvd1;    /**< Reserved. */
+		};
+	};
 } __rte_packed;
 
 /** VXLAN tunnel header length. */
@@ -45,11 +56,23 @@  struct rte_vxlan_hdr {
  * Contains the 8-bit flag, 8-bit next-protocol, 24-bit VXLAN Network
  * Identifier and Reserved fields (16 bits and 8 bits).
  */
+__extension__ /* no named member in struct */
 struct rte_vxlan_gpe_hdr {
-	uint8_t vx_flags;    /**< flag (8). */
-	uint8_t reserved[2]; /**< Reserved (16). */
-	uint8_t proto;       /**< next-protocol (8). */
-	rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+	union {
+		struct {
+			uint8_t vx_flags;    /**< flag (8). */
+			uint8_t reserved[2]; /**< Reserved (16). */
+			uint8_t protocol;    /**< next-protocol (8). */
+			rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+		};
+		struct {
+			uint8_t flags;    /**< Flags. */
+			uint8_t rsvd0[2]; /**< Reserved. */
+			uint8_t proto;    /**< Next protocol. */
+			uint8_t vni[3];   /**< VXLAN identifier. */
+			uint8_t rsvd1;    /**< Reserved. */
+		};
+	};
 } __rte_packed;
 
 /** VXLAN-GPE tunnel header length. */