net/mlx5: devcom, Add component size getter
authorTariq Toukan <tariqt@nvidia.com>
Mon, 21 Aug 2023 11:31:35 +0000 (14:31 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 14 Dec 2023 02:03:32 +0000 (18:03 -0800)
Add a getter for the number of participants in a devcom
component (those who share the same component id and key).

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h

index e8e50563e95629f2ac53c98b1e2357811d67f65a..e7d59cfa8708e1617f78b28974977a9588026d1f 100644 (file)
@@ -256,6 +256,13 @@ void mlx5_devcom_unregister_component(struct mlx5_devcom_comp_dev *devcom)
                devcom_free_comp_dev(devcom);
 }
 
+int mlx5_devcom_comp_get_size(struct mlx5_devcom_comp_dev *devcom)
+{
+       struct mlx5_devcom_comp *comp = devcom->comp;
+
+       return kref_read(&comp->ref);
+}
+
 int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
                           int event, int rollback_event,
                           void *event_data)
index fc23bbef87b4614f92431967826a78dd45d3e7d4..ec32b686f58654ed9628d13d8bf5ecf292420a4a 100644 (file)
@@ -31,6 +31,7 @@ void mlx5_devcom_unregister_component(struct mlx5_devcom_comp_dev *devcom);
 int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
                           int event, int rollback_event,
                           void *event_data);
+int mlx5_devcom_comp_get_size(struct mlx5_devcom_comp_dev *devcom);
 
 void mlx5_devcom_comp_set_ready(struct mlx5_devcom_comp_dev *devcom, bool ready);
 bool mlx5_devcom_comp_is_ready(struct mlx5_devcom_comp_dev *devcom);