From: Matan Azrad Date: Wed, 29 Jan 2020 12:38:39 +0000 (+0000) Subject: common/mlx5: glue VAR allocation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3e714a9ba74873e898ae67cf6c825b560781c168;p=dpdk.git common/mlx5: glue VAR allocation Virtio access region(VAR) is the UAR that allocated for virtio emulation access. Add rdma-core operations to allocate and free VAR. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko --- diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile index 7110231710..d1de3ec869 100644 --- a/drivers/common/mlx5/Makefile +++ b/drivers/common/mlx5/Makefile @@ -173,6 +173,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh infiniband/mlx5dv.h \ enum MLX5_MMAP_GET_NC_PAGES_CMD \ $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_VAR \ + infiniband/mlx5dv.h \ + func mlx5dv_alloc_var \ + $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ HAVE_ETHTOOL_LINK_MODE_25G \ /usr/include/linux/ethtool.h \ diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build index 76ca7d78b5..3e130cb5d9 100644 --- a/drivers/common/mlx5/meson.build +++ b/drivers/common/mlx5/meson.build @@ -120,6 +120,7 @@ if build 'MLX5DV_DR_DOMAIN_TYPE_FDB' ], [ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h', 'mlx5dv_dr_action_create_push_vlan' ], + [ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ], [ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h', 'SUPPORTED_40000baseKR4_Full' ], [ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h', diff --git a/drivers/common/mlx5/mlx5_glue.c b/drivers/common/mlx5/mlx5_glue.c index 56916367f5..27cf33cdb9 100644 --- a/drivers/common/mlx5/mlx5_glue.c +++ b/drivers/common/mlx5/mlx5_glue.c @@ -1160,6 +1160,30 @@ mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar) #endif } +static struct mlx5dv_var * +mlx5_glue_dv_alloc_var(struct ibv_context *context, uint32_t flags) +{ +#ifdef HAVE_IBV_VAR + return mlx5dv_alloc_var(context, flags); +#else + (void)context; + (void)flags; + errno = ENOTSUP; + return NULL; +#endif +} + +static void +mlx5_glue_dv_free_var(struct mlx5dv_var *var) +{ +#ifdef HAVE_IBV_VAR + mlx5dv_free_var(var); +#else + (void)var; + errno = ENOTSUP; +#endif +} + alignas(RTE_CACHE_LINE_SIZE) const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .version = MLX5_GLUE_VERSION, @@ -1267,4 +1291,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .devx_get_event = mlx5_glue_devx_get_event, .devx_alloc_uar = mlx5_glue_devx_alloc_uar, .devx_free_uar = mlx5_glue_devx_free_uar, + .dv_alloc_var = mlx5_glue_dv_alloc_var, + .dv_free_var = mlx5_glue_dv_free_var, }; diff --git a/drivers/common/mlx5/mlx5_glue.h b/drivers/common/mlx5/mlx5_glue.h index 7d9256ee94..6238b43946 100644 --- a/drivers/common/mlx5/mlx5_glue.h +++ b/drivers/common/mlx5/mlx5_glue.h @@ -93,6 +93,11 @@ struct mlx5dv_devx_async_event_hdr; #define MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA 1 #endif +#ifndef HAVE_IBV_VAR +struct mlx5dv_var { uint32_t page_id; uint32_t length; off_t mmap_off; + uint64_t comp_mask; }; +#endif + /* LIB_GLUE_VERSION must be updated every time this structure is modified. */ struct mlx5_glue { const char *version; @@ -231,6 +236,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_var *(*dv_alloc_var)(struct ibv_context *context, + uint32_t flags); + void (*dv_free_var)(struct mlx5dv_var *var); struct mlx5dv_devx_uar *(*devx_alloc_uar)(struct ibv_context *context, uint32_t flags); void (*devx_free_uar)(struct mlx5dv_devx_uar *devx_uar);