From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Using the driver support macros we can now directly create the required driver structs automatically. Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> --- kernel-headers/CMakeLists.txt | 1 + providers/qedr/qelr_abi.h | 91 ++++++------------------------------------- providers/qedr/qelr_main.c | 5 +-- providers/qedr/qelr_verbs.c | 18 ++++----- 4 files changed, 24 insertions(+), 91 deletions(-) diff --git a/kernel-headers/CMakeLists.txt b/kernel-headers/CMakeLists.txt index b0fb34375bcdc1..e8fb9a2464ead9 100644 --- a/kernel-headers/CMakeLists.txt +++ b/kernel-headers/CMakeLists.txt @@ -56,4 +56,5 @@ endfunction() # Transform the kernel ABIs used by the providers rdma_kernel_provider_abi( rdma/ib_user_verbs.h + rdma/qedr-abi.h ) diff --git a/providers/qedr/qelr_abi.h b/providers/qedr/qelr_abi.h index 95c880b6ab80a4..3666845c8d0020 100644 --- a/providers/qedr/qelr_abi.h +++ b/providers/qedr/qelr_abi.h @@ -34,87 +34,20 @@ #define __QELR_ABI_H__ #include <infiniband/kern-abi.h> +#include <rdma/qedr-abi.h> +#include <kernel-abi/qedr-abi.h> #define QELR_ABI_VERSION (8) -struct qelr_get_context { - struct ibv_get_context cmd; /* must be first */ -}; - -struct qelr_alloc_ucontext_resp { - struct ib_uverbs_get_context_resp ibv_resp; /* must be first */ - __u64 db_pa; - __u32 db_size; - - __u32 max_send_wr; - __u32 max_recv_wr; - __u32 max_srq_wr; - __u32 sges_per_send_wr; - __u32 sges_per_recv_wr; - __u32 sges_per_srq_wr; - __u32 max_cqes; -}; - -struct qelr_alloc_pd_req { - struct ibv_alloc_pd cmd; /* must be first */ -}; - -struct qelr_alloc_pd_resp { - struct ib_uverbs_alloc_pd_resp ibv_resp; /* must be first */ - __u32 pd_id; -}; - -struct qelr_create_cq_req { - struct ibv_create_cq ibv_cmd; /* must be first */ - - __u64 addr; /* user space virtual address of CQ buffer */ - __u64 len; /* size of CQ buffer */ -}; - -struct qelr_create_cq_resp { - struct ib_uverbs_create_cq_resp ibv_resp; /* must be first */ - __u32 db_offset; - __u16 icid; -}; - -struct qelr_reg_mr { - struct ibv_reg_mr ibv_cmd; /* must be first */ -}; - -struct qelr_reg_mr_resp { - struct ib_uverbs_reg_mr_resp ibv_resp; /* must be first */ -}; - -struct qelr_create_qp_req { - struct ibv_create_qp ibv_qp; /* must be first */ - - __u32 qp_handle_hi; - __u32 qp_handle_lo; - - /* SQ */ - __u64 sq_addr; /* user space virtual address of SQ buffer */ - __u64 sq_len; /* length of SQ buffer */ - - /* RQ */ - __u64 rq_addr; /* user space virtual address of RQ buffer */ - __u64 rq_len; /* length of RQ buffer */ -}; - -struct qelr_create_qp_resp { - struct ib_uverbs_create_qp_resp ibv_resp; /* must be first */ - - __u32 qp_id; - __u32 atomic_supported; - - /* SQ */ - __u32 sq_db_offset; - __u16 sq_icid; - - /* RQ */ - __u32 rq_db_offset; - __u16 rq_icid; - - __u32 rq_db2_offset; -}; +DECLARE_DRV_CMD(qelr_alloc_pd, IB_USER_VERBS_CMD_ALLOC_PD, + empty, qedr_alloc_pd_uresp); +DECLARE_DRV_CMD(qelr_create_cq, IB_USER_VERBS_CMD_CREATE_CQ, + qedr_create_cq_ureq, qedr_create_cq_uresp); +DECLARE_DRV_CMD(qelr_create_qp, IB_USER_VERBS_CMD_CREATE_QP, + qedr_create_qp_ureq, qedr_create_qp_uresp); +DECLARE_DRV_CMD(qelr_get_context, IB_USER_VERBS_CMD_GET_CONTEXT, + empty, qedr_alloc_ucontext_resp); +DECLARE_DRV_CMD(qelr_reg_mr, IB_USER_VERBS_CMD_REG_MR, + empty, empty); #endif /* __QELR_ABI_H__ */ diff --git a/providers/qedr/qelr_main.c b/providers/qedr/qelr_main.c index 84a8576d43d57c..e99fc88ebd9ff8 100644 --- a/providers/qedr/qelr_main.c +++ b/providers/qedr/qelr_main.c @@ -160,7 +160,7 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev, { struct qelr_devctx *ctx; struct qelr_get_context cmd; - struct qelr_alloc_ucontext_resp resp; + struct qelr_get_context_resp resp; ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx, RDMA_DRIVER_QEDR); @@ -172,8 +172,7 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev, qelr_open_debug_file(ctx); qelr_set_debug_mask(); - if (ibv_cmd_get_context(&ctx->ibv_ctx, - (struct ibv_get_context *)&cmd, sizeof(cmd), + if (ibv_cmd_get_context(&ctx->ibv_ctx, &cmd.ibv_cmd, sizeof(cmd), &resp.ibv_resp, sizeof(resp))) goto cmd_err; diff --git a/providers/qedr/qelr_verbs.c b/providers/qedr/qelr_verbs.c index bac5aae8838ff7..e3b01f28633024 100644 --- a/providers/qedr/qelr_verbs.c +++ b/providers/qedr/qelr_verbs.c @@ -114,7 +114,7 @@ int qelr_query_port(struct ibv_context *context, uint8_t port, struct ibv_pd *qelr_alloc_pd(struct ibv_context *context) { - struct qelr_alloc_pd_req cmd; + struct qelr_alloc_pd cmd; struct qelr_alloc_pd_resp resp; struct qelr_pd *pd; struct qelr_devctx *cxt = get_qelr_ctx(context); @@ -126,7 +126,7 @@ struct ibv_pd *qelr_alloc_pd(struct ibv_context *context) bzero(pd, sizeof(*pd)); memset(&cmd, 0, sizeof(cmd)); - if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd.cmd, sizeof(cmd), + if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd.ibv_cmd, sizeof(cmd), &resp.ibv_resp, sizeof(resp))) { free(pd); return NULL; @@ -226,7 +226,7 @@ struct ibv_cq *qelr_create_cq(struct ibv_context *context, int cqe, { struct qelr_devctx *cxt = get_qelr_ctx(context); struct qelr_create_cq_resp resp; - struct qelr_create_cq_req cmd; + struct qelr_create_cq cmd; struct qelr_cq *cq; int chain_size; int rc; @@ -492,7 +492,7 @@ static inline void qelr_print_qp_init_attr( static inline void qelr_create_qp_configure_sq_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) + struct qelr_create_qp *req) { req->sq_addr = (uintptr_t)qp->sq.chain.first_addr; req->sq_len = qp->sq.chain.size; @@ -500,7 +500,7 @@ qelr_create_qp_configure_sq_req(struct qelr_qp *qp, static inline void qelr_create_qp_configure_rq_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) + struct qelr_create_qp *req) { req->rq_addr = (uintptr_t)qp->rq.chain.first_addr; req->rq_len = qp->rq.chain.size; @@ -508,7 +508,7 @@ qelr_create_qp_configure_rq_req(struct qelr_qp *qp, static inline void qelr_create_qp_configure_req(struct qelr_qp *qp, - struct qelr_create_qp_req *req) + struct qelr_create_qp *req) { memset(req, 0, sizeof(*req)); req->qp_handle_hi = U64_HI(qp); @@ -522,7 +522,7 @@ struct ibv_qp *qelr_create_qp(struct ibv_pd *pd, { struct qelr_devctx *cxt = get_qelr_ctx(pd->context); struct qelr_create_qp_resp resp; - struct qelr_create_qp_req req; + struct qelr_create_qp req; struct qelr_qp *qp; int rc; @@ -538,8 +538,8 @@ struct ibv_qp *qelr_create_qp(struct ibv_pd *pd, qelr_create_qp_configure_req(qp, &req); - rc = ibv_cmd_create_qp(pd, &qp->ibv_qp, attrs, &req.ibv_qp, sizeof(req), - &resp.ibv_resp, sizeof(resp)); + rc = ibv_cmd_create_qp(pd, &qp->ibv_qp, attrs, &req.ibv_cmd, + sizeof(req), &resp.ibv_resp, sizeof(resp)); if (rc) { DP_ERR(cxt->dbg_fp, "create qp: failed on ibv_cmd_create_qp with %d\n", rc); -- 2.16.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html