Skip to content

Commit 1b8cbbe

Browse files
committed
mlx5: Add support for DM export DMABUF fd
Add support for DM export DMABUF fd. Upon the allocation flow of the DM the driver may save the pg_off on its internal mlx5_dm structure. This data will be used upon exporting a DMABUF fd for the DM by calling ibv_cmd_export_dmabuf_fd(). Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
1 parent f824da4 commit 1b8cbbe

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

providers/mlx5/mlx5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static const struct verbs_context_ops mlx5_ctx_common_ops = {
177177
.dealloc_dmah = mlx5_dealloc_dmah,
178178
.reg_mr_ex = mlx5_reg_mr_ex,
179179
.query_port_speed = mlx5_query_port_speed,
180+
.dm_export_dmabuf_fd = mlx5_dm_export_dmabuf_fd,
180181
};
181182

182183
static const struct verbs_context_ops mlx5_ctx_cqev1_ops = {

providers/mlx5/mlx5.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ struct mlx5_dm {
645645
void *mmap_va;
646646
void *start_va;
647647
uint64_t remote_va;
648+
off_t pg_off;
648649
};
649650

650651
struct mlx5_mr {
@@ -1268,6 +1269,7 @@ int mlx5_modify_flow_action_esp(struct ibv_flow_action *action,
12681269
struct ibv_dm *mlx5_alloc_dm(struct ibv_context *context,
12691270
struct ibv_alloc_dm_attr *dm_attr);
12701271
int mlx5_free_dm(struct ibv_dm *ibdm);
1272+
int mlx5_dm_export_dmabuf_fd(struct ibv_dm *dm);
12711273
struct ibv_mr *mlx5_reg_dm_mr(struct ibv_pd *pd, struct ibv_dm *ibdm,
12721274
uint64_t dm_offset, size_t length,
12731275
unsigned int acc);

providers/mlx5/verbs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5066,8 +5066,10 @@ static void *dm_mmap(struct ibv_context *context, struct mlx5_dm *mdm,
50665066

50675067
set_command(MLX5_IB_MMAP_DEVICE_MEM, &offset);
50685068
set_extended_index(page_idx, &offset);
5069+
mdm->pg_off = page_size * offset;
5070+
50695071
return mmap(NULL, act_size, PROT_READ | PROT_WRITE, MAP_SHARED,
5070-
context->cmd_fd, page_size * offset);
5072+
context->cmd_fd, mdm->pg_off);
50715073
}
50725074

50735075
static void *_mlx5dv_dm_map_op_addr(struct ibv_dm *dm, uint8_t op)
@@ -5390,6 +5392,11 @@ struct ibv_dm *mlx5_alloc_dm(struct ibv_context *context,
53905392
return mlx5dv_alloc_dm(context, dm_attr, &mlx5_attr);
53915393
}
53925394

5395+
int mlx5_dm_export_dmabuf_fd(struct ibv_dm *ibdm)
5396+
{
5397+
return ibv_cmd_export_dmabuf_fd(ibdm->context, to_mdm(ibdm)->pg_off);
5398+
}
5399+
53935400
struct ibv_counters *mlx5_create_counters(struct ibv_context *context,
53945401
struct ibv_counters_init_attr *init_attr)
53955402
{

0 commit comments

Comments
 (0)