1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2019 Mellanox Technologies, Ltd
5 #ifndef RTE_PMD_MLX5_VDPA_H_
6 #define RTE_PMD_MLX5_VDPA_H_
11 #pragma GCC diagnostic ignored "-Wpedantic"
14 #include <rte_vhost.h>
16 #pragma GCC diagnostic error "-Wpedantic"
19 #include <mlx5_glue.h>
20 #include <mlx5_devx_cmds.h>
22 struct mlx5_vdpa_query_mr {
23 SLIST_ENTRY(mlx5_vdpa_query_mr) next;
26 struct mlx5dv_devx_umem *umem;
27 struct mlx5_devx_obj *mkey;
31 struct mlx5_vdpa_priv {
32 TAILQ_ENTRY(mlx5_vdpa_priv) next;
33 int id; /* vDPA device id. */
34 int vid; /* vhost device id. */
35 struct ibv_context *ctx; /* Device context. */
36 struct rte_vdpa_dev_addr dev_addr;
37 struct mlx5_hca_vdpa_attr caps;
38 uint32_t pdn; /* Protection Domain number. */
40 uint32_t gpa_mkey_index;
41 struct ibv_mr *null_mr;
42 struct rte_vhost_memory *vmem;
43 SLIST_HEAD(mr_list, mlx5_vdpa_query_mr) mr_list;
47 * Release all the prepared memory regions and all their related resources.
50 * The vdpa driver private structure.
52 void mlx5_vdpa_mem_dereg(struct mlx5_vdpa_priv *priv);
55 * Register all the memory regions of the virtio device to the HW and allocate
56 * all their related resources.
59 * The vdpa driver private structure.
62 * 0 on success, a negative errno value otherwise and rte_errno is set.
64 int mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv);
66 #endif /* RTE_PMD_MLX5_VDPA_H_ */