---
name: "ibv_open_device"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/ibv_open_device"
---

# ibv\_open\_device(3)

open and close an RDMA device context

## NAME

ibv\_open\_device, ibv\_close\_device - open and close an RDMA device context

## SYNOPSIS

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

struct ibv_context *ibv_open_device(struct ibv_device *device);

int ibv_close_device(struct ibv_context *context);
```

## DESCRIPTION

**ibv\_open\_device()** opens the device *device* and creates a context for further use.

**ibv\_close\_device()** closes the device context *context.*

## RETURN VALUE

**ibv\_open\_device()** returns a pointer to the allocated device context, or NULL if the request fails.

**ibv\_close\_device()** returns 0 on success, -1 on failure.

## NOTES

**ibv\_close\_device()** does not release all the resources allocated using context *context.* To avoid resource leaks, the user should release all associated resources before closing a context.

## SEE ALSO

[**ibv\_get\_device\_list**(3)](/ibv_get_device_list/3.md), [**ibv\_query\_device**(3)](/ibv_query_device/3.md), [**ibv\_query\_port**(3)](/ibv_query_port/3.md), [**ibv\_query\_gid**(3)](/ibv_query_gid/3.md), [**ibv\_query\_pkey**(3)](/ibv_query_pkey/3.md)

## AUTHORS

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