From patchwork Tue Mar 20 21:18:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10297953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF6E360349 for ; Tue, 20 Mar 2018 21:19:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D25E2969D for ; Tue, 20 Mar 2018 21:19:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9125A2969A; Tue, 20 Mar 2018 21:19:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15E62969A for ; Tue, 20 Mar 2018 21:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751396AbeCTVTN (ORCPT ); Tue, 20 Mar 2018 17:19:13 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44943 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbeCTVTG (ORCPT ); Tue, 20 Mar 2018 17:19:06 -0400 Received: by mail-wr0-f195.google.com with SMTP id u46so3163824wrc.11 for ; Tue, 20 Mar 2018 14:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rQFFZKl5GOtfzMh0d7PEXoV+2IxDuDYqy4a2uSfTRFQ=; b=X7Vbu+Ol+D1xreL1iNc878b1KCe8W4/vblsSTqtyw8Y6GpsSaDtV6t8NG0gODlF8rS LDifhzaczbB5j3Mj1IhaaEd1xvTVWy1Bv1Ude6Hs5/JPKJlQX1Y1vcm7k4+UFFwkMnDU 731W8eTfhklOSuGR5VE/pLruMD8PVBVDGk2OQDbvprnBqxwZgsli9NJa1BxcZb7juCPt Ibi/E+XtH+SRhKop8/ZzWnzzbCqjH2jQjhk3eGFUjOTGrum2brPFwDch05FBVR9iFgRS Vz3pbOPTlLG+6hjRM+AAwilgU2WIRmE+S/RnyBlyoZOckjLK/x74Nbvws0G6Ue3+euBI bghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rQFFZKl5GOtfzMh0d7PEXoV+2IxDuDYqy4a2uSfTRFQ=; b=QNBDMsCBddd4ucOiK60YGTVdAfjoeOdA35k+UbYUyAISr8bEj/g3uZRhfU2p7ZcxOZ H/lCX9MhMfgbxwxYcso0r6RvhKdXIZOgVkUgnu9Bo/UWiACkHSMMuKbOPlTUoKlH8UlI 1najo1HLKFHUnc/wZX3KW5NCCAl1AHhMl1WS/rQ47cPeuO530xgnT8qFLiAIwohWBGyC XNYraE79lNsZYKjowB7TDKVfmRqiWyVd8pZzc2cDHUn/qog70LlW18XfnIo5vC7+NWfU XePkt/jBt2UwY/xFYYyH9trZutyyGz4QHOCtra0L0Hsnkr+bS1tnDifAoSUi2NPBlBaX bK5w== X-Gm-Message-State: AElRT7F40WiBK6sCb8loa+O6ZWsA5/H8kxP2PjCbCSSTYekqJbU2rypo siBTT5nDc/W1bYiZqG9R2P0IXe/eoEs= X-Google-Smtp-Source: AG47ELt9ak8NbKdtrU0oGTDdQWb27vzzCcMRhDHupG/rnl4pbOMkQaQR5QtxMB2rX2n3a8HvJdrSdQ== X-Received: by 10.223.157.3 with SMTP id k3mr15290026wre.179.1521580745218; Tue, 20 Mar 2018 14:19:05 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id 21sm5381203wrt.82.2018.03.20.14.18.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 14:19:00 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eyOem-0002e7-SW; Tue, 20 Mar 2018 15:18:56 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe , Ram Amrani , Ariel Elior , Yishai Hadas , Matan Barak Subject: [PATCH rdma-core 01/20] qedr: Move qedr to exclusively use the kernel uapi headers Date: Tue, 20 Mar 2018 15:18:31 -0600 Message-Id: <20180320211850.10090-2-jgg@ziepe.ca> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180320211850.10090-1-jgg@ziepe.ca> References: <20180320211850.10090-1-jgg@ziepe.ca> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe Using the driver support macros we can now directly create the required driver structs automatically. Signed-off-by: Jason Gunthorpe --- 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 +#include +#include #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);