ethdev: add TTL change actions to flow API
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 24 Apr 2018 15:59:00 +0000 (17:59 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 27 Apr 2018 17:00:55 +0000 (18:00 +0100)
Add support for the following OpenFlow-defined actions:

- RTE_FLOW_ACTION_OF_SET_MPLS_TTL: MPLS TTL.

- RTE_FLOW_ACTION_OF_DEC_MPLS_TTL: decrement MPLS TTL.

- RTE_FLOW_ACTION_OF_SET_NW_TTL: IP TTL.

- RTE_FLOW_ACTION_OF_DEC_NW_TTL: decrement IP TTL.

- RTE_FLOW_ACTION_OF_COPY_TTL_OUT: copy TTL "outwards".

- RTE_FLOW_ACTION_OF_COPY_TTL_IN: copy TTL "inwards".

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
app/test-pmd/cmdline_flow.c
app/test-pmd/config.c
doc/guides/prog_guide/rte_flow.rst
doc/guides/testpmd_app_ug/testpmd_funcs.rst
lib/librte_ether/rte_flow.c
lib/librte_ether/rte_flow.h

index c83199f..5bda08f 100644 (file)
@@ -214,6 +214,14 @@ enum index {
        ACTION_PORT_ID_ID,
        ACTION_METER,
        ACTION_METER_ID,
+       ACTION_OF_SET_MPLS_TTL,
+       ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
+       ACTION_OF_DEC_MPLS_TTL,
+       ACTION_OF_SET_NW_TTL,
+       ACTION_OF_SET_NW_TTL_NW_TTL,
+       ACTION_OF_DEC_NW_TTL,
+       ACTION_OF_COPY_TTL_OUT,
+       ACTION_OF_COPY_TTL_IN,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -730,6 +738,12 @@ static const enum index next_action[] = {
        ACTION_PHY_PORT,
        ACTION_PORT_ID,
        ACTION_METER,
+       ACTION_OF_SET_MPLS_TTL,
+       ACTION_OF_DEC_MPLS_TTL,
+       ACTION_OF_SET_NW_TTL,
+       ACTION_OF_DEC_NW_TTL,
+       ACTION_OF_COPY_TTL_OUT,
+       ACTION_OF_COPY_TTL_IN,
        ZERO,
 };
 
@@ -783,6 +797,18 @@ static const enum index action_meter[] = {
        ZERO,
 };
 
+static const enum index action_of_set_mpls_ttl[] = {
+       ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
+       ACTION_NEXT,
+       ZERO,
+};
+
+static const enum index action_of_set_nw_ttl[] = {
+       ACTION_OF_SET_NW_TTL_NW_TTL,
+       ACTION_NEXT,
+       ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
                      const char *, unsigned int,
                      void *, unsigned int);
@@ -2086,6 +2112,68 @@ static const struct token token_list[] = {
                .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
                .call = parse_vc_conf,
        },
+       [ACTION_OF_SET_MPLS_TTL] = {
+               .name = "of_set_mpls_ttl",
+               .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
+               .priv = PRIV_ACTION
+                       (OF_SET_MPLS_TTL,
+                        sizeof(struct rte_flow_action_of_set_mpls_ttl)),
+               .next = NEXT(action_of_set_mpls_ttl),
+               .call = parse_vc,
+       },
+       [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
+               .name = "mpls_ttl",
+               .help = "MPLS TTL",
+               .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
+               .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
+                                       mpls_ttl)),
+               .call = parse_vc_conf,
+       },
+       [ACTION_OF_DEC_MPLS_TTL] = {
+               .name = "of_dec_mpls_ttl",
+               .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
+               .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
+               .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+               .call = parse_vc,
+       },
+       [ACTION_OF_SET_NW_TTL] = {
+               .name = "of_set_nw_ttl",
+               .help = "OpenFlow's OFPAT_SET_NW_TTL",
+               .priv = PRIV_ACTION
+                       (OF_SET_NW_TTL,
+                        sizeof(struct rte_flow_action_of_set_nw_ttl)),
+               .next = NEXT(action_of_set_nw_ttl),
+               .call = parse_vc,
+       },
+       [ACTION_OF_SET_NW_TTL_NW_TTL] = {
+               .name = "nw_ttl",
+               .help = "IP TTL",
+               .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
+               .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
+                                       nw_ttl)),
+               .call = parse_vc_conf,
+       },
+       [ACTION_OF_DEC_NW_TTL] = {
+               .name = "of_dec_nw_ttl",
+               .help = "OpenFlow's OFPAT_DEC_NW_TTL",
+               .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
+               .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+               .call = parse_vc,
+       },
+       [ACTION_OF_COPY_TTL_OUT] = {
+               .name = "of_copy_ttl_out",
+               .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
+               .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
+               .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+               .call = parse_vc,
+       },
+       [ACTION_OF_COPY_TTL_IN] = {
+               .name = "of_copy_ttl_in",
+               .help = "OpenFlow's OFPAT_COPY_TTL_IN",
+               .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
+               .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
+               .call = parse_vc,
+       },
 };
 
 /** Remove and return last entry from argument stack. */
