Skip to content

Commit

Permalink
UCT/API/IB: Add support for dmabuf registration
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefe committed Oct 7, 2022
1 parent a133f2d commit ee5fa05
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 88 deletions.
6 changes: 5 additions & 1 deletion src/tools/info/tl_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,12 @@ static void print_md_info(uct_component_h component,
size_limit_to_str(0, md_attr.max_alloc));
}
if (md_attr.flags & UCT_MD_FLAG_REG) {
printf("# register: %s, cost: ",
printf("# register: %s",
size_limit_to_str(0, md_attr.max_reg));
if (md_attr.flags & UCT_MD_FLAG_REG_DMABUF) {
printf(", dmabuf");
}
printf(", cost: ");
PRINT_LINEAR_FUNC_NS(&md_attr.reg_cost);
}
if (md_attr.flags & UCT_MD_FLAG_NEED_RKEY) {
Expand Down
7 changes: 6 additions & 1 deletion src/uct/api/uct.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,12 @@ enum {
* MD supports exporting memory keys with another process using the same
* device or attaching to an exported memory key.
*/
UCT_MD_FLAG_EXPORTED_MKEY = UCS_BIT(9)
UCT_MD_FLAG_EXPORTED_MKEY = UCS_BIT(9),

/**
* MD supports registering a dmabuf file descriptor.
*/
UCT_MD_FLAG_REG_DMABUF = UCS_BIT(10)
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/uct/api/uct_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define UCT_MEM_HANDLE_NULL NULL
#define UCT_INVALID_RKEY ((uintptr_t)(-1))
#define UCT_INLINE_API static UCS_F_ALWAYS_INLINE
#define UCT_DMABUF_FD_INVALID -1


/**
Expand Down
43 changes: 42 additions & 1 deletion src/uct/api/v2/uct_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ typedef struct {
* @brief MD memory registration operation flags.
*/
typedef enum {
UCT_MD_MEM_REG_FIELD_FLAGS = UCS_BIT(0)
UCT_MD_MEM_REG_FIELD_FLAGS = UCS_BIT(0),
UCT_MD_MEM_REG_FIELD_DMABUF_FD = UCS_BIT(1),
UCT_MD_MEM_REG_FIELD_DMABUF_OFFSET = UCS_BIT(2)
} uct_md_mem_reg_field_mask_t;


Expand Down Expand Up @@ -378,6 +380,45 @@ typedef struct uct_md_mem_reg_params {
* Operation specific flags, using bits from @ref uct_md_mem_flags_t.
*/
uint64_t flags;

/**
* dmabuf file descriptor of the memory region to register.
*
* If is set (along with its corresponding bit in the field_mask -
* @ref UCT_MD_MEM_REG_FIELD_DMABUF_FD), the memory region will be
* registered using dmabuf mechanism.
* Can be used only if the memory domain supports dmabuf registration by
* returning @ref UCT_MD_FLAG_REG_DMABUF flag from @ref uct_md_query_v2.
*
* When registering memory using dmabuf mechanism, any memory type is supported
* (assuming a valid dmabuf file descriptor could be created).
* Therefore, @ref uct_md_attr_v2_t.reg_mem_types field is not relevant for
* such registrations.
*
* If not set, it's assumed to be @ref UCT_DMABUF_FD_INVALID, and the memory
* region will be registered without using dmabuf mechanism.
*
* More information about dmabuf registration can be found in
* https://01.org/linuxgraphics/gfx-docs/drm/driver-api/dma-buf.html
*/
int dmabuf_fd;

/**
* When @ref uct_md_mem_reg_params_t.dmabuf_fd is provided, this field
* specifies the offset of the region to register relative to the start of
* the underlying dmabuf region.
*
* If not set (along with its corresponding bit in the field_mask -
* @ref UCT_MD_MEM_REG_FIELD_DMABUF_OFFSET) it's assumed to be 0.
*
* @note The value of this field must be equal to the offset of the virtual
* address provided by the address parameter to @ref uct_md_mem_reg_v2 from
* the beginning of the memory region associated with
* @ref uct_md_mem_reg_params_t.dmabuf_fd.
* For example, if the virtual address is equal to the beginning of the
* dmabuf region, then this field must be omitted or set to 0.
*/
size_t dmabuf_offset;
} uct_md_mem_reg_params_t;


Expand Down
Loading

0 comments on commit ee5fa05

Please sign in to comment.