Commit 07c9f1e5 authored by Saeed Mahameed's avatar Saeed Mahameed

net/mlx5e: NIC netdev init flow cleanup

Remove redundant call to unregister vport representor in mlx5e_add error
flow.

Hide the representor priv and eswitch internal structures from en_main.c
as preparation step for downstream patches which would allow building
the driver without support for  representors and eswitch.

Fixes: 6f08a22c ("net/mlx5e: Register/unregister vport representors on interface attach/detach")
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
parent 706b3583
...@@ -4428,32 +4428,27 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv) ...@@ -4428,32 +4428,27 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv)
static void *mlx5e_add(struct mlx5_core_dev *mdev) static void *mlx5e_add(struct mlx5_core_dev *mdev)
{ {
struct mlx5_eswitch *esw = mdev->priv.eswitch; struct net_device *netdev;
int total_vfs = MLX5_TOTAL_VPORTS(mdev); void *rpriv = NULL;
struct mlx5e_rep_priv *rpriv = NULL;
void *priv; void *priv;
int vport;
int err; int err;
struct net_device *netdev;
err = mlx5e_check_required_hca_cap(mdev); err = mlx5e_check_required_hca_cap(mdev);
if (err) if (err)
return NULL; return NULL;
if (MLX5_CAP_GEN(mdev, vport_group_manager)) { if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL); rpriv = mlx5e_alloc_nic_rep_priv(mdev);
if (!rpriv) { if (!rpriv) {
mlx5_core_warn(mdev, mlx5_core_warn(mdev, "Failed to alloc NIC rep priv data\n");
"Not creating net device, Failed to alloc rep priv data\n");
return NULL; return NULL;
} }
rpriv->rep = &esw->offloads.vport_reps[0];
} }
netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, rpriv); netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, rpriv);
if (!netdev) { if (!netdev) {
mlx5_core_err(mdev, "mlx5e_create_netdev failed\n"); mlx5_core_err(mdev, "mlx5e_create_netdev failed\n");
goto err_unregister_reps; goto err_free_rpriv;
} }
priv = netdev_priv(netdev); priv = netdev_priv(netdev);
...@@ -4474,14 +4469,9 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) ...@@ -4474,14 +4469,9 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
err_detach: err_detach:
mlx5e_detach(mdev, priv); mlx5e_detach(mdev, priv);
err_destroy_netdev: err_destroy_netdev:
mlx5e_destroy_netdev(priv); mlx5e_destroy_netdev(priv);
err_free_rpriv:
err_unregister_reps:
for (vport = 1; vport < total_vfs; vport++)
mlx5_eswitch_unregister_vport_rep(esw, vport);
kfree(rpriv); kfree(rpriv);
return NULL; return NULL;
} }
......
...@@ -1099,3 +1099,16 @@ void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv) ...@@ -1099,3 +1099,16 @@ void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv)
mlx5e_rep_unregister_vf_vports(priv); /* VFs vports */ mlx5e_rep_unregister_vf_vports(priv); /* VFs vports */
mlx5_eswitch_unregister_vport_rep(esw, 0); /* UPLINK PF*/ mlx5_eswitch_unregister_vport_rep(esw, 0); /* UPLINK PF*/
} }
void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev)
{
struct mlx5_eswitch *esw = mdev->priv.eswitch;
struct mlx5e_rep_priv *rpriv;
rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL);
if (!rpriv)
return NULL;
rpriv->rep = &esw->offloads.vport_reps[0];
return rpriv;
}
...@@ -123,6 +123,7 @@ struct mlx5e_encap_entry { ...@@ -123,6 +123,7 @@ struct mlx5e_encap_entry {
int encap_size; int encap_size;
}; };
void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev);
void mlx5e_register_vport_reps(struct mlx5e_priv *priv); void mlx5e_register_vport_reps(struct mlx5e_priv *priv);
void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv); void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv);
bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv); bool mlx5e_is_uplink_rep(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