Skip to content

Commit

Permalink
net/mlx5: Lag, Remove duplicate code checking lag is supported
Browse files Browse the repository at this point in the history
Remove duplicate function for checking if device has lag support.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
roidayan authored and Saeed Mahameed committed Jun 23, 2023
1 parent 690ad62 commit 8ec91f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,7 @@ void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw)
if (!MLX5_CAP_ESW(esw->dev, merged_eswitch))
return;

if (!mlx5_is_lag_supported(esw->dev))
if (!mlx5_lag_is_supported(esw->dev))
return;

mlx5_devcom_register_component(devcom,
Expand All @@ -2890,7 +2890,7 @@ void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw)
if (!MLX5_CAP_ESW(esw->dev, merged_eswitch))
return;

if (!mlx5_is_lag_supported(esw->dev))
if (!mlx5_lag_is_supported(esw->dev))
return;

mlx5_devcom_send_event(devcom, MLX5_DEVCOM_ESW_OFFLOADS,
Expand Down
15 changes: 11 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,14 +1268,21 @@ void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev)
mlx5_ldev_put(ldev);
}

bool mlx5_lag_is_supported(struct mlx5_core_dev *dev)
{
if (!MLX5_CAP_GEN(dev, vport_group_manager) ||
!MLX5_CAP_GEN(dev, lag_master) ||
MLX5_CAP_GEN(dev, num_lag_ports) < 2 ||
MLX5_CAP_GEN(dev, num_lag_ports) > MLX5_MAX_PORTS)
return false;
return true;
}

void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
{
int err;

if (!MLX5_CAP_GEN(dev, vport_group_manager) ||
!MLX5_CAP_GEN(dev, lag_master) ||
(MLX5_CAP_GEN(dev, num_lag_ports) > MLX5_MAX_PORTS ||
MLX5_CAP_GEN(dev, num_lag_ports) <= 1))
if (!mlx5_lag_is_supported(dev))
return;

recheck:
Expand Down
10 changes: 1 addition & 9 deletions drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ struct mlx5_lag {
struct lag_mpesw lag_mpesw;
};

static inline bool mlx5_is_lag_supported(struct mlx5_core_dev *dev)
{
if (!MLX5_CAP_GEN(dev, vport_group_manager) ||
!MLX5_CAP_GEN(dev, lag_master) ||
MLX5_CAP_GEN(dev, num_lag_ports) < 2 ||
MLX5_CAP_GEN(dev, num_lag_ports) > MLX5_MAX_PORTS)
return false;
return true;
}
bool mlx5_lag_is_supported(struct mlx5_core_dev *dev);

static inline struct mlx5_lag *
mlx5_lag_dev(struct mlx5_core_dev *dev)
Expand Down

0 comments on commit 8ec91f5

Please sign in to comment.