From patchwork Thu Nov 23 03:10:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: longli@linuxonhyperv.com X-Patchwork-Id: 168673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp190693vqx; Wed, 22 Nov 2023 19:10:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRodj9NYEApf13nfFTFT09JiAqAH7RTVmgMf0mnAGw01mMc3E5tqdVCzmCPbYxA/eLVcMV X-Received: by 2002:a17:90b:38cd:b0:27c:f309:f381 with SMTP id nn13-20020a17090b38cd00b0027cf309f381mr5058194pjb.6.1700709049876; Wed, 22 Nov 2023 19:10:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700709049; cv=none; d=google.com; s=arc-20160816; b=xAdNz2EDCiSB4ZttPA/c2qtmlA8FTrdt1/x6fdDpzYekuzAoOlneAkFrFhCbpquqbc w6X+K/RO1heqts0EgwhGOYrIlErTtRxO9HrsGOHJHR04kGIgCuZkL0/31PQZMWuTaurJ yftUY2yC7dxHYLkES5UeMqhTd+wHhRV3l5eWkmImAPijKFniLiAQlKDN/8NQIqL/FXXM px41+CfVu4CyN8KfW6X1eiuk0YBuYhr4yRLSzrxRxKG/Slw2T1o/cF0qBt01JdGu3TH5 Iz4wP/JNC6vYjlouzdJRsxwGudECkkXgIWcxnbvcPp/DtznW/rRtdYcXIDrGPMMnVHmO fACA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=xQ3ukOJ7UAMLtXOhtejHTA9H2LOb0GWntyVyLe1Zgwk=; fh=uNLUDd9eMsTSVEvEY0MjopzAsOI0Sfr5Wvsh0Zza+hA=; b=0cj3ft5E8kUx2T1km9MFO1x5pVEX4khX43qA/rDjFpJGhGnVb/HlcH0Mdr+Zpt2gBn gNMTizZ1JrPYURwhYdN5GyI1bxdlyxD/i/mNaMKOGvI5bwLL0kcLOJQ1k/AJqBc4iQNc 89zZ7CmPHLN4NprncSco/3T5WOVL6kK+mzfrSYVBf9/YOLsS9p/dUWg8S5AENaRHPmBi aL3F1r9sZ81BfJ3TBiXFtnbY+eRiRmp1towHk7AWUAXTB6jiy/BwXXR8/9xrQEr/VPZW Noyjjie6AmwbAkgABeNYWqhysCsk5iwZ1uvUQAaHd5gfoQNdhU0qzgziO1gO5g3pDoWP JNVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=YvYrDBNx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z20-20020a17090a8b9400b0028017a2a8f5si430057pjn.121.2023.11.22.19.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:10:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=YvYrDBNx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 28341830D113; Wed, 22 Nov 2023 19:10:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344560AbjKWDKZ (ORCPT + 99 others); Wed, 22 Nov 2023 22:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344420AbjKWDKR (ORCPT ); Wed, 22 Nov 2023 22:10:17 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 807261BF; Wed, 22 Nov 2023 19:10:23 -0800 (PST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 15FA020B74C3; Wed, 22 Nov 2023 19:10:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 15FA020B74C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1700709023; bh=xQ3ukOJ7UAMLtXOhtejHTA9H2LOb0GWntyVyLe1Zgwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvYrDBNxlA+Y7BRxm67Df5yz8aKeEi3dO5140JpcvsPSqRhApWQIpPgxcezhUZ56i pD07Ox+JhpLu7mYXOFkAdSySEsPg/JL0Ma2XDQ/CLyRYqHSOXMLGB+vdHRtMvKOBQX 4qozkANc4LALqBPURkMf4+n2sRx6BKwo/AFSIy/k= From: longli@linuxonhyperv.com To: Jason Gunthorpe , Leon Romanovsky , Ajay Sharma , Dexuan Cui , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Long Li Subject: [Patch v1 3/4] RDMA/mana_ib: create RDMA adapter handle Date: Wed, 22 Nov 2023 19:10:09 -0800 Message-Id: <1700709010-22042-4-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1700709010-22042-1-git-send-email-longli@linuxonhyperv.com> References: <1700709010-22042-1-git-send-email-longli@linuxonhyperv.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 19:10:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783322693112717751 X-GMAIL-MSGID: 1783322693112717751 From: Long Li Create the RDMA device handle with the SoC using the management EQ created earlier. Signed-off-by: Long Li --- drivers/infiniband/hw/mana/device.c | 10 ++++-- drivers/infiniband/hw/mana/main.c | 51 ++++++++++++++++++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 30 ++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index 3da4763e1a0c..5e5aa75230c2 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -93,9 +93,10 @@ static int mana_ib_probe(struct auxiliary_device *adev, goto deregister_device; } + ret = mana_ib_create_adapter(dev); if (ret) { - ib_dealloc_device(&dev->ib_dev); - return ret; + ibdev_err(&dev->ib_dev, "Failed to create adapter"); + goto free_error_eq; } ret = ib_register_device(&dev->ib_dev, "mana_%d", @@ -108,8 +109,10 @@ static int mana_ib_probe(struct auxiliary_device *adev, return 0; destroy_adapter: - mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq); + mana_ib_destroy_adapter(dev); +free_error_eq: xa_destroy(&dev->rq_to_qp_lookup_table); + mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq); deregister_device: mana_gd_deregister_device(dev->gdma_dev); free_ib_device: @@ -123,6 +126,7 @@ static void mana_ib_remove(struct auxiliary_device *adev) ib_unregister_device(&dev->ib_dev); + mana_ib_destroy_adapter(dev); mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq); xa_destroy(&dev->rq_to_qp_lookup_table); mana_gd_deregister_device(dev->gdma_dev); diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 032f926bf1ab..4f4343d14041 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -522,6 +522,57 @@ void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext) { } +int mana_ib_destroy_adapter(struct mana_ib_dev *dev) +{ + struct mana_ib_destroy_adapter_resp resp = {}; + struct mana_ib_destroy_adapter_req req = {}; + struct gdma_context *gc; + int err; + + gc = dev->gdma_dev->gdma_context; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_DESTROY_ADAPTER, sizeof(req), + sizeof(resp)); + req.adapter = dev->adapter_handle; + req.hdr.dev_id = gc->mana_ib.dev_id; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + + if (err) { + ibdev_err(&dev->ib_dev, "Failed to destroy adapter err %d", err); + return err; + } + + return 0; +} + +int mana_ib_create_adapter(struct mana_ib_dev *dev) +{ + struct mana_ib_create_adapter_resp resp = {}; + struct mana_ib_create_adapter_req req = {}; + struct gdma_context *gc; + int err; + + gc = dev->gdma_dev->gdma_context; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CREATE_ADAPTER, sizeof(req), + sizeof(resp)); + req.notify_eq_id = dev->fatal_err_eq->id; + req.hdr.dev_id = gc->mana_ib.dev_id; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + + if (err) { + ibdev_err(&dev->ib_dev, "Failed to create adapter err %d", + err); + return err; + } + + dev->adapter_handle = resp.adapter; + + return 0; +} + static void mana_ib_critical_event_handler(void *ctx, struct gdma_queue *queue, struct gdma_event *event) { diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index a5577c119def..4286caf0d67c 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -31,6 +31,7 @@ struct mana_ib_dev { struct ib_device ib_dev; struct gdma_dev *gdma_dev; struct gdma_queue *fatal_err_eq; + mana_handle_t adapter_handle; struct xarray rq_to_qp_lookup_table; }; @@ -94,6 +95,31 @@ struct mana_ib_rwq_ind_table { struct ib_rwq_ind_table ib_ind_table; }; +enum mana_ib_command_code { + MANA_IB_CREATE_ADAPTER = 0x30002, + MANA_IB_DESTROY_ADAPTER = 0x30003, +}; + +struct mana_ib_create_adapter_req { + struct gdma_req_hdr hdr; + u32 notify_eq_id; + u32 reserved; +}; /*HW Data */ + +struct mana_ib_create_adapter_resp { + struct gdma_resp_hdr hdr; + mana_handle_t adapter; +}; /* HW Data */ + +struct mana_ib_destroy_adapter_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; +}; /*HW Data */ + +struct mana_ib_destroy_adapter_resp { + struct gdma_resp_hdr hdr; +}; /* HW Data */ + int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, mana_handle_t *gdma_region); @@ -163,4 +189,8 @@ void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext); int mana_ib_create_error_eq(struct mana_ib_dev *mdev); +int mana_ib_create_adapter(struct mana_ib_dev *mdev); + +int mana_ib_destroy_adapter(struct mana_ib_dev *mdev); + #endif