Skip to contentSkip to conversation

net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping

bug report Dan Carpenter 3 participants 5 messages Feb 10, 2021 – Feb 12, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello Vlad Buslov,

The patch 84ae9c1f29c0: "net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping" from Sep 23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/vport.c:1170 mlx5_vport_get_other_func_cap()
	warn: odd binop '0x0 & 0x1'

drivers/net/ethernet/mellanox/mlx5/core/vport.c
1168 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) 1169 {
1170 u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);

HCA_CAP_OPMOD_GET_MAX is zero. The 0x01 is a magical number.

  1171          u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
  1172  
  1173          MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
  1174          MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
  1175          MLX5_SET(query_hca_cap_in, in, function_id, function_id);
  1176          MLX5_SET(query_hca_cap_in, in, other_function, true);
  1177          return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
  1178  }

regards,
dan carpenter

#1 lore raw
Quoted 16 lines · Dan Carpenter

Hello Vlad Buslov,

The patch 84ae9c1f29c0: "net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping" from Sep 23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/vport.c:1170 mlx5_vport_get_other_func_cap()
	warn: odd binop '0x0 & 0x1'

drivers/net/ethernet/mellanox/mlx5/core/vport.c
1168 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) 1169 {
1170 u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);

HCA_CAP_OPMOD_GET_MAX is zero. The 0x01 is a magical number.

Quoted 8 lines
  1171          u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
  1172
  1173          MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
  1174          MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
  1175          MLX5_SET(query_hca_cap_in, in, function_id, function_id);
  1176          MLX5_SET(query_hca_cap_in, in, other_function, true);
  1177          return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
  1178  }

Dan,

I'm running smatch which is based on 6193b3b71beb ("extra: fix some error pointer handling") and I don't see this error. Should I run something special?

Thanks

Quoted 3 lines

regards,
dan carpenter

#2 lore raw
Quoted 26 lines · Leon Romanovsky
Quoted 16 lines · Dan Carpenter

Hello Vlad Buslov,

The patch 84ae9c1f29c0: "net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping" from Sep 23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/vport.c:1170 mlx5_vport_get_other_func_cap()
	warn: odd binop '0x0 & 0x1'

drivers/net/ethernet/mellanox/mlx5/core/vport.c
1168 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) 1169 {
1170 u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);

HCA_CAP_OPMOD_GET_MAX is zero. The 0x01 is a magical number.

Quoted 8 lines
  1171          u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
  1172
  1173          MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
  1174          MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
  1175          MLX5_SET(query_hca_cap_in, in, function_id, function_id);
  1176          MLX5_SET(query_hca_cap_in, in, other_function, true);
  1177          return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
  1178  }
Quoted 5 lines

Dan,

I'm running smatch which is based on 6193b3b71beb ("extra: fix some error pointer handling") and I don't see this error. Should I run something special?

This check is too crap to publish.

The heuristic was "a bitwise AND which always results in zero" but a lot of code does stuff like: "data = 0x00 << 0 | 0x04 << 8 | 0x12 << 16;" I could never figure out a way to make the check useful enough to publish.

regards,
dan carpenter

#3 lore raw
Quoted 33 lines · Dan Carpenter
Quoted 26 lines · Leon Romanovsky
Quoted 16 lines · Dan Carpenter

Hello Vlad Buslov,

The patch 84ae9c1f29c0: "net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping" from Sep 23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/vport.c:1170 mlx5_vport_get_other_func_cap()
	warn: odd binop '0x0 & 0x1'

drivers/net/ethernet/mellanox/mlx5/core/vport.c
1168 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) 1169 {
1170 u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);

HCA_CAP_OPMOD_GET_MAX is zero. The 0x01 is a magical number.

Quoted 8 lines
  1171          u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
  1172
  1173          MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
  1174          MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
  1175          MLX5_SET(query_hca_cap_in, in, function_id, function_id);
  1176          MLX5_SET(query_hca_cap_in, in, other_function, true);
  1177          return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
  1178  }
Quoted 5 lines

Dan,

I'm running smatch which is based on 6193b3b71beb ("extra: fix some error pointer handling") and I don't see this error. Should I run something special?

Quoted 6 lines

This check is too crap to publish.

The heuristic was "a bitwise AND which always results in zero" but a lot of code does stuff like: "data = 0x00 << 0 | 0x04 << 8 | 0x12 << 16;" I could never figure out a way to make the check useful enough to publish.

But you can warn about simple cases like above, which is constant zero AND something.

Thanks

Quoted 4 lines

regards,
dan carpenter

#4 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

Hello Vlad Buslov,

The patch 84ae9c1f29c0: "net/mlx5e: E-Switch, Maintain vhca_id to vport_num mapping" from Sep 23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/vport.c:1170 mlx5_vport_get_other_func_cap()
	warn: odd binop '0x0 & 0x1'
Quoted 6 lines

drivers/net/ethernet/mellanox/mlx5/core/vport.c
1168 int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) 1169 {
1170 u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);

HCA_CAP_OPMOD_GET_MAX is zero. The 0x01 is a magical number.

Hi Dan,

Thanks for reporting and sorry for the late reply. Adding Saeed, we will handle the issue.

Regards,
Vlad

[...]