[PATCH net-next 09/10] net/mlx5: qos: Init shared devlink rate domain

Tariq Toukan
2025-02-13T18:03:13Z

From: Cosmin Ratiu <cratiu@nvidia.com>

If the device can do cross-esw scheduling, switch to using a shared rate
domain so that devlink rate nodes can have parents from other functions
of the same device.

As a fallback mechanism, if switching to a shared rate domain failed, a
warning is logged and the code proceeds with trying to use a private qos
domain since cross-esw scheduling cannot be supported.

Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
index e6dcfe348a7e..9af12ae98691 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
@@ -899,6 +899,20 @@ int mlx5_esw_qos_init(struct mlx5_eswitch *esw)
bool use_shared_domain = esw->mode == MLX5_ESWITCH_OFFLOADS &&
MLX5_CAP_QOS(esw->dev, esw_cross_esw_sched);

+ if (use_shared_domain) {
+ u64 guid = mlx5_query_nic_system_image_guid(esw->dev);
+ int err;
+
+ err = devlink_shared_rate_domain_init(priv_to_devlink(esw->dev), guid);
+ if (err) {
+ /* On failure, issue a warning and switch to using a private domain. */
+ esw_warn(esw->dev,
+ "Shared devlink rate domain init failed (err %d), cross-esw QoS not available",
+ err);
+ use_shared_domain = false;
+ }
+ }
+
if (esw->qos.domain) {
if (esw->qos.domain->shared == use_shared_domain)
return 0; /* Nothing to change. */
--
2.45.0