diff mbox series

[04/10] ethdev: reuse header definition in flow pattern item VXLAN

Message ID 20210312093143.28186-4-ivan.malov@oktetlabs.ru (mailing list archive)
State Superseded
Headers show
Series [01/10] ethdev: reuse header definition in flow pattern item ETH | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ivan Malov March 12, 2021, 9:31 a.m. UTC
One ought to reuse existing header structs in flow items.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 lib/librte_ethdev/rte_flow.h | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index b9b349669..56c97829c 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -25,6 +25,7 @@ 
 #include <rte_sctp.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
+#include <rte_vxlan.h>
 #include <rte_byteorder.h>
 #include <rte_esp.h>
 #include <rte_higig.h>
@@ -954,18 +955,31 @@  static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
  * RTE_FLOW_ITEM_TYPE_VXLAN.
  *
  * Matches a VXLAN header (RFC 7348).
+ *
+ * Fields @p flags, @p rsvd0, @p vni and @rsvd1 are left here for compatibility.
+ * Consumers of this item definition are encouraged to use field @p hdr instead.
  */
+RTE_STD_C11
 struct rte_flow_item_vxlan {
-	uint8_t flags; /**< Normally 0x08 (I flag). */
-	uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
-	uint8_t vni[3]; /**< VXLAN identifier. */
-	uint8_t rsvd1; /**< Reserved, normally 0x00. */
+	union {
+		struct {
+			/*
+			 * These fields are retained for compatibility.
+			 * Please switch to the new header field below.
+			 */
+			uint8_t flags; /**< Normally 0x08 (I flag). */
+			uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
+			uint8_t vni[3]; /**< VXLAN identifier. */
+			uint8_t rsvd1; /**< Reserved, normally 0x00. */
+		};
+		struct rte_vxlan_hdr hdr;
+	};
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
 #ifndef __cplusplus
 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
-	.vni = "\xff\xff\xff",
+	.hdr.vx_vni = RTE_BE32(__builtin_constant_p(0xffffff << 8)),
 };
 #endif