From 7b5107bae600750eaaeb6b99c35844b38119f097 Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Wed, 29 Jan 2020 12:38:37 +0000 Subject: [PATCH] common/mlx5: glue UAR allocation The isolated, protected and independent direct access to the HW by multiple processes is implemented via User Access Region (UAR) mechanism. The UAR is part of PCI address space that is mapped for direct access to the HW from the CPU. UAR is comprised of multiple pages, each page containing registers that control the HW operation. UAR mechanism is used to post execution or control requests to the HW. It is used by the HW to enforce protection and isolation between different processes. Add a glue command to allocate and free an UAR. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko --- drivers/common/mlx5/mlx5_glue.c | 25 +++++++++++++++++++++++++ drivers/common/mlx5/mlx5_glue.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/drivers/common/mlx5/mlx5_glue.c b/drivers/common/mlx5/mlx5_glue.c index e4eabdbb03..56916367f5 100644 --- a/drivers/common/mlx5/mlx5_glue.c +++ b/drivers/common/mlx5/mlx5_glue.c @@ -1137,6 +1137,29 @@ mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc, #endif } +static struct mlx5dv_devx_uar * +mlx5_glue_devx_alloc_uar(struct ibv_context *context, uint32_t flags) +{ +#ifdef HAVE_IBV_DEVX_OBJ + return mlx5dv_devx_alloc_uar(context, flags); +#else + (void)context; + (void)flags; + errno = ENOTSUP; + return NULL; +#endif +} + +static void +mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar) +{ +#ifdef HAVE_IBV_DEVX_OBJ + mlx5dv_devx_free_uar(devx_uar); +#else + (void)devx_uar; +#endif +} + alignas(RTE_CACHE_LINE_SIZE) const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .version = MLX5_GLUE_VERSION, @@ -1242,4 +1265,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event, .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd, .devx_get_event = mlx5_glue_devx_get_event, + .devx_alloc_uar = mlx5_glue_devx_alloc_uar, + .devx_free_uar = mlx5_glue_devx_free_uar, }; diff --git a/drivers/common/mlx5/mlx5_glue.h b/drivers/common/mlx5/mlx5_glue.h index 6fc00dde74..7d9256ee94 100644 --- a/drivers/common/mlx5/mlx5_glue.h +++ b/drivers/common/mlx5/mlx5_glue.h @@ -66,6 +66,7 @@ enum mlx5dv_flow_table_type { flow_table_type = 0, }; #ifndef HAVE_IBV_DEVX_OBJ struct mlx5dv_devx_obj; struct mlx5dv_devx_umem { uint32_t umem_id; }; +struct mlx5dv_devx_uar { void *reg_addr; void *base_addr; uint32_t page_id; }; #endif #ifndef HAVE_IBV_DEVX_ASYNC @@ -230,6 +231,9 @@ struct mlx5_glue { int (*dv_destroy_flow)(void *flow); int (*dv_destroy_flow_matcher)(void *matcher); struct ibv_context *(*dv_open_device)(struct ibv_device *device); + struct mlx5dv_devx_uar *(*devx_alloc_uar)(struct ibv_context *context, + uint32_t flags); + void (*devx_free_uar)(struct mlx5dv_devx_uar *devx_uar); struct mlx5dv_devx_obj *(*devx_obj_create) (struct ibv_context *ctx, const void *in, size_t inlen, -- 2.20.1