---
name: "ibv_ack_async_event"
section: "3"
platform: "linux"
package: "rdma-core"
version: "65.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ibv_get_async_event"
---

# ibv\_ack\_async\_event(3)

get or acknowledge asynchronous events

Part of [ibv\_get\_async\_event(3)](/ibv_get_async_event/3.md).

## NAME

ibv\_get\_async\_event, ibv\_ack\_async\_event - get or acknowledge asynchronous events

## SYNOPSIS

```
#include <infiniband/verbs.h>

int ibv_get_async_event(struct ibv_context *context,
                        struct ibv_async_event *event);

void ibv_ack_async_event(struct ibv_async_event *event);
```

## DESCRIPTION

**ibv\_get\_async\_event()** waits for the next async event of the RDMA device context *context* and returns it through the pointer *event,* which is an ibv\_async\_event struct, as defined in \<infiniband/verbs.h\>.

```
struct ibv_async_event {
union {
struct ibv_cq  *cq;             /* CQ that got the event */
struct ibv_qp  *qp;             /* QP that got the event */
struct ibv_srq *srq;            /* SRQ that got the event */
struct ibv_wq  *wq;             /* WQ that got the event */
int             port_num;       /* port number that got the event */
} element;
enum ibv_event_type     event_type;     /* type of the event */
};
```

One member of the element union will be valid, depending on the event\_type member of the structure.  event\_type will be one of the following events:

*QP events:*

- **IBV\_EVENT\_QP\_FATAL Error occurred on a QP and it transitioned to error state**

  - **IBV\_EVENT\_QP\_REQ\_ERR Invalid Request Local Work Queue Error**

  - **IBV\_EVENT\_QP\_ACCESS\_ERR Local access violation error**

  - **IBV\_EVENT\_COMM\_EST Communication was established on a QP**

  - **IBV\_EVENT\_SQ\_DRAINED Send Queue was drained of outstanding messages in progress**

  - **IBV\_EVENT\_PATH\_MIG A connection has migrated to the alternate path**

  - **IBV\_EVENT\_PATH\_MIG\_ERR A connection failed to migrate to the alternate path**

  - **IBV\_EVENT\_QP\_LAST\_WQE\_REACHED Last WQE Reached on a QP associated with an SRQ**

  *CQ events:*

- **IBV\_EVENT\_CQ\_ERR CQ is in error (CQ overrun)**

  *SRQ events:*

- **IBV\_EVENT\_SRQ\_ERR Error occurred on an SRQ**

  - **IBV\_EVENT\_SRQ\_LIMIT\_REACHED SRQ limit was reached**

  *WQ events:*

- **IBV\_EVENT\_WQ\_FATAL Error occurred on a WQ and it transitioned to error state**

  *Port events:*

- **IBV\_EVENT\_PORT\_ACTIVE Link became active on a port**

  - **IBV\_EVENT\_PORT\_ERR Link became unavailable on a port**

  - **IBV\_EVENT\_LID\_CHANGE LID was changed on a port**

  - **IBV\_EVENT\_PKEY\_CHANGE P\_Key table was changed on a port**

  - **IBV\_EVENT\_SM\_CHANGE SM was changed on a port**

  - **IBV\_EVENT\_CLIENT\_REREGISTER SM sent a CLIENT\_REREGISTER request to a port**

  - **IBV\_EVENT\_GID\_CHANGE GID table was changed on a port**

  *CA events:*

- **IBV\_EVENT\_DEVICE\_FATAL CA is in FATAL state**

  - **IBV\_EVENT\_DEVICE\_SPEED\_CHANGE Speed changed on one or many ports of the device due to configuration or state changes**

  **ibv\_ack\_async\_event()** acknowledge the async event *event.*

## RETURN VALUE

**ibv\_get\_async\_event()** returns 0 on success, and -1 on error.

**ibv\_ack\_async\_event()** returns no value.

## NOTES

All async events that **ibv\_get\_async\_event()** returns must be acknowledged using **ibv\_ack\_async\_event().** To avoid races, destroying an object (CQ, SRQ or QP) will wait for all affiliated events for the object to be acknowledged; this avoids an application retrieving an affiliated event after the corresponding object has already been destroyed.

**ibv\_get\_async\_event()** is a blocking function.  If multiple threads call this function simultaneously, then when an async event occurs, only one thread will receive it, and it is not possible to predict which thread will receive it.

## EXAMPLES

The following code example demonstrates one possible way to work with async events in non-blocking mode. It performs the following steps:

1\. Set the async events queue work mode to be non-blocked\
 2\. Poll the queue until it has an async event\
 3\. Get the async event and ack it

```
/* change the blocking mode of the async event queue */
flags = fcntl(ctx->async_fd, F_GETFL);
rc = fcntl(ctx->async_fd, F_SETFL, flags | O_NONBLOCK);
if (rc < 0) {
        fprintf(stderr, "Failed to change file descriptor of async event queue\n");
        return 1;
}
/*
 * poll the queue until it has an event and sleep ms_timeout
 * milliseconds between any iteration
 */
my_pollfd.fd      = ctx->async_fd;
my_pollfd.events  = POLLIN;
my_pollfd.revents = 0;
do {
        rc = poll(&my_pollfd, 1, ms_timeout);
} while (rc == 0);
if (rc < 0) {
        fprintf(stderr, "poll failed\n");
        return 1;
}
/* Get the async event */
if (ibv_get_async_event(ctx, &async_event)) {
        fprintf(stderr, "Failed to get async_event\n");
        return 1;
}
/* Ack the event */
ibv_ack_async_event(&async_event);
```

## SEE ALSO

[**ibv\_open\_device**(3)](/ibv_open_device/3.md)

## AUTHORS

- Dotan Barak \<dotanba@gmail.com\>
