Skip to contentSkip to conversation

net/mlx5: fix matcher flags in counter offset detection

PATCH In review Dariusz Sosnowski 4 participants 5 messages Aug 20, 2025 – Sep 1, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix matcher flags in counter offset detection

This patch fixes a bug in
mlx5_flow_dv_discover_counter_offset_support()
uncovered by a warning reported by MSVC:

../drivers/net/mlx5/mlx5_flow_dv.c(19636): warning C5287:
operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags';
use an explicit cast to silence this warning

IBV_FLOW_ATTR_FLAGS_EGRESS was incorrectly passed in to type field of mlx5dv_flow_matcher_attr struct,
instead of flags field.
As a result counter offset support discovery returned a false positive result on application with old rdma-core.

Bugzilla ID: 1758

Fixes 4fd5e1484887 ("net/mlx5: fix counter offset detection")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
index 7b9e5018b8..4a6f9d63fb 100644
@@ -19652,7 +19652,8 @@ mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev)
 		.size = sizeof(value.buf),
 	};
 	struct mlx5dv_flow_matcher_attr dv_attr = {
-		.type = IBV_FLOW_ATTR_NORMAL | IBV_FLOW_ATTR_FLAGS_EGRESS,
+		.type = IBV_FLOW_ATTR_NORMAL,
+		.flags = IBV_FLOW_ATTR_FLAGS_EGRESS,
 		.priority = 0,
 		.match_criteria_enable = 0,
 		.match_mask = (void *)&mask,

--
2.39.5

#1 lore raw
Quoted 16 lines · Dariusz Sosnowski

This patch fixes a bug in
mlx5_flow_dv_discover_counter_offset_support()
uncovered by a warning reported by MSVC:

../drivers/net/mlx5/mlx5_flow_dv.c(19636): warning C5287:
operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags';
use an explicit cast to silence this warning

IBV_FLOW_ATTR_FLAGS_EGRESS was incorrectly passed in to type field of mlx5dv_flow_matcher_attr struct,
instead of flags field.
As a result counter offset support discovery returned a false positive result on application with old rdma-core.

Quoted 7 lines

Bugzilla ID: 1758

Fixes 4fd5e1484887 ("net/mlx5: fix counter offset detection")

I did not test the patch, but on the principle this lgtm.

Andre, can you confirm it solves the build warning you were seeing with MSVC?

Signature · 1 line
David Marchand
#2 lore raw
Quoted 22 lines · David Marchand
Quoted 21 lines · Dariusz Sosnowski

This patch fixes a bug in
mlx5_flow_dv_discover_counter_offset_support()
uncovered by a warning reported by MSVC:

../drivers/net/mlx5/mlx5_flow_dv.c(19636): warning C5287:
operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags';
use an explicit cast to silence this warning

IBV_FLOW_ATTR_FLAGS_EGRESS was incorrectly passed in to type field of mlx5dv_flow_matcher_attr struct,
instead of flags field.
As a result counter offset support discovery returned a false positive result on application with old rdma-core.

Bugzilla ID: 1758

Fixes 4fd5e1484887 ("net/mlx5: fix counter offset detection")
Quoted 11 lines
Quoted 2 lines

I did not test the patch, but on the principle this lgtm.

Andre, can you confirm it solves the build warning you were seeing with MSVC?

Signature · 1 line
David Marchand

Dariusz and David,

This patch compiles cleanly with MSVC.
Thanks for fixing this bug!

Andre Muezerie

Acked-by on v1 1/1
#3 lore raw
In reply to Dariusz Sosnowski
Quoted 41 lines · Dariusz Sosnowski

This patch fixes a bug in
mlx5_flow_dv_discover_counter_offset_support()
uncovered by a warning reported by MSVC:

../drivers/net/mlx5/mlx5_flow_dv.c(19636): warning C5287:
operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags';
use an explicit cast to silence this warning

IBV_FLOW_ATTR_FLAGS_EGRESS was incorrectly passed in to type field of mlx5dv_flow_matcher_attr struct,
instead of flags field.
As a result counter offset support discovery returned a false positive result on application with old rdma-core.

Bugzilla ID: 1758

Fixes 4fd5e1484887 ("net/mlx5: fix counter offset detection")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_dv.c +2 -2
index 7b9e5018b8..4a6f9d63fb 100644
@@ -19652,7 +19652,8 @@ mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev)
 		.size = sizeof(value.buf),
 	};
 	struct mlx5dv_flow_matcher_attr dv_attr = {
-		.type = IBV_FLOW_ATTR_NORMAL | IBV_FLOW_ATTR_FLAGS_EGRESS,
+		.type = IBV_FLOW_ATTR_NORMAL,
+		.flags = IBV_FLOW_ATTR_FLAGS_EGRESS,
 		.priority = 0,
 		.match_criteria_enable = 0,
 		.match_mask = (void *)&mask,
--
Quoted 2 lines

2.39.5

This compiles cleanly with msvc. Thanks for fixing it.

#4 lore raw
In reply to Dariusz Sosnowski

Hi,

Quoted 15 lines · Dariusz Sosnowski

This patch fixes a bug in
mlx5_flow_dv_discover_counter_offset_support()
uncovered by a warning reported by MSVC:

../drivers/net/mlx5/mlx5_flow_dv.c(19636): warning C5287:
operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags';
use an explicit cast to silence this warning

IBV_FLOW_ATTR_FLAGS_EGRESS was incorrectly passed in to type field of mlx5dv_flow_matcher_attr struct,
instead of flags field.
As a result counter offset support discovery returned a false positive result on application with old rdma-core.

Quoted 7 lines

Bugzilla ID: 1758

Fixes 4fd5e1484887 ("net/mlx5: fix counter offset detection")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh