| 1 |
.\" -*- nroff -*- |
| 2 |
.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md |
| 3 |
.\" |
| 4 |
.TH IBV_ALLOC_DM 3 2017-07-25 libibverbs "Libibverbs Programmer's Manual" |
| 5 |
.SH "NAME" |
| 6 |
ibv_alloc_dm, ibv_free_dm, ibv_memcpy_to/from_dm \- allocate or free a device memory buffer (DMs) and perform memory copy to or |
| 7 |
from it |
| 8 |
.SH "SYNOPSIS" |
| 9 |
.nf |
| 10 |
.B #include <infiniband/verbs.h> |
| 11 |
.sp |
| 12 |
.BI "struct ibv_dm *ibv_alloc_dm(struct ibv_context " "*context", |
| 13 |
.BI " struct ibv_alloc_dm_attr " "*attr"); |
| 14 |
.sp |
| 15 |
.BI "int ibv_free_dm(struct ibv_dm " "*dm"); |
| 16 |
.fi |
| 17 |
.SH "DESCRIPTION" |
| 18 |
.B ibv_alloc_dm() |
| 19 |
allocates a device memory buffer for the RDMA device context |
| 20 |
.I context\fR. |
| 21 |
The argument |
| 22 |
.I attr |
| 23 |
is a pointer to an ibv_alloc_dm_attr struct, as defined in <infiniband/verbs.h>. |
| 24 |
.PP |
| 25 |
.B ibv_free_dm() |
| 26 |
free the device memory buffer |
| 27 |
.I dm\fR. |
| 28 |
.PP |
| 29 |
.nf |
| 30 |
struct ibv_alloc_dm_attr { |
| 31 |
.in +8 |
| 32 |
size_t length; /* Length of desired device memory buffer */ |
| 33 |
uint32_t log_align_req; /* Log base 2 of address alignment requirement */ |
| 34 |
uint32_t comp_mask; /* Compatibility mask that defines which of the following variables are valid */ |
| 35 |
.in -8 |
| 36 |
}; |
| 37 |
|
| 38 |
Address alignment may be required in cases where RDMA atomic operations will be performed using the device memory. |
| 39 |
.PP |
| 40 |
In such cases, the user may specify the device memory start address alignment using the log_align_req parameter |
| 41 |
.PP |
| 42 |
in the allocation attributes struct. |
| 43 |
.PP |
| 44 |
.SH "Accessing an allocated device memory" |
| 45 |
.nf |
| 46 |
In order to perform a write/read memory access to an allocated device memory, a user could use the ibv_memcpy_to_dm |
| 47 |
and ibv_memcpy_from_dm calls respectively. |
| 48 |
.sp |
| 49 |
.BI "int ibv_memcpy_to_dm(struct ibv_dm " "*dm" ", uint64_t " "dm_offset", |
| 50 |
.BI " void " "*host_addr" ", size_t " "length" "); |
| 51 |
.sp |
| 52 |
.BI "int ibv_memcpy_from_dm(void " "*host_addr" ", struct ibv_dm " "*dm" ", |
| 53 |
.BI " uint64_t " "dm_offset" ", size_t " "length" "); |
| 54 |
.sp |
| 55 |
.I dm_offest |
| 56 |
is the byte offset from the beginning of the allocated device memory buffer to access. |
| 57 |
.sp |
| 58 |
.I host_addr |
| 59 |
is the host memory buffer address to access. |
| 60 |
.sp |
| 61 |
.I length |
| 62 |
is the copy length in bytes. |
| 63 |
.sp |
| 64 |
.fi |
| 65 |
.SH "Device memory registration" |
| 66 |
.nf |
| 67 |
User may register the allocated device memory as a memory region and use the lkey/rkey inside sge when posting receive |
| 68 |
or sending work request. This type of MR is defined as zero based and therefore any reference to it (specifically in sge) |
| 69 |
is done with a byte offset from the beginning of the region. |
| 70 |
.sp |
| 71 |
This type of registration is done using ibv_reg_dm_mr. |
| 72 |
.sp |
| 73 |
.BI "struct ibv_mr* ibv_reg_dm_mr(struct ibv_pd " "*pd" ", struct ibv_dm " "*dm" ", uint64_t " "dm_offset", |
| 74 |
.BI " size_t " "length" ", uint32_t " "access"); |
| 75 |
.sp |
| 76 |
.I pd |
| 77 |
the associated pd for this registration. |
| 78 |
.sp |
| 79 |
.I dm |
| 80 |
the associated dm for this registration. |
| 81 |
.sp |
| 82 |
.I dm_offest |
| 83 |
is the byte offset from the beginning of the allocated device memory buffer to register. |
| 84 |
.sp |
| 85 |
.I length |
| 86 |
the memory length to register. |
| 87 |
.sp |
| 88 |
.I access |
| 89 |
mr access flags (Use enum ibv_access_flags). For this type of registration, user must set the IBV_ACCESS_ZERO_BASED |
| 90 |
flag. |
| 91 |
|
| 92 |
.SH "RETURN VALUE" |
| 93 |
.B ibv_alloc_dm() |
| 94 |
returns a pointer to an ibv_dm struct or NULL if the request fails. |
| 95 |
The output dm contains the handle which could be used by user to import this device memory. |
| 96 |
.PP |
| 97 |
.B ibv_free_dm() |
| 98 |
returns 0 on success, or the value of errno on failure (which indicates the failure reason). |
| 99 |
.PP |
| 100 |
.B ibv_reg_dm_mr() |
| 101 |
returns a pointer to an ibv_mr struct on success or NULL if request fails. |
| 102 |
.PP |
| 103 |
.B ibv_memcpy_to_dm()/ibv_memcpy_from_dm() |
| 104 |
returns 0 on success or the failure reason value on failure. |
| 105 |
.SH "NOTES" |
| 106 |
.B ibv_alloc_dm() |
| 107 |
may fail if device has no more free device memory left, where the maximum amount of allocated memory is provided by the |
| 108 |
.I max_dm_size\fR attribute in |
| 109 |
.I ibv_device_attr_ex\fR struct. |
| 110 |
.B ibv_free_dm() |
| 111 |
may fail if any other resources (such as an MR) is still associated with the DM being |
| 112 |
freed. |
| 113 |
.SH "SEE ALSO" |
| 114 |
.BR ibv_query_device_ex (3), |
| 115 |
.SH "AUTHORS" |
| 116 |
.TP |
| 117 |
Ariel Levkovich <[email protected]> |