Skip to content

Commit

Permalink
providers/mana: fix align_hw_size and improve get_wqe_size
Browse files Browse the repository at this point in the history
Mana HW expects buffers to be a power of 2 and be at least 4KB.
The existing align_hw_size returns 1 when input is 0, providing
incorrect buffer size for empty queues.
Change the order of align and pow to get 4096 for the input 0,
which is expected by the HW.

Use uint32_t in the get_wqe_size helper.

Fixes: 443f196 ("mana: Microsoft Azure Network Adapter (MANA) RDMA provider")
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
  • Loading branch information
Konstantin Taranov committed Jul 1, 2024
1 parent f0be938 commit f79e367
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
4 changes: 1 addition & 3 deletions providers/mana/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,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) {
Expand Down
20 changes: 5 additions & 15 deletions providers/mana/mana.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f79e367

Please sign in to comment.