提交 2110f9bf 编写于 作者: O Or Gerlitz 提交者: Roland Dreier

IB/iser: Add asynchronous event handler

Add handler to handle events such as port up and down.  This is useful
when testing high-availability schemes such as multi-pathing.
Signed-off-by: NOr Gerlitz <ogerlitz@voltaire.com>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 0eddb519
...@@ -232,6 +232,7 @@ struct iser_device { ...@@ -232,6 +232,7 @@ struct iser_device {
struct ib_cq *tx_cq; struct ib_cq *tx_cq;
struct ib_mr *mr; struct ib_mr *mr;
struct tasklet_struct cq_tasklet; struct tasklet_struct cq_tasklet;
struct ib_event_handler event_handler;
struct list_head ig_list; /* entry in ig devices list */ struct list_head ig_list; /* entry in ig devices list */
int refcount; int refcount;
}; };
......
...@@ -54,6 +54,13 @@ static void iser_qp_event_callback(struct ib_event *cause, void *context) ...@@ -54,6 +54,13 @@ static void iser_qp_event_callback(struct ib_event *cause, void *context)
iser_err("got qp event %d\n",cause->event); iser_err("got qp event %d\n",cause->event);
} }
static void iser_event_handler(struct ib_event_handler *handler,
struct ib_event *event)
{
iser_err("async event %d on device %s port %d\n", event->event,
event->device->name, event->element.port_num);
}
/** /**
* iser_create_device_ib_res - creates Protection Domain (PD), Completion * iser_create_device_ib_res - creates Protection Domain (PD), Completion
* Queue (CQ), DMA Memory Region (DMA MR) with the device associated with * Queue (CQ), DMA Memory Region (DMA MR) with the device associated with
...@@ -96,8 +103,15 @@ static int iser_create_device_ib_res(struct iser_device *device) ...@@ -96,8 +103,15 @@ static int iser_create_device_ib_res(struct iser_device *device)
if (IS_ERR(device->mr)) if (IS_ERR(device->mr))
goto dma_mr_err; goto dma_mr_err;
INIT_IB_EVENT_HANDLER(&device->event_handler, device->ib_device,
iser_event_handler);
if (ib_register_event_handler(&device->event_handler))
goto handler_err;
return 0; return 0;
handler_err:
ib_dereg_mr(device->mr);
dma_mr_err: dma_mr_err:
tasklet_kill(&device->cq_tasklet); tasklet_kill(&device->cq_tasklet);
cq_arm_err: cq_arm_err:
...@@ -120,7 +134,7 @@ static void iser_free_device_ib_res(struct iser_device *device) ...@@ -120,7 +134,7 @@ static void iser_free_device_ib_res(struct iser_device *device)
BUG_ON(device->mr == NULL); BUG_ON(device->mr == NULL);
tasklet_kill(&device->cq_tasklet); tasklet_kill(&device->cq_tasklet);
(void)ib_unregister_event_handler(&device->event_handler);
(void)ib_dereg_mr(device->mr); (void)ib_dereg_mr(device->mr);
(void)ib_destroy_cq(device->tx_cq); (void)ib_destroy_cq(device->tx_cq);
(void)ib_destroy_cq(device->rx_cq); (void)ib_destroy_cq(device->rx_cq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册