diff options
author | Dotan Barak <dotanb@mellanox.co.il> | 2006-03-23 00:48:03 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:36:00 -0800 |
commit | e7f6cb49601f33540b3251593e1b82bf224b4e12 (patch) | |
tree | 654c17a21a323bd40ce498a049b0343fd34303c2 | |
parent | 1ac5f02fc0278b1d192a762b0fad523dc9c41dcb (diff) | |
download | libibverbs-e7f6cb49601f33540b3251593e1b82bf224b4e12.tar.gz |
Added a print of the event name in string format
Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | examples/asyncwatch.c | 37 |
2 files changed, 40 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2006-03-22 Dotan Barak <dotanb@mellanox.co.il> + + * examples/asyncwatch.c: Print asynchronous event name as well as + raw integer value. + 2006-03-22 Roland Dreier <rdreier@cisco.com> * include/infiniband/verbs.h (ibv_req_notify_cq): Document diff --git a/examples/asyncwatch.c b/examples/asyncwatch.c index c469ad7..9d706a1 100644 --- a/examples/asyncwatch.c +++ b/examples/asyncwatch.c @@ -42,6 +42,38 @@ #include <infiniband/verbs.h> +static const char *event_name_str(enum ibv_event_type event_type) +{ + switch (event_type) { + case IBV_EVENT_DEVICE_FATAL: + return "IBV_EVENT_DEVICE_FATAL"; + case IBV_EVENT_PORT_ACTIVE: + return "IBV_EVENT_PORT_ACTIVE"; + case IBV_EVENT_PORT_ERR: + return "IBV_EVENT_PORT_ERR"; + case IBV_EVENT_LID_CHANGE: + return "IBV_EVENT_LID_CHANGE"; + case IBV_EVENT_PKEY_CHANGE: + return "IBV_EVENT_PKEY_CHANGE"; + case IBV_EVENT_SM_CHANGE: + return "IBV_EVENT_SM_CHANGE"; + + case IBV_EVENT_CQ_ERR: + case IBV_EVENT_QP_FATAL: + case IBV_EVENT_QP_REQ_ERR: + case IBV_EVENT_QP_ACCESS_ERR: + case IBV_EVENT_COMM_EST: + case IBV_EVENT_SQ_DRAINED: + case IBV_EVENT_PATH_MIG: + case IBV_EVENT_PATH_MIG_ERR: + case IBV_EVENT_SRQ_ERR: + case IBV_EVENT_SRQ_LIMIT_REACHED: + case IBV_EVENT_QP_LAST_WQE_REACHED: + default: + return "unexpected"; + } +} + int main(int argc, char *argv[]) { struct ibv_device **dev_list; @@ -73,8 +105,9 @@ int main(int argc, char *argv[]) if (ibv_get_async_event(context, &event)) return 1; - printf(" event_type %d, port %d\n", event.event_type, - event.element.port_num); + printf(" event_type %s (%d), port %d\n", + event_name_str(event.event_type), + event.event_type, event.element.port_num); ibv_ack_async_event(&event); } |