DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@nvidia.com>
To: Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>
Subject: [PATCH 4/4] net/mlx5: add modify field action ADD fields validation
Date: Thu, 14 Dec 2023 11:04:27 +0800	[thread overview]
Message-ID: <20231214030428.363471-5-suanmingm@nvidia.com> (raw)
In-Reply-To: <20231214030428.363471-1-suanmingm@nvidia.com>

Due to HW limitation, not all the fields are available as ADD_FIELD
destination.

This commit adds the validation to the destinations.

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
 doc/guides/rel_notes/release_24_03.rst |  4 ++++
 drivers/net/mlx5/mlx5_flow_hw.c        | 32 ++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index e9c9717706..2c0e2930cc 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated NVIDIA mlx5 driver.**
+
+  * Added support for accumulating from src field to dst field.
+
 
 Removed Items
 -------------
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index d224979ee8..c4a90a3690 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -4948,6 +4948,33 @@ flow_hw_modify_field_is_used(const struct rte_flow_action_modify_field *action,
 	return action->src.field == field || action->dst.field == field;
 }
 
+static bool
+flow_hw_modify_field_is_add_dst_valid(const struct rte_flow_action_modify_field *conf)
+{
+	if (conf->operation != RTE_FLOW_MODIFY_ADD)
+		return true;
+	if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
+	    conf->src.field == RTE_FLOW_FIELD_VALUE)
+		return true;
+	switch (conf->dst.field) {
+	case RTE_FLOW_FIELD_IPV4_TTL:
+	case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+	case RTE_FLOW_FIELD_TCP_SEQ_NUM:
+	case RTE_FLOW_FIELD_TCP_ACK_NUM:
+	case RTE_FLOW_FIELD_TAG:
+	case RTE_FLOW_FIELD_META:
+	case RTE_FLOW_FIELD_FLEX_ITEM:
+	case RTE_FLOW_FIELD_TCP_DATA_OFFSET:
+	case RTE_FLOW_FIELD_IPV4_IHL:
+	case RTE_FLOW_FIELD_IPV4_TOTAL_LEN:
+	case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN:
+		return true;
+	default:
+		break;
+	}
+	return false;
+}
+
 static int
 flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
 				     const struct rte_flow_action *action,
@@ -5060,6 +5087,11 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION, action,
 				"MPLS cannot be used as destination");
+	/* ADD_FIELD is not supported for all the fields. */
+	if (!flow_hw_modify_field_is_add_dst_valid(action_conf))
+		return rte_flow_error_set(error, EINVAL,
+				RTE_FLOW_ERROR_TYPE_ACTION, action,
+				"invalid add_field destination");
 	return 0;
 }
 static int
-- 
2.34.1


  parent reply	other threads:[~2023-12-14  3:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14  3:04 [PATCH 0/4] net/mlx5: add modify field ADD fields support Suanming Mou
2023-12-14  3:04 ` [PATCH 1/4] net/mlx5: add TCP/IP length modify field Suanming Mou
2023-12-14 11:35   ` Ori Kam
2023-12-14 11:36   ` Ori Kam
2023-12-14  3:04 ` [PATCH 2/4] net/mlx5: rename modify copy destination to destination Suanming Mou
2023-12-14 11:37   ` Ori Kam
2023-12-14  3:04 ` [PATCH 3/4] net/mlx5: add modify field action ADD fields support Suanming Mou
2023-12-14 11:38   ` Ori Kam
2023-12-14  3:04 ` Suanming Mou [this message]
2023-12-14 11:39   ` [PATCH 4/4] net/mlx5: add modify field action ADD fields validation Ori Kam
2024-01-07 12:37 ` [PATCH 0/4] net/mlx5: add modify field ADD fields support Raslan Darawsheh

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20231214030428.363471-5-suanmingm@nvidia.com \
    --to=suanmingm@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

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

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