Commit d012f5d6 authored by Or Gerlitz's avatar Or Gerlitz Committed by Doug Ledford

IB/mlx5: Refactor registration to netdev notifier

Refactor the netdev notifier registration into a small helper function.

This is a pre-step towards having mlx5 IB device over an Ethernet port
which doesn't support RoCE. Also, renamed the de-registration helper
and the new helper as netdev notifier and not roce, to make it clear
this is not only used with roce.

This patch doesn't change any functionality.
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent b216af40
...@@ -2843,7 +2843,21 @@ static void mlx5_roce_lag_cleanup(struct mlx5_ib_dev *dev) ...@@ -2843,7 +2843,21 @@ static void mlx5_roce_lag_cleanup(struct mlx5_ib_dev *dev)
} }
} }
static void mlx5_remove_roce_notifier(struct mlx5_ib_dev *dev) static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev)
{
int err;
dev->roce.nb.notifier_call = mlx5_netdev_event;
err = register_netdevice_notifier(&dev->roce.nb);
if (err) {
dev->roce.nb.notifier_call = NULL;
return err;
}
return 0;
}
static void mlx5_remove_netdev_notifier(struct mlx5_ib_dev *dev)
{ {
if (dev->roce.nb.notifier_call) { if (dev->roce.nb.notifier_call) {
unregister_netdevice_notifier(&dev->roce.nb); unregister_netdevice_notifier(&dev->roce.nb);
...@@ -2855,12 +2869,9 @@ static int mlx5_enable_roce(struct mlx5_ib_dev *dev) ...@@ -2855,12 +2869,9 @@ static int mlx5_enable_roce(struct mlx5_ib_dev *dev)
{ {
int err; int err;
dev->roce.nb.notifier_call = mlx5_netdev_event; err = mlx5_add_netdev_notifier(dev);
err = register_netdevice_notifier(&dev->roce.nb); if (err)
if (err) {
dev->roce.nb.notifier_call = NULL;
return err; return err;
}
err = mlx5_nic_vport_enable_roce(dev->mdev); err = mlx5_nic_vport_enable_roce(dev->mdev);
if (err) if (err)
...@@ -2876,7 +2887,7 @@ static int mlx5_enable_roce(struct mlx5_ib_dev *dev) ...@@ -2876,7 +2887,7 @@ static int mlx5_enable_roce(struct mlx5_ib_dev *dev)
mlx5_nic_vport_disable_roce(dev->mdev); mlx5_nic_vport_disable_roce(dev->mdev);
err_unregister_netdevice_notifier: err_unregister_netdevice_notifier:
mlx5_remove_roce_notifier(dev); mlx5_remove_netdev_notifier(dev);
return err; return err;
} }
...@@ -3242,7 +3253,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) ...@@ -3242,7 +3253,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
err_disable_roce: err_disable_roce:
if (ll == IB_LINK_LAYER_ETHERNET) { if (ll == IB_LINK_LAYER_ETHERNET) {
mlx5_disable_roce(dev); mlx5_disable_roce(dev);
mlx5_remove_roce_notifier(dev); mlx5_remove_netdev_notifier(dev);
} }
err_free_port: err_free_port:
...@@ -3259,7 +3270,7 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) ...@@ -3259,7 +3270,7 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context)
struct mlx5_ib_dev *dev = context; struct mlx5_ib_dev *dev = context;
enum rdma_link_layer ll = mlx5_ib_port_link_layer(&dev->ib_dev, 1); enum rdma_link_layer ll = mlx5_ib_port_link_layer(&dev->ib_dev, 1);
mlx5_remove_roce_notifier(dev); mlx5_remove_netdev_notifier(dev);
ib_unregister_device(&dev->ib_dev); ib_unregister_device(&dev->ib_dev);
mlx5_ib_dealloc_q_counters(dev); mlx5_ib_dealloc_q_counters(dev);
destroy_umrc_res(dev); destroy_umrc_res(dev);
......
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