net/mlx5: E-Switch, Handle mode change failures
E-switch mode changes involve creating HW tables, potentially allocating netdevices, etc, and things can fail. Add an attempt to rollback to the existing mode when changing to the new mode fails. Only if rollback fails, getting proper SRIOV functionality requires module unload or sriov disablement/enablement. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4eea37d7b9
commit
6c419ba8e2
|
@ -446,7 +446,7 @@ mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn)
|
|||
|
||||
static int esw_offloads_start(struct mlx5_eswitch *esw)
|
||||
{
|
||||
int err, num_vfs = esw->dev->priv.sriov.num_vfs;
|
||||
int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
|
||||
|
||||
if (esw->mode != SRIOV_LEGACY) {
|
||||
esw_warn(esw->dev, "Can't set offloads mode, SRIOV legacy not enabled\n");
|
||||
|
@ -455,8 +455,12 @@ static int esw_offloads_start(struct mlx5_eswitch *esw)
|
|||
|
||||
mlx5_eswitch_disable_sriov(esw);
|
||||
err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);
|
||||
if (err)
|
||||
esw_warn(esw->dev, "Failed set eswitch to offloads, err %d\n", err);
|
||||
if (err) {
|
||||
esw_warn(esw->dev, "Failed setting eswitch to offloads, err %d\n", err);
|
||||
err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
|
||||
if (err1)
|
||||
esw_warn(esw->dev, "Failed setting eswitch back to legacy, err %d\n", err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -508,12 +512,16 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
|
|||
|
||||
static int esw_offloads_stop(struct mlx5_eswitch *esw)
|
||||
{
|
||||
int err, num_vfs = esw->dev->priv.sriov.num_vfs;
|
||||
int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
|
||||
|
||||
mlx5_eswitch_disable_sriov(esw);
|
||||
err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
|
||||
if (err)
|
||||
esw_warn(esw->dev, "Failed set eswitch legacy mode. err %d\n", err);
|
||||
if (err) {
|
||||
esw_warn(esw->dev, "Failed setting eswitch to legacy, err %d\n", err);
|
||||
err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);
|
||||
if (err1)
|
||||
esw_warn(esw->dev, "Failed setting eswitch back to offloads, err %d\n", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue