From c751be10272168119ea6ab50a197e5c4e9927d02 Mon Sep 17 00:00:00 2001 From: Shun Hao Date: Wed, 12 May 2021 13:20:59 +0300 Subject: [PATCH] net/mlx5: fix metering with flow ID 0 When getting meter flow_id bits, there's an issue that not handling correctly if flow_id is 0. This fix this issue that when flow_id is 0, treat it as 1 bit. Fixes: 83306d6c465a ("net/mlx5: fix meter statistics") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8d4b4a8187..23d4224ec5 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4802,8 +4802,8 @@ flow_meter_split_prep(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "Failed to allocate meter flow id."); flow_id = tag_id - 1; - flow_id_bits = MLX5_REG_BITS - __builtin_clz(flow_id); - flow_id_bits = flow_id_bits ? flow_id_bits : 1; + flow_id_bits = (!flow_id) ? 1 : + (MLX5_REG_BITS - __builtin_clz(flow_id)); if ((flow_id_bits + priv->sh->mtrmng->max_mtr_bits) > mtr_reg_bits) { mlx5_ipool_free(fm->flow_ipool, tag_id); -- 2.20.1