.TH "rte_memory.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_memory.h
.SH SYNOPSIS
.br
.PP
\fR#include <stdint\&.h>\fP
.br
\fR#include <stddef\&.h>\fP
.br
\fR#include <stdio\&.h>\fP
.br
\fR#include <rte_bitops\&.h>\fP
.br
\fR#include <rte_common\&.h>\fP
.br
\fR#include <rte_config\&.h>\fP
.br
\fR#include <rte_eal_memconfig\&.h>\fP
.br
\fR#include <rte_fbarray\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBrte_memseg\fP"
.br
.ti -1c
.RI "struct \fBrte_memseg_list\fP"
.br
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBSOCKET_ID_ANY\fP   \-1"
.br
.ti -1c
.RI "#define \fBRTE_MEMSEG_FLAG_DO_NOT_FREE\fP   \fBRTE_BIT32\fP(0)"
.br
.ti -1c
.RI "#define \fBRTE_MEMSEG_FLAG_DIRTY\fP   \fBRTE_BIT32\fP(1)"
.br
.ti -1c
.RI "#define \fBRTE_MEM_EVENT_CALLBACK_NAME_LEN\fP   64"
.br
.ti -1c
.RI "#define \fBRTE_MEM_ALLOC_VALIDATOR_NAME_LEN\fP   64"
.br
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "\fBtypedef\fP int(* \fBrte_memseg_walk_t\fP) (const struct \fBrte_memseg_list\fP *msl, const struct \fBrte_memseg\fP *ms, void *arg)"
.br
.ti -1c
.RI "\fBtypedef\fP int(* \fBrte_memseg_contig_walk_t\fP) (const struct \fBrte_memseg_list\fP *msl, const struct \fBrte_memseg\fP *ms, size_t len, void *arg)"
.br
.ti -1c
.RI "\fBtypedef\fP int(* \fBrte_memseg_list_walk_t\fP) (const struct \fBrte_memseg_list\fP *msl, void *arg)"
.br
.ti -1c
.RI "\fBtypedef\fP void(* \fBrte_mem_event_callback_t\fP) (enum \fBrte_mem_event\fP event_type, const void *addr, size_t len, void *arg)"
.br
.ti -1c
.RI "\fBtypedef\fP int(* \fBrte_mem_alloc_validator_t\fP) (int socket_id, size_t cur_limit, size_t new_len)"
.br
.in -1c
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBrte_mem_event\fP { \fBRTE_MEM_EVENT_ALLOC\fP = 0, \fBRTE_MEM_EVENT_FREE\fP }"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBrte_mem_lock_page\fP (const void *virt)"
.br
.ti -1c
.RI "\fBphys_addr_t\fP \fBrte_mem_virt2phy\fP (const void *virt)"
.br
.ti -1c
.RI "\fBrte_iova_t\fP \fBrte_mem_virt2iova\fP (const void *virt)"
.br
.ti -1c
.RI "void * \fBrte_mem_iova2virt\fP (\fBrte_iova_t\fP iova)"
.br
.ti -1c
.RI "struct \fBrte_memseg\fP * \fBrte_mem_virt2memseg\fP (const void *virt, const struct \fBrte_memseg_list\fP *msl)"
.br
.ti -1c
.RI "struct \fBrte_memseg_list\fP * \fBrte_mem_virt2memseg_list\fP (const void *virt)"
.br
.ti -1c
.RI "int \fBrte_memseg_walk\fP (\fBrte_memseg_walk_t\fP func, void *arg)"
.br
.ti -1c
.RI "int \fBrte_memseg_contig_walk\fP (\fBrte_memseg_contig_walk_t\fP func, void *arg)"
.br
.ti -1c
.RI "int \fBrte_memseg_list_walk\fP (\fBrte_memseg_list_walk_t\fP func, void *arg) __rte_locks_excluded(\fBrte_mcfg_mem_get_lock\fP())"
.br
.ti -1c
.RI "int \fBrte_memseg_walk_thread_unsafe\fP (\fBrte_memseg_walk_t\fP func, void *arg)"
.br
.ti -1c
.RI "int \fBrte_memseg_contig_walk_thread_unsafe\fP (\fBrte_memseg_contig_walk_t\fP func, void *arg)"
.br
.ti -1c
.RI "int \fBrte_memseg_list_walk_thread_unsafe\fP (\fBrte_memseg_list_walk_t\fP func, void *arg)"
.br
.ti -1c
.RI "int \fBrte_memseg_get_fd\fP (const struct \fBrte_memseg\fP *ms)"
.br
.ti -1c
.RI "int \fBrte_memseg_get_fd_thread_unsafe\fP (const struct \fBrte_memseg\fP *ms)"
.br
.ti -1c
.RI "int \fBrte_memseg_get_fd_offset\fP (const struct \fBrte_memseg\fP *ms, size_t *offset)"
.br
.ti -1c
.RI "int \fBrte_memseg_get_fd_offset_thread_unsafe\fP (const struct \fBrte_memseg\fP *ms, size_t *offset)"
.br
.ti -1c
.RI "int \fBrte_extmem_register\fP (void *va_addr, size_t len, \fBrte_iova_t\fP iova_addrs[], unsigned int n_pages, size_t page_sz)"
.br
.ti -1c
.RI "int \fBrte_extmem_unregister\fP (void *va_addr, size_t len)"
.br
.ti -1c
.RI "int \fBrte_extmem_attach\fP (void *va_addr, size_t len)"
.br
.ti -1c
.RI "int \fBrte_extmem_detach\fP (void *va_addr, size_t len)"
.br
.ti -1c
.RI "void \fBrte_dump_physmem_layout\fP (FILE *f)"
.br
.ti -1c
.RI "uint64_t \fBrte_eal_get_physmem_size\fP (void)"
.br
.ti -1c
.RI "unsigned \fBrte_memory_get_nchannel\fP (void)"
.br
.ti -1c
.RI "unsigned \fBrte_memory_get_nrank\fP (void)"
.br
.ti -1c
.RI "int \fBrte_mem_check_dma_mask\fP (uint8_t maskbits)"
.br
.ti -1c
.RI "int \fBrte_mem_check_dma_mask_thread_unsafe\fP (uint8_t maskbits)"
.br
.ti -1c
.RI "void \fBrte_mem_set_dma_mask\fP (uint8_t maskbits)"
.br
.ti -1c
.RI "int \fBrte_eal_using_phys_addrs\fP (void)"
.br
.ti -1c
.RI "int \fBrte_mem_event_callback_register\fP (const char *name, \fBrte_mem_event_callback_t\fP clb, void *arg)"
.br
.ti -1c
.RI "int \fBrte_mem_event_callback_unregister\fP (const char *name, void *arg)"
.br
.ti -1c
.RI "int \fBrte_mem_alloc_validator_register\fP (const char *name, \fBrte_mem_alloc_validator_t\fP clb, int socket_id, size_t limit)"
.br
.RI "Register validator callback for memory allocations\&. "
.ti -1c
.RI "int \fBrte_mem_alloc_validator_unregister\fP (const char *name, int socket_id)"
.br
.RI "Unregister validator callback for memory allocations\&. "
.ti -1c
.RI "__rte_experimental void \fBrte_memzero_explicit\fP (void *dst, size_t sz)"
.br
.ti -1c
.RI "static __rte_experimental bool \fBrte_memeq_timingsafe\fP (const void *a, const void *b, size_t n)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Memory-related RTE API\&. 
.PP
Definition in file \fBrte_memory\&.h\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define SOCKET_ID_ANY   \-1"
Any NUMA socket\&. 
.PP
Definition at line \fB39\fP of file \fBrte_memory\&.h\fP\&.
.SS "#define RTE_MEMSEG_FLAG_DO_NOT_FREE   \fBRTE_BIT32\fP(0)"
Prevent this segment from being freed back to the OS\&. 
.PP
Definition at line \fB42\fP of file \fBrte_memory\&.h\fP\&.
.SS "#define RTE_MEMSEG_FLAG_DIRTY   \fBRTE_BIT32\fP(1)"
This segment is not filled with zeros\&. 
.PP
Definition at line \fB44\fP of file \fBrte_memory\&.h\fP\&.
.SS "#define RTE_MEM_EVENT_CALLBACK_NAME_LEN   64"
maximum length of callback name 
.PP
Definition at line \fB609\fP of file \fBrte_memory\&.h\fP\&.
.SS "#define RTE_MEM_ALLOC_VALIDATOR_NAME_LEN   64"
maximum length of alloc validator name 
.PP
Definition at line \fB665\fP of file \fBrte_memory\&.h\fP\&.
.SH "Typedef Documentation"
.PP 
.SS "\fBtypedef\fP int(* rte_memseg_walk_t) (const struct \fBrte_memseg_list\fP *msl, const struct \fBrte_memseg\fP *ms, void *arg)"
Memseg walk function prototype\&.

