aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2026-10-21 13:25:38 +0200
committerPaolo Abeni <pabeni@redhat.com>2026-10-21 13:25:39 +0200
commitabeacca61eea4f6803df4a595b656ea45c2d3249 (patch)
tree1fc3be646900698ccaee5b773bca5dafa1b8de9d
parent1234707482053f1d1ac7c5756207d2c29057974c (diff)
parentd425ec9bb9371d52d492ac4d09f0da6e26561684 (diff)
Merge branch 'net-mlx5-hws-fix-modify-header-pattern-compare'
Alexandre Cassen says: ==================== net/mlx5: HWS, fix modify header pattern compare The fs_hws modify header pools and the HWS pattern cache decide whether two modify headers can share a pattern. Two bugs let different patterns compare equal: - On big-endian the HWS core comparison checks the data dword of each action instead of its control dword. - The fs_hws pool match ignores the destination of copy and add_field actions. Patch 2 moves the pool match to the HWS core comparison that patch 1 fixes. v2: https://lore.kernel.org/netdev/20261012101937.1335231-1-acassen@corp.free.fr/ v1: https://lore.kernel.org/netdev/20261010120147.135825-1-acassen@corp.free.fr/ ==================== Link: https://patch.msgid.link/20261019133159.1742411-1-acassen@corp.free.fr Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h5
3 files changed, 15 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c
index 86828e329187..05aa143fa088 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c
@@ -3,6 +3,7 @@
#include <mlx5_core.h>
#include "fs_hws_pools.h"
+#include "internal.h"
#define MLX5_FS_HWS_DEFAULT_BULK_LEN 65536
#define MLX5_FS_HWS_POOL_MAX_THRESHOLD BIT(18)
@@ -389,7 +390,7 @@ bool mlx5_fs_hws_mh_pool_match(struct mlx5_fs_pool *mh_pool,
struct mlx5hws_action_mh_pattern *pattern)
{
struct mlx5hws_action_mh_pattern *pool_pattern;
- int num_actions, i;
+ int num_actions;
pool_pattern = mh_pool->pool_ctx;
if (WARN_ON_ONCE(!pool_pattern))
@@ -398,12 +399,8 @@ bool mlx5_fs_hws_mh_pool_match(struct mlx5_fs_pool *mh_pool,
if (pattern->sz != pool_pattern->sz)
return false;
num_actions = pattern->sz / MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto);
- for (i = 0; i < num_actions; i++) {
- if ((__force __be32)pattern->data[i] !=
- (__force __be32)pool_pattern->data[i])
- return false;
- }
- return true;
+ return mlx5hws_pat_compare_pattern(num_actions, pool_pattern->data,
+ num_actions, pattern->data);
}
struct mlx5hws_action *mlx5_fc_get_hws_action(struct mlx5hws_context *ctx,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c
index 9af449c2b4d5..a49115f04025 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c
@@ -96,10 +96,10 @@ void mlx5hws_pat_uninit_pattern_cache(struct mlx5hws_pattern_cache *cache)
kfree(cache);
}
-static bool mlx5hws_pat_compare_pattern(int cur_num_of_actions,
- __be64 cur_actions[],
- int num_of_actions,
- __be64 actions[])
+bool mlx5hws_pat_compare_pattern(int cur_num_of_actions,
+ __be64 cur_actions[],
+ int num_of_actions,
+ __be64 actions[])
{
int i;
@@ -116,8 +116,8 @@ static bool mlx5hws_pat_compare_pattern(int cur_num_of_actions,
return false;
} else {
/* Compare just the control, not the values */
- if ((__force __be32)actions[i] !=
- (__force __be32)cur_actions[i])
+ if (*(__be32 *)&actions[i] !=
+ *(__be32 *)&cur_actions[i])
return false;
}
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h
index 7fbd8dc7aa18..2be7787104e1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.h
@@ -49,6 +49,11 @@ int mlx5hws_pat_init_pattern_cache(struct mlx5hws_pattern_cache **cache);
void mlx5hws_pat_uninit_pattern_cache(struct mlx5hws_pattern_cache *cache);
+bool mlx5hws_pat_compare_pattern(int cur_num_of_actions,
+ __be64 cur_actions[],
+ int num_of_actions,
+ __be64 actions[]);
+
bool mlx5hws_pat_verify_actions(struct mlx5hws_context *ctx, __be64 pattern[], size_t sz);
int mlx5hws_arg_create(struct mlx5hws_context *ctx,