diff mbox series

[v2,1/2] net/mlx5: fix metadata endianness in modify field action

Message ID 20220203084652.19167-1-viacheslavo@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series [v2,1/2] net/mlx5: fix metadata endianness in modify field action | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Slava Ovsiienko Feb. 3, 2022, 8:46 a.m. UTC
As modify field action immediate source parameter the metadata
should follow the CPU endianness (according to SET_META action
structure format), and mlx5 PMD wrongly handled the immediate
parameter metadata buffer as big-endian, resulting in wrong
metadata set action with incorrect endianness.

Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
Cc: stable@dpdk.org

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Raslan Darawsheh Feb. 9, 2022, 8:50 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Slava Ovsiienko <viacheslavo@nvidia.com>
> Sent: Thursday, February 3, 2022 10:47 AM
> To: dev@dpdk.org
> Cc: ferruh.yigit@intel.com; Matan Azrad <matan@nvidia.com>; Raslan
> Darawsheh <rasland@nvidia.com>; stable@dpdk.org
> Subject: [PATCH v2 1/2] net/mlx5: fix metadata endianness in modify field
> action
> 
> As modify field action immediate source parameter the metadata should
> follow the CPU endianness (according to SET_META action structure format),
> and mlx5 PMD wrongly handled the immediate parameter metadata buffer
> as big-endian, resulting in wrong metadata set action with incorrect
> endianness.
> 
> Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
diff mbox series

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index af90a7fd0a..10ef2af06a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1867,7 +1867,7 @@  flow_dv_convert_action_modify_field
 	struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = {
 								{0, 0, 0} };
 	uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
-	uint32_t type;
+	uint32_t type, meta = 0;
 	uint32_t shift = 0;
 
 	if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
@@ -1880,6 +1880,11 @@  flow_dv_convert_action_modify_field
 		item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ?
 					(void *)(uintptr_t)conf->src.pvalue :
 					(void *)(uintptr_t)&conf->src.value;
+		if (conf->dst.field == RTE_FLOW_FIELD_META) {
+			meta = *(const unaligned_uint32_t *)item.spec;
+			meta = rte_cpu_to_be_32(meta);
+			item.spec = &meta;
+		}
 	} else {
 		type = MLX5_MODIFICATION_TYPE_COPY;
 		/** For COPY fill the destination field (dcopy) without mask. */