Skip to content

Commit eb555e3

Browse files
Jiri PirkoSaeed Mahameed
authored andcommitted
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>
1 parent 5c632cc commit eb555e3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,9 +4258,6 @@ mlx5_devlink_port_fn_get_vport(struct devlink_port *port, struct mlx5_eswitch *e
42584258
{
42594259
u16 vport_num;
42604260

4261-
if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager))
4262-
return ERR_PTR(-EOPNOTSUPP);
4263-
42644261
vport_num = mlx5_esw_devlink_port_index_to_vport_num(port->index);
42654262
return mlx5_eswitch_get_vport(esw, vport_num);
42664263
}
@@ -4276,6 +4273,11 @@ int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enab
42764273
return -EOPNOTSUPP;
42774274
}
42784275

4276+
if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
4277+
NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
4278+
return -EOPNOTSUPP;
4279+
}
4280+
42794281
vport = mlx5_devlink_port_fn_get_vport(port, esw);
42804282
if (IS_ERR(vport)) {
42814283
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,
43034305
return -EOPNOTSUPP;
43044306
}
43054307

4308+
if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
4309+
NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
4310+
return -EOPNOTSUPP;
4311+
}
4312+
43064313
vport = mlx5_devlink_port_fn_get_vport(port, esw);
43074314
if (IS_ERR(vport)) {
43084315
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,
43544361
struct mlx5_eswitch *esw = mlx5_devlink_eswitch_nocheck_get(port->devlink);
43554362
struct mlx5_vport *vport;
43564363

4364+
if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
4365+
NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
4366+
return -EOPNOTSUPP;
4367+
}
4368+
43574369
vport = mlx5_devlink_port_fn_get_vport(port, esw);
43584370
if (IS_ERR(vport)) {
43594371
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,
43774389
u16 vport_num;
43784390
int err;
43794391

4392+
if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) {
4393+
NL_SET_ERR_MSG_MOD(extack, "Device doesn't support VHCA management");
4394+
return -EOPNOTSUPP;
4395+
}
4396+
43804397
vport = mlx5_devlink_port_fn_get_vport(port, esw);
43814398
if (IS_ERR(vport)) {
43824399
NL_SET_ERR_MSG_MOD(extack, "Invalid port");

0 commit comments

Comments
 (0)