From: Dekel Peled Date: Sun, 17 Jan 2021 09:40:46 +0000 (+0200) Subject: net/mlx5: fix flow split combined with counter X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=63f4d5693ed8459f8867a23d0b87cf9c60983767;p=dpdk.git net/mlx5: fix flow split combined with counter Currently, for a flow containing a count action, if flow is split to sub-flows, a new counter will be created for each sub-flow. However only the counter created for the last sub-flow will be queried on flow query and cleared on flow removal. This behavior is wrong, causing a leak of resources. Need to create just one counter per flow, and use it for all sub-flows. This patch adds the required check to make sure a counter is created just once per flow, and used by all sub-flows. Fixes: fa2d01c87d2b ("net/mlx5: support flow aging") Cc: stable@dpdk.org Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 5e34cbeea9..012d5893ba 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -10681,17 +10681,22 @@ flow_dv_translate(struct rte_eth_dev *dev, handle->dvh.modify_hdr->action; } if (action_flags & MLX5_FLOW_ACTION_COUNT) { - flow->counter = - flow_dv_translate_create_counter(dev, - dev_flow, count, age); - - if (!flow->counter) - return rte_flow_error_set + /* + * Create one count action, to be used + * by all sub-flows. + */ + if (!flow->counter) { + flow->counter = + flow_dv_translate_create_counter + (dev, dev_flow, count, + age); + if (!flow->counter) + return rte_flow_error_set (error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, - "cannot create counter" - " object."); + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "cannot create counter" + " object."); + } dev_flow->dv.actions[actions_n] = (flow_dv_counter_get_by_idx(dev, flow->counter, NULL))->action;