Skip to content

Commit

Permalink
net/mlx5e: en_tc, re-factor query route port
Browse files Browse the repository at this point in the history
query for peer esw outside of if scope.
This is preparation for query route port over multiple peers.

Signed-off-by: Mark Bloch <[email protected]>
Reviewed-by: Roi Dayan <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
  • Loading branch information
mark-bloch authored and Saeed Mahameed committed Jun 2, 2023
1 parent ed7a8fe commit 0af3613
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,37 +1666,31 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
{
struct mlx5e_priv *out_priv, *route_priv;
struct mlx5_core_dev *route_mdev;
struct mlx5_devcom *devcom;
struct mlx5_eswitch *esw;
u16 vhca_id;
int err;

out_priv = netdev_priv(out_dev);
esw = out_priv->mdev->priv.eswitch;
route_priv = netdev_priv(route_dev);
route_mdev = route_priv->mdev;

vhca_id = MLX5_CAP_GEN(route_mdev, vhca_id);
if (mlx5_lag_is_active(out_priv->mdev)) {
struct mlx5_devcom *devcom;
int err;

/* In lag case we may get devices from different eswitch instances.
* If we failed to get vport num, it means, mostly, that we on the wrong
* eswitch.
*/
err = mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
if (err != -ENOENT)
return err;

rcu_read_lock();
devcom = out_priv->mdev->priv.devcom;
esw = mlx5_devcom_get_peer_data_rcu(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
err = esw ? mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport) : -ENODEV;
rcu_read_unlock();
err = mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
if (!err)
return err;

if (!mlx5_lag_is_active(out_priv->mdev))
return err;
}

return mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
rcu_read_lock();
devcom = out_priv->mdev->priv.devcom;
esw = mlx5_devcom_get_peer_data_rcu(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
err = esw ? mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport) : -ENODEV;
rcu_read_unlock();

return err;
}

static int
Expand Down

0 comments on commit 0af3613

Please sign in to comment.