Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp262896lqf; Fri, 26 Apr 2024 06:13:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvN+WmQXgTFNXPqeHUuzAsL/7/SmekgxNeIEbgZV9qMoMgkFDCy9Wpq39ure4YahiAvAtKB3rRbX9nfMMwSoehJjhrESfZd7zhDGWUdg== X-Google-Smtp-Source: AGHT+IHgWeq890DLhwr89O/SlJnnVAOigajGTRTst6QPxDuvbVDMoWY/Uwe12mmdBF/9viBDI3rG X-Received: by 2002:a05:6a20:da99:b0:1a9:4186:2047 with SMTP id iy25-20020a056a20da9900b001a941862047mr3068094pzb.44.1714137204926; Fri, 26 Apr 2024 06:13:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714137204; cv=pass; d=google.com; s=arc-20160816; b=cWzPoPhhxGpL65d23qw+p3oiRcHpVr6LslBJG3jikHaXSsw31Mv4G7KqycmXDo5vDQ 3BZPIhd7T4Q2mnZd1vqKecXyeXrSMvoSLnS91igWvSUptOhAW1bxM9/YEmw1n8EoAuu6 dIoQdktUdnoTb/vvtd/07nmju/vlg2hVE+TFgrE3S2rARhZeKCq2SrONE+O8UGJRP+Lm ShhIrD0zyM6l2fYA2MasBXAFbm5dNcUF0j/OPM0SoWZI9vhdlkY48907Gnf7KJ0A83ZL tEfZnPNDROv+KLZhy8NN5OP6ShYHxQUK2vlk8A0ilLdAAclvHB7egM/nsjWnXP08PPJj Lsxw== 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=gE7Ou1irGU+YLTnkid1jAQnRHHkTvBHMHZzISwJetCA=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=r5w34nMXE8WmVPn6SlHkHpLGOuS79gwNwAahpn/F0ps0TPRSAUEg5rzWKUNOru8NLj tCqvmSC1Z5bZ1lHt8nQiLQj4NhG26wHT6u7/gY7XgObKNXJaStXUe5Q+EeAvWyXiJAOi KyBPEn7wwMOmAYpw9lNpax1TbLOT3LoYRnr/MBdcOwiTI8/wA1Zt9ABnS7sz/2RFPhHT 2E9iPUGzfibO4HAGjc3W4w6pl222kJzpOSOx8fVhW2MhKkkOrKHej00dYqYa58TK0aNW yqcaD+hbFQ61n5zcshsEjdU4wTGnUTDDveRcpDKbONH+URtDTAzTDfhTayI3Ms4xIQ1a t+dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="e4Gzd42/"; 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-160033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160033-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 14-20020a63174e000000b005f803b2c253si12311730pgx.872.2024.04.26.06.13.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 06:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="e4Gzd42/"; 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-160033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160033-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 D71B5284A79 for ; Fri, 26 Apr 2024 13:13:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BEE91474B5; Fri, 26 Apr 2024 13:12:48 +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="e4Gzd42/" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DEB5146D52; Fri, 26 Apr 2024 13:12:46 +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=1714137167; cv=none; b=JIxL8+iiNvK7xBhqB5sQQI47FSb2VKjcNiST57CYspCzjHlvpAQPip5ON3wuQl47BHPFkXvoQE8eHANrnmEa93y+cOecve2ua2gRIi1g4DTmQq9NqTvCd1aengJ3rPBxTOdK2Hr76nB81RbFoqfDFMF/Lh4vFUlAOonWDRqXNns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714137167; c=relaxed/simple; bh=IgGML0fgJ8FIxgu9wUJmI92FBHaBdGYmeXjsJuCWcd0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=axmpQR7xCnGT/ukViB7fQ5PDffczoHJYPmdBKSxHjqaehSTS/AtIZ1xNvqmjZi2VDlA7J1NBMafZWex7PwESNgXSjutjcrVCBf+zRnsTbPSgsviYslzZ5dSDmQXibTocV3lEhm1cJT5Cpa7SIhayj+c4N0teW/rw07atltnihFo= 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=e4Gzd42/; 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 0827B210EF27; Fri, 26 Apr 2024 06:12:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0827B210EF27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1714137166; bh=gE7Ou1irGU+YLTnkid1jAQnRHHkTvBHMHZzISwJetCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e4Gzd42/wsr4nsQ4VCDE/BJDTrKmPveakT64D/+F8p1PV5cKyhfwOnrxw9SakOsif mzubS1w6bn5GIawW5+8mewLASjRBf6vbaoZBL6m6b/aZVxZ6aslJy+1i9HuHRViNCa tVziAoUMkysO3ukzVfJHsLwQF2V5syCqXeoTJqW4= 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 v2 2/5] RDMA/mana_ib: create and destroy RNIC cqs Date: Fri, 26 Apr 2024 06:12:37 -0700 Message-Id: <1714137160-5222-3-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1714137160-5222-1-git-send-email-kotaranov@linux.microsoft.com> References: <1714137160-5222-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 RNIC requests for creation and destruction of RNIC CQs. Signed-off-by: Konstantin Taranov Reviewed-by: Long Li --- drivers/infiniband/hw/mana/main.c | 54 ++++++++++++++++++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 32 +++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 546d059..2a41135 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -834,3 +834,57 @@ int mana_ib_gd_config_mac(struct mana_ib_dev *mdev, enum mana_ib_addr_op op, u8 return 0; } + +int mana_ib_gd_create_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq, u32 doorbell) +{ + struct gdma_context *gc = mdev_to_gc(mdev); + struct mana_rnic_create_cq_resp resp = {}; + struct mana_rnic_create_cq_req req = {}; + int err; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CREATE_CQ, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + req.gdma_region = cq->queue.gdma_region; + req.eq_id = mdev->eqs[cq->comp_vector]->id; + req.doorbell_page = doorbell; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to create cq err %d", err); + return err; + } + + cq->queue.id = resp.cq_id; + cq->cq_handle = resp.cq_handle; + /* The GDMA region is now owned by the CQ handle */ + cq->queue.gdma_region = GDMA_INVALID_DMA_REGION; + + return 0; +} + +int mana_ib_gd_destroy_cq(struct mana_ib_dev *mdev, struct mana_ib_cq *cq) +{ + struct gdma_context *gc = mdev_to_gc(mdev); + struct mana_rnic_destroy_cq_resp resp = {}; + struct mana_rnic_destroy_cq_req req = {}; + int err; + + if (cq->cq_handle == INVALID_MANA_HANDLE) + return 0; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_DESTROY_CQ, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + req.cq_handle = cq->cq_handle; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to destroy cq 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 bfcf6df..9162f29 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -92,6 +92,7 @@ struct mana_ib_cq { struct mana_ib_queue queue; int cqe; u32 comp_vector; + mana_handle_t cq_handle; }; struct mana_ib_qp { @@ -119,6 +120,8 @@ enum mana_ib_command_code { MANA_IB_DESTROY_ADAPTER = 0x30003, MANA_IB_CONFIG_IP_ADDR = 0x30004, MANA_IB_CONFIG_MAC_ADDR = 0x30005, + MANA_IB_CREATE_CQ = 0x30008, + MANA_IB_DESTROY_CQ = 0x30009, }; struct mana_ib_query_adapter_caps_req { @@ -202,6 +205,31 @@ struct mana_rnic_config_mac_addr_resp { struct gdma_resp_hdr hdr; }; /* HW Data */ +struct mana_rnic_create_cq_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; + u64 gdma_region; + u32 eq_id; + u32 doorbell_page; +}; /* HW Data */ + +struct mana_rnic_create_cq_resp { + struct gdma_resp_hdr hdr; + mana_handle_t cq_handle; + u32 cq_id; + u32 reserved; +}; /* HW Data */ + +struct mana_rnic_destroy_cq_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; + mana_handle_t cq_handle; +}; /* HW Data */ + +struct mana_rnic_destroy_cq_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; @@ -321,4 +349,8 @@ int mana_ib_gd_add_gid(const struct ib_gid_attr *attr, void **context); int mana_ib_gd_del_gid(const struct ib_gid_attr *attr, void **context); int mana_ib_gd_config_mac(struct mana_ib_dev *mdev, enum mana_ib_addr_op op, u8 *mac); + +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); #endif -- 2.43.0