doc: add patch dependency syntax to contributing guide
[dpdk.git] / drivers / common / mlx5 / mlx5_malloc.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4
5 #ifndef MLX5_MALLOC_H_
6 #define MLX5_MALLOC_H_
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 enum mlx5_mem_flags {
13         MLX5_MEM_ANY = 0,
14         /* Memory will be allocated dpends on sys_mem_en. */
15         MLX5_MEM_SYS = 1 << 0,
16         /* Memory should be allocated from system. */
17         MLX5_MEM_RTE = 1 << 1,
18         /* Memory should be allocated from rte hugepage. */
19         MLX5_MEM_ZERO = 1 << 2,
20         /* Memory should be cleared to zero. */
21 };
22
23 /**
24  * Select the PMD memory allocate preference.
25  *
26  * Once sys_mem_en is set, the default memory allocate will from
27  * system only if an explicitly flag is set to order the memory
28  * from rte hugepage memory.
29  *
30  * @param sys_mem_en
31  *   Use system memory or not.
32  */
33 __rte_internal
34 void mlx5_malloc_mem_select(uint32_t sys_mem_en);
35
36 /**
37  * Dump the PMD memory usage statistic.
38  */
39 __rte_internal
40 void mlx5_memory_stat_dump(void);
41
42 /**
43  * Memory allocate function.
44  *
45  * @param flags
46  *   The bits as enum mlx5_mem_flags defined.
47  * @param size
48  *   Memory size to be allocated.
49  * @param align
50  *   Memory alignment.
51  * @param socket
52  *   The socket memory should allocated.
53  *   Valid only when allocate the memory from rte hugepage.
54  *
55  * @return
56  *   Pointer of the allocated memory, NULL otherwise.
57  */
58 __rte_internal
59 void *mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket);
60
61 /**
62  * Memory reallocate function.
63  *
64  *
65  *
66  * @param addr
67  *   The memory to be reallocated.
68  * @param flags
69  *   The bits as enum mlx5_mem_flags defined.
70  * @param size
71  *   Memory size to be allocated.
72  * @param align
73  *   Memory alignment.
74  * @param socket
75  *   The socket memory should allocated.
76  *   Valid only when allocate the memory from rte hugepage.
77  *
78  * @return
79  *   Pointer of the allocated memory, NULL otherwise.
80  */
81
82 __rte_internal
83 void *mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
84                    int socket);
85
86 /**
87  * Memory free function.
88  *
89  * @param addr
90  *   The memory address to be freed..
91  */
92 __rte_internal
93 void mlx5_free(void *addr);
94
95 #ifdef __cplusplus
96 }
97 #endif
98
99 #endif