net/mlx5e: Use the new mlx5 core notifier API
authorSaeed Mahameed <saeedm@mellanox.com>
Mon, 26 Nov 2018 22:38:58 +0000 (14:38 -0800)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 30 Nov 2018 00:40:31 +0000 (16:40 -0800)
Remove the deprecated mlx5_interface->event mlx5e callback and use new
mlx5 notifier API to subscribe for mlx5 events, handle port change event
as received from FW rather than handling the mlx5 core processed port
change software version event.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index aea74856c7028d98a037f321d43a2700cfaa4afd..13d8a74d3db5d8de4f478f2a2da9c593bd95930a 100644 (file)
@@ -631,7 +631,6 @@ struct mlx5e_channel_stats {
 } ____cacheline_aligned_in_smp;
 
 enum {
-       MLX5E_STATE_ASYNC_EVENTS_ENABLED,
        MLX5E_STATE_OPENED,
        MLX5E_STATE_DESTROYING,
 };
@@ -690,6 +689,8 @@ struct mlx5e_priv {
        struct hwtstamp_config     tstamp;
        u16                        q_counter;
        u16                        drop_rq_q_counter;
+       struct notifier_block      events_nb;
+
 #ifdef CONFIG_MLX5_CORE_EN_DCB
        struct mlx5e_dcbx          dcbx;
 #endif
index 0d495a6b39499b91afe2c08af16810d52ae325d2..56bc41b1c31f972bb3e26311650ec67a165f2516 100644 (file)
@@ -294,33 +294,35 @@ void mlx5e_queue_update_stats(struct mlx5e_priv *priv)
        queue_work(priv->wq, &priv->update_stats_work);
 }
 
-static void mlx5e_async_event(struct mlx5_core_dev *mdev, void *vpriv,
-                             enum mlx5_dev_event event, unsigned long param)
+static int async_event(struct notifier_block *nb, unsigned long event, void *data)
 {
-       struct mlx5e_priv *priv = vpriv;
+       struct mlx5e_priv *priv = container_of(nb, struct mlx5e_priv, events_nb);
+       struct mlx5_eqe   *eqe = data;
 
-       if (!test_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state))
-               return;
+       if (event != MLX5_EVENT_TYPE_PORT_CHANGE)
+               return NOTIFY_DONE;
 
-       switch (event) {
-       case MLX5_DEV_EVENT_PORT_UP:
-       case MLX5_DEV_EVENT_PORT_DOWN:
+       switch (eqe->sub_type) {
+       case MLX5_PORT_CHANGE_SUBTYPE_DOWN:
+       case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE:
                queue_work(priv->wq, &priv->update_carrier_work);
                break;
        default:
-               break;
+               return NOTIFY_DONE;
        }
+
+       return NOTIFY_OK;
 }
 
 static void mlx5e_enable_async_events(struct mlx5e_priv *priv)
 {
-       set_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state);
+       priv->events_nb.notifier_call = async_event;
+       mlx5_notifier_register(priv->mdev, &priv->events_nb);
 }
 
 static void mlx5e_disable_async_events(struct mlx5e_priv *priv)
 {
-       clear_bit(MLX5E_STATE_ASYNC_EVENTS_ENABLED, &priv->state);
-       mlx5_eq_synchronize_async_irq(priv->mdev);
+       mlx5_notifier_unregister(priv->mdev, &priv->events_nb);
 }
 
 static inline void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,
@@ -5170,7 +5172,6 @@ static struct mlx5_interface mlx5e_interface = {
        .remove    = mlx5e_remove,
        .attach    = mlx5e_attach,
        .detach    = mlx5e_detach,
-       .event     = mlx5e_async_event,
        .protocol  = MLX5_INTERFACE_PROTOCOL_ETH,
        .get_dev   = mlx5e_get_netdev,
 };