Skip to content

Commit

Permalink
net/mlx5e: IPoIB, Basic netdev ndos open/close
Browse files Browse the repository at this point in the history
Implement open/close of IPoIB netdevice ndos using mlx5e's
channels API to manage data path resources (RQs/SQs/CQs).

Set IPoIB netdev address on dev_init ndo.

Signed-off-by: Saeed Mahameed <[email protected]>
Reviewed-by: Erez Shitrit <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Saeed Mahameed authored and davem330 committed Apr 17, 2017
1 parent 5426a0b commit 603f4a4
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,8 @@ typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *new_chs,
mlx5e_fp_hw_modify hw_modify);
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);

void mlx5e_build_default_indir_rqt(struct mlx5_core_dev *mdev,
u32 *indirection_rqt, int len,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,7 @@ static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv)
}
}

static void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
{
int num_txqs = priv->channels.num * priv->channels.params.num_tc;
struct net_device *netdev = priv->netdev;
Expand All @@ -2567,7 +2567,7 @@ static void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
mlx5e_redirect_rqts_to_channels(priv, &priv->channels);
}

static void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
{
mlx5e_redirect_rqts_to_drop(priv);

Expand Down
90 changes: 89 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
#include "en.h"
#include "ipoib.h"

static int mlx5i_open(struct net_device *netdev);
static int mlx5i_close(struct net_device *netdev);
static int mlx5i_dev_init(struct net_device *dev);
static void mlx5i_dev_cleanup(struct net_device *dev);

static const struct net_device_ops mlx5i_netdev_ops = {
.ndo_open = mlx5i_open,
.ndo_stop = mlx5i_close,
.ndo_init = mlx5i_dev_init,
.ndo_uninit = mlx5i_dev_cleanup,
};

/* IPoIB mlx5 netdev profile */

/* Called directly after IPoIB netdevice was created to initialize SW structs */
Expand All @@ -52,7 +64,17 @@ static void mlx5i_init(struct mlx5_core_dev *mdev,
mlx5e_build_nic_params(mdev, &priv->channels.params, profile->max_nch(mdev));

mutex_init(&priv->state_lock);
/* TODO : init netdev features here */

netdev->hw_features |= NETIF_F_SG;
netdev->hw_features |= NETIF_F_IP_CSUM;
netdev->hw_features |= NETIF_F_IPV6_CSUM;
netdev->hw_features |= NETIF_F_GRO;
netdev->hw_features |= NETIF_F_TSO;
netdev->hw_features |= NETIF_F_TSO6;
netdev->hw_features |= NETIF_F_RXCSUM;
netdev->hw_features |= NETIF_F_RXHASH;

netdev->netdev_ops = &mlx5i_netdev_ops;
}

/* Called directly before IPoIB netdevice is destroyed to cleanup SW structs */
Expand Down Expand Up @@ -181,6 +203,72 @@ static const struct mlx5e_profile mlx5i_nic_profile = {
.max_tc = MLX5I_MAX_NUM_TC,
};

/* mlx5i netdev NDos */

static int mlx5i_dev_init(struct net_device *dev)
{
struct mlx5e_priv *priv = mlx5i_epriv(dev);
struct mlx5i_priv *ipriv = priv->ppriv;

/* Set dev address using underlay QP */
dev->dev_addr[1] = (ipriv->qp.qpn >> 16) & 0xff;
dev->dev_addr[2] = (ipriv->qp.qpn >> 8) & 0xff;
dev->dev_addr[3] = (ipriv->qp.qpn) & 0xff;

return 0;
}

static void mlx5i_dev_cleanup(struct net_device *dev)
{
/* TODO: detach underlay qp from flow-steering by reset it */
}

static int mlx5i_open(struct net_device *netdev)
{
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
int err;

mutex_lock(&priv->state_lock);

set_bit(MLX5E_STATE_OPENED, &priv->state);

err = mlx5e_open_channels(priv, &priv->channels);
if (err)
goto err_clear_state_opened_flag;

mlx5e_refresh_tirs(priv, false);
mlx5e_activate_priv_channels(priv);
mutex_unlock(&priv->state_lock);
return 0;

err_clear_state_opened_flag:
clear_bit(MLX5E_STATE_OPENED, &priv->state);
mutex_unlock(&priv->state_lock);
return err;
}

static int mlx5i_close(struct net_device *netdev)
{
struct mlx5e_priv *priv = mlx5i_epriv(netdev);

/* May already be CLOSED in case a previous configuration operation
* (e.g RX/TX queue size change) that involves close&open failed.
*/
mutex_lock(&priv->state_lock);

if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
goto unlock;

clear_bit(MLX5E_STATE_OPENED, &priv->state);

netif_carrier_off(priv->netdev);
mlx5e_deactivate_priv_channels(priv);
mlx5e_close_channels(&priv->channels);
unlock:
mutex_unlock(&priv->state_lock);
return 0;
}

/* IPoIB RDMA netdev callbacks */

static int mlx5i_check_required_hca_cap(struct mlx5_core_dev *mdev)
Expand Down

0 comments on commit 603f4a4

Please sign in to comment.