index 7f5f40f..b05cd9c 100644 (file)
@@ -1106,6 +1106,14 @@ static const struct {
        MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)),
        MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)),
        MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
+       MK_FLOW_ACTION(OF_SET_MPLS_TTL,
+                      sizeof(struct rte_flow_action_of_set_mpls_ttl)),
+       MK_FLOW_ACTION(OF_DEC_MPLS_TTL, 0),
+       MK_FLOW_ACTION(OF_SET_NW_TTL,
+                      sizeof(struct rte_flow_action_of_set_nw_ttl)),
+       MK_FLOW_ACTION(OF_DEC_NW_TTL, 0),
+       MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0),
+       MK_FLOW_ACTION(OF_COPY_TTL_IN, 0),
 };
 
 /** Compute storage space needed by action configuration and copy it. */
index 9993c09..50cb043 100644 (file)
@@ -1716,6 +1716,103 @@ fields in the pattern items.
    | 1     | END      |
    +-------+----------+
 
+Action: ``OF_SET_MPLS_TTL``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_SET_MPLS_TTL`` ("MPLS TTL") as defined by the `OpenFlow
+Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_mpls_ttl:
+
+.. table:: OF_SET_MPLS_TTL
+
+   +--------------+----------+
+   | Field        | Value    |
+   +==============+==========+
+   | ``mpls_ttl`` | MPLS TTL |
+   +--------------+----------+
+
+Action: ``OF_DEC_MPLS_TTL``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_DEC_MPLS_TTL`` ("decrement MPLS TTL") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_dec_mpls_ttl:
+
+.. table:: OF_DEC_MPLS_TTL
+
+   +---------------+
+   | Field         |
+   +===============+
+   | no properties |
+   +---------------+
+
+Action: ``OF_SET_NW_TTL``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_SET_NW_TTL`` ("IP TTL") as defined by the `OpenFlow
+Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_nw_ttl:
+
+.. table:: OF_SET_NW_TTL
+
+   +------------+--------+
+   | Field      | Value  |
+   +============+========+
+   | ``nw_ttl`` | IP TTL |
+   +------------+--------+
+
+Action: ``OF_DEC_NW_TTL``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_DEC_NW_TTL`` ("decrement IP TTL") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_dec_nw_ttl:
+
+.. table:: OF_DEC_NW_TTL
+
+   +---------------+
+   | Field         |
+   +===============+
+   | no properties |
+   +---------------+
+
+Action: ``OF_COPY_TTL_OUT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_COPY_TTL_OUT`` ("copy TTL "outwards" -- from
+next-to-outermost to outermost") as defined by the `OpenFlow Switch
+Specification`_.
+
+.. _table_rte_flow_action_of_copy_ttl_out:
+
+.. table:: OF_COPY_TTL_OUT
+
+   +---------------+
+   | Field         |
+   +===============+
+   | no properties |
+   +---------------+
+
+Action: ``OF_COPY_TTL_IN``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Implements ``OFPAT_COPY_TTL_IN`` ("copy TTL "inwards" -- from outermost to
+next-to-outermost") as defined by the `OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_copy_ttl_in:
+
+.. table:: OF_COPY_TTL_IN
+
+   +---------------+
+   | Field         |
+   +===============+
+   | no properties |
+   +---------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
@@ -2296,3 +2393,5 @@ Future evolutions
 
 - Optional software fallback when PMDs are unable to handle requested flow
   rules so applications do not have to implement their own.
+
+.. _OpenFlow Switch Specification: https://www.opennetworking.org/software-defined-standards/specifications/
index 6660282..e2a967b 100644 (file)
@@ -3503,6 +3503,22 @@ This section lists supported actions and their attributes, if any.
   - ``original {boolean}``: use original DPDK port ID if possible.
   - ``id {unsigned}``: DPDK port ID.
 
+- ``of_set_mpls_ttl``: OpenFlow's ``OFPAT_SET_MPLS_TTL``.
+
+  - ``mpls_ttl``: MPLS TTL.
+
+- ``of_dec_mpls_ttl``: OpenFlow's ``OFPAT_DEC_MPLS_TTL``.
+
+- ``of_set_nw_ttl``: OpenFlow's ``OFPAT_SET_NW_TTL``.
+
+  - ``nw_ttl``: IP TTL.
+
+- ``of_dec_nw_ttl``: OpenFlow's ``OFPAT_DEC_NW_TTL``.
+
+- ``of_copy_ttl_out``: OpenFlow's ``OFPAT_COPY_TTL_OUT``.
+
+- ``of_copy_ttl_in``: OpenFlow's ``OFPAT_COPY_TTL_IN``.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
index 64e579d..7c0ae5b 100644 (file)
@@ -90,6 +90,14 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
        MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),
        MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)),
        MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)),
