* [bug report] net/mlx5: Implement devlink total_vfs parameter
@ 2025-09-12 12:47 Dan Carpenter
2025-09-14 17:04 ` Vlad Dumitrescu
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-09-12 12:47 UTC (permalink / raw)
To: Vlad Dumitrescu; +Cc: linux-rdma
Hello Vlad Dumitrescu,
Commit a4c49611cf4f ("net/mlx5: Implement devlink total_vfs
parameter") from Sep 6, 2025 (linux-next), leads to the following
Smatch static checker warning:
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c:494 mlx5_devlink_total_vfs_set()
warn: duplicate check 'per_pf_support' (previous on line 479)
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c
455 static int mlx5_devlink_total_vfs_set(struct devlink *devlink, u32 id,
456 struct devlink_param_gset_ctx *ctx,
457 struct netlink_ext_ack *extack)
458 {
459 struct mlx5_core_dev *dev = devlink_priv(devlink);
460 u32 mnvda[MLX5_ST_SZ_DW(mnvda_reg)];
461 bool per_pf_support;
462 void *data;
463 int err;
464
465 err = mlx5_nv_param_read_global_pci_cap(dev, mnvda, sizeof(mnvda));
466 if (err) {
467 NL_SET_ERR_MSG_MOD(extack, "Failed to read global pci cap");
468 return err;
469 }
470
471 data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
472 if (!MLX5_GET(nv_global_pci_cap, data, sriov_support)) {
473 NL_SET_ERR_MSG_MOD(extack, "Not configurable on this device");
474 return -EOPNOTSUPP;
475 }
476
477 per_pf_support = MLX5_GET(nv_global_pci_cap, data,
478 per_pf_total_vf_supported);
479 if (!per_pf_support) {
480 /* We don't allow global SRIOV setting on per PF devlink */
481 NL_SET_ERR_MSG_MOD(extack,
482 "SRIOV is not per PF on this device");
483 return -EOPNOTSUPP;
!per_pf_support is not supported.
484 }
485
486 memset(mnvda, 0, sizeof(mnvda));
487 err = mlx5_nv_param_read_global_pci_conf(dev, mnvda, sizeof(mnvda));
488 if (err)
489 return err;
490
491 MLX5_SET(nv_global_pci_conf, data, sriov_valid, 1);
492 MLX5_SET(nv_global_pci_conf, data, per_pf_total_vf, per_pf_support);
493
--> 494 if (!per_pf_support) {
495 MLX5_SET(nv_global_pci_conf, data, total_vfs, ctx->val.vu32);
496 return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
Dead code.
497 }
498
499 /* SRIOV is per PF */
500 err = mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
501 if (err)
502 return err;
503
504 memset(mnvda, 0, sizeof(mnvda));
505 err = mlx5_nv_param_read_per_host_pf_conf(dev, mnvda, sizeof(mnvda));
506 if (err)
507 return err;
508
509 data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
510 MLX5_SET(nv_pf_pci_conf, data, total_vf, ctx->val.vu32);
511 return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
512 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] net/mlx5: Implement devlink total_vfs parameter
2025-09-12 12:47 [bug report] net/mlx5: Implement devlink total_vfs parameter Dan Carpenter
@ 2025-09-14 17:04 ` Vlad Dumitrescu
0 siblings, 0 replies; 2+ messages in thread
From: Vlad Dumitrescu @ 2025-09-14 17:04 UTC (permalink / raw)
To: Saeed Mahameed; +Cc: linux-rdma, Dan Carpenter
On 9/12/25 05:47, Dan Carpenter wrote:
> Hello Vlad Dumitrescu,
>
> Commit a4c49611cf4f ("net/mlx5: Implement devlink total_vfs
> parameter") from Sep 6, 2025 (linux-next), leads to the following
> Smatch static checker warning:
>
> drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c:494 mlx5_devlink_total_vfs_set()
> warn: duplicate check 'per_pf_support' (previous on line 479)
>
> drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c
> 455 static int mlx5_devlink_total_vfs_set(struct devlink *devlink, u32 id,
> 456 struct devlink_param_gset_ctx *ctx,
> 457 struct netlink_ext_ack *extack)
> 458 {
> 459 struct mlx5_core_dev *dev = devlink_priv(devlink);
> 460 u32 mnvda[MLX5_ST_SZ_DW(mnvda_reg)];
> 461 bool per_pf_support;
> 462 void *data;
> 463 int err;
> 464
> 465 err = mlx5_nv_param_read_global_pci_cap(dev, mnvda, sizeof(mnvda));
> 466 if (err) {
> 467 NL_SET_ERR_MSG_MOD(extack, "Failed to read global pci cap");
> 468 return err;
> 469 }
> 470
> 471 data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
> 472 if (!MLX5_GET(nv_global_pci_cap, data, sriov_support)) {
> 473 NL_SET_ERR_MSG_MOD(extack, "Not configurable on this device");
> 474 return -EOPNOTSUPP;
> 475 }
> 476
> 477 per_pf_support = MLX5_GET(nv_global_pci_cap, data,
> 478 per_pf_total_vf_supported);
> 479 if (!per_pf_support) {
> 480 /* We don't allow global SRIOV setting on per PF devlink */
> 481 NL_SET_ERR_MSG_MOD(extack,
> 482 "SRIOV is not per PF on this device");
> 483 return -EOPNOTSUPP;
>
> !per_pf_support is not supported.
>
> 484 }
> 485
> 486 memset(mnvda, 0, sizeof(mnvda));
> 487 err = mlx5_nv_param_read_global_pci_conf(dev, mnvda, sizeof(mnvda));
> 488 if (err)
> 489 return err;
> 490
> 491 MLX5_SET(nv_global_pci_conf, data, sriov_valid, 1);
> 492 MLX5_SET(nv_global_pci_conf, data, per_pf_total_vf, per_pf_support);
> 493
> --> 494 if (!per_pf_support) {
> 495 MLX5_SET(nv_global_pci_conf, data, total_vfs, ctx->val.vu32);
> 496 return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
>
> Dead code.
>
> 497 }
> 498
> 499 /* SRIOV is per PF */
> 500 err = mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
> 501 if (err)
> 502 return err;
> 503
> 504 memset(mnvda, 0, sizeof(mnvda));
> 505 err = mlx5_nv_param_read_per_host_pf_conf(dev, mnvda, sizeof(mnvda));
> 506 if (err)
> 507 return err;
> 508
> 509 data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
> 510 MLX5_SET(nv_pf_pci_conf, data, total_vf, ctx->val.vu32);
> 511 return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
> 512 }
Dan, thank you for the report!
Saeed, it seems like this was introduced all the way back in v2.
Vlad
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-14 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 12:47 [bug report] net/mlx5: Implement devlink total_vfs parameter Dan Carpenter
2025-09-14 17:04 ` Vlad Dumitrescu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox