Commit 8c98ee77 authored by Eli Britstein's avatar Eli Britstein Committed by Saeed Mahameed

net/mlx5e: E-Switch, Add extack messages to devlink callbacks

Return extack messages for failures in the e-switch devlink callbacks.
Messages provide reasons for not being able to issue the operation.
Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent db7ff19e
...@@ -816,24 +816,29 @@ static int esw_offloads_start(struct mlx5_eswitch *esw, ...@@ -816,24 +816,29 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs; int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
if (esw->mode != SRIOV_LEGACY) { if (esw->mode != SRIOV_LEGACY) {
esw_warn(esw->dev, "Can't set offloads mode, SRIOV legacy not enabled\n"); NL_SET_ERR_MSG_MOD(extack,
"Can't set offloads mode, SRIOV legacy not enabled");
return -EINVAL; return -EINVAL;
} }
mlx5_eswitch_disable_sriov(esw); mlx5_eswitch_disable_sriov(esw);
err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS); err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);
if (err) { if (err) {
esw_warn(esw->dev, "Failed setting eswitch to offloads, err %d\n", err); NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch to offloads");
err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY); err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
if (err1) if (err1) {
esw_warn(esw->dev, "Failed setting eswitch back to legacy, err %d\n", err1); NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch back to legacy");
}
} }
if (esw->offloads.inline_mode == MLX5_INLINE_MODE_NONE) { if (esw->offloads.inline_mode == MLX5_INLINE_MODE_NONE) {
if (mlx5_eswitch_inline_mode_get(esw, if (mlx5_eswitch_inline_mode_get(esw,
num_vfs, num_vfs,
&esw->offloads.inline_mode)) { &esw->offloads.inline_mode)) {
esw->offloads.inline_mode = MLX5_INLINE_MODE_L2; esw->offloads.inline_mode = MLX5_INLINE_MODE_L2;
esw_warn(esw->dev, "Inline mode is different between vports\n"); NL_SET_ERR_MSG_MOD(extack,
"Inline mode is different between vports");
} }
} }
return err; return err;
...@@ -982,10 +987,12 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, ...@@ -982,10 +987,12 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
mlx5_eswitch_disable_sriov(esw); mlx5_eswitch_disable_sriov(esw);
err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY); err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
if (err) { if (err) {
esw_warn(esw->dev, "Failed setting eswitch to legacy, err %d\n", err); NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");
err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS); err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);
if (err1) if (err1) {
esw_warn(esw->dev, "Failed setting eswitch back to offloads, err %d\n", err); NL_SET_ERR_MSG_MOD(extack,
"Failed setting eswitch back to offloads");
}
} }
/* enable back PF RoCE */ /* enable back PF RoCE */
...@@ -1151,14 +1158,15 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode, ...@@ -1151,14 +1158,15 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
return 0; return 0;
/* fall through */ /* fall through */
case MLX5_CAP_INLINE_MODE_L2: case MLX5_CAP_INLINE_MODE_L2:
esw_warn(dev, "Inline mode can't be set\n"); NL_SET_ERR_MSG_MOD(extack, "Inline mode can't be set");
return -EOPNOTSUPP; return -EOPNOTSUPP;
case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT: case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT:
break; break;
} }
if (esw->offloads.num_flows > 0) { if (esw->offloads.num_flows > 0) {
esw_warn(dev, "Can't set inline mode when flows are configured\n"); NL_SET_ERR_MSG_MOD(extack,
"Can't set inline mode when flows are configured");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1169,8 +1177,8 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode, ...@@ -1169,8 +1177,8 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
for (vport = 1; vport < esw->enabled_vports; vport++) { for (vport = 1; vport < esw->enabled_vports; vport++) {
err = mlx5_modify_nic_vport_min_inline(dev, vport, mlx5_mode); err = mlx5_modify_nic_vport_min_inline(dev, vport, mlx5_mode);
if (err) { if (err) {
esw_warn(dev, "Failed to set min inline on vport %d\n", NL_SET_ERR_MSG_MOD(extack,
vport); "Failed to set min inline on vport");
goto revert_inline_mode; goto revert_inline_mode;
} }
} }
...@@ -1264,7 +1272,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap, ...@@ -1264,7 +1272,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,
return 0; return 0;
if (esw->offloads.num_flows > 0) { if (esw->offloads.num_flows > 0) {
esw_warn(dev, "Can't set encapsulation when flows are configured\n"); NL_SET_ERR_MSG_MOD(extack,
"Can't set encapsulation when flows are configured");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1273,7 +1282,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap, ...@@ -1273,7 +1282,8 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, u8 encap,
esw->offloads.encap = encap; esw->offloads.encap = encap;
err = esw_create_offloads_fast_fdb_table(esw); err = esw_create_offloads_fast_fdb_table(esw);
if (err) { if (err) {
esw_warn(esw->dev, "Failed re-creating fast FDB table, err %d\n", err); NL_SET_ERR_MSG_MOD(extack,
"Failed re-creating fast FDB table");
esw->offloads.encap = !encap; esw->offloads.encap = !encap;
(void)esw_create_offloads_fast_fdb_table(esw); (void)esw_create_offloads_fast_fdb_table(esw);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment