net/mlx5e: Add helper functions for reporter's basics
authorAya Levin <ayal@mellanox.com>
Thu, 11 Jul 2019 14:17:36 +0000 (17:17 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Tue, 20 Aug 2019 20:08:16 +0000 (13:08 -0700)
Introduce helper functions for create and destroy reporters and update
channels. In the following patch, rx reporter is added and it will use
these helpers too.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en/health.c
drivers/net/ethernet/mellanox/mlx5/core/en/health.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index ffd9a7a165a2123a2cf1e54ff9ee311c8d211a76..c11d0162eaf8ad2c2029266c44f839e678bb1512 100644 (file)
@@ -96,6 +96,23 @@ int mlx5e_reporter_cq_common_diagnose(struct mlx5e_cq *cq, struct devlink_fmsg *
        return 0;
 }
 
+int mlx5e_health_create_reporters(struct mlx5e_priv *priv)
+{
+       return  mlx5e_reporter_tx_create(priv);
+}
+
+void mlx5e_health_destroy_reporters(struct mlx5e_priv *priv)
+{
+       mlx5e_reporter_tx_destroy(priv);
+}
+
+void mlx5e_health_channels_update(struct mlx5e_priv *priv)
+{
+       if (priv->tx_reporter)
+               devlink_health_reporter_state_update(priv->tx_reporter,
+                                                    DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
+}
+
 int mlx5e_health_sq_to_ready(struct mlx5e_channel *channel, u32 sqn)
 {
        struct mlx5_core_dev *mdev = channel->mdev;
index 6725d417aaf5fe53c9c40786ae2a42bd3ae4aee2..b2c0ccc79b220ac269d69bbb15d2561eaa0d5dfe 100644 (file)
@@ -29,5 +29,9 @@ int mlx5e_health_recover_channels(struct mlx5e_priv *priv);
 int mlx5e_health_report(struct mlx5e_priv *priv,
                        struct devlink_health_reporter *reporter, char *err_str,
                        struct mlx5e_err_ctx *err_ctx);
+int mlx5e_health_create_reporters(struct mlx5e_priv *priv);
+void mlx5e_health_destroy_reporters(struct mlx5e_priv *priv);
+void mlx5e_health_channels_update(struct mlx5e_priv *priv);
+
 
 #endif
index 695c75a8d1abe055cb810599f19b7a2abcad0070..f3bcb9ddca5864ffbfe5ae40c62bd1a7b5aa2fe6 100644 (file)
@@ -2323,10 +2323,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
                        goto err_close_channels;
        }
 
-       if (priv->tx_reporter)
-               devlink_health_reporter_state_update(priv->tx_reporter,
-                                                    DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
-
+       mlx5e_health_channels_update(priv);
        kvfree(cparam);
        return 0;
 
@@ -3201,7 +3198,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
 {
        int tc;
 
-       mlx5e_reporter_tx_destroy(priv);
        for (tc = 0; tc < priv->profile->max_tc; tc++)
                mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
 }
@@ -4969,12 +4965,14 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
                mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
        mlx5e_build_nic_netdev(netdev);
        mlx5e_build_tc2txq_maps(priv);
+       mlx5e_health_create_reporters(priv);
 
        return 0;
 }
 
 static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
 {
+       mlx5e_health_destroy_reporters(priv);
        mlx5e_tls_cleanup(priv);
        mlx5e_ipsec_cleanup(priv);
        mlx5e_netdev_cleanup(priv->netdev, priv);
@@ -5077,7 +5075,6 @@ static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
 #ifdef CONFIG_MLX5_CORE_EN_DCB
        mlx5e_dcbnl_initialize(priv);
 #endif
-       mlx5e_reporter_tx_create(priv);
        return 0;
 }