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,int ibv_access_flags access);
int ibv_dereg_mr(struct ibv_mr *mr);

Description

The ibv_reg_mr() function registers a memory region (MR) that is associated with the protection domain, the pd parameter. The starting address of the MR is specified by using the addr parameter and its size is specified by using the length parameter. The access parameter describes the required memory protection attributes that are 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 the IBV_ACCESS_REMOTE_WRITE or IBV_ACCESS_REMOTE_ATOMIC flag is set, the IBV_ACCESS_LOCAL_WRITE flag must also be set.

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

The ibv_dereg_mr() function release the MR.

Parameters

Item Descriptor
pd Specifies the ibv_pd struct for the ibv_alloc_pd() function.
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) lkey field is used by the ibv_sge struct when posting buffers with ibv_post_* verbs, and the remote key (R_Key) rkey field is used by remote processes to run the remote device memory access (RDMA) operations. The remote process places the rkey field in the ibv_send_wr struct that is sent to the ibv_post_send() function.

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