DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: shaguna@chelsio.com, nirranjan@chelsio.com, indranil@chelsio.com
Subject: [dpdk-dev] [RFC v2 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers
Date: Mon, 13 Aug 2018 19:06:57 +0530	[thread overview]
Message-ID: <88ca7476616ac1a339eb7c6494b93f627b335b93.1534166371.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1534166371.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1534166371.git.rahul.lakkireddy@chelsio.com>

From: Shagun Agrawal <shaguna@chelsio.com>

Add actions:
- SET_TP_SRC - set a new TCP/UDP source port number.
- SET_TP_DST - set a new TCP/UDP destination port number.

Signed-off-by: Shagun Agrawal <shaguna@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
v2:
- Remove OpenFlow prefix from TCP/UDP port rewrite actions.
- Re-based to tip.

 app/test-pmd/cmdline_flow.c                 | 50 +++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  4 +++
 doc/guides/prog_guide/rte_flow.rst          | 30 +++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 +++++
 lib/librte_ethdev/rte_flow.c                |  4 +++
 lib/librte_ethdev/rte_flow.h                | 29 +++++++++++++++++
 6 files changed, 125 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fd135da64..3935539cb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -251,6 +251,10 @@ enum index {
 	ACTION_SET_IPV6_SRC_IPV6_SRC,
 	ACTION_SET_IPV6_DST,
 	ACTION_SET_IPV6_DST_IPV6_DST,
+	ACTION_SET_TP_SRC,
+	ACTION_SET_TP_SRC_TP_SRC,
+	ACTION_SET_TP_DST,
+	ACTION_SET_TP_DST_TP_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -828,6 +832,8 @@ static const enum index next_action[] = {
 	ACTION_SET_IPV4_DST,
 	ACTION_SET_IPV6_SRC,
 	ACTION_SET_IPV6_DST,
+	ACTION_SET_TP_SRC,
+	ACTION_SET_TP_DST,
 	ZERO,
 };
 
@@ -954,6 +960,18 @@ static const enum index action_set_ipv6_dst[] = {
 	ZERO,
 };
 
+static const enum index action_set_tp_src[] = {
+	ACTION_SET_TP_SRC_TP_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_tp_dst[] = {
+	ACTION_SET_TP_DST_TP_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_jump[] = {
 	ACTION_JUMP_GROUP,
 	ACTION_NEXT,
@@ -2570,6 +2588,38 @@ static const struct token token_list[] = {
 			(struct rte_flow_action_set_ipv6, ipv6_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_SET_TP_SRC] = {
+		.name = "set_tp_src",
+		.help = "set TCP/UDP source port number",
+		.priv = PRIV_ACTION(SET_TP_SRC,
+			sizeof(struct rte_flow_action_set_tp)),
+		.next = NEXT(action_set_tp_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_TP_SRC_TP_SRC] = {
+		.name = "port",
+		.help = "new source port number to set",
+		.next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_set_tp, port)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_TP_DST] = {
+		.name = "set_tp_dst",
+		.help = "set TCP/UDP destination port number",
+		.priv = PRIV_ACTION(SET_TP_DST,
+			sizeof(struct rte_flow_action_set_tp)),
+		.next = NEXT(action_set_tp_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_TP_DST_TP_DST] = {
+		.name = "port",
+		.help = "new destination port number to set",
+		.next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_set_tp, port)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 401b066b3..70dd52254 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1161,6 +1161,10 @@ static const struct {
 		       sizeof(struct rte_flow_action_set_ipv6)),
 	MK_FLOW_ACTION(SET_IPV6_DST,
 		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_TP_SRC,
+		       sizeof(struct rte_flow_action_set_tp)),
+	MK_FLOW_ACTION(SET_TP_DST,
+		       sizeof(struct rte_flow_action_set_tp)),
 };
 
 /** Compute storage space needed by action configuration and copy it. */
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 8f3dcc6c1..4faf8cb40 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2136,6 +2136,36 @@ Set a new IPv6 destination address.
    | ``ipv6_addr`` | new IPv6 destination address |
    +---------------+------------------------------+
 
+Action: ``SET_TP_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new TCP/UDP source port number.
+
+.. _table_rte_flow_action_set_tp_src:
+
+.. table:: SET_TP_SRC
+
+   +----------+-------------------------+
+   | Field    | Value                   |
+   +==========+=========================+
+   | ``port`` | new TCP/UDP source port |
+   +---------------+--------------------+
+
+Action: ``SET_TP_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new TCP/UDP destination port number.
+
+.. _table_rte_flow_action_set_tp_dst:
+
+.. table:: SET_TP_DST
+
+   +----------+------------------------------+
+   | Field    | Value                        |
+   +==========+==============================+
+   | ``port`` | new TCP/UDP destination port |
+   +---------------+-------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 638331c17..f60be0862 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3713,6 +3713,14 @@ This section lists supported actions and their attributes, if any.
 
   - ``ipv6_addr``: New IPv6 destination address.
 
+- ``of_set_tp_src``: Set a new TCP/UDP source port number.
+
+  - ``port``: New TCP/UDP source port number.
+
+- ``of_set_tp_dst``: Set a new TCP/UDP destination port number.
+
+  - ``port``: New TCP/UDP destination port number.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index d4f1b9a05..409c79741 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -117,6 +117,10 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 		       sizeof(struct rte_flow_action_set_ipv6)),
 	MK_FLOW_ACTION(SET_IPV6_DST,
 		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_TP_SRC,
+		       sizeof(struct rte_flow_action_set_tp)),
+	MK_FLOW_ACTION(SET_TP_DST,
+		       sizeof(struct rte_flow_action_set_tp)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 48c3c606e..c80771b25 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1533,6 +1533,20 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_ipv6.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
+
+	/**
+	 * Modify source port in TCP/UDP packets.
+	 *
+	 * See struct rte_flow_action_set_tp.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
+
+	/**
+	 * Modify destination port in TCP/UDP packets.
+	 *
+	 * See struct rte_flow_action_set_tp.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_TP_DST,
 };
 
 /**
@@ -1926,6 +1940,21 @@ struct rte_flow_action_set_ipv6 {
 	uint8_t ipv6_addr[16];
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_TP_DST
+ *
+ * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
+ * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
+ * for the specified TCP/UDP header.
+ */
+struct rte_flow_action_set_tp {
+	uint16_t port;
+};
+
 /*
  * Definition of a single action.
  *
-- 
2.14.1

  parent reply	other threads:[~2018-08-13 13:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22  9:56 [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API Rahul Lakkireddy
2018-06-22  9:56 ` [dpdk-dev] [RFC 1/3] ethdev: add flow api actions to modify IP addresses Rahul Lakkireddy
2018-06-22  9:56 ` [dpdk-dev] [RFC 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers Rahul Lakkireddy
2018-06-22  9:56 ` [dpdk-dev] [RFC 3/3] net/cxgbe: add flow actions to modify IP and TCP/UDP port address Rahul Lakkireddy
2018-06-26 10:32 ` [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API Thomas Monjalon
2018-07-02  9:09 ` Jack Min
2018-07-02 12:04   ` Rahul Lakkireddy
2018-07-03  2:27     ` Jack Min
2018-07-03 13:39       ` Rahul Lakkireddy
2018-07-04  1:11         ` Jack Min
2018-07-05 20:16         ` Adrien Mazarguil
2018-07-10 13:14           ` Rahul Lakkireddy
2018-08-01 23:35             ` Jack Min
2018-08-02 14:59               ` Rahul Lakkireddy
2018-08-13 13:36 ` [dpdk-dev] [RFC v2 " Rahul Lakkireddy
2018-08-13 13:36   ` [dpdk-dev] [RFC v2 1/3] ethdev: add flow api actions to modify IP addresses Rahul Lakkireddy
2018-09-18  7:56     ` Xiaoyu Min
2018-09-19 15:14       ` Rahul Lakkireddy
2018-08-13 13:36   ` Rahul Lakkireddy [this message]
2018-09-18  9:29     ` [dpdk-dev] [RFC v2 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers Xiaoyu Min
2018-09-19 15:16       ` Rahul Lakkireddy
2018-08-13 13:36   ` [dpdk-dev] [RFC v2 3/3] net/cxgbe: add flow actions to modify IP and TCP/UDP port address Rahul Lakkireddy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88ca7476616ac1a339eb7c6494b93f627b335b93.1534166371.git.rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=indranil@chelsio.com \
    --cc=nirranjan@chelsio.com \
    --cc=shaguna@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).