From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Using the driver support macros we can now directly create the required driver structs automatically. There is one exciting thing here, bnxt_re has a problem with alignment of the alloc_pd driver_data, due to a bug in the core code. bnxt worked around it with some very ugly pointer math, but we have to solve it properly as the common macros detect the problem. Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> --- buildlib/make_abi_structs.py | 6 ++--- kernel-headers/CMakeLists.txt | 1 + providers/bnxt_re/bnxt_re-abi.h | 60 +++++++++-------------------------------- providers/bnxt_re/main.c | 4 +-- providers/bnxt_re/verbs.c | 20 +++++++------- 5 files changed, 29 insertions(+), 62 deletions(-) diff --git a/buildlib/make_abi_structs.py b/buildlib/make_abi_structs.py index 029f10428ad300..0817735ebe17d1 100644 --- a/buildlib/make_abi_structs.py +++ b/buildlib/make_abi_structs.py @@ -24,8 +24,8 @@ def in_struct(ln,FO,nesting=0): """Copy a top level structure over to the #define output, keeping track of nested structures.""" if nesting == 0: - if ln == "};": - FO.write("}\n\n"); + if re.match(r"(}.*);",ln): + FO.write(ln[:-1] + "\n\n"); return find_struct; FO.write(ln + " \\\n"); @@ -33,7 +33,7 @@ def in_struct(ln,FO,nesting=0): if ln == "struct {" or ln == "union {": return functools.partial(in_struct,nesting=nesting+1); - if re.match(r"}.*;",ln): + if re.match(r"}.*;",ln): return functools.partial(in_struct,nesting=nesting-1); return functools.partial(in_struct,nesting=nesting); diff --git a/kernel-headers/CMakeLists.txt b/kernel-headers/CMakeLists.txt index 8f41b6e98b54f5..2c062f8d17a67b 100644 --- a/kernel-headers/CMakeLists.txt +++ b/kernel-headers/CMakeLists.txt @@ -55,6 +55,7 @@ endfunction() # Transform the kernel ABIs used by the providers rdma_kernel_provider_abi( + rdma/bnxt_re-abi.h rdma/cxgb4-abi.h rdma/hns-abi.h rdma/ib_user_verbs.h diff --git a/providers/bnxt_re/bnxt_re-abi.h b/providers/bnxt_re/bnxt_re-abi.h index a9cd44c72e77df..02d1d5774ab3fe 100644 --- a/providers/bnxt_re/bnxt_re-abi.h +++ b/providers/bnxt_re/bnxt_re-abi.h @@ -41,11 +41,23 @@ #include <infiniband/kern-abi.h> #include <rdma/bnxt_re-abi.h> +#include <kernel-abi/bnxt_re-abi.h> #define BNXT_RE_ABI_VERSION 1 #define BNXT_RE_FULL_FLAG_DELTA 0x80 +DECLARE_DRV_CMD(ubnxt_re_pd, IB_USER_VERBS_CMD_ALLOC_PD, + empty, bnxt_re_pd_resp); +DECLARE_DRV_CMD(ubnxt_re_cq, IB_USER_VERBS_CMD_CREATE_CQ, + bnxt_re_cq_req, bnxt_re_cq_resp); +DECLARE_DRV_CMD(ubnxt_re_qp, IB_USER_VERBS_CMD_CREATE_QP, + bnxt_re_qp_req, bnxt_re_qp_resp); +DECLARE_DRV_CMD(ubnxt_re_cntx, IB_USER_VERBS_CMD_GET_CONTEXT, + empty, bnxt_re_uctx_resp); +DECLARE_DRV_CMD(ubnxt_re_mr, IB_USER_VERBS_CMD_REG_MR, + empty, empty); + enum bnxt_re_wr_opcode { BNXT_RE_WR_OPCD_SEND = 0x00, BNXT_RE_WR_OPCD_SEND_IMM = 0x01, @@ -189,41 +201,6 @@ struct bnxt_re_db_hdr { __le32 typ_qid; /* typ: 4, qid:20*/ }; -struct ubnxt_re_cntx_resp { - struct ib_uverbs_get_context_resp resp; - __u32 dev_id; - __u32 max_qp; /* To allocate qp-table */ - __u32 pg_size; - __u32 cqe_size; - __u32 max_cqd; - __u32 rsvd; -}; - -struct ubnxt_re_pd_resp { - struct ib_uverbs_alloc_pd_resp resp; - __u32 pdid; - __u32 dpi; - __u64 dbr; -}; - -struct ubnxt_re_mr_resp { - struct ib_uverbs_reg_mr_resp resp; -}; - -struct ubnxt_re_cq_req { - struct ibv_create_cq cmd; - __u64 cq_va; - __u64 cq_handle; -}; - -struct ubnxt_re_cq_resp { - struct ib_uverbs_create_cq_resp resp; - __u32 cqid; - __u32 tail; - __u32 phase; - __u32 rsvd; -}; - struct bnxt_re_bcqe { __le32 flg_st_typ_ph; __le32 qphi_rwrid; @@ -257,19 +234,6 @@ struct bnxt_re_term_cqe { __le64 rsvd1; }; -struct ubnxt_re_qp_req { - struct ibv_create_qp cmd; - __u64 qpsva; - __u64 qprva; - __u64 qp_handle; -}; - -struct ubnxt_re_qp_resp { - struct ib_uverbs_create_qp_resp resp; - __u32 qpid; - __u32 rsvd; -}; - struct bnxt_re_bsqe { __le32 rsv_ws_fl_wt; __le32 key_immd; diff --git a/providers/bnxt_re/main.c b/providers/bnxt_re/main.c index 32ad59832e66af..54e3cc31cb3adc 100644 --- a/providers/bnxt_re/main.c +++ b/providers/bnxt_re/main.c @@ -124,13 +124,13 @@ static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev, memset(&resp, 0, sizeof(resp)); if (ibv_cmd_get_context(&cntx->ibvctx, &cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) + &resp.ibv_resp, sizeof(resp))) goto failed; cntx->dev_id = resp.dev_id; cntx->max_qp = resp.max_qp; dev->pg_size = resp.pg_size; - dev->cqe_size = resp.cqe_size; + dev->cqe_size = resp.cqe_sz; dev->max_cq_depth = resp.max_cqd; pthread_spin_init(&cntx->fqlock, PTHREAD_PROCESS_PRIVATE); /* mmap shared page. */ diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c index d4232b6224e40c..c90581d6041b64 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c @@ -93,11 +93,13 @@ struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *ibvctx) memset(&resp, 0, sizeof(resp)); if (ibv_cmd_alloc_pd(ibvctx, &pd->ibvpd, &cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) + &resp.ibv_resp, sizeof(resp))) goto out; pd->pdid = resp.pdid; - dbr = *(uint64_t *)((uint32_t *)&resp + 3); + dbr = resp.dbr; + static_assert(offsetof(struct ubnxt_re_pd_resp, dbr) == 4 * 3, + "Bad dbr placement"); /* Map DB page now. */ if (!cntx->udpi.dbpage) { @@ -144,7 +146,7 @@ struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len, return NULL; if (ibv_cmd_reg_mr(ibvpd, sva, len, (uintptr_t)sva, access, &mr->ibvmr, - &cmd, sizeof(cmd), &resp.resp, sizeof(resp))) { + &cmd, sizeof(cmd), &resp.ibv_resp, sizeof(resp))) { free(mr); return NULL; } @@ -169,7 +171,7 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, struct ibv_comp_channel *channel, int vec) { struct bnxt_re_cq *cq; - struct ubnxt_re_cq_req cmd; + struct ubnxt_re_cq cmd; struct ubnxt_re_cq_resp resp; struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); @@ -196,8 +198,8 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, memset(&resp, 0, sizeof(resp)); if (ibv_cmd_create_cq(ibvctx, ncqe, channel, vec, - &cq->ibvcq, &cmd.cmd, sizeof(cmd), - &resp.resp, sizeof(resp))) + &cq->ibvcq, &cmd.ibv_cmd, sizeof(cmd), + &resp.ibv_resp, sizeof(resp))) goto cmdfail; cq->cqid = resp.cqid; @@ -873,7 +875,7 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, struct ibv_qp_init_attr *attr) { struct bnxt_re_qp *qp; - struct ubnxt_re_qp_req req; + struct ubnxt_re_qp req; struct ubnxt_re_qp_resp resp; struct bnxt_re_qpcap *cap; @@ -898,8 +900,8 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, req.qprva = qp->rqq ? (uintptr_t)qp->rqq->va : 0; req.qp_handle = (uintptr_t)qp; - if (ibv_cmd_create_qp(ibvpd, &qp->ibvqp, attr, &req.cmd, sizeof(req), - &resp.resp, sizeof(resp))) { + if (ibv_cmd_create_qp(ibvpd, &qp->ibvqp, attr, &req.ibv_cmd, sizeof(req), + &resp.ibv_resp, sizeof(resp))) { goto failcmd; } -- 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