[v4] net/mlx5/hws: fix bug in pattern creation
Checks
Commit Message
When creating a new pattern the data area should be clean, otherwise
when the data will come from the arg object it will do OR operation on
the data part in the pattern and use the dirty area as is.
Now we clean the data area on each pattern creation.
Fixes: f8c8a6d8440d ("net/mlx5/hws: add action object")
Cc: stable@dpdk.org
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr_cmd.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Comments
Hi,
> -----Original Message-----
> From: Erez Shitrit <erezsh@nvidia.com>
> Sent: Wednesday, March 22, 2023 4:41 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Subject: [PATCH v4] net/mlx5/hws: fix bug in pattern creation
>
>
> When creating a new pattern the data area should be clean, otherwise
> when the data will come from the arg object it will do OR operation on
> the data part in the pattern and use the dirty area as is.
>
> Now we clean the data area on each pattern creation.
>
> Fixes: f8c8a6d8440d ("net/mlx5/hws: add action object")
> Cc: stable@dpdk.org
>
> Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
> Reviewed-by: Alex Vesker <valex@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
@@ -523,9 +523,11 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,
uint32_t in[MLX5_ST_SZ_DW(create_header_modify_pattern_in)] = {0};
uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
struct mlx5dr_devx_obj *devx_obj;
- void *pattern_data;
+ uint64_t *pattern_data;
+ int num_of_actions;
void *pattern;
void *attr;
+ int i;
if (pattern_length > MAX_ACTIONS_DATA_IN_HEADER_MODIFY) {
DR_LOG(ERR, "Pattern length %d exceeds limit %d",
@@ -551,9 +553,19 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,
/* Pattern_length is in ddwords */
MLX5_SET(header_modify_pattern_in, pattern, pattern_length, pattern_length / (2 * DW_SIZE));
- pattern_data = MLX5_ADDR_OF(header_modify_pattern_in, pattern, pattern_data);
+ pattern_data = (uint64_t *)MLX5_ADDR_OF(header_modify_pattern_in, pattern, pattern_data);
memcpy(pattern_data, actions, pattern_length);
+ num_of_actions = pattern_length / MLX5DR_MODIFY_ACTION_SIZE;
+ for (i = 0; i < num_of_actions; i++) {
+ int type;
+
+ type = MLX5_GET(set_action_in, &pattern_data[i], action_type);
+ if (type != MLX5_MODIFICATION_TYPE_COPY)
+ /* Action typ-copy use all bytes for control */
+ MLX5_SET(set_action_in, &pattern_data[i], data, 0);
+ }
+
devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
if (!devx_obj->obj) {
DR_LOG(ERR, "Failed to create header_modify_pattern");