1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
12 #ifndef MLX5_MALLOC_ALIGNMENT
14 #define MLX5_MALLOC_ALIGNMENT 8
16 #define MLX5_MALLOC_ALIGNMENT 16
22 /* Memory will be allocated dpends on sys_mem_en. */
23 MLX5_MEM_SYS = 1 << 0,
24 /* Memory should be allocated from system. */
25 MLX5_MEM_RTE = 1 << 1,
26 /* Memory should be allocated from rte hugepage. */
27 MLX5_MEM_ZERO = 1 << 2,
28 /* Memory should be cleared to zero. */
32 * Select the PMD memory allocate preference.
34 * Once sys_mem_en is set, the default memory allocate will from
35 * system only if an explicitly flag is set to order the memory
36 * from rte hugepage memory.
39 * Use system memory or not.
42 void mlx5_malloc_mem_select(uint32_t sys_mem_en);
45 * Dump the PMD memory usage statistic.
48 void mlx5_memory_stat_dump(void);
51 * Memory allocate function.
54 * The bits as enum mlx5_mem_flags defined.
56 * Memory size to be allocated.
60 * The socket memory should allocated.
61 * Valid only when allocate the memory from rte hugepage.
64 * Pointer of the allocated memory, NULL otherwise.
67 void *mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket);
70 * Memory reallocate function.
75 * The memory to be reallocated.
77 * The bits as enum mlx5_mem_flags defined.
79 * Memory size to be allocated.
83 * The socket memory should allocated.
84 * Valid only when allocate the memory from rte hugepage.
87 * Pointer of the allocated memory, NULL otherwise.
91 void *mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
95 * Memory free function.
98 * The memory address to be freed..
101 void mlx5_free(void *addr);