]> git.hungrycats.org Git - linux/commitdiff
net/mlx5: Fix RoCE setting at HCA level
authorShay Drory <shayd@nvidia.com>
Wed, 9 Nov 2022 12:42:59 +0000 (14:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 11:00:35 +0000 (12:00 +0100)
[ Upstream commit c4ad5f2bdad56265b23d3635494ecdb205431807 ]

mlx5 PF can disable RoCE for its VFs and SFs. In such case RoCE is
marked as unsupported on those VFs/SFs.
The cited patch added an option for disable (and enable) RoCE at HCA
level. However, that commit didn't check whether RoCE is supported on
the HCA and enabled user to try and set RoCE to on.
Fix it by checking whether the HCA supports RoCE.

Fixes: fbfa97b4d79f ("net/mlx5: Disable roce at HCA level")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
drivers/net/ethernet/mellanox/mlx5/core/main.c

index 9e4e8d551884c36fabe10c0e8bb203ba259a9585..97e9ec44a759b3cb0eda9632836db1389aa5a653 100644 (file)
@@ -468,7 +468,7 @@ static int mlx5_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
        bool new_state = val.vbool;
 
        if (new_state && !MLX5_CAP_GEN(dev, roce) &&
-           !MLX5_CAP_GEN(dev, roce_rw_supported)) {
+           !(MLX5_CAP_GEN(dev, roce_rw_supported) && MLX5_CAP_GEN_MAX(dev, roce))) {
                NL_SET_ERR_MSG_MOD(extack, "Device doesn't support RoCE");
                return -EOPNOTSUPP;
        }
index dcc1e1b404e3e1fde692da484478f1f5eae4be4f..0a2f23a7082a8c2bc0e1d0c7295389495bde4760 100644 (file)
@@ -614,7 +614,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)
                MLX5_SET(cmd_hca_cap, set_hca_cap, num_total_dynamic_vf_msix,
                         MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix));
 
-       if (MLX5_CAP_GEN(dev, roce_rw_supported))
+       if (MLX5_CAP_GEN(dev, roce_rw_supported) && MLX5_CAP_GEN_MAX(dev, roce))
                MLX5_SET(cmd_hca_cap, set_hca_cap, roce,
                         mlx5_is_roce_on(dev));