numam-dpdk/drivers/vdpa/mlx5/mlx5_vdpa.h
Matan Azrad cc07a42da2 vdpa/mlx5: prepare memory regions
In order to map the guest physical addresses used by the virtio device
guest side to the host physical addresses used by the HW as the host
side, memory regions are created.

By this way, for example, the HW can translate the addresses of the
packets posted by the guest and to take the packets from the correct
place.

The design is to work with single MR which will be configured to the
virtio queues in the HW, hence a lot of direct MRs are grouped to single
indirect MR.

Create functions to prepare and release MRs with all the related
resources that are required for it.

Create a new file mlx5_vdpa_mem.c to manage all the MR related code
in the driver.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2020-02-05 09:51:21 +01:00

67 lines
1.6 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2019 Mellanox Technologies, Ltd
*/
#ifndef RTE_PMD_MLX5_VDPA_H_
#define RTE_PMD_MLX5_VDPA_H_
#include <sys/queue.h>
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <rte_vdpa.h>
#include <rte_vhost.h>
#ifdef PEDANTIC
#pragma GCC diagnostic error "-Wpedantic"
#endif
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
struct mlx5_vdpa_query_mr {
SLIST_ENTRY(mlx5_vdpa_query_mr) next;
void *addr;
uint64_t length;
struct mlx5dv_devx_umem *umem;
struct mlx5_devx_obj *mkey;
int is_indirect;
};
struct mlx5_vdpa_priv {
TAILQ_ENTRY(mlx5_vdpa_priv) next;
int id; /* vDPA device id. */
int vid; /* vhost device id. */
struct ibv_context *ctx; /* Device context. */
struct rte_vdpa_dev_addr dev_addr;
struct mlx5_hca_vdpa_attr caps;
uint32_t pdn; /* Protection Domain number. */
struct ibv_pd *pd;
uint32_t gpa_mkey_index;
struct ibv_mr *null_mr;
struct rte_vhost_memory *vmem;
SLIST_HEAD(mr_list, mlx5_vdpa_query_mr) mr_list;
};
/**
* Release all the prepared memory regions and all their related resources.
*
* @param[in] priv
* The vdpa driver private structure.
*/
void mlx5_vdpa_mem_dereg(struct mlx5_vdpa_priv *priv);
/**
* Register all the memory regions of the virtio device to the HW and allocate
* all their related resources.
*
* @param[in] priv
* The vdpa driver private structure.
*
* @return
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
int mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv);
#endif /* RTE_PMD_MLX5_VDPA_H_ */