Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_main.c
index f374348..72c91ff 100644 (file)
@@ -417,7 +417,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
                err = mlx5_wq_ll_create(mdev, &rqp->wq, rqc_wq, &rq->mpwqe.wq,
                                        &rq->wq_ctrl);
                if (err)
-                       return err;
+                       goto err_rq_wq_destroy;
 
                rq->mpwqe.wq.db = &rq->mpwqe.wq.db[MLX5_RCV_DBR];
 
@@ -445,7 +445,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
                err = mlx5_wq_cyc_create(mdev, &rqp->wq, rqc_wq, &rq->wqe.wq,
                                         &rq->wq_ctrl);
                if (err)
-                       return err;
+                       goto err_rq_wq_destroy;
 
                rq->wqe.wq.db = &rq->wqe.wq.db[MLX5_RCV_DBR];
 
@@ -3062,6 +3062,25 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
        priv->tstamp.rx_filter = HWTSTAMP_FILTER_NONE;
 }
 
+static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev,
+                                    enum mlx5_port_status state)
+{
+       struct mlx5_eswitch *esw = mdev->priv.eswitch;
+       int vport_admin_state;
+
+       mlx5_set_port_admin_status(mdev, state);
+
+       if (!MLX5_ESWITCH_MANAGER(mdev) ||  mlx5_eswitch_mode(esw) == MLX5_ESWITCH_OFFLOADS)
+               return;
+
+       if (state == MLX5_PORT_UP)
+               vport_admin_state = MLX5_VPORT_ADMIN_STATE_AUTO;
+       else
+               vport_admin_state = MLX5_VPORT_ADMIN_STATE_DOWN;
+
+       mlx5_eswitch_set_vport_state(esw, MLX5_VPORT_UPLINK, vport_admin_state);
+}
+
 int mlx5e_open_locked(struct net_device *netdev)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -3094,7 +3113,7 @@ int mlx5e_open(struct net_device *netdev)
        mutex_lock(&priv->state_lock);
        err = mlx5e_open_locked(netdev);
        if (!err)
-               mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
+               mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_UP);
        mutex_unlock(&priv->state_lock);
 
        return err;
@@ -3128,7 +3147,7 @@ int mlx5e_close(struct net_device *netdev)
                return -ENODEV;
 
        mutex_lock(&priv->state_lock);
-       mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_DOWN);
+       mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_DOWN);
        err = mlx5e_close_locked(netdev);
        mutex_unlock(&priv->state_lock);
 
@@ -5177,7 +5196,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 
        /* Marking the link as currently not needed by the Driver */
        if (!netif_running(netdev))
-               mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
+               mlx5e_modify_admin_state(mdev, MLX5_PORT_DOWN);
 
        mlx5e_set_netdev_mtu_boundaries(priv);
        mlx5e_set_dev_port_mtu(priv);
@@ -5384,6 +5403,8 @@ err_cleanup_tx:
        profile->cleanup_tx(priv);
 
 out:
+       set_bit(MLX5E_STATE_DESTROYING, &priv->state);
+       cancel_work_sync(&priv->update_stats_work);
        return err;
 }