DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: shaguna@chelsio.com, indranil@chelsio.com, nirranjan@chelsio.com
Subject: [dpdk-dev] [RFC 1/3] ethdev: add flow api actions to modify IP addresses
Date: Fri, 22 Jun 2018 15:26:03 +0530	[thread overview]
Message-ID: <f09bc4cab33aeac4d5d3cd8e478daa42e11b0e45.1529650435.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1529650435.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1529650435.git.rahul.lakkireddy@chelsio.com>

From: Shagun Agrawal <shaguna@chelsio.com>

Add actions:
- OF_SET_NW_IPV4_SRC - set a new IPv4 source address.
- OF_SET_NW_IPV4_DST - set a new IPv4 destination address.
- OF_SET_NW_IPV6_SRC - set a new IPv6 source address.
- OF_SET_NW_IPV6_DST - set a new IPv6 destination address.

Based on OFPAT_SET_NW_SRC and OFPAT_SET_NW_DST in OpenFlow
Specification.

Signed-off-by: Shagun Agrawal <shaguna@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |   8 +++
 doc/guides/prog_guide/rte_flow.rst          |  68 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 lib/librte_ethdev/rte_flow.c                |   8 +++
 lib/librte_ethdev/rte_flow.h                |  62 +++++++++++++++++
 6 files changed, 262 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 9918d7fda..4550491ec 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -237,6 +237,14 @@ enum index {
 	ACTION_OF_POP_MPLS_ETHERTYPE,
 	ACTION_OF_PUSH_MPLS,
 	ACTION_OF_PUSH_MPLS_ETHERTYPE,
+	ACTION_OF_SET_NW_IPV4_SRC,
+	ACTION_OF_SET_NW_IPV4_SRC_NW_IPV4_SRC,
+	ACTION_OF_SET_NW_IPV4_DST,
+	ACTION_OF_SET_NW_IPV4_DST_NW_IPV4_DST,
+	ACTION_OF_SET_NW_IPV6_SRC,
+	ACTION_OF_SET_NW_IPV6_SRC_NW_IPV6_SRC,
+	ACTION_OF_SET_NW_IPV6_DST,
+	ACTION_OF_SET_NW_IPV6_DST_NW_IPV6_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -773,6 +781,10 @@ static const enum index next_action[] = {
 	ACTION_OF_SET_VLAN_PCP,
 	ACTION_OF_POP_MPLS,
 	ACTION_OF_PUSH_MPLS,
+	ACTION_OF_SET_NW_IPV4_SRC,
+	ACTION_OF_SET_NW_IPV4_DST,
+	ACTION_OF_SET_NW_IPV6_SRC,
+	ACTION_OF_SET_NW_IPV6_DST,
 	ZERO,
 };
 
@@ -868,6 +880,30 @@ static const enum index action_of_push_mpls[] = {
 	ZERO,
 };
 
+static const enum index action_of_set_nw_ipv4_src[] = {
+	ACTION_OF_SET_NW_IPV4_SRC_NW_IPV4_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_of_set_nw_ipv4_dst[] = {
+	ACTION_OF_SET_NW_IPV4_DST_NW_IPV4_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_of_set_nw_ipv6_src[] = {
+	ACTION_OF_SET_NW_IPV6_SRC_NW_IPV6_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_of_set_nw_ipv6_dst[] = {
+	ACTION_OF_SET_NW_IPV6_DST_NW_IPV6_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_jump[] = {
 	ACTION_JUMP_GROUP,
 	ACTION_NEXT,
@@ -2362,6 +2398,70 @@ static const struct token token_list[] = {
 			      ethertype)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_OF_SET_NW_IPV4_SRC] = {
+		.name = "of_set_ipv4_src",
+		.help = "set ipv4 source address",
+		.priv = PRIV_ACTION(OF_SET_NW_IPV4_SRC,
+			sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+		.next = NEXT(action_of_set_nw_ipv4_src),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_NW_IPV4_SRC_NW_IPV4_SRC] = {
+		.name = "ipv4_addr",
+		.help = "new ipv4 source address to set",
+		.next = NEXT(action_of_set_nw_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_of_set_nw_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_OF_SET_NW_IPV4_DST] = {
+		.name = "of_set_ipv4_dst",
+		.help = "set ipv4 destination address",
+		.priv = PRIV_ACTION(OF_SET_NW_IPV4_DST,
+			sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+		.next = NEXT(action_of_set_nw_ipv4_dst),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_NW_IPV4_DST_NW_IPV4_DST] = {
+		.name = "ipv4_addr",
+		.help = "new ipv4 destination address to set",
+		.next = NEXT(action_of_set_nw_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_of_set_nw_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_OF_SET_NW_IPV6_SRC] = {
+		.name = "of_set_ipv6_src",
+		.help = "set ipv6 source address",
+		.priv = PRIV_ACTION(OF_SET_NW_IPV6_SRC,
+			sizeof(struct rte_flow_action_of_set_nw_ipv6)),
+		.next = NEXT(action_of_set_nw_ipv6_src),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_NW_IPV6_SRC_NW_IPV6_SRC] = {
+		.name = "ipv6_addr",
+		.help = "new ipv6 source address to set",
+		.next = NEXT(action_of_set_nw_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_of_set_nw_ipv6, ipv6_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_OF_SET_NW_IPV6_DST] = {
+		.name = "of_set_ipv6_dst",
+		.help = "set ipv6 destination address",
+		.priv = PRIV_ACTION(OF_SET_NW_IPV6_DST,
+			sizeof(struct rte_flow_action_of_set_nw_ipv6)),
+		.next = NEXT(action_of_set_nw_ipv6_dst),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_NW_IPV6_DST_NW_IPV6_DST] = {
+		.name = "ipv6_addr",
+		.help = "new ipv6 destination address to set",
+		.next = NEXT(action_of_set_nw_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_of_set_nw_ipv6, ipv6_addr)),
+		.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 97020fb3d..83cb0354d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1153,6 +1153,14 @@ static const struct {
 		       sizeof(struct rte_flow_action_of_pop_mpls)),
 	MK_FLOW_ACTION(OF_PUSH_MPLS,
 		       sizeof(struct rte_flow_action_of_push_mpls)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV4_SRC,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV4_DST,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV6_SRC,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv6)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV6_DST,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv6)),
 };
 
 /** 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 b305a72a5..3f56cc2d1 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2076,6 +2076,74 @@ RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
 
 This action modifies the payload of matched flows.
 
+Action: ``OF_SET_NW_IPV4_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv4 source address. It is based on ``OFPAT_SET_NW_SRC``
+("set the network source address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_nw_ipv4_src:
+
+.. table:: OF_SET_NW_IPV4_SRC
+
+   +---------------+-------------------------+
+   | Field         | Value                   |
+   +===============+=========================+
+   | ``ipv4_addr`` | new IPv4 source address |
+   +---------------+-------------------------+
+
+Action: ``OF_SET_NW_IPV4_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv4 destination address. It is based on ``OFPAT_SET_NW_DST``
+("set the network destination address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_nw_ipv4_dst:
+
+.. table:: OF_SET_NW_IPV4_DST
+
+   +---------------+------------------------------+
+   | Field         | Value                        |
+   +===============+==============================+
+   | ``ipv4_addr`` | new IPv4 destination address |
+   +---------------+------------------------------+
+
+Action: ``OF_SET_NW_IPV6_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv6 source address. It is based on ``OFPAT_SET_NW_SRC``
+("set the network source address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_nw_ipv6_src:
+
+.. table:: OF_SET_NW_IPV6_SRC
+
+   +---------------+-------------------------+
+   | Field         | Value                   |
+   +===============+=========================+
+   | ``ipv6_addr`` | new IPv6 source address |
+   +---------------+-------------------------+
+
+Action: ``OF_SET_NW_IPV6_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new IPv6 destination address. It is based on ``OFPAT_SET_NW_DST``
+("set the network destination address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_nw_ipv6_dst:
+
+.. table:: OF_SET_NW_IPV6_DST
+
+   +---------------+------------------------------+
+   | Field         | Value                        |
+   +===============+==============================+
+   | ``ipv6_addr`` | new IPv6 destination address |
+   +---------------+------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 0d6fd50ca..56e3d6326 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3650,6 +3650,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``ethertype``: Ethertype.
 
+- ``of_set_ipv4_src``: Set a new IPv4 source address.
+
+  - ``ipv4_addr``: New IPv4 source address.
+
+- ``of_set_ipv4_dst``: Set a new IPv4 destination address.
+
+  - ``ipv4_addr``: New IPv4 destination address.
+
+- ``of_set_ipv6_src``: Set a new IPv6 source address.
+
+  - ``ipv6_addr``: New IPv6 source address.
+
+- ``of_set_ipv6_dst``: Set a new ipv6 destination address.
+
+  - ``ipv6_addr``: New IPv6 destination address.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index b2afba089..29f846783 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -109,6 +109,14 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 		       sizeof(struct rte_flow_action_of_pop_mpls)),
 	MK_FLOW_ACTION(OF_PUSH_MPLS,
 		       sizeof(struct rte_flow_action_of_push_mpls)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV4_SRC,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV4_DST,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv4)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV6_SRC,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv6)),
+	MK_FLOW_ACTION(OF_SET_NW_IPV6_DST,
+		       sizeof(struct rte_flow_action_of_set_nw_ipv6)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f8ba71cdb..76cf652c5 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1505,6 +1505,38 @@ enum rte_flow_action_type {
 	 * error.
 	 */
 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+	/**
+	 * Implements OFPAT_SET_NW_SRC (set the network src addr) as defined
+	 * by the OpenFlow Switch Specification for ipv4 address.
+	 *
+	 * See struct rte_flow_action_of_set_nw_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV4_SRC,
+
+	/**
+	 * Implements OFPAT_SET_NW_DST (set the network dst addr) as defined
+	 * by the OpenFlow Switch Specification for ipv4 address.
+	 *
+	 * See struct rte_flow_action_of_set_nw_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV4_DST,
+
+	/**
+	 * Implements OFPAT_SET_NW_SRC (set the network src addr) as defined
+	 * by the OpenFlow Switch Specification for ipv6 address.
+	 *
+	 * See struct rte_flow_action_of_set_nw_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV6_SRC,
+
+	/**
+	 * Implements OFPAT_SET_NW_DST (set the network dst addr) as defined
+	 * by the OpenFlow Switch Specification for ipv6 address.
+	 *
+	 * See struct rte_flow_action_of_set_nw_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV6_DST,
 };
 
 /**
@@ -1868,6 +1900,36 @@ 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_OF_SET_NW_IPV4_SRC
+ * RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV4_DST
+ *
+ * Implements OFPAT_SET_NW_SRC & OFPAT_SET_NW_DST (set the network
+ * src/dst addr) as defined by the OpenFlow Switch Specification
+ * for ipv4 address.
+ */
+struct rte_flow_action_of_set_nw_ipv4 {
+	uint32_t ipv4_addr;
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV6_SRC
+ * RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV6_DST
+ *
+ * Implements OFPAT_SET_NW_SRC & OFPAT_SET_NW_DST (set the network
+ * src/dst addr) as defined by the OpenFlow Switch Specification
+ * for ipv6 address.
+ */
+struct rte_flow_action_of_set_nw_ipv6 {
+	uint8_t ipv6_addr[16];
+};
+
 /*
  * Definition of a single action.
  *
-- 
2.14.1

  reply	other threads:[~2018-06-22  9:57 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 ` Rahul Lakkireddy [this message]
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   ` [dpdk-dev] [RFC v2 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers Rahul Lakkireddy
2018-09-18  9:29     ` 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=f09bc4cab33aeac4d5d3cd8e478daa42e11b0e45.1529650435.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).