ibv_impo...import_mr(3)

πŸ’… ibv_import_mr(3) β€” bestie edition

okay so this page is from the Libibverbs Programmer's Manual, and it's about two lil functions that let you pull a Memory Region into your process from a handle, and then yeet it back out when you're done. no cap, it's giving "shared custody but for kernel objects" πŸŽ€


✨ NAME ✨

ibv_import_mr β€” import an MR from a given ibv_pd

ibv_unimport_mr β€” unimport an MR


🌸 SYNOPSIS 🌸

#include <infiniband/verbs.h>

struct ibv_mr *ibv_import_mr(struct ibv_pd *pd, uint32_t mr_handle);
void ibv_unimport_mr(struct ibv_mr *mr)

πŸ¦‹ DESCRIPTION πŸ¦‹

so ibv_import_mr() hands you back a Memory region (MR) that's associated with the given mr_handle, inside the RDMA context that's associated with the given pd. literally that simple πŸ’–

the input mr_handle value must be a valid kernel handle for an MR object in the associated RDMA context. and like, how do you even get one of those? easy β€” grab it from the original MR by reading its ibv_mr->handle member value. iykyk 🫢

ibv_unimport_mr() is the opposite vibe β€” it unimports the MR. once you're done using the MR, you should call either ibv_dereg_mr() or ibv_unimport_mr(). here's the tea on the difference β˜•:

  • the first one (ibv_dereg_mr()) goes to the kernel to destroy the object
  • the second one (ibv_unimport_mr()) just cleans up whatever is needed / the opposite of the import β€” without calling the kernel
⚠️ okay this part is important, don't skip it: it is the responsibility of the application to coordinate between all the ibv_context(s) that use this MR. once destroy is done, no other process can touch the object except for unimport. all users of the context must collaborate to ensure this. fr fr, no main character energy here β€” this is a team effort πŸ‘‘

πŸŽ€ RETURN VALUE πŸŽ€

ibv_import_mr() returns a pointer to the allocated MR, or NULL if the request fails. (yes bestie, always check for NULL 😭)


πŸ”₯ NOTES πŸ”₯

the addr field in the imported MR is not applicable β€” a NULL value is expected. don't come for it, it's just how it is πŸ’€


🌈 SEE ALSO 🌈

ibv_reg_mr(3), ibv_reg_dm_mr(3), ibv_reg_mr_iova(3), ibv_reg_mr_iova2(3), ibv_dereg_mr(3),


πŸ‘‘ AUTHOR πŸ‘‘

Yishai Hadas <yishaih@mellanox.com>


and that's the whole page, bestie. this icon was brought to you by libibverbs, dated 2020-5-3 β€” go forth and import responsibly πŸ§šβ€β™€οΈπŸ’œ

πŸ“¦ where this page comes from