[v4,1/3] ethdev: add generic TTL rewrite actions

Message ID 20181011132641.1000-2-jackmin@mellanox.com
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: add generic TTL rewrite actions
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Jack Min Oct. 11, 2018, 1:27 p.m.
rewrite TTL by decrease or just set it directly
it's not necessary to check if the final result
is zero or not

This is slightly different from the one defined
by openflow and more generic

Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 24 +++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  2 ++
 lib/librte_ethdev/rte_flow.h       | 31 ++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)

Comments

Ferruh Yigit Oct. 12, 2018, 2:12 p.m. | #1
On 10/11/2018 2:27 PM, Jack Min wrote:
> rewrite TTL by decrease or just set it directly
> it's not necessary to check if the final result
> is zero or not
> 
> This is slightly different from the one defined
> by openflow and more generic
> 
> Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
> Acked-by: Yongseok Koh <yskoh@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst | 24 +++++++++++++++++++++++

Getting following documentation warning, can you please check:

rte_flow.rst:2198: WARNING: Content block expected for the "table" directive;
none found.
Jack Min Oct. 13, 2018, 2:16 a.m. | #2
On 18-10-12 15:12:06, Ferruh Yigit wrote:
> On 10/11/2018 2:27 PM, Jack Min wrote:
> > rewrite TTL by decrease or just set it directly
> > it's not necessary to check if the final result
> > is zero or not
> > 
> > This is slightly different from the one defined
> > by openflow and more generic
> > 
> > Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
> > Acked-by: Yongseok Koh <yskoh@mellanox.com>
> > ---
> >  doc/guides/prog_guide/rte_flow.rst | 24 +++++++++++++++++++++++
> 
> Getting following documentation warning, can you please check:
> 
> rte_flow.rst:2198: WARNING: Content block expected for the "table" directive;
> none found.
> 
Yes, of course.

Patch

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index a5ec441c9..9fc5b88f2 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2197,12 +2197,36 @@  Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
 
 .. table:: MAC_SWAP
 
+Action: ``DEC_TTL``
+^^^^^^^^^^^^^^^^^^^
+
+Decrease TTL value.
+
+.. _table_rte_flow_action_dec_ttl:
+
+.. table:: DEC_TTL
+
    +---------------+
    | Field         |
    +===============+
    | no properties |
    +---------------+
 
+Action: ``SET_TTL``
+^^^^^^^^^^^^^^^^^^^
+
+Assigns a new TTL value.
+
+.. _table_rte_flow_action_set_ttl:
+
+.. table:: SET_TTL
+
+   +---------------+--------------------+
+   | Field         | Value              |
+   +===============+====================+
+   | ``ttl_value`` | new TTL value      |
+   +---------------+--------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index bc9e719dc..5040c7667 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -136,6 +136,8 @@  static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(SET_TP_DST,
 		       sizeof(struct rte_flow_action_set_tp)),
 	MK_FLOW_ACTION(MAC_SWAP, 0),
+	MK_FLOW_ACTION(DEC_TTL, 0),
+	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 68bbf57d0..f102e6939 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1579,6 +1579,26 @@  enum rte_flow_action_type {
 	 * No associated configuration structure.
 	 */
 	RTE_FLOW_ACTION_TYPE_MAC_SWAP,
+
+	/**
+	 * Decrease TTL value directly
+	 *
+	 * If flow pattern doesn't define a valid RTE_FLOW_ITEM_TYPE_IPV4, or
+	 * RTE_FLOW_ITEM_TYPE_IPV6, the PMD should return a
+	 * RTE_FLOW_ERROR_TYPE_ACTION error.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TTL,
+
+	/**
+	 * Set TTL value
+	 *
+	 * If flow pattern doesn't define a valid RTE_FLOW_ITEM_TYPE_IPV4, or
+	 * RTE_FLOW_ITEM_TYPE_IPV6, the PMD should return a
+	 * RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_set_ttl
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_TTL,
 };
 
 /**
@@ -1987,6 +2007,17 @@  struct rte_flow_action_set_tp {
 	rte_be16_t port;
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_SET_TTL
+ *
+ * Set the TTL value directly for IPv4 or IPv6
+ * The RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6
+ * must be present in pattern
+ */
+struct rte_flow_action_set_ttl {
+	uint8_t ttl_value;
+};
+
 /*
  * Definition of a single action.
  *