From patchwork Tue Mar 27 22:03:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10311795 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 58F9E60212 for ; Tue, 27 Mar 2018 22:03:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 418B72999B for ; Tue, 27 Mar 2018 22:03:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3622429E13; Tue, 27 Mar 2018 22:03:55 +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 8AEF226E76 for ; Tue, 27 Mar 2018 22:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbeC0WDw (ORCPT ); Tue, 27 Mar 2018 18:03:52 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:44808 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeC0WDt (ORCPT ); Tue, 27 Mar 2018 18:03:49 -0400 Received: by mail-io0-f194.google.com with SMTP id d7so1076508ioc.11 for ; Tue, 27 Mar 2018 15:03:49 -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=0MiaPVGMuA/AaSSqT5XGbzPS5UXYxL/AZIcHxW7Gal8=; b=NruCWZ9MZIDqyi2r/+HRG5sAbRlbHwMW8s+3fKQCwgR42ev7XvrVD+2ZsAGh09/UW2 RY6W0ihUO14zTR4LYLMQHL9KBs3x1N57z6SxkbEm9tYSoQJXom6yxEDazfAfY61DAQEy tHvXCJ6qHb83Og3NAVbVMWSyoVxuRAbeAcqCFo7Cr6FK9bVCCyHP/BIoPJiW4sdYTrPc sQkoeVpAflhzNVVNDIAa5WwdWMMPtzCHmz2JDmaSaHiSfHGmrQ3msMahQqhAxwcXclcc 9vkB8ztrZVkA5QnG9rSS8q4LDmIzo7Tvpnry0KmJFjXKswPNZKpckjOAoRQL6WxFB9L1 aZSA== 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=0MiaPVGMuA/AaSSqT5XGbzPS5UXYxL/AZIcHxW7Gal8=; b=aDQJ2BSDhJcAxGSdabhYy/wQRDfpCuHRV1cNhOQnSIxN/S4dAVvSGPCRg9dDPD8XCs RH76gLpmCzxfIGa+3FlYr+Pk1gAdcaK7D2sO9vKNpdD2SziLHHzhe09ka5t4Hw6kPY0o 3pTHpnXYDw0nGSP9Vw3GGS0iCAtDZwNwpAXYPw2ncZtHb0w1cRNZuOyaQguaiGVeWcyV 0aQJEey+DbGqpdKz77nDu/uXiaRXwGtVC99hFYALnUQ6cg+mZPwuH8SOv6Ow6E96Nr2R ilBqvFeTx81H4NxoOM8DhY2o1MmnDlucPsuD1C730asRCNvmEGRBAha9L8778ggYSSo3 H5aQ== X-Gm-Message-State: AElRT7Fh/ZxzhioiajSDI7wTLIW9+ynfBVa60iEgg9ymPeUz12va9EtK jynAtZTD9/xV+p4SvGtfnaR4hfw+6a0= X-Google-Smtp-Source: AG47ELtcTQTdhYcKBh8gGjpzpCpoY8TQIF1/u0cIe6BQcyT9D4A2Hme0yAjryFVzNhd8uVj1hVIGHw== X-Received: by 10.107.32.145 with SMTP id g139mr47224346iog.56.1522188228692; Tue, 27 Mar 2018 15:03:48 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id c8-v6sm1701005ita.18.2018.03.27.15.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 15:03:45 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1f0wgy-0004Ow-Ip; Tue, 27 Mar 2018 16:03:44 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe , Devesh Sharma , Yishai Hadas , Matan Barak Subject: [PATCH rdma-core 4/6] ocrdma: Move ocrdma to exclusively use the kernel uapi headers Date: Tue, 27 Mar 2018 16:03:34 -0600 Message-Id: <20180327220336.16668-5-jgg@ziepe.ca> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180327220336.16668-1-jgg@ziepe.ca> References: <20180327220336.16668-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/ocrdma/ocrdma_abi.h | 130 +++++----------------------------------- providers/ocrdma/ocrdma_main.c | 2 +- providers/ocrdma/ocrdma_verbs.c | 18 +++--- 4 files changed, 25 insertions(+), 126 deletions(-) diff --git a/kernel-headers/CMakeLists.txt b/kernel-headers/CMakeLists.txt index 1c4662007a02a3..e59ffd9e0c29db 100644 --- a/kernel-headers/CMakeLists.txt +++ b/kernel-headers/CMakeLists.txt @@ -64,6 +64,7 @@ rdma_kernel_provider_abi( rdma/mlx5-abi.h rdma/mthca-abi.h rdma/nes-abi.h + rdma/ocrdma-abi.h rdma/qedr-abi.h rdma/rdma_user_rxe.h rdma/vmw_pvrdma-abi.h diff --git a/providers/ocrdma/ocrdma_abi.h b/providers/ocrdma/ocrdma_abi.h index b5ac0991abb331..6956a4f112e24c 100644 --- a/providers/ocrdma/ocrdma_abi.h +++ b/providers/ocrdma/ocrdma_abi.h @@ -38,9 +38,23 @@ #include #include #include +#include #define OCRDMA_ABI_VERSION 2 +DECLARE_DRV_CMD(uocrdma_get_context, IB_USER_VERBS_CMD_GET_CONTEXT, + empty, ocrdma_alloc_ucontext_resp); +DECLARE_DRV_CMD(uocrdma_alloc_pd, IB_USER_VERBS_CMD_ALLOC_PD, + ocrdma_alloc_pd_ureq, ocrdma_alloc_pd_uresp); +DECLARE_DRV_CMD(uocrdma_create_cq, IB_USER_VERBS_CMD_CREATE_CQ, + ocrdma_create_cq_ureq, ocrdma_create_cq_uresp); +DECLARE_DRV_CMD(uocrdma_reg_mr, IB_USER_VERBS_CMD_REG_MR, + empty, empty); +DECLARE_DRV_CMD(uocrdma_create_qp, IB_USER_VERBS_CMD_CREATE_QP, + ocrdma_create_qp_ureq, ocrdma_create_qp_uresp); +DECLARE_DRV_CMD(uocrdma_create_srq, IB_USER_VERBS_CMD_CREATE_SRQ, + empty, ocrdma_create_srq_uresp); + #define Bit(_b) (1 << (_b)) #define OCRDMA_MAX_QP 2048 @@ -62,122 +76,6 @@ enum { /* solicited bit */ #define OCRDMA_DB_CQ_SOLICIT_SHIFT (31) /* bit 31 */ -struct uocrdma_get_context { - struct ibv_get_context cmd; -}; - -struct uocrdma_alloc_ucontext_resp { - struct ib_uverbs_get_context_resp ibv_resp; - uint32_t dev_id; - uint32_t wqe_size; - uint32_t max_inline_data; - uint32_t dpp_wqe_size; - uint64_t ah_tbl_page; - uint32_t ah_tbl_len; - uint32_t rqe_size; - uint8_t fw_ver[32]; - uint64_t rsvd1; - uint64_t rsvd2; -}; - -struct uocrdma_alloc_pd_req { - struct ibv_alloc_pd cmd; - uint64_t rsvd; -}; - -struct uocrdma_alloc_pd_resp { - struct ib_uverbs_alloc_pd_resp ibv_resp; - uint32_t id; - uint32_t dpp_enabled; - uint32_t dpp_page_addr_hi; - uint32_t dpp_page_addr_lo; - uint64_t rsvd; -}; - -struct uocrdma_create_cq_req { - struct ibv_create_cq ibv_cmd; - uint32_t dpp_cq; - uint32_t rsvd; -}; - -struct uocrdma_create_cq_resp { - struct ib_uverbs_create_cq_resp ibv_resp; - uint32_t cq_id; - uint32_t size; - uint32_t num_pages; - uint32_t max_hw_cqe; - uint64_t page_addr[MAX_CQ_PAGES]; - uint64_t db_page_addr; - uint32_t db_page_size; - uint32_t phase_change; - uint64_t rsvd1; - uint64_t rsvd2; -}; - -struct uocrdma_reg_mr { - struct ibv_reg_mr ibv_cmd; -}; - -struct uocrdma_reg_mr_resp { - struct ib_uverbs_reg_mr_resp ibv_resp; -}; - -struct uocrdma_create_qp_cmd { - struct ibv_create_qp ibv_cmd; - uint8_t enable_dpp_cq; - uint8_t rsvd; - uint16_t dpp_cq_id; - uint32_t rsvd1; /* pad */ -}; - -struct uocrdma_create_qp_uresp { - struct ib_uverbs_create_qp_resp ibv_resp; - uint16_t qp_id; - uint16_t sq_dbid; - uint16_t rq_dbid; - uint16_t resv0; /* pad */ - uint32_t sq_page_size; - uint32_t rq_page_size; - uint32_t num_sq_pages; - uint32_t num_rq_pages; - uint64_t sq_page_addr[MAX_QP_PAGES]; - uint64_t rq_page_addr[MAX_QP_PAGES]; - uint64_t db_page_addr; - uint32_t db_page_size; - uint32_t dpp_credit; - uint32_t dpp_offset; - uint32_t num_wqe_allocated; - uint32_t num_rqe_allocated; - uint32_t db_sq_offset; - uint32_t db_rq_offset; - uint32_t db_shift; - uint64_t rsvd[11]; /* 8*8 + 4*4 + 8 */ -}; - -struct uocrdma_create_srq_cmd { - struct ibv_create_srq ibv_cmd; -}; - -struct uocrdma_create_srq_resp { - struct ib_uverbs_create_srq_resp ibv_resp; - uint16_t rq_dbid; - uint16_t resv0; - uint32_t resv1; - - uint32_t rq_page_size; - uint32_t num_rq_pages; - - uint64_t rq_page_addr[MAX_QP_PAGES]; - uint64_t db_page_addr; - - uint32_t db_page_size; - uint32_t num_rqe_allocated; - uint32_t db_rq_offset; - uint32_t db_shift; - uint64_t rsvd2; - uint64_t rsvd3; -}; - enum OCRDMA_CQE_STATUS { OCRDMA_CQE_SUCCESS = 0, OCRDMA_CQE_LOC_LEN_ERR = 1, diff --git a/providers/ocrdma/ocrdma_main.c b/providers/ocrdma/ocrdma_main.c index ee67f4d07d5139..c3df474f06e60c 100644 --- a/providers/ocrdma/ocrdma_main.c +++ b/providers/ocrdma/ocrdma_main.c @@ -110,7 +110,7 @@ static struct verbs_context *ocrdma_alloc_context(struct ibv_device *ibdev, { struct ocrdma_devctx *ctx; struct uocrdma_get_context cmd; - struct uocrdma_alloc_ucontext_resp resp; + struct uocrdma_get_context_resp resp; ctx = verbs_init_and_alloc_context(ibdev, cmd_fd, ctx, ibv_ctx, RDMA_DRIVER_OCRDMA); diff --git a/providers/ocrdma/ocrdma_verbs.c b/providers/ocrdma/ocrdma_verbs.c index 223ad9c690fd0a..b9fa7d68dcc3cb 100644 --- a/providers/ocrdma/ocrdma_verbs.c +++ b/providers/ocrdma/ocrdma_verbs.c @@ -133,7 +133,7 @@ static void ocrdma_free_ah_tbl_id(struct ocrdma_devctx *ctx, int idx) */ struct ibv_pd *ocrdma_alloc_pd(struct ibv_context *context) { - struct uocrdma_alloc_pd_req cmd; + struct uocrdma_alloc_pd cmd; struct uocrdma_alloc_pd_resp resp; struct ocrdma_pd *pd; uint64_t map_address = 0; @@ -144,8 +144,8 @@ struct ibv_pd *ocrdma_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, - &resp.ibv_resp, sizeof resp)) { + if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd.ibv_cmd, sizeof(cmd), + &resp.ibv_resp, sizeof(resp))) { free(pd); return NULL; } @@ -230,7 +230,7 @@ static struct ibv_cq *ocrdma_create_cq_common(struct ibv_context *context, int comp_vector, int dpp_cq) { int status; - struct uocrdma_create_cq_req cmd; + struct uocrdma_create_cq cmd; struct uocrdma_create_cq_resp resp; struct ocrdma_cq *cq; struct ocrdma_device *dev = get_ocrdma_dev(context->device); @@ -252,10 +252,10 @@ static struct ibv_cq *ocrdma_create_cq_common(struct ibv_context *context, cq->dev = dev; cq->cq_id = resp.cq_id; cq->cq_dbid = resp.cq_id; - cq->cq_mem_size = resp.size; + cq->cq_mem_size = resp.page_size; cq->max_hw_cqe = resp.max_hw_cqe; cq->phase_change = resp.phase_change; - cq->va = mmap(NULL, resp.size, PROT_READ | PROT_WRITE, + cq->va = mmap(NULL, resp.page_size, PROT_READ | PROT_WRITE, MAP_SHARED, context->cmd_fd, resp.page_addr[0]); if (cq->va == MAP_FAILED) goto cq_err2; @@ -354,7 +354,7 @@ struct ibv_srq *ocrdma_create_srq(struct ibv_pd *pd, { int status = 0; struct ocrdma_srq *srq; - struct uocrdma_create_srq_cmd cmd; + struct uocrdma_create_srq cmd; struct uocrdma_create_srq_resp resp; void *map_addr; @@ -464,8 +464,8 @@ struct ibv_qp *ocrdma_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attrs) { int status = 0; - struct uocrdma_create_qp_cmd cmd; - struct uocrdma_create_qp_uresp resp; + struct uocrdma_create_qp cmd; + struct uocrdma_create_qp_resp resp; struct ocrdma_qp *qp; void *map_addr; #ifdef DPP_CQ_SUPPORT