Commit 29b598dd authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed

net/mlx5e: Move uplink rep init/cleanup code into own functions

Clean up the code and allows to call uplink rep init/cleanup
from different location later.
To be used later for a new uplink representor mode.
Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
Reviewed-by: default avatarEli Britstein <elibr@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 4c7cea2f
......@@ -1674,19 +1674,15 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
mlx5e_close_drop_rq(&priv->drop_rq);
}
static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
static int mlx5e_init_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_rep_uplink_priv *uplink_priv;
struct net_device *netdev;
struct mlx5e_priv *priv;
int err;
err = mlx5e_create_tises(priv);
if (err) {
mlx5_core_warn(priv->mdev, "create tises failed, %d\n", err);
return err;
}
if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
netdev = rpriv->netdev;
priv = netdev_priv(netdev);
uplink_priv = &rpriv->uplink_priv;
mutex_init(&uplink_priv->unready_flows_lock);
......@@ -1695,7 +1691,7 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
/* init shared tc flow table */
err = mlx5e_tc_esw_init(&uplink_priv->tc_ht);
if (err)
goto destroy_tises;
return err;
mlx5_init_port_tun_entropy(&uplink_priv->tun_entropy, priv->mdev);
......@@ -1707,24 +1703,40 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
mlx5_core_err(priv->mdev, "Failed to register netdev notifier\n");
goto tc_esw_cleanup;
}
}
return 0;
tc_esw_cleanup:
mlx5e_tc_esw_cleanup(&uplink_priv->tc_ht);
destroy_tises:
mlx5e_destroy_tises(priv);
return err;
}
static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
int err;
mlx5e_destroy_tises(priv);
err = mlx5e_create_tises(priv);
if (err) {
mlx5_core_warn(priv->mdev, "create tises failed, %d\n", err);
return err;
}
if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
err = mlx5e_init_uplink_rep_tx(rpriv);
if (err)
goto destroy_tises;
}
return 0;
destroy_tises:
mlx5e_destroy_tises(priv);
return err;
}
static void mlx5e_cleanup_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
{
/* clean indirect TC block notifications */
unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb);
mlx5e_rep_indr_clean_block_privs(rpriv);
......@@ -1732,7 +1744,16 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
/* delete shared tc flow table */
mlx5e_tc_esw_cleanup(&rpriv->uplink_priv.tc_ht);
mutex_destroy(&rpriv->uplink_priv.unready_flows_lock);
}
}
static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
mlx5e_destroy_tises(priv);
if (rpriv->rep->vport == MLX5_VPORT_UPLINK)
mlx5e_cleanup_uplink_rep_tx(rpriv);
}
static void mlx5e_rep_enable(struct mlx5e_priv *priv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment