Commit 1a79c2b9 authored by Konstantin Taranov's avatar Konstantin Taranov Committed by Leon Romanovsky

RDMA/mana_ib: Create and destroy rnic adapter

Add functions for RNIC creation and destruction.
If creation fails, the ib_probe fails as well.
Signed-off-by: default avatarKonstantin Taranov <kotaranov@microsoft.com>
Link: https://lore.kernel.org/r/1712738551-22075-3-git-send-email-kotaranov@linux.microsoft.comSigned-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 98b889c4
......@@ -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);
......
......@@ -637,3 +637,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;
}
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment