Debian Codegraph @

libibverbs/man/ibv_get_async_event.3

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