[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1700709010-22042-4-git-send-email-longli@linuxonhyperv.com>
Date: Wed, 22 Nov 2023 19:10:09 -0800
From: longli@...uxonhyperv.com
To: Jason Gunthorpe <jgg@...pe.ca>,
Leon Romanovsky <leon@...nel.org>,
Ajay Sharma <sharmaajay@...rosoft.com>,
Dexuan Cui <decui@...rosoft.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: linux-rdma@...r.kernel.org,
linux-hyperv@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Long Li <longli@...rosoft.com>
Subject: [Patch v1 3/4] RDMA/mana_ib: create RDMA adapter handle
From: Long Li <longli@...rosoft.com>
Create the RDMA device handle with the SoC using the management EQ created
earlier.
Signed-off-by: Long Li <longli@...rosoft.com>
---
drivers/infiniband/hw/mana/device.c | 10 ++++--
drivers/infiniband/hw/mana/main.c | 51 ++++++++++++++++++++++++++++
drivers/infiniband/hw/mana/mana_ib.h | 30 ++++++++++++++++
3 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c
index 3da4763e1a0c..5e5aa75230c2 100644
--- a/drivers/infiniband/hw/mana/device.c
+++ b/drivers/infiniband/hw/mana/device.c
@@ -93,9 +93,10 @@ static int mana_ib_probe(struct auxiliary_device *adev,
goto deregister_device;
}
+ ret = mana_ib_create_adapter(dev);
if (ret) {
- ib_dealloc_device(&dev->ib_dev);
- return ret;
+ ibdev_err(&dev->ib_dev, "Failed to create adapter");
+ goto free_error_eq;
}
ret = ib_register_device(&dev->ib_dev, "mana_%d",
@@ -108,8 +109,10 @@ static int mana_ib_probe(struct auxiliary_device *adev,
return 0;
destroy_adapter:
- mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq);
+ mana_ib_destroy_adapter(dev);
+free_error_eq:
xa_destroy(&dev->rq_to_qp_lookup_table);
+ mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq);
deregister_device:
mana_gd_deregister_device(dev->gdma_dev);
free_ib_device:
@@ -123,6 +126,7 @@ static void mana_ib_remove(struct auxiliary_device *adev)
ib_unregister_device(&dev->ib_dev);
+ mana_ib_destroy_adapter(dev);
mana_gd_destroy_queue(dev->gdma_dev->gdma_context, dev->fatal_err_eq);
xa_destroy(&dev->rq_to_qp_lookup_table);
mana_gd_deregister_device(dev->gdma_dev);
diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
index 032f926bf1ab..4f4343d14041 100644
--- a/drivers/infiniband/hw/mana/main.c
+++ b/drivers/infiniband/hw/mana/main.c
@@ -522,6 +522,57 @@ void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
{
}
+int mana_ib_destroy_adapter(struct mana_ib_dev *dev)
+{
+ struct mana_ib_destroy_adapter_resp resp = {};
+ struct mana_ib_destroy_adapter_req req = {};
+ struct gdma_context *gc;
+ int err;
+
+ gc = dev->gdma_dev->gdma_context;
+
+ mana_gd_init_req_hdr(&req.hdr, MANA_IB_DESTROY_ADAPTER, sizeof(req),
+ sizeof(resp));
+ req.adapter = dev->adapter_handle;
+ req.hdr.dev_id = gc->mana_ib.dev_id;
+
+ err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
+
+ if (err) {
+ ibdev_err(&dev->ib_dev, "Failed to destroy adapter err %d", err);
+ return err;
+ }
+
+ return 0;
+}
+
+int mana_ib_create_adapter(struct mana_ib_dev *dev)
+{
+ struct mana_ib_create_adapter_resp resp = {};
+ struct mana_ib_create_adapter_req req = {};
+ struct gdma_context *gc;
+ int err;
+
+ gc = dev->gdma_dev->gdma_context;
+
+ mana_gd_init_req_hdr(&req.hdr, MANA_IB_CREATE_ADAPTER, sizeof(req),
+ sizeof(resp));
+ req.notify_eq_id = dev->fatal_err_eq->id;
+ req.hdr.dev_id = gc->mana_ib.dev_id;
+
+ err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
+
+ if (err) {
+ ibdev_err(&dev->ib_dev, "Failed to create adapter err %d",
+ err);
+ return err;
+ }
+
+ dev->adapter_handle = resp.adapter;
+
+ return 0;
+}
+
static void mana_ib_critical_event_handler(void *ctx, struct gdma_queue *queue,
struct gdma_event *event)
{
diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h
index a5577c119def..4286caf0d67c 100644
--- a/drivers/infiniband/hw/mana/mana_ib.h
+++ b/drivers/infiniband/hw/mana/mana_ib.h
@@ -31,6 +31,7 @@ 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 xarray rq_to_qp_lookup_table;
};
@@ -94,6 +95,31 @@ struct mana_ib_rwq_ind_table {
struct ib_rwq_ind_table ib_ind_table;
};
+enum mana_ib_command_code {
+ MANA_IB_CREATE_ADAPTER = 0x30002,
+ MANA_IB_DESTROY_ADAPTER = 0x30003,
+};
+
+struct mana_ib_create_adapter_req {
+ struct gdma_req_hdr hdr;
+ u32 notify_eq_id;
+ u32 reserved;
+}; /*HW Data */
+
+struct mana_ib_create_adapter_resp {
+ struct gdma_resp_hdr hdr;
+ mana_handle_t adapter;
+}; /* HW Data */
+
+struct mana_ib_destroy_adapter_req {
+ struct gdma_req_hdr hdr;
+ mana_handle_t adapter;
+}; /*HW Data */
+
+struct mana_ib_destroy_adapter_resp {
+ struct gdma_resp_hdr hdr;
+}; /* HW Data */
+
int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem,
mana_handle_t *gdma_region);
@@ -163,4 +189,8 @@ void mana_ib_disassociate_ucontext(struct ib_ucontext *ibcontext);
int mana_ib_create_error_eq(struct mana_ib_dev *mdev);
+int mana_ib_create_adapter(struct mana_ib_dev *mdev);
+
+int mana_ib_destroy_adapter(struct mana_ib_dev *mdev);
+
#endif
--
2.34.1
Powered by blists - more mailing lists