diff mbox series

[v1] net/mlx5: fix meter flow id

Message ID 20210512102100.23870-1-shunh@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series [v1] net/mlx5: fix meter flow id | expand

Checks

Context Check Description
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/iol-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Shun Hao May 12, 2021, 10:20 a.m. UTC
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: 83306d6c46 ("net/mlx5: fix meter statistics")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Monjalon May 12, 2021, 12:50 p.m. UTC | #1
> > 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: 83306d6c46 ("net/mlx5: fix meter statistics")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Shun Hao <shunh@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Applied in next-net-mlx, thanks.
diff mbox series

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 32634c9af7..edfac0d99f 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -4794,8 +4794,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);