From: Xueming Li Date: Wed, 28 Oct 2020 09:33:23 +0000 (+0800) Subject: net/mlx5: support zero size entry for indexed pool X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=79807d6a6edf8770d67ee4c101ebe1ad45d697c5;p=dpdk.git net/mlx5: support zero size entry for indexed pool To make indexed pool to be used as ID generator, this patch allows entry size to be zero. Signed-off-by: Xueming Li Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c index 9a54fda9b0..3a1f87a361 100644 --- a/drivers/net/mlx5/mlx5_utils.c +++ b/drivers/net/mlx5/mlx5_utils.c @@ -230,7 +230,7 @@ mlx5_ipool_create(struct mlx5_indexed_pool_config *cfg) struct mlx5_indexed_pool *pool; uint32_t i; - if (!cfg || !cfg->size || (!cfg->malloc ^ !cfg->free) || + if (!cfg || (!cfg->malloc ^ !cfg->free) || (cfg->trunk_size && ((cfg->trunk_size & (cfg->trunk_size - 1)) || ((__builtin_ffs(cfg->trunk_size) + TRUNK_IDX_BITS) > 32)))) return NULL; @@ -391,7 +391,7 @@ mlx5_ipool_zmalloc(struct mlx5_indexed_pool *pool, uint32_t *idx) { void *entry = mlx5_ipool_malloc(pool, idx); - if (entry) + if (entry && pool->cfg.size) memset(entry, 0, pool->cfg.size); return entry; }