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;