IBV_ALLOC_MW(3)

πŸ’– IBV_ALLOC_MW β€” the manual page, but make it cute

okay bestie, welcome to ibv_alloc_mw(3), straight out of the Libibverbs Programmer's Manual. it's the page about memory windows, and honestly? it's giving "small but mighty". let's get into it πŸ’…


✨ NAME ✨

ibv_alloc_mw, ibv_dealloc_mw β€” allocate or deallocate a memory window (MW)


πŸŽ€ SYNOPSIS πŸŽ€

#include <infiniband/verbs.h>

struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd,
                            enum ibv_mw_type type);

int ibv_dealloc_mw(struct ibv_mw *mw);

🌸 DESCRIPTION 🌸

so ibv_alloc_mw() allocates a memory window (MW) that's associated with the protection domain pd. and the MW's type β€” which is either 1 or 2A/2B β€” is type. that's it, that's the whole vibe ✨

ngl the important part: the MW gets created not bound. it's like, a blank canvas, a fresh face, no commitments. for it to actually be useful, the MW has to be bound, and you do that through either ibv_bind_mw (type 1) or a special WR (type 2). once it's bound, the memory window lets RDMA (remote) access happen to a subset of the MR it was bound to β€” queen behaviour honestly πŸ‘‘

and it stays valid until it gets invalidated by one of these three things:

  • the ibv_bind_mw verb with zero length for type 1
  • the IBV_WR_LOCAL_INV/IBV_WR_SEND_WITH_INV WR opcode for type 2
  • deallocation

then ibv_dealloc_mw() β€” it unbinds in case it was previously bound, and deallocates the MW mw. two jobs, one function, we love a multitasker 🫢


⭐ RETURN VALUE ⭐

ibv_alloc_mw() returns a pointer to the allocated MW, or NULL if the request fails. 😭

and bestie, listen β€” the remote key (R_Key) field rkey is used by remote processes to perform Atomic and RDMA operations. this key will be changed during bind operations, no cap. the remote process places this rkey as the rkey field of struct ibv_send_wr passed to the ibv_post_send function. iykyk πŸ”‘

ibv_dealloc_mw() returns 0 on success, or the value of errno on failure (which indicates the failure reason). classic errno moment πŸ™ˆ


πŸ’€ NOTES πŸ’€

ibv_dereg_mr() fails if any memory window is still bound to this MR. so clean up your windows first, okay? don't leave them open like unread texts πŸ“΅

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHORS πŸ‘‘

  • Majd Dibbiny <majd@mellanox.com>
  • Yishai Hadas <yishaih@mellanox.com>

and that's the whole page, bestie!! this one shipped under libibverbs and it's dated 2016-02-02 β€” vintage, iconic, still slaying. go bind a memory window, you've got this πŸ¦‹πŸ’–

πŸ“¦ where this page comes from