DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] add actions to modify header fields
@ 2019-03-21 14:18 Dekel Peled
  2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
                   ` (8 more replies)
  0 siblings, 9 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-21 14:18 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Patch [1] implemented set of header modification actions in MLX PMD,
based on ethdev and testpmd updates included in [2].

This series implements support of additional header modification
actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  72 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   8 +
 lib/librte_ethdev/rte_flow.h                |  60 +++++++
 8 files changed, 516 insertions(+), 1 deletion(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH 1/3] ethdev: add actions to modify TCP header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
@ 2019-03-21 14:18 ` " Dekel Peled
  2019-03-26  9:24   ` Dekel Peled
  2019-03-29 13:58   ` Adrien Mazarguil
  2019-03-21 14:18 ` [PATCH 2/3] app/testpmd: " Dekel Peled
                   ` (7 subsequent siblings)
  8 siblings, 2 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-21 14:18 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  8 +++++
 lib/librte_ethdev/rte_flow.h       | 60 +++++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 0203f4f..bdb817a 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +-----------+--------------------------------------------+
+   | Field     | Value                                      |
+   +===========+============================================+
+   | ``value`` | Value to increase TCP sequence number by   |
+   +-----------+--------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +-----------+--------------------------------------------+
+   | Field     | Value                                      |
+   +===========+============================================+
+   | ``value`` | Value to decrease TCP sequence number by   |
+   +-----------+--------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +-----------+--------------------------------------------------+
+   | Field     | Value                                            |
+   +===========+==================================================+
+   | ``value`` | Value to increase TCP acknowledgment number by   |
+   +-----------+--------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
+Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +-----------+--------------------------------------------------+
+   | Field     | Value                                            |
+   +===========+==================================================+
+   | ``value`` | Value to decrease TCP acknowledgment number by   |
+   +-----------+--------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..589d0b9 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,14 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+	MK_FLOW_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+	MK_FLOW_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index c0fe879..74cd03e 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
+	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_modify_tcp_seq
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
+	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_modify_tcp_seq
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
+	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_modify_tcp_ack
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
+	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+	 *
+	 * See struct rte_flow_action_modify_tcp_ack
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2122,6 +2162,26 @@ struct rte_flow_action_set_mac {
 	uint8_t mac_addr[ETHER_ADDR_LEN];
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
+ * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
+ *
+ * Increase/Decrease outermost TCP's sequence number
+ */
+struct rte_flow_action_modify_tcp_seq {
+	rte_be32_t value;
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
+ * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
+ *
+ * Increase/Decrease TCP's acknowledgment number.
+ */
+struct rte_flow_action_modify_tcp_ack {
+	rte_be32_t value;
+};
+
 /*
  * Definition of a single action.
  *
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH 2/3] app/testpmd: add actions to modify TCP header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
  2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-03-21 14:18 ` " Dekel Peled
  2019-03-29 13:58   ` Adrien Mazarguil
  2019-03-21 14:18 ` [PATCH 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-03-21 14:18 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 36659a6..5cd4ceb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -271,6 +271,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -884,6 +892,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1046,6 +1058,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 1a12da4..c6f8b2c 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3961,6 +3961,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH 3/3] net/mlx5: update modify header using Direct Verbs
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
  2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-03-21 14:18 ` [PATCH 2/3] app/testpmd: " Dekel Peled
@ 2019-03-21 14:18 ` Dekel Peled
  2019-04-02 15:13 ` [PATCH v2 0/3] add actions to modify header fields Dekel Peled
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-21 14:18 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index e1e798b..c49e245 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -113,6 +113,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -134,7 +138,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ebcdd15..7324e33 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_action_modify_tcp_seq *conf =
+		(const struct rte_flow_action_modify_tcp_seq *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->value);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_action_modify_tcp_ack *conf =
+		(const struct rte_flow_action_modify_tcp_ack *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->value);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] = {
 						MLX5_FLOW_ACTION_SET_TTL :
 						MLX5_FLOW_ACTION_DEC_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3066,6 +3284,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index da1219e..d5c5d3c 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 1/3] ethdev: add actions to modify TCP header fields
  2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-03-26  9:24   ` Dekel Peled
  2019-03-29 13:58   ` Adrien Mazarguil
  1 sibling, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-26  9:24 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: dev, Ori Kam, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Shahaf Shuler, Yongseok Koh, Olga Shern

Hi Adrien, 

Can you please review?
I'll appreciate receiving any comments soon.

Thanks,
Dekel

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Thursday, March 21, 2019 4:19 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [PATCH 1/3] ethdev: add actions to modify TCP header fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst | 72
> ++++++++++++++++++++++++++++++++++++++
>  lib/librte_ethdev/rte_flow.c       |  8 +++++
>  lib/librte_ethdev/rte_flow.h       | 60
> +++++++++++++++++++++++++++++++
>  3 files changed, 140 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/rte_flow.rst
> b/doc/guides/prog_guide/rte_flow.rst
> index 0203f4f..bdb817a 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> error will be returned.
>     | ``mac_addr`` | MAC address   |
>     +--------------+---------------+
> 
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_inc_tcp_seq:
> +
> +.. table:: INC_TCP_SEQ
> +
> +   +-----------+--------------------------------------------+
> +   | Field     | Value                                      |
> +
> +===========+============================================+
> +   | ``value`` | Value to increase TCP sequence number by   |
> +   +-----------+--------------------------------------------+
> +
> +Action: ``DEC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease sequence number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_dec_tcp_seq:
> +
> +.. table:: DEC_TCP_SEQ
> +
> +   +-----------+--------------------------------------------+
> +   | Field     | Value                                      |
> +
> +===========+============================================+
> +   | ``value`` | Value to decrease TCP sequence number by   |
> +   +-----------+--------------------------------------------+
> +
> +Action: ``INC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase acknowledgment number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_inc_tcp_ack:
> +
> +.. table:: INC_TCP_ACK
> +
> +   +-----------+--------------------------------------------------+
> +   | Field     | Value                                            |
> +
> +===========+=============================================
> =====+
> +   | ``value`` | Value to increase TCP acknowledgment number by   |
> +   +-----------+--------------------------------------------------+
> +
> +Action: ``DEC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease acknowledgment number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> +
> +.. _table_rte_flow_action_dec_tcp_ack:
> +
> +.. table:: DEC_TCP_ACK
> +
> +   +-----------+--------------------------------------------------+
> +   | Field     | Value                                            |
> +
> +===========+=============================================
> =====+
> +   | ``value`` | Value to decrease TCP acknowledgment number by   |
> +   +-----------+--------------------------------------------------+
> +
>  Negative types
>  ~~~~~~~~~~~~~~
> 
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index
> 3277be1..589d0b9 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -143,6 +143,14 @@ struct rte_flow_desc_data {
>  	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
>  	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> rte_flow_action_set_mac)),
>  	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> rte_flow_action_set_mac)),
> +	MK_FLOW_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +	MK_FLOW_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
>  };
> 
>  static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index
> c0fe879..74cd03e 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_set_mac.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> +
> +	/**
> +	 * Decrease sequence number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> +
> +	/**
> +	 * Increase acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> +
> +	/**
> +	 * Decrease acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
>  };
> 
>  /**
> @@ -2122,6 +2162,26 @@ struct rte_flow_action_set_mac {
>  	uint8_t mac_addr[ETHER_ADDR_LEN];
>  };
> 
> +/**
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> + *
> + * Increase/Decrease outermost TCP's sequence number  */ struct
> +rte_flow_action_modify_tcp_seq {
> +	rte_be32_t value;
> +};
> +
> +/**
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> + *
> + * Increase/Decrease TCP's acknowledgment number.
> + */
> +struct rte_flow_action_modify_tcp_ack {
> +	rte_be32_t value;
> +};
> +
>  /*
>   * Definition of a single action.
>   *
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 1/3] ethdev: add actions to modify TCP header fields
  2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-03-26  9:24   ` Dekel Peled
@ 2019-03-29 13:58   ` Adrien Mazarguil
  2019-03-31 13:09     ` Dekel Peled
  1 sibling, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-03-29 13:58 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs, dev, orika

Hi Derek,

It's been a while since I last reviewed something, sorry it took so long.
Some comments below.

On Thu, Mar 21, 2019 at 04:18:35PM +0200, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.

Out of curiosity, are these upcoming/existing OpenFlow actions? If so you
should consider prefixing them with "OF_", otherwise leave them as is.

> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++++++++++++++++++++++
>  lib/librte_ethdev/rte_flow.c       |  8 +++++
>  lib/librte_ethdev/rte_flow.h       | 60 +++++++++++++++++++++++++++++++
>  3 files changed, 140 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index 0203f4f..bdb817a 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
>     | ``mac_addr`` | MAC address   |
>     +--------------+---------------+
>  
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.

I know this is already present for various SET* actions, but please do not
tie actions to the presence of specific pattern items at the API level. You
can describe that the lack of a TCP header in matched *traffic* results in
unspecified behavior though.

Then PMD documentation can describe that the lack of a TCP pattern item with
this action results in RTE_FLOW_ERROR_TYPE_ACTION as a PMD-specific
constraint.

> +
> +.. _table_rte_flow_action_inc_tcp_seq:
> +
> +.. table:: INC_TCP_SEQ
> +
> +   +-----------+--------------------------------------------+
> +   | Field     | Value                                      |
> +   +===========+============================================+
> +   | ``value`` | Value to increase TCP sequence number by   |
> +   +-----------+--------------------------------------------+

Nit: unnecessary empty space after "by".

> +
> +Action: ``DEC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease sequence number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.

Same comment as above.

> +
> +.. _table_rte_flow_action_dec_tcp_seq:
> +
> +.. table:: DEC_TCP_SEQ
> +
> +   +-----------+--------------------------------------------+
> +   | Field     | Value                                      |
> +   +===========+============================================+
> +   | ``value`` | Value to decrease TCP sequence number by   |
> +   +-----------+--------------------------------------------+
> +
> +Action: ``INC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase acknowledgment number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.

Ditto.

> +
> +.. _table_rte_flow_action_inc_tcp_ack:
> +
> +.. table:: INC_TCP_ACK
> +
> +   +-----------+--------------------------------------------------+
> +   | Field     | Value                                            |
> +   +===========+==================================================+
> +   | ``value`` | Value to increase TCP acknowledgment number by   |
> +   +-----------+--------------------------------------------------+
> +
> +Action: ``DEC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease acknowledgment number in the outermost TCP header.
> +
> +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item.
> +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.

Ditto.

> +
> +.. _table_rte_flow_action_dec_tcp_ack:
> +
> +.. table:: DEC_TCP_ACK
> +
> +   +-----------+--------------------------------------------------+
> +   | Field     | Value                                            |
> +   +===========+==================================================+
> +   | ``value`` | Value to decrease TCP acknowledgment number by   |
> +   +-----------+--------------------------------------------------+
> +
>  Negative types
>  ~~~~~~~~~~~~~~
>  
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
> index 3277be1..589d0b9 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -143,6 +143,14 @@ struct rte_flow_desc_data {
>  	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
>  	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
>  	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
> +	MK_FLOW_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +	MK_FLOW_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
>  };
>  
>  static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index c0fe879..74cd03e 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_set_mac.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.

Ditto.

> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> +
> +	/**
> +	 * Decrease sequence number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.

Ditto.

> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> +
> +	/**
> +	 * Increase acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *

Ditto.

> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> +
> +	/**
> +	 * Decrease acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP,
> +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> +	 *

Ditto.

> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
>  };
>  
>  /**
> @@ -2122,6 +2162,26 @@ struct rte_flow_action_set_mac {
>  	uint8_t mac_addr[ETHER_ADDR_LEN];
>  };
>  
> +/**

Experimental tag is missing.

> + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> + *
> + * Increase/Decrease outermost TCP's sequence number

Suggestion:

 Increase/decrease outermost TCP sequence number.

> + */
> +struct rte_flow_action_modify_tcp_seq {
> +	rte_be32_t value;

Field documentation is mandatory, e.g.:

 rte_be32_t value; /**< Value to add/subtract. */

Beside, I'm not sure this value should be big endian since it's not stored
as is in the TCP header; it's used by the host system to compute a new
value.

Also what about having another field to specify what needs to be done with
this value (e.g. add/sub/set - in which case big endian makes sense) to
reduce the number of new actions? Something like:

 struct rte_flow_action_mod_tcp_seq {
     enum rte_flow_action_mod_tcp_seq_op {
         RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_ADD,
         RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_SUB,
         RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_SET,
     } op; /**< Operation to perform. */
     rte_be32_t value; /**< Value to use with operation. */
 };

> +};
> +
> +/**

Experimental tag also missing.

> + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> + *
> + * Increase/Decrease TCP's acknowledgment number.

Suggestion:

 Increase/decrease outermost TCP acknowledgment number.

> + */
> +struct rte_flow_action_modify_tcp_ack {
> +	rte_be32_t value;

Field documentation also missing.

> +};
> +
>  /*
>   * Definition of a single action.
>   *
> -- 
> 1.8.3.1
> 

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 2/3] app/testpmd: add actions to modify TCP header fields
  2019-03-21 14:18 ` [PATCH 2/3] app/testpmd: " Dekel Peled
@ 2019-03-29 13:58   ` Adrien Mazarguil
  2019-03-31 13:10     ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-03-29 13:58 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs, dev, orika

On Thu, Mar 21, 2019 at 04:18:36PM +0200, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
>                 header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
>                 header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>

I suggest to merge this patch into the previous one. No reason for testpmd
to be updated separately.

Some comments below.

> ---
>  app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 36659a6..5cd4ceb 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -271,6 +271,14 @@ enum index {
>  	ACTION_SET_MAC_SRC_MAC_SRC,
>  	ACTION_SET_MAC_DST,
>  	ACTION_SET_MAC_DST_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_DEC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK_VALUE,
>  };
>  
>  /** Maximum size for pattern in struct rte_flow_item_raw. */
> @@ -884,6 +892,10 @@ struct parse_action_priv {
>  	ACTION_SET_TTL,
>  	ACTION_SET_MAC_SRC,
>  	ACTION_SET_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK,
>  	ZERO,
>  };
>  
> @@ -1046,6 +1058,30 @@ struct parse_action_priv {
>  	ZERO,
>  };
>  
> +static const enum index action_inc_tcp_seq[] = {
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_seq[] = {
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_inc_tcp_ack[] = {
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_ack[] = {
> +	ACTION_DEC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static int parse_init(struct context *, const struct token *,
>  		      const char *, unsigned int,
>  		      void *, unsigned int);
> @@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
>  			     (struct rte_flow_action_set_mac, mac_addr)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_INC_TCP_SEQ] = {
> +		.name = "inc_tcp_seq",
> +		.help = "increase TCP sequence number",
> +		.priv = PRIV_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_inc_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP sequence number by",
> +		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),

You may need to remove HTON here depending on the chosen endian for the
API, see my comments on previous patch.

> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_SEQ] = {
> +		.name = "dec_tcp_seq",
> +		.help = "decrease TCP sequence number",
> +		.priv = PRIV_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_dec_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP sequence number by",
> +		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),

Same here.

> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_INC_TCP_ACK] = {
> +		.name = "inc_tcp_ack",
> +		.help = "increase TCP acknowledgment number",
> +		.priv = PRIV_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_inc_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP acknowledgment number by",
> +		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),

Ditto.

> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_ACK] = {
> +		.name = "dec_tcp_ack",
> +		.help = "decrease TCP acknowledgment number",
> +		.priv = PRIV_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_dec_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP acknowledgment number by",
> +		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),

Ditto.

> +		.call = parse_vc_conf,
> +	},
>  };
>  
>  /** Remove and return last entry from argument stack. */
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 1a12da4..c6f8b2c 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3961,6 +3961,22 @@ This section lists supported actions and their attributes, if any.
>  
>    - ``mac_addr {MAC-48}``: new destination MAC address
>  
> +- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header
> +
> +  - ``value {unsigned}``: Value to increase TCP sequence number by
> +
> +- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header
> +
> +  - ``value {unsigned}``: Value to decrease TCP sequence number by
> +
> +- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header
> +
> +  - ``value {unsigned}``: Value to increase TCP acknowledgment number by
> +
> +- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header
> +
> +  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by

Please add missing "." to each line.

> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
>  
> -- 
> 1.8.3.1
> 

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 1/3] ethdev: add actions to modify TCP header fields
  2019-03-29 13:58   ` Adrien Mazarguil
@ 2019-03-31 13:09     ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-31 13:09 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Friday, March 29, 2019 4:59 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [PATCH 1/3] ethdev: add actions to modify TCP header fields
> 
> Hi Derek,

It's Dekel, not Derek.

> 
> It's been a while since I last reviewed something, sorry it took so long.
> Some comments below.
> 
> On Thu, Mar 21, 2019 at 04:18:35PM +0200, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> 
> Out of curiosity, are these upcoming/existing OpenFlow actions? If so you
> should consider prefixing them with "OF_", otherwise leave them as is.

Not related to OpenFlow.

> 
> > Original work by Xiaoyu Min.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > ---
> >  doc/guides/prog_guide/rte_flow.rst | 72
> ++++++++++++++++++++++++++++++++++++++
> >  lib/librte_ethdev/rte_flow.c       |  8 +++++
> >  lib/librte_ethdev/rte_flow.h       | 60
> +++++++++++++++++++++++++++++++
> >  3 files changed, 140 insertions(+)
> >
> > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > b/doc/guides/prog_guide/rte_flow.rst
> > index 0203f4f..bdb817a 100644
> > --- a/doc/guides/prog_guide/rte_flow.rst
> > +++ b/doc/guides/prog_guide/rte_flow.rst
> > @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> error will be returned.
> >     | ``mac_addr`` | MAC address   |
> >     +--------------+---------------+
> >
> > +Action: ``INC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase sequence number in the outermost TCP header.
> > +
> > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item.
> > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> 
> I know this is already present for various SET* actions, but please do not tie
> actions to the presence of specific pattern items at the API level. You can
> describe that the lack of a TCP header in matched *traffic* results in
> unspecified behavior though.

I accept, will change it in all relevant locations.

> 
> Then PMD documentation can describe that the lack of a TCP pattern item
> with this action results in RTE_FLOW_ERROR_TYPE_ACTION as a PMD-specific
> constraint.
> 
> > +
> > +.. _table_rte_flow_action_inc_tcp_seq:
> > +
> > +.. table:: INC_TCP_SEQ
> > +
> > +   +-----------+--------------------------------------------+
> > +   | Field     | Value                                      |
> > +
> +===========+============================================+
> > +   | ``value`` | Value to increase TCP sequence number by   |
> > +   +-----------+--------------------------------------------+
> 
> Nit: unnecessary empty space after "by".

Will remove.

> 
> > +
> > +Action: ``DEC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Decrease sequence number in the outermost TCP header.
> > +
> > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item.
> > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> 
> Same comment as above.
> 
> > +
> > +.. _table_rte_flow_action_dec_tcp_seq:
> > +
> > +.. table:: DEC_TCP_SEQ
> > +
> > +   +-----------+--------------------------------------------+
> > +   | Field     | Value                                      |
> > +
> +===========+============================================+
> > +   | ``value`` | Value to decrease TCP sequence number by   |
> > +   +-----------+--------------------------------------------+
> > +
> > +Action: ``INC_TCP_ACK``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase acknowledgment number in the outermost TCP header.
> > +
> > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item.
> > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> 
> Ditto.
> 
> > +
> > +.. _table_rte_flow_action_inc_tcp_ack:
> > +
> > +.. table:: INC_TCP_ACK
> > +
> > +   +-----------+--------------------------------------------------+
> > +   | Field     | Value                                            |
> > +
> +===========+=============================================
> =====+
> > +   | ``value`` | Value to increase TCP acknowledgment number by   |
> > +   +-----------+--------------------------------------------------+
> > +
> > +Action: ``DEC_TCP_ACK``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Decrease acknowledgment number in the outermost TCP header.
> > +
> > +It must be used with a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item.
> > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
> 
> Ditto.
> 
> > +
> > +.. _table_rte_flow_action_dec_tcp_ack:
> > +
> > +.. table:: DEC_TCP_ACK
> > +
> > +   +-----------+--------------------------------------------------+
> > +   | Field     | Value                                            |
> > +
> +===========+=============================================
> =====+
> > +   | ``value`` | Value to decrease TCP acknowledgment number by   |
> > +   +-----------+--------------------------------------------------+
> > +
> >  Negative types
> >  ~~~~~~~~~~~~~~
> >
> > diff --git a/lib/librte_ethdev/rte_flow.c
> > b/lib/librte_ethdev/rte_flow.c index 3277be1..589d0b9 100644
> > --- a/lib/librte_ethdev/rte_flow.c
> > +++ b/lib/librte_ethdev/rte_flow.c
> > @@ -143,6 +143,14 @@ struct rte_flow_desc_data {
> >  	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
> >  	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> rte_flow_action_set_mac)),
> >  	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> rte_flow_action_set_mac)),
> > +	MK_FLOW_ACTION(INC_TCP_SEQ,
> > +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> > +	MK_FLOW_ACTION(DEC_TCP_SEQ,
> > +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> > +	MK_FLOW_ACTION(INC_TCP_ACK,
> > +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> > +	MK_FLOW_ACTION(DEC_TCP_ACK,
> > +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> >  };
> >
> >  static int
> > diff --git a/lib/librte_ethdev/rte_flow.h
> > b/lib/librte_ethdev/rte_flow.h index c0fe879..74cd03e 100644
> > --- a/lib/librte_ethdev/rte_flow.h
> > +++ b/lib/librte_ethdev/rte_flow.h
> > @@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
> >  	 * See struct rte_flow_action_set_mac.
> >  	 */
> >  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > +
> > +	/**
> > +	 * Increase sequence number in the outermost TCP header.
> > +	 *
> > +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> > +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> 
> Ditto.
> 
> > +	 *
> > +	 * See struct rte_flow_action_modify_tcp_seq
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> > +
> > +	/**
> > +	 * Decrease sequence number in the outermost TCP header.
> > +	 *
> > +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> > +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> 
> Ditto.
> 
> > +	 *
> > +	 * See struct rte_flow_action_modify_tcp_seq
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> > +
> > +	/**
> > +	 * Increase acknowledgment number in the outermost TCP header.
> > +	 *
> > +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> > +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> > +	 *
> 
> Ditto.
> 
> > +	 * See struct rte_flow_action_modify_tcp_ack
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> > +
> > +	/**
> > +	 * Decrease acknowledgment number in the outermost TCP header.
> > +	 *
> > +	 * If flow pattern does not define a valid
> RTE_FLOW_ITEM_TYPE_TCP,
> > +	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
> > +	 *
> 
> Ditto.
> 
> > +	 * See struct rte_flow_action_modify_tcp_ack
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
> >  };
> >
> >  /**
> > @@ -2122,6 +2162,26 @@ struct rte_flow_action_set_mac {
> >  	uint8_t mac_addr[ETHER_ADDR_LEN];
> >  };
> >
> > +/**
> 
> Experimental tag is missing.

Will add it here and elsewhere.

> 
> > + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> > + *
> > + * Increase/Decrease outermost TCP's sequence number
> 
> Suggestion:
> 
>  Increase/decrease outermost TCP sequence number.

Accepted, will change here and elsewhere.

> 
> > + */
> > +struct rte_flow_action_modify_tcp_seq {
> > +	rte_be32_t value;
> 
> Field documentation is mandatory, e.g.:
> 
>  rte_be32_t value; /**< Value to add/subtract. */

Will add it.

> 
> Beside, I'm not sure this value should be big endian since it's not stored as is
> in the TCP header; it's used by the host system to compute a new value.

It isn't used by the host, but sent to NIC as part of action.

> 
> Also what about having another field to specify what needs to be done with
> this value (e.g. add/sub/set - in which case big endian makes sense) to
> reduce the number of new actions? Something like:
> 
>  struct rte_flow_action_mod_tcp_seq {
>      enum rte_flow_action_mod_tcp_seq_op {
>          RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_ADD,
>          RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_SUB,
>          RTE_FLOW_ACTION_MOD_TCP_SEQ_OP_SET,
>      } op; /**< Operation to perform. */
>      rte_be32_t value; /**< Value to use with operation. */  };
> 
> > +};
> > +
> > +/**
> 
> Experimental tag also missing.
> 
> > + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> > + *
> > + * Increase/Decrease TCP's acknowledgment number.
> 
> Suggestion:
> 
>  Increase/decrease outermost TCP acknowledgment number.

Accepted, will change.

> 
> > + */
> > +struct rte_flow_action_modify_tcp_ack {
> > +	rte_be32_t value;
> 
> Field documentation also missing.
> 
> > +};
> > +
> >  /*
> >   * Definition of a single action.
> >   *
> > --
> > 1.8.3.1
> >
> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 2/3] app/testpmd: add actions to modify TCP header fields
  2019-03-29 13:58   ` Adrien Mazarguil
