From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jack Min Subject: [PATCH v6 1/3] ethdev: add generic TTL rewrite actions Date: Tue, 16 Oct 2018 08:14:23 +0000 Message-ID: <20181016081350.24765-2-jackmin@mellanox.com> References: <20181013032348.26380-1-jackmin@mellanox.com> <20181016081350.24765-1-jackmin@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: Adrien Mazarguil , John McNamara , Marko Kovacevic , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Return-path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60065.outbound.protection.outlook.com [40.107.6.65]) by dpdk.org (Postfix) with ESMTP id 9ABC94CA5 for ; Tue, 16 Oct 2018 10:14:24 +0200 (CEST) In-Reply-To: <20181016081350.24765-1-jackmin@mellanox.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Yongseok Koh --- doc/guides/prog_guide/rte_flow.rst | 36 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 2 ++ lib/librte_ethdev/rte_flow.h | 23 +++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte= _flow.rst index a5ec441c9..e76632907 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2203,6 +2203,42 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be = returned. | no properties | +---------------+ =20 +Action: ``DEC_TTL`` +^^^^^^^^^^^^^^^^^^^ + +Decrease TTL value. + +If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6 +in pattern, Some PMDs will reject rule because behaviour will be undefined= . + +.. _table_rte_flow_action_dec_ttl: + +.. table:: DEC_TTL + + +---------------+ + | Field | + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ + | no properties | + +---------------+ + +Action: ``SET_TTL`` +^^^^^^^^^^^^^^^^^^^ + +Assigns a new TTL value. + +If there is no valid RTE_FLOW_ITEM_TYPE_IPV4 or RTE_FLOW_ITEM_TYPE_IPV6 +in pattern, Some PMDs will reject rule because behaviour will be undefined= . + +.. _table_rte_flow_action_set_ttl: + +.. table:: SET_TTL + + +---------------+--------------------+ + | Field | Value | + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ + | ``ttl_value`` | new TTL value | + +---------------+--------------------+ + Negative types ~~~~~~~~~~~~~~ =20 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_ac= tion[] =3D { 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)), }; =20 static int diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 68bbf57d0..79bcb292d 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -1579,6 +1579,20 @@ enum rte_flow_action_type { * No associated configuration structure. */ RTE_FLOW_ACTION_TYPE_MAC_SWAP, + + /** + * Decrease TTL value directly + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_DEC_TTL, + + /** + * Set TTL value + * + * See struct rte_flow_action_set_ttl + */ + RTE_FLOW_ACTION_TYPE_SET_TTL, }; =20 /** @@ -1987,6 +2001,15 @@ struct rte_flow_action_set_tp { rte_be16_t port; }; =20 +/** + * RTE_FLOW_ACTION_TYPE_SET_TTL + * + * Set the TTL value directly for IPv4 or IPv6 + */ +struct rte_flow_action_set_ttl { + uint8_t ttl_value; +}; + /* * Definition of a single action. * --=20 2.17.1