[dpdk-dev] [PATCH v4 26/32] common/mlx5/windows: add OS umem reg/dereg API
Tal Shnaiderman
talshn at nvidia.com
Sun Dec 13 21:49:59 CET 2020
Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They
are equivalent to the Linux implementation.
Signed-off-by: Tal Shnaiderman <talshn at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
---
drivers/common/mlx5/rte_common_mlx5_exports.def | 2 +
drivers/common/mlx5/windows/mlx5_common_os.c | 60 +++++++++++++++++++++++++
drivers/common/mlx5/windows/mlx5_common_os.h | 2 +
3 files changed, 64 insertions(+)
diff --git a/drivers/common/mlx5/rte_common_mlx5_exports.def b/drivers/common/mlx5/rte_common_mlx5_exports.def
index 5db1eaa48c..1eabe29a58 100644
--- a/drivers/common/mlx5/rte_common_mlx5_exports.def
+++ b/drivers/common/mlx5/rte_common_mlx5_exports.def
@@ -63,3 +63,5 @@ EXPORTS
mlx5_free
mlx5_os_alloc_pd
mlx5_os_dealloc_pd
+ mlx5_os_umem_reg
+ mlx5_os_umem_dereg
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c
index 85537b6739..cbb09906bd 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.c
+++ b/drivers/common/mlx5/windows/mlx5_common_os.c
@@ -70,3 +70,63 @@ mlx5_os_dealloc_pd(void *pd)
mlx5_free(pd);
return 0;
}
+
+/**
+ * Register umem.
+ *
+ * @param[in] ctx
+ * Pointer to context.
+ * @param[in] addr
+ * Pointer to memory start address.
+ * @param[in] size
+ * Size of the memory to register.
+ * @param[out] access
+ * UMEM access type
+ *
+ * @return
+ * umem on successful registration, NULL and errno otherwise
+ */
+void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+ struct mlx5_devx_umem *umem;
+
+ umem = mlx5_malloc(MLX5_MEM_ZERO,
+ (sizeof(*umem)), 0, SOCKET_ID_ANY);
+ if (!umem) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ umem->umem_hdl = mlx5_glue->devx_umem_reg(ctx, addr, size, access,
+ &umem->umem_id);
+ if (!umem->umem_hdl) {
+ mlx5_free(umem);
+ return NULL;
+ }
+ umem->addr = addr;
+ return umem;
+}
+
+/**
+ * Deregister umem.
+ *
+ * @param[in] pumem
+ * Pointer to umem.
+ *
+ * @return
+ * 0 on successful release, negative number otherwise
+ */
+int
+mlx5_os_umem_dereg(void *pumem)
+{
+ struct mlx5_devx_umem *umem;
+ int err = 0;
+
+ if (!pumem)
+ return err;
+ umem = pumem;
+ if (umem->umem_hdl)
+ err = mlx5_glue->devx_umem_dereg(umem->umem_hdl);
+ mlx5_free(umem);
+ return err;
+}
diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h
index f47351ec41..decb5acd45 100644
--- a/drivers/common/mlx5/windows/mlx5_common_os.h
+++ b/drivers/common/mlx5/windows/mlx5_common_os.h
@@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem)
void *mlx5_os_alloc_pd(void *ctx);
int mlx5_os_dealloc_pd(void *pd);
+void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access);
+int mlx5_os_umem_dereg(void *pumem);
#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
--
2.16.1.windows.4
More information about the dev
mailing list