Skip to content

Commit

Permalink
libqedr: add support for XRC-SRQ's.
Browse files Browse the repository at this point in the history
Add support for XRC-SRQ's user mode application.
Implement the specific verbs.

Signed-off-by: Michal Kalderon <[email protected]>
Signed-off-by: Yuval Basson <[email protected]>
  • Loading branch information
Yuval Basson authored and Michal Kalderon committed Sep 7, 2020
1 parent e41c757 commit cae4a99
Show file tree
Hide file tree
Showing 6 changed files with 454 additions and 117 deletions.
37 changes: 33 additions & 4 deletions providers/qedr/qelr.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ enum qelr_dpm_flags {
QELR_DPM_FLAGS_EDPM_MODE = (1 << 2),
};

#define QELR_MAX_SRQ_ID 4096

struct qelr_devctx {
struct verbs_context ibv_ctx;
FILE *dbg_fp;
Expand All @@ -147,6 +149,7 @@ struct qelr_devctx {
uint32_t sges_per_send_wr;
uint32_t sges_per_recv_wr;
uint32_t sges_per_srq_wr;
struct qelr_srq **srq_table;
int max_cqes;
};

Expand Down Expand Up @@ -227,6 +230,10 @@ struct qelr_rdma_ext {
__be32 dma_length;
};

struct qelr_xrceth {
__be32 xrc_srq;
};

/* rdma extension, invalidate / immediate data + padding, inline data... */
#define QELR_MAX_DPM_PAYLOAD (sizeof(struct qelr_rdma_ext) + sizeof(uint64_t) +\
ROCE_REQ_MAX_INLINE_DATA_SIZE)
Expand Down Expand Up @@ -259,16 +266,24 @@ struct qelr_srq_hwq_info {
};

struct qelr_srq {
struct ibv_srq ibv_srq;
struct verbs_srq verbs_srq;
struct qelr_srq_hwq_info hw_srq;
uint16_t srq_id;
pthread_spinlock_t lock;
bool is_xrc;
};

enum qelr_qp_flags {
QELR_QP_FLAG_SQ = 1 << 0,
QELR_QP_FLAG_RQ = 1 << 1,
};

struct qelr_qp {
struct ibv_qp ibv_qp;
struct verbs_qp verbs_qp;
struct ibv_qp *ibv_qp;
pthread_spinlock_t q_lock;
enum qelr_qp_state state; /* QP state */
uint8_t flags;

struct qelr_qp_hwq_info sq;
struct qelr_qp_hwq_info rq;
Expand Down Expand Up @@ -305,9 +320,16 @@ static inline struct qelr_device *get_qelr_dev(struct ibv_device *ibdev)
return container_of(ibdev, struct qelr_device, ibv_dev.device);
}

static inline struct ibv_qp *get_ibv_qp(struct qelr_qp *qp)
{
return &qp->verbs_qp.qp;
}

static inline struct qelr_qp *get_qelr_qp(struct ibv_qp *ibqp)
{
return container_of(ibqp, struct qelr_qp, ibv_qp);
struct verbs_qp *vqp = (struct verbs_qp *)ibqp;

return container_of(vqp, struct qelr_qp, verbs_qp);
}

static inline struct qelr_pd *get_qelr_pd(struct ibv_pd *ibpd)
Expand All @@ -322,7 +344,14 @@ static inline struct qelr_cq *get_qelr_cq(struct ibv_cq *ibcq)

static inline struct qelr_srq *get_qelr_srq(struct ibv_srq *ibsrq)
{
return container_of(ibsrq, struct qelr_srq, ibv_srq);
struct verbs_srq *vsrq = (struct verbs_srq *)ibsrq;

return container_of(vsrq, struct qelr_srq, verbs_srq);
}

static inline struct ibv_srq *get_ibv_srq(struct qelr_srq *srq)
{
return &srq->verbs_srq.srq;
}

#define SET_FIELD(value, name, flag) \
Expand Down
4 changes: 4 additions & 0 deletions providers/qedr/qelr_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ DECLARE_DRV_CMD(qelr_reg_mr, IB_USER_VERBS_CMD_REG_MR,
empty, empty);
DECLARE_DRV_CMD(qelr_create_srq, IB_USER_VERBS_CMD_CREATE_SRQ,
qedr_create_srq_ureq, qedr_create_srq_uresp);
DECLARE_DRV_CMD(qelr_create_srq_ex, IB_USER_VERBS_CMD_CREATE_XSRQ,
qedr_create_srq_ureq, qedr_create_srq_uresp);
DECLARE_DRV_CMD(qelr_create_qp_ex, IB_USER_VERBS_EX_CMD_CREATE_QP,
qedr_create_qp_ureq, qedr_create_qp_uresp);

