ibv_reg_mr

Registers or releases a memory region (MR).

Syntax

#include <rdma/verbs.h>
struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,size_t length,enum ibv_access_flags access);
int ibv_dereg_mr(struct ibv_mr *mr);

Description

The ibv_reg_mr() function registers a memory region (MR) associated with the protection domain pd. The MR's starting address is addr and its size is length. The parameter access describes the required memory protection attributes that is either 0 or the bitwise OR of one or more of the following flags:

The attribute wc_flags describes the properties of the work completion. It is either 0 or the bitwise OR of one or more of the following flags:
IBV_ACCESS_LOCAL_WRITE
Enables Local Write Access
IBV_ACCESS_REMOTE_WRITE
Enable Remote Write Access
IBV_ACCESS_REMOTE_READ
Enable Remote Read Access
IBV_ACCESS_REMOTE_ATOMIC
Enable Remote Atomic Operation Access (Not supported)
IBV_ACCESS_MW_BIND
Enable Memory Window Binding(Not supported)

If IBV_ACCESS_REMOTE_WRITE, or IBV_ACCESS_REMOTE_ATOMIC is set, then IBV_ACCESS_LOCAL_WRITE must be set too.

Note: Local read access is always enabled for the MR.

The ibv_dereg_mr() function release the MR mr.

Parameters

pd Specifies the protection domain, struct ibv_pd from ibv_alloc_pd.
addr Specifies the memory base address.
length Specifies the length of memory region in bytes.
access Specifies the access flags.

Return Values

The ibv_reg_mr() function returns a pointer to the registered MR on success, and NULL if the request fails. The local key (L_Key) field lkey is used as the lkey field of struct ibv_sge when posting buffers with ibv_post_* verbs, and the remote key (R_Key) field rkey is used by remote processes to perform RDMA operations. The remote process places this rkey as the rkey field of struct ibv_send_wr passed to the ibv_post_send function.

The ibv_dereg_mr() function returns 0 on success, and the value of errno on failure that indicates the failure reason.

[ Feedback ]