Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp2074lqj; Wed, 10 Apr 2024 01:43:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqla0JPAxHKKPe3WKMsoHwmj37t7wFZipNGJjsibfS7RZakMZ0YNWlBLuMD6EBeiEkb5IU5qZrkyF56N2ivB1XoXg4Z3hIR2Kbo2TJEA== X-Google-Smtp-Source: AGHT+IHvaQCKmFeg3ImX73QBFyzusRTKTaLcsDqq8jXYcH2ksjNGQnDN4tOzfl9c2Vl+InU2MaMK X-Received: by 2002:a05:622a:20d:b0:434:b11e:8683 with SMTP id b13-20020a05622a020d00b00434b11e8683mr1589161qtx.7.1712738596424; Wed, 10 Apr 2024 01:43:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712738596; cv=pass; d=google.com; s=arc-20160816; b=SAa3szgMb/lvHzlUHv1U/xAhrBxsY/wq3F2RqbKK4Z83q3cnglzGZvM11tjkye7WC7 1x5Y29Srwjeyyna3S2f219ihvs9zT/SgrdgNp0VQn+2uLXK7zxt1VeS3pUHNDTAkRSlK eHLURItTaqZk9hHczIzGnbeT4reJfrmEbijLQz2mXz49IXjwBHaa25mAIxcO3auYymIZ vMtzoJ+RXN0DcPidXWoBoXozmsDzRPDzr1M9eml21Irb4z4lcV7KfAt0/ieGdzSfcV6V rvyPTz6B6hhNKckhCXUhyBoODbvjhpysZm8dh7SNxk+9YlAFuXI3JzqN2fMtRdzKJIqm T77A== 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=W9w7GJWqvIwZdFH9Mme/YLMG5+pTk49k5ZpBxP4+eUE=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=mUkJfjJI87jCbdHZd+KfMsBGsrNqNDPpGENbzPAhFfcZ5Em6b06k76iooAP48hfz8L vpEswYVg5zBcSQkUh4K9en5Ua1U5QSDEXP95kqSKAY8jgazDt9fAOYaD/WXJFy6w1Hye n74+GXN17MA4E8E5JOdU+MixC58ak3p3xObkZyNEe70zu7hilJuVM/G/NBDJVZDs+KfQ X3aizGNXJKgZFy6Xf5QaB2EzgKQiQFOmoB6GoSzPqyt9eo4a8oRyp/Do1e0Z6phiJaDH 71j5DYwlCC8WtfQb4Y4fVwdtLEOcv9PaS+K+lDzggfdEO+BAYyb7w/8swv6mqLg+hCpD k0KQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="iNINV/HH"; 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-138183-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138183-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id hd15-20020a05622a298f00b0043478a22ab0si4303273qtb.549.2024.04.10.01.43.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 01:43:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138183-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="iNINV/HH"; 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-138183-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138183-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1E5C41C20CAD for ; Wed, 10 Apr 2024 08:43:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 716C31552F2; Wed, 10 Apr 2024 08:42:40 +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="iNINV/HH" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD78D154C0A; Wed, 10 Apr 2024 08:42:37 +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=1712738559; cv=none; b=Oxol2VVaIW4lDkSqaxkwsMxJ7WdJndANpUIy9NhXYfIVMFkNc6TR4ZFyYcFiRAcGSIT+XEokEE3iqY9TAdqibP8rfGZLvDv7rHZBQ3mFzBPAAHVkIHVRVy5TXRJIVER2MbXoTxz+33sBSVkntiJi6L3l3Hk5df4kF+hBblz0xD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712738559; c=relaxed/simple; bh=bM0oK7MTXduTMJ4UNCL9VTBSkBbMAxcFDPFIVGvVT68=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=bK16y9PM+romaDlCD0uoDV1S81QR8Htb8YG4wOFFXOV0w1GtBwsyHS9kSfBUxvSUJAxgPdNWrnnpLVY5lLmvZ8Xc9erjMEXebCtwdwu4ulMjf2ufo5wKHuo0+LdOO1ZbdSjjT/I+haOms3mE8MBU4G0Xy/X0ZLKnUSJ0y7lcTp4= 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=iNINV/HH; 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 989A120EB0FB; Wed, 10 Apr 2024 01:42:37 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 989A120EB0FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712738557; bh=W9w7GJWqvIwZdFH9Mme/YLMG5+pTk49k5ZpBxP4+eUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNINV/HHyPKqelqQui6UKFPmIr9EHfz5RRcxpctjyQ5XkkBtX60ocIIh18zBzxZeR 6FUVi0Mk1vqcPP7zn/6R7SOyyR3dxiNLk7oZLjqUYpE0s8JbSbkoWrbsIcYfrJ/WZ4 U5EmEgySuo2Ff9KHsEQ0WA85cSa+85z5eUsKBfPM= 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 v3 2/6] RDMA/mana_ib: Create and destroy rnic adapter Date: Wed, 10 Apr 2024 01:42:27 -0700 Message-Id: <1712738551-22075-3-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1712738551-22075-1-git-send-email-kotaranov@linux.microsoft.com> References: <1712738551-22075-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 Add functions for RNIC creation and destruction. If creation fails, the ib_probe fails as well. Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/device.c | 9 +++++- drivers/infiniband/hw/mana/main.c | 43 ++++++++++++++++++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 28 ++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index 335ac6baa8d4..a98a04ff92e5 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -98,15 +98,21 @@ static int mana_ib_probe(struct auxiliary_device *adev, goto deregister_device; } + ret = mana_ib_gd_create_rnic_adapter(dev); + if (ret) + goto destroy_eqs; + ret = ib_register_device(&dev->ib_dev, "mana_%d", mdev->gdma_context->dev); if (ret) - goto destroy_eqs; + goto destroy_rnic; dev_set_drvdata(&adev->dev, dev); return 0; +destroy_rnic: + mana_ib_gd_destroy_rnic_adapter(dev); destroy_eqs: mana_ib_destroy_eqs(dev); deregister_device: @@ -121,6 +127,7 @@ 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_ib_gd_destroy_rnic_adapter(dev); mana_ib_destroy_eqs(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 4a9571c14853..aa3cac8d3edb 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -639,3 +639,46 @@ void mana_ib_destroy_eqs(struct mana_ib_dev *mdev) { mana_gd_destroy_queue(mdev_to_gc(mdev), mdev->fatal_err_eq); } + +int 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; + + 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); + return err; + } + mdev->adapter_handle = resp.adapter; + + return 0; +} + +int 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; + int err; + + 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; + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + if (err) { + ibdev_err(&mdev->ib_dev, "Failed to destroy RNIC adapter 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 7c55204125de..842f9c63a495 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -54,6 +54,7 @@ struct mana_ib_queue { 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; }; @@ -113,6 +114,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 { @@ -141,6 +144,27 @@ 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 struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev) { return mdev->gdma_dev->gdma_context; @@ -238,4 +262,8 @@ int mana_ib_gd_query_adapter_caps(struct mana_ib_dev *mdev); int mana_ib_create_eqs(struct mana_ib_dev *mdev); void mana_ib_destroy_eqs(struct mana_ib_dev *mdev); + +int mana_ib_gd_create_rnic_adapter(struct mana_ib_dev *mdev); + +int mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev); #endif -- 2.43.0