@ 2019-03-31 13:10     ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-03-31 13:10 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Friday, March 29, 2019 4:59 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [PATCH 2/3] app/testpmd: add actions to modify TCP header
> fields
> 
> On Thu, Mar 21, 2019 at 04:18:36PM +0200, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> >                 header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> >                 header.
> >
> > Original work by Xiaoyu Min.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> 
> I suggest to merge this patch into the previous one. No reason for testpmd
> to be updated separately.
> 

I prefer it in separate patch since it is part of different SW module.

> Some comments below.
> 
> > ---
> >  app/test-pmd/cmdline_flow.c                 | 100
> ++++++++++++++++++++++++++++
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
> >  2 files changed, 116 insertions(+)
> >
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index 36659a6..5cd4ceb 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -271,6 +271,14 @@ enum index {
> >  	ACTION_SET_MAC_SRC_MAC_SRC,
> >  	ACTION_SET_MAC_DST,
> >  	ACTION_SET_MAC_DST_MAC_DST,
> > +	ACTION_INC_TCP_SEQ,
> > +	ACTION_INC_TCP_SEQ_VALUE,
> > +	ACTION_DEC_TCP_SEQ,
> > +	ACTION_DEC_TCP_SEQ_VALUE,
> > +	ACTION_INC_TCP_ACK,
> > +	ACTION_INC_TCP_ACK_VALUE,
> > +	ACTION_DEC_TCP_ACK,
> > +	ACTION_DEC_TCP_ACK_VALUE,
> >  };
> >
> >  /** Maximum size for pattern in struct rte_flow_item_raw. */ @@
> > -884,6 +892,10 @@ struct parse_action_priv {
> >  	ACTION_SET_TTL,
> >  	ACTION_SET_MAC_SRC,
> >  	ACTION_SET_MAC_DST,
> > +	ACTION_INC_TCP_SEQ,
> > +	ACTION_DEC_TCP_SEQ,
> > +	ACTION_INC_TCP_ACK,
> > +	ACTION_DEC_TCP_ACK,
> >  	ZERO,
> >  };
> >
> > @@ -1046,6 +1058,30 @@ struct parse_action_priv {
> >  	ZERO,
> >  };
> >
> > +static const enum index action_inc_tcp_seq[] = {
> > +	ACTION_INC_TCP_SEQ_VALUE,
> > +	ACTION_NEXT,
> > +	ZERO,
> > +};
> > +
> > +static const enum index action_dec_tcp_seq[] = {
> > +	ACTION_DEC_TCP_SEQ_VALUE,
> > +	ACTION_NEXT,
> > +	ZERO,
> > +};
> > +
> > +static const enum index action_inc_tcp_ack[] = {
> > +	ACTION_INC_TCP_ACK_VALUE,
> > +	ACTION_NEXT,
> > +	ZERO,
> > +};
> > +
> > +static const enum index action_dec_tcp_ack[] = {
> > +	ACTION_DEC_TCP_ACK_VALUE,
> > +	ACTION_NEXT,
> > +	ZERO,
> > +};
> > +
> >  static int parse_init(struct context *, const struct token *,
> >  		      const char *, unsigned int,
> >  		      void *, unsigned int);
> > @@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct
> context *, const struct token *,
> >  			     (struct rte_flow_action_set_mac, mac_addr)),
> >  		.call = parse_vc_conf,
> >  	},
> > +	[ACTION_INC_TCP_SEQ] = {
> > +		.name = "inc_tcp_seq",
> > +		.help = "increase TCP sequence number",
> > +		.priv = PRIV_ACTION(INC_TCP_SEQ,
> > +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> > +		.next = NEXT(action_inc_tcp_seq),
> > +		.call = parse_vc,
> > +	},
> > +	[ACTION_INC_TCP_SEQ_VALUE] = {
> > +		.name = "value",
> > +		.help = "the value to increase TCP sequence number by",
> > +		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> > +		.args = ARGS(ARGS_ENTRY_HTON
> > +			(struct rte_flow_action_modify_tcp_seq, value)),
> 
> You may need to remove HTON here depending on the chosen endian for
> the API, see my comments on previous patch.
> 
> > +		.call = parse_vc_conf,
> > +	},
> > +	[ACTION_DEC_TCP_SEQ] = {
> > +		.name = "dec_tcp_seq",
> > +		.help = "decrease TCP sequence number",
> > +		.priv = PRIV_ACTION(DEC_TCP_SEQ,
> > +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> > +		.next = NEXT(action_dec_tcp_seq),
> > +		.call = parse_vc,
> > +	},
> > +	[ACTION_DEC_TCP_SEQ_VALUE] = {
> > +		.name = "value",
> > +		.help = "the value to decrease TCP sequence number by",
> > +		.next = NEXT(action_dec_tcp_seq,
> NEXT_ENTRY(UNSIGNED)),
> > +		.args = ARGS(ARGS_ENTRY_HTON
> > +			(struct rte_flow_action_modify_tcp_seq, value)),
> 
> Same here.
> 
> > +		.call = parse_vc_conf,
> > +	},
> > +	[ACTION_INC_TCP_ACK] = {
> > +		.name = "inc_tcp_ack",
> > +		.help = "increase TCP acknowledgment number",
> > +		.priv = PRIV_ACTION(INC_TCP_ACK,
> > +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> > +		.next = NEXT(action_inc_tcp_ack),
> > +		.call = parse_vc,
> > +	},
> > +	[ACTION_INC_TCP_ACK_VALUE] = {
> > +		.name = "value",
> > +		.help = "the value to increase TCP acknowledgment number
> by",
> > +		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> > +		.args = ARGS(ARGS_ENTRY_HTON
> > +			(struct rte_flow_action_modify_tcp_ack, value)),
> 
> Ditto.
> 
> > +		.call = parse_vc_conf,
> > +	},
> > +	[ACTION_DEC_TCP_ACK] = {
> > +		.name = "dec_tcp_ack",
> > +		.help = "decrease TCP acknowledgment number",
> > +		.priv = PRIV_ACTION(DEC_TCP_ACK,
> > +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> > +		.next = NEXT(action_dec_tcp_ack),
> > +		.call = parse_vc,
> > +	},
> > +	[ACTION_DEC_TCP_ACK_VALUE] = {
> > +		.name = "value",
> > +		.help = "the value to decrease TCP acknowledgment number
> by",
> > +		.next = NEXT(action_dec_tcp_ack,
> NEXT_ENTRY(UNSIGNED)),
> > +		.args = ARGS(ARGS_ENTRY_HTON
> > +			(struct rte_flow_action_modify_tcp_ack, value)),
> 
> Ditto.
> 
> > +		.call = parse_vc_conf,
> > +	},
> >  };
> >
> >  /** Remove and return last entry from argument stack. */ diff --git
> > a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > index 1a12da4..c6f8b2c 100644
> > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > @@ -3961,6 +3961,22 @@ This section lists supported actions and their
> attributes, if any.
> >
> >    - ``mac_addr {MAC-48}``: new destination MAC address
> >
> > +- ``inc_tcp_seq``: Increase sequence number in the outermost TCP
> > +header
> > +
> > +  - ``value {unsigned}``: Value to increase TCP sequence number by
> > +
> > +- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP
> > +header
> > +
> > +  - ``value {unsigned}``: Value to decrease TCP sequence number by
> > +
> > +- ``inc_tcp_ack``: Increase acknowledgment number in the outermost
> > +TCP header
> > +
> > +  - ``value {unsigned}``: Value to increase TCP acknowledgment number
> > + by
> > +
> > +- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost
> > +TCP header
> > +
> > +  - ``value {unsigned}``: Value to decrease TCP acknowledgment number
> > + by
> 
> Please add missing "." to each line.

Will add.

> 
> > +
> >  Destroying flow rules
> >  ~~~~~~~~~~~~~~~~~~~~~
> >
> > --
> > 1.8.3.1
> >
> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v2 0/3] add actions to modify header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (2 preceding siblings ...)
  2019-03-21 14:18 ` [PATCH 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-04-02 15:13 ` Dekel Peled
  2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
  2019-04-02 15:13 ` [PATCH v2 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-04-02 15:13 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  72 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   8 +
 lib/librte_ethdev/rte_flow.h                |  70 ++++++++
 8 files changed, 526 insertions(+), 1 deletion(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (3 preceding siblings ...)
  2019-04-02 15:13 ` [PATCH v2 0/3] add actions to modify header fields Dekel Peled
@ 2019-04-02 15:13 ` Dekel Peled
  2019-04-02 16:33   ` Ori Kam
  2019-04-03  9:14   ` Adrien Mazarguil
  2019-04-02 15:13 ` [PATCH v2 2/3] app/testpmd: " Dekel Peled
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-02 15:13 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  8 +++++
 lib/librte_ethdev/rte_flow.h       | 70 ++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 0203f4f..5bebb29 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item,
+behavior is unspecified, depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to increase TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item,
+behavior is unspecified, depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to decrease TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item,
+behavior is unspecified, depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to increase TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item,
+behavior is unspecified, depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to decrease TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..589d0b9 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,14 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+	MK_FLOW_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+	MK_FLOW_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index c0fe879..eca7544 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,50 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
+	 * flow pattern item, behavior is unspecified, depending on
+	 * PMD implementation.
+	 *
+	 * See struct rte_flow_action_modify_tcp_seq
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
+	 * flow pattern item, behavior is unspecified, depending on
+	 * PMD implementation.
+	 *
+	 * See struct rte_flow_action_modify_tcp_seq
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
+	 * flow pattern item, behavior is unspecified, depending on
+	 * PMD implementation.
+	 *
+	 * See struct rte_flow_action_modify_tcp_ack
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
+	 * flow pattern item, behavior is unspecified, depending on
+	 * PMD implementation.
+	 *
+	 * See struct rte_flow_action_modify_tcp_ack
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2122,6 +2166,32 @@ struct rte_flow_action_set_mac {
 	uint8_t mac_addr[ETHER_ADDR_LEN];
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
+ * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
+ *
+ * Increase/Decrease outermost TCP sequence number
+ */
+struct rte_flow_action_modify_tcp_seq {
+	rte_be32_t value; /**< Value to increase/decrease by. */
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
+ * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
+ *
+ * Increase/Decrease outermost TCP acknowledgment number.
+ */
+struct rte_flow_action_modify_tcp_ack {
+	rte_be32_t value; /**< Value to increase/decrease by. */
+};
+
 /*
  * Definition of a single action.
  *
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v2 2/3] app/testpmd: add actions to modify TCP header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (4 preceding siblings ...)
  2019-04-02 15:13 ` [PATCH v2 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
@ 2019-04-02 15:13 ` " Dekel Peled
  2019-04-02 16:33   ` Ori Kam
  2019-04-02 15:13 ` [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-04-02 15:13 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 36659a6..5cd4ceb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -271,6 +271,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -884,6 +892,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1046,6 +1058,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index bcf1449..bf93cea 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3997,6 +3997,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (5 preceding siblings ...)
  2019-04-02 15:13 ` [PATCH v2 2/3] app/testpmd: " Dekel Peled
@ 2019-04-02 15:13 ` Dekel Peled
  2019-04-02 16:34   ` Ori Kam
  2019-04-03  8:27   ` Shahaf Shuler
  2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
  8 siblings, 2 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-02 15:13 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs
  Cc: dev, orika, dekelp

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index e1e798b..c49e245 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -113,6 +113,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -134,7 +138,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 966dad9..eadd93f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_action_modify_tcp_seq *conf =
+		(const struct rte_flow_action_modify_tcp_seq *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->value);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_action_modify_tcp_ack *conf =
+		(const struct rte_flow_action_modify_tcp_ack *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->value);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] = {
 						MLX5_FLOW_ACTION_SET_TTL :
 						MLX5_FLOW_ACTION_DEC_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index da1219e..d5c5d3c 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-02 15:13 ` [PATCH v2 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
@ 2019-04-02 16:33   ` Ori Kam
  2019-04-03  9:14   ` Adrien Mazarguil
  1 sibling, 0 replies; 76+ messages in thread
From: Ori Kam @ 2019-04-02 16:33 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler
  Cc: dev, Dekel Peled



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Tuesday, April 2, 2019 6:13 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH v2 1/3] ethdev: add actions to modify TCP header
> fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst | 72
> ++++++++++++++++++++++++++++++++++++++
>  lib/librte_ethdev/rte_flow.c       |  8 +++++
>  lib/librte_ethdev/rte_flow.h       | 70
> ++++++++++++++++++++++++++++++++++++
>  3 files changed, 150 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/rte_flow.rst
> b/doc/guides/prog_guide/rte_flow.rst
> index 0203f4f..5bebb29 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error
> will be returned.
>     | ``mac_addr`` | MAC address   |
>     +--------------+---------------+
> 
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +
> +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item,
> +behavior is unspecified, depending on PMD implementation.
> +
> +.. _table_rte_flow_action_inc_tcp_seq:
> +
> +.. table:: INC_TCP_SEQ
> +
> +   +-----------+------------------------------------------+
> +   | Field     | Value                                    |
> +   +===========+==========================================+
> +   | ``value`` | Value to increase TCP sequence number by |
> +   +-----------+------------------------------------------+
> +
> +Action: ``DEC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease sequence number in the outermost TCP header.
> +
> +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item,
> +behavior is unspecified, depending on PMD implementation.
> +
> +.. _table_rte_flow_action_dec_tcp_seq:
> +
> +.. table:: DEC_TCP_SEQ
> +
> +   +-----------+------------------------------------------+
> +   | Field     | Value                                    |
> +   +===========+==========================================+
> +   | ``value`` | Value to decrease TCP sequence number by |
> +   +-----------+------------------------------------------+
> +
> +Action: ``INC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase acknowledgment number in the outermost TCP header.
> +
> +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item,
> +behavior is unspecified, depending on PMD implementation.
> +
> +.. _table_rte_flow_action_inc_tcp_ack:
> +
> +.. table:: INC_TCP_ACK
> +
> +   +-----------+------------------------------------------------+
> +   | Field     | Value                                          |
> +   +===========+================================================+
> +   | ``value`` | Value to increase TCP acknowledgment number by |
> +   +-----------+------------------------------------------------+
> +
> +Action: ``DEC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease acknowledgment number in the outermost TCP header.
> +
> +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern
> item,
> +behavior is unspecified, depending on PMD implementation.
> +
> +.. _table_rte_flow_action_dec_tcp_ack:
> +
> +.. table:: DEC_TCP_ACK
> +
> +   +-----------+------------------------------------------------+
> +   | Field     | Value                                          |
> +   +===========+================================================+
> +   | ``value`` | Value to decrease TCP acknowledgment number by |
> +   +-----------+------------------------------------------------+
> +
>  Negative types
>  ~~~~~~~~~~~~~~
> 
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
> index 3277be1..589d0b9 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -143,6 +143,14 @@ struct rte_flow_desc_data {
>  	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
>  	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> rte_flow_action_set_mac)),
>  	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> rte_flow_action_set_mac)),
> +	MK_FLOW_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +	MK_FLOW_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +	MK_FLOW_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
>  };
> 
>  static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index c0fe879..eca7544 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,50 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_set_mac.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
> +	 * flow pattern item, behavior is unspecified, depending on
> +	 * PMD implementation.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> +
> +	/**
> +	 * Decrease sequence number in the outermost TCP header.
> +	 *
> +	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
> +	 * flow pattern item, behavior is unspecified, depending on
> +	 * PMD implementation.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_seq
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> +
> +	/**
> +	 * Increase acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
> +	 * flow pattern item, behavior is unspecified, depending on
> +	 * PMD implementation.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> +
> +	/**
> +	 * Decrease acknowledgment number in the outermost TCP header.
> +	 *
> +	 * If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP
> +	 * flow pattern item, behavior is unspecified, depending on
> +	 * PMD implementation.
> +	 *
> +	 * See struct rte_flow_action_modify_tcp_ack
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
>  };
> 
>  /**
> @@ -2122,6 +2166,32 @@ struct rte_flow_action_set_mac {
>  	uint8_t mac_addr[ETHER_ADDR_LEN];
>  };
> 
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> + *
> + * Increase/Decrease outermost TCP sequence number
> + */
> +struct rte_flow_action_modify_tcp_seq {
> +	rte_be32_t value; /**< Value to increase/decrease by. */
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> + *
> + * Increase/Decrease outermost TCP acknowledgment number.
> + */
> +struct rte_flow_action_modify_tcp_ack {
> +	rte_be32_t value; /**< Value to increase/decrease by. */
> +};
> +
>  /*
>   * Definition of a single action.
>   *
> --
> 1.8.3.1


Thanks,
Acked-by: Ori Kam <orika@mellanox.com>

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 2/3] app/testpmd: add actions to modify TCP header fields
  2019-04-02 15:13 ` [PATCH v2 2/3] app/testpmd: " Dekel Peled
@ 2019-04-02 16:33   ` Ori Kam
  0 siblings, 0 replies; 76+ messages in thread
From: Ori Kam @ 2019-04-02 16:33 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler
  Cc: dev, Dekel Peled



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Tuesday, April 2, 2019 6:13 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH v2 2/3] app/testpmd: add actions to modify TCP
> header fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
>                 header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
>                 header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 100
> ++++++++++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 36659a6..5cd4ceb 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -271,6 +271,14 @@ enum index {
>  	ACTION_SET_MAC_SRC_MAC_SRC,
>  	ACTION_SET_MAC_DST,
>  	ACTION_SET_MAC_DST_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_DEC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK_VALUE,
>  };
> 
>  /** Maximum size for pattern in struct rte_flow_item_raw. */
> @@ -884,6 +892,10 @@ struct parse_action_priv {
>  	ACTION_SET_TTL,
>  	ACTION_SET_MAC_SRC,
>  	ACTION_SET_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK,
>  	ZERO,
>  };
> 
> @@ -1046,6 +1058,30 @@ struct parse_action_priv {
>  	ZERO,
>  };
> 
> +static const enum index action_inc_tcp_seq[] = {
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_seq[] = {
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_inc_tcp_ack[] = {
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_ack[] = {
> +	ACTION_DEC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static int parse_init(struct context *, const struct token *,
>  		      const char *, unsigned int,
>  		      void *, unsigned int);
> @@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context
> *, const struct token *,
>  			     (struct rte_flow_action_set_mac, mac_addr)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_INC_TCP_SEQ] = {
> +		.name = "inc_tcp_seq",
> +		.help = "increase TCP sequence number",
> +		.priv = PRIV_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_inc_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP sequence number by",
> +		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_SEQ] = {
> +		.name = "dec_tcp_seq",
> +		.help = "decrease TCP sequence number",
> +		.priv = PRIV_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_dec_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP sequence number by",
> +		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_INC_TCP_ACK] = {
> +		.name = "inc_tcp_ack",
> +		.help = "increase TCP acknowledgment number",
> +		.priv = PRIV_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_inc_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP acknowledgment number
> by",
> +		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_ACK] = {
> +		.name = "dec_tcp_ack",
> +		.help = "decrease TCP acknowledgment number",
> +		.priv = PRIV_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_dec_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP acknowledgment number
> by",
> +		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),
> +		.call = parse_vc_conf,
> +	},
>  };
> 
>  /** Remove and return last entry from argument stack. */
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index bcf1449..bf93cea 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3997,6 +3997,22 @@ This section lists supported actions and their
> attributes, if any.
> 
>    - ``mac_addr {MAC-48}``: new destination MAC address
> 
> +- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to increase TCP sequence number by.
> +
> +- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP sequence number by.
> +
> +- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
> +
> +- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 1.8.3.1

Thanks,
Acked-by: Ori Kam <orika@mellanox.com>

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs
  2019-04-02 15:13 ` [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-04-02 16:34   ` Ori Kam
  2019-04-03  8:27   ` Shahaf Shuler
  1 sibling, 0 replies; 76+ messages in thread
From: Ori Kam @ 2019-04-02 16:34 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler
  Cc: dev, Dekel Peled



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Tuesday, April 2, 2019 6:13 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using
> Direct Verbs
> 
> This patch implements additional actions of packet header
> modifications.
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.h    |  10 +-
>  drivers/net/mlx5/mlx5_flow_dv.c | 239
> ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_prm.h     |  12 ++
>  3 files changed, 260 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index e1e798b..c49e245 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -113,6 +113,10 @@
>  #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
>  #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
>  #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
> +#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
> +#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
> +#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
> +#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
> 
>  #define MLX5_FLOW_FATE_ACTIONS \
>  	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE |
> MLX5_FLOW_ACTION_RSS)
> @@ -134,7 +138,11 @@
>  				      MLX5_FLOW_ACTION_SET_TTL | \
>  				      MLX5_FLOW_ACTION_DEC_TTL | \
>  				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
> -				      MLX5_FLOW_ACTION_SET_MAC_DST)
> +				      MLX5_FLOW_ACTION_SET_MAC_DST | \
> +				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
> +				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
> +				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
> +				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
> 
>  #ifndef IPPROTO_MPLS
>  #define IPPROTO_MPLS 137
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 966dad9..eadd93f 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] = {
>  struct field_modify_info modify_tcp[] = {
>  	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
>  	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
> +	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
> +	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
>  	{0, 0, 0},
>  };
> 
> @@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] = {
>  }
> 
>  /**
> + * Convert modify-header increment/decrement TCP Sequence number
> + * to DV specification.
> + *
> + * @param[in,out] resource
> + *   Pointer to the modify-header resource.
> + * @param[in] action
> + *   Pointer to action specification.
> + * @param[out] error
> + *   Pointer to the error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_convert_action_modify_tcp_seq
> +			(struct mlx5_flow_dv_modify_hdr_resource *resource,
> +			 const struct rte_flow_action *action,
> +			 struct rte_flow_error *error)
> +{
> +	const struct rte_flow_action_modify_tcp_seq *conf =
> +		(const struct rte_flow_action_modify_tcp_seq *)(action->conf);
> +	uint64_t value = rte_be_to_cpu_32(conf->value);
> +	struct rte_flow_item item;
> +	struct rte_flow_item_tcp tcp;
> +	struct rte_flow_item_tcp tcp_mask;
> +
> +	memset(&tcp, 0, sizeof(tcp));
> +	memset(&tcp_mask, 0, sizeof(tcp_mask));
> +	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
> +		/*
> +		 * The HW has no decrement operation, only increment
> operation.
> +		 * To simulate decrement X from Y using increment operation
> +		 * we need to add UINT32_MAX X times to Y.
> +		 * Each adding of UINT32_MAX decrements Y by 1.
> +		 */
> +		value *= UINT32_MAX;
> +	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
> +	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
> +	item.type = RTE_FLOW_ITEM_TYPE_TCP;
> +	item.spec = &tcp;
> +	item.mask = &tcp_mask;
> +	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
> +					     MLX5_MODIFICATION_TYPE_ADD,
> error);
> +}
> +
> +/**
> + * Convert modify-header increment/decrement TCP Acknowledgment
> number
> + * to DV specification.
> + *
> + * @param[in,out] resource
> + *   Pointer to the modify-header resource.
> + * @param[in] action
> + *   Pointer to action specification.
> + * @param[out] error
> + *   Pointer to the error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_convert_action_modify_tcp_ack
> +			(struct mlx5_flow_dv_modify_hdr_resource *resource,
> +			 const struct rte_flow_action *action,
> +			 struct rte_flow_error *error)
> +{
> +	const struct rte_flow_action_modify_tcp_ack *conf =
> +		(const struct rte_flow_action_modify_tcp_ack *)(action->conf);
> +	uint64_t value = rte_be_to_cpu_32(conf->value);
> +	struct rte_flow_item item;
> +	struct rte_flow_item_tcp tcp;
> +	struct rte_flow_item_tcp tcp_mask;
> +
> +	memset(&tcp, 0, sizeof(tcp));
> +	memset(&tcp_mask, 0, sizeof(tcp_mask));
> +	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
> +		/*
> +		 * The HW has no decrement operation, only increment
> operation.
> +		 * To simulate decrement X from Y using increment operation
> +		 * we need to add UINT32_MAX X times to Y.
> +		 * Each adding of UINT32_MAX decrements Y by 1.
> +		 */
> +		value *= UINT32_MAX;
> +	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
> +	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
> +	item.type = RTE_FLOW_ITEM_TYPE_TCP;
> +	item.spec = &tcp;
> +	item.mask = &tcp_mask;
> +	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
> +					     MLX5_MODIFICATION_TYPE_ADD,
> error);
> +}
> +
> +/**
>   * Validate META item.
>   *
>   * @param[in] dev
> @@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] = {
>  }
> 
>  /**
> + * Validate the modify-header actions of increment/decrement
> + * TCP Sequence-number.
> + *
> + * @param[in] action_flags
> + *   Holds the actions detected until now.
> + * @param[in] action
> + *   Pointer to the modify action.
> + * @param[in] item_flags
> + *   Holds the items detected.
> + * @param[out] error
> + *   Pointer to error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
> +				       const struct rte_flow_action *action,
> +				       const uint64_t item_flags,
> +				       struct rte_flow_error *error)
> +{
> +	int ret = 0;
> +
> +	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
> +	if (!ret) {
> +		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL, "no TCP item in"
> +						  " pattern");
> +		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> &&
> +			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ))
> ||
> +		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> &&
> +			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL,
> +						  "cannot decrease and
> increase"
> +						  " TCP sequence number"
> +						  " at the same time");
> +	}
> +	return ret;
> +}
> +
> +/**
> + * Validate the modify-header actions of increment/decrement
> + * TCP Acknowledgment number.
> + *
> + * @param[in] action_flags
> + *   Holds the actions detected until now.
> + * @param[in] action
> + *   Pointer to the modify action.
> + * @param[in] item_flags
> + *   Holds the items detected.
> + * @param[out] error
> + *   Pointer to error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
> +				       const struct rte_flow_action *action,
> +				       const uint64_t item_flags,
> +				       struct rte_flow_error *error)
> +{
> +	int ret = 0;
> +
> +	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
> +	if (!ret) {
> +		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL, "no TCP item in"
> +						  " pattern");
> +		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> &&
> +			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK))
> ||
> +		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> &&
> +			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL,
> +						  "cannot decrease and
> increase"
> +						  " TCP acknowledgment
> number"
> +						  " at the same time");
> +	}
> +	return ret;
> +}
> +
> +/**
>   * Validate the modify-header TTL actions.
>   *
>   * @param[in] action_flags
> @@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] = {
> 
> 	MLX5_FLOW_ACTION_SET_TTL :
> 
> 	MLX5_FLOW_ACTION_DEC_TTL;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
> +			ret = flow_dv_validate_action_modify_tcp_seq
> +								(action_flags,
> +								 actions,
> +								 item_flags,
> +								 error);
> +			if (ret < 0)
> +				return ret;
> +			/* Count all modify-header actions as one action. */
> +			if (!(action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS))
> +				++actions_n;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
> +
> 	MLX5_FLOW_ACTION_INC_TCP_SEQ :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_SEQ;
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
> +			ret = flow_dv_validate_action_modify_tcp_ack
> +								(action_flags,
> +								 actions,
> +								 item_flags,
> +								 error);
> +			if (ret < 0)
> +				return ret;
> +			/* Count all modify-header actions as one action. */
> +			if (!(action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS))
> +				++actions_n;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
> +
> 	MLX5_FLOW_ACTION_INC_TCP_ACK :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_ACK;
> +			break;
>  		default:
>  			return rte_flow_error_set(error, ENOTSUP,
> 
> RTE_FLOW_ERROR_TYPE_ACTION,
> @@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] = {
>  				return -rte_errno;
>  			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
> +			if (flow_dv_convert_action_modify_tcp_seq(&res,
> actions,
> +								  error))
> +				return -rte_errno;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
> +					MLX5_FLOW_ACTION_INC_TCP_SEQ :
> +					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
> +			break;
> +
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
> +			if (flow_dv_convert_action_modify_tcp_ack(&res,
> actions,
> +								  error))
> +				return -rte_errno;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
> +					MLX5_FLOW_ACTION_INC_TCP_ACK :
> +					MLX5_FLOW_ACTION_DEC_TCP_ACK;
> +			break;
>  		case RTE_FLOW_ACTION_TYPE_END:
>  			actions_end = true;
>  			if (action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS) {
> diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
> index da1219e..d5c5d3c 100644
> --- a/drivers/net/mlx5/mlx5_prm.h
> +++ b/drivers/net/mlx5/mlx5_prm.h
> @@ -336,6 +336,18 @@ enum mlx5_modification_field {
>  	MLX5_MODI_IN_IPV6_HOPLIMIT,
>  	MLX5_MODI_META_DATA_REG_A,
>  	MLX5_MODI_META_DATA_REG_B = 0x50,
> +	MLX5_MODI_META_REG_C_0,
> +	MLX5_MODI_META_REG_C_1,
> +	MLX5_MODI_META_REG_C_2,
> +	MLX5_MODI_META_REG_C_3,
> +	MLX5_MODI_META_REG_C_4,
> +	MLX5_MODI_META_REG_C_5,
> +	MLX5_MODI_META_REG_C_6,
> +	MLX5_MODI_META_REG_C_7,
> +	MLX5_MODI_OUT_TCP_SEQ_NUM,
> +	MLX5_MODI_IN_TCP_SEQ_NUM,
> +	MLX5_MODI_OUT_TCP_ACK_NUM,
> +	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
>  };
> 
>  /* Modification sub command. */
> --
> 1.8.3.1

Thanks,
Acked-by: Ori Kam <orika@mellanox.com>

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs
  2019-04-02 15:13 ` [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2019-04-02 16:34   ` Ori Kam
@ 2019-04-03  8:27   ` Shahaf Shuler
  1 sibling, 0 replies; 76+ messages in thread
From: Shahaf Shuler @ 2019-04-03  8:27 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh
  Cc: dev, Ori Kam, Dekel Peled

Tuesday, April 2, 2019 6:13 PM, Dekel Peled:
> Subject: [dpdk-dev] [PATCH v2 3/3] net/mlx5: update modify header using
> Direct Verbs
> 
> This patch implements additional actions of packet header modifications.
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>

Acked-by: Shahaf Shuler <shahafs@mellanox.com>

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-02 15:13 ` [PATCH v2 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
  2019-04-02 16:33   ` Ori Kam
@ 2019-04-03  9:14   ` Adrien Mazarguil
  2019-04-03 10:49     ` Dekel Peled
  1 sibling, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-04-03  9:14 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs, dev, orika

Hi Dekel,

On Tue, Apr 02, 2019 at 06:13:19PM +0300, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
<snip>
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +
> +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow pattern item,
> +behavior is unspecified, depending on PMD implementation.

I still don't agree with the wording as it implies one must combine this
action with the TCP pattern item or else, while one should simply ensure the
presence of TCP traffic somehow. This may be done by a prior filtering rule.

So here's a generic suggestion which could be used with pretty much all
modifying actions (other actions have the same problem and will have to be
fixed as well eventually):

 Using this action on non-matching traffic results in undefined behavior.

This comment applies to all instances in this patch.

<snip>
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> + *
> + * Increase/Decrease outermost TCP sequence number
> + */
> +struct rte_flow_action_modify_tcp_seq {
> +	rte_be32_t value; /**< Value to increase/decrease by. */
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> + *
> + * Increase/Decrease outermost TCP acknowledgment number.
> + */
> +struct rte_flow_action_modify_tcp_ack {
> +	rte_be32_t value; /**< Value to increase/decrease by. */
> +};

Thanks for adding experimental tags and comments, however you didn't reply
anything about using a single action, or at least a single structure for
add/sub/set? I'd like to hear your thoughts.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-03  9:14   ` Adrien Mazarguil
@ 2019-04-03 10:49     ` Dekel Peled
  2019-04-03 12:49       ` Adrien Mazarguil
  0 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-04-03 10:49 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Wednesday, April 3, 2019 12:15 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
> 
> Hi Dekel,
> 
> On Tue, Apr 02, 2019 at 06:13:19PM +0300, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> >
> > Original work by Xiaoyu Min.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> <snip>
> > +Action: ``INC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase sequence number in the outermost TCP header.
> > +
> > +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow
> > +pattern item, behavior is unspecified, depending on PMD
> implementation.
> 
> I still don't agree with the wording as it implies one must combine this action
> with the TCP pattern item or else, while one should simply ensure the
> presence of TCP traffic somehow. This may be done by a prior filtering rule.
> 
> So here's a generic suggestion which could be used with pretty much all
> modifying actions (other actions have the same problem and will have to be
> fixed as well eventually):
> 
>  Using this action on non-matching traffic results in undefined behavior.
> 
> This comment applies to all instances in this patch.

I accept your suggestion, indeed the existing actions have the problematic condition.
However I would like to currently leave this patch as-is for consistency.
I will send a fix patch for next release, applying the updated text to all modify-header actions.

> 
> <snip>
> > +/**
> > + * @warning
> > + * @b EXPERIMENTAL: this structure may change without prior notice
> > + *
> > + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> > + *
> > + * Increase/Decrease outermost TCP sequence number  */ struct
> > +rte_flow_action_modify_tcp_seq {
> > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> > +
> > +/**
> > + * @warning
> > + * @b EXPERIMENTAL: this structure may change without prior notice
> > + *
> > + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> > + *
> > + * Increase/Decrease outermost TCP acknowledgment number.
> > + */
> > +struct rte_flow_action_modify_tcp_ack {
> > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> 
> Thanks for adding experimental tags and comments, however you didn't
> reply anything about using a single action, or at least a single structure for
> add/sub/set? I'd like to hear your thoughts.

It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
The current implementation is more straight-forward in my opinion.

> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-03 10:49     ` Dekel Peled
@ 2019-04-03 12:49       ` Adrien Mazarguil
  2019-04-04  9:01         ` Ori Kam
  0 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-04-03 12:49 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev, Ori Kam

On Wed, Apr 03, 2019 at 10:49:09AM +0000, Dekel Peled wrote:
> Thanks, PSB.
> 
> > -----Original Message-----
> > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > Sent: Wednesday, April 3, 2019 12:15 PM
> > To: Dekel Peled <dekelp@mellanox.com>
> > Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> > bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> > Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> > <orika@mellanox.com>
> > Subject: Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
> > 
> > Hi Dekel,
> > 
> > On Tue, Apr 02, 2019 at 06:13:19PM +0300, Dekel Peled wrote:
> > > Add actions:
> > > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> > header.
> > > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > > 		header.
> > > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > > 		header.
> > >
> > > Original work by Xiaoyu Min.
> > >
> > > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > <snip>
> > > +Action: ``INC_TCP_SEQ``
> > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > +
> > > +Increase sequence number in the outermost TCP header.
> > > +
> > > +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow
> > > +pattern item, behavior is unspecified, depending on PMD
> > implementation.
> > 
> > I still don't agree with the wording as it implies one must combine this action
> > with the TCP pattern item or else, while one should simply ensure the
> > presence of TCP traffic somehow. This may be done by a prior filtering rule.
> > 
> > So here's a generic suggestion which could be used with pretty much all
> > modifying actions (other actions have the same problem and will have to be
> > fixed as well eventually):
> > 
> >  Using this action on non-matching traffic results in undefined behavior.
> > 
> > This comment applies to all instances in this patch.
> 
> I accept your suggestion, indeed the existing actions have the problematic condition.
> However I would like to currently leave this patch as-is for consistency.
> I will send a fix patch for next release, applying the updated text to all modify-header actions.

Please do it now as it's much more difficult to change an existing API
later (think deprecation notices and endless discussions); even seemingly
minor documentation issues like this one may affect applications.

> > <snip>
> > > +/**
> > > + * @warning
> > > + * @b EXPERIMENTAL: this structure may change without prior notice
> > > + *
> > > + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> > > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> > > + *
> > > + * Increase/Decrease outermost TCP sequence number  */ struct
> > > +rte_flow_action_modify_tcp_seq {
> > > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> > > +
> > > +/**
> > > + * @warning
> > > + * @b EXPERIMENTAL: this structure may change without prior notice
> > > + *
> > > + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> > > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> > > + *
> > > + * Increase/Decrease outermost TCP acknowledgment number.
> > > + */
> > > +struct rte_flow_action_modify_tcp_ack {
> > > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> > 
> > Thanks for adding experimental tags and comments, however you didn't
> > reply anything about using a single action, or at least a single structure for
> > add/sub/set? I'd like to hear your thoughts.
> 
> It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
> The current implementation is more straight-forward in my opinion.

I generally also prefer the one action per thing to do approach, but seeing
the kind of actions you're adding, I fear we'll soon end up with lots of
similar rte_flow_action_* structures modifying a single 32-bit value in some
way.

So for the same reasons as above, I think it's the right time to define a
shared structure to rule them all, or maybe even let users provide a
rte_be32_t/uint32_t/whatever pointer directly as a conf pointer (not
as straightforward to document though).

An object to rule them all would look something like that:

 union rte_flow_integer {
     rte_be64_t be64;
     rte_le64_t le64;
     uint64_t u64;
     int64_t i64;
     rte_be32_t be32;
     rte_le32_t le32;
     uint32_t u32;
     int32_t i32;
     uint8_t u8;
     int8_t i8;
 };

Then actions that need a single integer value only have to document which
field is relevant to them. How about that?

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-03 12:49       ` Adrien Mazarguil
@ 2019-04-04  9:01         ` Ori Kam
  2019-04-04 13:25           ` Adrien Mazarguil
  0 siblings, 1 reply; 76+ messages in thread
From: Ori Kam @ 2019-04-04  9:01 UTC (permalink / raw)
  To: Adrien Mazarguil, Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev

Hi Adrien,

PSB

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Wednesday, April 3, 2019 3:49 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>; Shahaf
> Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
> 
> On Wed, Apr 03, 2019 at 10:49:09AM +0000, Dekel Peled wrote:
> > Thanks, PSB.
> >
> > > -----Original Message-----
> > > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > > Sent: Wednesday, April 3, 2019 12:15 PM
> > > To: Dekel Peled <dekelp@mellanox.com>
> > > Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> > > bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> > > Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> > > <orika@mellanox.com>
> > > Subject: Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
> > >
> > > Hi Dekel,
> > >
> > > On Tue, Apr 02, 2019 at 06:13:19PM +0300, Dekel Peled wrote:
> > > > Add actions:
> > > > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > > > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> > > header.
> > > > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > > > 		header.
> > > > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost
> TCP
> > > > 		header.
> > > >
> > > > Original work by Xiaoyu Min.
> > > >
> > > > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > > <snip>
> > > > +Action: ``INC_TCP_SEQ``
> > > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > > +
> > > > +Increase sequence number in the outermost TCP header.
> > > > +
> > > > +If this action is used without a valid RTE_FLOW_ITEM_TYPE_TCP flow
> > > > +pattern item, behavior is unspecified, depending on PMD
> > > implementation.
> > >
> > > I still don't agree with the wording as it implies one must combine this
> action
> > > with the TCP pattern item or else, while one should simply ensure the
> > > presence of TCP traffic somehow. This may be done by a prior filtering rule.
> > >
> > > So here's a generic suggestion which could be used with pretty much all
> > > modifying actions (other actions have the same problem and will have to be
> > > fixed as well eventually):
> > >
> > >  Using this action on non-matching traffic results in undefined behavior.
> > >
> > > This comment applies to all instances in this patch.
> >
> > I accept your suggestion, indeed the existing actions have the problematic
> condition.
> > However I would like to currently leave this patch as-is for consistency.
> > I will send a fix patch for next release, applying the updated text to all
> modify-header actions.
> 
> Please do it now as it's much more difficult to change an existing API
> later (think deprecation notices and endless discussions); even seemingly
> minor documentation issues like this one may affect applications.
> 
I agree that changing API is not easy. This is why I think we should keep Dekel patch,
there is a number of API and consistency is very important. Also the PMD is based on the current
description that such command should fail.

So lets keep it this way if you want to change all API then and only then this API should be changed.

> > > <snip>
> > > > +/**
> > > > + * @warning
> > > > + * @b EXPERIMENTAL: this structure may change without prior notice
> > > > + *
> > > > + * RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> > > > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> > > > + *
> > > > + * Increase/Decrease outermost TCP sequence number  */ struct
> > > > +rte_flow_action_modify_tcp_seq {
> > > > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> > > > +
> > > > +/**
> > > > + * @warning
> > > > + * @b EXPERIMENTAL: this structure may change without prior notice
> > > > + *
> > > > + * RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> > > > + * RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> > > > + *
> > > > + * Increase/Decrease outermost TCP acknowledgment number.
> > > > + */
> > > > +struct rte_flow_action_modify_tcp_ack {
> > > > +	rte_be32_t value; /**< Value to increase/decrease by. */ };
> > >
> > > Thanks for adding experimental tags and comments, however you didn't
> > > reply anything about using a single action, or at least a single structure for
> > > add/sub/set? I'd like to hear your thoughts.
> >
> > It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
> > The current implementation is more straight-forward in my opinion.
> 
> I generally also prefer the one action per thing to do approach, but seeing
> the kind of actions you're adding, I fear we'll soon end up with lots of
> similar rte_flow_action_* structures modifying a single 32-bit value in some
> way.
> 
> So for the same reasons as above, I think it's the right time to define a
> shared structure to rule them all, or maybe even let users provide a
> rte_be32_t/uint32_t/whatever pointer directly as a conf pointer (not
> as straightforward to document though).
> 
> An object to rule them all would look something like that:
> 
>  union rte_flow_integer {
>      rte_be64_t be64;
>      rte_le64_t le64;
>      uint64_t u64;
>      int64_t i64;
>      rte_be32_t be32;
>      rte_le32_t le32;
>      uint32_t u32;
>      int32_t i32;
>      uint8_t u8;
>      int8_t i8;
>  };
> 
> Then actions that need a single integer value only have to document which
> field is relevant to them. How about that?
> 

Like my previous comment. I understand your idea, but it has no huge advantage compared to the
suggested one by Dekel which also match all other API.

Currently for each action we have a direct command, which is easy to understand by using your idea we break this concept.
There is no issue with having a large number of actions, it is even easer to read and document if each action is dedicated,
as you can also see from OVS.

So I vote to keep Dekel patch as is.

> --
> Adrien Mazarguil
> 6WIND


Ori Kam

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-04  9:01         ` Ori Kam
@ 2019-04-04 13:25           ` Adrien Mazarguil
  2019-04-05 11:54             ` [dpdk-dev] " Andrew Rybchenko
  2019-04-08 13:36             ` Dekel Peled
  0 siblings, 2 replies; 76+ messages in thread
From: Adrien Mazarguil @ 2019-04-04 13:25 UTC (permalink / raw)
  To: Ori Kam
  Cc: Dekel Peled, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, dev

Hi Ori,

(trimming message down a bit)

On Thu, Apr 04, 2019 at 09:01:52AM +0000, Ori Kam wrote:
> Hi Adrien,
> 
> PSB
<snip>
> 
> > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
<snip>
> > On Wed, Apr 03, 2019 at 10:49:09AM +0000, Dekel Peled wrote:
> > > Thanks, PSB.
<snip>
> > > > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
<snip>
> > > > I still don't agree with the wording as it implies one must combine this
> > action
> > > > with the TCP pattern item or else, while one should simply ensure the
> > > > presence of TCP traffic somehow. This may be done by a prior filtering rule.
> > > >
> > > > So here's a generic suggestion which could be used with pretty much all
> > > > modifying actions (other actions have the same problem and will have to be
> > > > fixed as well eventually):
> > > >
> > > >  Using this action on non-matching traffic results in undefined behavior.
> > > >
> > > > This comment applies to all instances in this patch.
> > >
> > > I accept your suggestion, indeed the existing actions have the problematic
> > condition.
> > > However I would like to currently leave this patch as-is for consistency.
> > > I will send a fix patch for next release, applying the updated text to all
> > modify-header actions.
> > 
> > Please do it now as it's much more difficult to change an existing API
> > later (think deprecation notices and endless discussions); even seemingly
> > minor documentation issues like this one may affect applications.
> > 
> I agree that changing API is not easy. This is why I think we should keep Dekel patch,
> there is a number of API and consistency is very important. Also the PMD is based on the current
> description that such command should fail.
> 
> So lets keep it this way if you want to change all API then and only then this API should be changed.

Wait, I'm not asking Delek to modify existing code/APIs right now, only to
document these new actions properly from the start so we don't have to do it
later (you even acknowledged it's more difficult that way).

So I fail to understand why it's so important for their documentation to be
consistent with unrelated and badly documented actions?

Note the change I'm asking for at the API level doesn't affect PMD code,
which remains free to put extra limitations (namely the presence of TCP
pattern items). It's just that these limitations have nothing to do in the
API itself.

<snip>
> > > It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
> > > The current implementation is more straight-forward in my opinion.
> > 
> > I generally also prefer the one action per thing to do approach, but seeing
> > the kind of actions you're adding, I fear we'll soon end up with lots of
> > similar rte_flow_action_* structures modifying a single 32-bit value in some
> > way.
> > 
> > So for the same reasons as above, I think it's the right time to define a
> > shared structure to rule them all, or maybe even let users provide a
> > rte_be32_t/uint32_t/whatever pointer directly as a conf pointer (not
> > as straightforward to document though).
> > 
> > An object to rule them all would look something like that:
> > 
> >  union rte_flow_integer {
> >      rte_be64_t be64;
> >      rte_le64_t le64;
> >      uint64_t u64;
> >      int64_t i64;
> >      rte_be32_t be32;
> >      rte_le32_t le32;
> >      uint32_t u32;
> >      int32_t i32;
> >      uint8_t u8;
> >      int8_t i8;
> >  };
> > 
> > Then actions that need a single integer value only have to document which
> > field is relevant to them. How about that?
> > 
> 
> Like my previous comment. I understand your idea, but it has no huge advantage compared to the
> suggested one by Dekel which also match all other API.
> 
> Currently for each action we have a direct command, which is easy to understand by using your idea we break this concept.

Yes, although not all actions have a configuration structure. Those that do
indeed have a rte_flow_action_* counterpart, but it doesn't have to be
unique, see RTE_FLOW_ITEM_GTP/GTPC/GTPU for instance.

Likewise this patch adds struct rte_flow_action_modify_tcp_seq shared by
RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ and RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
although they lack a common prefix (inc_tcp/dec_tcp vs. modify_tcp). The
type to use is covered by documentation and that's fine.

So why not go a little further and share the exact same structure with
RTE_FLOW_ACTION_TYPE_INC_TCP_ACK and RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK?

And while there, why not plan for subsequent actions that take a single
integer value of some kind, because modifying existing APIs once upstream is
complicated... See where I'm going?

> There is no issue with having a large number of actions, it is even easer to read and document if each action is dedicated,
> as you can also see from OVS.

I'm actually fine with a large number of actions (rte_flow can support 2^31
unique actions). Not so much with a large number of identical configuration
structures that only differ by name associated with them. This is what I'd
like to avoid before it's too late.

> So I vote to keep Dekel patch as is.

I don't, I guess another vote is needed to decide :)

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-04 13:25           ` Adrien Mazarguil
@ 2019-04-05 11:54             ` " Andrew Rybchenko
  2019-04-08 13:36             ` Dekel Peled
  1 sibling, 0 replies; 76+ messages in thread
From: Andrew Rybchenko @ 2019-04-05 11:54 UTC (permalink / raw)
  To: Adrien Mazarguil, Ori Kam
  Cc: Dekel Peled, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, dev

On 4/4/19 4:25 PM, Adrien Mazarguil wrote:
> Hi Ori,
>
> (trimming message down a bit)
>
> On Thu, Apr 04, 2019 at 09:01:52AM +0000, Ori Kam wrote:
>> Hi Adrien,
>>
>> PSB
> <snip>
>>> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> <snip>
>>> On Wed, Apr 03, 2019 at 10:49:09AM +0000, Dekel Peled wrote:
>>>> Thanks, PSB.
> <snip>
>>>>> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> <snip>
>>>>> I still don't agree with the wording as it implies one must combine this
>>> action
>>>>> with the TCP pattern item or else, while one should simply ensure the
>>>>> presence of TCP traffic somehow. This may be done by a prior filtering rule.
>>>>>
>>>>> So here's a generic suggestion which could be used with pretty much all
>>>>> modifying actions (other actions have the same problem and will have to be
>>>>> fixed as well eventually):
>>>>>
>>>>>   Using this action on non-matching traffic results in undefined behavior.
>>>>>
>>>>> This comment applies to all instances in this patch.
>>>> I accept your suggestion, indeed the existing actions have the problematic
>>> condition.
>>>> However I would like to currently leave this patch as-is for consistency.
>>>> I will send a fix patch for next release, applying the updated text to all
>>> modify-header actions.
>>>
>>> Please do it now as it's much more difficult to change an existing API
>>> later (think deprecation notices and endless discussions); even seemingly
>>> minor documentation issues like this one may affect applications.
>>>
>> I agree that changing API is not easy. This is why I think we should keep Dekel patch,
>> there is a number of API and consistency is very important. Also the PMD is based on the current
>> description that such command should fail.
>>
>> So lets keep it this way if you want to change all API then and only then this API should be changed.
> Wait, I'm not asking Delek to modify existing code/APIs right now, only to
> document these new actions properly from the start so we don't have to do it
> later (you even acknowledged it's more difficult that way).
>
> So I fail to understand why it's so important for their documentation to be
> consistent with unrelated and badly documented actions?
>
> Note the change I'm asking for at the API level doesn't affect PMD code,
> which remains free to put extra limitations (namely the presence of TCP
> pattern items). It's just that these limitations have nothing to do in the
> API itself.
>
> <snip>
>>>> It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
>>>> The current implementation is more straight-forward in my opinion.
>>> I generally also prefer the one action per thing to do approach, but seeing
>>> the kind of actions you're adding, I fear we'll soon end up with lots of
>>> similar rte_flow_action_* structures modifying a single 32-bit value in some
>>> way.
>>>
>>> So for the same reasons as above, I think it's the right time to define a
>>> shared structure to rule them all, or maybe even let users provide a
>>> rte_be32_t/uint32_t/whatever pointer directly as a conf pointer (not
>>> as straightforward to document though).
>>>
>>> An object to rule them all would look something like that:
>>>
>>>   union rte_flow_integer {
>>>       rte_be64_t be64;
>>>       rte_le64_t le64;
>>>       uint64_t u64;
>>>       int64_t i64;
>>>       rte_be32_t be32;
>>>       rte_le32_t le32;
>>>       uint32_t u32;
>>>       int32_t i32;
>>>       uint8_t u8;
>>>       int8_t i8;
>>>   };
>>>
>>> Then actions that need a single integer value only have to document which
>>> field is relevant to them. How about that?

I like the idea (plus 16-bit options). We already have too many
rte_flow_action_* structures with single integer in it.

>> Like my previous comment. I understand your idea, but it has no huge advantage compared to the
>> suggested one by Dekel which also match all other API.
>>
>> Currently for each action we have a direct command, which is easy to understand by using your idea we break this concept.
> Yes, although not all actions have a configuration structure. Those that do
> indeed have a rte_flow_action_* counterpart, but it doesn't have to be
> unique, see RTE_FLOW_ITEM_GTP/GTPC/GTPU for instance.
>
> Likewise this patch adds struct rte_flow_action_modify_tcp_seq shared by
> RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ and RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> although they lack a common prefix (inc_tcp/dec_tcp vs. modify_tcp). The
> type to use is covered by documentation and that's fine.
>
> So why not go a little further and share the exact same structure with
> RTE_FLOW_ACTION_TYPE_INC_TCP_ACK and RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK?

Shouldn't these action be RTE_FLOW_ACTION_TYPE_MOD_TCP_{ACK,SEQ}
with singed 32-bit integer parameter (negative to decrement, positive to
increment)? IMHO, having INC and DEC is too artificial and just bloat API
and code.

> And while there, why not plan for subsequent actions that take a single
> integer value of some kind, because modifying existing APIs once upstream is
> complicated... See where I'm going?
>
>> There is no issue with having a large number of actions, it is even easer to read and document if each action is dedicated,
>> as you can also see from OVS.
> I'm actually fine with a large number of actions (rte_flow can support 2^31
> unique actions). Not so much with a large number of identical configuration
> structures that only differ by name associated with them. This is what I'd
> like to avoid before it's too late.

Too many actions bloat the code everywhere: API, PMDs, testpmd, other apps.
If it is possible to decrease number of different actions without
over-complicating, it should be done.

>> So I vote to keep Dekel patch as is.
> I don't, I guess another vote is needed to decide :)
>


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-04 13:25           ` Adrien Mazarguil
  2019-04-05 11:54             ` [dpdk-dev] " Andrew Rybchenko
@ 2019-04-08 13:36             ` Dekel Peled
  2019-04-08 13:53               ` Andrew Rybchenko
  1 sibling, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-04-08 13:36 UTC (permalink / raw)
  To: Adrien Mazarguil, Ori Kam, Andrew Rybchenko
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Thursday, April 4, 2019 4:26 PM
> To: Ori Kam <orika@mellanox.com>
> Cc: Dekel Peled <dekelp@mellanox.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>;
> dev@dpdk.org
> Subject: Re: [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
> 
> Hi Ori,
> 
> (trimming message down a bit)
> 
> On Thu, Apr 04, 2019 at 09:01:52AM +0000, Ori Kam wrote:
> > Hi Adrien,
> >
> > PSB
> <snip>
> >
> > > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> <snip>
> > > On Wed, Apr 03, 2019 at 10:49:09AM +0000, Dekel Peled wrote:
> > > > Thanks, PSB.
> <snip>
> > > > > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> <snip>
> > > > > I still don't agree with the wording as it implies one must
> > > > > combine this
> > > action
> > > > > with the TCP pattern item or else, while one should simply
> > > > > ensure the presence of TCP traffic somehow. This may be done by a
> prior filtering rule.
> > > > >
> > > > > So here's a generic suggestion which could be used with pretty
> > > > > much all modifying actions (other actions have the same problem
> > > > > and will have to be fixed as well eventually):
> > > > >
> > > > >  Using this action on non-matching traffic results in undefined
> behavior.
> > > > >
> > > > > This comment applies to all instances in this patch.
> > > >
> > > > I accept your suggestion, indeed the existing actions have the
> > > > problematic
> > > condition.
> > > > However I would like to currently leave this patch as-is for consistency.
> > > > I will send a fix patch for next release, applying the updated
> > > > text to all
> > > modify-header actions.
> > >
> > > Please do it now as it's much more difficult to change an existing
> > > API later (think deprecation notices and endless discussions); even
> > > seemingly minor documentation issues like this one may affect
> applications.
> > >
> > I agree that changing API is not easy. This is why I think we should
> > keep Dekel patch, there is a number of API and consistency is very
> > important. Also the PMD is based on the current description that such
> command should fail.
> >
> > So lets keep it this way if you want to change all API then and only then this
> API should be changed.
> 
> Wait, I'm not asking Delek to modify existing code/APIs right now, only to

It's Dekel, not Delek (nor any other permutation of these letters).

> document these new actions properly from the start so we don't have to do
> it later (you even acknowledged it's more difficult that way).
> 
> So I fail to understand why it's so important for their documentation to be
> consistent with unrelated and badly documented actions?
> 
> Note the change I'm asking for at the API level doesn't affect PMD code,
> which remains free to put extra limitations (namely the presence of TCP
> pattern items). It's just that these limitations have nothing to do in the API
> itself.

Accepted, I will change the documentation as you suggested, with note that the resulting undefined behavior is per PMD implementation.

Regarding Andrew's suggestion: "Shouldn't these action be RTE_FLOW_ACTION_TYPE_MOD_TCP_{ACK,SEQ} with singed 32-bit integer parameter (negative to decrement, positive to increment)?"
I will leave the actions as is, the action names indicate the operation they perform. 

> 
> <snip>
> > > > It's either 2 actions with 1 parameters, or 1 action with 2 parameters.
> > > > The current implementation is more straight-forward in my opinion.
> > >
> > > I generally also prefer the one action per thing to do approach, but
> > > seeing the kind of actions you're adding, I fear we'll soon end up
> > > with lots of similar rte_flow_action_* structures modifying a single
> > > 32-bit value in some way.
> > >
> > > So for the same reasons as above, I think it's the right time to
> > > define a shared structure to rule them all, or maybe even let users
> > > provide a rte_be32_t/uint32_t/whatever pointer directly as a conf
> > > pointer (not as straightforward to document though).
> > >
> > > An object to rule them all would look something like that:
> > >
> > >  union rte_flow_integer {
> > >      rte_be64_t be64;
> > >      rte_le64_t le64;
> > >      uint64_t u64;
> > >      int64_t i64;
> > >      rte_be32_t be32;
> > >      rte_le32_t le32;
> > >      uint32_t u32;
> > >      int32_t i32;
> > >      uint8_t u8;
> > >      int8_t i8;
> > >  };
> > >
> > > Then actions that need a single integer value only have to document
> > > which field is relevant to them. How about that?
> > >
> >
> > Like my previous comment. I understand your idea, but it has no huge
> > advantage compared to the suggested one by Dekel which also match all
> other API.
> >
> > Currently for each action we have a direct command, which is easy to
> understand by using your idea we break this concept.
> 
> Yes, although not all actions have a configuration structure. Those that do
> indeed have a rte_flow_action_* counterpart, but it doesn't have to be
> unique, see RTE_FLOW_ITEM_GTP/GTPC/GTPU for instance.
> 
> Likewise this patch adds struct rte_flow_action_modify_tcp_seq shared by
> RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ and
> RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ although they lack a common
> prefix (inc_tcp/dec_tcp vs. modify_tcp). The type to use is covered by
> documentation and that's fine.
> 
> So why not go a little further and share the exact same structure with
> RTE_FLOW_ACTION_TYPE_INC_TCP_ACK and
> RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK?
> 

Accepted, I will add union as you suggested (plus 16 bit values as Andrew noted) and use it for all the new actions.

> And while there, why not plan for subsequent actions that take a single
> integer value of some kind, because modifying existing APIs once upstream
> is complicated... See where I'm going?
> 
> > There is no issue with having a large number of actions, it is even
> > easer to read and document if each action is dedicated, as you can also see
> from OVS.
> 
> I'm actually fine with a large number of actions (rte_flow can support 2^31
> unique actions). Not so much with a large number of identical configuration
> structures that only differ by name associated with them. This is what I'd like
> to avoid before it's too late.
> 
> > So I vote to keep Dekel patch as is.
> 
> I don't, I guess another vote is needed to decide :)
> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-08 13:36             ` Dekel Peled
@ 2019-04-08 13:53               ` Andrew Rybchenko
  2019-04-08 14:21                 ` Adrien Mazarguil
  0 siblings, 1 reply; 76+ messages in thread
From: Andrew Rybchenko @ 2019-04-08 13:53 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, Ori Kam
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, dev

On 4/8/19 4:36 PM, Dekel Peled wrote:
> Regarding Andrew's suggestion: "Shouldn't these action be RTE_FLOW_ACTION_TYPE_MOD_TCP_{ACK,SEQ} with singed 32-bit integer parameter (negative to decrement, positive to increment)?"
> I will leave the actions as is, the action names indicate the operation they perform.

I think it is an overkill to have two actions for the purpose: DEC 
(value) == INC ((uint32_t)-value)
If it is really important to have DEC and INC, please, make it clear 
from actions documentation why.

Thanks,
Andrew.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] ethdev: add actions to modify TCP header fields
  2019-04-08 13:53               ` Andrew Rybchenko
@ 2019-04-08 14:21                 ` Adrien Mazarguil
  0 siblings, 0 replies; 76+ messages in thread
From: Adrien Mazarguil @ 2019-04-08 14:21 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: Dekel Peled, Ori Kam, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, dev

Hi Andrew, *Dekel* (I swear I'm not doing it on purpose, hopefully I won't
make that stupid mistake again :)

On Mon, Apr 08, 2019 at 04:53:54PM +0300, Andrew Rybchenko wrote:
> On 4/8/19 4:36 PM, Dekel Peled wrote:
> > Regarding Andrew's suggestion: "Shouldn't these action be RTE_FLOW_ACTION_TYPE_MOD_TCP_{ACK,SEQ} with singed 32-bit integer parameter (negative to decrement, positive to increment)?"
> > I will leave the actions as is, the action names indicate the operation they perform.
> 
> I think it is an overkill to have two actions for the purpose: DEC (value)
> == INC ((uint32_t)-value)
> If it is really important to have DEC and INC, please, make it clear from
> actions documentation why.

The main reason in my opinion is that a signed value may not be able to
represent an increment large enough for an unsigned value of the same bit
width.

This can be worked around by using a type larger than the underlying data
field (e.g. i64 for u32), but it will look confusing and is not an option
for the largest unsigned type we support (u64).

Another problem is what endian increment/decrement actions should use. There
are no dedicated endian types for signed values at the moment, and I'm not
sure we should define any.

This could be addressed by defining a third "SET" action to overwrite the
current value (even if unused) as this action will use the same type as
the two others and that of the underlying data (including endianness) for
consistency.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] add actions to modify header fields
  2019-04-02 15:13 ` [PATCH v2 0/3] add actions to modify header fields Dekel Peled
@ 2019-04-10 11:26   ` " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 1/3] ethdev: add actions to modify TCP " Dekel Peled
                       ` (3 more replies)
  0 siblings, 4 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:26 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  72 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  60 +++++++
 8 files changed, 512 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] ethdev: add actions to modify TCP header fields
  2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
@ 2019-04-10 11:26     ` " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: " Dekel Peled
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:26 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 +++
 lib/librte_ethdev/rte_flow.h       | 60 +++++++++++++++++++++++++++++++
 3 files changed, 136 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 0203f4f..58cf6cc 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior, 
+depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to increase TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior, 
+depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to decrease TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior, 
+depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to increase TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior, 
+depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to decrease TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..ed4e643 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(struct rte_flow_general_action)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index c0fe879..3b0e262 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2123,6 +2163,26 @@ struct rte_flow_action_set_mac {
 };
 
 /*
+ * @warning
+ * @b EXPERIMENTAL: this union may change without prior notice
+ *
+ * General integer type, can be expanded as needed.
+*/
+union rte_flow_integer {
+      rte_be32_t be32;
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * General struct, for use by actions that require a single integer value.
+ */
+struct rte_flow_general_action {
+	union rte_flow_integer integer;
+};
+
+/*
  * Definition of a single action.
  *
  * A list of actions is terminated by a END action.
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] app/testpmd: add actions to modify TCP header fields
  2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-04-10 11:26     ` " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
  3 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:26 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 36659a6..4b2c378 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -271,6 +271,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -884,6 +892,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1046,6 +1058,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 06c8b2a..318f017 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3997,6 +3997,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] net/mlx5: update modify header using Direct Verbs
  2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: " Dekel Peled
@ 2019-04-10 11:26     ` Dekel Peled
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
  3 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:26 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index e1e798b..c49e245 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -113,6 +113,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -134,7 +138,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ad84dea..16ea72f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_general_action *conf =
+		(const struct rte_flow_general_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->integer.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_general_action *conf =
+		(const struct rte_flow_general_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->integer.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] = {
 						MLX5_FLOW_ACTION_SET_TTL :
 						MLX5_FLOW_ACTION_DEC_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index fb14e4c..ad7e2e3 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields
  2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
                       ` (2 preceding siblings ...)
  2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-04-10 11:50     ` Dekel Peled
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP " Dekel Peled
                         ` (3 more replies)
  3 siblings, 4 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:50 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  72 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  60 +++++++
 8 files changed, 512 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP header fields
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
@ 2019-04-10 11:50       ` " Dekel Peled
  2019-04-18 12:30         ` Adrien Mazarguil
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: " Dekel Peled
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:50 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 72 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 +++
 lib/librte_ethdev/rte_flow.h       | 60 +++++++++++++++++++++++++++++++
 3 files changed, 136 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 0203f4f..fc234de 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior,
+depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to increase TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior,
+depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +-----------+------------------------------------------+
+   | Field     | Value                                    |
+   +===========+==========================================+
+   | ``value`` | Value to decrease TCP sequence number by |
+   +-----------+------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior,
+depending on PMD implementation.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to increase TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior,
+depending on PMD implementation.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +-----------+------------------------------------------------+
+   | Field     | Value                                          |
+   +===========+================================================+
+   | ``value`` | Value to decrease TCP acknowledgment number by |
+   +-----------+------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..ed4e643 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(struct rte_flow_general_action)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(struct rte_flow_general_action)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index c0fe879..e3f6210 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior, depending on PMD implementation.
+	 *
+	 * See struct rte_flow_general_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2123,6 +2163,26 @@ struct rte_flow_action_set_mac {
 };
 
 /*
+ * @warning
+ * @b EXPERIMENTAL: this union may change without prior notice
+ *
+ * General integer type, can be expanded as needed.
+ */
+union rte_flow_integer {
+	rte_be32_t be32;
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * General struct, for use by actions that require a single integer value.
+ */
+struct rte_flow_general_action {
+	union rte_flow_integer integer;
+};
+
+/*
  * Definition of a single action.
  *
  * A list of actions is terminated by a END action.
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] app/testpmd: add actions to modify TCP header fields
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-04-10 11:50       ` " Dekel Peled
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
  3 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:50 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 36659a6..4b2c378 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -271,6 +271,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -884,6 +892,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1046,6 +1058,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_general_action)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_general_action, integer)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 06c8b2a..318f017 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3997,6 +3997,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] net/mlx5: update modify header using Direct Verbs
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: " Dekel Peled
@ 2019-04-10 11:50       ` Dekel Peled
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
  3 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-10 11:50 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index e1e798b..c49e245 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -113,6 +113,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -134,7 +138,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ad84dea..16ea72f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -126,6 +126,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -512,6 +514,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_general_action *conf =
+		(const struct rte_flow_general_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->integer.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_general_action *conf =
+		(const struct rte_flow_general_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->integer.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1385,6 +1479,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -1962,6 +2146,40 @@ struct field_modify_info modify_tcp[] = {
 						MLX5_FLOW_ACTION_SET_TTL :
 						MLX5_FLOW_ACTION_DEC_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3089,6 +3307,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index fb14e4c..ad7e2e3 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP header fields
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-04-18 12:30         ` Adrien Mazarguil
  2019-04-22  7:15           ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-04-18 12:30 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs,
	arybchenko, dev, orika

On Wed, Apr 10, 2019 at 02:50:41PM +0300, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>

Almost there... Some changes were not made as discussed, please see below.

<snip>
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index 0203f4f..fc234de 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
>     | ``mac_addr`` | MAC address   |
>     +--------------+---------------+
>  
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +
> +Using this action on non-matching traffic will result in undefined behavior,
> +depending on PMD implementation.

OK, "depending on PMD implementation" looks a bit redundant though.

> +
> +.. _table_rte_flow_action_inc_tcp_seq:
> +
> +.. table:: INC_TCP_SEQ
> +
> +   +-----------+------------------------------------------+
> +   | Field     | Value                                    |
> +   +===========+==========================================+
> +   | ``value`` | Value to increase TCP sequence number by |
> +   +-----------+------------------------------------------+

Configuration object documentation needs updating since you changed its type
and fields.

These comments also apply to DEC_TCP_SEQ, INC_TCP_ACK and DEC_TCP_ACK.

<snip>
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index c0fe879..e3f6210 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_set_mac.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior, depending on PMD implementation.

"depending on PMD implementation" also redundant here.

<snip>
>  /*
> + * @warning
> + * @b EXPERIMENTAL: this union may change without prior notice
> + *
> + * General integer type, can be expanded as needed.
> + */
> +union rte_flow_integer {
> +	rte_be32_t be32;
> +};

You must include the extra fields you don't use (64/16/32/8 and
le/be/host/signed variants as described in previous messages) to limit the
risk of ABI breakage next time someone needs a field that isn't there yet.

This object must be able to accommodate the largest supported integer and
have the proper alignment constraints for any of these types, hence the
union with all of them from the start.

> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * General struct, for use by actions that require a single integer value.
> + */
> +struct rte_flow_general_action {
> +	union rte_flow_integer integer;
> +};

Seriously, why can't actions take "union rte_flow_integer" directly? Besides
"rte_flow_general_action" is vague as heck.

Seems like you made this structure so it could be extended later, but forgot
that doing so is not an option since ABIs are set in stone. You must make
new APIs as exhaustive and restrict their scope as much as possible from the
start because of that.

Note if you don't want to use union rte_flow_integer directly, it's also
fine to document your actions as taking (const rte_be32_t *) directly
through their conf pointer.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP header fields
  2019-04-18 12:30         ` Adrien Mazarguil
@ 2019-04-22  7:15           ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-22  7:15 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, arybchenko, dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Thursday, April 18, 2019 3:31 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com;
> dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: Re: [PATCH v4 1/3] ethdev: add actions to modify TCP header fields
> 
> On Wed, Apr 10, 2019 at 02:50:41PM +0300, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> >
> > Original work by Xiaoyu Min.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> 
> Almost there... Some changes were not made as discussed, please see
> below.
> 
> <snip>
> > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > b/doc/guides/prog_guide/rte_flow.rst
> > index 0203f4f..fc234de 100644
> > --- a/doc/guides/prog_guide/rte_flow.rst
> > +++ b/doc/guides/prog_guide/rte_flow.rst
> > @@ -2345,6 +2345,78 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> error will be returned.
> >     | ``mac_addr`` | MAC address   |
> >     +--------------+---------------+
> >
> > +Action: ``INC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase sequence number in the outermost TCP header.
> > +
> > +Using this action on non-matching traffic will result in undefined
> > +behavior, depending on PMD implementation.
> 
> OK, "depending on PMD implementation" looks a bit redundant though.

Fine, will remove it.

> 
> > +
> > +.. _table_rte_flow_action_inc_tcp_seq:
> > +
> > +.. table:: INC_TCP_SEQ
> > +
> > +   +-----------+------------------------------------------+
> > +   | Field     | Value                                    |
> > +
> +===========+==========================================+
> > +   | ``value`` | Value to increase TCP sequence number by |
> > +   +-----------+------------------------------------------+
> 
> Configuration object documentation needs updating since you changed its
> type and fields.
> 
> These comments also apply to DEC_TCP_SEQ, INC_TCP_ACK and
> DEC_TCP_ACK.

Will update.

> 
> <snip>
> > diff --git a/lib/librte_ethdev/rte_flow.h
> > b/lib/librte_ethdev/rte_flow.h index c0fe879..e3f6210 100644
> > --- a/lib/librte_ethdev/rte_flow.h
> > +++ b/lib/librte_ethdev/rte_flow.h
> > @@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
> >  	 * See struct rte_flow_action_set_mac.
> >  	 */
> >  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > +
> > +	/**
> > +	 * Increase sequence number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior, depending on PMD implementation.
> 
> "depending on PMD implementation" also redundant here.
> 
> <snip>
> >  /*
> > + * @warning
> > + * @b EXPERIMENTAL: this union may change without prior notice
> > + *
> > + * General integer type, can be expanded as needed.
> > + */
> > +union rte_flow_integer {
> > +	rte_be32_t be32;
> > +};
> 
> You must include the extra fields you don't use (64/16/32/8 and
> le/be/host/signed variants as described in previous messages) to limit the
> risk of ABI breakage next time someone needs a field that isn't there yet.
> 
> This object must be able to accommodate the largest supported integer and
> have the proper alignment constraints for any of these types, hence the
> union with all of them from the start.

I will add required fields for 8, 16 and 32 bits.
Adding 64 bit fields will inflate the union size, wasting memory.
It should be handled separately in specific cases.

> 
> > +
> > +/**
> > + * @warning
> > + * @b EXPERIMENTAL: this structure may change without prior notice
> > + *
> > + * General struct, for use by actions that require a single integer value.
> > + */
> > +struct rte_flow_general_action {
> > +	union rte_flow_integer integer;
> > +};
> 
> Seriously, why can't actions take "union rte_flow_integer" directly? Besides
> "rte_flow_general_action" is vague as heck.
> 

I prefer to follow the existing convention, where actions take struct even if it contains a single field.
I will define the union unnamed in the struct.
I will rename to rte_flow_integer_action.

> Seems like you made this structure so it could be extended later, but forgot
> that doing so is not an option since ABIs are set in stone. You must make new
> APIs as exhaustive and restrict their scope as much as possible from the start
> because of that.
> 
> Note if you don't want to use union rte_flow_integer directly, it's also fine to
> document your actions as taking (const rte_be32_t *) directly through their
> conf pointer.
> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields
  2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
                         ` (2 preceding siblings ...)
  2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-04-22 11:22       ` Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 1/3] ethdev: add actions to modify TCP " Dekel Peled
                           ` (4 more replies)
  3 siblings, 5 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-22 11:22 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  68 ++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  61 +++++++
 8 files changed, 509 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v5 1/3] ethdev: add actions to modify TCP header fields
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
@ 2019-04-22 11:22         ` " Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: " Dekel Peled
                           ` (3 subsequent siblings)
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-22 11:22 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 68 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 +++
 lib/librte_ethdev/rte_flow.h       | 61 ++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 0203f4f..a050853 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,74 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +----------+------------------------------------------+
+   | Field    | Value                                    |
+   +==========+==========================================+
+   | ``be32`` | Value to increase TCP sequence number by |
+   +----------+------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +----------+------------------------------------------+
+   | Field    | Value                                    |
+   +==========+==========================================+
+   | ``be32`` | Value to decrease TCP sequence number by |
+   +----------+------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +----------+------------------------------------------------+
+   | Field    | Value                                          |
+   +==========+================================================+
+   | ``be32`` | Value to increase TCP acknowledgment number by |
+   +----------+------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +----------+------------------------------------------------+
+   | Field    | Value                                          |
+   +==========+================================================+
+   | ``be32`` | Value to decrease TCP acknowledgment number by |
+   +----------+------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..d666d06 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(struct rte_flow_integer_action)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index c0fe879..e03ca58 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2122,6 +2162,27 @@ struct rte_flow_action_set_mac {
 	uint8_t mac_addr[ETHER_ADDR_LEN];
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * General struct, for use by actions that require a single integer value.
+ */
+struct rte_flow_integer_action {
+	union rte_flow_integer {
+		rte_be32_t	be32;
+		rte_le32_t	le32;
+		uint32_t	u32;
+		int32_t		i32;
+		rte_be16_t	be16;
+		rte_le16_t	le16;
+		uint16_t	u16;
+		int16_t		i16;
+		uint8_t		u8;
+		int8_t		i8;
+	} rte_flow_int;
+};
+
 /*
  * Definition of a single action.
  *
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v5 2/3] app/testpmd: add actions to modify TCP header fields
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-04-22 11:22         ` " Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
                           ` (2 subsequent siblings)
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-22 11:22 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 54ff175..3c66b10 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -273,6 +273,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -886,6 +894,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1048,6 +1060,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2855,6 +2891,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 5d4dc6f..f0a457b 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4000,6 +4000,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v5 3/3] net/mlx5: update modify header using Direct Verbs
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: " Dekel Peled
@ 2019-04-22 11:22         ` Dekel Peled
  2019-06-02  8:18         ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-04-22 11:22 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika, dekelp

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 9f47fd4..1d56911 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -113,6 +113,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -135,7 +139,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3862b26..4a87a4c 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -127,6 +127,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -552,6 +554,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_integer_action *conf =
+		(const struct rte_flow_integer_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->rte_flow_int.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_integer_action *conf =
+		(const struct rte_flow_integer_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->rte_flow_int.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1498,6 +1592,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2126,6 +2310,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3465,6 +3683,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index b15266f..a644369 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
                           ` (2 preceding siblings ...)
  2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-06-02  8:18         ` Dekel Peled
  2019-06-04  5:13           ` Dekel Peled
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
  4 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-06-02  8:18 UTC (permalink / raw)
  To: Adrien Mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, arybchenko, Yigit, Ferruh
  Cc: dev, Ori Kam

Hi, 

Please review/comment on v5 of this series so it can be accepted.
http://patches.dpdk.org/cover/52974/

Regards,
Dekel

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Monday, April 22, 2019 2:23 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [PATCH v5 0/3] add actions to modify header fields
> 
> Patch [1] implemented set of header modification actions in MLX PMD,
> based on ethdev and testpmd updates included in [2].
> This series implements support of additional header modification actions, in
> ethdev, testpmd, and MLX5 PMD.
> 
> Original work by Xiaoyu Min.
> 
> [1] http://patches.dpdk.org/patch/49310/
> [2] http://mails.dpdk.org/archives/dev/2018-August/109672.html
> 
> ---
> v2: apply code review comments.
> v3: apply additional code review comments.
>     - Update documentation of new commands.
>     - Use common general struct for all commands.
> v4: apply checkpatch comments.
> v5: apply additional code review comments.
>     - Add 8, 16, 32 bit types to union.
>     - Update struct name and documentation.
> ---
> 
> Dekel Peled (3):
>   ethdev: add actions to modify TCP header fields
>   app/testpmd: add actions to modify TCP header fields
>   net/mlx5: update modify header using Direct Verbs
> 
>  app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
>  doc/guides/prog_guide/rte_flow.rst          |  68 ++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
>  drivers/net/mlx5/mlx5_flow.h                |  10 +-
>  drivers/net/mlx5/mlx5_flow_dv.c             | 239
> ++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_prm.h                 |  12 ++
>  lib/librte_ethdev/rte_flow.c                |   4 +
>  lib/librte_ethdev/rte_flow.h                |  61 +++++++
>  8 files changed, 509 insertions(+), 1 deletion(-)
> 
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields
  2019-06-02  8:18         ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
@ 2019-06-04  5:13           ` Dekel Peled
  2019-06-04  8:14             ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-06-04  5:13 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, Ori Kam, Thomas Monjalon

Hi Adrien,

I understand that you might have some reservations about patch http://patches.dpdk.org/patch/52975/.
I'm preparing v6, with update documentation according to comments from Thomas.
In v5 I modified the struct rte_flow_integer_action, according to your comments in previous versions.
Please reply with any additional comments so I can push this series forward.

Regards,
Dekel

> -----Original Message-----
> From: Dekel Peled
> Sent: Sunday, June 2, 2019 11:18 AM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com; Yigit,
> Ferruh <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: RE: [PATCH v5 0/3] add actions to modify header fields
> 
> Hi,
> 
> Please review/comment on v5 of this series so it can be accepted.
> http://patches.dpdk.org/cover/52974/
> 
> Regards,
> Dekel
> 
> > -----Original Message-----
> > From: Dekel Peled <dekelp@mellanox.com>
> > Sent: Monday, April 22, 2019 2:23 PM
> > To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> > wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> > bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf
> > Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com
> > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> > <dekelp@mellanox.com>
> > Subject: [PATCH v5 0/3] add actions to modify header fields
> >
> > Patch [1] implemented set of header modification actions in MLX PMD,
> > based on ethdev and testpmd updates included in [2].
> > This series implements support of additional header modification
> > actions, in ethdev, testpmd, and MLX5 PMD.
> >
> > Original work by Xiaoyu Min.
> >
> > [1] http://patches.dpdk.org/patch/49310/
> > [2] http://mails.dpdk.org/archives/dev/2018-August/109672.html
> >
> > ---
> > v2: apply code review comments.
> > v3: apply additional code review comments.
> >     - Update documentation of new commands.
> >     - Use common general struct for all commands.
> > v4: apply checkpatch comments.
> > v5: apply additional code review comments.
> >     - Add 8, 16, 32 bit types to union.
> >     - Update struct name and documentation.
> > ---
> >
> > Dekel Peled (3):
> >   ethdev: add actions to modify TCP header fields
> >   app/testpmd: add actions to modify TCP header fields
> >   net/mlx5: update modify header using Direct Verbs
> >
> >  app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
> >  doc/guides/prog_guide/rte_flow.rst          |  68 ++++++++
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
> >  drivers/net/mlx5/mlx5_flow.h                |  10 +-
> >  drivers/net/mlx5/mlx5_flow_dv.c             | 239
> > ++++++++++++++++++++++++++++
> >  drivers/net/mlx5/mlx5_prm.h                 |  12 ++
> >  lib/librte_ethdev/rte_flow.c                |   4 +
> >  lib/librte_ethdev/rte_flow.h                |  61 +++++++
> >  8 files changed, 509 insertions(+), 1 deletion(-)
> >
> > --
> > 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields
  2019-06-04  5:13           ` Dekel Peled
@ 2019-06-04  8:14             ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-04  8:14 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev, Ori Kam, Thomas Monjalon

Hi Adrien (again ;-)

To clarify, I'm working on v6 but will not send it yet.
I'm waiting for your comments on v5, and will send v6 only after getting all comments.

Regards,
Dekel


> -----Original Message-----
> From: Dekel Peled
> Sent: Tuesday, June 4, 2019 8:13 AM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Thomas Monjalon
> <thomasm@mellanox.com>
> Subject: RE: [PATCH v5 0/3] add actions to modify header fields
> 
> Hi Adrien,
> 
> I understand that you might have some reservations about patch
> http://patches.dpdk.org/patch/52975/.
> I'm preparing v6, with update documentation according to comments from
> Thomas.
> In v5 I modified the struct rte_flow_integer_action, according to your
> comments in previous versions.
> Please reply with any additional comments so I can push this series forward.
> 
> Regards,
> Dekel
> 
> > -----Original Message-----
> > From: Dekel Peled
> > Sent: Sunday, June 2, 2019 11:18 AM
> > To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> > wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> > bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf
> > Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com; Yigit,
> > Ferruh <ferruh.yigit@intel.com>
> > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> > Subject: RE: [PATCH v5 0/3] add actions to modify header fields
> >
> > Hi,
> >
> > Please review/comment on v5 of this series so it can be accepted.
> > http://patches.dpdk.org/cover/52974/
> >
> > Regards,
> > Dekel
> >
> > > -----Original Message-----
> > > From: Dekel Peled <dekelp@mellanox.com>
> > > Sent: Monday, April 22, 2019 2:23 PM
> > > To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> > > wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> > > bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> > Shahaf
> > > Shuler <shahafs@mellanox.com>; arybchenko@solarflare.com
> > > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> > > <dekelp@mellanox.com>
> > > Subject: [PATCH v5 0/3] add actions to modify header fields
> > >
> > > Patch [1] implemented set of header modification actions in MLX PMD,
> > > based on ethdev and testpmd updates included in [2].
> > > This series implements support of additional header modification
> > > actions, in ethdev, testpmd, and MLX5 PMD.
> > >
> > > Original work by Xiaoyu Min.
> > >
> > > [1] http://patches.dpdk.org/patch/49310/
> > > [2] http://mails.dpdk.org/archives/dev/2018-August/109672.html
> > >
> > > ---
> > > v2: apply code review comments.
> > > v3: apply additional code review comments.
> > >     - Update documentation of new commands.
> > >     - Use common general struct for all commands.
> > > v4: apply checkpatch comments.
> > > v5: apply additional code review comments.
> > >     - Add 8, 16, 32 bit types to union.
> > >     - Update struct name and documentation.
> > > ---
> > >
> > > Dekel Peled (3):
> > >   ethdev: add actions to modify TCP header fields
> > >   app/testpmd: add actions to modify TCP header fields
> > >   net/mlx5: update modify header using Direct Verbs
> > >
> > >  app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
> > >  doc/guides/prog_guide/rte_flow.rst          |  68 ++++++++
> > >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
> > >  drivers/net/mlx5/mlx5_flow.h                |  10 +-
> > >  drivers/net/mlx5/mlx5_flow_dv.c             | 239
> > > ++++++++++++++++++++++++++++
> > >  drivers/net/mlx5/mlx5_prm.h                 |  12 ++
> > >  lib/librte_ethdev/rte_flow.c                |   4 +
> > >  lib/librte_ethdev/rte_flow.h                |  61 +++++++
> > >  8 files changed, 509 insertions(+), 1 deletion(-)
> > >
> > > --
> > > 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v6 0/3] add actions to modify header fields
  2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
                           ` (3 preceding siblings ...)
  2019-06-02  8:18         ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
@ 2019-06-17  6:12         ` " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 1/3] ethdev: add actions to modify TCP " Dekel Peled
                             ` (4 more replies)
  4 siblings, 5 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-17  6:12 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika

Patch [1] implemented set of header modification actions in MLX PMD,
based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification
actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
v6: expand description of new struct in h file and commit log.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  68 ++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 239 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  64 ++++++++
 8 files changed, 512 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v6 1/3] ethdev: add actions to modify TCP header fields
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
@ 2019-06-17  6:12           ` " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: " Dekel Peled
                             ` (3 subsequent siblings)
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-17  6:12 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Add struct rte_flow_integer_action, containing a union of integers of
all types and sizes, up to 32 bit.
Intended for use by actions that require a single integer value,
instead of using an action-specific structure for each of these
actions.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 68 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 +++
 lib/librte_ethdev/rte_flow.h       | 64 +++++++++++++++++++++++++++++++++++
 3 files changed, 136 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index a34d012..eeb9ddc 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2345,6 +2345,74 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_inc_tcp_seq:
+
+.. table:: INC_TCP_SEQ
+
+   +----------+------------------------------------------+
+   | Field    | Value                                    |
+   +==========+==========================================+
+   | ``be32`` | Value to increase TCP sequence number by |
+   +----------+------------------------------------------+
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_dec_tcp_seq:
+
+.. table:: DEC_TCP_SEQ
+
+   +----------+------------------------------------------+
+   | Field    | Value                                    |
+   +==========+==========================================+
+   | ``be32`` | Value to decrease TCP sequence number by |
+   +----------+------------------------------------------+
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_inc_tcp_ack:
+
+.. table:: INC_TCP_ACK
+
+   +----------+------------------------------------------------+
+   | Field    | Value                                          |
+   +==========+================================================+
+   | ``be32`` | Value to increase TCP acknowledgment number by |
+   +----------+------------------------------------------------+
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+.. _table_rte_flow_action_dec_tcp_ack:
+
+.. table:: DEC_TCP_ACK
+
+   +----------+------------------------------------------------+
+   | Field    | Value                                          |
+   +==========+================================================+
+   | ``be32`` | Value to decrease TCP acknowledgment number by |
+   +----------+------------------------------------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..d666d06 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(struct rte_flow_integer_action)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(struct rte_flow_integer_action)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f3a8fb1..5dbd6cf 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1650,6 +1650,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2131,6 +2171,30 @@ struct rte_flow_action_set_mac {
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * General structure, containing a union of integers of all types
+ * and sizes, up to 32 bit.
+ * Intended for use by actions that require a single integer value,
+ * instead of using an action-specific structure for each of these actions.
+ */
+struct rte_flow_integer_action {
+	union rte_flow_integer {
+		rte_be32_t	be32;
+		rte_le32_t	le32;
+		uint32_t	u32;
+		int32_t		i32;
+		rte_be16_t	be16;
+		rte_le16_t	le16;
+		uint16_t	u16;
+		int16_t		i16;
+		uint8_t		u8;
+		int8_t		i8;
+	} rte_flow_int;
+};
+
 /*
  * Definition of a single action.
  *
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v6 2/3] app/testpmd: add actions to modify TCP header fields
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-06-17  6:12           ` " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
                             ` (2 subsequent siblings)
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-17  6:12 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index a3bbadd..8ce5ae1 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -272,6 +272,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -885,6 +893,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1047,6 +1059,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2854,6 +2890,70 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_integer_action)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_integer_action, rte_flow_int)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..49a9e15 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4106,6 +4106,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v6 3/3] net/mlx5: update modify header using Direct Verbs
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: " Dekel Peled
@ 2019-06-17  6:12           ` Dekel Peled
  2019-06-27 17:39           ` [dpdk-dev] [PATCH v7 0/3] add actions to modify header fields Dekel Peled
       [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
  4 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-17  6:12 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, arybchenko
  Cc: dev, orika

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 239 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index b665420..dc4a56a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -114,6 +114,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -140,7 +144,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index d096b02..28c3594 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -561,6 +563,98 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_integer_action *conf =
+		(const struct rte_flow_integer_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->rte_flow_int.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const struct rte_flow_integer_action *conf =
+		(const struct rte_flow_integer_action *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(conf->rte_flow_int.be32);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1668,6 +1762,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2416,6 +2600,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3895,6 +4113,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 602a5ac..c2fb654 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -336,6 +336,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v7 0/3] add actions to modify header fields
  2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
                             ` (2 preceding siblings ...)
  2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-06-27 17:39           ` Dekel Peled
  2019-06-30  7:59             ` [dpdk-dev] [PATCH v8 " Dekel Peled
       [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
  4 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-06-27 17:39 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Patch [1] implemented set of header modification actions in MLX PMD,
based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification
actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
v6: expand description of new struct in h file and commit log.
v7: - Remove the common general struct with union added in v3 & v5.
    - Commands take a simple integer value, not enclosed in a structure.
    - Use separate commands for INC and DEC to allow full use of
      the 32 bit value as unsigned.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  35 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 237 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  42 ++++-
 8 files changed, 453 insertions(+), 3 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields
       [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
@ 2019-06-27 17:39             ` Dekel Peled
  2019-06-27 17:54               ` Andrew Rybchenko
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 2/3] app/testpmd: " Dekel Peled
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-06-27 17:39 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

This patch introduces a new approach, using a simple integer instead
of using an action-specific structure for each of these actions.
This approach can be later applied to modify existing actions which
require only a single integer.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++++++++++++++-
 lib/librte_ethdev/rte_flow.c       |  4 ++++
 lib/librte_ethdev/rte_flow.h       | 42 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index a34d012..783a904 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1214,7 +1214,8 @@ Actions
 ~~~~~~~
 
 Each possible action is represented by a type. Some have associated
-configuration structures. Several actions combined in a list can be assigned
+configuration structures, some others use a simple integer.
+Several actions combined in a list can be assigned
 to a flow rule and are performed in order.
 
 They fall in three categories:
@@ -2345,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+Value to increase TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+Value to decrease TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..0c9f6c6 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f3a8fb1..8c962d0 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1650,6 +1650,46 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 *
+	 * See struct rte_flow_integer_action.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2140,7 +2180,7 @@ struct rte_flow_action_set_mac {
  */
 struct rte_flow_action {
 	enum rte_flow_action_type type; /**< Action type. */
-	const void *conf; /**< Pointer to action configuration structure. */
+	const void *conf; /**< Pointer to action configuration. */
 };
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v7 2/3] app/testpmd: add actions to modify TCP header fields
       [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
@ 2019-06-27 17:39             ` " Dekel Peled
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-27 17:39 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

This patch introduces a new macro ARG_ENTRY_HTON, to allow using
a single argument, not enclosed in a structure.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 201bd9d..e644efa 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -272,6 +272,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -485,6 +493,14 @@ struct token {
 		.size = sizeof(((s *)0)->f), \
 	})
 
+/** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
+#define ARG_ENTRY_HTON(s) \
+	(&(const struct arg){ \
+		.hton = 1, \
+		.offset = 0, \
+		.size = sizeof(s), \
+	})
+
 /** Parser output buffer layout expected by cmd_flow_parsed(). */
 struct buffer {
 	enum index command; /**< Flow command. */
@@ -885,6 +901,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1047,6 +1067,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2854,6 +2898,62 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..49a9e15 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4106,6 +4106,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v7 3/3] net/mlx5: update modify header using Direct Verbs
       [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 2/3] app/testpmd: " Dekel Peled
@ 2019-06-27 17:39             ` Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-27 17:39 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 237 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 258 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index b665420..dc4a56a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -114,6 +114,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -140,7 +144,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 933ad0b..8f64182 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -561,6 +563,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1668,6 +1760,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2416,6 +2598,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3895,6 +4111,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 1a19958..7482383 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -347,6 +347,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields
  2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
@ 2019-06-27 17:54               ` Andrew Rybchenko
  2019-06-28 16:18                 ` Adrien Mazarguil
  0 siblings, 1 reply; 76+ messages in thread
From: Andrew Rybchenko @ 2019-06-27 17:54 UTC (permalink / raw)
  To: Dekel Peled, adrien.mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, yskoh, shahafs, viacheslavo
  Cc: dev, orika

On 6/27/19 8:39 PM, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
>
> Original work by Xiaoyu Min.
>
> This patch introduces a new approach, using a simple integer instead
> of using an action-specific structure for each of these actions.
> This approach can be later applied to modify existing actions which
> require only a single integer.

If we allow it, may be we should fix at least experimental API and
remove dummy structures.

I think ideally it should be a pre-patch which allows to avoid structures.
Right now it is a mixture of two logical changes.

> Signed-off-by: Dekel Peled <dekelp@mellanox.com>

A nit below (plus above), other than that
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>


[...]

> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index f3a8fb1..8c962d0 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1650,6 +1650,46 @@ enum rte_flow_action_type {
>   	 * See struct rte_flow_action_set_mac.
>   	 */
>   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 *
> +	 * See struct rte_flow_integer_action.

There is no  rte_flow_integer_action, please, fix.

[...]

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields
  2019-06-27 17:54               ` Andrew Rybchenko
@ 2019-06-28 16:18                 ` Adrien Mazarguil
  0 siblings, 0 replies; 76+ messages in thread
From: Adrien Mazarguil @ 2019-06-28 16:18 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: Dekel Peled, wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh,
	shahafs, viacheslavo, dev, orika

On Thu, Jun 27, 2019 at 08:54:57PM +0300, Andrew Rybchenko wrote:
> On 6/27/19 8:39 PM, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> > 
> > Original work by Xiaoyu Min.
> > 
> > This patch introduces a new approach, using a simple integer instead
> > of using an action-specific structure for each of these actions.
> > This approach can be later applied to modify existing actions which
> > require only a single integer.
> 
> If we allow it, may be we should fix at least experimental API and
> remove dummy structures.
>
> I think ideally it should be a pre-patch which allows to avoid structures.
> Right now it is a mixture of two logical changes.

Yep, I agree we need to split patches and affected experimental APIs should
be modified as well, although the latter part can be done in a third patch,
possibly a whole separate series since a number of "fix" patches might be
needed. This series has been waiting long enough already.

> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> 
> A nit below (plus above), other than that
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>

Ditto, otherwise looks good to me too, we're almost there!

Dekel: this looks so much cleaner without those pesky structures :)

> [...]
> 
> > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> > index f3a8fb1..8c962d0 100644
> > --- a/lib/librte_ethdev/rte_flow.h
> > +++ b/lib/librte_ethdev/rte_flow.h
> > @@ -1650,6 +1650,46 @@ enum rte_flow_action_type {
> >   	 * See struct rte_flow_action_set_mac.
> >   	 */
> >   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > +
> > +	/**
> > +	 * Increase sequence number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior.
> > +	 *
> > +	 * See struct rte_flow_integer_action.
> 
> There is no  rte_flow_integer_action, please, fix.
> 
> [...]

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v8 0/3] add actions to modify header fields
  2019-06-27 17:39           ` [dpdk-dev] [PATCH v7 0/3] add actions to modify header fields Dekel Peled
@ 2019-06-30  7:59             ` " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP " Dekel Peled
                                 ` (2 more replies)
  0 siblings, 3 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-30  7:59 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Patch [1] implemented set of header modification actions in MLX PMD,
based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification
actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
v6: expand description of new struct in h file and commit log.
v7: - Remove the common general struct with union added in v3 & v5.
    - Commands take a simple integer value, not enclosed in a structure.
    - Use separate commands for INC and DEC to allow full use of
      the 32 bit value as unsigned.
v8: clean redundant comments refering to removed structure.      
---
      
Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  35 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 237 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  34 +++-
 8 files changed, 445 insertions(+), 3 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP header fields
  2019-06-30  7:59             ` [dpdk-dev] [PATCH v8 " Dekel Peled
@ 2019-06-30  7:59               ` " Dekel Peled
  2019-07-01  8:55                 ` Adrien Mazarguil
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 2/3] app/testpmd: " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-06-30  7:59 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

This patch introduces a new approach, using a simple integer instead
of using an action-specific structure for each of these actions.
This approach can be later applied to modify existing actions which
require only a single integer.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++++++++++++++++++-
 lib/librte_ethdev/rte_flow.c       |  4 ++++
 lib/librte_ethdev/rte_flow.h       | 34 +++++++++++++++++++++++++++++++++-
 3 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index a34d012..783a904 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1214,7 +1214,8 @@ Actions
 ~~~~~~~
 
 Each possible action is represented by a type. Some have associated
-configuration structures. Several actions combined in a list can be assigned
+configuration structures, some others use a simple integer.
+Several actions combined in a list can be assigned
 to a flow rule and are performed in order.
 
 They fall in three categories:
@@ -2345,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+Value to increase TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+Value to decrease TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..0c9f6c6 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f3a8fb1..f5db6b6 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1650,6 +1650,38 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
@@ -2140,7 +2172,7 @@ struct rte_flow_action_set_mac {
  */
 struct rte_flow_action {
 	enum rte_flow_action_type type; /**< Action type. */
-	const void *conf; /**< Pointer to action configuration structure. */
+	const void *conf; /**< Pointer to action configuration. */
 };
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v8 2/3] app/testpmd: add actions to modify TCP header fields
  2019-06-30  7:59             ` [dpdk-dev] [PATCH v8 " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-06-30  7:59               ` " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-30  7:59 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

This patch introduces a new macro ARG_ENTRY_HTON, to allow using
a single argument, not enclosed in a structure.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 201bd9d..e644efa 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -272,6 +272,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -485,6 +493,14 @@ struct token {
 		.size = sizeof(((s *)0)->f), \
 	})
 
+/** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
+#define ARG_ENTRY_HTON(s) \
+	(&(const struct arg){ \
+		.hton = 1, \
+		.offset = 0, \
+		.size = sizeof(s), \
+	})
+
 /** Parser output buffer layout expected by cmd_flow_parsed(). */
 struct buffer {
 	enum index command; /**< Flow command. */
@@ -885,6 +901,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1047,6 +1067,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2854,6 +2898,62 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..49a9e15 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4106,6 +4106,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v8 3/3] net/mlx5: update modify header using Direct Verbs
  2019-06-30  7:59             ` [dpdk-dev] [PATCH v8 " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 2/3] app/testpmd: " Dekel Peled
@ 2019-06-30  7:59               ` Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-06-30  7:59 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c | 237 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h     |  12 ++
 3 files changed, 258 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index b665420..dc4a56a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -114,6 +114,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -140,7 +144,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 933ad0b..8f64182 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -561,6 +563,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1668,6 +1760,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2416,6 +2598,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3895,6 +4111,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 1a19958..7482383 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -347,6 +347,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP header fields
  2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-07-01  8:55                 ` Adrien Mazarguil
  2019-07-01  9:58                   ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-07-01  8:55 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs,
	viacheslavo, arybchenko, dev, orika

On Sun, Jun 30, 2019 at 10:59:08AM +0300, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> This patch introduces a new approach, using a simple integer instead
> of using an action-specific structure for each of these actions.
> This approach can be later applied to modify existing actions which
> require only a single integer.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>

You didn't take Andrew's comment [1] into account, this patch must be
split. I'll highlight what needs to be moved to a pre-patch below.

[1] https://mails.dpdk.org/archives/dev/2019-June/136101.html

[...]
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index a34d012..783a904 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -1214,7 +1214,8 @@ Actions
>  ~~~~~~~
>  
>  Each possible action is represented by a type. Some have associated
> -configuration structures. Several actions combined in a list can be assigned
> +configuration structures, some others use a simple integer.
> +Several actions combined in a list can be assigned
>  to a flow rule and are performed in order.

^^^^ This must be moved to a separate patch ^^^^

BTW, how about "configuration structure" -> "configuration object"
encompassing all kinds of objects once and for all instead? Such a generic
term will be handy when actions start using floats or function pointers.

[...]
>  /**
> @@ -2140,7 +2172,7 @@ struct rte_flow_action_set_mac {
>   */
>  struct rte_flow_action {
>  	enum rte_flow_action_type type; /**< Action type. */
> -	const void *conf; /**< Pointer to action configuration structure. */
> +	const void *conf; /**< Pointer to action configuration. */
>  };

^^^^ This must be moved to a separate patch ^^^^

Same comment regarding "configuration object".

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP header fields
  2019-07-01  8:55                 ` Adrien Mazarguil
@ 2019-07-01  9:58                   ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-01  9:58 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, Yongseok Koh,
	Shahaf Shuler, Slava Ovsiienko, arybchenko, dev, Ori Kam

Accepted, will send separate patch and v9 later today.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Monday, July 1, 2019 11:55 AM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; arybchenko@solarflare.com; dev@dpdk.org;
> Ori Kam <orika@mellanox.com>
> Subject: Re: [PATCH v8 1/3] ethdev: add actions to modify TCP header fields
> 
> On Sun, Jun 30, 2019 at 10:59:08AM +0300, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> >
> > Original work by Xiaoyu Min.
> >
> > This patch introduces a new approach, using a simple integer instead
> > of using an action-specific structure for each of these actions.
> > This approach can be later applied to modify existing actions which
> > require only a single integer.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> 
> You didn't take Andrew's comment [1] into account, this patch must be split.
> I'll highlight what needs to be moved to a pre-patch below.
> 
> [1]
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmails.
> dpdk.org%2Farchives%2Fdev%2F2019-
> June%2F136101.html&amp;data=02%7C01%7Cdekelp%40mellanox.com%7C0
> 353d4fafe004b4434a608d6fe01d04c%7Ca652971c7d2e4d9ba6a4d149256f461b
> %7C0%7C0%7C636975681078705620&amp;sdata=wrMFZOMT65S6X6d4vTnsF
> AAyRF%2F2dTnonX4Ozy7S930%3D&amp;reserved=0
> 
> [...]
> > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > b/doc/guides/prog_guide/rte_flow.rst
> > index a34d012..783a904 100644
> > --- a/doc/guides/prog_guide/rte_flow.rst
> > +++ b/doc/guides/prog_guide/rte_flow.rst
> > @@ -1214,7 +1214,8 @@ Actions
> >  ~~~~~~~
> >
> >  Each possible action is represented by a type. Some have associated
> > -configuration structures. Several actions combined in a list can be
> > assigned
> > +configuration structures, some others use a simple integer.
> > +Several actions combined in a list can be assigned
> >  to a flow rule and are performed in order.
> 
> ^^^^ This must be moved to a separate patch ^^^^
> 
> BTW, how about "configuration structure" -> "configuration object"
> encompassing all kinds of objects once and for all instead? Such a generic
> term will be handy when actions start using floats or function pointers.
> 
> [...]
> >  /**
> > @@ -2140,7 +2172,7 @@ struct rte_flow_action_set_mac {
> >   */
> >  struct rte_flow_action {
> >  	enum rte_flow_action_type type; /**< Action type. */
> > -	const void *conf; /**< Pointer to action configuration structure. */
> > +	const void *conf; /**< Pointer to action configuration. */
> >  };
> 
> ^^^^ This must be moved to a separate patch ^^^^
> 
> Same comment regarding "configuration object".
> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (6 preceding siblings ...)
  2019-04-02 15:13 ` [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-07-01 15:43 ` Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP " Dekel Peled
                     ` (2 more replies)
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
  8 siblings, 3 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-01 15:43 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
v6: expand description of new struct in h file and commit log.
v7: - Remove the common general struct with union added in v3 & v5.
    - Commands take a simple integer value, not enclosed in a structure.
    - Use separate commands for INC and DEC with 32 bit unsigned value
      of type rte_be32_t.
v8: clean redundant comments refering to removed structure.
v9: - Send the announcement of new approach (use action with single
      argument configuration) in separate patch before this series,
      see http://patches.dpdk.org/patch/55773/.
    - Add PMD release notes update.
---


Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 |  92 +++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  32 ++++
 doc/guides/rel_notes/release_19_08.rst      |   6 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 237 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  32 ++++
 9 files changed, 440 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP header fields
  2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
@ 2019-07-01 15:43   ` " Dekel Peled
  2019-07-02  8:14     ` Andrew Rybchenko
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 2/3] app/testpmd: " Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-07-01 15:43 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

This patch uses the new approach introduced by [1], using a simple
integer instead of using an action-specific structure for each of
the new actions.

[1] http://patches.dpdk.org/patch/55773/

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/prog_guide/rte_flow.rst | 32 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 ++++
 lib/librte_ethdev/rte_flow.h       | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 67deed7..bbe32db 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+Value to increase TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+Value to decrease TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..0c9f6c6 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 2232856..28445f4 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,38 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v9 2/3] app/testpmd: add actions to modify TCP header fields
  2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-07-01 15:43   ` " Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-01 15:43 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

This patch uses the new approach introduced by [1], using the new
macro ARG_ENTRY_HTON to pass a single integer argument to each of
the new actions.

[1] http://patches.dpdk.org/patch/55773/

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 92 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 16 +++++
 2 files changed, 108 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fa7bd13..e644efa 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -272,6 +272,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -893,6 +901,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1055,6 +1067,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2862,6 +2898,62 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..49a9e15 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4106,6 +4106,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v9 3/3] net/mlx5: update modify header using Direct Verbs
  2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 2/3] app/testpmd: " Dekel Peled
@ 2019-07-01 15:43   ` Dekel Peled
  2 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-01 15:43 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/rel_notes/release_19_08.rst |   6 +
 drivers/net/mlx5/mlx5_flow.h           |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c        | 237 +++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h            |  12 ++
 4 files changed, 264 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 3da2667..85a208d 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -99,6 +99,12 @@ New Features
   Updated ``librte_telemetry`` to fetch the global metrics from the
   ``librte_metrics`` library.
 
+* **Updated Mellanox mlx5 driver.**
+
+  Updated Mellanox mlx5 driver with new features and improvements, including:
+
+  * Updated the packet header modification feature. Added support of TCP header
+    sequence number and acknowledgment number modification.
 
 Removed Items
 -------------
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index b665420..dc4a56a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -114,6 +114,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -140,7 +144,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 933ad0b..8f64182 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -561,6 +563,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1668,6 +1760,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2416,6 +2598,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3895,6 +4111,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 1a19958..7482383 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -347,6 +347,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP header fields
  2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-07-02  8:14     ` Andrew Rybchenko
  2019-07-02  9:52       ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Andrew Rybchenko @ 2019-07-02  8:14 UTC (permalink / raw)
  To: Dekel Peled, adrien.mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

On 01.07.2019 18:43, Dekel Peled wrote:
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
>
> Original work by Xiaoyu Min.
>
> This patch uses the new approach introduced by [1], using a simple
> integer instead of using an action-specific structure for each of
> the new actions.
>
> [1] http://patches.dpdk.org/patch/55773/
>
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
>   doc/guides/prog_guide/rte_flow.rst | 32 ++++++++++++++++++++++++++++++++
>   lib/librte_ethdev/rte_flow.c       |  4 ++++
>   lib/librte_ethdev/rte_flow.h       | 32 ++++++++++++++++++++++++++++++++
>   3 files changed, 68 insertions(+)
>
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index 67deed7..bbe32db 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
>      | ``mac_addr`` | MAC address   |
>      +--------------+---------------+
>   
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +Value to increase TCP sequence number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``DEC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease sequence number in the outermost TCP header.
> +Value to decrease TCP sequence number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``INC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase acknowledgment number in the outermost TCP header.
> +Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``DEC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease acknowledgment number in the outermost TCP header.
> +Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
>   Negative types
>   ~~~~~~~~~~~~~~
>   
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
> index 3277be1..0c9f6c6 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -143,6 +143,10 @@ struct rte_flow_desc_data {
>   	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
>   	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
>   	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
> +	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
>   };
>   
>   static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index 2232856..28445f4 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,38 @@ enum rte_flow_action_type {
>   	 * See struct rte_flow_action_set_mac.
>   	 */
>   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> +
> +	/**
> +	 * Decrease sequence number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> +
> +	/**
> +	 * Increase acknowledgment number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> +
> +	/**
> +	 * Decrease acknowledgment number in the outermost TCP header.
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
>   };
>   
>   /**

Other actions have type of configuration data description in a comment just
before the action enum element. I'm not sure why it is skipped here.
It is really vital information.



^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP header fields
  2019-07-02  8:14     ` Andrew Rybchenko
@ 2019-07-02  9:52       ` Dekel Peled
  2019-07-02 10:33         ` Adrien Mazarguil
  0 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-07-02  9:52 UTC (permalink / raw)
  To: Andrew Rybchenko, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler, Slava Ovsiienko
  Cc: dev, Ori Kam

Thanks, PSB

> -----Original Message-----
> From: Andrew Rybchenko <arybchenko@solarflare.com>
> Sent: Tuesday, July 2, 2019 11:14 AM
> To: Dekel Peled <dekelp@mellanox.com>; Adrien Mazarguil
> <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>; Slava
> Ovsiienko <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP
> header fields
> 
> On 01.07.2019 18:43, Dekel Peled wrote:
> > Add actions:
> > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> header.
> > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > 		header.
> > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > 		header.
> >
> > Original work by Xiaoyu Min.
> >
> > This patch uses the new approach introduced by [1], using a simple
> > integer instead of using an action-specific structure for each of the
> > new actions.
> >
> > [1]
> >
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
> >
> es.dpdk.org%2Fpatch%2F55773%2F&amp;data=02%7C01%7Cdekelp%40mell
> anox.co
> >
> m%7Cae3a2667c3a243a9c1e508d6fec54a22%7Ca652971c7d2e4d9ba6a4d1492
> 56f461
> >
> b%7C0%7C0%7C636976520663069258&amp;sdata=1z3uDQGnnyPZH9NAUuY5
> 0ZSg3smyZ
> > nDmc3QZtuNTmyg%3D&amp;reserved=0
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > ---
> >   doc/guides/prog_guide/rte_flow.rst | 32
> ++++++++++++++++++++++++++++++++
> >   lib/librte_ethdev/rte_flow.c       |  4 ++++
> >   lib/librte_ethdev/rte_flow.h       | 32
> ++++++++++++++++++++++++++++++++
> >   3 files changed, 68 insertions(+)
> >
> > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > b/doc/guides/prog_guide/rte_flow.rst
> > index 67deed7..bbe32db 100644
> > --- a/doc/guides/prog_guide/rte_flow.rst
> > +++ b/doc/guides/prog_guide/rte_flow.rst
> > @@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> error will be returned.
> >      | ``mac_addr`` | MAC address   |
> >      +--------------+---------------+
> >
> > +Action: ``INC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase sequence number in the outermost TCP header.
> > +Value to increase TCP sequence number by is a big-endian 32 bit integer.
> > +
> > +Using this action on non-matching traffic will result in undefined behavior.
> > +
> > +Action: ``DEC_TCP_SEQ``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Decrease sequence number in the outermost TCP header.
> > +Value to decrease TCP sequence number by is a big-endian 32 bit integer.
> > +
> > +Using this action on non-matching traffic will result in undefined behavior.
> > +
> > +Action: ``INC_TCP_ACK``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Increase acknowledgment number in the outermost TCP header.
> > +Value to increase TCP acknowledgment number by is a big-endian 32 bit
> integer.
> > +
> > +Using this action on non-matching traffic will result in undefined behavior.
> > +
> > +Action: ``DEC_TCP_ACK``
> > +^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +Decrease acknowledgment number in the outermost TCP header.
> > +Value to decrease TCP acknowledgment number by is a big-endian 32 bit
> integer.
> > +
> > +Using this action on non-matching traffic will result in undefined behavior.
> > +
> >   Negative types
> >   ~~~~~~~~~~~~~~
> >
> > diff --git a/lib/librte_ethdev/rte_flow.c
> > b/lib/librte_ethdev/rte_flow.c index 3277be1..0c9f6c6 100644
> > --- a/lib/librte_ethdev/rte_flow.c
> > +++ b/lib/librte_ethdev/rte_flow.c
> > @@ -143,6 +143,10 @@ struct rte_flow_desc_data {
> >   	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
> >   	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> rte_flow_action_set_mac)),
> >   	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> > rte_flow_action_set_mac)),
> > +	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> > +	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> > +	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> > +	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
> >   };
> >
> >   static int
> > diff --git a/lib/librte_ethdev/rte_flow.h
> > b/lib/librte_ethdev/rte_flow.h index 2232856..28445f4 100644
> > --- a/lib/librte_ethdev/rte_flow.h
> > +++ b/lib/librte_ethdev/rte_flow.h
> > @@ -1651,6 +1651,38 @@ enum rte_flow_action_type {
> >   	 * See struct rte_flow_action_set_mac.
> >   	 */
> >   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > +
> > +	/**
> > +	 * Increase sequence number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior.
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> > +
> > +	/**
> > +	 * Decrease sequence number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior.
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> > +
> > +	/**
> > +	 * Increase acknowledgment number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior.
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> > +
> > +	/**
> > +	 * Decrease acknowledgment number in the outermost TCP header.
> > +	 *
> > +	 * Using this action on non-matching traffic will result in
> > +	 * undefined behavior.
> > +	 */
> > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
> >   };
> >
> >   /**
> 
> Other actions have type of configuration data description in a comment just
> before the action enum element. I'm not sure why it is skipped here.
> It is really vital information.
> 

I had the relevant struct name here, and removed it when I changed it to integer.
In the documentation doc/guides/prog_guide/rte_flow.rst  I added description, please see above.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP header fields
  2019-07-02  9:52       ` Dekel Peled
@ 2019-07-02 10:33         ` Adrien Mazarguil
  2019-07-02 12:01           ` Dekel Peled
  0 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-07-02 10:33 UTC (permalink / raw)
  To: Dekel Peled
  Cc: Andrew Rybchenko, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, Slava Ovsiienko, dev, Ori Kam

On Tue, Jul 02, 2019 at 09:52:40AM +0000, Dekel Peled wrote:
> Thanks, PSB
> 
> > -----Original Message-----
> > From: Andrew Rybchenko <arybchenko@solarflare.com>
> > Sent: Tuesday, July 2, 2019 11:14 AM
> > To: Dekel Peled <dekelp@mellanox.com>; Adrien Mazarguil
> > <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> > jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> > <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>; Slava
> > Ovsiienko <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> > Subject: Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP
> > header fields
> > 
> > On 01.07.2019 18:43, Dekel Peled wrote:
> > > Add actions:
> > > - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> > > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> > header.
> > > - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> > > 		header.
> > > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> > > 		header.
> > >
> > > Original work by Xiaoyu Min.
> > >
> > > This patch uses the new approach introduced by [1], using a simple
> > > integer instead of using an action-specific structure for each of the
> > > new actions.
> > >
> > > [1]
> > >
> > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
> > >
> > es.dpdk.org%2Fpatch%2F55773%2F&amp;data=02%7C01%7Cdekelp%40mell
> > anox.co
> > >
> > m%7Cae3a2667c3a243a9c1e508d6fec54a22%7Ca652971c7d2e4d9ba6a4d1492
> > 56f461
> > >
> > b%7C0%7C0%7C636976520663069258&amp;sdata=1z3uDQGnnyPZH9NAUuY5
> > 0ZSg3smyZ
> > > nDmc3QZtuNTmyg%3D&amp;reserved=0
> > >
> > > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > > ---
> > >   doc/guides/prog_guide/rte_flow.rst | 32
> > ++++++++++++++++++++++++++++++++
> > >   lib/librte_ethdev/rte_flow.c       |  4 ++++
> > >   lib/librte_ethdev/rte_flow.h       | 32
> > ++++++++++++++++++++++++++++++++
> > >   3 files changed, 68 insertions(+)
> > >
> > > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > > b/doc/guides/prog_guide/rte_flow.rst
> > > index 67deed7..bbe32db 100644
> > > --- a/doc/guides/prog_guide/rte_flow.rst
> > > +++ b/doc/guides/prog_guide/rte_flow.rst
> > > @@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> > error will be returned.
> > >      | ``mac_addr`` | MAC address   |
> > >      +--------------+---------------+
> > >
> > > +Action: ``INC_TCP_SEQ``
> > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > +
> > > +Increase sequence number in the outermost TCP header.
> > > +Value to increase TCP sequence number by is a big-endian 32 bit integer.
> > > +
> > > +Using this action on non-matching traffic will result in undefined behavior.
> > > +
> > > +Action: ``DEC_TCP_SEQ``
> > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > +
> > > +Decrease sequence number in the outermost TCP header.
> > > +Value to decrease TCP sequence number by is a big-endian 32 bit integer.
> > > +
> > > +Using this action on non-matching traffic will result in undefined behavior.
> > > +
> > > +Action: ``INC_TCP_ACK``
> > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > +
> > > +Increase acknowledgment number in the outermost TCP header.
> > > +Value to increase TCP acknowledgment number by is a big-endian 32 bit
> > integer.
> > > +
> > > +Using this action on non-matching traffic will result in undefined behavior.
> > > +
> > > +Action: ``DEC_TCP_ACK``
> > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > +
> > > +Decrease acknowledgment number in the outermost TCP header.
> > > +Value to decrease TCP acknowledgment number by is a big-endian 32 bit
> > integer.
> > > +
> > > +Using this action on non-matching traffic will result in undefined behavior.
> > > +
> > >   Negative types
> > >   ~~~~~~~~~~~~~~
> > >
> > > diff --git a/lib/librte_ethdev/rte_flow.c
> > > b/lib/librte_ethdev/rte_flow.c index 3277be1..0c9f6c6 100644
> > > --- a/lib/librte_ethdev/rte_flow.c
> > > +++ b/lib/librte_ethdev/rte_flow.c
> > > @@ -143,6 +143,10 @@ struct rte_flow_desc_data {
> > >   	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
> > >   	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> > rte_flow_action_set_mac)),
> > >   	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> > > rte_flow_action_set_mac)),
> > > +	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> > > +	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> > > +	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> > > +	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
> > >   };
> > >
> > >   static int
> > > diff --git a/lib/librte_ethdev/rte_flow.h
> > > b/lib/librte_ethdev/rte_flow.h index 2232856..28445f4 100644
> > > --- a/lib/librte_ethdev/rte_flow.h
> > > +++ b/lib/librte_ethdev/rte_flow.h
> > > @@ -1651,6 +1651,38 @@ enum rte_flow_action_type {
> > >   	 * See struct rte_flow_action_set_mac.
> > >   	 */
> > >   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > > +
> > > +	/**
> > > +	 * Increase sequence number in the outermost TCP header.
> > > +	 *
> > > +	 * Using this action on non-matching traffic will result in
> > > +	 * undefined behavior.
> > > +	 */
> > > +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> > > +
> > > +	/**
> > > +	 * Decrease sequence number in the outermost TCP header.
> > > +	 *
> > > +	 * Using this action on non-matching traffic will result in
> > > +	 * undefined behavior.
> > > +	 */
> > > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> > > +
> > > +	/**
> > > +	 * Increase acknowledgment number in the outermost TCP header.
> > > +	 *
> > > +	 * Using this action on non-matching traffic will result in
> > > +	 * undefined behavior.
> > > +	 */
> > > +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> > > +
> > > +	/**
> > > +	 * Decrease acknowledgment number in the outermost TCP header.
> > > +	 *
> > > +	 * Using this action on non-matching traffic will result in
> > > +	 * undefined behavior.
> > > +	 */
> > > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
> > >   };
> > >
> > >   /**
> > 
> > Other actions have type of configuration data description in a comment just
> > before the action enum element. I'm not sure why it is skipped here.
> > It is really vital information.
> > 
> 
> I had the relevant struct name here, and removed it when I changed it to integer.
> In the documentation doc/guides/prog_guide/rte_flow.rst  I added description, please see above.

Yes, still Andrew is right, header documentation must be exhaustive.
Developers might use rte_flow.rst as reference and to understand the
underlying design but will definitely rely on rte_flow.h (and Doxygen) when
writing code.

I suggest something which describes types and how they are used a bit like
enum rte_flow_conv_op, e.g. for RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:

 [...]
 *
 * Action configuration specifies the value to decrease TCP acknowledgment
 * number as a big-endian 32 bit integer.
 *
 * @p conf type:
 * @code const rte_be32_t * @endcode
 */

I know other actions do not have the same format but we'll update them
eventually.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP header fields
  2019-07-02 10:33         ` Adrien Mazarguil
@ 2019-07-02 12:01           ` Dekel Peled
  0 siblings, 0 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-02 12:01 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: Andrew Rybchenko, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	Yongseok Koh, Shahaf Shuler, Slava Ovsiienko, dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Tuesday, July 2, 2019 1:33 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: Andrew Rybchenko <arybchenko@solarflare.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP
> header fields
> 
> On Tue, Jul 02, 2019 at 09:52:40AM +0000, Dekel Peled wrote:
> > Thanks, PSB
> >
> > > -----Original Message-----
> > > From: Andrew Rybchenko <arybchenko@solarflare.com>
> > > Sent: Tuesday, July 2, 2019 11:14 AM
> > > To: Dekel Peled <dekelp@mellanox.com>; Adrien Mazarguil
> > > <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> > > jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> > > <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>; Slava
> > > Ovsiienko <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> > > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> > > Subject: Re: [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify
> > > TCP header fields
> > >
> > > On 01.07.2019 18:43, Dekel Peled wrote:
> > > > Add actions:
> > > > - INC_TCP_SEQ - Increase sequence number in the outermost TCP
> header.
> > > > - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP
> > > header.
> > > > - INC_TCP_ACK - Increase acknowledgment number in the outermost
> TCP
> > > > 		header.
> > > > - DEC_TCP_ACK - Decrease acknowledgment number in the outermost
> TCP
> > > > 		header.
> > > >
> > > > Original work by Xiaoyu Min.
> > > >
> > > > This patch uses the new approach introduced by [1], using a simple
> > > > integer instead of using an action-specific structure for each of
> > > > the new actions.
> > > >
> > > > [1]
> > > >
> > > http://patch
> > > >
> > >
> es.dpdk.org%2Fpatch%2F55773%2F&amp;data=02%7C01%7Cdekelp%40mell
> > > anox.co
> > > >
> > >
> m%7Cae3a2667c3a243a9c1e508d6fec54a22%7Ca652971c7d2e4d9ba6a4d1492
> > > 56f461
> > > >
> > >
> b%7C0%7C0%7C636976520663069258&amp;sdata=1z3uDQGnnyPZH9NAUuY5
> > > 0ZSg3smyZ
> > > > nDmc3QZtuNTmyg%3D&amp;reserved=0
> > > >
> > > > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > > > ---
> > > >   doc/guides/prog_guide/rte_flow.rst | 32
> > > ++++++++++++++++++++++++++++++++
> > > >   lib/librte_ethdev/rte_flow.c       |  4 ++++
> > > >   lib/librte_ethdev/rte_flow.h       | 32
> > > ++++++++++++++++++++++++++++++++
> > > >   3 files changed, 68 insertions(+)
> > > >
> > > > diff --git a/doc/guides/prog_guide/rte_flow.rst
> > > > b/doc/guides/prog_guide/rte_flow.rst
> > > > index 67deed7..bbe32db 100644
> > > > --- a/doc/guides/prog_guide/rte_flow.rst
> > > > +++ b/doc/guides/prog_guide/rte_flow.rst
> > > > @@ -2346,6 +2346,38 @@ Otherwise,
> RTE_FLOW_ERROR_TYPE_ACTION
> > > error will be returned.
> > > >      | ``mac_addr`` | MAC address   |
> > > >      +--------------+---------------+
> > > >
> > > > +Action: ``INC_TCP_SEQ``
> > > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > > +
> > > > +Increase sequence number in the outermost TCP header.
> > > > +Value to increase TCP sequence number by is a big-endian 32 bit
> integer.
> > > > +
> > > > +Using this action on non-matching traffic will result in undefined
> behavior.
> > > > +
> > > > +Action: ``DEC_TCP_SEQ``
> > > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > > +
> > > > +Decrease sequence number in the outermost TCP header.
> > > > +Value to decrease TCP sequence number by is a big-endian 32 bit
> integer.
> > > > +
> > > > +Using this action on non-matching traffic will result in undefined
> behavior.
> > > > +
> > > > +Action: ``INC_TCP_ACK``
> > > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > > +
> > > > +Increase acknowledgment number in the outermost TCP header.
> > > > +Value to increase TCP acknowledgment number by is a big-endian 32
> > > > +bit
> > > integer.
> > > > +
> > > > +Using this action on non-matching traffic will result in undefined
> behavior.
> > > > +
> > > > +Action: ``DEC_TCP_ACK``
> > > > +^^^^^^^^^^^^^^^^^^^^^^^
> > > > +
> > > > +Decrease acknowledgment number in the outermost TCP header.
> > > > +Value to decrease TCP acknowledgment number by is a big-endian 32
> > > > +bit
> > > integer.
> > > > +
> > > > +Using this action on non-matching traffic will result in undefined
> behavior.
> > > > +
> > > >   Negative types
> > > >   ~~~~~~~~~~~~~~
> > > >
> > > > diff --git a/lib/librte_ethdev/rte_flow.c
> > > > b/lib/librte_ethdev/rte_flow.c index 3277be1..0c9f6c6 100644
> > > > --- a/lib/librte_ethdev/rte_flow.c
> > > > +++ b/lib/librte_ethdev/rte_flow.c
> > > > @@ -143,6 +143,10 @@ struct rte_flow_desc_data {
> > > >   	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
> > > >   	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> > > rte_flow_action_set_mac)),
> > > >   	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> > > > rte_flow_action_set_mac)),
> > > > +	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> > > > +	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> > > > +	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> > > > +	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
> > > >   };
> > > >
> > > >   static int
> > > > diff --git a/lib/librte_ethdev/rte_flow.h
> > > > b/lib/librte_ethdev/rte_flow.h index 2232856..28445f4 100644
> > > > --- a/lib/librte_ethdev/rte_flow.h
> > > > +++ b/lib/librte_ethdev/rte_flow.h
> > > > @@ -1651,6 +1651,38 @@ enum rte_flow_action_type {
> > > >   	 * See struct rte_flow_action_set_mac.
> > > >   	 */
> > > >   	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> > > > +
> > > > +	/**
> > > > +	 * Increase sequence number in the outermost TCP header.
> > > > +	 *
> > > > +	 * Using this action on non-matching traffic will result in
> > > > +	 * undefined behavior.
> > > > +	 */
> > > > +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> > > > +
> > > > +	/**
> > > > +	 * Decrease sequence number in the outermost TCP header.
> > > > +	 *
> > > > +	 * Using this action on non-matching traffic will result in
> > > > +	 * undefined behavior.
> > > > +	 */
> > > > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> > > > +
> > > > +	/**
> > > > +	 * Increase acknowledgment number in the outermost TCP header.
> > > > +	 *
> > > > +	 * Using this action on non-matching traffic will result in
> > > > +	 * undefined behavior.
> > > > +	 */
> > > > +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> > > > +
> > > > +	/**
> > > > +	 * Decrease acknowledgment number in the outermost TCP header.
> > > > +	 *
> > > > +	 * Using this action on non-matching traffic will result in
> > > > +	 * undefined behavior.
> > > > +	 */
> > > > +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
> > > >   };
> > > >
> > > >   /**
> > >
> > > Other actions have type of configuration data description in a
> > > comment just before the action enum element. I'm not sure why it is
> skipped here.
> > > It is really vital information.
> > >
> >
> > I had the relevant struct name here, and removed it when I changed it to
> integer.
> > In the documentation doc/guides/prog_guide/rte_flow.rst  I added
> description, please see above.
> 
> Yes, still Andrew is right, header documentation must be exhaustive.
> Developers might use rte_flow.rst as reference and to understand the
> underlying design but will definitely rely on rte_flow.h (and Doxygen) when
> writing code.
> 
> I suggest something which describes types and how they are used a bit like
> enum rte_flow_conv_op, e.g. for RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
> 
>  [...]
>  *
>  * Action configuration specifies the value to decrease TCP acknowledgment
>  * number as a big-endian 32 bit integer.
>  *
>  * @p conf type:
>  * @code const rte_be32_t * @endcode
>  */
> 
> I know other actions do not have the same format but we'll update them
> eventually.

Agree, I'll add this documentation.

> 
> --
> Adrien Mazarguil
> 6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields
  2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
                   ` (7 preceding siblings ...)
  2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
@ 2019-07-02 14:44 ` Dekel Peled
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP " Dekel Peled
                     ` (3 more replies)
  8 siblings, 4 replies; 76+ messages in thread
From: Dekel Peled @ 2019-07-02 14:44 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.

Original work by Xiaoyu Min.

[1] http://patches.dpdk.org/patch/49310/
[2] http://mails.dpdk.org/archives/dev/2018-August/109672.html

---
v2: apply code review comments.
v3: apply additional code review comments.
    - Update documentation of new commands.
    - Use common general struct for all commands.
v4: apply checkpatch comments.
v5: apply additional code review comments.
    - Add 8, 16, 32 bit types to union.
    - Update struct name and documentation.
v6: expand description of new struct in h file and commit log.
v7: - Remove the common general struct with union added in v3 & v5.
    - Commands take a simple integer value, not enclosed in a structure.
    - Use separate commands for INC and DEC with 32 bit unsigned value
      of type rte_be32_t.
v8: clean redundant comments refering to removed structure.
v9: - Send the announcement of new approach (use action with single
      argument configuration) in separate patch before this series,
      see http://patches.dpdk.org/patch/55773/.
    - Add PMD release notes update.
v10: - Reorder release notes update properly.
     - Update comments for doxygen.
---

Dekel Peled (3):
  ethdev: add actions to modify TCP header fields
  app/testpmd: add actions to modify TCP header fields
  net/mlx5: update modify header using Direct Verbs

 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++
 doc/guides/prog_guide/rte_flow.rst          |  32 ++++
 doc/guides/rel_notes/release_19_08.rst      |   7 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/mlx5/mlx5_flow.h                |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c             | 237 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h                 |  12 ++
 lib/librte_ethdev/rte_flow.c                |   4 +
 lib/librte_ethdev/rte_flow.h                |  56 +++++++
 9 files changed, 473 insertions(+), 1 deletion(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP header fields
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
@ 2019-07-02 14:44   ` " Dekel Peled
  2019-07-03  5:04     ` Slava Ovsiienko
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 2/3] app/testpmd: " Dekel Peled
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-07-02 14:44 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

This patch uses the new approach introduced by [1], using a simple
integer instead of using an action-specific structure for each of
the new actions.

[1] http://patches.dpdk.org/patch/55882/

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/prog_guide/rte_flow.rst | 32 ++++++++++++++++++++++
 lib/librte_ethdev/rte_flow.c       |  4 +++
 lib/librte_ethdev/rte_flow.h       | 56 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 67deed7..bbe32db 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
    | ``mac_addr`` | MAC address   |
    +--------------+---------------+
 
+Action: ``INC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase sequence number in the outermost TCP header.
+Value to increase TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_SEQ``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease sequence number in the outermost TCP header.
+Value to decrease TCP sequence number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``INC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Increase acknowledgment number in the outermost TCP header.
+Value to increase TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
+Action: ``DEC_TCP_ACK``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Decrease acknowledgment number in the outermost TCP header.
+Value to decrease TCP acknowledgment number by is a big-endian 32 bit integer.
+
+Using this action on non-matching traffic will result in undefined behavior.
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 3277be1..0c9f6c6 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -143,6 +143,10 @@ struct rte_flow_desc_data {
 	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
 	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)),
 	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)),
+	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
 };
 
 static int
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 2232856..bc41023 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -1651,6 +1651,62 @@ enum rte_flow_action_type {
 	 * See struct rte_flow_action_set_mac.
 	 */
 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+
+	/**
+	 * Increase sequence number in the outermost TCP header.
+	 *
+	 * Action configuration specifies the value to increase
+	 * TCP sequence number as a big-endian 32 bit integer.
+	 *
+	 * @p conf type:
+	 * @code rte_be32_t * @endcode
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
+
+	/**
+	 * Decrease sequence number in the outermost TCP header.
+	 *
+	 * Action configuration specifies the value to decrease
+	 * TCP sequence number as a big-endian 32 bit integer.
+	 *
+	 * @p conf type:
+	 * @code rte_be32_t * @endcode
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
+
+	/**
+	 * Increase acknowledgment number in the outermost TCP header.
+	 *
+	 * Action configuration specifies the value to increase
+	 * TCP acknowledgment number as a big-endian 32 bit integer.
+	 *
+	 * @p conf type:
+	 * @code rte_be32_t * @endcode
+
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
+
+	/**
+	 * Decrease acknowledgment number in the outermost TCP header.
+	 *
+	 * Action configuration specifies the value to decrease
+	 * TCP acknowledgment number as a big-endian 32 bit integer.
+	 *
+	 * @p conf type:
+	 * @code rte_be32_t * @endcode
+	 *
+	 * Using this action on non-matching traffic will result in
+	 * undefined behavior.
+	 */
+	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
 };
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v10 2/3] app/testpmd: add actions to modify TCP header fields
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-07-02 14:44   ` " Dekel Peled
  2019-07-03  6:30     ` Slava Ovsiienko
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
  2019-07-02 15:15   ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Adrien Mazarguil
  3 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-07-02 14:44 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

This patch uses the new approach introduced by [1], using a new
macro ARG_ENTRY_HTON to pass a single integer argument to each of
the new actions.

[1] http://patches.dpdk.org/patch/55882/

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 201bd9d..e644efa 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -272,6 +272,14 @@ enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -485,6 +493,14 @@ struct token {
 		.size = sizeof(((s *)0)->f), \
 	})
 
+/** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
+#define ARG_ENTRY_HTON(s) \
+	(&(const struct arg){ \
+		.hton = 1, \
+		.offset = 0, \
+		.size = sizeof(s), \
+	})
+
 /** Parser output buffer layout expected by cmd_flow_parsed(). */
 struct buffer {
 	enum index command; /**< Flow command. */
@@ -885,6 +901,10 @@ struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1047,6 +1067,30 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2854,6 +2898,62 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cb83a3c..49a9e15 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4106,6 +4106,22 @@ This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP " Dekel Peled
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 2/3] app/testpmd: " Dekel Peled
@ 2019-07-02 14:44   ` Dekel Peled
  2019-07-03  6:30     ` Slava Ovsiienko
  2019-07-02 15:15   ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Adrien Mazarguil
  3 siblings, 1 reply; 76+ messages in thread
From: Dekel Peled @ 2019-07-02 14:44 UTC (permalink / raw)
  To: adrien.mazarguil, wenzhuo.lu, jingjing.wu, bernard.iremonger,
	yskoh, shahafs, viacheslavo, arybchenko
  Cc: dev, orika

This patch implements additional actions of packet header
modifications.

Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
		header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
		header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 doc/guides/rel_notes/release_19_08.rst |   7 +
 drivers/net/mlx5/mlx5_flow.h           |  10 +-
 drivers/net/mlx5/mlx5_flow_dv.c        | 237 +++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_prm.h            |  12 ++
 4 files changed, 265 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 3da2667..450d22f 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -74,6 +74,13 @@ New Features
 
   * Enabled Tx outer/inner L3/L4 checksum offload.
 
+* **Updated Mellanox mlx5 driver.**
+
+  Updated Mellanox mlx5 driver with new features and improvements, including:
+
+  * Updated the packet header modification feature. Added support of TCP header
+    sequence number and acknowledgment number modification.
+
 * **Updated Solarflare network PMD.**
 
   Updated the Solarflare ``sfc_efx`` driver with changes including:
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index b665420..dc4a56a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -114,6 +114,10 @@
 #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
 #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
+#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
+#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
+#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
+#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -140,7 +144,11 @@
 				      MLX5_FLOW_ACTION_SET_TTL | \
 				      MLX5_FLOW_ACTION_DEC_TTL | \
 				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
-				      MLX5_FLOW_ACTION_SET_MAC_DST)
+				      MLX5_FLOW_ACTION_SET_MAC_DST | \
+				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
+				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
+				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
 
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 933ad0b..8f64182 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
 struct field_modify_info modify_tcp[] = {
 	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
 	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
+	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
+	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
 	{0, 0, 0},
 };
 
@@ -561,6 +563,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Convert modify-header increment/decrement TCP Sequence number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_seq
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
+ * Convert modify-header increment/decrement TCP Acknowledgment number
+ * to DV specification.
+ *
+ * @param[in,out] resource
+ *   Pointer to the modify-header resource.
+ * @param[in] action
+ *   Pointer to action specification.
+ * @param[out] error
+ *   Pointer to the error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_tcp_ack
+			(struct mlx5_flow_dv_modify_hdr_resource *resource,
+			 const struct rte_flow_action *action,
+			 struct rte_flow_error *error)
+{
+	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
+	uint64_t value = rte_be_to_cpu_32(*conf);
+	struct rte_flow_item item;
+	struct rte_flow_item_tcp tcp;
+	struct rte_flow_item_tcp tcp_mask;
+
+	memset(&tcp, 0, sizeof(tcp));
+	memset(&tcp_mask, 0, sizeof(tcp_mask));
+	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
+		/*
+		 * The HW has no decrement operation, only increment operation.
+		 * To simulate decrement X from Y using increment operation
+		 * we need to add UINT32_MAX X times to Y.
+		 * Each adding of UINT32_MAX decrements Y by 1.
+		 */
+		value *= UINT32_MAX;
+	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
+	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
+	item.type = RTE_FLOW_ITEM_TYPE_TCP;
+	item.spec = &tcp;
+	item.mask = &tcp_mask;
+	return flow_dv_convert_modify_action(&item, modify_tcp, resource,
+					     MLX5_MODIFICATION_TYPE_ADD, error);
+}
+
+/**
  * Validate META item.
  *
  * @param[in] dev
@@ -1668,6 +1760,96 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Sequence-number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_SEQ)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP sequence number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
+ * Validate the modify-header actions of increment/decrement
+ * TCP Acknowledgment number.
+ *
+ * @param[in] action_flags
+ *   Holds the actions detected until now.
+ * @param[in] action
+ *   Pointer to the modify action.
+ * @param[in] item_flags
+ *   Holds the items detected.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
+				       const struct rte_flow_action *action,
+				       const uint64_t item_flags,
+				       struct rte_flow_error *error)
+{
+	int ret = 0;
+
+	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
+	if (!ret) {
+		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL, "no TCP item in"
+						  " pattern");
+		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
+		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK &&
+			(action_flags & MLX5_FLOW_ACTION_INC_TCP_ACK)))
+			return rte_flow_error_set(error, EINVAL,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  NULL,
+						  "cannot decrease and increase"
+						  " TCP acknowledgment number"
+						  " at the same time");
+	}
+	return ret;
+}
+
+/**
  * Validate the modify-header TTL actions.
  *
  * @param[in] action_flags
@@ -2416,6 +2598,40 @@ struct field_modify_info modify_tcp[] = {
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			ret = flow_dv_validate_action_modify_tcp_seq
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+						MLX5_FLOW_ACTION_INC_TCP_SEQ :
+						MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			ret = flow_dv_validate_action_modify_tcp_ack
+								(action_flags,
+								 actions,
+								 item_flags,
+								 error);
+			if (ret < 0)
+				return ret;
+			/* Count all modify-header actions as one action. */
+			if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
+				++actions_n;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+						MLX5_FLOW_ACTION_INC_TCP_ACK :
+						MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		default:
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
@@ -3895,6 +4111,27 @@ struct field_modify_info modify_tcp[] = {
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
+			if (flow_dv_convert_action_modify_tcp_seq(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
+					MLX5_FLOW_ACTION_INC_TCP_SEQ :
+					MLX5_FLOW_ACTION_DEC_TCP_SEQ;
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
+		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
+			if (flow_dv_convert_action_modify_tcp_ack(&res, actions,
+								  error))
+				return -rte_errno;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
+					MLX5_FLOW_ACTION_INC_TCP_ACK :
+					MLX5_FLOW_ACTION_DEC_TCP_ACK;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 1a19958..7482383 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -347,6 +347,18 @@ enum mlx5_modification_field {
 	MLX5_MODI_IN_IPV6_HOPLIMIT,
 	MLX5_MODI_META_DATA_REG_A,
 	MLX5_MODI_META_DATA_REG_B = 0x50,
+	MLX5_MODI_META_REG_C_0,
+	MLX5_MODI_META_REG_C_1,
+	MLX5_MODI_META_REG_C_2,
+	MLX5_MODI_META_REG_C_3,
+	MLX5_MODI_META_REG_C_4,
+	MLX5_MODI_META_REG_C_5,
+	MLX5_MODI_META_REG_C_6,
+	MLX5_MODI_META_REG_C_7,
+	MLX5_MODI_OUT_TCP_SEQ_NUM,
+	MLX5_MODI_IN_TCP_SEQ_NUM,
+	MLX5_MODI_OUT_TCP_ACK_NUM,
+	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
 };
 
 /* Modification sub command. */
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields
  2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
                     ` (2 preceding siblings ...)
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-07-02 15:15   ` Adrien Mazarguil
  2019-07-03 14:59     ` Ferruh Yigit
  3 siblings, 1 reply; 76+ messages in thread
From: Adrien Mazarguil @ 2019-07-02 15:15 UTC (permalink / raw)
  To: Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs,
	viacheslavo, arybchenko, dev, orika

On Tue, Jul 02, 2019 at 05:44:25PM +0300, Dekel Peled wrote:
> Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
> This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.
> 
> Original work by Xiaoyu Min.
> 
> [1] http://patches.dpdk.org/patch/49310/
> [2] http://mails.dpdk.org/archives/dev/2018-August/109672.html
> 
> ---
> v2: apply code review comments.
> v3: apply additional code review comments.
>     - Update documentation of new commands.
>     - Use common general struct for all commands.
> v4: apply checkpatch comments.
> v5: apply additional code review comments.
>     - Add 8, 16, 32 bit types to union.
>     - Update struct name and documentation.
> v6: expand description of new struct in h file and commit log.
> v7: - Remove the common general struct with union added in v3 & v5.
>     - Commands take a simple integer value, not enclosed in a structure.
>     - Use separate commands for INC and DEC with 32 bit unsigned value
>       of type rte_be32_t.
> v8: clean redundant comments refering to removed structure.
> v9: - Send the announcement of new approach (use action with single
>       argument configuration) in separate patch before this series,
>       see http://patches.dpdk.org/patch/55773/.
>     - Add PMD release notes update.
> v10: - Reorder release notes update properly.
>      - Update comments for doxygen.

Phew!

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP header fields
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP " Dekel Peled
@ 2019-07-03  5:04     ` Slava Ovsiienko
  0 siblings, 0 replies; 76+ messages in thread
From: Slava Ovsiienko @ 2019-07-03  5:04 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler, arybchenko,
	Raslan Darawsheh
  Cc: dev, Ori Kam

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Tuesday, July 2, 2019 17:44
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: [PATCH v10 1/3] ethdev: add actions to modify TCP header fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> This patch uses the new approach introduced by [1], using a simple integer
> instead of using an action-specific structure for each of the new actions.
> 
> [1] http://patches.dpdk.org/patch/55882/
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst | 32 ++++++++++++++++++++++
>  lib/librte_ethdev/rte_flow.c       |  4 +++
>  lib/librte_ethdev/rte_flow.h       | 56
> ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 92 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/rte_flow.rst
> b/doc/guides/prog_guide/rte_flow.rst
> index 67deed7..bbe32db 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -2346,6 +2346,38 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION
> error will be returned.
>     | ``mac_addr`` | MAC address   |
>     +--------------+---------------+
> 
> +Action: ``INC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase sequence number in the outermost TCP header.
> +Value to increase TCP sequence number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``DEC_TCP_SEQ``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease sequence number in the outermost TCP header.
> +Value to decrease TCP sequence number by is a big-endian 32 bit integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``INC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Increase acknowledgment number in the outermost TCP header.
> +Value to increase TCP acknowledgment number by is a big-endian 32 bit
> integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
> +Action: ``DEC_TCP_ACK``
> +^^^^^^^^^^^^^^^^^^^^^^^
> +
> +Decrease acknowledgment number in the outermost TCP header.
> +Value to decrease TCP acknowledgment number by is a big-endian 32 bit
> integer.
> +
> +Using this action on non-matching traffic will result in undefined behavior.
> +
>  Negative types
>  ~~~~~~~~~~~~~~
> 
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index
> 3277be1..0c9f6c6 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -143,6 +143,10 @@ struct rte_flow_desc_data {
>  	MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)),
>  	MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct
> rte_flow_action_set_mac)),
>  	MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct
> rte_flow_action_set_mac)),
> +	MK_FLOW_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> +	MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
>  };
> 
>  static int
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index
> 2232856..bc41023 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -1651,6 +1651,62 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_set_mac.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
> +
> +	/**
> +	 * Increase sequence number in the outermost TCP header.
> +	 *
> +	 * Action configuration specifies the value to increase
> +	 * TCP sequence number as a big-endian 32 bit integer.
> +	 *
> +	 * @p conf type:
> +	 * @code rte_be32_t * @endcode
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
> +
> +	/**
> +	 * Decrease sequence number in the outermost TCP header.
> +	 *
> +	 * Action configuration specifies the value to decrease
> +	 * TCP sequence number as a big-endian 32 bit integer.
> +	 *
> +	 * @p conf type:
> +	 * @code rte_be32_t * @endcode
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
> +
> +	/**
> +	 * Increase acknowledgment number in the outermost TCP header.
> +	 *
> +	 * Action configuration specifies the value to increase
> +	 * TCP acknowledgment number as a big-endian 32 bit integer.
> +	 *
> +	 * @p conf type:
> +	 * @code rte_be32_t * @endcode
> +
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
> +
> +	/**
> +	 * Decrease acknowledgment number in the outermost TCP header.
> +	 *
> +	 * Action configuration specifies the value to decrease
> +	 * TCP acknowledgment number as a big-endian 32 bit integer.
> +	 *
> +	 * @p conf type:
> +	 * @code rte_be32_t * @endcode
> +	 *
> +	 * Using this action on non-matching traffic will result in
> +	 * undefined behavior.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
>  };
> 
>  /**
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v10 2/3] app/testpmd: add actions to modify TCP header fields
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 2/3] app/testpmd: " Dekel Peled
@ 2019-07-03  6:30     ` Slava Ovsiienko
  0 siblings, 0 replies; 76+ messages in thread
From: Slava Ovsiienko @ 2019-07-03  6:30 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler, arybchenko,
	Raslan Darawsheh
  Cc: dev, Ori Kam

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Tuesday, July 2, 2019 17:44
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: [PATCH v10 2/3] app/testpmd: add actions to modify TCP header
> fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
>                 header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
>                 header.
> 
> Original work by Xiaoyu Min.
> 
> This patch uses the new approach introduced by [1], using a new macro
> ARG_ENTRY_HTON to pass a single integer argument to each of the new
> actions.
> 
> [1] http://patches.dpdk.org/patch/55882/
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  app/test-pmd/cmdline_flow.c                 | 100
> ++++++++++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 201bd9d..e644efa 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -272,6 +272,14 @@ enum index {
>  	ACTION_SET_MAC_SRC_MAC_SRC,
>  	ACTION_SET_MAC_DST,
>  	ACTION_SET_MAC_DST_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_DEC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK_VALUE,
>  };
> 
>  /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -485,6
> +493,14 @@ struct token {
>  		.size = sizeof(((s *)0)->f), \
>  	})
> 
> +/** Same as ARGS_ENTRY_HTON() for a single argument, without structure.
> +*/ #define ARG_ENTRY_HTON(s) \
> +	(&(const struct arg){ \
> +		.hton = 1, \
> +		.offset = 0, \
> +		.size = sizeof(s), \
> +	})
> +
>  /** Parser output buffer layout expected by cmd_flow_parsed(). */  struct
> buffer {
>  	enum index command; /**< Flow command. */ @@ -885,6 +901,10
> @@ struct parse_action_priv {
>  	ACTION_SET_TTL,
>  	ACTION_SET_MAC_SRC,
>  	ACTION_SET_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK,
>  	ZERO,
>  };
> 
> @@ -1047,6 +1067,30 @@ struct parse_action_priv {
>  	ZERO,
>  };
> 
> +static const enum index action_inc_tcp_seq[] = {
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_seq[] = {
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_inc_tcp_ack[] = {
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_ack[] = {
> +	ACTION_DEC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static int parse_init(struct context *, const struct token *,
>  		      const char *, unsigned int,
>  		      void *, unsigned int);
> @@ -2854,6 +2898,62 @@ static int comp_vc_action_rss_queue(struct
> context *, const struct token *,
>  			     (struct rte_flow_action_set_mac, mac_addr)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_INC_TCP_SEQ] = {
> +		.name = "inc_tcp_seq",
> +		.help = "increase TCP sequence number",
> +		.priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
> +		.next = NEXT(action_inc_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP sequence number by",
> +		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_SEQ] = {
> +		.name = "dec_tcp_seq",
> +		.help = "decrease TCP sequence number",
> +		.priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
> +		.next = NEXT(action_dec_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP sequence number by",
> +		.next = NEXT(action_dec_tcp_seq,
> NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_INC_TCP_ACK] = {
> +		.name = "inc_tcp_ack",
> +		.help = "increase TCP acknowledgment number",
> +		.priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
> +		.next = NEXT(action_inc_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP acknowledgment number
> by",
> +		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_ACK] = {
> +		.name = "dec_tcp_ack",
> +		.help = "decrease TCP acknowledgment number",
> +		.priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
> +		.next = NEXT(action_dec_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP acknowledgment number
> by",
> +		.next = NEXT(action_dec_tcp_ack,
> NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
> +		.call = parse_vc_conf,
> +	},
>  };
> 
>  /** Remove and return last entry from argument stack. */ diff --git
> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index cb83a3c..49a9e15 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -4106,6 +4106,22 @@ This section lists supported actions and their
> attributes, if any.
> 
>    - ``mac_addr {MAC-48}``: new destination MAC address
> 
> +- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to increase TCP sequence number by.
> +
> +- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP sequence number by.
> +
> +- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
> +
> +- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs
  2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
@ 2019-07-03  6:30     ` Slava Ovsiienko
  0 siblings, 0 replies; 76+ messages in thread
From: Slava Ovsiienko @ 2019-07-03  6:30 UTC (permalink / raw)
  To: Dekel Peled, Adrien Mazarguil, wenzhuo.lu, jingjing.wu,
	bernard.iremonger, Yongseok Koh, Shahaf Shuler, arybchenko,
	Raslan Darawsheh
  Cc: dev, Ori Kam

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Tuesday, July 2, 2019 17:44
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>;
> wenzhuo.lu@intel.com; jingjing.wu@intel.com;
> bernard.iremonger@intel.com; Yongseok Koh <yskoh@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>
> Subject: [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs
> 
> This patch implements additional actions of packet header
> modifications.
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
> 		header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
> 		header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  doc/guides/rel_notes/release_19_08.rst |   7 +
>  drivers/net/mlx5/mlx5_flow.h           |  10 +-
>  drivers/net/mlx5/mlx5_flow_dv.c        | 237
> +++++++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_prm.h            |  12 ++
>  4 files changed, 265 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guides/rel_notes/release_19_08.rst
> b/doc/guides/rel_notes/release_19_08.rst
> index 3da2667..450d22f 100644
> --- a/doc/guides/rel_notes/release_19_08.rst
> +++ b/doc/guides/rel_notes/release_19_08.rst
> @@ -74,6 +74,13 @@ New Features
> 
>    * Enabled Tx outer/inner L3/L4 checksum offload.
> 
> +* **Updated Mellanox mlx5 driver.**
> +
> +  Updated Mellanox mlx5 driver with new features and improvements,
> including:
> +
> +  * Updated the packet header modification feature. Added support of TCP
> header
> +    sequence number and acknowledgment number modification.
> +
>  * **Updated Solarflare network PMD.**
> 
>    Updated the Solarflare ``sfc_efx`` driver with changes including:
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index b665420..dc4a56a 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -114,6 +114,10 @@
>  #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
>  #define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)
>  #define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)
> +#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28)
> +#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29)
> +#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30)
> +#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31)
> 
>  #define MLX5_FLOW_FATE_ACTIONS \
>  	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
> @@ -140,7 +144,11 @@
>  				      MLX5_FLOW_ACTION_SET_TTL | \
>  				      MLX5_FLOW_ACTION_DEC_TTL | \
>  				      MLX5_FLOW_ACTION_SET_MAC_SRC | \
> -				      MLX5_FLOW_ACTION_SET_MAC_DST)
> +				      MLX5_FLOW_ACTION_SET_MAC_DST | \
> +				      MLX5_FLOW_ACTION_INC_TCP_SEQ | \
> +				      MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
> +				      MLX5_FLOW_ACTION_INC_TCP_ACK | \
> +				      MLX5_FLOW_ACTION_DEC_TCP_ACK)
> 
>  #ifndef IPPROTO_MPLS
>  #define IPPROTO_MPLS 137
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 933ad0b..8f64182 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -136,6 +136,8 @@ struct field_modify_info modify_udp[] = {
>  struct field_modify_info modify_tcp[] = {
>  	{2, 0, MLX5_MODI_OUT_TCP_SPORT},
>  	{2, 2, MLX5_MODI_OUT_TCP_DPORT},
> +	{4, 4, MLX5_MODI_OUT_TCP_SEQ_NUM},
> +	{4, 8, MLX5_MODI_OUT_TCP_ACK_NUM},
>  	{0, 0, 0},
>  };
> 
> @@ -561,6 +563,96 @@ struct field_modify_info modify_tcp[] = {
>  }
> 
>  /**
> + * Convert modify-header increment/decrement TCP Sequence number
> + * to DV specification.
> + *
> + * @param[in,out] resource
> + *   Pointer to the modify-header resource.
> + * @param[in] action
> + *   Pointer to action specification.
> + * @param[out] error
> + *   Pointer to the error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_convert_action_modify_tcp_seq
> +			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
> +			 const struct rte_flow_action *action,
> +			 struct rte_flow_error *error)
> +{
> +	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
> +	uint64_t value = rte_be_to_cpu_32(*conf);
> +	struct rte_flow_item item;
> +	struct rte_flow_item_tcp tcp;
> +	struct rte_flow_item_tcp tcp_mask;
> +
> +	memset(&tcp, 0, sizeof(tcp));
> +	memset(&tcp_mask, 0, sizeof(tcp_mask));
> +	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ)
> +		/*
> +		 * The HW has no decrement operation, only increment
> operation.
> +		 * To simulate decrement X from Y using increment operation
> +		 * we need to add UINT32_MAX X times to Y.
> +		 * Each adding of UINT32_MAX decrements Y by 1.
> +		 */
> +		value *= UINT32_MAX;
> +	tcp.hdr.sent_seq = rte_cpu_to_be_32((uint32_t)value);
> +	tcp_mask.hdr.sent_seq = RTE_BE32(UINT32_MAX);
> +	item.type = RTE_FLOW_ITEM_TYPE_TCP;
> +	item.spec = &tcp;
> +	item.mask = &tcp_mask;
> +	return flow_dv_convert_modify_action(&item, modify_tcp,
> resource,
> +
> MLX5_MODIFICATION_TYPE_ADD, error);
> +}
> +
> +/**
> + * Convert modify-header increment/decrement TCP Acknowledgment
> number
> + * to DV specification.
> + *
> + * @param[in,out] resource
> + *   Pointer to the modify-header resource.
> + * @param[in] action
> + *   Pointer to action specification.
> + * @param[out] error
> + *   Pointer to the error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_convert_action_modify_tcp_ack
> +			(struct mlx5_flow_dv_modify_hdr_resource
> *resource,
> +			 const struct rte_flow_action *action,
> +			 struct rte_flow_error *error)
> +{
> +	const rte_be32_t *conf = (const rte_be32_t *)(action->conf);
> +	uint64_t value = rte_be_to_cpu_32(*conf);
> +	struct rte_flow_item item;
> +	struct rte_flow_item_tcp tcp;
> +	struct rte_flow_item_tcp tcp_mask;
> +
> +	memset(&tcp, 0, sizeof(tcp));
> +	memset(&tcp_mask, 0, sizeof(tcp_mask));
> +	if (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK)
> +		/*
> +		 * The HW has no decrement operation, only increment
> operation.
> +		 * To simulate decrement X from Y using increment operation
> +		 * we need to add UINT32_MAX X times to Y.
> +		 * Each adding of UINT32_MAX decrements Y by 1.
> +		 */
> +		value *= UINT32_MAX;
> +	tcp.hdr.recv_ack = rte_cpu_to_be_32((uint32_t)value);
> +	tcp_mask.hdr.recv_ack = RTE_BE32(UINT32_MAX);
> +	item.type = RTE_FLOW_ITEM_TYPE_TCP;
> +	item.spec = &tcp;
> +	item.mask = &tcp_mask;
> +	return flow_dv_convert_modify_action(&item, modify_tcp,
> resource,
> +
> MLX5_MODIFICATION_TYPE_ADD, error);
> +}
> +
> +/**
>   * Validate META item.
>   *
>   * @param[in] dev
> @@ -1668,6 +1760,96 @@ struct field_modify_info modify_tcp[] = {
>  }
> 
>  /**
> + * Validate the modify-header actions of increment/decrement
> + * TCP Sequence-number.
> + *
> + * @param[in] action_flags
> + *   Holds the actions detected until now.
> + * @param[in] action
> + *   Pointer to the modify action.
> + * @param[in] item_flags
> + *   Holds the items detected.
> + * @param[out] error
> + *   Pointer to error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_validate_action_modify_tcp_seq(const uint64_t action_flags,
> +				       const struct rte_flow_action *action,
> +				       const uint64_t item_flags,
> +				       struct rte_flow_error *error)
> +{
> +	int ret = 0;
> +
> +	ret = flow_dv_validate_action_modify_hdr(action_flags, action,
> error);
> +	if (!ret) {
> +		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL, "no TCP item in"
> +						  " pattern");
> +		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
> &&
> +			(action_flags &
> MLX5_FLOW_ACTION_DEC_TCP_SEQ)) ||
> +		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
> &&
> +			(action_flags &
> MLX5_FLOW_ACTION_INC_TCP_SEQ)))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL,
> +						  "cannot decrease and
> increase"
> +						  " TCP sequence number"
> +						  " at the same time");
> +	}
> +	return ret;
> +}
> +
> +/**
> + * Validate the modify-header actions of increment/decrement
> + * TCP Acknowledgment number.
> + *
> + * @param[in] action_flags
> + *   Holds the actions detected until now.
> + * @param[in] action
> + *   Pointer to the modify action.
> + * @param[in] item_flags
> + *   Holds the items detected.
> + * @param[out] error
> + *   Pointer to error structure.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +static int
> +flow_dv_validate_action_modify_tcp_ack(const uint64_t action_flags,
> +				       const struct rte_flow_action *action,
> +				       const uint64_t item_flags,
> +				       struct rte_flow_error *error)
> +{
> +	int ret = 0;
> +
> +	ret = flow_dv_validate_action_modify_hdr(action_flags, action,
> error);
> +	if (!ret) {
> +		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL, "no TCP item in"
> +						  " pattern");
> +		if ((action->type == RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
> &&
> +			(action_flags &
> MLX5_FLOW_ACTION_DEC_TCP_ACK)) ||
> +		    (action->type == RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
> &&
> +			(action_flags &
> MLX5_FLOW_ACTION_INC_TCP_ACK)))
> +			return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  NULL,
> +						  "cannot decrease and
> increase"
> +						  " TCP acknowledgment
> number"
> +						  " at the same time");
> +	}
> +	return ret;
> +}
> +
> +/**
>   * Validate the modify-header TTL actions.
>   *
>   * @param[in] action_flags
> @@ -2416,6 +2598,40 @@ struct field_modify_info modify_tcp[] = {
>  			++actions_n;
>  			action_flags |= MLX5_FLOW_ACTION_JUMP;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
> +			ret = flow_dv_validate_action_modify_tcp_seq
> +
> 	(action_flags,
> +								 actions,
> +								 item_flags,
> +								 error);
> +			if (ret < 0)
> +				return ret;
> +			/* Count all modify-header actions as one action. */
> +			if (!(action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS))
> +				++actions_n;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
> +
> 	MLX5_FLOW_ACTION_INC_TCP_SEQ :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_SEQ;
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
> +			ret = flow_dv_validate_action_modify_tcp_ack
> +
> 	(action_flags,
> +								 actions,
> +								 item_flags,
> +								 error);
> +			if (ret < 0)
> +				return ret;
> +			/* Count all modify-header actions as one action. */
> +			if (!(action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS))
> +				++actions_n;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
> +
> 	MLX5_FLOW_ACTION_INC_TCP_ACK :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_ACK;
> +			break;
>  		default:
>  			return rte_flow_error_set(error, ENOTSUP,
> 
> RTE_FLOW_ERROR_TYPE_ACTION,
> @@ -3895,6 +4111,27 @@ struct field_modify_info modify_tcp[] = {
>  				return -rte_errno;
>  			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ:
> +			if (flow_dv_convert_action_modify_tcp_seq(&res,
> actions,
> +								  error))
> +				return -rte_errno;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ ?
> +					MLX5_FLOW_ACTION_INC_TCP_SEQ
> :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_SEQ;
> +			break;
> +
> +		case RTE_FLOW_ACTION_TYPE_INC_TCP_ACK:
> +		case RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK:
> +			if (flow_dv_convert_action_modify_tcp_ack(&res,
> actions,
> +								  error))
> +				return -rte_errno;
> +			action_flags |= actions->type ==
> +
> 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK ?
> +					MLX5_FLOW_ACTION_INC_TCP_ACK
> :
> +
> 	MLX5_FLOW_ACTION_DEC_TCP_ACK;
> +			break;
>  		case RTE_FLOW_ACTION_TYPE_END:
>  			actions_end = true;
>  			if (action_flags &
> MLX5_FLOW_MODIFY_HDR_ACTIONS) {
> diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
> index 1a19958..7482383 100644
> --- a/drivers/net/mlx5/mlx5_prm.h
> +++ b/drivers/net/mlx5/mlx5_prm.h
> @@ -347,6 +347,18 @@ enum mlx5_modification_field {
>  	MLX5_MODI_IN_IPV6_HOPLIMIT,
>  	MLX5_MODI_META_DATA_REG_A,
>  	MLX5_MODI_META_DATA_REG_B = 0x50,
> +	MLX5_MODI_META_REG_C_0,
> +	MLX5_MODI_META_REG_C_1,
> +	MLX5_MODI_META_REG_C_2,
> +	MLX5_MODI_META_REG_C_3,
> +	MLX5_MODI_META_REG_C_4,
> +	MLX5_MODI_META_REG_C_5,
> +	MLX5_MODI_META_REG_C_6,
> +	MLX5_MODI_META_REG_C_7,
> +	MLX5_MODI_OUT_TCP_SEQ_NUM,
> +	MLX5_MODI_IN_TCP_SEQ_NUM,
> +	MLX5_MODI_OUT_TCP_ACK_NUM,
> +	MLX5_MODI_IN_TCP_ACK_NUM = 0x5C,
>  };
> 
>  /* Modification sub command. */
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields
  2019-07-02 15:15   ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Adrien Mazarguil
@ 2019-07-03 14:59     ` Ferruh Yigit
  0 siblings, 0 replies; 76+ messages in thread
From: Ferruh Yigit @ 2019-07-03 14:59 UTC (permalink / raw)
  To: Adrien Mazarguil, Dekel Peled
  Cc: wenzhuo.lu, jingjing.wu, bernard.iremonger, yskoh, shahafs,
	viacheslavo, arybchenko, dev, orika

On 7/2/2019 4:15 PM, Adrien Mazarguil wrote:
> On Tue, Jul 02, 2019 at 05:44:25PM +0300, Dekel Peled wrote:
>> Patch [1] implemented set of header modification actions in MLX PMD, based on ethdev and testpmd updates included in [2].
>> This series implements support of additional header modification actions, in ethdev, testpmd, and MLX5 PMD.
>>
>> Original work by Xiaoyu Min.
>>
>> [1] http://patches.dpdk.org/patch/49310/
>> [2] http://mails.dpdk.org/archives/dev/2018-August/109672.html
>>
>> ---
>> v2: apply code review comments.
>> v3: apply additional code review comments.
>>     - Update documentation of new commands.
>>     - Use common general struct for all commands.
>> v4: apply checkpatch comments.
>> v5: apply additional code review comments.
>>     - Add 8, 16, 32 bit types to union.
>>     - Update struct name and documentation.
>> v6: expand description of new struct in h file and commit log.
>> v7: - Remove the common general struct with union added in v3 & v5.
>>     - Commands take a simple integer value, not enclosed in a structure.
>>     - Use separate commands for INC and DEC with 32 bit unsigned value
>>       of type rte_be32_t.
>> v8: clean redundant comments refering to removed structure.
>> v9: - Send the announcement of new approach (use action with single
>>       argument configuration) in separate patch before this series,
>>       see http://patches.dpdk.org/patch/55773/.
>>     - Add PMD release notes update.
>> v10: - Reorder release notes update properly.
>>      - Update comments for doxygen.
> 
> Phew!
> 
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> 

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 76+ messages in thread

end of thread, back to index

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 14:18 [PATCH 0/3] add actions to modify header fields Dekel Peled
2019-03-21 14:18 ` [PATCH 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-03-26  9:24   ` Dekel Peled
2019-03-29 13:58   ` Adrien Mazarguil
2019-03-31 13:09     ` Dekel Peled
2019-03-21 14:18 ` [PATCH 2/3] app/testpmd: " Dekel Peled
2019-03-29 13:58   ` Adrien Mazarguil
2019-03-31 13:10     ` Dekel Peled
2019-03-21 14:18 ` [PATCH 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-04-02 15:13 ` [PATCH v2 0/3] add actions to modify header fields Dekel Peled
2019-04-10 11:26   ` [dpdk-dev] [PATCH v3 " Dekel Peled
2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: " Dekel Peled
2019-04-10 11:26     ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-04-10 11:50     ` [dpdk-dev] [PATCH v4 0/3] add actions to modify header fields Dekel Peled
2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-04-18 12:30         ` Adrien Mazarguil
2019-04-22  7:15           ` Dekel Peled
2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: " Dekel Peled
2019-04-10 11:50       ` [dpdk-dev] [PATCH v4 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-04-22 11:22       ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: " Dekel Peled
2019-04-22 11:22         ` [dpdk-dev] [PATCH v5 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-06-02  8:18         ` [dpdk-dev] [PATCH v5 0/3] add actions to modify header fields Dekel Peled
2019-06-04  5:13           ` Dekel Peled
2019-06-04  8:14             ` Dekel Peled
2019-06-17  6:12         ` [dpdk-dev] [PATCH v6 " Dekel Peled
2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: " Dekel Peled
2019-06-17  6:12           ` [dpdk-dev] [PATCH v6 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-06-27 17:39           ` [dpdk-dev] [PATCH v7 0/3] add actions to modify header fields Dekel Peled
2019-06-30  7:59             ` [dpdk-dev] [PATCH v8 " Dekel Peled
2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-07-01  8:55                 ` Adrien Mazarguil
2019-07-01  9:58                   ` Dekel Peled
2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 2/3] app/testpmd: " Dekel Peled
2019-06-30  7:59               ` [dpdk-dev] [PATCH v8 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
     [not found]           ` <cover.1561656977.git.dekelp@mellanox.com>
2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
2019-06-27 17:54               ` Andrew Rybchenko
2019-06-28 16:18                 ` Adrien Mazarguil
2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 2/3] app/testpmd: " Dekel Peled
2019-06-27 17:39             ` [dpdk-dev] [PATCH v7 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-04-02 15:13 ` [PATCH v2 1/3] ethdev: add actions to modify TCP header fields Dekel Peled
2019-04-02 16:33   ` Ori Kam
2019-04-03  9:14   ` Adrien Mazarguil
2019-04-03 10:49     ` Dekel Peled
2019-04-03 12:49       ` Adrien Mazarguil
2019-04-04  9:01         ` Ori Kam
2019-04-04 13:25           ` Adrien Mazarguil
2019-04-05 11:54             ` [dpdk-dev] " Andrew Rybchenko
2019-04-08 13:36             ` Dekel Peled
2019-04-08 13:53               ` Andrew Rybchenko
2019-04-08 14:21                 ` Adrien Mazarguil
2019-04-02 15:13 ` [PATCH v2 2/3] app/testpmd: " Dekel Peled
2019-04-02 16:33   ` Ori Kam
2019-04-02 15:13 ` [PATCH v2 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-04-02 16:34   ` Ori Kam
2019-04-03  8:27   ` Shahaf Shuler
2019-07-01 15:43 ` [dpdk-dev] [PATCH v9 0/3] add actions to modify header fields Dekel Peled
2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-07-02  8:14     ` Andrew Rybchenko
2019-07-02  9:52       ` Dekel Peled
2019-07-02 10:33         ` Adrien Mazarguil
2019-07-02 12:01           ` Dekel Peled
2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 2/3] app/testpmd: " Dekel Peled
2019-07-01 15:43   ` [dpdk-dev] [PATCH v9 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-07-02 14:44 ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Dekel Peled
2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 1/3] ethdev: add actions to modify TCP " Dekel Peled
2019-07-03  5:04     ` Slava Ovsiienko
2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 2/3] app/testpmd: " Dekel Peled
2019-07-03  6:30     ` Slava Ovsiienko
2019-07-02 14:44   ` [dpdk-dev] [PATCH v10 3/3] net/mlx5: update modify header using Direct Verbs Dekel Peled
2019-07-03  6:30     ` Slava Ovsiienko
2019-07-02 15:15   ` [dpdk-dev] [PATCH v10 0/3] add actions to modify header fields Adrien Mazarguil
2019-07-03 14:59     ` Ferruh Yigit

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org dpdk-dev@archiver.kernel.org
	public-inbox-index dpdk-dev


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox