DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
To: <dev@dpdk.org>
Cc: <rasland@nvidia.com>, <matan@nvidia.com>, <shahafs@nvidia.com>,
	<orika@nvidia.com>, <getelson@nvidia.com>, <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH v3 5/5] net/mlx5: update modify field action
Date: Tue, 12 Oct 2021 11:06:31 +0300	[thread overview]
Message-ID: <20211012080631.28504-6-viacheslavo@nvidia.com> (raw)
In-Reply-To: <20211012080631.28504-1-viacheslavo@nvidia.com>

Update immediate value/pointer source operand support
for modify field RTE Flow action:

  - source operand data can be presented by byte buffer
    (instead of former uint64_t) or by pointer
  - no host byte ordering is assumed anymore for immediate
    data buffer (not uint64_t anymore)
  - no immediate value offset is expected

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 50 +++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index c6370cd1d6..867f587960 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1391,7 +1391,7 @@ flow_dv_convert_action_modify_ipv6_dscp
 
 static int
 mlx5_flow_item_field_width(struct mlx5_priv *priv,
-			   enum rte_flow_field_id field)
+			   enum rte_flow_field_id field, int inherit)
 {
 	switch (field) {
 	case RTE_FLOW_FIELD_START:
@@ -1442,7 +1442,8 @@ mlx5_flow_item_field_width(struct mlx5_priv *priv,
 		return __builtin_popcount(priv->sh->dv_meta_mask);
 	case RTE_FLOW_FIELD_POINTER:
 	case RTE_FLOW_FIELD_VALUE:
-		return 64;
+		MLX5_ASSERT(inherit >= 0);
+		return inherit < 0 ? 0 : inherit;
 	default:
 		MLX5_ASSERT(false);
 	}
@@ -1462,7 +1463,8 @@ mlx5_flow_field_id_to_modify_info
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t idx = 0;
 	uint32_t off = 0;
-	uint64_t val = 0;
+	uint8_t *pval;
+
 	switch (data->field) {
 	case RTE_FLOW_FIELD_START:
 		/* not supported yet */
@@ -1838,32 +1840,37 @@ mlx5_flow_field_id_to_modify_info
 		break;
 	case RTE_FLOW_FIELD_POINTER:
 	case RTE_FLOW_FIELD_VALUE:
-		if (data->field == RTE_FLOW_FIELD_POINTER)
-			memcpy(&val, (void *)(uintptr_t)data->value,
-			       sizeof(uint64_t));
-		else
-			val = data->value;
+		pval = data->field == RTE_FLOW_FIELD_POINTER ?
+		       (uint8_t *)(uintptr_t)data->pvalue :
+		       (uint8_t *)(uintptr_t)&data->value;
 		for (idx = 0; idx < MLX5_ACT_MAX_MOD_FIELDS; idx++) {
+			if (!dst_width)
+				break;
 			if (mask[idx]) {
 				if (dst_width == 48) {
 					/*special case for MAC addresses */
-					value[idx] = rte_cpu_to_be_16(val);
-					val >>= 16;
+					value[idx] = rte_cpu_to_be_16
+						(*(unaligned_uint16_t *)pval);
+					pval += sizeof(uint16_t);
 					dst_width -= 16;
 				} else if (dst_width > 16) {
-					value[idx] = rte_cpu_to_be_32(val);
-					val >>= 32;
+					value[idx] = rte_cpu_to_be_32
+						(*(unaligned_uint32_t *)pval);
+					pval += sizeof(uint32_t);
+					dst_width -= RTE_MIN(32u, dst_width);
 				} else if (dst_width > 8) {
-					value[idx] = rte_cpu_to_be_16(val);
-					val >>= 16;
+					value[idx] = rte_cpu_to_be_16
+						(*(unaligned_uint16_t *)pval);
+					pval += sizeof(uint16_t);
+					dst_width -= RTE_MIN(16u, dst_width);
 				} else {
-					value[idx] = (uint8_t)val;
-					val >>= 8;
+					value[idx] = *pval++;
+					dst_width -= RTE_MIN(8u, dst_width);
 				}
 				if (*shift)
 					value[idx] <<= *shift;
-				if (!val)
-					break;
+			} else {
+				pval += sizeof(uint32_t);
 			}
 		}
 		break;
@@ -1910,8 +1917,9 @@ flow_dv_convert_action_modify_field
 	uint32_t value[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
 	uint32_t type;
 	uint32_t shift = 0;
-	uint32_t dst_width = mlx5_flow_item_field_width(priv, conf->dst.field);
+	uint32_t dst_width;
 
+	dst_width = mlx5_flow_item_field_width(priv, conf->dst.field, -1);
 	if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
 		conf->src.field == RTE_FLOW_FIELD_VALUE) {
 		type = MLX5_MODIFICATION_TYPE_SET;
@@ -4874,9 +4882,9 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,
 	const struct rte_flow_action_modify_field *action_modify_field =
 		action->conf;
 	uint32_t dst_width = mlx5_flow_item_field_width(priv,
-				action_modify_field->dst.field);
+				action_modify_field->dst.field, -1);
 	uint32_t src_width = mlx5_flow_item_field_width(priv,
-				action_modify_field->src.field);
+				action_modify_field->src.field, dst_width);
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (ret)
-- 
2.18.1


  parent reply	other threads:[~2021-10-12  8:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 14:16 [dpdk-dev] [RFC 1/3] ethdev: update modify field flow action Viacheslav Ovsiienko
2021-09-10 14:16 ` [dpdk-dev] [RFC 2/3] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-09-10 14:16 ` [dpdk-dev] [RFC 3/3] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-01 19:52 ` [dpdk-dev] [PATCH 0/3] ethdev: update modify field flow action Viacheslav Ovsiienko
2021-10-01 19:52   ` [dpdk-dev] [PATCH 1/3] " Viacheslav Ovsiienko
2021-10-04  9:38     ` Ori Kam
2021-10-01 19:52   ` [dpdk-dev] [PATCH 2/3] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-10-01 19:52   ` [dpdk-dev] [PATCH 3/3] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-10 23:45 ` [dpdk-dev] [PATCH v2 0/5] ethdev: update modify field flow action Viacheslav Ovsiienko
2021-10-10 23:45   ` [dpdk-dev] [PATCH v2 1/5] " Viacheslav Ovsiienko
2021-10-11  7:19     ` Ori Kam
2021-10-11  9:54     ` Andrew Rybchenko
2021-10-10 23:45   ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-10-11  9:13     ` Ori Kam
2021-10-10 23:45   ` [dpdk-dev] [PATCH v2 3/5] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-11  9:15     ` Ori Kam
2021-10-10 23:45   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: update modify field action Viacheslav Ovsiienko
2021-10-10 23:45   ` [dpdk-dev] [PATCH v2 5/5] doc: remove modify field action data deprecation notice Viacheslav Ovsiienko
2021-10-11  9:14     ` Ori Kam
2021-10-11  9:31     ` Andrew Rybchenko
2021-10-12  8:06 ` [dpdk-dev] [PATCH v3 0/5] ethdev: update modify field flow action Viacheslav Ovsiienko
2021-10-12  8:06   ` [dpdk-dev] [PATCH v3 1/5] " Viacheslav Ovsiienko
2021-10-12  8:16     ` Andrew Rybchenko
2021-10-12  8:06   ` [dpdk-dev] [PATCH v3 2/5] ethdev: fix missed experimental tag for modify field action Viacheslav Ovsiienko
2021-10-12  8:13     ` Ori Kam
2021-10-12  8:14     ` Andrew Rybchenko
2021-10-12  8:06   ` [dpdk-dev] [PATCH v3 3/5] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-10-12  8:06   ` [dpdk-dev] [PATCH v3 4/5] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-12  8:06   ` Viacheslav Ovsiienko [this message]
2021-10-12 20:25 ` [dpdk-dev] [PATCH v5 0/5] ethdev: update modify field flow action Viacheslav Ovsiienko
2021-10-12 20:25   ` [dpdk-dev] [PATCH v5 1/5] " Viacheslav Ovsiienko
2021-10-12 20:25   ` [dpdk-dev] [PATCH v5 2/5] ethdev: fix missed experimental tag for modify field action Viacheslav Ovsiienko
2021-10-12 20:25   ` [dpdk-dev] [PATCH v5 3/5] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-10-12 20:25   ` [dpdk-dev] [PATCH v5 4/5] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-12 20:25   ` [dpdk-dev] [PATCH v5 5/5] net/mlx5: update modify field action Viacheslav Ovsiienko
2021-10-13 13:46   ` [dpdk-dev] [PATCH v5 0/5] ethdev: update modify field flow action Ferruh Yigit
2021-10-13 18:45 ` [dpdk-dev] [PATCH v6 " Viacheslav Ovsiienko
2021-10-13 18:45   ` [dpdk-dev] [PATCH v6 1/5] " Viacheslav Ovsiienko
2021-10-14 12:08     ` Ferruh Yigit
2021-10-14 20:07       ` Slava Ovsiienko
2021-10-13 18:45   ` [dpdk-dev] [PATCH v6 2/5] ethdev: fix missed experimental tag for modify field action Viacheslav Ovsiienko
2021-10-13 18:45   ` [dpdk-dev] [PATCH v6 3/5] app/testpmd: update modify field flow action support Viacheslav Ovsiienko
2021-10-13 18:45   ` [dpdk-dev] [PATCH v6 4/5] app/testpmd: fix hex string parser in flow commands Viacheslav Ovsiienko
2021-10-13 18:45   ` [dpdk-dev] [PATCH v6 5/5] net/mlx5: update modify field action Viacheslav Ovsiienko
2021-10-14 12:37   ` [dpdk-dev] [PATCH v6 0/5] ethdev: update modify field flow action Ferruh Yigit

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=20211012080631.28504-6-viacheslavo@nvidia.com \
    --to=viacheslavo@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=getelson@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=thomas@monjalon.net \
    /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).