User Manual

Rev 2.1-1.0.6
Mellanox Technologies
113
4.20.1 Query Capabilities
Memory Windows are available if and only the hardware supports it. To verify whether Memory
Windows are available, run
ibv_query_device.
For example:
4.20.2 Allocating Memory Window
Allocating memory window is done by calling the ibv_alloc_mw verb.
4.20.3 Binding Memory Windows
After allocated, memory window should be bound to a registered memory region. Memory
Region should have been registered using the
IBV_ACCESS_MW_BIND access flag.
Binding Memory Window type 1 is done via the
ibv_bind_mw verb.
Binding memory window type 2B is done via the
ibv_post_send verb and a specific
Work Request (WR) with
opcode = IBV_WR_BIND_MW
Prior to binding, please make sure to update the existing rkey.
4.20.4 Invalidating Memory Window
Before rebinding Memory Window type 2, it must be invalidated using the ibv_post_send verb
and a specific WR with
opcode = IBV_WR_LOCAL_INV.
4.20.5 Deallocating Memory Window
Deallocating memory window is done using the ibv_dealloc_mw verb.
truct ibv_device_attr device_attr = {};
ibv_query_device (context, & device_attr);
if (device_attr.device_cap_flags & IBV_DEVICE_MEM_WINDOW ||
device_attr.device_cap_flags & IBV_DEVICE_MW_TYPE_2B) {
/* Memory window is supported */
type_mw = IBV_MW_TYPE_2/ IBV_MW_TYPE_1
mw = ibv_alloc_mw(pd, type_mw);
struct ibv_mw_bind mw_bind;
ret = ibv_bind_mw(qp, mw, &mw_bind);
ibv_inc_rkey(mw->rkey)
ibv_dealloc_mw(mw);