This patch adds support for using flow counters with offsets within a DevX bulk, in flow rules on root table, in HWS layer.
Signed-off-by: Dariusz Sosnowski <[email protected]> --- drivers/net/mlx5/hws/mlx5dr.h | 14 ++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 20 +++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 58526fc08e..c13316305f 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -738,6 +738,20 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx, struct mlx5dr_devx_obj *obj, uint32_t flags); +/* Check if counter action on root table is supported. + * + * @return true if counter action on root table is supported. + */ +static inline bool +mlx5dr_action_counter_root_is_supported(void) +{ +#ifdef HAVE_MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET + return true; +#else + return false; +#endif +} + /* Create direct rule reformat action. * * @param[in] ctx diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index d765d57a8f..b35bf07c3c 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -832,16 +832,11 @@ int mlx5dr_action_root_build_attr(struct mlx5dr_rule_action rule_actions[], attr[i].type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION; attr[i].action = action->flow_action; break; -#ifdef HAVE_IBV_FLOW_DEVX_COUNTERS +#ifdef HAVE_MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET case MLX5DR_ACTION_TYP_CTR: - attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX; - attr[i].obj = action->devx_obj; - - if (rule_actions[i].counter.offset) { - DR_LOG(ERR, "Counter offset not supported over root"); - rte_errno = ENOTSUP; - return rte_errno; - } + attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET; + attr[i].bulk_obj.obj = action->devx_obj; + attr[i].bulk_obj.offset = rule_actions[i].counter.offset; break; #endif default: @@ -1712,6 +1707,13 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx, return NULL; } + if (mlx5dr_action_is_root_flags(flags) && + !mlx5dr_action_counter_root_is_supported()) { + DR_LOG(ERR, "Counter action is not supported on root"); + rte_errno = ENOTSUP; + return NULL; + } + action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_CTR); if (!action) return NULL; -- 2.39.5

