forked from luck/tmp_suning_uos_patched
net/mlx5: Align sriov/eswitch modules with the new load/unload flow.
Init/cleanup sriov/eswitch in the core software context init/cleanup flows. Attach/detach sriov/eswitch in the core load/unload flows. Signed-off-by: Mohamad Haj Yahia <mohamad@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
62a9b90ad8
commit
c2d6e31a00
|
@ -1654,7 +1654,6 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
|
||||||
esw->enabled_vports = 0;
|
esw->enabled_vports = 0;
|
||||||
esw->mode = SRIOV_NONE;
|
esw->mode = SRIOV_NONE;
|
||||||
|
|
||||||
mlx5_eswitch_attach(esw);
|
|
||||||
dev->priv.eswitch = esw;
|
dev->priv.eswitch = esw;
|
||||||
return 0;
|
return 0;
|
||||||
abort:
|
abort:
|
||||||
|
@ -1675,7 +1674,6 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
|
||||||
|
|
||||||
esw_info(esw->dev, "cleanup\n");
|
esw_info(esw->dev, "cleanup\n");
|
||||||
|
|
||||||
mlx5_eswitch_detach(esw);
|
|
||||||
esw->dev->priv.eswitch = NULL;
|
esw->dev->priv.eswitch = NULL;
|
||||||
destroy_workqueue(esw->work_queue);
|
destroy_workqueue(esw->work_queue);
|
||||||
kfree(esw->l2_table.bitmap);
|
kfree(esw->l2_table.bitmap);
|
||||||
|
|
|
@ -1136,8 +1136,30 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
|
||||||
goto err_tables_cleanup;
|
goto err_tables_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
|
err = mlx5_eswitch_init(dev);
|
||||||
|
if (err) {
|
||||||
|
dev_err(&pdev->dev, "Failed to init eswitch %d\n", err);
|
||||||
|
goto err_rl_cleanup;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
err = mlx5_sriov_init(dev);
|
||||||
|
if (err) {
|
||||||
|
dev_err(&pdev->dev, "Failed to init sriov %d\n", err);
|
||||||
|
goto err_eswitch_cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_eswitch_cleanup:
|
||||||
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
|
mlx5_eswitch_cleanup(dev->priv.eswitch);
|
||||||
|
|
||||||
|
err_rl_cleanup:
|
||||||
|
#endif
|
||||||
|
mlx5_cleanup_rl_table(dev);
|
||||||
|
|
||||||
err_tables_cleanup:
|
err_tables_cleanup:
|
||||||
mlx5_cleanup_mkey_table(dev);
|
mlx5_cleanup_mkey_table(dev);
|
||||||
mlx5_cleanup_srq_table(dev);
|
mlx5_cleanup_srq_table(dev);
|
||||||
|
@ -1153,6 +1175,10 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
|
||||||
|
|
||||||
static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
|
static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
|
||||||
{
|
{
|
||||||
|
mlx5_sriov_cleanup(dev);
|
||||||
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
|
mlx5_eswitch_cleanup(dev->priv.eswitch);
|
||||||
|
#endif
|
||||||
mlx5_cleanup_rl_table(dev);
|
mlx5_cleanup_rl_table(dev);
|
||||||
mlx5_cleanup_mkey_table(dev);
|
mlx5_cleanup_mkey_table(dev);
|
||||||
mlx5_cleanup_srq_table(dev);
|
mlx5_cleanup_srq_table(dev);
|
||||||
|
@ -1293,14 +1319,10 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MLX5_CORE_EN
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
err = mlx5_eswitch_init(dev);
|
mlx5_eswitch_attach(dev->priv.eswitch);
|
||||||
if (err) {
|
|
||||||
dev_err(&pdev->dev, "eswitch init failed %d\n", err);
|
|
||||||
goto err_reg_dev;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
err = mlx5_sriov_init(dev);
|
err = mlx5_sriov_attach(dev);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "sriov init failed %d\n", err);
|
dev_err(&pdev->dev, "sriov init failed %d\n", err);
|
||||||
goto err_sriov;
|
goto err_sriov;
|
||||||
|
@ -1324,11 +1346,11 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_reg_dev:
|
err_reg_dev:
|
||||||
mlx5_sriov_cleanup(dev);
|
mlx5_sriov_detach(dev);
|
||||||
|
|
||||||
err_sriov:
|
err_sriov:
|
||||||
#ifdef CONFIG_MLX5_CORE_EN
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
mlx5_eswitch_cleanup(dev->priv.eswitch);
|
mlx5_eswitch_detach(dev->priv.eswitch);
|
||||||
#endif
|
#endif
|
||||||
mlx5_cleanup_fs(dev);
|
mlx5_cleanup_fs(dev);
|
||||||
|
|
||||||
|
@ -1394,9 +1416,9 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
|
||||||
if (mlx5_device_registered(dev))
|
if (mlx5_device_registered(dev))
|
||||||
mlx5_detach_device(dev);
|
mlx5_detach_device(dev);
|
||||||
|
|
||||||
mlx5_sriov_cleanup(dev);
|
mlx5_sriov_detach(dev);
|
||||||
#ifdef CONFIG_MLX5_CORE_EN
|
#ifdef CONFIG_MLX5_CORE_EN
|
||||||
mlx5_eswitch_cleanup(dev->priv.eswitch);
|
mlx5_eswitch_detach(dev->priv.eswitch);
|
||||||
#endif
|
#endif
|
||||||
mlx5_cleanup_fs(dev);
|
mlx5_cleanup_fs(dev);
|
||||||
mlx5_irq_clear_affinity_hints(dev);
|
mlx5_irq_clear_affinity_hints(dev);
|
||||||
|
|
|
@ -222,7 +222,7 @@ int mlx5_sriov_init(struct mlx5_core_dev *dev)
|
||||||
if (!sriov->vfs_ctx)
|
if (!sriov->vfs_ctx)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
return mlx5_sriov_attach(dev);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mlx5_sriov_cleanup(struct mlx5_core_dev *dev)
|
void mlx5_sriov_cleanup(struct mlx5_core_dev *dev)
|
||||||
|
@ -231,6 +231,6 @@ void mlx5_sriov_cleanup(struct mlx5_core_dev *dev)
|
||||||
|
|
||||||
if (!mlx5_core_is_pf(dev))
|
if (!mlx5_core_is_pf(dev))
|
||||||
return;
|
return;
|
||||||
mlx5_sriov_detach(dev);
|
|
||||||
kfree(sriov->vfs_ctx);
|
kfree(sriov->vfs_ctx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user