Skip to contentSkip to conversation

ethdev: add IP address and TCP/UDP port rewrite actions to flow API

RFC Superseded Rahul Lakkireddy 4 participants 22 messages Jun 22, 2018 – Sep 19, 2018 Network drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1] http://www.opennetworking.org/images/openflow-switch-v1.5.1.pdf

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150 ++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

RFC 1/3 ethdev: add flow api actions to modify IP addresses

From: Shagun Agrawal <[email protected]>

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.

---
 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(+)
app/test-pmd/cmdline_flow.c +100 -0
index 9918d7fda..4550491ec 100644
@@ -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. */
app/test-pmd/config.c +8 -0
index 97020fb3d..83cb0354d 100644
@@ -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. */
doc/guides/prog_guide/rte_flow.rst +68 -0

74 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +16 -0
index 0d6fd50ca..56e3d6326 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/librte_ethdev/rte_flow.c +8 -0
index b2afba089..29f846783 100644
@@ -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
lib/librte_ethdev/rte_flow.h +62 -0

74 lines not on this page · raw message

Signature · 1 line
2.14.1
#2 lore raw

RFC 2/3 ethdev: add flow api actions to modify TCP/UDP port numbers

In reply to Rahul Lakkireddy

From: Shagun Agrawal <[email protected]>

Add actions:
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

Based on OFPAT_SET_TP_SRC and OFPAT_SET_TP_DST actions from OpenFlow Specification.

---
 app/test-pmd/cmdline_flow.c                 | 50 +++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  4 +++
 doc/guides/prog_guide/rte_flow.rst          | 34 ++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 +++++
 lib/librte_ethdev/rte_flow.c                |  4 +++
 lib/librte_ethdev/rte_flow.h                | 30 +++++++++++++++++
 6 files changed, 130 insertions(+)
app/test-pmd/cmdline_flow.c +50 -0
index 4550491ec..87745ada9 100644
@@ -245,6 +245,10 @@ enum index {
 	ACTION_OF_SET_NW_IPV6_SRC_NW_IPV6_SRC,
 	ACTION_OF_SET_NW_IPV6_DST,
 	ACTION_OF_SET_NW_IPV6_DST_NW_IPV6_DST,
+	ACTION_OF_SET_TP_SRC,
+	ACTION_OF_SET_TP_SRC_TP_SRC,
+	ACTION_OF_SET_TP_DST,
+	ACTION_OF_SET_TP_DST_TP_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -785,6 +789,8 @@ static const enum index next_action[] = {
 	ACTION_OF_SET_NW_IPV4_DST,
 	ACTION_OF_SET_NW_IPV6_SRC,
 	ACTION_OF_SET_NW_IPV6_DST,
+	ACTION_OF_SET_TP_SRC,
+	ACTION_OF_SET_TP_DST,
 	ZERO,
 };
 
@@ -904,6 +910,18 @@ static const enum index action_of_set_nw_ipv6_dst[] = {
 	ZERO,
 };
 
+static const enum index action_of_set_tp_src[] = {
+	ACTION_OF_SET_TP_SRC_TP_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_of_set_tp_dst[] = {
+	ACTION_OF_SET_TP_DST_TP_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_jump[] = {
 	ACTION_JUMP_GROUP,
 	ACTION_NEXT,
@@ -2462,6 +2480,38 @@ static const struct token token_list[] = {
 			(struct rte_flow_action_of_set_nw_ipv6, ipv6_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_OF_SET_TP_SRC] = {
+		.name = "of_set_tp_src",
+		.help = "set tcp/udp source port number",
+		.priv = PRIV_ACTION(OF_SET_TP_SRC,
+			sizeof(struct rte_flow_action_of_set_tp)),
+		.next = NEXT(action_of_set_tp_src),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_TP_SRC_TP_SRC] = {
+		.name = "port",
+		.help = "new source port number to set",
+		.next = NEXT(action_of_set_tp_src, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_of_set_tp, port)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_OF_SET_TP_DST] = {
+		.name = "of_set_tp_dst",
+		.help = "set tcp/udp destination port number",
+		.priv = PRIV_ACTION(OF_SET_TP_DST,
+			sizeof(struct rte_flow_action_of_set_tp)),
+		.next = NEXT(action_of_set_tp_dst),
+		.call = parse_vc,
+	},
+	[ACTION_OF_SET_TP_DST_TP_DST] = {
+		.name = "port",
+		.help = "new destination port number to set",
+		.next = NEXT(action_of_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_of_set_tp, port)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
app/test-pmd/config.c +4 -0
index 83cb0354d..1faf0071e 100644
@@ -1161,6 +1161,10 @@ static const struct {
 		       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)),
+	MK_FLOW_ACTION(OF_SET_TP_SRC,
+		       sizeof(struct rte_flow_action_of_set_tp)),
+	MK_FLOW_ACTION(OF_SET_TP_DST,
+		       sizeof(struct rte_flow_action_of_set_tp)),
 };
 
 /** Compute storage space needed by action configuration and copy it. */
doc/guides/prog_guide/rte_flow.rst +34 -0
index 3f56cc2d1..76c25a606 100644
@@ -2144,6 +2144,40 @@ Set a new IPv6 destination address. It is based on ``OFPAT_SET_NW_DST``
    | ``ipv6_addr`` | new IPv6 destination address |
    +---------------+------------------------------+
 
+Action: ``OF_SET_TP_SRC``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new TCP/UDP source port number. It is based on ``OFPAT_SET_TP_SRC``
+("set the transport source address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_tp_src:
+
+.. table:: OF_SET_TP_SRC
+
+   +----------+-------------------------+
+   | Field    | Value                   |
+   +==========+=========================+
+   | ``port`` | new TCP/UDP source port |
+   +---------------+--------------------+
+
+Action: ``OF_SET_TP_DST``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a new TCP/UDP destination port number. It is based on ``OFPAT_SET_TP_DST``
+("set the transport destination address") as defined by the
+`OpenFlow Switch Specification`_.
+
+.. _table_rte_flow_action_of_set_tp_dst:
+
+.. table:: OF_SET_TP_DST
+
+   +----------+------------------------------+
+   | Field    | Value                        |
+   +==========+==============================+
+   | ``port`` | new TCP/UDP destination port |
+   +---------------+-------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
doc/guides/testpmd_app_ug/testpmd_funcs.rst +8 -0
index 56e3d6326..488b84de8 100644
@@ -3666,6 +3666,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
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/librte_ethdev/rte_flow.c +4 -0
index 29f846783..c1ec26276 100644
@@ -117,6 +117,10 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 		       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)),
+	MK_FLOW_ACTION(OF_SET_TP_SRC,
+		       sizeof(struct rte_flow_action_of_set_tp)),
+	MK_FLOW_ACTION(OF_SET_TP_DST,
+		       sizeof(struct rte_flow_action_of_set_tp)),
 };
 
 static int
lib/librte_ethdev/rte_flow.h +30 -0
index 76cf652c5..9b58f3894 100644
@@ -1537,6 +1537,22 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_of_set_nw_ipv6.
 	 */
 	RTE_FLOW_ACTION_TYPE_OF_SET_NW_IPV6_DST,
+
+	/**
+	 * Implements OFPAT_SET_TP_SRC (set the source transport port) as
+	 * defined by the OpenFlow Switch Specification for tcp/udp.
+	 *
+	 * See struct rte_flow_action_of_set_tp.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_TP_SRC,
+
+	/**
+	 * Implements OFPAT_SET_TP_DST (set the destination transport port)
+	 * as defined by the OpenFlow Switch Specification for tcp/udp.
+	 *
+	 * See struct rte_flow_action_of_set_tp.
+	 */
+	RTE_FLOW_ACTION_TYPE_OF_SET_TP_DST,
 };
 
 /**
@@ -1930,6 +1946,20 @@ struct rte_flow_action_of_set_nw_ipv6 {
 	uint8_t ipv6_addr[16];
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_OF_SET_TP_SRC
+ * RTE_FLOW_ACTION_TYPE_OF_SET_TP_DST
+ *
+ * Implements OFPAT_SET_TP_SRC & OFPAT_SET_TP_DST (set the transport port)
+ * as defined by the OpenFlow Switch Specification for tcp/udp.
+ */
+struct rte_flow_action_of_set_tp {
+	uint16_t port;
+};
+
 /*
  * Definition of a single action.
  *
Signature · 1 line
2.14.1
#3 lore raw

RFC 3/3 net/cxgbe: add flow actions to modify IP and TCP/UDP port address

In reply to Rahul Lakkireddy

From: Shagun Agrawal <[email protected]>

Query firmware for the new filter work request to offload flows with actions to modify IP and TCP/UDP port addresses. When available, translate IP and TCP/UDP port address modify actions to internal hardware specification and offload the flow to hardware.

---
 drivers/net/cxgbe/base/common.h         |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h |  50 +++++++++++++
 drivers/net/cxgbe/cxgbe_filter.c        |  23 +++++-
 drivers/net/cxgbe/cxgbe_filter.h        |  26 ++++++-
 drivers/net/cxgbe/cxgbe_flow.c          | 127 ++++++++++++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c          |  10 +++
 6 files changed, 233 insertions(+), 4 deletions(-)
drivers/net/cxgbe/base/common.h +1 -0
index e524f7931..f4b2e14cd 100644
@@ -256,6 +256,7 @@ struct adapter_params {
 
 	bool ulptx_memwrite_dsgl;          /* use of T5 DSGL allowed */
 	u8 fw_caps_support;		  /* 32-bit Port Capabilities */
+	bool filter2_wr_support;	/* FW support for FILTER2_WR */
 };
 
 /* Firmware Port Capabilities types.
drivers/net/cxgbe/base/t4fw_interface.h +50 -0

74 lines not on this page · raw message

drivers/net/cxgbe/cxgbe_filter.c +20 -3
index d098b9308..6744b6a60 100644
@@ -30,6 +30,10 @@ int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs)
 
 #undef S
 #undef U
+
+	if (fs->nat_mode && !adapter->params.filter2_wr_support)
+		return -EOPNOTSUPP;
+
 	return 0;
 }
 
@@ -193,7 +197,7 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	struct adapter *adapter = ethdev2adap(dev);
 	struct filter_entry *f = &adapter->tids.ftid_tab[fidx];
 	struct rte_mbuf *mbuf;
-	struct fw_filter_wr *fwr;
+	struct fw_filter2_wr *fwr;
 	struct sge_ctrl_txq *ctrlq;
 	unsigned int port_id = ethdev2pinfo(dev)->port_id;
 	int ret;
@@ -208,13 +212,16 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	mbuf->data_len = sizeof(*fwr);
 	mbuf->pkt_len = mbuf->data_len;
 
-	fwr = rte_pktmbuf_mtod(mbuf, struct fw_filter_wr *);
+	fwr = rte_pktmbuf_mtod(mbuf, struct fw_filter2_wr *);
 	memset(fwr, 0, sizeof(*fwr));
 
 	/*
 	 * Construct the work request to set the filter.
 	 */
-	fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER_WR));
+	if (adapter->params.filter2_wr_support)
+		fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER2_WR));
+	else
+		fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER_WR));
 	fwr->len16_pkd = cpu_to_be32(V_FW_WR_LEN16(sizeof(*fwr) / 16));
 	fwr->tid_to_iq =
 		cpu_to_be32(V_FW_FILTER_WR_TID(f->tid) |
@@ -224,6 +231,7 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	fwr->del_filter_to_l2tix =
 		cpu_to_be32(V_FW_FILTER_WR_DROP(f->fs.action == FILTER_DROP) |
 			    V_FW_FILTER_WR_DIRSTEER(f->fs.dirsteer) |
+			    V_FW_FILTER_WR_LPBK(f->fs.action == FILTER_SWITCH) |
 			    V_FW_FILTER_WR_HITCNTS(f->fs.hitcnts) |
 			    V_FW_FILTER_WR_PRIO(f->fs.prio));
 	fwr->ethtype = cpu_to_be16(f->fs.val.ethtype);
@@ -244,6 +252,15 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	fwr->fp = cpu_to_be16(f->fs.val.fport);
 	fwr->fpm = cpu_to_be16(f->fs.mask.fport);
 
+	if (adapter->params.filter2_wr_support && f->fs.nat_mode) {
+		fwr->natmode_to_ulp_type =
+			V_FW_FILTER2_WR_NATMODE(f->fs.nat_mode);
+		memcpy(fwr->newlip, f->fs.nat_lip, sizeof(fwr->newlip));
+		memcpy(fwr->newfip, f->fs.nat_fip, sizeof(fwr->newfip));
+		fwr->newlport = cpu_to_be16(f->fs.nat_lport);
+		fwr->newfport = cpu_to_be16(f->fs.nat_fport);
+	}
+
 	/*
 	 * Mark the filter as "pending" and ship off the Filter Work Request.
 	 * When we get the Work Request Reply we'll clear the pending status.
drivers/net/cxgbe/cxgbe_filter.h +25 -1
index 4df37b9cd..609751474 100644
@@ -97,6 +97,18 @@ struct ch_filter_specification {
 	uint32_t dirsteer:1;	/* 0 => RSS, 1 => steer to iq */
 	uint32_t iq:10;		/* ingress queue */
 
+	/*
+	 * Switch proxy/rewrite fields.  An ingress packet which matches a
+	 * filter with "switch" set will be looped back out as an egress
+	 * packet -- potentially with some Ethernet header rewriting.
+	 */
+	uint32_t nat_mode:3;	/* specify NAT operation mode */
+
+	uint8_t nat_lip[16];	/* local IP to use after NAT'ing */
+	uint8_t nat_fip[16];	/* foreign IP to use after NAT'ing */
+	uint16_t nat_lport;	/* local port to use after NAT'ing */
+	uint16_t nat_fport;	/* foreign port to use after NAT'ing */
+
 	/* Filter rule value/mask pairs. */
 	struct ch_filter_tuple val;
 	struct ch_filter_tuple mask;
@@ -104,7 +116,19 @@ struct ch_filter_specification {
 
 enum {
 	FILTER_PASS = 0,	/* default */
-	FILTER_DROP
+	FILTER_DROP,
+	FILTER_SWITCH,
+};
+
+enum {
+	NAT_MODE_NONE = 0,	/* No NAT performed */
+	NAT_MODE_DIP,		/* NAT on Dst IP */
+	NAT_MODE_DIP_DP,	/* NAT on Dst IP, Dst Port */
+	NAT_MODE_DIP_DP_SIP,	/* NAT on Dst IP, Dst Port and Src IP */
+	NAT_MODE_DIP_DP_SP,	/* NAT on Dst IP, Dst Port and Src Port */
+	NAT_MODE_SIP_SP,	/* NAT on Src IP and Src Port */
+	NAT_MODE_DIP_SIP_SP,	/* NAT on Dst IP, Src IP and Src Port */
+	NAT_MODE_ALL		/* NAT on entire 4-tuple */
 };
 
 enum filter_type {
drivers/net/cxgbe/cxgbe_flow.c +127 -0

151 lines not on this page · raw message

drivers/net/cxgbe/cxgbe_main.c +10 -0
index 21ad380ae..50d93e7da 100644
@@ -990,6 +990,16 @@ static int adap_init0(struct adapter *adap)
 	if (ret < 0)
 		goto bye;
 
+	/* See if FW supports FW_FILTER2 work request */
+	if (is_t4(adap->params.chip)) {
+		adap->params.filter2_wr_support = 0;
+	} else {
+		params[0] = FW_PARAM_DEV(FILTER2_WR);
+		ret = t4_query_params(adap, adap->mbox, adap->pf, 0,
+				      1, params, val);
+		adap->params.filter2_wr_support = (ret == 0 && val[0] != 0);
+	}
+
 	/* query tid-related parameters */
 	params[0] = FW_PARAM_DEV(NTID);
 	ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1,
Signature · 1 line
2.14.1
#4 lore raw
In reply to Rahul Lakkireddy

Hi,

22/06/2018 11:56, Rahul Lakkireddy:

Quoted 7 lines

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

Given the date of submission, I guess you do not expect it for 18.08. Next time, better to make it clear by adding it in the Subject:

	[RFC 18.11 0/3]

Thanks for proposing in advance.
I hope we will have some good reviews in advance too.

Adding some active maintainers as Cc.

#5 lore raw
In reply to Rahul Lakkireddy

Hey,

I've one question:

Do those APIs support modify inner IP headers?

In our scenarios, we need to specific that NAT action is on inner or outer IP header.

Thanks,
-Jack

Quoted 65 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.open
networking.org%2Fimages%2Fopenflow-switch- v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f 123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636 652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH 0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

#6 lore raw

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;

};

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 71 lines

In our scenarios, we need to specific that NAT action is on inner or outer IP header.

Thanks,
-Jack

Quoted 65 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.open
networking.org%2Fimages%2Fopenflow-switch- v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f 123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636 652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH 0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

#7 lore raw

Hey Rahul,

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {

uint32_t ipv4_addr;
uint8_t level; /* 0 - outer (default), 1 - inner, 2 -255 deeper if available */
};

What do you think ?

-Jack

Quoted 120 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 1 line

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 44 lines

Thanks,
-Jack

Quoted 40 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH

Quoted 25 lines
Quoted 24 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

#8 lore raw
Quoted 4 lines · Jack Min

Hey Rahul,

Thank you, those two are the ways to achieve that.

Quoted 9 lines

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {

uint32_t ipv4_addr;
uint8_t level; /* 0 - outer (default), 1 - inner, 2 -255 deeper if available */
};

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

Thanks,
Rahul

Quoted 121 lines
Quoted 121 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 1 line

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 44 lines

Thanks,
-Jack

Quoted 40 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH

Quoted 25 lines
Quoted 24 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

#9 lore raw

Rahul, Thank you 😊!

-Jack

Quoted 162 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 3, 2018 21:39
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Quoted 9 lines · Jack Min

Hey Rahul,

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {

uint32_t ipv4_addr;
uint8_t level; /* 0 - outer (default), 1 - inner, 2 -255 deeper if available

*/

Quoted 4 lines
    };

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

Thanks,
Rahul

Quoted 70 lines
Quoted 70 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 2 lines

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 21 lines

Thanks,
-Jack

Quoted 17 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC,

and

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%
2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port
address

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127

+++++++++++++++++++++++

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

#10 lore raw
In reply to Rahul Lakkireddy
Quoted 12 lines · Rahul Lakkireddy
Quoted 11 lines · Jack Min

Hey Rahul,

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {

uint32_t ipv4_addr;
uint8_t level; /* 0 - outer (default), 1 - inner, 2 -255 deeper if available */
};

Quoted 4 lines
Quoted 2 lines

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

I still haven't looked at the original proposal (will get there eventually), however keep in mind the presence of "OF" in action names stands for "OpenFlow".

Since you chose this route, these actions must be implemented exactly as defined by the OpenFlow specification, which comprises their name, input parameters and behavior.

For instance there is no support/distinction for IPv6. NW actions must be named OF_SET_NW_SRC and OF_SET_NW_DST, only support IPv4 (a single be32) and not have the ability to tell inner from outer as it's unspecified (note a safe approach would be to interpret this as "outermost" given the tendency of OpenFlow actions to prepend empty headers and modify them afterward).

In short you can't be creative if you want to keep the OF prefix.

My suggestion would be to stick with OF if your target use case is OVS and implement these actions exactly as defined by OpenFlow, even if it means limitations due to API (not HW) constraints. Not having to spend time to figure how to map OF actions to rte_flow and handle quirks on both sides should be much more convenient to users, particularly so if these actions bear the same name.

Quoted 120 lines
Quoted 120 lines
Quoted 120 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 1 line

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 44 lines

Thanks,
-Jack

Quoted 40 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH

Quoted 25 lines
Quoted 24 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

Signature · 2 lines
Adrien Mazarguil
6WIND
#11 lore raw
Quoted 26 lines · Adrien Mazarguil
Quoted 12 lines · Rahul Lakkireddy
Quoted 11 lines · Jack Min

Hey Rahul,

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {

uint32_t ipv4_addr;
uint8_t level; /* 0 - outer (default), 1 - inner, 2 -255 deeper if available */
};

Quoted 4 lines
Quoted 2 lines

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

I still haven't looked at the original proposal (will get there eventually), however keep in mind the presence of "OF" in action names stands for "OpenFlow".

Since you chose this route, these actions must be implemented exactly as defined by the OpenFlow specification, which comprises their name, input parameters and behavior.

Quoted 8 lines

For instance there is no support/distinction for IPv6. NW actions must be named OF_SET_NW_SRC and OF_SET_NW_DST, only support IPv4 (a single be32) and not have the ability to tell inner from outer as it's unspecified (note a safe approach would be to interpret this as "outermost" given the tendency of OpenFlow actions to prepend empty headers and modify them afterward).

In short you can't be creative if you want to keep the OF prefix.

Ok, will drop OF prefix for these actions in v2.

Quoted 7 lines

My suggestion would be to stick with OF if your target use case is OVS and implement these actions exactly as defined by OpenFlow, even if it means limitations due to API (not HW) constraints. Not having to spend time to figure how to map OF actions to rte_flow and handle quirks on both sides should be much more convenient to users, particularly so if these actions bear the same name.

We can translate OF_SET_NW_* actions to RTE_FLOW_ACTION_SET_NW_IPV4_* actions in OVS stack itself before sending them via DPDK stack for offload.

Thanks,
Rahul

Quoted 124 lines
Quoted 120 lines
Quoted 120 lines
Quoted 120 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 1 line

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 44 lines

Thanks,
-Jack

Quoted 40 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC, and OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b79954b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C636

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDSH

Quoted 25 lines
Quoted 24 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102 +++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127 +++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

Signature · 2 lines
Adrien Mazarguil
6WIND
#12 lore raw
Quoted 16 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 10, 2018 21:14
To: Adrien Mazarguil <[email protected]>
Cc: Jack Min <[email protected]>; [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Quoted 4 lines · Adrien Mazarguil
Quoted 3 lines · Rahul Lakkireddy
Quoted 2 lines · Jack Min

Hey Rahul,

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {
 	   uint32_t ipv4_addr;
                uint8_t   level;  /* 0 - outer (default), 1 - inner, 2 -255 deeper if

available */

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
    };

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

Rahul, we have second thought about **level** parameter. We found there are no any *real* user case which really need to modify the inner layer. Do you have any? If no, **level** could be removed in order to keep API clean and simple.

Quoted 14 lines
Quoted 10 lines

I still haven't looked at the original proposal (will get there eventually), however keep in mind the presence of "OF" in action names stands for "OpenFlow".

Since you chose this route, these actions must be implemented exactly as defined by the OpenFlow specification, which comprises their name, input parameters and behavior.

For instance there is no support/distinction for IPv6. NW actions must be named OF_SET_NW_SRC and OF_SET_NW_DST, only support IPv4 (a

single

Quoted 3 lines

be32) and not have the ability to tell inner from outer as it's unspecified (note a safe approach would be to interpret this as "outermost" given the tendency of OpenFlow actions to prepend empty headers

Quoted 6 lines

and modify them afterward).

Quoted 3 lines

In short you can't be creative if you want to keep the OF prefix.

Ok, will drop OF prefix for these actions in v2.

How about drop the NW prefix as well? Since we don't want to stick on openflow, NW prefix seems redundant. Names like RTE_FLOW_ACTION_SET_IPV4_SRC is clear enough, isn't it? What do you think?

Quoted 155 lines
Quoted 7 lines

My suggestion would be to stick with OF if your target use case is OVS and implement these actions exactly as defined by OpenFlow, even if it means limitations due to API (not HW) constraints. Not having to spend time to figure how to map OF actions to rte_flow and handle quirks on both sides should be much more convenient to users, particularly so if these actions bear the same name.

We can translate OF_SET_NW_* actions to RTE_FLOW_ACTION_SET_NW_IPV4_* actions in OVS stack itself before sending them via DPDK stack for offload.

Thanks,
Rahul

Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 2 lines

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 22 lines

Thanks,
-Jack

Quoted 18 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC,

and

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and

testpmd.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Patch 3 shows CXGBE PMD example to offload these actions to

hardware.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A
%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b7995

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

4b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C63

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

6

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDS

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

H

Quoted 8 lines
Quoted 8 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port
address

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102

+++++++++++++++++++

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127

+++++++++++++++++++++++

Quoted 12 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

--
Adrien Mazarguil
6WIND

#13 lore raw
Quoted 26 lines · Jack Min
Quoted 26 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 10, 2018 21:14
To: Adrien Mazarguil <[email protected]>
Cc: Jack Min <[email protected]>; [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Quoted 11 lines · Adrien Mazarguil
Quoted 10 lines · Rahul Lakkireddy
Quoted 9 lines · Jack Min

Hey Rahul,

Thank you, those two are the ways to achieve that.

Personally I prefer the option 1 but with a little bit difference, something like:

    struct rte_flow_action_of_set_nw_ipv4 {
 	   uint32_t ipv4_addr;
                uint8_t   level;  /* 0 - outer (default), 1 - inner, 2 -255 deeper if

available */

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    };
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

What do you think ?

Looks good. I'll update the API and use the above approach in v2.

Rahul, we have second thought about **level** parameter. We found there are no any *real* user case which really need to modify the inner layer. Do you have any? If no, **level** could be removed in order to keep API clean and simple.

I'm also not aware of any use case to modify inner IP headers. So, will not add 'level' to the API for now, unless anyone else have a use case for modifying inner IP headers.

Quoted 16 lines
Quoted 16 lines
Quoted 10 lines

I still haven't looked at the original proposal (will get there eventually), however keep in mind the presence of "OF" in action names stands for "OpenFlow".

Since you chose this route, these actions must be implemented exactly as defined by the OpenFlow specification, which comprises their name, input parameters and behavior.

For instance there is no support/distinction for IPv6. NW actions must be named OF_SET_NW_SRC and OF_SET_NW_DST, only support IPv4 (a

single

Quoted 3 lines

be32) and not have the ability to tell inner from outer as it's unspecified (note a safe approach would be to interpret this as "outermost" given the tendency of OpenFlow actions to prepend empty headers

and modify them afterward).

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

In short you can't be creative if you want to keep the OF prefix.

Ok, will drop OF prefix for these actions in v2.

How about drop the NW prefix as well? Since we don't want to stick on openflow, NW prefix seems redundant. Names like RTE_FLOW_ACTION_SET_IPV4_SRC is clear enough, isn't it? What do you think?

Agreed. Will drop the NW prefix as well.

Thanks,
Rahul

Quoted 155 lines
Quoted 155 lines
Quoted 7 lines

My suggestion would be to stick with OF if your target use case is OVS and implement these actions exactly as defined by OpenFlow, even if it means limitations due to API (not HW) constraints. Not having to spend time to figure how to map OF actions to rte_flow and handle quirks on both sides should be much more convenient to users, particularly so if these actions bear the same name.

We can translate OF_SET_NW_* actions to RTE_FLOW_ACTION_SET_NW_IPV4_* actions in OVS stack itself before sending them via DPDK stack for offload.

Thanks,
Rahul

Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: July 2, 2018 20:04
To: Jack Min <[email protected]>
Cc: [email protected]; Shagun Agarwal <[email protected]>; Indranil Choudhury <[email protected]>; Nirranjan Kirubaharan <[email protected]>; Shahaf Shuler <[email protected]>; Xueming(Steven) Li <[email protected]>
Subject: Re: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

Hi Jack,

Quoted 6 lines · Jack Min

Hey,

I've one question:

Do those APIs support modify inner IP headers?

I'm afraid not. These API only modify outer IP addresses.

I can think of two ways to achieve this:

1. Enhance these API to accept an additional flag to indicate inner or outer. For example, to set inner IPv4 address, we can set inner to 1 in following structure.

   struct rte_flow_action_of_set_nw_ipv4 {
	   uint32_t inner:1; /* 1 - Inner, 0 - Outer */
	   uint32_t reserved:31;
	   uint32_t ipv4_addr;
   };

2. Add new actions to indicate inner IP addresses; i.e.

RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV4_DST
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_SRC
RTE_FLOW_ACTION_TYPE_OF_SET_INNER_NW_IPV6_DST

Thanks,
Rahul

Quoted 2 lines

In our scenarios, we need to specific that NAT action is on inner or outer IP

header.

Quoted 22 lines

Thanks,
-Jack

Quoted 18 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rahul Lakkireddy
Sent: June 22, 2018 17:56
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC 0/3] ethdev: add IP address and TCP/UDP port rewrite actions to flow API

This series of patches add support for 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.
- OF_SET_TP_SRC - set a new TCP/UDP source port number.
- OF_SET_TP_DST - set a new TCP/UDP destination port number.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

The IP address and TCP/UDP port rewrite actions are based on OFPAT_SET_NW_SRC, OFPAT_SET_NW_DST, OFPAT_SET_TP_SRC,

and

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

OFPAT_SET_TP_DST actions from OpenFlow Specification [1].

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and

testpmd.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Patch 3 shows CXGBE PMD example to offload these actions to

hardware.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

[1]
https://emea01.safelinks.protection.outlook.com/?url=http%3A
%2F%2Fww
w.open
networking.org%2Fimages%2Fopenflow-switch-

v1.5.1.pdf&data=02%7C01%7Cxuemingl%40mellanox.com%7C74c8ce3b7995

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

4b2f

Quoted 1 line
Quoted 1 line

123208d5d8268617%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C1%7C63

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

6

Quoted 1 line
Quoted 1 line

652582334142929&sdata=uoFc1KjVTkGI9fdaPNXvXYRmh%2F6HLMKT79IwgvDS

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

H

Quoted 8 lines
Quoted 8 lines

0k%3D&reserved=0

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port
address

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 app/test-pmd/cmdline_flow.c                 | 150
++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          | 102

+++++++++++++++++++

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  23 ++++-
 drivers/net/cxgbe/cxgbe_filter.h            |  26 ++++-
 drivers/net/cxgbe/cxgbe_flow.c              | 127

+++++++++++++++++++++++

Quoted 12 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  92 +++++++++++++++++
 12 files changed, 625 insertions(+), 4 deletions(-)

--
2.14.1

--
Adrien Mazarguil
6WIND

#14 lore raw

v2 cover ethdev: add IP address and TCP/UDP port rewrite actions to flow API

In reply to Rahul Lakkireddy

This series of patches add support for actions:
- SET_IPV4_SRC - set a new IPv4 source address.
- SET_IPV4_DST - set a new IPv4 destination address.
- SET_IPV6_SRC - set a new IPv6 source address.
- SET_IPV6_DST - set a new IPv6 destination address.
- SET_TP_SRC - set a new TCP/UDP source port number.
- SET_TP_DST - set a new TCP/UDP destination port number.

These actions are useful in Network Address Translation use case to edit IP address and TCP/UDP port numbers before switching the packets out to the destination device port.

Patch 1 adds support for IP address rewrite to rte_flow and testpmd.

Patch 2 adds support for TCP/UDP port rewrite to rte_flow and testpmd.

Patch 3 shows CXGBE PMD example to offload these actions to hardware.

Feedback and suggestions will be much appreciated.

Thanks,
Rahul

---
v2
- Remove OpenFlow prefix.
- Remove Network (NW) prefix from IPv4 and IPv6 rewrite actions.
- Re-based to tip.

Shagun Agrawal (3):
ethdev: add flow api actions to modify IP addresses
ethdev: add flow api actions to modify TCP/UDP port numbers net/cxgbe: add flow actions to modify IP and TCP/UDP port address

 app/test-pmd/cmdline_flow.c                 | 150 ++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |  12 +++
 doc/guides/prog_guide/rte_flow.rst          |  90 +++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  24 +++++
 drivers/net/cxgbe/base/common.h             |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h     |  50 ++++++++++
 drivers/net/cxgbe/cxgbe_filter.c            |  21 +++-
 drivers/net/cxgbe/cxgbe_filter.h            |  23 +++++
 drivers/net/cxgbe/cxgbe_flow.c              | 100 ++++++++++++++++++-
 drivers/net/cxgbe/cxgbe_main.c              |  10 ++
 lib/librte_ethdev/rte_flow.c                |  12 +++
 lib/librte_ethdev/rte_flow.h                |  87 ++++++++++++++++
 12 files changed, 575 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.1
#15 lore raw

RFC v2 1/3 ethdev: add flow api actions to modify IP addresses

From: Shagun Agrawal <[email protected]>

Add actions:
- SET_IPV4_SRC - set a new IPv4 source address.
- SET_IPV4_DST - set a new IPv4 destination address.
- SET_IPV6_SRC - set a new IPv6 source address.
- SET_IPV6_DST - set a new IPv6 destination address.

---
v2:
- Remove OpenFlow prefix from IPv4 and IPv6 rewrite actions.
- Remove Network (NW) prefix from IPv4 and IPv6 rewrite actions.
- Re-based to tip.

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 app/test-pmd/config.c                       |   8 +++
 doc/guides/prog_guide/rte_flow.rst          |  60 +++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 lib/librte_ethdev/rte_flow.c                |   8 +++
 lib/librte_ethdev/rte_flow.h                |  58 ++++++++++++++++
 6 files changed, 250 insertions(+)
app/test-pmd/cmdline_flow.c +100 -0
index f9260600e..fd135da64 100644
@@ -243,6 +243,14 @@ enum index {
 	ACTION_VXLAN_DECAP,
 	ACTION_NVGRE_ENCAP,
 	ACTION_NVGRE_DECAP,
+	ACTION_SET_IPV4_SRC,
+	ACTION_SET_IPV4_SRC_IPV4_SRC,
+	ACTION_SET_IPV4_DST,
+	ACTION_SET_IPV4_DST_IPV4_DST,
+	ACTION_SET_IPV6_SRC,
+	ACTION_SET_IPV6_SRC_IPV6_SRC,
+	ACTION_SET_IPV6_DST,
+	ACTION_SET_IPV6_DST_IPV6_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -816,6 +824,10 @@ static const enum index next_action[] = {
 	ACTION_VXLAN_DECAP,
 	ACTION_NVGRE_ENCAP,
 	ACTION_NVGRE_DECAP,
+	ACTION_SET_IPV4_SRC,
+	ACTION_SET_IPV4_DST,
+	ACTION_SET_IPV6_SRC,
+	ACTION_SET_IPV6_DST,
 	ZERO,
 };
 
@@ -918,6 +930,30 @@ static const enum index action_of_push_mpls[] = {
 	ZERO,
 };
 
+static const enum index action_set_ipv4_src[] = {
+	ACTION_SET_IPV4_SRC_IPV4_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv4_dst[] = {
+	ACTION_SET_IPV4_DST_IPV4_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv6_src[] = {
+	ACTION_SET_IPV6_SRC_IPV6_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_set_ipv6_dst[] = {
+	ACTION_SET_IPV6_DST_IPV6_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_jump[] = {
 	ACTION_JUMP_GROUP,
 	ACTION_NEXT,
@@ -2470,6 +2506,70 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
 		.call = parse_vc,
 	},
+	[ACTION_SET_IPV4_SRC] = {
+		.name = "set_ipv4_src",
+		.help = "set IPv4 source address",
+		.priv = PRIV_ACTION(SET_IPV4_SRC,
+			sizeof(struct rte_flow_action_set_ipv4)),
+		.next = NEXT(action_set_ipv4_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV4_SRC_IPV4_SRC] = {
+		.name = "ipv4_addr",
+		.help = "new IPv4 source address to set",
+		.next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV4_DST] = {
+		.name = "set_ipv4_dst",
+		.help = "set IPv4 destination address",
+		.priv = PRIV_ACTION(SET_IPV4_DST,
+			sizeof(struct rte_flow_action_set_ipv4)),
+		.next = NEXT(action_set_ipv4_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV4_DST_IPV4_DST] = {
+		.name = "ipv4_addr",
+		.help = "new IPv4 destination address to set",
+		.next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv4, ipv4_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV6_SRC] = {
+		.name = "set_ipv6_src",
+		.help = "set IPv6 source address",
+		.priv = PRIV_ACTION(SET_IPV6_SRC,
+			sizeof(struct rte_flow_action_set_ipv6)),
+		.next = NEXT(action_set_ipv6_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV6_SRC_IPV6_SRC] = {
+		.name = "ipv6_addr",
+		.help = "new IPv6 source address to set",
+		.next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv6, ipv6_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_IPV6_DST] = {
+		.name = "set_ipv6_dst",
+		.help = "set IPv6 destination address",
+		.priv = PRIV_ACTION(SET_IPV6_DST,
+			sizeof(struct rte_flow_action_set_ipv6)),
+		.next = NEXT(action_set_ipv6_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_IPV6_DST_IPV6_DST] = {
+		.name = "ipv6_addr",
+		.help = "new IPv6 destination address to set",
+		.next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_set_ipv6, ipv6_addr)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
app/test-pmd/config.c +8 -0
index 14ccd6864..401b066b3 100644
@@ -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(SET_IPV4_SRC,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV4_DST,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV6_SRC,
+		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_IPV6_DST,
+		       sizeof(struct rte_flow_action_set_ipv6)),
 };
 
 /** Compute storage space needed by action configuration and copy it. */
doc/guides/prog_guide/rte_flow.rst +60 -0

66 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +16 -0
index dde205a2b..638331c17 100644
@@ -3697,6 +3697,22 @@ This section lists supported actions and their attributes, if any.
 - ``nvgre_decap``: Performs a decapsulation action by stripping all headers of
   the NVGRE tunnel network overlay from the matched flow.
 
+- ``set_ipv4_src``: Set a new IPv4 source address.
+
+  - ``ipv4_addr``: New IPv4 source address.
+
+- ``set_ipv4_dst``: Set a new IPv4 destination address.
+
+  - ``ipv4_addr``: New IPv4 destination address.
+
+- ``set_ipv6_src``: Set a new IPv6 source address.
+
+  - ``ipv6_addr``: New IPv6 source address.
+
+- ``set_ipv6_dst``: Set a new IPv6 destination address.
+
+  - ``ipv6_addr``: New IPv6 destination address.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/librte_ethdev/rte_flow.c +8 -0
index cff4b5209..d4f1b9a05 100644
@@ -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(SET_IPV4_SRC,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV4_DST,
+		       sizeof(struct rte_flow_action_set_ipv4)),
+	MK_FLOW_ACTION(SET_IPV6_SRC,
+		       sizeof(struct rte_flow_action_set_ipv6)),
+	MK_FLOW_ACTION(SET_IPV6_DST,
+		       sizeof(struct rte_flow_action_set_ipv6)),
 };
 
 static int
lib/librte_ethdev/rte_flow.h +58 -0

70 lines not on this page · raw message

Signature · 1 line
2.14.1
#16 lore raw

Re: [RFC v2 1/3] ethdev: add flow api actions to modify IP addresses

Quoted 29 lines

static int

lib/librte_ethdev/rte_flow.h +19 -0
index f8ba71cdb..48c3c606e 100644
@@ -1505,6 +1505,34 @@ enum rte_flow_action_type {
 	 * error.
 	 */
 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+	/**
+	 * Modify IPv4 source address
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
+
+	/**
+	 * Modify IPv4 destination address
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
+
+	/**
+	 * Modify IPv6 source address
+	 *
+	 * See struct rte_flow_action_set_ipv6.

lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 1536

Quoted 10 lines
lib/librte_ethdev/rte_flow.h +9 -0
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
+
+	/**
+	 * Modify IPv6 destination address
+	 *
+	 * See struct rte_flow_action_set_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
 };

Hey Rahul,

Sorry for the late response. Just a small comment:

We would need the corresponding RTE_FLOW_ITEM_TYPE_* specified in pattern. i.e RTE_FLOW_ITEM_TYPE_IPV6 must be in pattern for action RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC otherwise RTE_FLOW_ERROR_TYPE_ACTION return.
Would be better to document this in comments and __rte_flow.rst__

What do you think?

-Jack

#17 lore raw

Re: [RFC v2 1/3] ethdev: add flow api actions to modify IP addresses

Quoted 41 lines · Xiaoyu Min
Quoted 29 lines

static int

lib/librte_ethdev/rte_flow.h +19 -0
index f8ba71cdb..48c3c606e 100644
@@ -1505,6 +1505,34 @@ enum rte_flow_action_type {
 	 * error.
 	 */
 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+	/**
+	 * Modify IPv4 source address
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
+
+	/**
+	 * Modify IPv4 destination address
+	 *
+	 * See struct rte_flow_action_set_ipv4.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
+
+	/**
+	 * Modify IPv6 source address
+	 *
+	 * See struct rte_flow_action_set_ipv6.

lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 1536

Quoted 10 lines
lib/librte_ethdev/rte_flow.h +9 -0
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
+
+	/**
+	 * Modify IPv6 destination address
+	 *
+	 * See struct rte_flow_action_set_ipv6.
+	 */
+	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
 };

Hey Rahul,

Quoted 9 lines

Sorry for the late response. Just a small comment:

We would need the corresponding RTE_FLOW_ITEM_TYPE_* specified in pattern. i.e RTE_FLOW_ITEM_TYPE_IPV6 must be in pattern for action RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC otherwise RTE_FLOW_ERROR_TYPE_ACTION return.
Would be better to document this in comments and __rte_flow.rst__

What do you think?

Ok. Will update the comment and doc.

Thanks,
Rahul

#18 lore raw

RFC v2 2/3 ethdev: add flow api actions to modify TCP/UDP port numbers

In reply to Rahul Lakkireddy

From: Shagun Agrawal <[email protected]>

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

---
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(+)
app/test-pmd/cmdline_flow.c +50 -0
index fd135da64..3935539cb 100644
@@ -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. */
app/test-pmd/config.c +4 -0
index 401b066b3..70dd52254 100644
@@ -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. */
doc/guides/prog_guide/rte_flow.rst +30 -0
index 8f3dcc6c1..4faf8cb40 100644
@@ -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
 ~~~~~~~~~~~~~~
 
doc/guides/testpmd_app_ug/testpmd_funcs.rst +8 -0
index 638331c17..f60be0862 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~
 
lib/librte_ethdev/rte_flow.c +4 -0
index d4f1b9a05..409c79741 100644
@@ -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
lib/librte_ethdev/rte_flow.h +29 -0
index 48c3c606e..c80771b25 100644
@@ -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.
  *
Signature · 1 line
2.14.1
#19 lore raw

Re: [RFC v2 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers

Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 638331c17..f60be0862 100644
@@ -3713,6 +3713,14 @@ This section lists supported actions and their

attributes, if any.

Quoted 3 lines

- ``ipv6_addr``: New IPv6 destination address.

+- ``of_set_tp_src``: Set a new TCP/UDP source port number.

should be set_tp_src :-)

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their attributes, if any. · line 3720

Quoted 4 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
+
+  - ``port``: New TCP/UDP source port number.
+
+- ``of_set_tp_dst``: Set a new TCP/UDP destination port number.

set_tp_dst

Quoted 22 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
+  - ``port``: New TCP/UDP destination port number.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
 
 
 static int
lib/librte_ethdev/rte_flow.h +6 -0
index 48c3c606e..c80771b25 100644
@@ -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.
+        */

lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 1551

Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8 -0
+       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,
 };
 

We need to state the corresponding RTE_FLOW_ITEM_TYPE_(UDP|TCP) should be in pattern

-Jack

#20 lore raw

Re: [RFC v2 2/3] ethdev: add flow api actions to modify TCP/UDP port numbers

Quoted 43 lines · Xiaoyu Min
Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 638331c17..f60be0862 100644
@@ -3713,6 +3713,14 @@ This section lists supported actions and their

attributes, if any.

Quoted 3 lines

- ``ipv6_addr``: New IPv6 destination address.

+- ``of_set_tp_src``: Set a new TCP/UDP source port number.

should be set_tp_src :-)

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their attributes, if any. · line 3720

Quoted 4 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
+
+  - ``port``: New TCP/UDP source port number.
+
+- ``of_set_tp_dst``: Set a new TCP/UDP destination port number.

set_tp_dst

Quoted 25 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
+  - ``port``: New TCP/UDP destination port number.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
 
 
 static int
lib/librte_ethdev/rte_flow.h +9 -0
index 48c3c606e..c80771b25 100644
@@ -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,
+
+       /**
Quoted 9 lines

lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 1551

Quoted 7 lines
lib/librte_ethdev/rte_flow.h +5 -0
+        * Modify destination port in TCP/UDP packets.
+        *
+        * See struct rte_flow_action_set_tp.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_TP_DST,
 };
 

We need to state the corresponding RTE_FLOW_ITEM_TYPE_(UDP|TCP) should be in pattern

Ok. Will update the comment and doc.

Thanks,
Rahul

#21 lore raw

RFC v2 3/3 net/cxgbe: add flow actions to modify IP and TCP/UDP port address

In reply to Rahul Lakkireddy

From: Shagun Agrawal <[email protected]>

Query firmware for the new filter work request to offload flows with actions to modify IP and TCP/UDP port addresses. When available, translate IP and TCP/UDP port address modify actions to internal hardware specification and offload the flow to hardware.

---
v2:
- Re-based to tip.

 drivers/net/cxgbe/base/common.h         |   1 +
 drivers/net/cxgbe/base/t4fw_interface.h |  50 ++++++++++++++++
 drivers/net/cxgbe/cxgbe_filter.c        |  21 ++++++-
 drivers/net/cxgbe/cxgbe_filter.h        |  23 ++++++++
 drivers/net/cxgbe/cxgbe_flow.c          | 100 +++++++++++++++++++++++++++++++-
 drivers/net/cxgbe/cxgbe_main.c          |  10 ++++
 6 files changed, 200 insertions(+), 5 deletions(-)
drivers/net/cxgbe/base/common.h +1 -0
index 157201da2..bbd915f29 100644
@@ -270,6 +270,7 @@ struct adapter_params {
 
 	bool ulptx_memwrite_dsgl;          /* use of T5 DSGL allowed */
 	u8 fw_caps_support;		  /* 32-bit Port Capabilities */
+	bool filter2_wr_support;	/* FW support for FILTER2_WR */
 };
 
 /* Firmware Port Capabilities types.
drivers/net/cxgbe/base/t4fw_interface.h +50 -0

74 lines not on this page · raw message

drivers/net/cxgbe/cxgbe_filter.c +18 -3
index 7f0d38001..deae1c37b 100644
@@ -87,6 +87,9 @@ int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs)
 	if (fs->val.iport >= adapter->params.nports)
 		return -ERANGE;
 
+	if (!fs->cap && fs->nat_mode && !adapter->params.filter2_wr_support)
+		return -EOPNOTSUPP;
+
 	return 0;
 }
 
@@ -648,7 +651,7 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	struct adapter *adapter = ethdev2adap(dev);
 	struct filter_entry *f = &adapter->tids.ftid_tab[fidx];
 	struct rte_mbuf *mbuf;
-	struct fw_filter_wr *fwr;
+	struct fw_filter2_wr *fwr;
 	struct sge_ctrl_txq *ctrlq;
 	unsigned int port_id = ethdev2pinfo(dev)->port_id;
 	int ret;
@@ -663,13 +666,16 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	mbuf->data_len = sizeof(*fwr);
 	mbuf->pkt_len = mbuf->data_len;
 
-	fwr = rte_pktmbuf_mtod(mbuf, struct fw_filter_wr *);
+	fwr = rte_pktmbuf_mtod(mbuf, struct fw_filter2_wr *);
 	memset(fwr, 0, sizeof(*fwr));
 
 	/*
 	 * Construct the work request to set the filter.
 	 */
-	fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER_WR));
+	if (adapter->params.filter2_wr_support)
+		fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER2_WR));
+	else
+		fwr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER_WR));
 	fwr->len16_pkd = cpu_to_be32(V_FW_WR_LEN16(sizeof(*fwr) / 16));
 	fwr->tid_to_iq =
 		cpu_to_be32(V_FW_FILTER_WR_TID(f->tid) |
@@ -704,6 +710,15 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	fwr->fp = cpu_to_be16(f->fs.val.fport);
 	fwr->fpm = cpu_to_be16(f->fs.mask.fport);
 
+	if (adapter->params.filter2_wr_support && f->fs.nat_mode) {
+		fwr->natmode_to_ulp_type =
+			V_FW_FILTER2_WR_NATMODE(f->fs.nat_mode);
+		memcpy(fwr->newlip, f->fs.nat_lip, sizeof(fwr->newlip));
+		memcpy(fwr->newfip, f->fs.nat_fip, sizeof(fwr->newfip));
+		fwr->newlport = cpu_to_be16(f->fs.nat_lport);
+		fwr->newfport = cpu_to_be16(f->fs.nat_fport);
+	}
+
 	/*
 	 * Mark the filter as "pending" and ship off the Filter Work Request.
 	 * When we get the Work Request Reply we'll clear the pending status.
drivers/net/cxgbe/cxgbe_filter.h +23 -0
index af8fa7529..c85fa6d2c 100644
@@ -100,6 +100,18 @@ struct ch_filter_specification {
 
 	uint32_t eport:2;	/* egress port to switch packet out */
 
+	/*
+	 * Switch proxy/rewrite fields.  An ingress packet which matches a
+	 * filter with "switch" set will be looped back out as an egress
+	 * packet -- potentially with some Ethernet header rewriting.
+	 */
+	uint32_t nat_mode:3;	/* specify NAT operation mode */
+
+	uint8_t nat_lip[16];	/* local IP to use after NAT'ing */
+	uint8_t nat_fip[16];	/* foreign IP to use after NAT'ing */
+	uint16_t nat_lport;	/* local port to use after NAT'ing */
+	uint16_t nat_fport;	/* foreign port to use after NAT'ing */
+
 	/* Filter rule value/mask pairs. */
 	struct ch_filter_tuple val;
 	struct ch_filter_tuple mask;
@@ -111,6 +123,17 @@ enum {
 	FILTER_SWITCH
 };
 
+enum {
+	NAT_MODE_NONE = 0,	/* No NAT performed */
+	NAT_MODE_DIP,		/* NAT on Dst IP */
+	NAT_MODE_DIP_DP,	/* NAT on Dst IP, Dst Port */
+	NAT_MODE_DIP_DP_SIP,	/* NAT on Dst IP, Dst Port and Src IP */
+	NAT_MODE_DIP_DP_SP,	/* NAT on Dst IP, Dst Port and Src Port */
+	NAT_MODE_SIP_SP,	/* NAT on Src IP and Src Port */
+	NAT_MODE_DIP_SIP_SP,	/* NAT on Dst IP, Src IP and Src Port */
+	NAT_MODE_ALL		/* NAT on entire 4-tuple */
+};
+
 enum filter_type {
 	FILTER_TYPE_IPV4 = 0,
 	FILTER_TYPE_IPV6,
drivers/net/cxgbe/cxgbe_flow.c +98 -2

140 lines not on this page · raw message

drivers/net/cxgbe/cxgbe_main.c +10 -0
index c3938e8db..4aeb3e074 100644
@@ -1170,6 +1170,16 @@ static int adap_init0(struct adapter *adap)
 			goto bye;
 	}
 
+	/* See if FW supports FW_FILTER2 work request */
+	if (is_t4(adap->params.chip)) {
+		adap->params.filter2_wr_support = 0;
+	} else {
+		params[0] = FW_PARAM_DEV(FILTER2_WR);
+		ret = t4_query_params(adap, adap->mbox, adap->pf, 0,
+				      1, params, val);
+		adap->params.filter2_wr_support = (ret == 0 && val[0] != 0);
+	}
+
 	/* query tid-related parameters */
 	params[0] = FW_PARAM_DEV(NTID);
 	ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1,
Signature · 1 line
2.14.1