eal: move cache line and IOVA related definitions
[dpdk.git] / lib / librte_eal / common / include / rte_memory.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _RTE_MEMORY_H_
6 #define _RTE_MEMORY_H_
7
8 /**
9  * @file
10  *
11  * Memory-related RTE API.
12  */
13
14 #include <stdint.h>
15 #include <stddef.h>
16 #include <stdio.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #include <rte_common.h>
23 #include <rte_compat.h>
24 #include <rte_config.h>
25 #include <rte_fbarray.h>
26
27 __extension__
28 enum rte_page_sizes {
29         RTE_PGSIZE_4K    = 1ULL << 12,
30         RTE_PGSIZE_64K   = 1ULL << 16,
31         RTE_PGSIZE_256K  = 1ULL << 18,
32         RTE_PGSIZE_2M    = 1ULL << 21,
33         RTE_PGSIZE_16M   = 1ULL << 24,
34         RTE_PGSIZE_256M  = 1ULL << 28,
35         RTE_PGSIZE_512M  = 1ULL << 29,
36         RTE_PGSIZE_1G    = 1ULL << 30,
37         RTE_PGSIZE_4G    = 1ULL << 32,
38         RTE_PGSIZE_16G   = 1ULL << 34,
39 };
40
41 #define SOCKET_ID_ANY -1                    /**< Any NUMA socket. */
42
43 /**
44  * Physical memory segment descriptor.
45  */
46 #define RTE_MEMSEG_FLAG_DO_NOT_FREE (1 << 0)
47 /**< Prevent this segment from being freed back to the OS. */
48 struct rte_memseg {
49         RTE_STD_C11
50         union {
51                 phys_addr_t phys_addr;  /**< deprecated - Start physical address. */
52                 rte_iova_t iova;        /**< Start IO address. */
53         };
54         RTE_STD_C11
55         union {
56                 void *addr;         /**< Start virtual address. */
57                 uint64_t addr_64;   /**< Makes sure addr is always 64 bits */
58         };
59         size_t len;               /**< Length of the segment. */
60         uint64_t hugepage_sz;       /**< The pagesize of underlying memory */
61         int32_t socket_id;          /**< NUMA socket ID. */
62         uint32_t nchannel;          /**< Number of channels. */
63         uint32_t nrank;             /**< Number of ranks. */
64         uint32_t flags;             /**< Memseg-specific flags */
65 } __rte_packed;
66
67 /**
68  * memseg list is a special case as we need to store a bunch of other data
69  * together with the array itself.
70  */
71 struct rte_memseg_list {
72         RTE_STD_C11
73         union {
74                 void *base_va;
75                 /**< Base virtual address for this memseg list. */
76                 uint64_t addr_64;
77                 /**< Makes sure addr is always 64-bits */
78         };
79         uint64_t page_sz; /**< Page size for all memsegs in this list. */
80         int socket_id; /**< Socket ID for all memsegs in this list. */
81         volatile uint32_t version; /**< version number for multiprocess sync. */
82         size_t len; /**< Length of memory area covered by this memseg list. */
83         unsigned int external; /**< 1 if this list points to external memory */
84         struct rte_fbarray memseg_arr;
85 };
86
87 /**
88  * Lock page in physical memory and prevent from swapping.
89  *
90  * @param virt
91  *   The virtual address.
92  * @return
93  *   0 on success, negative on error.
94  */
95 int rte_mem_lock_page(const void *virt);
96
97 /**
98  * Get physical address of any mapped virtual address in the current process.
99  * It is found by browsing the /proc/self/pagemap special file.
100  * The page must be locked.
101  *
102  * @param virt
103  *   The virtual address.
104  * @return
105  *   The physical address or RTE_BAD_IOVA on error.
106  */
107 phys_addr_t rte_mem_virt2phy(const void *virt);
108
109 /**
110  * Get IO virtual address of any mapped virtual address in the current process.
111  *
112  * @param virt
113  *   The virtual address.
114  * @return
115  *   The IO address or RTE_BAD_IOVA on error.
116  */
117 rte_iova_t rte_mem_virt2iova(const void *virt);
118
119 /**
120  * Get virtual memory address corresponding to iova address.
121  *
122  * @note This function read-locks the memory hotplug subsystem, and thus cannot
123  *       be used within memory-related callback functions.
124  *
125  * @param iova
126  *   The iova address.
127  * @return
128  *   Virtual address corresponding to iova address (or NULL if address does not
129  *   exist within DPDK memory map).
130  */
131 __rte_experimental
132 void *
133 rte_mem_iova2virt(rte_iova_t iova);
134
135 /**
136  * Get memseg to which a particular virtual address belongs.
137  *
138  * @param virt
139  *   The virtual address.
140  * @param msl
141  *   The memseg list in which to look up based on ``virt`` address
142  *   (can be NULL).
143  * @return
144  *   Memseg pointer on success, or NULL on error.
145  */
146 __rte_experimental
147 struct rte_memseg *
148 rte_mem_virt2memseg(const void *virt, const struct rte_memseg_list *msl);
149
150 /**
151  * Get memseg list corresponding to virtual memory address.
152  *
153  * @param virt
154  *   The virtual address.
155  * @return
156  *   Memseg list to which this virtual address belongs to.
157  */
158 __rte_experimental
159 struct rte_memseg_list *
160 rte_mem_virt2memseg_list(const void *virt);
161
162 /**
163  * Memseg walk function prototype.
164  *
165  * Returning 0 will continue walk
166  * Returning 1 will stop the walk
167  * Returning -1 will stop the walk and report error
168  */
169 typedef int (*rte_memseg_walk_t)(const struct rte_memseg_list *msl,
170                 const struct rte_memseg *ms, void *arg);
171
172 /**
173  * Memseg contig walk function prototype. This will trigger a callback on every
174  * VA-contiguous area starting at memseg ``ms``, so total valid VA space at each
175  * callback call will be [``ms->addr``, ``ms->addr + len``).
176  *
177  * Returning 0 will continue walk
178  * Returning 1 will stop the walk
179  * Returning -1 will stop the walk and report error
180  */
181 typedef int (*rte_memseg_contig_walk_t)(const struct rte_memseg_list *msl,
182                 const struct rte_memseg *ms, size_t len, void *arg);
183
184 /**
185  * Memseg list walk function prototype. This will trigger a callback on every
186  * allocated memseg list.
187  *
188  * Returning 0 will continue walk
189  * Returning 1 will stop the walk
190  * Returning -1 will stop the walk and report error
191  */
192 typedef int (*rte_memseg_list_walk_t)(const struct rte_memseg_list *msl,
193                 void *arg);
194
195 /**
196  * Walk list of all memsegs.
197  *
198  * @note This function read-locks the memory hotplug subsystem, and thus cannot
199  *       be used within memory-related callback functions.
200  *
201  * @note This function will also walk through externally allocated segments. It
202  *       is up to the user to decide whether to skip through these segments.
203  *
204  * @param func
205  *   Iterator function
206  * @param arg
207  *   Argument passed to iterator
208  * @return
209  *   0 if walked over the entire list
210  *   1 if stopped by the user
211  *   -1 if user function reported error
212  */
213 __rte_experimental
214 int
215 rte_memseg_walk(rte_memseg_walk_t func, void *arg);
216
217 /**
218  * Walk each VA-contiguous area.
219  *
220  * @note This function read-locks the memory hotplug subsystem, and thus cannot
221  *       be used within memory-related callback functions.
222  *
223  * @note This function will also walk through externally allocated segments. It
224  *       is up to the user to decide whether to skip through these segments.
225  *
226  * @param func
227  *   Iterator function
228  * @param arg
229  *   Argument passed to iterator
230  * @return
231  *   0 if walked over the entire list
232  *   1 if stopped by the user
233  *   -1 if user function reported error
234  */
235 __rte_experimental
236 int
237 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg);
238
239 /**
240  * Walk each allocated memseg list.
241  *
242  * @note This function read-locks the memory hotplug subsystem, and thus cannot
243  *       be used within memory-related callback functions.
244  *
245  * @note This function will also walk through externally allocated segments. It
246  *       is up to the user to decide whether to skip through these segments.
247  *
248  * @param func
249  *   Iterator function
250  * @param arg
251  *   Argument passed to iterator
252  * @return
253  *   0 if walked over the entire list
254  *   1 if stopped by the user
255  *   -1 if user function reported error
256  */
257 __rte_experimental
258 int
259 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg);
260
261 /**
262  * Walk list of all memsegs without performing any locking.
263  *
264  * @note This function does not perform any locking, and is only safe to call
265  *       from within memory-related callback functions.
266  *
267  * @param func
268  *   Iterator function
269  * @param arg
270  *   Argument passed to iterator
271  * @return
272  *   0 if walked over the entire list
273  *   1 if stopped by the user
274  *   -1 if user function reported error
275  */
276 __rte_experimental
277 int
278 rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg);
279
280 /**
281  * Walk each VA-contiguous area without performing any locking.
282  *
283  * @note This function does not perform any locking, and is only safe to call
284  *       from within memory-related callback functions.
285  *
286  * @param func
287  *   Iterator function
288  * @param arg
289  *   Argument passed to iterator
290  * @return
291  *   0 if walked over the entire list
292  *   1 if stopped by the user
293  *   -1 if user function reported error
294  */
295 __rte_experimental
296 int
297 rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg);
298
299 /**
300  * Walk each allocated memseg list without performing any locking.
301  *
302  * @note This function does not perform any locking, and is only safe to call
303  *       from within memory-related callback functions.
304  *
305  * @param func
306  *   Iterator function
307  * @param arg
308  *   Argument passed to iterator
309  * @return
310  *   0 if walked over the entire list
311  *   1 if stopped by the user
312  *   -1 if user function reported error
313  */
314 __rte_experimental
315 int
316 rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg);
317
318 /**
319  * Return file descriptor associated with a particular memseg (if available).
320  *
321  * @note This function read-locks the memory hotplug subsystem, and thus cannot
322  *       be used within memory-related callback functions.
323  *
324  * @note This returns an internal file descriptor. Performing any operations on
325  *       this file descriptor is inherently dangerous, so it should be treated
326  *       as read-only for all intents and purposes.
327  *
328  * @param ms
329  *   A pointer to memseg for which to get file descriptor.
330  *
331  * @return
332  *   Valid file descriptor in case of success.
333  *   -1 in case of error, with ``rte_errno`` set to the following values:
334  *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg
335  *     - ENODEV  - ``ms`` fd is not available
336  *     - ENOENT  - ``ms`` is an unused segment
337  *     - ENOTSUP - segment fd's are not supported
338  */
339 __rte_experimental
340 int
341 rte_memseg_get_fd(const struct rte_memseg *ms);
342
343 /**
344  * Return file descriptor associated with a particular memseg (if available).
345  *
346  * @note This function does not perform any locking, and is only safe to call
347  *       from within memory-related callback functions.
348  *
349  * @note This returns an internal file descriptor. Performing any operations on
350  *       this file descriptor is inherently dangerous, so it should be treated
351  *       as read-only for all intents and purposes.
352  *
353  * @param ms
354  *   A pointer to memseg for which to get file descriptor.
355  *
356  * @return
357  *   Valid file descriptor in case of success.
358  *   -1 in case of error, with ``rte_errno`` set to the following values:
359  *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg
360  *     - ENODEV  - ``ms`` fd is not available
361  *     - ENOENT  - ``ms`` is an unused segment
362  *     - ENOTSUP - segment fd's are not supported
363  */
364 __rte_experimental
365 int
366 rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms);
367
368 /**
369  * Get offset into segment file descriptor associated with a particular memseg
370  * (if available).
371  *
372  * @note This function read-locks the memory hotplug subsystem, and thus cannot
373  *       be used within memory-related callback functions.
374  *
375  * @param ms
376  *   A pointer to memseg for which to get file descriptor.
377  * @param offset
378  *   A pointer to offset value where the result will be stored.
379  *
380  * @return
381  *   Valid file descriptor in case of success.
382  *   -1 in case of error, with ``rte_errno`` set to the following values:
383  *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg
384  *     - EINVAL  - ``offset`` pointer was NULL
385  *     - ENODEV  - ``ms`` fd is not available
386  *     - ENOENT  - ``ms`` is an unused segment
387  *     - ENOTSUP - segment fd's are not supported
388  */
389 __rte_experimental
390 int
391 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset);
392
393 /**
394  * Get offset into segment file descriptor associated with a particular memseg
395  * (if available).
396  *
397  * @note This function does not perform any locking, and is only safe to call
398  *       from within memory-related callback functions.
399  *
400  * @param ms
401  *   A pointer to memseg for which to get file descriptor.
402  * @param offset
403  *   A pointer to offset value where the result will be stored.
404  *
405  * @return
406  *   Valid file descriptor in case of success.
407  *   -1 in case of error, with ``rte_errno`` set to the following values:
408  *     - EINVAL  - ``ms`` pointer was NULL or did not point to a valid memseg
409  *     - EINVAL  - ``offset`` pointer was NULL
410  *     - ENODEV  - ``ms`` fd is not available
411  *     - ENOENT  - ``ms`` is an unused segment
412  *     - ENOTSUP - segment fd's are not supported
413  */
414 __rte_experimental
415 int
416 rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
417                 size_t *offset);
418
419 /**
420  * @warning
421  * @b EXPERIMENTAL: this API may change without prior notice
422  *
423  * Register external memory chunk with DPDK.
424  *
425  * @note Using this API is mutually exclusive with ``rte_malloc`` family of
426  *   API's.
427  *
428  * @note This API will not perform any DMA mapping. It is expected that user
429  *   will do that themselves.
430  *
431  * @note Before accessing this memory in other processes, it needs to be
432  *   attached in each of those processes by calling ``rte_extmem_attach`` in
433  *   each other process.
434  *
435  * @param va_addr
436  *   Start of virtual area to register. Must be aligned by ``page_sz``.
437  * @param len
438  *   Length of virtual area to register. Must be aligned by ``page_sz``.
439  * @param iova_addrs
440  *   Array of page IOVA addresses corresponding to each page in this memory
441  *   area. Can be NULL, in which case page IOVA addresses will be set to
442  *   RTE_BAD_IOVA.
443  * @param n_pages
444  *   Number of elements in the iova_addrs array. Ignored if  ``iova_addrs``
445  *   is NULL.
446  * @param page_sz
447  *   Page size of the underlying memory
448  *
449  * @return
450  *   - 0 on success
451  *   - -1 in case of error, with rte_errno set to one of the following:
452  *     EINVAL - one of the parameters was invalid
453  *     EEXIST - memory chunk is already registered
454  *     ENOSPC - no more space in internal config to store a new memory chunk
455  */
456 __rte_experimental
457 int
458 rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
459                 unsigned int n_pages, size_t page_sz);
460
461 /**
462  * @warning
463  * @b EXPERIMENTAL: this API may change without prior notice
464  *
465  * Unregister external memory chunk with DPDK.
466  *
467  * @note Using this API is mutually exclusive with ``rte_malloc`` family of
468  *   API's.
469  *
470  * @note This API will not perform any DMA unmapping. It is expected that user
471  *   will do that themselves.
472  *
473  * @note Before calling this function, all other processes must call
474  *   ``rte_extmem_detach`` to detach from the memory area.
475  *
476  * @param va_addr
477  *   Start of virtual area to unregister
478  * @param len
479  *   Length of virtual area to unregister
480  *
481  * @return
482  *   - 0 on success
483  *   - -1 in case of error, with rte_errno set to one of the following:
484  *     EINVAL - one of the parameters was invalid
485  *     ENOENT - memory chunk was not found
486  */
487 __rte_experimental
488 int
489 rte_extmem_unregister(void *va_addr, size_t len);
490
491 /**
492  * @warning
493  * @b EXPERIMENTAL: this API may change without prior notice
494  *
495  * Attach to external memory chunk registered in another process.
496  *
497  * @note Using this API is mutually exclusive with ``rte_malloc`` family of
498  *   API's.
499  *
500  * @note This API will not perform any DMA mapping. It is expected that user
501  *   will do that themselves.
502  *
503  * @param va_addr
504  *   Start of virtual area to register
505  * @param len
506  *   Length of virtual area to register
507  *
508  * @return
509  *   - 0 on success
510  *   - -1 in case of error, with rte_errno set to one of the following:
511  *     EINVAL - one of the parameters was invalid
512  *     ENOENT - memory chunk was not found
513  */
514 __rte_experimental
515 int
516 rte_extmem_attach(void *va_addr, size_t len);
517
518 /**
519  * @warning
520  * @b EXPERIMENTAL: this API may change without prior notice
521  *
522  * Detach from external memory chunk registered in another process.
523  *
524  * @note Using this API is mutually exclusive with ``rte_malloc`` family of
525  *   API's.
526  *
527  * @note This API will not perform any DMA unmapping. It is expected that user
528  *   will do that themselves.
529  *
530  * @param va_addr
531  *   Start of virtual area to unregister
532  * @param len
533  *   Length of virtual area to unregister
534  *
535  * @return
536  *   - 0 on success
537  *   - -1 in case of error, with rte_errno set to one of the following:
538  *     EINVAL - one of the parameters was invalid
539  *     ENOENT - memory chunk was not found
540  */
541 __rte_experimental
542 int
543 rte_extmem_detach(void *va_addr, size_t len);
544
545 /**
546  * Dump the physical memory layout to a file.
547  *
548  * @note This function read-locks the memory hotplug subsystem, and thus cannot
549  *       be used within memory-related callback functions.
550  *
551  * @param f
552  *   A pointer to a file for output
553  */
554 void rte_dump_physmem_layout(FILE *f);
555
556 /**
557  * Get the total amount of available physical memory.
558  *
559  * @note This function read-locks the memory hotplug subsystem, and thus cannot
560  *       be used within memory-related callback functions.
561  *
562  * @return
563  *    The total amount of available physical memory in bytes.
564  */
565 uint64_t rte_eal_get_physmem_size(void);
566
567 /**
568  * Get the number of memory channels.
569  *
570  * @return
571  *   The number of memory channels on the system. The value is 0 if unknown
572  *   or not the same on all devices.
573  */
574 unsigned rte_memory_get_nchannel(void);
575
576 /**
577  * Get the number of memory ranks.
578  *
579  * @return
580  *   The number of memory ranks on the system. The value is 0 if unknown or
581  *   not the same on all devices.
582  */
583 unsigned rte_memory_get_nrank(void);
584
585 /**
586  * @warning
587  * @b EXPERIMENTAL: this API may change without prior notice
588  *
589  * Check if all currently allocated memory segments are compliant with
590  * supplied DMA address width.
591  *
592  *  @param maskbits
593  *    Address width to check against.
594  */
595 __rte_experimental
596 int rte_mem_check_dma_mask(uint8_t maskbits);
597
598 /**
599  * @warning
600  * @b EXPERIMENTAL: this API may change without prior notice
601  *
602  * Check if all currently allocated memory segments are compliant with
603  * supplied DMA address width. This function will use
604  * rte_memseg_walk_thread_unsafe instead of rte_memseg_walk implying
605  * memory_hotplug_lock will not be acquired avoiding deadlock during
606  * memory initialization.
607  *
608  * This function is just for EAL core memory internal use. Drivers should
609  * use the previous rte_mem_check_dma_mask.
610  *
611  *  @param maskbits
612  *    Address width to check against.
613  */
614 __rte_experimental
615 int rte_mem_check_dma_mask_thread_unsafe(uint8_t maskbits);
616
617 /**
618  * @warning
619  * @b EXPERIMENTAL: this API may change without prior notice
620  *
621  *  Set dma mask to use once memory initialization is done. Previous functions
622  *  rte_mem_check_dma_mask and rte_mem_check_dma_mask_thread_unsafe can not be
623  *  used safely until memory has been initialized.
624  */
625 __rte_experimental
626 void rte_mem_set_dma_mask(uint8_t maskbits);
627
628 /**
629  * Drivers based on uio will not load unless physical
630  * addresses are obtainable. It is only possible to get
631  * physical addresses when running as a privileged user.
632  *
633  * @return
634  *   1 if the system is able to obtain physical addresses.
635  *   0 if using DMA addresses through an IOMMU.
636  */
637 int rte_eal_using_phys_addrs(void);
638
639
640 /**
641  * Enum indicating which kind of memory event has happened. Used by callbacks to
642  * distinguish between memory allocations and deallocations.
643  */
644 enum rte_mem_event {
645         RTE_MEM_EVENT_ALLOC = 0, /**< Allocation event. */
646         RTE_MEM_EVENT_FREE,      /**< Deallocation event. */
647 };
648 #define RTE_MEM_EVENT_CALLBACK_NAME_LEN 64
649 /**< maximum length of callback name */
650
651 /**
652  * Function typedef used to register callbacks for memory events.
653  */
654 typedef void (*rte_mem_event_callback_t)(enum rte_mem_event event_type,
655                 const void *addr, size_t len, void *arg);
656
657 /**
658  * Function used to register callbacks for memory events.
659  *
660  * @note callbacks will happen while memory hotplug subsystem is write-locked,
661  *       therefore some functions (e.g. `rte_memseg_walk()`) will cause a
662  *       deadlock when called from within such callbacks.
663  *
664  * @note mem event callbacks not being supported is an expected error condition,
665  *       so user code needs to handle this situation. In these cases, return
666  *       value will be -1, and rte_errno will be set to ENOTSUP.
667  *
668  * @param name
669  *   Name associated with specified callback to be added to the list.
670  *
671  * @param clb
672  *   Callback function pointer.
673  *
674  * @param arg
675  *   Argument to pass to the callback.
676  *
677  * @return
678  *   0 on successful callback register
679  *   -1 on unsuccessful callback register, with rte_errno value indicating
680  *   reason for failure.
681  */
682 __rte_experimental
683 int
684 rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb,
685                 void *arg);
686
687 /**
688  * Function used to unregister callbacks for memory events.
689  *
690  * @param name
691  *   Name associated with specified callback to be removed from the list.
692  *
693  * @param arg
694  *   Argument to look for among callbacks with specified callback name.
695  *
696  * @return
697  *   0 on successful callback unregister
698  *   -1 on unsuccessful callback unregister, with rte_errno value indicating
699  *   reason for failure.
700  */
701 __rte_experimental
702 int
703 rte_mem_event_callback_unregister(const char *name, void *arg);
704
705
706 #define RTE_MEM_ALLOC_VALIDATOR_NAME_LEN 64
707 /**< maximum length of alloc validator name */
708 /**
709  * Function typedef used to register memory allocation validation callbacks.
710  *
711  * Returning 0 will allow allocation attempt to continue. Returning -1 will
712  * prevent allocation from succeeding.
713  */
714 typedef int (*rte_mem_alloc_validator_t)(int socket_id,
715                 size_t cur_limit, size_t new_len);
716
717 /**
718  * @brief Register validator callback for memory allocations.
719  *
720  * Callbacks registered by this function will be called right before memory
721  * allocator is about to trigger allocation of more pages from the system if
722  * said allocation will bring total memory usage above specified limit on
723  * specified socket. User will be able to cancel pending allocation if callback
724  * returns -1.
725  *
726  * @note callbacks will happen while memory hotplug subsystem is write-locked,
727  *       therefore some functions (e.g. `rte_memseg_walk()`) will cause a
728  *       deadlock when called from within such callbacks.
729  *
730  * @note validator callbacks not being supported is an expected error condition,
731  *       so user code needs to handle this situation. In these cases, return
732  *       value will be -1, and rte_errno will be set to ENOTSUP.
733  *
734  * @param name
735  *   Name associated with specified callback to be added to the list.
736  *
737  * @param clb
738  *   Callback function pointer.
739  *
740  * @param socket_id
741  *   Socket ID on which to watch for allocations.
742  *
743  * @param limit
744  *   Limit above which to trigger callbacks.
745  *
746  * @return
747  *   0 on successful callback register
748  *   -1 on unsuccessful callback register, with rte_errno value indicating
749  *   reason for failure.
750  */
751 __rte_experimental
752 int
753 rte_mem_alloc_validator_register(const char *name,
754                 rte_mem_alloc_validator_t clb, int socket_id, size_t limit);
755
756 /**
757  * @brief Unregister validator callback for memory allocations.
758  *
759  * @param name
760  *   Name associated with specified callback to be removed from the list.
761  *
762  * @param socket_id
763  *   Socket ID on which to watch for allocations.
764  *
765  * @return
766  *   0 on successful callback unregister
767  *   -1 on unsuccessful callback unregister, with rte_errno value indicating
768  *   reason for failure.
769  */
770 __rte_experimental
771 int
772 rte_mem_alloc_validator_unregister(const char *name, int socket_id);
773
774 #ifdef __cplusplus
775 }
776 #endif
777
778 #endif /* _RTE_MEMORY_H_ */