[RFC,v2] ethdev: support MPLS tunnel encapsulation action

Message ID 1528713999-25914-1-git-send-email-orika@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [RFC,v2] ethdev: support MPLS tunnel encapsulation action |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Ori Kam June 11, 2018, 10:46 a.m. UTC
  Until now MPLS tunnel is supported only for checksum and
TSO offloading.

IN DPDK 18.05 some encapsulation API has been added for
VXLAN and NVGRE.

This patch adds the encapsulation offload for the MPLS tunnel type.

Signed-off-by: Ori Kam <orika@mellanox.com>

---
v2: Specific MPLS encapsulation RFC

v1: generic tunnel encapsulation RFC [1].
The generic approach must be discussed some more
so it will not be ready for the 18.08 DPDK release.

This MPLS-specific API targets 18.08 and is based on the current
encapsulation API.

[1] http://dpdk.org/ml/archives/dev/2018-June/103485.html
---
---
 doc/guides/prog_guide/rte_flow.rst |   54 ++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.h       |   54 ++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 0 deletions(-)
  

Patch

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index b305a72..e40f9fe 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2076,6 +2076,60 @@  RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
 
 This action modifies the payload of matched flows.
 
+Action: ``MPLS_L2_ENCAP``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs MPLS encapsulation action over L2 inner packet by encapsulating
+the matched flow with the requested MPLS tunnel as defined in 
+the``rte_flow_action_mpls_l2_encap`` flow item
+definition.
+
+This action modifies the payload of matched flows. The flow definition specified
+in the ``rte_flow_action_mpls_l2_encap`` action structure must defined a valid
+MPLS network overlay. The pattern must be
+terminated with the RTE_FLOW_ITEM_TYPE_END item type.
+
+.. _table_rte_flow_action_mpls_l2_encap:
+
+.. table:: MPLS_ENCAP
+
+   +----------------+-------------------------------------+
+   | Field          | Value                               |
+   +================+=====================================+
+   | ``definition`` | MPLS end-point overlay definition  |
+   +----------------+-------------------------------------+
+
+.. _table_rte_flow_action_mpls_l2_encap_example:
+
+.. table:: IPv4 GRE MPLS flow pattern example.
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | Ethernet |
+   +-------+----------+
+   | 1     | IPv4     |
+   +-------+----------+
+   | 2     | GRE      |
+   +-------+----------+
+   | 3     | MPLS     |
+   +-------+----------+
+   | 4     | END      |
+   +-------+----------+
+
+Action: ``MPLS_l2_DECAP``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a decapsulation action by stripping all headers of the MPLS tunnel
+network overlay from the matched flow.
+
+The flow items pattern defined for the flow rule with which a ``MPLS_DECAP``
+action is specified, must define a valid MPLS tunnel. If the
+flow pattern does not specify a valid MPLS tunnel then a
+RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
+
+This action modifies the payload of matched flows.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f8ba71c..6edce68 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1505,6 +1505,23 @@  enum rte_flow_action_type {
 	 * error.
 	 */
 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+	/**
+	 * Encapsulate flow in MPLS L2 tunnel defined in the
+	 * rte_flow_action_mpls_l2_encap action structure.
+	 *
+	 * See struct rte_flow_action_mpls_l2_encap.
+	 */
+	RTE_FLOW_ACTION_TYPE_MPLS_L2_ENCAP,
+
+	/**
+	 * Decapsulate outer most MPLS L2 tunnel from matched flow.
+	 *
+	 * If flow pattern does not define a valid MPLS L2 tunnel
+	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
+	 * error.
+	 */
+	RTE_FLOW_ACTION_TYPE_MPLS_L2_DECAP,
 };
 
 /**
@@ -1868,6 +1885,43 @@  struct rte_flow_action_nvgre_encap {
 	struct rte_flow_item *definition;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_MPLS_L2_ENCAP
+ *
+ * MPLS l2 tunnel end-point encapsulation data definition
+ *
+ * The tunnel definition is provided through the flow item pattern.
+ * This action includes both MPLSoGRE and MPLSoUDP.
+ * The flow definition must be provided in order from the 
+ * RTE_FLOW_ITEM_TYPE_ETH definition up the end item,
+ * which is specified by RTE_FLOW_ITEM_TYPE_END.
+ *
+ * The mask field allows user to specify which fields in the flow item
+ * definitions can be ignored and which have valid data and can be used
+ * verbatim.
+ *
+ * Note: the last field is not used in the definition of a tunnel and can be
+ * ignored.
+ *
+ * Example of valid flow definition for RTE_FLOW_ACTION_TYPE_MPLS_L2_ENCAP:
+ *
+ * - ETH / IPV4 / GRE / MPLS / END
+ * - ETH / VLAN / IPV4 / GRE / MPLS / END
+ * - ETH / IPV4 / UDP / MPLS / END
+ * - ETH / VLAN / IPV4 / UDP / MPLS / END
+ *
+ */
+struct rte_flow_action_mpls_l2_encap {
+	/**
+	 * Encapsulating mpls tunnel definition
+	 * (terminated by the END pattern item).
+	 */
+	struct rte_flow_item *definition;
+};
+
 /*
  * Definition of a single action.
  *