+       MK_FLOW_ACTION(OF_SET_MPLS_TTL,
+                      sizeof(struct rte_flow_action_of_set_mpls_ttl)),
+       MK_FLOW_ACTION(OF_DEC_MPLS_TTL, 0),
+       MK_FLOW_ACTION(OF_SET_NW_TTL,
+                      sizeof(struct rte_flow_action_of_set_nw_ttl)),
+       MK_FLOW_ACTION(OF_DEC_NW_TTL, 0),
+       MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0),
+       MK_FLOW_ACTION(OF_COPY_TTL_IN, 0),
 };
 
 static int
index 2fde0f2..b94ffb0 100644 (file)
@@ -1332,7 +1332,57 @@ enum rte_flow_action_type {
         *
         * See struct rte_flow_action_security.
         */
-       RTE_FLOW_ACTION_TYPE_SECURITY
+       RTE_FLOW_ACTION_TYPE_SECURITY,
+
+       /**
+        * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
+        * OpenFlow Switch Specification.
+        *
+        * See struct rte_flow_action_of_set_mpls_ttl.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
+
+       /**
+        * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
+        * by the OpenFlow Switch Specification.
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
+
+       /**
+        * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
+        * Switch Specification.
+        *
+        * See struct rte_flow_action_of_set_nw_ttl.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
+
+       /**
+        * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
+        * the OpenFlow Switch Specification.
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
+
+       /**
+        * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
+        * next-to-outermost to outermost") as defined by the OpenFlow
+        * Switch Specification.
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
+
+       /**
+        * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
+        * outermost to next-to-outermost") as defined by the OpenFlow
+        * Switch Specification.
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
 };
 
 /**
@@ -1509,6 +1559,26 @@ struct rte_flow_action_security {
        void *security_session; /**< Pointer to security session structure. */
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
+ *
+ * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
+ * Switch Specification.
+ */
+struct rte_flow_action_of_set_mpls_ttl {
+       uint8_t mpls_ttl; /**< MPLS TTL. */
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
+ *
+ * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
+ * Specification.
+ */
+struct rte_flow_action_of_set_nw_ttl {
+       uint8_t nw_ttl; /**< IP TTL. */
+};
+
 /**
  * Definition of a single action.
  *