From: Cosmin Ratiu Previously, the master device of the uplink netdev was queried for its maximum link speed from the QoS layer, requiring the uplink_netdev mutex and possibly the RTNL (if the call originated from the TC matchall layer). Acquiring these locks here is risky, as lock cycles could form. The locking for the QoS layer is about to change, so to avoid issues, replace the code querying the LAG's max link speed with the existing infrastructure added in commit [1]. This simplifies this part and avoids potential lock cycles. One caveat is that there's a new edge case, when the bond device is not fully formed to represent the LAG device, the speed isn't calculated and is left at 0. This now handled explicitly. [1] commit f0b2fde98065 ("net/mlx5: Add support for querying bond speed") Signed-off-by: Cosmin Ratiu Reviewed-by: Carolina Jubran Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/esw/qos.c | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c index faccc60fc93a..d04fda4b3778 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c @@ -1489,41 +1489,16 @@ static int esw_qos_node_enable_tc_arbitration(struct mlx5_esw_sched_node *node, return err; } -static u32 mlx5_esw_qos_lag_link_speed_get(struct mlx5_core_dev *mdev, - bool take_rtnl) -{ - struct ethtool_link_ksettings lksettings; - struct net_device *slave, *master; - u32 speed = SPEED_UNKNOWN; - - slave = mlx5_uplink_netdev_get(mdev); - if (!slave) - goto out; - - if (take_rtnl) - rtnl_lock(); - master = netdev_master_upper_dev_get(slave); - if (master && !__ethtool_get_link_ksettings(master, &lksettings)) - speed = lksettings.base.speed; - if (take_rtnl) - rtnl_unlock(); - -out: - mlx5_uplink_netdev_put(mdev, slave); - return speed; -} - static int mlx5_esw_qos_max_link_speed_get(struct mlx5_core_dev *mdev, u32 *link_speed_max, - bool take_rtnl, struct netlink_ext_ack *extack) { int err; - if (!mlx5_lag_is_active(mdev)) + if (!mlx5_lag_is_active(mdev) || + mlx5_lag_query_bond_speed(mdev, link_speed_max) < 0 || + *link_speed_max == 0) goto skip_lag; - *link_speed_max = mlx5_esw_qos_lag_link_speed_get(mdev, take_rtnl); - if (*link_speed_max != (u32)SPEED_UNKNOWN) return 0; @@ -1560,7 +1535,8 @@ int mlx5_esw_qos_modify_vport_rate(struct mlx5_eswitch *esw, u16 vport_num, u32 return PTR_ERR(vport); if (rate_mbps) { - err = mlx5_esw_qos_max_link_speed_get(esw->dev, &link_speed_max, false, NULL); + err = mlx5_esw_qos_max_link_speed_get(esw->dev, &link_speed_max, + NULL); if (err) return err; @@ -1598,7 +1574,7 @@ static int esw_qos_devlink_rate_to_mbps(struct mlx5_core_dev *mdev, const char * return -EINVAL; } - err = mlx5_esw_qos_max_link_speed_get(mdev, &link_speed_max, true, extack); + err = mlx5_esw_qos_max_link_speed_get(mdev, &link_speed_max, extack); if (err) return err; -- 2.44.0