Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1574708rdb; Wed, 31 Jan 2024 02:56:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9GABS1eoMPKzNu0mpsWVk/sTnhrGv5foMRdIoFsCY3FdPyb4RIvBg2dTdVcyVxX2tmFgl X-Received: by 2002:a17:903:1104:b0:1d8:d6bf:144b with SMTP id n4-20020a170903110400b001d8d6bf144bmr1462129plh.4.1706698608520; Wed, 31 Jan 2024 02:56:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706698608; cv=pass; d=google.com; s=arc-20160816; b=KtFaDdMVpeurs59TgnzUoVhIhOLFqBye+DW4XKoVfoPjudSWWHag4CmnZUBL7uTCmB YIF1o4E6UIfJMEEvgUyMRkH/366Bv2itx2VgQu4R8onJ/FS89QhJ4kr9eq87IfxKe4Qk 9vdZJbnONtgu0X49jvL/gdVJnaL3/YO0JfvQkQ75q+fmyaiPzNr3/y1oB9Oa1/eJIUeu Mk+XjknA9Ndj2zZhQCcb1DdWuFWGmX/+6NBYtVwLplW6sOSBaOy+ZbwLe7k7wJcIQCxg SJKIXvy+nJfthvAZ89H5iWUELOTmLiM3AAUmFiWL7E0DkoRdDnoerMEdtLG1yKpH/t/x Ijag== 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=FQMJvC08Xx+rruS+xJDdv53mAl3GJPxfohVLYNulxEA=; fh=Q8LTT1eeZYpbehzkX7JSQgnO7/R1YqJXWxVY2UQ5WMo=; b=XDFpm+LrsiPO4X5YmyZZK24M8J8nEdRe9UXg3HoCZu0Xn9OjrU232KCnRv6yd2V1tl ecksWOffK/DnavPuuQVsmBgH9AzKDKoCkfibQZgjTHX3xF5m53JwlP7+ocu6SkSiuByo a2Pg/z1gi3G2bHB+Y3GhMb+/MC7SdD56oApacLMIdCa14/ba57kpbIbBPDUnYeiWQBlD FXCNpAjE/dgFrbCBLahkhQMgS0b0ZdmbKwlTcXh3Phep2CoP9w0/b3knZjE1jEsm5dM5 EafF7ar5uHCVh9u2Ri5q6DP/xYWKFbi9vLnaX/UxvmeTZpS+bb+FvOVslVaP1w/AhjPy EFAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=S3JrxK1p; 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-46276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com X-Forwarded-Encrypted: i=1; AJvYcCU1FQqgnNhUhnyskq+8HeqL4UtcEtgcAzfRegHQ6lDg7AdyHpY1RJFI9OYK5umUMVN9IsKvRYCaSWmwV5e5NRe5eYMbvrLUTg5oyw+lqA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t1-20020a170902e84100b001d5ac82c7fcsi9850594plg.447.2024.01.31.02.56.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 02:56:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46276-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=S3JrxK1p; 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-46276-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46276-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 2B55629BAE0 for ; Wed, 31 Jan 2024 10:56:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8949C768F4; Wed, 31 Jan 2024 10:56:00 +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="S3JrxK1p" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 397536A030; Wed, 31 Jan 2024 10:55:58 +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=1706698559; cv=none; b=rFpROYn1MjJezdru3mpaR95J/kb7Ip+y7uzeso18wBcUQTNCOq4n7ESQAvcq39xm4DrrS6Lkmb6UUZ9uK6f/91sFzC7kXysyH8YZoKBMa547cnml+xz2x/TrrpDDZspIWnJ+7dM6UdWxPnlbphHg/yylWHwszSBq4HThlwuHnBE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706698559; c=relaxed/simple; bh=GI6QY98SEMz0zqOuQidUbYonmgSgitJXQUyspqe4rNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=fpYF+IoV17o2REa2Tn1PCvaJUZqmrS8QTvwh2/N9p8QvRlZyKNYW6xi3EvvFoqiixxImEm/d1qPi440k3k+arU+1pVXKLjGA0D16uj5XGpbskUivQ23ZhrJNzomYV8OYAo7KZ8GjWxjqi0YGN9VVrlIfL3ev2WvQu3M5ebdTSA0= 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=S3JrxK1p; 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 C2D7F20B2002; Wed, 31 Jan 2024 02:55:57 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C2D7F20B2002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1706698557; bh=FQMJvC08Xx+rruS+xJDdv53mAl3GJPxfohVLYNulxEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S3JrxK1pO/X+3876uWpPrkKDWepe9Vt4MtQXVlmCX64d3WHz/zd7d+5oyQgIYhwdO umuzfIPe5kdz3Z+Pt0J0sWk06449UeLvCdOdjXosVxc53ZsLQ1ojYj283Y0kgxEJJ1 zCjsENNIHlMzHWM35uivZp6tyUSr22W+J5DixdAE= 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 v1 2/5] RDMA/mana_ib: Create and destroy rnic adapter Date: Wed, 31 Jan 2024 02:55:49 -0800 Message-Id: <1706698552-25383-3-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1706698552-25383-1-git-send-email-kotaranov@linux.microsoft.com> References: <1706698552-25383-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: This patch adds RNIC creation and destruction. If creation of RNIC fails, we support only RAW QPs as they are served by ethernet driver. Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/main.c | 31 +++++++++++++++++++++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index c64d569..33cd69e 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -581,14 +581,31 @@ static void mana_ib_destroy_eqs(struct mana_ib_dev *mdev) void mana_ib_gd_create_rnic_adapter(struct mana_ib_dev *mdev) { + struct mana_rnic_create_adapter_resp resp = {}; + struct mana_rnic_create_adapter_req req = {}; + struct gdma_context *gc = mdev_to_gc(mdev); int err; + mdev->adapter_handle = INVALID_MANA_HANDLE; + err = mana_ib_create_eqs(mdev); if (err) { ibdev_err(&mdev->ib_dev, "Failed to create EQs for RNIC err %d", err); goto cleanup; } + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CREATE_ADAPTER, sizeof(req), sizeof(resp)); + req.hdr.req.msg_version = GDMA_MESSAGE_V2; + req.hdr.dev_id = gc->mana_ib.dev_id; + req.notify_eq_id = mdev->fatal_err_eq->id; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to create RNIC adapter err %d", err); + goto cleanup; + } + mdev->adapter_handle = resp.adapter; + return; cleanup: @@ -599,5 +616,19 @@ void mana_ib_gd_create_rnic_adapter(struct mana_ib_dev *mdev) void mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev) { + struct mana_rnic_destroy_adapter_resp resp = {}; + struct mana_rnic_destroy_adapter_req req = {}; + struct gdma_context *gc; + + if (!rnic_is_enabled(mdev)) + return; + + gc = mdev_to_gc(mdev); + mana_gd_init_req_hdr(&req.hdr, MANA_IB_DESTROY_ADAPTER, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + + mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + mdev->adapter_handle = INVALID_MANA_HANDLE; mana_ib_destroy_eqs(mdev); } diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index a4b94ee..96454cf 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -48,6 +48,7 @@ struct mana_ib_adapter_caps { struct mana_ib_dev { struct ib_device ib_dev; struct gdma_dev *gdma_dev; + mana_handle_t adapter_handle; struct gdma_queue *fatal_err_eq; struct mana_ib_adapter_caps adapter_caps; }; @@ -115,6 +116,8 @@ 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, }; struct mana_ib_query_adapter_caps_req { @@ -143,6 +146,32 @@ struct mana_ib_query_adapter_caps_resp { u32 max_inline_data_size; }; /* HW Data */ +struct mana_rnic_create_adapter_req { + struct gdma_req_hdr hdr; + u32 notify_eq_id; + u32 reserved; + u64 feature_flags; +}; /*HW Data */ + +struct mana_rnic_create_adapter_resp { + struct gdma_resp_hdr hdr; + mana_handle_t adapter; +}; /* HW Data */ + +struct mana_rnic_destroy_adapter_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; +}; /*HW Data */ + +struct mana_rnic_destroy_adapter_resp { + struct gdma_resp_hdr hdr; +}; /* HW Data */ + +static inline bool rnic_is_enabled(struct mana_ib_dev *mdev) +{ + return mdev->adapter_handle != INVALID_MANA_HANDLE; +} + static inline struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev) { return mdev->gdma_dev->gdma_context; -- 1.8.3.1