diff options
| author | Mark Bloch <mbloch@nvidia.com> | 2026-01-12 11:40:23 +0200 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2026-01-15 12:10:27 +0100 |
| commit | 96e89982a68c36a5cca6c7078ebdf48b11dd5515 (patch) | |
| tree | 8aefd7217ea66897ebda52b67a096a36b314fb45 | |
| parent | 8138fc46d9a44c0a3457028b9912cfd4406b35d1 (diff) | |
net/mlx5: fs, factor out flow counter bulk init
Add mlx5_fc_bulk_init() to handle bulk initialization of flow counters.
This change does not alter any logic, but refactors the code to remove
duplicate initialization logic by centralizing it in a single function.
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1768210825-1598472-2-git-send-email-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c index 83001eda3884..e14570a3d492 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c @@ -421,6 +421,13 @@ static void mlx5_fc_init(struct mlx5_fc *counter, struct mlx5_fc_bulk *bulk, counter->id = id; } +static void mlx5_fc_bulk_init(struct mlx5_fc_bulk *fc_bulk, u32 base_id) +{ + fc_bulk->base_id = base_id; + refcount_set(&fc_bulk->hws_data.hws_action_refcount, 0); + mutex_init(&fc_bulk->hws_data.lock); +} + u32 mlx5_fc_get_base_id(struct mlx5_fc *counter) { return counter->bulk->base_id; @@ -447,12 +454,11 @@ static struct mlx5_fs_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev, if (mlx5_cmd_fc_bulk_alloc(dev, alloc_bitmask, &base_id)) goto fs_bulk_cleanup; - fc_bulk->base_id = base_id; + + mlx5_fc_bulk_init(fc_bulk, base_id); for (i = 0; i < bulk_len; i++) mlx5_fc_init(&fc_bulk->fcs[i], fc_bulk, base_id + i); - refcount_set(&fc_bulk->hws_data.hws_action_refcount, 0); - mutex_init(&fc_bulk->hws_data.lock); return &fc_bulk->fs_bulk; fs_bulk_cleanup: @@ -560,10 +566,8 @@ mlx5_fc_local_create(u32 counter_id, u32 offset, u32 bulk_size) counter->type = MLX5_FC_TYPE_LOCAL; counter->id = counter_id; - fc_bulk->base_id = counter_id - offset; fc_bulk->fs_bulk.bulk_len = bulk_size; - refcount_set(&fc_bulk->hws_data.hws_action_refcount, 0); - mutex_init(&fc_bulk->hws_data.lock); + mlx5_fc_bulk_init(fc_bulk, counter_id - offset); counter->bulk = fc_bulk; refcount_set(&counter->fc_local_refcount, 1); return counter; |
