common/mlx5: add glue function for domain sync
authorBing Zhao <bingz@nvidia.com>
Tue, 27 Oct 2020 14:46:53 +0000 (22:46 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:35:04 +0000 (23:35 +0100)
In rdma-core, the "mlx5dv_dr_domain_sync" function was already
provided. It is used to flush the rule submission queue. The wrapper
function in the glue layer is added for using this.
It only supports DR flows right now the same as domain creating and
destroying functions.

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/common/mlx5/linux/mlx5_glue.c
drivers/common/mlx5/linux/mlx5_glue.h
drivers/common/mlx5/mlx5_malloc.c

index 47b7e98..4a76902 100644 (file)
@@ -494,6 +494,19 @@ mlx5_glue_dr_destroy_domain(void *domain)
 #endif
 }
 
+static int
+mlx5_glue_dr_sync_domain(void *domain, uint32_t flags)
+{
+#ifdef HAVE_MLX5DV_DR
+       return mlx5dv_dr_domain_sync(domain, flags);
+#else
+       (void)domain;
+       (void)flags;
+       errno = ENOTSUP;
+       return errno;
+#endif
+}
+
 static struct ibv_cq_ex *
 mlx5_glue_dv_create_cq(struct ibv_context *context,
                       struct ibv_cq_init_attr_ex *cq_attr,
@@ -1331,6 +1344,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
        .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
        .dr_create_domain = mlx5_glue_dr_create_domain,
        .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
+       .dr_sync_domain = mlx5_glue_dr_sync_domain,
        .dv_create_cq = mlx5_glue_dv_create_cq,
        .dv_create_wq = mlx5_glue_dv_create_wq,
        .dv_query_device = mlx5_glue_dv_query_device,
index 42b2f61..a5e7fb3 100644 (file)
@@ -224,6 +224,7 @@ struct mlx5_glue {
        void *(*dr_create_domain)(struct ibv_context *ctx,
                                  enum mlx5dv_dr_domain_type domain);
        int (*dr_destroy_domain)(void *domain);
+       int (*dr_sync_domain)(void *domain, uint32_t flags);
        struct ibv_cq_ex *(*dv_create_cq)
                (struct ibv_context *context,
                 struct ibv_cq_init_attr_ex *cq_attr,
index f64c15f..5a3267f 100644 (file)
@@ -187,7 +187,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket)
                mlx5_mem_update_msl(addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
                if (addr)
-                       __atomic_add_fetch(&mlx5_sys_mem->malloc_rte, 1,
+                       __atomic_add_fetch(&mlx5_sys_mem.malloc_rte, 1,
                                           __ATOMIC_RELAXED);
 #endif
                return addr;
@@ -201,7 +201,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket)
                addr = malloc(size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        if (addr)
-               __atomic_add_fetch(&mlx5_sys_mem->malloc_sys, 1,
+               __atomic_add_fetch(&mlx5_sys_mem.malloc_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
        return addr;
@@ -235,7 +235,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
                mlx5_mem_update_msl(new_addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
                if (new_addr)
-                       __atomic_add_fetch(&mlx5_sys_mem->realloc_rte, 1,
+                       __atomic_add_fetch(&mlx5_sys_mem.realloc_rte, 1,
                                           __ATOMIC_RELAXED);
 #endif
                return new_addr;
@@ -248,7 +248,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
        new_addr = realloc(addr, size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        if (new_addr)
-               __atomic_add_fetch(&mlx5_sys_mem->realloc_sys, 1,
+               __atomic_add_fetch(&mlx5_sys_mem.realloc_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
        return new_addr;
@@ -261,13 +261,13 @@ mlx5_free(void *addr)
                return;
        if (!mlx5_mem_is_rte(addr)) {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem->free_sys, 1,
+               __atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
                                   __ATOMIC_RELAXED);
 #endif
                free(addr);
        } else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-               __atomic_add_fetch(&mlx5_sys_mem->free_rte, 1,
+               __atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
                                   __ATOMIC_RELAXED);
 #endif
                rte_free(addr);