.PP
Returning 0 will continue walk Returning 1 will stop the walk Returning -1 will stop the walk and report error 
.PP
Definition at line \fB167\fP of file \fBrte_memory\&.h\fP\&.
.SS "\fBtypedef\fP int(* rte_memseg_contig_walk_t) (const struct \fBrte_memseg_list\fP *msl, const struct \fBrte_memseg\fP *ms, size_t len, void *arg)"
Memseg contig walk function prototype\&. This will trigger a callback on every VA-contiguous area starting at memseg \fRms\fP, so total valid VA space at each callback call will be [\fRms->addr\fP, \fRms->addr + len\fP)\&.

.PP
Returning 0 will continue walk Returning 1 will stop the walk Returning -1 will stop the walk and report error 
.PP
Definition at line \fB179\fP of file \fBrte_memory\&.h\fP\&.
.SS "\fBtypedef\fP int(* rte_memseg_list_walk_t) (const struct \fBrte_memseg_list\fP *msl, void *arg)"
Memseg list walk function prototype\&. This will trigger a callback on every allocated memseg list\&.

.PP
Returning 0 will continue walk Returning 1 will stop the walk Returning -1 will stop the walk and report error 
.PP
Definition at line \fB190\fP of file \fBrte_memory\&.h\fP\&.
.SS "\fBtypedef\fP void(* rte_mem_event_callback_t) (enum \fBrte_mem_event\fP event_type, const void *addr, size_t len, void *arg)"
Function typedef used to register callbacks for memory events\&. 
.PP
Definition at line \fB615\fP of file \fBrte_memory\&.h\fP\&.
.SS "\fBtypedef\fP int(* rte_mem_alloc_validator_t) (int socket_id, size_t cur_limit, size_t new_len)"
Function typedef used to register memory allocation validation callbacks\&.

