@@ -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);
@@ -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)
{
@@ -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