Skip to content

Commit

Permalink
mempool/octeontx2: fix shift calculation
Browse files Browse the repository at this point in the history
[ upstream commit 43d8940 ]

Shift is used to generate an 8-bit saturate value from the current
aura used count. The shift value should be derived from the log2 of
block count if it is greater than 256 else the shift should be 0.

Fixes: 7bcc47c ("mempool/octeontx2: add mempool alloc op")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
  • Loading branch information
PavanNikhilesh authored and cpaelzer committed Aug 9, 2021
1 parent eb35473 commit 004151c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/mempool/octeontx2/otx2_mempool_ops.c
Expand Up @@ -533,7 +533,8 @@ npa_lf_aura_pool_pair_alloc(struct otx2_npa_lf *lf, const uint32_t block_size,
/* Update aura fields */
aura->pool_addr = pool_id;/* AF will translate to associated poolctx */
aura->ena = 1;
aura->shift = __builtin_clz(block_count) - 8;
aura->shift = rte_log2_u32(block_count);
aura->shift = aura->shift < 8 ? 0 : aura->shift - 8;
aura->limit = block_count;
aura->pool_caching = 1;
aura->err_int_ena = BIT(NPA_AURA_ERR_INT_AURA_ADD_OVER);
Expand All @@ -548,7 +549,8 @@ npa_lf_aura_pool_pair_alloc(struct otx2_npa_lf *lf, const uint32_t block_size,
pool->ena = 1;
pool->buf_size = block_size / OTX2_ALIGN;
pool->stack_max_pages = stack_size;
pool->shift = __builtin_clz(block_count) - 8;
pool->shift = rte_log2_u32(block_count);
pool->shift = pool->shift < 8 ? 0 : pool->shift - 8;
pool->ptr_start = 0;
pool->ptr_end = ~0;
pool->stack_caching = 1;
Expand Down

0 comments on commit 004151c

Please sign in to comment.