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 depends 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.
41 void mlx5_malloc_mem_select(uint32_t sys_mem_en);
44 * Dump the PMD memory usage statistic.
47 void mlx5_memory_stat_dump(void);
50 * Memory allocate function.
53 * The bits as enum mlx5_mem_flags defined.
55 * Memory size to be allocated.
59 * The socket memory should allocated.
60 * Valid only when allocate the memory from rte hugepage.
63 * Pointer of the allocated memory, NULL otherwise.
66 void *mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket);
69 * Memory reallocate function.
74 * The memory to be reallocated.
76 * The bits as enum mlx5_mem_flags defined.
78 * Memory size to be allocated.
82 * The socket memory should allocated.
83 * Valid only when allocate the memory from rte hugepage.
86 * Pointer of the allocated memory, NULL otherwise.
90 void *mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
94 * Memory free function.
97 * The memory address to be freed..
100 void mlx5_free(void *addr);