Commit 4c66df01 authored by Mark Bloch's avatar Mark Bloch Committed by Saeed Mahameed

net/mlx5: E-Switch, Simplify representor load/unload callback API

In the load() callback for loading representors we don't really need
struct mlx5_eswitch but struct mlx5_core_dev, pass it directly.

In the unload() callback for unloading representors we don't need the
struct mlx5_eswitch argument, remove it.
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 6ed1803a
...@@ -967,7 +967,7 @@ static const struct mlx5e_profile mlx5e_rep_profile = { ...@@ -967,7 +967,7 @@ static const struct mlx5e_profile mlx5e_rep_profile = {
/* e-Switch vport representors */ /* e-Switch vport representors */
static int static int
mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) mlx5e_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
{ {
struct mlx5e_priv *priv = netdev_priv(rep->netdev); struct mlx5e_priv *priv = netdev_priv(rep->netdev);
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -992,7 +992,7 @@ mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -992,7 +992,7 @@ mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
} }
static void static void
mlx5e_nic_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) mlx5e_nic_rep_unload(struct mlx5_eswitch_rep *rep)
{ {
struct mlx5e_priv *priv = netdev_priv(rep->netdev); struct mlx5e_priv *priv = netdev_priv(rep->netdev);
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -1008,7 +1008,7 @@ mlx5e_nic_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -1008,7 +1008,7 @@ mlx5e_nic_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
} }
static int static int
mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
{ {
struct mlx5e_rep_priv *rpriv; struct mlx5e_rep_priv *rpriv;
struct net_device *netdev; struct net_device *netdev;
...@@ -1019,7 +1019,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -1019,7 +1019,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
if (!rpriv) if (!rpriv)
return -ENOMEM; return -ENOMEM;
netdev = mlx5e_create_netdev(esw->dev, &mlx5e_rep_profile, rpriv); netdev = mlx5e_create_netdev(dev, &mlx5e_rep_profile, rpriv);
if (!netdev) { if (!netdev) {
pr_warn("Failed to create representor netdev for vport %d\n", pr_warn("Failed to create representor netdev for vport %d\n",
rep->vport); rep->vport);
...@@ -1044,7 +1044,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -1044,7 +1044,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
goto err_detach_netdev; goto err_detach_netdev;
} }
upriv = netdev_priv(mlx5_eswitch_get_uplink_netdev(esw)); upriv = netdev_priv(mlx5_eswitch_get_uplink_netdev(dev->priv.eswitch));
err = tc_setup_cb_egdev_register(netdev, mlx5e_setup_tc_block_cb, err = tc_setup_cb_egdev_register(netdev, mlx5e_setup_tc_block_cb,
upriv); upriv);
if (err) if (err)
...@@ -1076,7 +1076,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -1076,7 +1076,7 @@ mlx5e_vport_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
} }
static void static void
mlx5e_vport_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
{ {
struct net_device *netdev = rep->netdev; struct net_device *netdev = rep->netdev;
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -1085,7 +1085,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) ...@@ -1085,7 +1085,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep)
struct mlx5e_priv *upriv; struct mlx5e_priv *upriv;
unregister_netdev(rep->netdev); unregister_netdev(rep->netdev);
upriv = netdev_priv(mlx5_eswitch_get_uplink_netdev(esw)); upriv = netdev_priv(mlx5_eswitch_get_uplink_netdev(priv->mdev->priv.eswitch));
tc_setup_cb_egdev_unregister(netdev, mlx5e_setup_tc_block_cb, tc_setup_cb_egdev_unregister(netdev, mlx5e_setup_tc_block_cb,
upriv); upriv);
mlx5e_rep_neigh_cleanup(rpriv); mlx5e_rep_neigh_cleanup(rpriv);
......
...@@ -139,10 +139,9 @@ struct mlx5_esw_sq { ...@@ -139,10 +139,9 @@ struct mlx5_esw_sq {
}; };
struct mlx5_eswitch_rep { struct mlx5_eswitch_rep {
int (*load)(struct mlx5_eswitch *esw, int (*load)(struct mlx5_core_dev *dev,
struct mlx5_eswitch_rep *rep); struct mlx5_eswitch_rep *rep);
void (*unload)(struct mlx5_eswitch *esw, void (*unload)(struct mlx5_eswitch_rep *rep);
struct mlx5_eswitch_rep *rep);
u16 vport; u16 vport;
u8 hw_id[ETH_ALEN]; u8 hw_id[ETH_ALEN];
struct net_device *netdev; struct net_device *netdev;
......
...@@ -777,7 +777,7 @@ static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports) ...@@ -777,7 +777,7 @@ static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports)
if (!rep->valid) if (!rep->valid)
continue; continue;
rep->unload(esw, rep); rep->unload(rep);
} }
} }
...@@ -792,7 +792,7 @@ static int esw_offloads_load_reps(struct mlx5_eswitch *esw, int nvports) ...@@ -792,7 +792,7 @@ static int esw_offloads_load_reps(struct mlx5_eswitch *esw, int nvports)
if (!rep->valid) if (!rep->valid)
continue; continue;
err = rep->load(esw, rep); err = rep->load(esw->dev, rep);
if (err) if (err)
goto err_reps; goto err_reps;
} }
...@@ -1193,7 +1193,7 @@ void mlx5_eswitch_unregister_vport_rep(struct mlx5_eswitch *esw, ...@@ -1193,7 +1193,7 @@ void mlx5_eswitch_unregister_vport_rep(struct mlx5_eswitch *esw,
rep = &offloads->vport_reps[vport_index]; rep = &offloads->vport_reps[vport_index];
if (esw->mode == SRIOV_OFFLOADS && esw->vports[vport_index].enabled) if (esw->mode == SRIOV_OFFLOADS && esw->vports[vport_index].enabled)
rep->unload(esw, rep); rep->unload(rep);
rep->valid = false; rep->valid = false;
} }
......
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