Add new rte_actions to push and remove the specific
type of IPv6 extension to and from original packets.

A new extension to be pushed should be the last extension
due to the next header awareness.

Remove can support the IPv6 extension in any position.

Signed-off-by: Rongwei Liu <rongw...@nvidia.com>
---
 doc/guides/prog_guide/rte_flow.rst | 21 ++++++++++++
 lib/ethdev/rte_flow.c              |  2 ++
 lib/ethdev/rte_flow.h              | 52 ++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst 
b/doc/guides/prog_guide/rte_flow.rst
index 43e38839ae..6a7401c98a 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -3308,6 +3308,27 @@ and rte_mtr_policy_get() API respectively.
    | ``policy``       | Meter policy object  |
    +------------------+----------------------+
 
+Action: ``IPV6_EXT_PUSH``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Add an IPv6 extension into IPv6 header and its template is provided in
+its data buffer with the specific type as defined in the
+``rte_flow_action_ipv6_ext_push`` definition.
+
+This action modifies the payload of matched flows. The data supplied must
+be a valid extension in the specified type, it should be added the last one
+if preceding extension existed. When applied to the original packet the
+resulting packet must be a valid packet.
+
+Action: ``IPV6_EXT_REMOVE``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Remove an IPv6 extension whose type is provided in its type as defined in
+the ``rte_flow_action_ipv6_ext_remove``.
+
+This action modifies the payload of matched flow and the packet should be
+valid after removing.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 26531ecb8e..4504bb3ae9 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -272,6 +272,8 @@ static const struct rte_flow_desc_data 
rte_flow_desc_action[] = {
        MK_FLOW_ACTION(SEND_TO_KERNEL, 0),
        MK_FLOW_ACTION(QUOTA, sizeof(struct rte_flow_action_quota)),
        MK_FLOW_ACTION(INDIRECT_LIST, 0),
+       MK_FLOW_ACTION(IPV6_EXT_PUSH, sizeof(struct 
rte_flow_action_ipv6_ext_push)),
+       MK_FLOW_ACTION(IPV6_EXT_REMOVE, sizeof(struct 
rte_flow_action_ipv6_ext_remove)),
 };
 
 int
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index dfad6d1af4..f5e0c22389 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3029,6 +3029,25 @@ enum rte_flow_action_type {
         * RTE_FLOW_ACTION_TYPE_INDIRECT_LIST
         */
        RTE_FLOW_ACTION_TYPE_INDIRECT_LIST,
+
+       /**
+        * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH
+        *
+        * Push IPv6 extension into IPv6 packet.
+        *
+        * @see struct rte_flow_action_ipv6_ext_push.
+        */
+       RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH,
+
+       /**
+        * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE
+        *
+        * Remove IPv6 extension from IPv6 packet whose type
+        * is provided in its configuration buffer.
+        *
+        * @see struct rte_flow_action_ipv6_ext_remove.
+        */
+       RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE,
 };
 
 /**
@@ -3469,6 +3488,39 @@ struct rte_flow_action_vxlan_encap {
        struct rte_flow_item *definition;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH
+ *
+ * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH include:
+ *
+ * - IPV6_EXT TYPE / IPV6_EXT_HEADER_IN_TYPE / END
+ *
+ * size holds the number of bytes in @p data.
+ * The data must be added as the last IPv6 extension.
+ */
+struct rte_flow_action_ipv6_ext_push {
+       uint8_t *data; /**< IPv6 extension header data. */
+       size_t size; /**< Size of @p data. */
+       uint8_t type; /**< Type of IPv6 extension. */
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE
+ *
+ * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE include:
+ *
+ * - IPV6_EXT TYPE / END
+ */
+struct rte_flow_action_ipv6_ext_remove {
+       uint8_t type; /**< Type of IPv6 extension. */
+};
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice
-- 
2.27.0

Reply via email to