From patchwork Thu Nov 23 03:10:07 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: 168672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp190570vqx; Wed, 22 Nov 2023 19:10:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKK/7hQFLrcmIvMl/A7qMx5SKTDXLXCNDzrexil4E5360Juv1Cy7H9440+YucCg+yJg2pX X-Received: by 2002:a05:6870:cb47:b0:1f4:a122:6b02 with SMTP id oz7-20020a056870cb4700b001f4a1226b02mr5628066oab.45.1700709032042; Wed, 22 Nov 2023 19:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700709032; cv=none; d=google.com; s=arc-20160816; b=UPotcPczYmJoICrEb77C7YzXSVPN51JHTzNwGjSO3I3xfV/xIzHJ3oBbq94MKs3+6S AYxy7K0P2CXbkJNUoxISfHllBy4SxRUhyzQ5TI5eVMsyYuGwiJ6LOfZTz//1KYv0aK6Q qfgwtDbslrR6tzqU53y51yq2yE6TWWvc+TyLIqVxOM8+wwYtu0lxmZDF1kMlu5junnPt yI9m1uzH8URhSyyJbbL8oIRDSM4UrR5k3G5S3n4jUM0dWLo343CQlwoGoPvGQ779eCPb 2d0h0yYbvb+pBEpznG610jK5FRgNYYU2YQR+jv55LLPs+mpWuOUSl9Zv4O69FfWWJInb 8KhA== 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=fCIFn3GJFLoQMuBZv93aVsFVYpHzIMQe/aK7neaJcik=; fh=uNLUDd9eMsTSVEvEY0MjopzAsOI0Sfr5Wvsh0Zza+hA=; b=V9iO5Jub3pW7eUNvK19dhawA9TLAKKOmsWVhBXJtAHB7hojHBMEeoQSJWJGexag+XK mZFPZj9qnaQFZw1niyCL7ZkBywUJ67p5/WKFSQqjvuBLH8oi6Hea4rv5LsH6Xu/AMvvT pZHBzsK9vDF9A3p0qE1oK9sZIZNJiq4VWbfpG2qcyWj3LFGezFFb/r/d4dH8udDQaQZ9 XH0rVb6i32EAgnt3a2wPUoU3n32sfFtK9oIaDquaUE2FZ0RSxxPY1AB3xAdiXM7B/fES FBsVsV/2v1aT/P22wTCKRMIDkBcDrlRD1shMKY/iz/YqYuDRE81YcTLv190skG7GfG5e tJow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=mQtLgvoy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d15-20020a056a00198f00b00690258a9766si368989pfl.373.2023.11.22.19.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=mQtLgvoy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 6DBE9820AABF; Wed, 22 Nov 2023 19:10:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344392AbjKWDKQ (ORCPT + 99 others); Wed, 22 Nov 2023 22:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344375AbjKWDKP (ORCPT ); Wed, 22 Nov 2023 22:10:15 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C13EB1B6; Wed, 22 Nov 2023 19:10:21 -0800 (PST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 5FF6020B74C1; Wed, 22 Nov 2023 19:10:21 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FF6020B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1700709021; bh=fCIFn3GJFLoQMuBZv93aVsFVYpHzIMQe/aK7neaJcik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQtLgvoy45/c7jBbvKhY7meyZuxzwh7z+W6JYXNROSgyw5lfc9fVzbhOgdl5QKcpJ rUKVtz732kYqT9BvFWT06x5roQ6MSPNc1OOaSuBJd7XSAx9xQkRsjG3bIcCckwFgc/ OIld9g3MZDPZSl6OC2a2Oc+/1PIrGuS+qNQ7Q2sc= 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 1/4] RDMA/mana_ib: register RDMA device with GDMA Date: Wed, 22 Nov 2023 19:10:07 -0800 Message-Id: <1700709010-22042-2-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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 19:10:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783322674166954375 X-GMAIL-MSGID: 1783322674166954375 From: Long Li MANA hardware supports RC queue pairs over RoCE. Software needs to register with the RDMA management interface on the SoC to access this feature. Signed-off-by: Long Li --- drivers/infiniband/hw/mana/device.c | 25 ++++++++++++++++--- drivers/infiniband/hw/mana/main.c | 4 +-- drivers/infiniband/hw/mana/qp.c | 15 +++++------ .../net/ethernet/microsoft/mana/gdma_main.c | 5 ++++ include/net/mana/gdma.h | 4 +++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index d4541b8707e4..ee29ddf36cf3 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -68,7 +68,6 @@ static int mana_ib_probe(struct auxiliary_device *adev, ibdev_dbg(&dev->ib_dev, "mdev=%p id=%d num_ports=%d\n", mdev, mdev->dev_id.as_uint32, dev->ib_dev.phys_port_cnt); - dev->gdma_dev = mdev; dev->ib_dev.node_type = RDMA_NODE_IB_CA; /* @@ -78,16 +77,33 @@ static int mana_ib_probe(struct auxiliary_device *adev, dev->ib_dev.num_comp_vectors = 1; dev->ib_dev.dev.parent = mdev->gdma_context->dev; - ret = ib_register_device(&dev->ib_dev, "mana_%d", - mdev->gdma_context->dev); + ret = mana_gd_register_device(&mdev->gdma_context->mana_ib); + if (ret) { + ibdev_err(&dev->ib_dev, "Failed to register device, ret %d", + ret); + goto free_ib_device; + } + dev->gdma_dev = &mdev->gdma_context->mana_ib; + if (ret) { ib_dealloc_device(&dev->ib_dev); return ret; } + ret = ib_register_device(&dev->ib_dev, "mana_%d", + mdev->gdma_context->dev); + if (ret) + goto destroy_adapter; + dev_set_drvdata(&adev->dev, dev); return 0; + +destroy_adapter: + mana_gd_deregister_device(dev->gdma_dev); +free_ib_device: + ib_dealloc_device(&dev->ib_dev); + return ret; } static void mana_ib_remove(struct auxiliary_device *adev) @@ -95,6 +111,9 @@ static void mana_ib_remove(struct auxiliary_device *adev) struct mana_ib_dev *dev = dev_get_drvdata(&adev->dev); ib_unregister_device(&dev->ib_dev); + + mana_gd_deregister_device(dev->gdma_dev); + ib_dealloc_device(&dev->ib_dev); } diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 7be4c3adb4e2..53730306ed9b 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -8,7 +8,7 @@ void mana_ib_uncfg_vport(struct mana_ib_dev *dev, struct mana_ib_pd *pd, u32 port) { - struct gdma_dev *gd = dev->gdma_dev; + struct gdma_dev *gd = &dev->gdma_dev->gdma_context->mana; struct mana_port_context *mpc; struct net_device *ndev; struct mana_context *mc; @@ -31,7 +31,7 @@ void mana_ib_uncfg_vport(struct mana_ib_dev *dev, struct mana_ib_pd *pd, int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, u32 doorbell_id) { - struct gdma_dev *mdev = dev->gdma_dev; + struct gdma_dev *mdev = &dev->gdma_dev->gdma_context->mana; struct mana_port_context *mpc; struct mana_context *mc; struct net_device *ndev; diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c index 4b3b5b274e84..ae45d28eef5e 100644 --- a/drivers/infiniband/hw/mana/qp.c +++ b/drivers/infiniband/hw/mana/qp.c @@ -21,8 +21,8 @@ static int mana_ib_cfg_vport_steering(struct mana_ib_dev *dev, u32 req_buf_size; int i, err; - mdev = dev->gdma_dev; - gc = mdev->gdma_context; + gc = dev->gdma_dev->gdma_context; + mdev = &gc->mana; req_buf_size = sizeof(*req) + sizeof(mana_handle_t) * MANA_INDIRECT_TABLE_SIZE; @@ -102,20 +102,21 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, struct ib_rwq_ind_table *ind_tbl = attr->rwq_ind_tbl; struct mana_ib_create_qp_rss_resp resp = {}; struct mana_ib_create_qp_rss ucmd = {}; - struct gdma_dev *gd = mdev->gdma_dev; mana_handle_t *mana_ind_table; struct mana_port_context *mpc; + unsigned int ind_tbl_size; struct mana_context *mc; struct net_device *ndev; struct mana_ib_cq *cq; struct mana_ib_wq *wq; - unsigned int ind_tbl_size; + struct gdma_dev *gd; struct ib_cq *ibcq; struct ib_wq *ibwq; int i = 0; u32 port; int ret; + gd = &mdev->gdma_dev->gdma_context->mana; mc = gd->driver_data; if (!udata || udata->inlen < sizeof(ucmd)) @@ -266,8 +267,8 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, struct mana_ib_ucontext *mana_ucontext = rdma_udata_to_drv_context(udata, struct mana_ib_ucontext, ibucontext); + struct gdma_dev *gd = &mdev->gdma_dev->gdma_context->mana; struct mana_ib_create_qp_resp resp = {}; - struct gdma_dev *gd = mdev->gdma_dev; struct mana_ib_create_qp ucmd = {}; struct mana_obj_spec wq_spec = {}; struct mana_obj_spec cq_spec = {}; @@ -437,7 +438,7 @@ static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp, { struct mana_ib_dev *mdev = container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); - struct gdma_dev *gd = mdev->gdma_dev; + struct gdma_dev *gd = &mdev->gdma_dev->gdma_context->mana; struct mana_port_context *mpc; struct mana_context *mc; struct net_device *ndev; @@ -464,7 +465,7 @@ static int mana_ib_destroy_qp_raw(struct mana_ib_qp *qp, struct ib_udata *udata) { struct mana_ib_dev *mdev = container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); - struct gdma_dev *gd = mdev->gdma_dev; + struct gdma_dev *gd = &mdev->gdma_dev->gdma_context->mana; struct ib_pd *ibpd = qp->ibqp.pd; struct mana_port_context *mpc; struct mana_context *mc; diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 6367de0c2c2e..02e50ed632ee 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -158,6 +158,9 @@ static int mana_gd_detect_devices(struct pci_dev *pdev) if (dev_type == GDMA_DEVICE_MANA) { gc->mana.gdma_context = gc; gc->mana.dev_id = dev; + } else if (dev_type == GDMA_DEVICE_MANA_IB) { + gc->mana_ib.dev_id = dev; + gc->mana_ib.gdma_context = gc; } } @@ -971,6 +974,7 @@ int mana_gd_register_device(struct gdma_dev *gd) return 0; } +EXPORT_SYMBOL(mana_gd_register_device); int mana_gd_deregister_device(struct gdma_dev *gd) { @@ -1001,6 +1005,7 @@ int mana_gd_deregister_device(struct gdma_dev *gd) return err; } +EXPORT_SYMBOL(mana_gd_deregister_device); u32 mana_gd_wq_avail_space(struct gdma_queue *wq) { diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index 88b6ef7ce1a6..000f0d7670f7 100644 --- a/include/net/mana/gdma.h +++ b/include/net/mana/gdma.h @@ -66,6 +66,7 @@ enum { GDMA_DEVICE_NONE = 0, GDMA_DEVICE_HWC = 1, GDMA_DEVICE_MANA = 2, + GDMA_DEVICE_MANA_IB = 3, }; struct gdma_resource { @@ -387,6 +388,9 @@ struct gdma_context { /* Azure network adapter */ struct gdma_dev mana; + + /* Azure RDMA adapter */ + struct gdma_dev mana_ib; }; #define MAX_NUM_GDMA_DEVICES 4 From patchwork Thu Nov 23 03:10:08 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: 168675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp190841vqx; Wed, 22 Nov 2023 19:11:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9pEB3VvXUDfY5vlbhMTTub/zL2DIGoLx53QCq9+sxFQacabAiUH5ryKrEgheTVMuhX2T7 X-Received: by 2002:a17:903:2281:b0:1cf:6315:8698 with SMTP id b1-20020a170903228100b001cf63158698mr4430653plh.42.1700709074712; Wed, 22 Nov 2023 19:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700709074; cv=none; d=google.com; s=arc-20160816; b=K04U9+ZNdGlNjlzRzTF9HSBse0uO/oQBnujOj2jXkwPDTggmYXdz530IBxcouswd84 IhU6JCoIsllVZQ7HY9BPOVsF8Boc8PlWeapT0d5c7LY+z6twkdRfOhtDXdG3c1IRpSmg pynLPja00f0hBMDzFAKWWlOUAcSTE0nyccdL7fW8k8ZJpcK17s2uG/Rklkxq21u7+GZc tN7VyVrAo2DUl4H11Sb5844trRpVWYDpwSRTood6MFNOmhGyx8e9X6KtH906l9vO3BTe h2CFymxnrNqL1F2bcLXhQq7HyBVs2OllFGEWJsH4DOoqio31WRENLcIfgLsEMwRAGrTr 1X3g== 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=r7cg3LEpjXHMbs6ZkeOp+TbHsor32SEuIoyU0GKim6M=; fh=uNLUDd9eMsTSVEvEY0MjopzAsOI0Sfr5Wvsh0Zza+hA=; b=dWu5xcYNmOuvzBJsIn3OQu5/qSZ/AU5fmovj8K9YB8dkwaY1gstTolYWODqYs5jJ4g V109Hm454snep1AUQsXlWr1LC1Bp6LHN9PjqM3reOliyp/mdYqfq5y7f1bm7JXq8QuCs aJeR4Pfi5VpQO11GwmNbm3aHVxJLtf2F0FqAg6d53JVZ1OUE/J+JhUIREgGJFk9yiD39 0sNPBjblbCRpYYTQjiWLN6HQShP6megTExSujGRGY5tGflZcCRcKkF2goZaFexuGVCnA 9zxX386n/Kb0++xVCPsHZyJvHJlMNuy11wBJjB6AwrtQ+JExPHA+vQqZXnQOUmi41cZY etLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=IAgyp0qN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id je18-20020a170903265200b001b973681493si263344plb.16.2023.11.22.19.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:11:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=IAgyp0qN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 71CE7830D131; Wed, 22 Nov 2023 19:11:10 -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 S1344492AbjKWDKX (ORCPT + 99 others); Wed, 22 Nov 2023 22:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344415AbjKWDKR (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 AF9981BD; Wed, 22 Nov 2023 19:10:22 -0800 (PST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 4686620B74C2; Wed, 22 Nov 2023 19:10:22 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4686620B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1700709022; bh=r7cg3LEpjXHMbs6ZkeOp+TbHsor32SEuIoyU0GKim6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IAgyp0qN1iod/BhS49hE2zsD8h+laSPBD5LMs6IijdLD+X5XV8CiPE140ntBzG4qP +ZYcXIESwMwpA/uW0ICkwNNBT8kFXgt77cTwHzKnn/3SqJH9DRKsNV/eS7KOpva+oc 1m+xM+7fRFKUp/7Wl4a8bazqhMxFo8KnwLX1A2H0= 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 2/4] RDMA/mana_ib: create and process EQ events Date: Wed, 22 Nov 2023 19:10:08 -0800 Message-Id: <1700709010-22042-3-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:11:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783322718663508587 X-GMAIL-MSGID: 1783322718663508587 From: Long Li Before the software can create an RDMA adapter handle with SoC, it needs to create EQs for processing SoC events from RDMA device. Because MSI-X vectors are shared between MANA Ethernet device and RDMA device, this patch adds support to share EQs on MSI-X vectors and creates management EQ for RDMA device. Signed-off-by: Long Li --- drivers/infiniband/hw/mana/device.c | 13 ++ drivers/infiniband/hw/mana/main.c | 52 +++++++ drivers/infiniband/hw/mana/mana_ib.h | 4 + drivers/infiniband/hw/mana/qp.c | 15 ++ .../net/ethernet/microsoft/mana/gdma_main.c | 147 ++++++++++-------- drivers/net/ethernet/microsoft/mana/mana_en.c | 3 + include/net/mana/gdma.h | 14 +- 7 files changed, 180 insertions(+), 68 deletions(-) diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index ee29ddf36cf3..3da4763e1a0c 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -85,6 +85,14 @@ static int mana_ib_probe(struct auxiliary_device *adev, } dev->gdma_dev = &mdev->gdma_context->mana_ib; + xa_init(&dev->rq_to_qp_lookup_table); + + ret = mana_ib_create_error_eq(dev); + if (ret) { + ibdev_err(&dev->ib_dev, "Failed to allocate err eq"); + goto deregister_device; + } + if (ret) { ib_dealloc_device(&dev->ib_dev); return ret; @@ -100,6 +108,9 @@ 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); + xa_destroy(&dev->rq_to_qp_lookup_table); +deregister_device: mana_gd_deregister_device(dev->gdma_dev); free_ib_device: ib_dealloc_device(&dev->ib_dev); @@ -112,6 +123,8 @@ static void mana_ib_remove(struct auxiliary_device *adev) ib_unregister_device(&dev->ib_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); ib_dealloc_device(&dev->ib_dev); diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 53730306ed9b..032f926bf1ab 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -521,3 +521,55 @@ int mana_ib_query_gid(struct ib_device *ibdev, u32 port, int index, void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext) { } + +static void mana_ib_critical_event_handler(void *ctx, struct gdma_queue *queue, + struct gdma_event *event) +{ + struct mana_ib_dev *dev = (struct mana_ib_dev *)ctx; + struct ib_event mib_event; + struct mana_ib_qp *qp; + u64 rq_id; + + switch (event->type) { + case GDMA_EQE_SOC_EVENT_NOTIFICATION: + rq_id = event->details[0] & 0xFFFFFF; + qp = xa_load(&dev->rq_to_qp_lookup_table, rq_id); + mib_event.event = IB_EVENT_QP_FATAL; + mib_event.device = &dev->ib_dev; + if (qp && qp->ibqp.event_handler) + qp->ibqp.event_handler(&mib_event, qp->ibqp.qp_context); + else + ibdev_dbg(&dev->ib_dev, "found no qp or event handler"); + ibdev_dbg(&dev->ib_dev, "Received critical notification"); + break; + default: + ibdev_dbg(&dev->ib_dev, "Received unsolicited evt %d", + event->type); + } +} + +int mana_ib_create_error_eq(struct mana_ib_dev *dev) +{ + struct gdma_queue_spec spec = {}; + int err; + + spec.type = GDMA_EQ; + spec.monitor_avl_buf = false; + spec.queue_size = EQ_SIZE; + spec.eq.callback = mana_ib_critical_event_handler; + spec.eq.context = dev; + spec.eq.log2_throttle_limit = LOG2_EQ_THROTTLE; + spec.eq.msix_allocated = true; + spec.eq.msix_index = 0; + spec.doorbell = dev->gdma_dev->doorbell; + spec.pdid = dev->gdma_dev->pdid; + + err = mana_gd_create_mana_eq(dev->gdma_dev, &spec, + &dev->fatal_err_eq); + if (err) + return err; + + dev->fatal_err_eq->eq.disable_needed = true; + + return 0; +} diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index 502cc8672eef..a5577c119def 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -30,6 +30,8 @@ struct mana_ib_dev { struct ib_device ib_dev; struct gdma_dev *gdma_dev; + struct gdma_queue *fatal_err_eq; + struct xarray rq_to_qp_lookup_table; }; struct mana_ib_wq { @@ -159,4 +161,6 @@ int mana_ib_query_gid(struct ib_device *ibdev, u32 port, int index, void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext); +int mana_ib_create_error_eq(struct mana_ib_dev *mdev); + #endif diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c index ae45d28eef5e..7ff9c8364551 100644 --- a/drivers/infiniband/hw/mana/qp.c +++ b/drivers/infiniband/hw/mana/qp.c @@ -211,6 +211,11 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, wq->id = wq_spec.queue_index; cq->id = cq_spec.queue_index; + ret = xa_err(xa_store(&mdev->rq_to_qp_lookup_table, + wq->id, qp, GFP_KERNEL)); + if (ret) + goto fail; + ibdev_dbg(&mdev->ib_dev, "ret %d rx_object 0x%llx wq id %llu cq id %llu\n", ret, wq->rx_object, wq->id, cq->id); @@ -246,6 +251,7 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, while (i-- > 0) { ibwq = ind_tbl->ind_tbl[i]; wq = container_of(ibwq, struct mana_ib_wq, ibwq); + xa_erase(&mdev->rq_to_qp_lookup_table, wq->id); mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object); } @@ -372,6 +378,11 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, qp->sq_id = wq_spec.queue_index; send_cq->id = cq_spec.queue_index; + err = xa_err(xa_store(&mdev->rq_to_qp_lookup_table, + qp->sq_id, qp, GFP_KERNEL)); + if (err) + goto err_destroy_wq_obj; + ibdev_dbg(&mdev->ib_dev, "ret %d qp->tx_object 0x%llx sq id %llu cq id %llu\n", err, qp->tx_object, qp->sq_id, send_cq->id); @@ -388,9 +399,11 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, goto err_destroy_wq_obj; } + return 0; err_destroy_wq_obj: + xa_erase(&mdev->rq_to_qp_lookup_table, qp->sq_id); mana_destroy_wq_obj(mpc, GDMA_SQ, qp->tx_object); err_destroy_dma_region: @@ -455,6 +468,7 @@ static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp, wq = container_of(ibwq, struct mana_ib_wq, ibwq); ibdev_dbg(&mdev->ib_dev, "destroying wq->rx_object %llu\n", wq->rx_object); + xa_erase(&mdev->rq_to_qp_lookup_table, wq->id); mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object); } @@ -477,6 +491,7 @@ static int mana_ib_destroy_qp_raw(struct mana_ib_qp *qp, struct ib_udata *udata) mpc = netdev_priv(ndev); pd = container_of(ibpd, struct mana_ib_pd, ibpd); + xa_erase(&mdev->rq_to_qp_lookup_table, qp->sq_id); mana_destroy_wq_obj(mpc, GDMA_SQ, qp->tx_object); if (qp->sq_umem) { diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 02e50ed632ee..f368056d0b0b 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -204,7 +204,8 @@ void mana_gd_free_memory(struct gdma_mem_info *gmi) } static int mana_gd_create_hw_eq(struct gdma_context *gc, - struct gdma_queue *queue) + struct gdma_queue *queue, + u32 doorbell, u32 pdid) { struct gdma_create_queue_resp resp = {}; struct gdma_create_queue_req req = {}; @@ -218,8 +219,8 @@ static int mana_gd_create_hw_eq(struct gdma_context *gc, req.hdr.dev_id = queue->gdma_dev->dev_id; req.type = queue->type; - req.pdid = queue->gdma_dev->pdid; - req.doolbell_id = queue->gdma_dev->doorbell; + req.pdid = pdid; + req.doolbell_id = doorbell; req.gdma_region = queue->mem_info.dma_region_handle; req.queue_size = queue->queue_size; req.log2_throttle_limit = queue->eq.log2_throttle_limit; @@ -393,53 +394,51 @@ static void mana_gd_process_eqe(struct gdma_queue *eq) } } -static void mana_gd_process_eq_events(void *arg) +static void mana_gd_process_eq_events(struct list_head *eq_list) { u32 owner_bits, new_bits, old_bits; union gdma_eqe_info eqe_info; struct gdma_eqe *eq_eqe_ptr; - struct gdma_queue *eq = arg; struct gdma_context *gc; + struct gdma_queue *eq; struct gdma_eqe *eqe; u32 head, num_eqe; int i; - gc = eq->gdma_dev->gdma_context; - - num_eqe = eq->queue_size / GDMA_EQE_SIZE; - eq_eqe_ptr = eq->queue_mem_ptr; - - /* Process up to 5 EQEs at a time, and update the HW head. */ - for (i = 0; i < 5; i++) { - eqe = &eq_eqe_ptr[eq->head % num_eqe]; - eqe_info.as_uint32 = eqe->eqe_info; - owner_bits = eqe_info.owner_bits; - - old_bits = (eq->head / num_eqe - 1) & GDMA_EQE_OWNER_MASK; - /* No more entries */ - if (owner_bits == old_bits) - break; - - new_bits = (eq->head / num_eqe) & GDMA_EQE_OWNER_MASK; - if (owner_bits != new_bits) { - dev_err(gc->dev, "EQ %d: overflow detected\n", eq->id); - break; + list_for_each_entry_rcu(eq, eq_list, entry) { + gc = eq->gdma_dev->gdma_context; + + num_eqe = eq->queue_size / GDMA_EQE_SIZE; + eq_eqe_ptr = eq->queue_mem_ptr; + /* Process up to 5 EQEs at a time, and update the HW head. */ + for (i = 0; i < 5; i++) { + eqe = &eq_eqe_ptr[eq->head % num_eqe]; + eqe_info.as_uint32 = eqe->eqe_info; + owner_bits = eqe_info.owner_bits; + + old_bits = (eq->head / num_eqe - 1) & GDMA_EQE_OWNER_MASK; + /* No more entries */ + if (owner_bits == old_bits) + break; + + new_bits = (eq->head / num_eqe) & GDMA_EQE_OWNER_MASK; + if (owner_bits != new_bits) { + dev_err(gc->dev, "EQ %d: overflow detected\n", + eq->id); + break; + } + /* Per GDMA spec, rmb is necessary after checking owner_bits, before + * reading eqe. + */ + rmb(); + mana_gd_process_eqe(eq); + eq->head++; } - /* Per GDMA spec, rmb is necessary after checking owner_bits, before - * reading eqe. - */ - rmb(); - - mana_gd_process_eqe(eq); - - eq->head++; + head = eq->head % (num_eqe << GDMA_EQE_OWNER_BITS); + mana_gd_ring_doorbell(gc, eq->gdma_dev->doorbell, eq->type, + eq->id, head, SET_ARM_BIT); } - - head = eq->head % (num_eqe << GDMA_EQE_OWNER_BITS); - - mana_gd_ring_doorbell(gc, eq->gdma_dev->doorbell, eq->type, eq->id, - head, SET_ARM_BIT); } static int mana_gd_register_irq(struct gdma_queue *queue, @@ -457,45 +456,48 @@ static int mana_gd_register_irq(struct gdma_queue *queue, gc = gd->gdma_context; r = &gc->msix_resource; dev = gc->dev; + msi_index = spec->eq.msix_index; spin_lock_irqsave(&r->lock, flags); - msi_index = find_first_zero_bit(r->map, r->size); - if (msi_index >= r->size || msi_index >= gc->num_msix_usable) { - err = -ENOSPC; - } else { - bitmap_set(r->map, msi_index, 1); - queue->eq.msix_index = msi_index; - } - - spin_unlock_irqrestore(&r->lock, flags); + if (!spec->eq.msix_allocated) { + msi_index = find_first_zero_bit(r->map, r->size); - if (err) { - dev_err(dev, "Register IRQ err:%d, msi:%u rsize:%u, nMSI:%u", - err, msi_index, r->size, gc->num_msix_usable); + if (msi_index >= r->size || + msi_index >= gc->num_msix_usable) + err = -ENOSPC; + else + bitmap_set(r->map, msi_index, 1); - return err; + if (err) { + dev_err(dev, "Register IRQ err:%d, msi:%u rsize:%u, nMSI:%u", + err, msi_index, r->size, gc->num_msix_usable); + goto out; + } } + queue->eq.msix_index = msi_index; gic = &gc->irq_contexts[msi_index]; - WARN_ON(gic->handler || gic->arg); - - gic->arg = queue; + list_add_rcu(&queue->entry, &gic->eq_list); gic->handler = mana_gd_process_eq_events; - return 0; +out: + spin_unlock_irqrestore(&r->lock, flags); + return err; } -static void mana_gd_deregiser_irq(struct gdma_queue *queue) +static void mana_gd_deregister_irq(struct gdma_queue *queue) { struct gdma_dev *gd = queue->gdma_dev; struct gdma_irq_context *gic; struct gdma_context *gc; struct gdma_resource *r; unsigned int msix_index; + struct gdma_queue *eq; unsigned long flags; + struct list_head *p; gc = gd->gdma_context; r = &gc->msix_resource; @@ -505,14 +507,24 @@ static void mana_gd_deregiser_irq(struct gdma_queue *queue) if (WARN_ON(msix_index >= gc->num_msix_usable)) return; + spin_lock_irqsave(&r->lock, flags); + gic = &gc->irq_contexts[msix_index]; - gic->handler = NULL; - gic->arg = NULL; + list_for_each_rcu(p, &gic->eq_list) { + eq = list_entry(p, struct gdma_queue, entry); + if (queue == eq) { + list_del(&eq->entry); + synchronize_rcu(); + break; + } + } - spin_lock_irqsave(&r->lock, flags); - bitmap_clear(r->map, msix_index, 1); - spin_unlock_irqrestore(&r->lock, flags); + if (list_empty(&gic->eq_list)) { + gic->handler = NULL; + bitmap_clear(r->map, msix_index, 1); + } + spin_unlock_irqrestore(&r->lock, flags); queue->eq.msix_index = INVALID_PCI_MSIX_INDEX; } @@ -575,7 +587,7 @@ static void mana_gd_destroy_eq(struct gdma_context *gc, bool flush_evenets, dev_warn(gc->dev, "Failed to flush EQ: %d\n", err); } - mana_gd_deregiser_irq(queue); + mana_gd_deregister_irq(queue); if (queue->eq.disable_needed) mana_gd_disable_queue(queue); @@ -590,7 +602,7 @@ static int mana_gd_create_eq(struct gdma_dev *gd, u32 log2_num_entries; int err; - queue->eq.msix_index = INVALID_PCI_MSIX_INDEX; + queue->eq.msix_index = spec->eq.msix_index; log2_num_entries = ilog2(queue->queue_size / GDMA_EQE_SIZE); @@ -612,7 +624,8 @@ static int mana_gd_create_eq(struct gdma_dev *gd, queue->eq.log2_throttle_limit = spec->eq.log2_throttle_limit ?: 1; if (create_hwq) { - err = mana_gd_create_hw_eq(gc, queue); + err = mana_gd_create_hw_eq(gc, queue, + spec->doorbell, spec->pdid); if (err) goto out; @@ -822,6 +835,7 @@ int mana_gd_create_mana_eq(struct gdma_dev *gd, kfree(queue); return err; } +EXPORT_SYMBOL(mana_gd_create_mana_eq); int mana_gd_create_mana_wq_cq(struct gdma_dev *gd, const struct gdma_queue_spec *spec, @@ -898,6 +912,7 @@ void mana_gd_destroy_queue(struct gdma_context *gc, struct gdma_queue *queue) mana_gd_free_memory(gmi); kfree(queue); } +EXPORT_SYMBOL(mana_gd_destroy_queue); int mana_gd_verify_vf_version(struct pci_dev *pdev) { @@ -1224,7 +1239,7 @@ static irqreturn_t mana_gd_intr(int irq, void *arg) struct gdma_irq_context *gic = arg; if (gic->handler) - gic->handler(gic->arg); + gic->handler(&gic->eq_list); return IRQ_HANDLED; } @@ -1277,7 +1292,7 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev) for (i = 0; i < nvec; i++) { gic = &gc->irq_contexts[i]; gic->handler = NULL; - gic->arg = NULL; + INIT_LIST_HEAD(&gic->eq_list); if (!i) snprintf(gic->name, MANA_IRQ_NAME_SZ, "mana_hwc@pci:%s", diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index fc3d2903a80f..abf63f405940 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1242,6 +1242,9 @@ static int mana_create_eq(struct mana_context *ac) spec.eq.callback = NULL; spec.eq.context = ac->eqs; spec.eq.log2_throttle_limit = LOG2_EQ_THROTTLE; + spec.eq.msix_allocated = false; + spec.doorbell = gd->doorbell; + spec.pdid = gd->pdid; for (i = 0; i < gc->max_num_queues; i++) { err = mana_gd_create_mana_eq(gd, &spec, &ac->eqs[i].eq); diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index 000f0d7670f7..e32c75639557 100644 --- a/include/net/mana/gdma.h +++ b/include/net/mana/gdma.h @@ -60,6 +60,11 @@ enum gdma_eqe_type { GDMA_EQE_HWC_INIT_DONE = 131, GDMA_EQE_HWC_SOC_RECONFIG = 132, GDMA_EQE_HWC_SOC_RECONFIG_DATA = 133, + + /* RDMA SOC Events */ + GDMA_EQE_SOC_EVENT_NOTIFICATION = 176, + GDMA_EQE_SOC_EVENT_TEST = 177, + }; enum { @@ -294,6 +299,7 @@ struct gdma_queue { u32 head; u32 tail; + struct list_head entry; /* Extra fields specific to EQ/CQ. */ union { @@ -321,6 +327,8 @@ struct gdma_queue_spec { enum gdma_queue_type type; bool monitor_avl_buf; unsigned int queue_size; + u32 doorbell; + u32 pdid; /* Extra fields specific to EQ/CQ. */ union { @@ -329,6 +337,8 @@ struct gdma_queue_spec { void *context; unsigned long log2_throttle_limit; + bool msix_allocated; + unsigned int msix_index; } eq; struct { @@ -344,8 +354,8 @@ struct gdma_queue_spec { #define MANA_IRQ_NAME_SZ 32 struct gdma_irq_context { - void (*handler)(void *arg); - void *arg; + void (*handler)(struct list_head *arg); + struct list_head eq_list; char name[MANA_IRQ_NAME_SZ]; }; 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 From patchwork Thu Nov 23 03:10:10 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: 168674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp190792vqx; Wed, 22 Nov 2023 19:11:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7jS+Yfkf2gHTd8HE2aycGzmf2WJV+adkKkWTJOWAhsG0RS8zJde8b+ReT5swux9t5mgfT X-Received: by 2002:a05:6a21:6d82:b0:187:152d:c1e2 with SMTP id wl2-20020a056a216d8200b00187152dc1e2mr4719651pzb.46.1700709065966; Wed, 22 Nov 2023 19:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700709065; cv=none; d=google.com; s=arc-20160816; b=GSy623cy+Ws+ARbHmpUItT83spr39TQPFAhNusMQVGu9kHetK3FRFEYmwKXXu8+afn tQ8/ZUUjtkoX8yOp1ONceoIOhyGZMYU4jxtjPbwvq8V3dQVhBv9QjS8lewF3PkXBmYkU GTiHp/4aRRaXFWUK7CIhSi/jPgySznU7YvvoNGuhPSABT1lYkFFV4tyOuF3OkYxga2r+ lMNlicS8z4WJepeWgrNprK0r2roF0Shcn96dOCKA5w2Dv5hH8ccyyfCpZnGzQMRKD7D6 ELCmOKubX86sAw7EA6NPxo555Hz8i0aeIMOOg2B5KJsH9hGpxjUuqVVIzkXyPc01XtpT yZMw== 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=zge+TQFwXGx9zNXcHD09zsfe5McbZNNhO/IEkAckKVM=; fh=uNLUDd9eMsTSVEvEY0MjopzAsOI0Sfr5Wvsh0Zza+hA=; b=0tmY8RDSBnDSOEQty1n60ItmVJSEWj/JsKmBB6PHOulqHjRpnjdVru3qqRayPfgiQ2 1RQhruB/gynm73HBZ130g/kjixUNZqFDjKglA6pB+fZvm+rcKwPbseG0lbMkSN8IJTuS +1jaYtjl+hfV/Kwm5MEr5eeq1iTTAgALEfIM0bG/AhdP1BtcWi4cW+6+Rv3tumJ9GdiA lrrxYj8ZqErQkHqj6VEnNb6eHQbH+HmdaywuKoLuE4rb68iVyutmBPWjuc73eIE9O3Js T+WOWtod1NMRsnozJ3500iqPi5eFM3YmuUoAbFvigLXDSzJ2gpxNVewf5Q0Ar8tgEnUh HhVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=iAFN63n9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b6-20020a170902ed0600b001cf665a0922si248437pld.468.2023.11.22.19.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=iAFN63n9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 31C1F807C763; Wed, 22 Nov 2023 19:11:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344577AbjKWDK2 (ORCPT + 99 others); Wed, 22 Nov 2023 22:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344449AbjKWDKV (ORCPT ); Wed, 22 Nov 2023 22:10:21 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 57A23D48; Wed, 22 Nov 2023 19:10:24 -0800 (PST) Received: by linux.microsoft.com (Postfix, from userid 1004) id E4D7020B74C4; Wed, 22 Nov 2023 19:10:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E4D7020B74C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1700709023; bh=zge+TQFwXGx9zNXcHD09zsfe5McbZNNhO/IEkAckKVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAFN63n9SE1RgVIab3JOrK9ll9qHaKIFkOz8tMFxWp5qDGZ71cWZNOmRwkCZtwU4p g4xt8dsaR53C75JBszyExnLp4fmqRQaVt18Gou3A5SMDCQu6VUbjtTO/rvF9foc92P qwEYH83jEIwPXG5OOQkt3vDC26G3laTw4DSzG0SU= 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 4/4] RDMA/mana_ib: query device capabilities Date: Wed, 22 Nov 2023 19:10:10 -0800 Message-Id: <1700709010-22042-5-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.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Wed, 22 Nov 2023 19:11:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783322709676692128 X-GMAIL-MSGID: 1783322709676692128 From: Long Li With RDMA device handle created, use it to query on hardware capabilities and cache this information for future query requests to the driver. Signed-off-by: Long Li --- drivers/infiniband/hw/mana/cq.c | 2 +- drivers/infiniband/hw/mana/device.c | 6 +++ drivers/infiniband/hw/mana/main.c | 59 +++++++++++++++++++++++----- drivers/infiniband/hw/mana/mana_ib.h | 51 ++++++++++++++++++++++++ drivers/infiniband/hw/mana/qp.c | 6 ++- include/net/mana/gdma.h | 1 + 6 files changed, 112 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c index d141cab8a1e6..71064f17c235 100644 --- a/drivers/infiniband/hw/mana/cq.c +++ b/drivers/infiniband/hw/mana/cq.c @@ -26,7 +26,7 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, return err; } - if (attr->cqe > MAX_SEND_BUFFERS_PER_QUEUE) { + if (attr->cqe > mdev->adapter_caps.max_requester_sq_size) { ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr->cqe); return -EINVAL; } diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index 5e5aa75230c2..06f53df072bb 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -99,6 +99,12 @@ static int mana_ib_probe(struct auxiliary_device *adev, goto free_error_eq; } + ret = mana_ib_query_adapter_caps(dev); + if (ret) { + ibdev_dbg(&dev->ib_dev, "Failed to get device caps"); + goto destroy_adapter; + } + ret = ib_register_device(&dev->ib_dev, "mana_%d", mdev->gdma_context->dev); if (ret) diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 4f4343d14041..bf27fa395a67 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -486,18 +486,14 @@ int mana_ib_get_port_immutable(struct ib_device *ibdev, u32 port_num, int mana_ib_query_device(struct ib_device *ibdev, struct ib_device_attr *props, struct ib_udata *uhw) { - props->max_qp = MANA_MAX_NUM_QUEUES; - props->max_qp_wr = MAX_SEND_BUFFERS_PER_QUEUE; - - /* - * max_cqe could be potentially much bigger. - * As this version of driver only support RAW QP, set it to the same - * value as max_qp_wr - */ - props->max_cqe = MAX_SEND_BUFFERS_PER_QUEUE; + struct mana_ib_dev *dev = container_of(ibdev, + struct mana_ib_dev, ib_dev); + props->max_qp = dev->adapter_caps.max_qp_count; + props->max_qp_wr = dev->adapter_caps.max_requester_sq_size; + props->max_cqe = dev->adapter_caps.max_requester_sq_size; + props->max_mr = dev->adapter_caps.max_mr_count; props->max_mr_size = MANA_IB_MAX_MR_SIZE; - props->max_mr = MANA_IB_MAX_MR; props->max_send_sge = MAX_TX_WQE_SGL_ENTRIES; props->max_recv_sge = MAX_RX_WQE_SGL_ENTRIES; @@ -624,3 +620,46 @@ int mana_ib_create_error_eq(struct mana_ib_dev *dev) return 0; } + +int mana_ib_query_adapter_caps(struct mana_ib_dev *dev) +{ + struct mana_ib_query_adapter_caps_resp resp = {}; + struct mana_ib_query_adapter_caps_req req = {}; + struct mana_ib_adapter_caps *caps = &dev->adapter_caps; + int err; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_GET_ADAPTER_CAP, sizeof(req), + sizeof(resp)); + req.hdr.resp.msg_version = GDMA_MESSAGE_V3; + req.hdr.dev_id = dev->gdma_dev->dev_id; + + err = mana_gd_send_request(dev->gdma_dev->gdma_context, sizeof(req), + &req, sizeof(resp), &resp); + + if (err) { + ibdev_err(&dev->ib_dev, + "Failed to query adapter caps err %d", err); + return err; + } + + caps->max_sq_id = resp.max_sq_id; + caps->max_rq_id = resp.max_rq_id; + caps->max_cq_id = resp.max_cq_id; + caps->max_qp_count = resp.max_qp_count; + caps->max_cq_count = resp.max_cq_count; + caps->max_mr_count = resp.max_mr_count; + caps->max_pd_count = resp.max_pd_count; + caps->max_inbound_read_limit = resp.max_inbound_read_limit; + caps->max_outbound_read_limit = resp.max_outbound_read_limit; + caps->mw_count = resp.mw_count; + caps->max_srq_count = resp.max_srq_count; + caps->max_requester_sq_size = resp.max_requester_sq_size; + caps->max_responder_sq_size = resp.max_responder_sq_size; + caps->max_requester_rq_size = resp.max_requester_rq_size; + caps->max_responder_rq_size = resp.max_responder_rq_size; + caps->max_inline_data_size = resp.max_inline_data_size; + caps->max_send_wqe_size = MAX_TX_WQE_SGL_ENTRIES; + caps->max_recv_wqe_size = MAX_RX_WQE_SGL_ENTRIES; + + return 0; +} diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index 4286caf0d67c..d7a56b075fbc 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -27,11 +27,33 @@ */ #define MANA_IB_MAX_MR 0xFFFFFFu +struct mana_ib_adapter_caps { + u32 max_sq_id; + u32 max_rq_id; + u32 max_cq_id; + u32 max_qp_count; + u32 max_cq_count; + u32 max_mr_count; + u32 max_pd_count; + u32 max_inbound_read_limit; + u32 max_outbound_read_limit; + u32 mw_count; + u32 max_srq_count; + u32 max_requester_sq_size; + u32 max_responder_sq_size; + u32 max_requester_rq_size; + u32 max_responder_rq_size; + u32 max_send_wqe_size; + u32 max_recv_wqe_size; + u32 max_inline_data_size; +}; + 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 mana_ib_adapter_caps adapter_caps; struct xarray rq_to_qp_lookup_table; }; @@ -96,6 +118,7 @@ struct mana_ib_rwq_ind_table { }; enum mana_ib_command_code { + MANA_IB_GET_ADAPTER_CAP = 0x30001, MANA_IB_CREATE_ADAPTER = 0x30002, MANA_IB_DESTROY_ADAPTER = 0x30003, }; @@ -120,6 +143,32 @@ struct mana_ib_destroy_adapter_resp { struct gdma_resp_hdr hdr; }; /* HW Data */ +struct mana_ib_query_adapter_caps_req { + struct gdma_req_hdr hdr; +}; /*HW Data */ + +struct mana_ib_query_adapter_caps_resp { + struct gdma_resp_hdr hdr; + u32 max_sq_id; + u32 max_rq_id; + u32 max_cq_id; + u32 max_qp_count; + u32 max_cq_count; + u32 max_mr_count; + u32 max_pd_count; + u32 max_inbound_read_limit; + u32 max_outbound_read_limit; + u32 mw_count; + u32 max_srq_count; + u32 max_requester_sq_size; + u32 max_responder_sq_size; + u32 max_requester_rq_size; + u32 max_responder_rq_size; + u32 max_send_wqe_size; + u32 max_recv_wqe_size; + u32 max_inline_data_size; +}; /* HW Data */ + int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, mana_handle_t *gdma_region); @@ -193,4 +242,6 @@ int mana_ib_create_adapter(struct mana_ib_dev *mdev); int mana_ib_destroy_adapter(struct mana_ib_dev *mdev); +int mana_ib_query_adapter_caps(struct mana_ib_dev *mdev); + #endif diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c index 7ff9c8364551..7211e93d999c 100644 --- a/drivers/infiniband/hw/mana/qp.c +++ b/drivers/infiniband/hw/mana/qp.c @@ -130,7 +130,8 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, return ret; } - if (attr->cap.max_recv_wr > MAX_SEND_BUFFERS_PER_QUEUE) { + if (attr->cap.max_recv_wr > + mdev->adapter_caps.max_requester_sq_size) { ibdev_dbg(&mdev->ib_dev, "Requested max_recv_wr %d exceeding limit\n", attr->cap.max_recv_wr); @@ -302,7 +303,8 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, if (port < 1 || port > mc->num_ports) return -EINVAL; - if (attr->cap.max_send_wr > MAX_SEND_BUFFERS_PER_QUEUE) { + if (attr->cap.max_send_wr > + mdev->adapter_caps.max_requester_sq_size) { ibdev_dbg(&mdev->ib_dev, "Requested max_send_wr %d exceeding limit\n", attr->cap.max_send_wr); diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index e32c75639557..c1850ec7faae 100644 --- a/include/net/mana/gdma.h +++ b/include/net/mana/gdma.h @@ -155,6 +155,7 @@ struct gdma_general_req { #define GDMA_MESSAGE_V1 1 #define GDMA_MESSAGE_V2 2 +#define GDMA_MESSAGE_V3 3 struct gdma_general_resp { struct gdma_resp_hdr hdr;