diff --git a/providers/mana/mana.c b/providers/mana/mana.c index 90aabd9d5..3545c579b 100644 --- a/providers/mana/mana.c +++ b/providers/mana/mana.c @@ -215,9 +215,7 @@ struct ibv_cq *mana_create_cq(struct ibv_context *context, int cqe, if (!cq) return NULL; - cq_size = cqe * COMP_ENTRY_SIZE; - cq_size = roundup_pow_of_two(cq_size); - cq_size = align(cq_size, MANA_PAGE_SIZE); + cq_size = align_hw_size(cqe * COMP_ENTRY_SIZE); cq->buf = ctx->extern_alloc.alloc(cq_size, ctx->extern_alloc.data); if (!cq->buf) { diff --git a/providers/mana/mana.h b/providers/mana/mana.h index 50d747314..6042b1b14 100644 --- a/providers/mana/mana.h +++ b/providers/mana/mana.h @@ -24,25 +24,15 @@ #define DOORBELL_PAGE_SIZE 4096 #define MANA_PAGE_SIZE 4096 -static inline int align_next_power2(int size) +static inline uint32_t align_hw_size(uint32_t size) { - int val = 1; - - while (val < size) - val <<= 1; - - return val; -} - -static inline int align_hw_size(int size) -{ - size = align(size, MANA_PAGE_SIZE); - return align_next_power2(size); + size = roundup_pow_of_two(size); + return align(size, MANA_PAGE_SIZE); } -static inline int get_wqe_size(int sge) +static inline uint32_t get_wqe_size(uint32_t sge) { - int wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_SMALL_SIZE; + uint32_t wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_SMALL_SIZE; return align(wqe_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE); }