From: Roman Zhukov <roman.zhu...@oktetlabs.ru>

Add new pattern item RTE_FLOW_ITEM_TYPE_GENEVE in flow API.
This commit also adds default mask for these item.

Signed-off-by: Roman Zhukov <roman.zhu...@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>
---
 doc/guides/prog_guide/rte_flow.rst | 12 ++++++++++++
 lib/librte_ether/rte_flow.c        |  1 +
 lib/librte_ether/rte_flow.h        | 31 +++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst 
b/doc/guides/prog_guide/rte_flow.rst
index d158be5..2f96623 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -863,6 +863,18 @@ Matches a VXLAN header (RFC 7348).
 - ``rsvd1``: reserved, normally 0x00.
 - Default ``mask`` matches VNI only.
 
+Item: ``GENEVE``
+^^^^^^^^^^^^^^^
+
+Matches a GENEVE header.
+
+- ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b),
+  OAM packet (1b), critical options present (1b), reserved 0 (6b).
+- ``protocol``: protocol type.
+- ``vni``: virtual network identifier.
+- ``rsvd1``: reserved, normally 0x00.
+- Default ``mask`` matches protocol type and VNI.
+
 Item: ``E_TAG``
 ^^^^^^^^^^^^^^^
 
diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 6659063..bf1b253 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -77,6 +77,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = 
{
        MK_FLOW_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
        MK_FLOW_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
        MK_FLOW_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
+       MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
        MK_FLOW_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
        MK_FLOW_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
        MK_FLOW_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index 47c88ea..29d81d4 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -272,6 +272,13 @@ enum rte_flow_item_type {
        RTE_FLOW_ITEM_TYPE_VXLAN,
 
        /**
+        * Matches a GENEVE header.
+        *
+        * See struct rte_flow_item_geneve.
+        */
+       RTE_FLOW_ITEM_TYPE_GENEVE,
+
+       /**
         * Matches a E_TAG header.
         *
         * See struct rte_flow_item_e_tag.
@@ -651,6 +658,30 @@ static const struct rte_flow_item_vxlan 
rte_flow_item_vxlan_mask = {
 #endif
 
 /**
+ * RTE_FLOW_ITEM_TYPE_GENEVE.
+ *
+ * Matches a GENEVE header.
+ */
+struct rte_flow_item_geneve {
+       /**
+        * Version (2b), length of the options fields (6b), OAM packet (1b),
+        * critical options present (1b), reserved 0 (6b).
+        */
+       rte_be16_t ver_opt_len_o_c_rsvd0;
+       rte_be16_t protocol; /**< Protocol type. */
+       uint8_t vni[3]; /**< Virtual Network Identifier. */
+       uint8_t rsvd1; /**< Reserved, normally 0x00. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
+#ifndef __cplusplus
+static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
+       .protocol = RTE_BE16(0xffff),
+       .vni = "\xff\xff\xff",
+};
+#endif
+
+/**
  * RTE_FLOW_ITEM_TYPE_E_TAG.
  *
  * Matches a E-tag header.
-- 
2.7.4

Reply via email to