#include <stdbool.h>
#include <string.h>
-#include "mlx5_common_utils.h"
+#include "mlx5_common_log.h"
+#include "mlx5_common_os.h"
#include "mlx5_malloc.h"
struct mlx5_sys_mem {
* Check if the address belongs to memory seg list.
*
* @param addr
- * Memory address to be ckeced.
+ * Memory address to be checked.
* @param msl
* Memory seg list.
*
* Check if the address belongs to rte memory.
*
* @param addr
- * Memory address to be ckeced.
+ * Memory address to be checked.
*
* @return
* True if it belongs, false otherwise.
mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)
{
void *buf;
- int ret;
-
- ret = posix_memalign(&buf, align, size);
- if (ret) {
- DRV_LOG(ERR,
- "Couldn't allocate buf size=%zu align=%u. Err=%d\n",
- size, align, ret);
+ buf = mlx5_os_malloc(align, size);
+ if (!buf) {
+ DRV_LOG(ERR, "Couldn't allocate buf size=%zu align=%u.",
+ size, align);
return NULL;
}
if (zero)
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;
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;
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;
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;
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);
+ mlx5_os_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);