1IBV_GET_ASYNC_EVENT(3) Libibverbs Programmer's Manual IBV_GET_ASYNC_EVENT(3)
2
3
4
6 ibv_get_async_event, ibv_ack_async_event - get or acknowledge asynchro‐
7 nous events
8
10 #include <infiniband/verbs.h>
11
12 int ibv_get_async_event(struct ibv_context *context,
13 struct ibv_async_event *event);
14
15 void ibv_ack_async_event(struct ibv_async_event *event);
16
18 ibv_get_async_event() waits for the next async event of the RDMA device
19 context context and returns it through the pointer event, which is an
20 ibv_async_event struct, as defined in <infiniband/verbs.h>.
21
22 struct ibv_async_event {
23 union {
24 struct ibv_cq *cq; /* CQ that got the event */
25 struct ibv_qp *qp; /* QP that got the event */
26 struct ibv_srq *srq; /* SRQ that got the event */
27 int port_num; /* port number that got the event */
28 } element;
29 enum ibv_event_type event_type; /* type of the event */
30 };
31
32 One member of the element union will be valid, depending on the
33 event_type member of the structure. event_type will be one of the fol‐
34 lowing events:
35
36 QP events:
37
38 IBV_EVENT_QP_FATAL Error occurred on a QP and it transitioned to error
39 state
40
41 IBV_EVENT_QP_REQ_ERR Invalid Request Local Work Queue Error
42
43 IBV_EVENT_QP_ACCESS_ERR Local access violation error
44
45 IBV_EVENT_COMM_EST Communication was established on a QP
46
47 IBV_EVENT_SQ_DRAINED Send Queue was drained of outstanding messages in
48 progress
49
50 IBV_EVENT_PATH_MIG A connection has migrated to the alternate path
51
52 IBV_EVENT_PATH_MIG_ERR A connection failed to migrate to the alternate
53 path
54
55 IBV_EVENT_QP_LAST_WQE_REACHED Last WQE Reached on a QP associated with
56 an SRQ
57
58 CQ events:
59
60 IBV_EVENT_CQ_ERR CQ is in error (CQ overrun)
61
62 SRQ events:
63
64 IBV_EVENT_SRQ_ERR Error occurred on an SRQ
65
66 IBV_EVENT_SRQ_LIMIT_REACHED SRQ limit was reached
67
68 Port events:
69
70 IBV_EVENT_PORT_ACTIVE Link became active on a port
71
72 IBV_EVENT_PORT_ERR Link became unavailable on a port
73
74 IBV_EVENT_LID_CHANGE LID was changed on a port
75
76 IBV_EVENT_PKEY_CHANGE P_Key table was changed on a port
77
78 IBV_EVENT_SM_CHANGE SM was changed on a port
79
80 IBV_EVENT_CLIENT_REREGISTER SM sent a CLIENT_REREGISTER request to a
81 port
82
83 CA events:
84
85 IBV_EVENT_DEVICE_FATAL CA is in FATAL state
86
87 ibv_ack_async_event() acknowledge the async event event.
88
90 ibv_get_async_event() returns 0 on success, and -1 on error.
91
92 ibv_ack_async_event() returns no value.
93
95 All async events that ibv_get_async_event() returns must be acknowl‐
96 edged using ibv_ack_async_event(). To avoid races, destroying an
97 object (CQ, SRQ or QP) will wait for all affiliated events for the
98 object to be acknowledged; this avoids an application retrieving an
99 affiliated event after the corresponding object has already been
100 destroyed.
101
102 ibv_get_async_event() is a blocking function. If multiple threads call
103 this function simultaneously, then when an async event occurs, only one
104 thread will receive it, and it is not possible to predict which thread
105 will receive it.
106
108 The following code example demonstrates one possible way to work with
109 async events in non-blocking mode. It performs the following steps:
110
111 1. Set the async events queue work mode to be non-blocked
112 2. Poll the queue until it has an async event
113 3. Get the async event and ack it
114
115 /* change the blocking mode of the async event queue */
116 flags = fcntl(ctx->async_fd, F_GETFL);
117 rc = fcntl(ctx->async_fd, F_SETFL, flags | O_NONBLOCK);
118 if (rc < 0) {
119 fprintf(stderr, "Failed to change file descriptor of async event queue\n");
120 return 1;
121 }
122
123 /*
124 * poll the queue until it has an event and sleep ms_timeout
125 * milliseconds between any iteration
126 */
127 my_pollfd.fd = ctx->async_fd;
128 my_pollfd.events = POLLIN;
129 my_pollfd.revents = 0;
130
131 do {
132 rc = poll(&my_pollfd, 1, ms_timeout);
133 } while (rc == 0);
134 if (rc < 0) {
135 fprintf(stderr, "poll failed\n");
136 return 1;
137 }
138
139 /* Get the async event */
140 if (ibv_get_async_event(ctx, &async_event)) {
141 fprintf(stderr, "Failed to get async_event\n");
142 return 1;
143 }
144
145 /* Ack the event */
146 ibv_ack_async_event(&async_event);
147
148
150 ibv_open_device(3)
151
153 Dotan Barak <dotanba@gmail.com>
154
155
156
157libibverbs 2006-10-31 IBV_GET_ASYNC_EVENT(3)