net/mlx5e: Add new profile function update_carrier
authorErez Shitrit <erezsh@mellanox.com>
Thu, 18 May 2017 11:32:11 +0000 (14:32 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 19 Jun 2017 15:40:20 +0000 (18:40 +0300)
Updating the carrier involves specific HW setting, each profile should
use its own function for that.

Both IPoIB and VF representor don't need carrier update function, since
VF representor has only a logical link to VF and IPoIB manages its own
link via ib_core upper layer.

Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
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
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c

index 49c5fe9..a223a8e 100644 (file)
@@ -782,6 +782,7 @@ struct mlx5e_profile {
        void    (*enable)(struct mlx5e_priv *priv);
        void    (*disable)(struct mlx5e_priv *priv);
        void    (*update_stats)(struct mlx5e_priv *priv);
+       void    (*update_carrier)(struct mlx5e_priv *priv);
        int     (*max_nch)(struct mlx5_core_dev *mdev);
        struct {
                mlx5e_fp_handle_rx_cqe handle_rx_cqe;
index 06eb7a8..343be65 100644 (file)
@@ -143,7 +143,8 @@ static void mlx5e_update_carrier_work(struct work_struct *work)
 
        mutex_lock(&priv->state_lock);
        if (test_bit(MLX5E_STATE_OPENED, &priv->state))
-               mlx5e_update_carrier(priv);
+               if (priv->profile->update_carrier)
+                       priv->profile->update_carrier(priv);
        mutex_unlock(&priv->state_lock);
 }
 
@@ -2598,9 +2599,10 @@ void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
 {
        struct net_device *netdev = priv->netdev;
        int new_num_txqs;
-
+       int carrier_ok;
        new_num_txqs = new_chs->num * new_chs->params.num_tc;
 
+       carrier_ok = netif_carrier_ok(netdev);
        netif_carrier_off(netdev);
 
        if (new_num_txqs < netdev->real_num_tx_queues)
@@ -2618,7 +2620,9 @@ void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
        mlx5e_refresh_tirs(priv, false);
        mlx5e_activate_priv_channels(priv);
 
-       mlx5e_update_carrier(priv);
+       /* return carrier back if needed */
+       if (carrier_ok)
+               netif_carrier_on(netdev);
 }
 
 int mlx5e_open_locked(struct net_device *netdev)
@@ -2634,7 +2638,8 @@ int mlx5e_open_locked(struct net_device *netdev)
 
        mlx5e_refresh_tirs(priv, false);
        mlx5e_activate_priv_channels(priv);
-       mlx5e_update_carrier(priv);
+       if (priv->profile->update_carrier)
+               priv->profile->update_carrier(priv);
        mlx5e_timestamp_init(priv);
 
        if (priv->profile->update_stats)
@@ -4215,6 +4220,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
        .disable           = mlx5e_nic_disable,
        .update_stats      = mlx5e_update_ndo_stats,
        .max_nch           = mlx5e_get_max_num_channels,
+       .update_carrier    = mlx5e_update_carrier,
        .rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe,
        .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
        .max_tc            = MLX5E_MAX_NUM_TC,
index 01798e1..a39873b 100644 (file)
@@ -916,6 +916,7 @@ static struct mlx5e_profile mlx5e_rep_profile = {
        .cleanup_tx             = mlx5e_cleanup_nic_tx,
        .update_stats           = mlx5e_rep_update_stats,
        .max_nch                = mlx5e_get_rep_max_num_channels,
+       .update_carrier         = NULL,
        .rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe_rep,
        .rx_handlers.handle_rx_cqe_mpwqe = NULL /* Not supported */,
        .max_tc                 = 1,
index fdeb426..cc9ff40 100644 (file)
@@ -291,6 +291,7 @@ static const struct mlx5e_profile mlx5i_nic_profile = {
        .disable           = NULL, /* mlx5i_disable */
        .update_stats      = NULL, /* mlx5i_update_stats */
        .max_nch           = mlx5e_get_max_num_channels,
+       .update_carrier    = NULL, /* no HW update in IB link */
        .rx_handlers.handle_rx_cqe       = mlx5i_handle_rx_cqe,
        .rx_handlers.handle_rx_cqe_mpwqe = NULL, /* Not supported */
        .max_tc            = MLX5I_MAX_NUM_TC,
@@ -337,6 +338,7 @@ static int mlx5i_open(struct net_device *netdev)
 
        mlx5e_refresh_tirs(priv, false);
        mlx5e_activate_priv_channels(priv);
+
        mutex_unlock(&priv->state_lock);
        return 0;