Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp407070lqh; Tue, 7 May 2024 02:54:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVllQVizop22w2MHeoCB2ZZnypgRJy7S6gIx57Pmc7QIu8XcDBlUBIFQAlKfCDSE00QloZ6GT2NjUL6wchhFrP3An2jxNnnHi8PJz70Gg== X-Google-Smtp-Source: AGHT+IGDKOwSkE3EqMsGBfApUbyANwuFqrcmd6j0/7o40wpceJQk92/tKgqIDN0L4zS45E0YwGZo X-Received: by 2002:a05:6a20:3cac:b0:1ac:c8dc:3e5e with SMTP id b44-20020a056a203cac00b001acc8dc3e5emr15902011pzj.24.1715075688267; Tue, 07 May 2024 02:54:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715075688; cv=pass; d=google.com; s=arc-20160816; b=VWaoq4R8vkh46C0/IYD/70Jbqq2Xo87AI5njevR1ANehsMmVu6Ze3lIb19ss8vIoro aRtIw+tcg0apWGsVVnfo8Kba1MB9uvscXH2jCaY45dE5z8s7txLLB1J2zbl8o5PJX9U0 GYYaGMyMc/H3MbDqedtc9ct4g5IiEkFRKluumRr4CXpXDePbCB2z12/yvw2lyamSIg/6 6WSIHS4SFzQMmafQTbmANwqJDX/crMQCO8ED8M7toUwLZZYjzUslIjO2OXuOFKW0l4AR sKnCfVDgbdbF1Q3rZguD6xhhWfsHH/TZSp268yS5Ce75uI3bmfRinGMKdVQ3LmxY+7RD 71mA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=HgZFHhJlwM0NqIiFtpKskjvYc629noqEAZv1L4k/RxU=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=S7eH4xXV7+dCsHj77WDnj8EitIO9t/Wi8FBIYKV0qGY3m2PWf0jIMEQoYceIySOiO1 o7ZW+dhrkOMf1ju8Rk/gRGUMBzTNLsU32C22z7lR8WgN+gNI0sWakTZ2L/uIvHI+Wdkf ea514Lu/R6CJIRWf0LUpeXluw4/e3Ehk0soUnZnqO4pOBWjjdW6hEB591l7mxSWh3zH5 38u2G9yDN67m2PTlFbPdC4k9Bc3rgfKinX1XmJ4BMhzzZ53aNmZ4hxfCgGs7QhLGxHiN UFlqaWzrN2WnA6lcQhwAqo9RnbtF/GdwpUShE+112QJwJYBj4mT2kJPU2YyMFQHxS72b dwWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=MLMJRB2o; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-171036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ko19-20020a056a00461300b006f45c3d4357si6414193pfb.112.2024.05.07.02.54.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=MLMJRB2o; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-171036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3DE62280CFC for ; Tue, 7 May 2024 09:54:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EACA150997; Tue, 7 May 2024 09:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="MLMJRB2o" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E03014D6EB; Tue, 7 May 2024 09:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715075610; cv=none; b=OTdNh7UWXPpSIUdyJ87lW3b5NclX6LRXsXUryZgvjdVOP5pyPejugYiF2uLIlslRbzfdjZaRk8iAXqFW3xxEnGG6oEmiHYCBXZN4XC714lSHY8SW+PTuxy+ybkTFKBt93HhIWHNr5K06qEtpi6US6tA7OTtUqBGCb3TDtADWMeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715075610; c=relaxed/simple; bh=4qkWqM/PRjPINX7Cp0H2sO1jItmV8+Exr95ZhIACmEc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=uctFLVQpoSf5yjAH6SE06JJAzFftB6Hc/D9woiRcDQUFfg4wASJ452jNqCWedlft6RQp+hFr8Kgoif4foBtnGzAY5sBt0bo+iBEEL/aOOZ60xFZ654YaMCNMDjoDxOsEp6JNeK585avfAx4RLBgmsZbXpdrn2GAk9zJFjjtZN+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=MLMJRB2o; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id D932420B2C84; Tue, 7 May 2024 02:53:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D932420B2C84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715075600; bh=HgZFHhJlwM0NqIiFtpKskjvYc629noqEAZv1L4k/RxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLMJRB2oyIHypJ6QEITmvDLsaJtjhg9gQae3pJHANHK1sCHyq6XJEYHQHLdoCy7Z5 QfDyaBBpADtOjccaNLaumc8BD0asGe9MWAJJaYgmVf0/544Gvktu0S4UJ/CbBkt6Co SPaccWLz2gVbfFMCZ3TQOj2BI0WtVVVgkN2cX1Ao= From: Konstantin Taranov To: kotaranov@microsoft.com, sharmaajay@microsoft.com, longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH rdma-next 1/3] RDMA/mana_ib: Create and destroy RC QP Date: Tue, 7 May 2024 02:53:13 -0700 Message-Id: <1715075595-24470-2-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1715075595-24470-1-git-send-email-kotaranov@linux.microsoft.com> References: <1715075595-24470-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Konstantin Taranov Implement HW requests to create and destroy an RC QP. An RC QP may have 5 queues. Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/main.c | 59 ++++++++++++++++++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 58 ++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 2a41135..6bd6072 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -888,3 +888,62 @@ int mana_ib_gd_destroy_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq) return 0; } + +int mana_ib_gd_create_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp, + struct ib_qp_init_attr *attr, u32 doorbell, u64 flags) +{ + struct mana_ib_cq *send_cq = container_of(qp->ibqp.send_cq, struct mana_ib_cq, ibcq); + struct mana_ib_cq *recv_cq = container_of(qp->ibqp.recv_cq, struct mana_ib_cq, ibcq); + struct mana_ib_pd *pd = container_of(qp->ibqp.pd, struct mana_ib_pd, ibpd); + struct gdma_context *gc = mdev_to_gc(mdev); + struct mana_rnic_create_qp_resp resp = {}; + struct mana_rnic_create_qp_req req = {}; + int err, i; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CREATE_RC_QP, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + req.pd_handle = pd->pd_handle; + req.send_cq_handle = send_cq->cq_handle; + req.recv_cq_handle = recv_cq->cq_handle; + for (i = 0; i < MANA_RC_QUEUE_TYPE_MAX; i++) + req.dma_region[i] = qp->rc_qp.queues[i].gdma_region; + req.doorbell_page = doorbell; + req.max_send_wr = attr->cap.max_send_wr; + req.max_recv_wr = attr->cap.max_recv_wr; + req.max_send_sge = attr->cap.max_send_sge; + req.max_recv_sge = attr->cap.max_recv_sge; + req.flags = flags; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to create rc qp err %d", err); + return err; + } + qp->qp_handle = resp.rc_qp_handle; + for (i = 0; i < MANA_RC_QUEUE_TYPE_MAX; i++) { + qp->rc_qp.queues[i].id = resp.queue_ids[i]; + /* The GDMA regions are now owned by the RNIC QP handle */ + qp->rc_qp.queues[i].gdma_region = GDMA_INVALID_DMA_REGION; + } + return 0; +} + +int mana_ib_gd_destroy_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp) +{ + struct mana_rnic_destroy_rc_qp_resp resp = {0}; + struct mana_rnic_destroy_rc_qp_req req = {0}; + struct gdma_context *gc = mdev_to_gc(mdev); + int err; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_DESTROY_RC_QP, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + req.rc_qp_handle = qp->qp_handle; + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to destroy rc qp err %d", err); + return err; + } + return 0; +} diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index 68c3b4f..a3e229c 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -95,11 +95,27 @@ struct mana_ib_cq { mana_handle_t cq_handle; }; +enum mana_rc_queue_type { + MANA_RC_SEND_QUEUE_REQUESTER = 0, + MANA_RC_SEND_QUEUE_RESPONDER, + MANA_RC_SEND_QUEUE_FMR, + MANA_RC_RECV_QUEUE_REQUESTER, + MANA_RC_RECV_QUEUE_RESPONDER, + MANA_RC_QUEUE_TYPE_MAX, +}; + +struct mana_ib_rc_qp { + struct mana_ib_queue queues[MANA_RC_QUEUE_TYPE_MAX]; +}; + struct mana_ib_qp { struct ib_qp ibqp; mana_handle_t qp_handle; - struct mana_ib_queue raw_sq; + union { + struct mana_ib_queue raw_sq; + struct mana_ib_rc_qp rc_qp; + }; /* The port on the IB device, starting with 1 */ u32 port; @@ -122,6 +138,8 @@ enum mana_ib_command_code { MANA_IB_CONFIG_MAC_ADDR = 0x30005, MANA_IB_CREATE_CQ = 0x30008, MANA_IB_DESTROY_CQ = 0x30009, + MANA_IB_CREATE_RC_QP = 0x3000a, + MANA_IB_DESTROY_RC_QP = 0x3000b, }; struct mana_ib_query_adapter_caps_req { @@ -230,6 +248,40 @@ struct mana_rnic_destroy_cq_resp { struct gdma_resp_hdr hdr; }; /* HW Data */ +struct mana_rnic_create_qp_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; + mana_handle_t pd_handle; + mana_handle_t send_cq_handle; + mana_handle_t recv_cq_handle; + u64 dma_region[MANA_RC_QUEUE_TYPE_MAX]; + u64 deprecated[2]; + u64 flags; + u32 doorbell_page; + u32 max_send_wr; + u32 max_recv_wr; + u32 max_send_sge; + u32 max_recv_sge; + u32 reserved; +}; /* HW Data */ + +struct mana_rnic_create_qp_resp { + struct gdma_resp_hdr hdr; + mana_handle_t rc_qp_handle; + u32 queue_ids[MANA_RC_QUEUE_TYPE_MAX]; + u32 reserved; +}; /* HW Data*/ + +struct mana_rnic_destroy_rc_qp_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; + mana_handle_t rc_qp_handle; +}; /* HW Data */ + +struct mana_rnic_destroy_rc_qp_resp { + struct gdma_resp_hdr hdr; +}; /* HW Data */ + static inline struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev) { return mdev->gdma_dev->gdma_context; @@ -354,4 +406,8 @@ int mana_ib_gd_config_mac(struct mana_ib_dev *mdev, enum mana_ib_addr_op op, u8 int mana_ib_gd_create_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq, u32 doorbell); int mana_ib_gd_destroy_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq); + +int mana_ib_gd_create_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp, + struct ib_qp_init_attr *attr, u32 doorbell, u64 flags); +int mana_ib_gd_destroy_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp); #endif -- 2.43.0