Commit 5a977b58 authored by Shay Drory's avatar Shay Drory Committed by Jakub Kicinski
Browse files

net/mlx5: Lag, move devcom registration to LAG layer



Move the devcom registration for the HCA_PORTS component from the core
initialization path into the LAG logic. This better reflects the logical
ownership of this component and ensures proper alignment with the LAG
lifecycle.

Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1757940070-618661-3-git-send-email-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f05a82fb
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -1404,6 +1404,34 @@ static int __mlx5_lag_dev_add_mdev(struct mlx5_core_dev *dev)
	return 0;
}

static void mlx5_lag_unregister_hca_devcom_comp(struct mlx5_core_dev *dev)
{
	mlx5_devcom_unregister_component(dev->priv.hca_devcom_comp);
}

static int mlx5_lag_register_hca_devcom_comp(struct mlx5_core_dev *dev)
{
	struct mlx5_devcom_match_attr attr = {
		.key.val = mlx5_query_nic_system_image_guid(dev),
	};

	/* This component is use to sync adding core_dev to lag_dev and to sync
	 * changes of mlx5_adev_devices between LAG layer and other layers.
	 */
	dev->priv.hca_devcom_comp =
		mlx5_devcom_register_component(dev->priv.devc,
					       MLX5_DEVCOM_HCA_PORTS,
					       &attr, NULL, dev);
	if (IS_ERR(dev->priv.hca_devcom_comp)) {
		mlx5_core_err(dev,
			      "Failed to register devcom HCA component, err: %ld\n",
			      PTR_ERR(dev->priv.hca_devcom_comp));
		return PTR_ERR(dev->priv.hca_devcom_comp);
	}

	return 0;
}

void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev)
{
	struct mlx5_lag *ldev;
@@ -1425,6 +1453,7 @@ void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev)
	}
	mlx5_ldev_remove_mdev(ldev, dev);
	mutex_unlock(&ldev->lock);
	mlx5_lag_unregister_hca_devcom_comp(dev);
	mlx5_ldev_put(ldev);
}

@@ -1435,7 +1464,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
	if (!mlx5_lag_is_supported(dev))
		return;

	if (IS_ERR_OR_NULL(dev->priv.hca_devcom_comp))
	if (mlx5_lag_register_hca_devcom_comp(dev))
		return;

recheck:
+0 −27
Original line number Diff line number Diff line
@@ -973,30 +973,6 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev)
	mlx5_pci_disable_device(dev);
}

static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
{
	struct mlx5_devcom_match_attr attr = {
		.key.val = mlx5_query_nic_system_image_guid(dev),
	};

	/* This component is use to sync adding core_dev to lag_dev and to sync
	 * changes of mlx5_adev_devices between LAG layer and other layers.
	 */
	if (!mlx5_lag_is_supported(dev))
		return;

	dev->priv.hca_devcom_comp =
		mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_HCA_PORTS,
					       &attr, NULL, dev);
	if (IS_ERR(dev->priv.hca_devcom_comp))
		mlx5_core_err(dev, "Failed to register devcom HCA component\n");
}

static void mlx5_unregister_hca_devcom_comp(struct mlx5_core_dev *dev)
{
	mlx5_devcom_unregister_component(dev->priv.hca_devcom_comp);
}

static int mlx5_init_once(struct mlx5_core_dev *dev)
{
	int err;
@@ -1005,7 +981,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
	if (IS_ERR(dev->priv.devc))
		mlx5_core_warn(dev, "failed to register devcom device %ld\n",
			       PTR_ERR(dev->priv.devc));
	mlx5_register_hca_devcom_comp(dev);

	err = mlx5_query_board_id(dev);
	if (err) {
@@ -1143,7 +1118,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
err_irq_cleanup:
	mlx5_irq_table_cleanup(dev);
err_devcom:
	mlx5_unregister_hca_devcom_comp(dev);
	mlx5_devcom_unregister_device(dev->priv.devc);

	return err;
@@ -1174,7 +1148,6 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
	mlx5_events_cleanup(dev);
	mlx5_eq_table_cleanup(dev);
	mlx5_irq_table_cleanup(dev);
	mlx5_unregister_hca_devcom_comp(dev);
	mlx5_devcom_unregister_device(dev->priv.devc);
}