providers/mana: Use extra-large power-of-two WQEs Model extra-large WQEs with their explicit 32-byte OOB layout instead of representing them as large WQEs with an additional virtual SGE. Use power-of-two WQE sizes for the RC requester and MM work queues. Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
diff --git a/providers/mana/mana.h b/providers/mana/mana.h index f629206..b4496cc 100644 --- a/providers/mana/mana.h +++ b/providers/mana/mana.h
@@ -18,6 +18,7 @@ #define INLINE_OOB_SMALL_SIZE 8 #define INLINE_OOB_LARGE_SIZE 24 +#define INLINE_OOB_EXTRA_LARGE_SIZE 32 #define GDMA_WQE_ALIGNMENT_UNIT_SIZE 32 @@ -73,9 +74,21 @@ return align(wqe_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE); } -static inline uint32_t get_large_wqe_size(uint32_t sge) +static inline uint32_t get_large_fixed_wqe_size(uint32_t sge) { - uint32_t wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_LARGE_SIZE; + uint32_t wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_EXTRA_LARGE_SIZE; + + return roundup_pow_of_two(wqe_size); +} + +static inline uint32_t get_large_wqe_size(uint32_t sge, uint32_t wqe_size_in_bu) +{ + uint32_t wqe_size; + + if (wqe_size_in_bu) + return wqe_size_in_bu * GDMA_WQE_ALIGNMENT_UNIT_SIZE; + + wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_LARGE_SIZE; return align(wqe_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE); } @@ -108,6 +121,7 @@ uint32_t size; uint32_t prod_idx; uint32_t cons_idx; + uint8_t wqe_size_in_bu; void *db_page; void *buffer;
diff --git a/providers/mana/qp.c b/providers/mana/qp.c index 940c075..876a70f 100644 --- a/providers/mana/qp.c +++ b/providers/mana/qp.c
@@ -223,9 +223,8 @@ switch (type) { case USER_RNIC_SEND_QUEUE_REQUESTER: /* WQE must have at least one SGE */ - /* For write with imm we need one extra SGE */ - sges = max(1U, attr->cap.max_send_sge) + 1; - size = align_hw_size(attr->cap.max_send_wr * get_large_wqe_size(sges)); + sges = max(1U, attr->cap.max_send_sge); + size = align_hw_size(attr->cap.max_send_wr * get_large_fixed_wqe_size(sges)); break; case USER_RNIC_SEND_QUEUE_RESPONDER: if (attr->qp_type == IBV_QPT_RC) @@ -241,8 +240,8 @@ size = align_hw_size(attr->cap.max_recv_wr * get_wqe_size(sges)); break; case USER_RNIC_SEND_QUEUE_MM: - sges = 2; - size = align_hw_size(attr->cap.max_send_wr * get_large_wqe_size(sges)); + sges = 1; + size = align_hw_size(attr->cap.max_send_wr * get_large_fixed_wqe_size(sges)); break; default: return 0; @@ -356,6 +355,7 @@ struct ibv_qp_init_attr *attr) { struct mana_context *ctx = to_mctx(ibpd->context); + uint8_t wqe_size_in_bu; struct mana_qp *qp; int ret, i; @@ -399,6 +399,10 @@ } } + wqe_size_in_bu = get_large_fixed_wqe_size(max(1U, attr->cap.max_send_sge)) + / GDMA_WQE_ALIGNMENT_UNIT_SIZE; + qp->rnic_qp.queues[USER_RNIC_SEND_QUEUE_REQUESTER].wqe_size_in_bu = wqe_size_in_bu; + ret = mana_create_cmd_qp(qp, ibpd, attr); if (ret) { errno = ret;
diff --git a/providers/mana/wr.c b/providers/mana/wr.c index e4d7c38..01067b1 100644 --- a/providers/mana/wr.c +++ b/providers/mana/wr.c
@@ -249,7 +249,7 @@ } total_sge = num_sge + (oob_sge ? 1 : 0); - wqe_size = get_large_wqe_size(total_sge); + wqe_size = get_large_wqe_size(total_sge, wq->wqe_size_in_bu); ret = gdma_get_current_wqe(wq, INLINE_OOB_LARGE_SIZE, wqe_size, wqe); if (ret)