1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
9 #include <rte_mempool.h>
10 #include <rte_malloc.h>
11 #include <rte_errno.h>
13 #include "mlx5_devx_cmds.h"
14 #include "mlx5_common_utils.h"
15 #include "mlx5_common.h"
18 * Initialization routine for run-time dependency on external lib
21 mlx5_glue_constructor(void)
26 * Allocate PD. Given a devx context object
27 * return an mlx5-pd object.
33 * The mlx5_pd if pd is valid, NULL and errno otherwise.
36 mlx5_os_alloc_pd(void *ctx)
38 struct mlx5_pd *ppd = mlx5_malloc(MLX5_MEM_ZERO,
39 sizeof(struct mlx5_pd), 0, SOCKET_ID_ANY);
43 struct mlx5_devx_obj *obj = mlx5_devx_cmd_alloc_pd(ctx);
55 * Release PD. Releases a given mlx5_pd object
61 * Zero if pd is released successfully, negative number otherwise.
64 mlx5_os_dealloc_pd(void *pd)
68 mlx5_devx_cmd_destroy(((struct mlx5_pd *)pd)->obj);
79 * Pointer to memory start address.
81 * Size of the memory to register.
86 * umem on successful registration, NULL and errno otherwise
89 mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
91 struct mlx5_devx_umem *umem;
93 umem = mlx5_malloc(MLX5_MEM_ZERO,
94 (sizeof(*umem)), 0, SOCKET_ID_ANY);
99 umem->umem_hdl = mlx5_glue->devx_umem_reg(ctx, addr, size, access,
101 if (!umem->umem_hdl) {
116 * 0 on successful release, negative number otherwise
119 mlx5_os_umem_dereg(void *pumem)
121 struct mlx5_devx_umem *umem;
128 err = mlx5_glue->devx_umem_dereg(umem->umem_hdl);