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

# ibv\_bind\_mw(3)

post a request to bind a type 1 memory window to a memory region

## NAME

ibv\_bind\_mw - post a request to bind a type 1 memory window to a memory region

## SYNOPSIS

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

int ibv_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
                struct ibv_mw_bind *mw_bind);
```

## DESCRIPTION

**ibv\_bind\_mw()** posts to the queue pair *qp* a request to bind the memory window *mw* according to the details in *mw\_bind.*

The argument *mw\_bind* is an ibv\_mw\_bind struct, as defined in \<infiniband/verbs.h\>.

```
struct ibv_mw_bind {
uint64_t                     wr_id;           /* User defined WR ID */
unsigned int                 send_flags;      /* Use ibv_send_flags */
struct ibv_mw_bind_info      bind_info;       /* MW bind information */
}
```

```
struct ibv_mw_bind_info {
struct ibv_mr                *mr;             /* The MR to bind the MW to */
uint64_t                     addr;            /* The address the MW should start at */
uint64_t                     length;          /* The length (in bytes) the MW should span */
unsigned int                 mw_access_flags; /* Access flags to the MW. Use ibv_access_flags */
};
```

The QP Transport Service Type must be either UC, RC or XRC\_SEND for bind operations.

The attribute send\_flags describes the properties of the WR. It is either 0 or the bitwise OR of one or more of the following flags:

- **IBV\_SEND\_FENCE Set the fence indicator.**

  - **IBV\_SEND\_SIGNALED Set the completion notification indicator. Relevant only if QP was created with sq\_sig\_all=0**

  The mw\_access\_flags define the allowed access to the MW after the bind completes successfully. It is either 0 or the bitwise OR of one or more of the following flags:

- **IBV\_ACCESS\_REMOTE\_WRITE Enable Remote Write Access. Requires local write access to the MR.**

  - **IBV\_ACCESS\_REMOTE\_READ Enable Remote Read Access**

  - **IBV\_ACCESS\_REMOTE\_ATOMIC Enable Remote Atomic Operation Access (if supported). Requires local write access to the MR.**

  - **IBV\_ACCESS\_ZERO\_BASED If set, the address set on the 'remote\_addr' field on the WR will be an offset from the MW's start address.**

  ## RETURN VALUE

**ibv\_bind\_mw()** returns 0 on success, or the value of errno on failure (which indicates the failure reason).  In case of a success, the R\_key of the memory window after the bind is returned in the mw\_bind-\>mw-\>rkey field.

## NOTES

The bind does not complete when the function return - it is merely posted to the QP. The user should keep a copy of the old R\_key, and fix the mw structure if the subsequent CQE for the bind operation indicates a failure. The user may safely send the R\_key using a send request on the same QP, (based on QP ordering rules: a send after a bind request on the same QP are always ordered), but must not transfer it to the remote in any other manner before reading a successful CQE.

Note that for type 2 MW, one should directly post bind WR to the QP, using ibv\_post\_send.

## SEE ALSO

[**ibv\_alloc\_mw**(3)](/ibv_alloc_mw/3.md), [**ibv\_post\_send**(3)](/ibv_post_send/3.md), [**ibv\_poll\_cq**(3)](/ibv_poll_cq/3.md) [**ibv\_reg\_mr**(3)](/ibv_reg_mr/3.md),

## AUTHORS

- Majd Dibbiny \<majd@mellanox.com\>

  - Yishai Hadas \<yishaih@mellanox.com\>
