From: Kiran Kumar K <kirankum...@marvell.com>

Add new rte_flow_item_nsh in order to match the network service header
based on RFC 8300.

Signed-off-by: Kiran Kumar K <kirankum...@marvell.com>
---
 lib/librte_ethdev/rte_flow.c |  1 +
 lib/librte_ethdev/rte_flow.h | 39 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 18fcb018e..39646167c 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -75,6 +75,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = 
{
        MK_FLOW_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
        MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)),
        MK_FLOW_ITEM(GRE_KEY, sizeof(rte_be32_t)),
+       MK_FLOW_ITEM(NSH, sizeof(struct rte_flow_item_nsh)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index b66bf1495..f0e99fa3e 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -434,6 +434,13 @@ enum rte_flow_item_type {
         * @code rte_be32_t * @endcode
         */
        RTE_FLOW_ITEM_TYPE_GRE_KEY,
+
+       /**
+        * Matches Network service header (NSH).
+        * See struct rte_flow_item_nsh.
+        *
+        */
+       RTE_FLOW_ITEM_TYPE_NSH,
 };
 
 /**
@@ -1214,6 +1221,38 @@ struct rte_flow_item_mark {
        uint32_t id; /**< Integer value to match against. */
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_NSH
+ *
+ * Match network service header (NSH), RFC 8300
+ *
+ */
+struct rte_flow_item_nsh {
+       uint32_t version:2;
+       uint32_t oam_pkt:1;
+       uint32_t reserved:1;
+       uint32_t ttl:6;
+       uint32_t length:6;
+       uint32_t reserved1:4;
+       uint32_t mdtype:4;
+       uint32_t next_proto:8;
+       uint32_t spi:24;
+       uint32_t sindex:8;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
+#ifndef __cplusplus
+static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
+       .mdtype = 0xf,
+       .next_proto = 0xff,
+       .spi = 0xffffff,
+       .sindex = 0xff,
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *
-- 
2.17.1

Reply via email to