DPDK patches and discussions
 help / color / mirror / Atom feed
* Looks like a bug: operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags'
@ 2025-05-27 19:32 Andre Muezerie
  2025-05-28 12:50 ` Suanming Mou
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Muezerie @ 2025-05-27 19:32 UTC (permalink / raw)
  To: Dariusz Sosnowski, Viacheslav Ovsiienko, Bing Zhao, Ori Kam,
	Suanming Mou, Matan Azrad
  Cc: dev

Hi Folks,


Compiling with MSCS resulted in the warning below:

../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

It looks like a legit bug. Here is the offending line:

	struct mlx5dv_flow_matcher_attr dv_attr = {
		.type = IBV_FLOW_ATTR_NORMAL | IBV_FLOW_ATTR_FLAGS_EGRESS,

As the warning states, the constants in the bitwise operation belong to different enums, and these enums have overlaping values, which makes the bitwise operation very suspicious.
On top of that, I see that struct mlx5dv_flow_matcher_attr has a field named "flags" which accepts values from ibv_flow_flags:

	struct mlx5dv_flow_matcher_attr {
		enum ibv_flow_attr_type type;
		uint32_t flags; /* From enum ibv_flow_flags. */

Could someone more familiar with the code take a look and make a fix if needed? My goal here is just to get the code to compile with MSVC without warnings. I can add a cast to remove the warning if this is indeed how the code should be, but I don't want to do this unless I get confirmation that this would be the right course of action.

Thanks,

Andre Muezerie

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Looks like a bug: operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags'
  2025-05-27 19:32 Looks like a bug: operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags' Andre Muezerie
@ 2025-05-28 12:50 ` Suanming Mou
  0 siblings, 0 replies; 2+ messages in thread
From: Suanming Mou @ 2025-05-28 12:50 UTC (permalink / raw)
  To: Andre Muezerie, Dariusz Sosnowski, Slava Ovsiienko, Bing Zhao,
	Ori Kam, Matan Azrad
  Cc: dev

Hi Andre,


> -----Original Message-----
> From: Andre Muezerie <andremue@linux.microsoft.com>
> Sent: Wednesday, May 28, 2025 3:33 AM
> To: Dariusz Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Bing Zhao <bingz@nvidia.com>; Ori Kam
> <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan
> Azrad <matan@nvidia.com>
> Cc: dev@dpdk.org
> Subject: Looks like a bug: operands are different enum types
> 'ibv_flow_attr_type' and 'ibv_flow_flags'
> 
> Hi Folks,
> 
> 
> Compiling with MSCS resulted in the warning below:
> 
> ../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
> 
> It looks like a legit bug. Here is the offending line:
> 
> 	struct mlx5dv_flow_matcher_attr dv_attr = {
> 		.type = IBV_FLOW_ATTR_NORMAL |
> IBV_FLOW_ATTR_FLAGS_EGRESS,
> 
> As the warning states, the constants in the bitwise operation belong to
> different enums, and these enums have overlaping values, which makes the
> bitwise operation very suspicious.
> On top of that, I see that struct mlx5dv_flow_matcher_attr has a field named
> "flags" which accepts values from ibv_flow_flags:
> 
> 	struct mlx5dv_flow_matcher_attr {
> 		enum ibv_flow_attr_type type;
> 		uint32_t flags; /* From enum ibv_flow_flags. */
> 
> Could someone more familiar with the code take a look and make a fix if
> needed? My goal here is just to get the code to compile with MSVC without
> warnings. I can add a cast to remove the warning if this is indeed how the
> code should be, but I don't want to do this unless I get confirmation that this
> would be the right course of action.

Yes, I think you are right. ` IBV_FLOW_ATTR_FLAGS_EGRESS ` should goes to flags.
Thanks for the reporting. 
Will first try to verify how it works even with the incorrect initialization.

> 
> Thanks,
> 
> Andre Muezerie

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-28 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-27 19:32 Looks like a bug: operands are different enum types 'ibv_flow_attr_type' and 'ibv_flow_flags' Andre Muezerie
2025-05-28 12:50 ` Suanming Mou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).