Skip to content

Commit 21a82be

Browse files
sodarraslandarawsheh
authored andcommitted
net/mlx5/hws: support counter from DevX bulk on root table
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]> Acked-by: Bing Zhao <[email protected]>
1 parent 102a72d commit 21a82be

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

drivers/net/mlx5/hws/mlx5dr.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,20 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx,
738738
struct mlx5dr_devx_obj *obj,
739739
uint32_t flags);
740740

741+
/* Check if counter action on root table is supported.
742+
*
743+
* @return true if counter action on root table is supported.
744+
*/
745+
static inline bool
746+
mlx5dr_action_counter_root_is_supported(void)
747+
{
748+
#ifdef HAVE_MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET
749+
return true;
750+
#else
751+
return false;
752+
#endif
753+
}
754+
741755
/* Create direct rule reformat action.
742756
*
743757
* @param[in] ctx

drivers/net/mlx5/hws/mlx5dr_action.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -832,16 +832,11 @@ int mlx5dr_action_root_build_attr(struct mlx5dr_rule_action rule_actions[],
832832
attr[i].type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
833833
attr[i].action = action->flow_action;
834834
break;
835-
#ifdef HAVE_IBV_FLOW_DEVX_COUNTERS
835+
#ifdef HAVE_MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET
836836
case MLX5DR_ACTION_TYP_CTR:
837-
attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
838-
attr[i].obj = action->devx_obj;
839-
840-
if (rule_actions[i].counter.offset) {
841-
DR_LOG(ERR, "Counter offset not supported over root");
842-
rte_errno = ENOTSUP;
843-
return rte_errno;
844-
}
837+
attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX_WITH_OFFSET;
838+
attr[i].bulk_obj.obj = action->devx_obj;
839+
attr[i].bulk_obj.offset = rule_actions[i].counter.offset;
845840
break;
846841
#endif
847842
default:
@@ -1712,6 +1707,13 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx,
17121707
return NULL;
17131708
}
17141709

1710+
if (mlx5dr_action_is_root_flags(flags) &&
1711+
!mlx5dr_action_counter_root_is_supported()) {
1712+
DR_LOG(ERR, "Counter action is not supported on root");
1713+
rte_errno = ENOTSUP;
1714+
return NULL;
1715+
}
1716+
17151717
action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_CTR);
17161718
if (!action)
17171719
return NULL;

0 commit comments

Comments
 (0)