ionic: Add ionic_dv_create_qp_ex API Add DV API ionic_dv_create_qp_ex to create QP with custrom flags. Rename IONIC_V1_CQE_TYPE_RECV_INDIR to IONIC_V1_CQE_TYPE_RECV_RCQE. Refactor ionic_create_qp_ex into ionic_create_qp_ex_common that accepts an optional ionic_dv_qp_init_attr_ex. The RQ buffer is extended by IONIC_RCQ_SIZE (4 KiB) when the RCQ pd_tag is used to support reorder completion queue. Signed-off-by: Allen Hubbe <allen.hubbe@amd.com> Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
diff --git a/providers/ionic/CMakeLists.txt b/providers/ionic/CMakeLists.txt index a28083f..795a100 100644 --- a/providers/ionic/CMakeLists.txt +++ b/providers/ionic/CMakeLists.txt
@@ -1,5 +1,5 @@ rdma_shared_provider(ionic libionic.map - 1 1.0.${PACKAGE_VERSION} + 1 1.1.${PACKAGE_VERSION} ionic.c ionic_verbs.c ionic_memory.c
diff --git a/providers/ionic/ionic.h b/providers/ionic/ionic.h index 9f6c632..b6352db 100644 --- a/providers/ionic/ionic.h +++ b/providers/ionic/ionic.h
@@ -22,6 +22,7 @@ #include "ionic_memory.h" #include "ionic_queue.h" #include "ionic_table.h" +#include "ionic_dv.h" #include <stdio.h> #include <inttypes.h> @@ -45,6 +46,17 @@ #define IONIC_PD_TAG_CQ (IONIC_PD_TAG | 1) #define IONIC_PD_TAG_SQ (IONIC_PD_TAG | 2) #define IONIC_PD_TAG_RQ (IONIC_PD_TAG | 3) +#define IONIC_PD_TAG_RCQ (IONIC_PD_TAG | 4) + +#define IONIC_SET_UDATA(ctx, req, field, val) \ + ({ \ + int __rc = 0; \ + if ((ctx)->robust_udata) \ + (req)->field = (val); \ + else \ + __rc = ENOTSUP; \ + __rc; \ + }) enum { IONIC_CQ_SUPPORTED_WC_FLAGS = @@ -83,6 +95,18 @@ IBV_QP_EX_WITH_SEND_WITH_INV, }; +enum { + IONIC_QP_SUPPORTED_INIT_ATTR_MASK = + IONIC_QP_INIT_ATTR_MASK_FLAGS, + + IONIC_QP_SUPPORTED_INIT_ATTR_FLAGS = + IONIC_QP_INIT_ATTR_RCCL | + IONIC_QP_INIT_ATTR_RCCL_DATA | + IONIC_QP_INIT_ATTR_RCCL_RDFENCE | + IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD | + IONIC_QP_INIT_ATTR_RCCL_RCQ, +}; + struct ionic_ctx { struct verbs_context vctx; @@ -256,6 +280,7 @@ struct ibv_send_wr ex_wr; int ex_rc; bool sig_all; + bool rcq; }; struct ionic_ah { @@ -377,4 +402,8 @@ /* ionic_verbs.h */ void ionic_verbs_set_ops(struct ionic_ctx *ctx); +struct ibv_qp *ionic_create_qp_ex_common(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex); + #endif /* IONIC_H */
diff --git a/providers/ionic/ionic_dv.c b/providers/ionic/ionic_dv.c index 738fcc3..92900dc 100644 --- a/providers/ionic/ionic_dv.c +++ b/providers/ionic/ionic_dv.c
@@ -105,3 +105,15 @@ return 0; } + +struct ibv_qp *ionic_dv_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex) +{ + if (!is_ionic_ctx(ibctx)) { + errno = EINVAL; + return NULL; + } + + return ionic_create_qp_ex_common(ibctx, ex, ionic_ex); +}
diff --git a/providers/ionic/ionic_dv.h b/providers/ionic/ionic_dv.h index a11f5a2..d8efda8 100644 --- a/providers/ionic/ionic_dv.h +++ b/providers/ionic/ionic_dv.h
@@ -68,6 +68,35 @@ */ int ionic_dv_pd_set_rqcmb(struct ibv_pd *ibpd, bool enable, bool expdb, bool require); +enum ionic_qp_init_attr_mask { + IONIC_QP_INIT_ATTR_MASK_FLAGS = 1 << 0, +}; + +enum ionic_qp_init_attr_flags { + IONIC_QP_INIT_ATTR_RCCL = 1 << 16, + IONIC_QP_INIT_ATTR_RCCL_DATA = 1 << 17, + IONIC_QP_INIT_ATTR_RCCL_RDFENCE = 1 << 18, + IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD = 1 << 19, + IONIC_QP_INIT_ATTR_RCCL_RCQ = 1 << 24, + IONIC_QP_INIT_ATTR_RCCL_P2P = 1 << 25, +}; + +struct ionic_dv_qp_init_attr_ex { + uint64_t comp_mask; + uint32_t flags; +}; + +/** + * ionic_dv_create_qp_ex - Create a queue pair with ionic-specific attributes. + * + * @ibctx - Device context. + * @ex - Standard QP init attributes. + * @ionic_ex - Ionic-specific QP init attributes (transport mode, rcq paths). + */ +struct ibv_qp *ionic_dv_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex); + #ifdef __cplusplus } #endif
diff --git a/providers/ionic/ionic_fw.h b/providers/ionic/ionic_fw.h index 6598213..5056a52 100644 --- a/providers/ionic/ionic_fw.h +++ b/providers/ionic/ionic_fw.h
@@ -217,4 +217,6 @@ return spec; } +#define IONIC_RCQ_SIZE 4096 + #endif /* IONIC_FW_H */
diff --git a/providers/ionic/ionic_fw_types.h b/providers/ionic/ionic_fw_types.h index b57f7f9..ed39c3d 100644 --- a/providers/ionic/ionic_fw_types.h +++ b/providers/ionic/ionic_fw_types.h
@@ -126,7 +126,7 @@ IONIC_V1_CQE_TYPE_RECV = 1, IONIC_V1_CQE_TYPE_SEND_MSN = 2, IONIC_V1_CQE_TYPE_SEND_NPG = 3, - IONIC_V1_CQE_TYPE_RECV_INDIR = 4, + IONIC_V1_CQE_TYPE_RECV_RCQE = 4, }; /* v1 base wqe header */
diff --git a/providers/ionic/ionic_queue.c b/providers/ionic/ionic_queue.c index 28458a6..518a986 100644 --- a/providers/ionic/ionic_queue.c +++ b/providers/ionic/ionic_queue.c
@@ -9,6 +9,7 @@ #include "ionic.h" #include "ionic_queue.h" #include "ionic_memory.h" +#include "ionic_fw.h" static void ionic_queue_map(struct ionic_queue *q, struct ionic_pd *pd, uint64_t pd_tag, int stride) { @@ -65,6 +66,9 @@ q->size = BIT_ULL(q->depth_log2 + q->stride_log2); q->mask = BIT(q->depth_log2) - 1; + if (pd_tag == IONIC_PD_TAG_RCQ) + q->size += IONIC_RCQ_SIZE; + ionic_queue_map(q, pd, pd_tag, stride); if (!q->ptr) return errno;
diff --git a/providers/ionic/ionic_verbs.c b/providers/ionic/ionic_verbs.c index 1159cec..9bae721 100644 --- a/providers/ionic/ionic_verbs.c +++ b/providers/ionic/ionic_verbs.c
@@ -1516,7 +1516,7 @@ break; - case IONIC_V1_CQE_TYPE_RECV_INDIR: + case IONIC_V1_CQE_TYPE_RECV_RCQE: list_del(&qp->cq_poll_rq); list_add_tail(&cq->poll_rq, &qp->cq_poll_rq); break; @@ -1798,7 +1798,12 @@ if (max_sge > ionic_v1_recv_wqe_max_sge(ctx->max_stride, 0, false)) return EINVAL; - pd_tag = IONIC_PD_TAG_RQ; + if (qp->rcq) { + pd_tag = IONIC_PD_TAG_RCQ; + qp->rq.cmb = 0; + } else { + pd_tag = IONIC_PD_TAG_RQ; + } qp->rq.spec = ionic_v1_use_spec_sge(max_sge, ctx->spec); if (qp->rq.cmb & IONIC_CMB_EXPDB) { @@ -2135,8 +2140,9 @@ ionic_wr_set(qp, 0, 0, NULL); } -static struct ibv_qp *ionic_create_qp_ex(struct ibv_context *ibctx, - struct ibv_qp_init_attr_ex *ex) +struct ibv_qp *ionic_create_qp_ex_common(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex) { struct ionic_ctx *ctx = to_ionic_ctx(ibctx); struct ionic_pd *pd = to_ionic_pd(ex->pd); @@ -2146,6 +2152,33 @@ struct ionic_cq *cq; int rc; + if (ionic_ex) { + if (!check_comp_mask(ionic_ex->comp_mask, + IONIC_QP_SUPPORTED_INIT_ATTR_MASK)) { + rc = ENOTSUP; + goto err_qp; + } + + if (ionic_ex->comp_mask & IONIC_QP_INIT_ATTR_MASK_FLAGS) { + if (!ctx->ionic_flags_supported || + !check_comp_mask(ionic_ex->flags, + IONIC_QP_SUPPORTED_INIT_ATTR_FLAGS)) { + rc = ENOTSUP; + goto err_qp; + } + + if ((ionic_ex->flags & IONIC_QP_INIT_ATTR_RCCL_RCQ) && + !ctx->rcq_sign_bit) { + rc = EINVAL; + goto err_qp; + } + + rc = IONIC_SET_UDATA(ctx, &req, ionic_flags, ionic_ex->flags); + if (rc) + goto err_qp; + } + } + if ((ex->comp_mask & IONIC_QP_REQUIRED_COMP_MASK) != IONIC_QP_REQUIRED_COMP_MASK) { rc = ENOTSUP; @@ -2186,6 +2219,7 @@ qp->has_rq = true; qp->lockfree = ex->pd ? ionic_pd_lockfree(ex->pd) : false; qp->sig_all = ex->sq_sig_all; + qp->rcq = ctx->rcq_sign_bit && (req.ionic_flags & IONIC_QP_INIT_ATTR_RCCL_RCQ); list_node_init(&qp->cq_poll_sq); list_node_init(&qp->cq_poll_rq); @@ -2328,6 +2362,12 @@ return NULL; } +static struct ibv_qp *ionic_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex) +{ + return ionic_create_qp_ex_common(ibctx, ex, NULL); +} + static void ionic_flush_qp(struct ionic_ctx *ctx, struct ionic_qp *qp) { struct ionic_cq *cq;
diff --git a/providers/ionic/libionic.map b/providers/ionic/libionic.map index 3efca32..be963d7 100644 --- a/providers/ionic/libionic.map +++ b/providers/ionic/libionic.map
@@ -10,3 +10,8 @@ ionic_dv_pd_set_rqcmb; local: *; }; + +IONIC_1.1 { + global: + ionic_dv_create_qp_ex; +} IONIC_1.0;