mlx5dv_devx_umem..._devx_umem_dereg(3)
π mlx5dv_devx_umem_reg / mlx5dv_devx_umem_reg_ex / mlx5dv_devx_umem_dereg
okay so bestie, you're in the mlx5dv section 3 pages, and this one is literally all about registering user memory so the devx interface can use it β¨ stay with me, it's actually so clean once you get it.
πΈ NAME
mlx5dv_devx_umem_regβ register a user memory to be used by the devx interfacemlx5dv_devx_umem_reg_exβ register a user memory to be used by the devx interface (yes, the fancy one π)mlx5dv_devx_umem_deregβ deregister a devx umem object
β¨ SYNOPSIS
#include <infiniband/mlx5dv.h>
struct mlx5dv_devx_umem {
uint32_t umem_id;
};
struct mlx5dv_devx_umem *
mlx5dv_devx_umem_reg(struct ibv_context *context, void *addr, size_t size,
uint32_t access)
struct mlx5dv_devx_umem_in {
void *addr;
size_t size;
uint32_t access;
uint64_t pgsz_bitmap;
uint64_t comp_mask;
int dmabuf_fd;
};
struct mlx5dv_devx_umem *
mlx5dv_devx_umem_reg_ex(struct ibv_context *ctx, struct mlx5dv_devx_umem_in *umem_in);
int mlx5dv_devx_umem_dereg(struct mlx5dv_devx_umem *dv_devx_umem)
π¦ DESCRIPTION
So basically: you're registering (or deregistering) a chunk of user memory so the devx interface can play with it. That's the whole vibe.
The register verb exposes a UMEM DEVX object for user memory registration for DMA π and the way it works is: the API takes your user address, length and access flags as input, and hands you back an object as output β that object holds the UMEM ID that the firmware returned for this registered memory. iconic behavior honestly.
Now, if you want to ask for specific page sizes for the given address and length? That's the "I have opinions" path, and for that you should use mlx5dv_devx_umem_reg_ex() π. But heads up: if the kernel couldn't find a matching page size from the given umem_in->pgsz_bitmap bitmap, the API will fail. no cap.
Then you take that UMEM ID and use it in device direct commands that use this memory instead of the physical addresses list β for example when you call mlx5dv_devx_obj_create to create a QP. that's the moment, that's the whole point π
.
π§ ARGUMENTS
contextβ RDMA device context to create the action on. the main character of this whole operation.addrβ The memory start address to register. where your memory starts, obvi.sizeβ The size of addr buffer. how much of it we're talking about.accessβ The desired memory protection attributes; it is either0or the bitwise OR of one or more ofenum ibv_access_flags. pick your permissions, babe.umem_inβ A structure that holds the argument bundle π (the whole little package of args).
and inside that struct:
pgsz_bitmapβ Represents the required page sizes. umem creation will fail if it cannot be created with these page sizes. so likeβ¦ choose wisely πcomp_maskβ Flags indicating the additional fields. the "did you bring extra stuff" flag.dmabuf_fdβ IfMLX5DV_UMEM_MASK_DMABUFis set incomp_maskthen this value must be a FD of a dmabuf. In this mode the dmabuf is used as the backing memory to create the umem out of. The dmabuf must be pinnable. Andaddris interpreted as the starting offset of the dmabuf. π«Ά
fr fr, that last one is a whole mode shift β the dmabuf is the backing memory, addr is just an offset. don't get it twisted.
π RETURN VALUE
Upon success, mlx5dv_devx_umem_reg / mlx5dv_devx_umem_reg_ex will return a new struct mlx5dv_devx_umem object π β on error NULL will be returned and errno will be set. so check your returns, bestie, always.
mlx5dv_devx_umem_dereg returns 0 on success, or the value of errno on failure (which indicates the failure reason). yep, it literally tells you why it's mad π
π SEE ALSO
π AUTHOR
Yishai Hadas <yishaih@mellanox.com>
and that's the page, bestie π β this is the mlx5dv_devx_umem..._devx_umem_dereg(3) page from the mlx5dv manual (the title and the manual name are the same mlx5dv_devx_umem..._devx_umem_dereg(3) string, printed top and bottom of the original, and the date/version line is that same footer), so go register some memory and slay ππ§β¨
π¦ where this page comes from
- alpine 3.24: rdma-core-doc 61.0-r0 Β· GPL-2.0-only OR BSD-2-Clause
- centos-stream 10: rdma-core-devel 62.0-3.el10 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms