diff options
author | Jiri Pirko <jiri@nvidia.com> | 2023-06-01 15:13:31 +0300 |
---|---|---|
committer | Saeed Mahameed <saeedm@nvidia.com> | 2023-08-23 07:34:18 +0300 |
commit | eb555e34f0841c880f709559d58866ff9d9321a1 (patch) | |
tree | ff9987b20e56916c4df12db5a703715d6c225786 /drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | |
parent | 5c632cc352e1ca7995e9ccea9a11f7f9a53b1717 (diff) | |
download | linux-eb555e34f0841c880f709559d58866ff9d9321a1.tar.xz |
net/mlx5: Check vhca_resource_manager capability in each op and add extack msg
Since the follow-up patch is going to remove
mlx5_devlink_port_fn_get_vport() entirely, move the vhca_resource_manager
capability checking to individual ops. Add proper extack message
on the way.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 23b562f07c68..e4d1744516f7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -4258,9 +4258,6 @@ mlx5_devlink_port_fn_get_vport(struct devlink_port *port, struct mlx5_eswitch *e { u16 vport_num; - if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) - return ERR_PTR(-EOPNOTSUPP); - vport_num = mlx5_esw_devlink_port_index_to_vport_num(port->index); return mlx5_eswitch_get_vport(esw, vport_num); } @@ -4276,6 +4273,11 @@ int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enab return -EOPNOTSUPP; } + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management"); + return -EOPNOTSUPP; + } + vport = mlx5_devlink_port_fn_get_vport(port, esw); if (IS_ERR(vport)) { NL_SET_ERR_MSG_MOD(extack, "Invalid port"); @@ -4303,6 +4305,11 @@ int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable, return -EOPNOTSUPP; } + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management"); + return -EOPNOTSUPP; + } + vport = mlx5_devlink_port_fn_get_vport(port, esw); if (IS_ERR(vport)) { NL_SET_ERR_MSG_MOD(extack, "Invalid port"); @@ -4354,6 +4361,11 @@ int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled, struct mlx5_eswitch *esw = mlx5_devlink_eswitch_nocheck_get(port->devlink); struct mlx5_vport *vport; + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management"); + return -EOPNOTSUPP; + } + vport = mlx5_devlink_port_fn_get_vport(port, esw); if (IS_ERR(vport)) { NL_SET_ERR_MSG_MOD(extack, "Invalid port"); @@ -4377,6 +4389,11 @@ int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable, u16 vport_num; int err; + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management"); + return -EOPNOTSUPP; + } + vport = mlx5_devlink_port_fn_get_vport(port, esw); if (IS_ERR(vport)) { NL_SET_ERR_MSG_MOD(extack, "Invalid port"); |