.PP
Returning 0 will allow allocation attempt to continue\&. Returning -1 will prevent allocation from succeeding\&. 
.PP
Definition at line \fB673\fP of file \fBrte_memory\&.h\fP\&.
.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBrte_mem_event\fP"
Enum indicating which kind of memory event has happened\&. Used by callbacks to distinguish between memory allocations and deallocations\&. 
.PP
\fBEnumerator\fP
.in +1c
.TP
\f(BIRTE_MEM_EVENT_ALLOC \fP
Allocation event\&. 
.TP
\f(BIRTE_MEM_EVENT_FREE \fP
Deallocation event\&. 
.PP
Definition at line \fB605\fP of file \fBrte_memory\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "int rte_mem_lock_page (const void * virt)"
Lock page in physical memory and prevent from swapping\&.

.PP
\fBParameters\fP
.RS 4
\fIvirt\fP The virtual address\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, negative on error\&. 
.RE
.PP

.SS "\fBphys_addr_t\fP rte_mem_virt2phy (const void * virt)"
Get physical address of any mapped virtual address in the current process\&. It is found by browsing the /proc/self/pagemap special file\&. The page must be locked\&.

.PP
\fBParameters\fP
.RS 4
\fIvirt\fP The virtual address\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The physical address or RTE_BAD_IOVA on error\&. 
.RE
.PP

.SS "\fBrte_iova_t\fP rte_mem_virt2iova (const void * virt)"
Get IO virtual address of any mapped virtual address in the current process\&.

.PP
\fBNote\fP
.RS 4
This function will not check internal page table\&. Instead, in IOVA as PA mode, it will fall back to getting real physical address (which may not match the expected IOVA, such as what was specified for external memory)\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIvirt\fP The virtual address\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The IO address or RTE_BAD_IOVA on error\&. 
.RE
.PP

.SS "void * rte_mem_iova2virt (\fBrte_iova_t\fP iova)"
Get virtual memory address corresponding to iova address\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIiova\fP The iova address\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Virtual address corresponding to iova address (or NULL if address does not exist within DPDK memory map)\&. 
.RE
.PP

.SS "struct \fBrte_memseg\fP * rte_mem_virt2memseg (const void * virt, const struct \fBrte_memseg_list\fP * msl)"
Get memseg to which a particular virtual address belongs\&.

.PP
\fBParameters\fP
.RS 4
\fIvirt\fP The virtual address\&. 
.br
\fImsl\fP The memseg list in which to look up based on \fRvirt\fP address (can be NULL)\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Memseg pointer on success, or NULL on error\&. 
.RE
.PP

.SS "struct \fBrte_memseg_list\fP * rte_mem_virt2memseg_list (const void * virt)"
Get memseg list corresponding to virtual memory address\&.

.PP
\fBParameters\fP
.RS 4
\fIvirt\fP The virtual address\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Memseg list to which this virtual address belongs to\&. 
.RE
.PP

.SS "int rte_memseg_walk (\fBrte_memseg_walk_t\fP func, void * arg)"
Walk list of all memsegs\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.

.PP
This function will also walk through externally allocated segments\&. It is up to the user to decide whether to skip through these segments\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_contig_walk (\fBrte_memseg_contig_walk_t\fP func, void * arg)"
Walk each VA-contiguous area\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.

.PP
This function will also walk through externally allocated segments\&. It is up to the user to decide whether to skip through these segments\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_list_walk (\fBrte_memseg_list_walk_t\fP func, void * arg)"
Walk each allocated memseg list\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.

.PP
This function will also walk through externally allocated segments\&. It is up to the user to decide whether to skip through these segments\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_walk_thread_unsafe (\fBrte_memseg_walk_t\fP func, void * arg)"
Walk list of all memsegs without performing any locking\&.

.PP
\fBNote\fP
.RS 4
This function does not perform any locking, and is only safe to call from within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_contig_walk_thread_unsafe (\fBrte_memseg_contig_walk_t\fP func, void * arg)"
Walk each VA-contiguous area without performing any locking\&.

.PP
\fBNote\fP
.RS 4
This function does not perform any locking, and is only safe to call from within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_list_walk_thread_unsafe (\fBrte_memseg_list_walk_t\fP func, void * arg)"
Walk each allocated memseg list without performing any locking\&.

.PP
\fBNote\fP
.RS 4
This function does not perform any locking, and is only safe to call from within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIfunc\fP Iterator function 
.br
\fIarg\fP Argument passed to iterator 
.RE
.PP
\fBReturns\fP
.RS 4
0 if walked over the entire list 1 if stopped by the user -1 if user function reported error 
.RE
.PP

.SS "int rte_memseg_get_fd (const struct \fBrte_memseg\fP * ms)"
Return file descriptor associated with a particular memseg (if available)\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.

.PP
This returns an internal file descriptor\&. Performing any operations on this file descriptor is inherently dangerous, so it should be treated as read-only for all intents and purposes\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIms\fP A pointer to memseg for which to get file descriptor\&.
.RE
.PP
\fBReturns\fP
.RS 4
Valid file descriptor in case of success\&. -1 in case of error, with \fR\fBrte_errno\fP\fP set to the following values:
.IP "\(bu" 2
EINVAL - \fRms\fP pointer was NULL or did not point to a valid memseg
.IP "\(bu" 2
ENODEV - \fRms\fP fd is not available
.IP "\(bu" 2
ENOENT - \fRms\fP is an unused segment
.IP "\(bu" 2
ENOTSUP - segment fd's are not supported 
.PP
.RE
.PP

.SS "int rte_memseg_get_fd_thread_unsafe (const struct \fBrte_memseg\fP * ms)"
Return file descriptor associated with a particular memseg (if available)\&.

.PP
\fBNote\fP
.RS 4
This function does not perform any locking, and is only safe to call from within memory-related callback functions\&.

.PP
This returns an internal file descriptor\&. Performing any operations on this file descriptor is inherently dangerous, so it should be treated as read-only for all intents and purposes\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIms\fP A pointer to memseg for which to get file descriptor\&.
.RE
.PP
\fBReturns\fP
.RS 4
Valid file descriptor in case of success\&. -1 in case of error, with \fR\fBrte_errno\fP\fP set to the following values:
.IP "\(bu" 2
EINVAL - \fRms\fP pointer was NULL or did not point to a valid memseg
.IP "\(bu" 2
ENODEV - \fRms\fP fd is not available
.IP "\(bu" 2
ENOENT - \fRms\fP is an unused segment
.IP "\(bu" 2
ENOTSUP - segment fd's are not supported 
.PP
.RE
.PP

.SS "int rte_memseg_get_fd_offset (const struct \fBrte_memseg\fP * ms, size_t * offset)"
Get offset into segment file descriptor associated with a particular memseg (if available)\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIms\fP A pointer to memseg for which to get file descriptor\&. 
.br
\fIoffset\fP A pointer to offset value where the result will be stored\&.
.RE
.PP
\fBReturns\fP
.RS 4
Valid file descriptor in case of success\&. -1 in case of error, with \fR\fBrte_errno\fP\fP set to the following values:
.IP "\(bu" 2
EINVAL - \fRms\fP pointer was NULL or did not point to a valid memseg
.IP "\(bu" 2
EINVAL - \fRoffset\fP pointer was NULL
.IP "\(bu" 2
ENODEV - \fRms\fP fd is not available
.IP "\(bu" 2
ENOENT - \fRms\fP is an unused segment
.IP "\(bu" 2
ENOTSUP - segment fd's are not supported 
.PP
.RE
.PP

.SS "int rte_memseg_get_fd_offset_thread_unsafe (const struct \fBrte_memseg\fP * ms, size_t * offset)"
Get offset into segment file descriptor associated with a particular memseg (if available)\&.

.PP
\fBNote\fP
.RS 4
This function does not perform any locking, and is only safe to call from within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIms\fP A pointer to memseg for which to get file descriptor\&. 
.br
\fIoffset\fP A pointer to offset value where the result will be stored\&.
.RE
.PP
\fBReturns\fP
.RS 4
Valid file descriptor in case of success\&. -1 in case of error, with \fR\fBrte_errno\fP\fP set to the following values:
.IP "\(bu" 2
EINVAL - \fRms\fP pointer was NULL or did not point to a valid memseg
.IP "\(bu" 2
EINVAL - \fRoffset\fP pointer was NULL
.IP "\(bu" 2
ENODEV - \fRms\fP fd is not available
.IP "\(bu" 2
ENOENT - \fRms\fP is an unused segment
.IP "\(bu" 2
ENOTSUP - segment fd's are not supported 
.PP
.RE
.PP

.SS "int rte_extmem_register (void * va_addr, size_t len, \fBrte_iova_t\fP iova_addrs[], unsigned int n_pages, size_t page_sz)"
Register external memory chunk with DPDK\&.

.PP
\fBNote\fP
.RS 4
Using this API is mutually exclusive with \fR\fBrte_malloc\fP\fP family of API's\&.

.PP
This API will not perform any DMA mapping\&. It is expected that user will do that themselves\&.

.PP
Before accessing this memory in other processes, it needs to be attached in each of those processes by calling \fR\fBrte_extmem_attach\fP\fP in each other process\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIva_addr\fP Start of virtual area to register\&. Must be aligned by \fRpage_sz\fP\&. 
.br
\fIlen\fP Length of virtual area to register\&. Must be aligned by \fRpage_sz\fP\&. 
.br
\fIiova_addrs\fP Array of page IOVA addresses corresponding to each page in this memory area\&. Can be NULL, in which case page IOVA addresses will be set to RTE_BAD_IOVA\&. 
.br
\fIn_pages\fP Number of elements in the iova_addrs array\&. Ignored if \fRiova_addrs\fP is NULL\&. 
.br
\fIpage_sz\fP Page size of the underlying memory
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success
.IP "\(bu" 2
-1 in case of error, with rte_errno set to one of the following: EINVAL - one of the parameters was invalid EEXIST - memory chunk is already registered ENOSPC - no more space in internal config to store a new memory chunk 
.PP
.RE
.PP

.SS "int rte_extmem_unregister (void * va_addr, size_t len)"
Unregister external memory chunk with DPDK\&.

.PP
\fBNote\fP
.RS 4
Using this API is mutually exclusive with \fR\fBrte_malloc\fP\fP family of API's\&.

.PP
This API will not perform any DMA unmapping\&. It is expected that user will do that themselves\&.

.PP
Before calling this function, all other processes must call \fR\fBrte_extmem_detach\fP\fP to detach from the memory area\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIva_addr\fP Start of virtual area to unregister 
.br
\fIlen\fP Length of virtual area to unregister
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success
.IP "\(bu" 2
-1 in case of error, with rte_errno set to one of the following: EINVAL - one of the parameters was invalid ENOENT - memory chunk was not found 
.PP
.RE
.PP

.SS "int rte_extmem_attach (void * va_addr, size_t len)"
Attach to external memory chunk registered in another process\&.

.PP
\fBNote\fP
.RS 4
Using this API is mutually exclusive with \fR\fBrte_malloc\fP\fP family of API's\&.

.PP
This API will not perform any DMA mapping\&. It is expected that user will do that themselves\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIva_addr\fP Start of virtual area to register 
.br
\fIlen\fP Length of virtual area to register
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success
.IP "\(bu" 2
-1 in case of error, with rte_errno set to one of the following: EINVAL - one of the parameters was invalid ENOENT - memory chunk was not found 
.PP
.RE
.PP

.SS "int rte_extmem_detach (void * va_addr, size_t len)"
Detach from external memory chunk registered in another process\&.

.PP
\fBNote\fP
.RS 4
Using this API is mutually exclusive with \fR\fBrte_malloc\fP\fP family of API's\&.

.PP
This API will not perform any DMA unmapping\&. It is expected that user will do that themselves\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIva_addr\fP Start of virtual area to unregister 
.br
\fIlen\fP Length of virtual area to unregister
.RE
.PP
\fBReturns\fP
.RS 4
.IP "\(bu" 2
0 on success
.IP "\(bu" 2
-1 in case of error, with rte_errno set to one of the following: EINVAL - one of the parameters was invalid ENOENT - memory chunk was not found 
.PP
.RE
.PP

.SS "void rte_dump_physmem_layout (FILE * f)"
Dump the physical memory layout to a file\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIf\fP A pointer to a file for output 
.RE
.PP

.SS "uint64_t rte_eal_get_physmem_size (void )"
Get the total amount of available physical memory\&.

.PP
\fBNote\fP
.RS 4
This function read-locks the memory hotplug subsystem, and thus cannot be used within memory-related callback functions\&.
.RE
.PP
\fBReturns\fP
.RS 4
The total amount of available physical memory in bytes\&. 
.RE
.PP

.SS "unsigned rte_memory_get_nchannel (void )"
Get the number of memory channels\&.

.PP
\fBReturns\fP
.RS 4
The number of memory channels on the system\&. The value is 0 if unknown or not the same on all devices\&. 
.RE
.PP

.SS "unsigned rte_memory_get_nrank (void )"
Get the number of memory ranks\&.

.PP
\fBReturns\fP
.RS 4
The number of memory ranks on the system\&. The value is 0 if unknown or not the same on all devices\&. 
.RE
.PP

.SS "int rte_mem_check_dma_mask (uint8_t maskbits)"
Check if all currently allocated memory segments are compliant with supplied DMA address width\&.

.PP
\fBParameters\fP
.RS 4
\fImaskbits\fP Address width to check against\&. 
.RE
.PP

.SS "int rte_mem_check_dma_mask_thread_unsafe (uint8_t maskbits)"
Check if all currently allocated memory segments are compliant with supplied DMA address width\&. This function will use rte_memseg_walk_thread_unsafe instead of rte_memseg_walk implying memory_hotplug_lock will not be acquired avoiding deadlock during memory initialization\&.

.PP
This function is just for EAL core memory internal use\&. Drivers should use the previous rte_mem_check_dma_mask\&.

.PP
\fBParameters\fP
.RS 4
\fImaskbits\fP Address width to check against\&. 
.RE
.PP

.SS "void rte_mem_set_dma_mask (uint8_t maskbits)"
Set dma mask to use once memory initialization is done\&. Previous functions rte_mem_check_dma_mask and rte_mem_check_dma_mask_thread_unsafe can not be used safely until memory has been initialized\&. 
.SS "int rte_eal_using_phys_addrs (void )"
Drivers based on uio will not load unless physical addresses are obtainable\&. It is only possible to get physical addresses when running as a privileged user\&.

.PP
\fBReturns\fP
.RS 4
1 if the system is able to obtain physical addresses\&. 0 if using DMA addresses through an IOMMU\&. 
.RE
.PP

.SS "int rte_mem_event_callback_register (const char * name, \fBrte_mem_event_callback_t\fP clb, void * arg)"
Function used to register callbacks for memory events\&.

.PP
\fBNote\fP
.RS 4
callbacks will happen while memory hotplug subsystem is write-locked, therefore some functions (e\&.g\&. \fR\fBrte_memseg_walk()\fP\fP) will cause a deadlock when called from within such callbacks\&.

.PP
mem event callbacks not being supported is an expected error condition, so user code needs to handle this situation\&. In these cases, return value will be -1, and rte_errno will be set to ENOTSUP\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIname\fP Name associated with specified callback to be added to the list\&.
.br
\fIclb\fP Callback function pointer\&.
.br
\fIarg\fP Argument to pass to the callback\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 on successful callback register -1 on unsuccessful callback register, with rte_errno value indicating reason for failure\&. 
.RE
.PP

.SS "int rte_mem_event_callback_unregister (const char * name, void * arg)"
Function used to unregister callbacks for memory events\&.

.PP
\fBParameters\fP
.RS 4
\fIname\fP Name associated with specified callback to be removed from the list\&.
.br
\fIarg\fP Argument to look for among callbacks with specified callback name\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 on successful callback unregister -1 on unsuccessful callback unregister, with rte_errno value indicating reason for failure\&. 
.RE
.PP

.SS "int rte_mem_alloc_validator_register (const char * name, \fBrte_mem_alloc_validator_t\fP clb, int socket_id, size_t limit)"

.PP
Register validator callback for memory allocations\&. Callbacks registered by this function will be called right before memory allocator is about to trigger allocation of more pages from the system if said allocation will bring total memory usage above specified limit on specified socket\&. User will be able to cancel pending allocation if callback returns -1\&.

.PP
\fBNote\fP
.RS 4
callbacks will happen while memory hotplug subsystem is write-locked, therefore some functions (e\&.g\&. \fR\fBrte_memseg_walk()\fP\fP) will cause a deadlock when called from within such callbacks\&.

.PP
validator callbacks not being supported is an expected error condition, so user code needs to handle this situation\&. In these cases, return value will be -1, and rte_errno will be set to ENOTSUP\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIname\fP Name associated with specified callback to be added to the list\&.
.br
\fIclb\fP Callback function pointer\&.
.br
\fIsocket_id\fP Socket ID on which to watch for allocations\&.
.br
\fIlimit\fP Limit above which to trigger callbacks\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 on successful callback register -1 on unsuccessful callback register, with rte_errno value indicating reason for failure\&. 
.RE
.PP

.SS "int rte_mem_alloc_validator_unregister (const char * name, int socket_id)"

.PP
Unregister validator callback for memory allocations\&. 
.PP
\fBParameters\fP
.RS 4
\fIname\fP Name associated with specified callback to be removed from the list\&.
.br
\fIsocket_id\fP Socket ID on which to watch for allocations\&.
.RE
.PP
\fBReturns\fP
.RS 4
0 on successful callback unregister -1 on unsuccessful callback unregister, with rte_errno value indicating reason for failure\&. 
.RE
.PP

.SS "__rte_experimental void rte_memzero_explicit (void * dst, size_t sz)"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Fill memory with zero's (e\&.g\&. sensitive keys)\&. Normally using memset() is fine, but in cases where clearing out local data before going out of scope is required, use \fBrte_memzero_explicit()\fP instead to prevent the compiler from optimizing away the zeroing operation\&.

.PP
\fBParameters\fP
.RS 4
\fIdst\fP Target buffer\&. 
.br
\fIsz\fP Number of bytes to fill\&. 
.RE
.PP

.SS "__rte_experimental bool rte_memeq_timingsafe (const void * a, const void * b, size_t n)\fR [inline]\fP, \fR [static]\fP"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Timing-safe memory equality comparison\&.

.PP
This function compares two memory regions in constant time, making it resistant to timing side-channel attacks\&. The execution time depends only on the length parameter, not on the actual data values being compared\&.

.PP
This is particularly important for cryptographic operations where timing differences could leak information about secret keys, passwords, or other sensitive data\&.

.PP
\fBParameters\fP
.RS 4
\fIa\fP Pointer to the first memory region to compare\&. 
.br
\fIb\fP Pointer to the second memory region to compare\&. 
.br
\fIn\fP Number of bytes to compare\&. 
.RE
.PP
\fBReturns\fP
.RS 4
true if the memory regions are identical, false if they differ\&. 
.RE
.PP

.PP
Definition at line \fB775\fP of file \fBrte_memory\&.h\fP\&.
.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