#endif /* __QELR_ABI_H__ */
8 changes: 7 additions & 1 deletion providers/qedr/qelr_hsi_rdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ struct rdma_cqe_responder
__le32 imm_data_or_inv_r_Key /* immediate data in case imm_flg is set, or invalidated r_key in case inv_flg is set */;
__le32 length;
__le32 imm_data_hi /* High bytes of immediate data in case imm_flg is set in iWARP only */;
__le16 rq_cons /* Valid only when status is WORK_REQUEST_FLUSHED_ERR. Indicates an aggregative flush on all posted RQ WQEs until the reported rq_cons. */;
__le16 rq_cons_or_srq_id;/* When type is RDMA_CQE_TYPE_RESPONDER_RQ and status is
* WORK_REQUEST_FLUSHED_ERR it indicates an aggregative
* flush on all posted RQ WQEs until the reported rq_cons.
* When type is RDMA_CQE_TYPE_RESPONDER_XRC_SRQ it is the srq_id
*/
uint8_t flags;
#define RDMA_CQE_RESPONDER_TOGGLE_BIT_MASK 0x1 /* indicates a valid completion written by FW. FW toggle this bit each time it finishes producing all PBL entries */
#define RDMA_CQE_RESPONDER_TOGGLE_BIT_SHIFT 0
Expand Down Expand Up @@ -133,6 +137,7 @@ enum rdma_cqe_requester_status_enum
RDMA_CQE_REQ_STS_RNR_NAK_RETRY_CNT_ERR,
RDMA_CQE_REQ_STS_TRANSPORT_RETRY_CNT_ERR,
RDMA_CQE_REQ_STS_WORK_REQUEST_FLUSHED_ERR,
RDMA_CQE_REQ_STS_XRC_VIOLATION_ERR,
MAX_RDMA_CQE_REQUESTER_STATUS_ENUM
};

Expand Down Expand Up @@ -163,6 +168,7 @@ enum rdma_cqe_type
RDMA_CQE_TYPE_REQUESTER,
RDMA_CQE_TYPE_RESPONDER_RQ,
RDMA_CQE_TYPE_RESPONDER_SRQ,
RDMA_CQE_TYPE_RESPONDER_XRC_SRQ,
RDMA_CQE_TYPE_INVALID,
MAX_RDMA_CQE_TYPE
};
Expand Down
15 changes: 15 additions & 0 deletions providers/qedr/qelr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
int cmd_fd,
void *private_data)
{
struct verbs_context *v_ctx;
struct qelr_devctx *ctx;
struct qelr_alloc_context cmd = {};
struct qelr_alloc_context_resp resp;
Expand All @@ -176,6 +177,7 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
if (!ctx)
return NULL;

v_ctx = &ctx->ibv_ctx;
memset(&resp, 0, sizeof(resp));

qelr_open_debug_file(ctx);
Expand All @@ -189,6 +191,12 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,

verbs_set_ops(&ctx->ibv_ctx, &qelr_ctx_ops);

ctx->srq_table = calloc(QELR_MAX_SRQ_ID, sizeof(*ctx->srq_table));
if (!ctx->srq_table) {
DP_ERR(ctx->dbg_fp, "failed to allocate srq_table\n");
return NULL;
}

ctx->kernel_page_size = sysconf(_SC_PAGESIZE);
ctx->db_pa = resp.db_pa;
ctx->db_size = resp.db_size;
Expand Down Expand Up @@ -240,6 +248,12 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
goto cmd_err;
}

v_ctx->create_qp_ex = qelr_create_qp_ex;
v_ctx->open_xrcd = qelr_open_xrcd;
v_ctx->close_xrcd = qelr_close_xrcd;
v_ctx->create_srq_ex = qelr_create_srq_ex;
v_ctx->get_srq_num = qelr_get_srq_num;

return &ctx->ibv_ctx;

cmd_err:
Expand All @@ -257,6 +271,7 @@ static void qelr_free_context(struct ibv_context *ibctx)
if (ctx->db_addr)
munmap(ctx->db_addr, ctx->db_size);

free(ctx->srq_table);
qelr_close_debug_file(ctx);
verbs_uninit_context(&ctx->ibv_ctx);
free(ctx);
Expand Down

0 comments on commit cae4a99

Please sign in to comment.