common/mlx5: glue VAR allocation
authorMatan Azrad <matan@mellanox.com>
Wed, 29 Jan 2020 12:38:39 +0000 (12:38 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 5 Feb 2020 08:51:20 +0000 (09:51 +0100)
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 <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/common/mlx5/Makefile
drivers/common/mlx5/meson.build
drivers/common/mlx5/mlx5_glue.c
drivers/common/mlx5/mlx5_glue.h

index 7110231..d1de3ec 100644 (file)
@@ -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 \
index 76ca7d7..3e130cb 100644 (file)
@@ -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',
index 5691636..27cf33c 100644 (file)
@@ -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,
 };
index 7d9256e..6238b43 100644 (file)
@@ -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);