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>
This commit is contained in:
committed by
Saeed Mahameed
parent
5c632cc352
commit
eb555e34f0
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user