DPDK  22.07.0
Enumerations | Functions
rte_eal_paging.h File Reference
#include <stdint.h>
#include <rte_compat.h>

Go to the source code of this file.

Enumerations

enum  rte_mem_prot { RTE_PROT_READ = 1 << 0, RTE_PROT_WRITE = 1 << 1, RTE_PROT_EXECUTE = 1 << 2 }
 
enum  rte_map_flags { RTE_MAP_SHARED = 1 << 0, RTE_MAP_ANONYMOUS = 1 << 1, RTE_MAP_PRIVATE = 1 << 2, RTE_MAP_FORCE_ADDRESS = 1 << 3 }
 

Functions

__rte_internal void * rte_mem_map (void *requested_addr, size_t size, int prot, int flags, int fd, uint64_t offset)
 
__rte_internal int rte_mem_unmap (void *virt, size_t size)
 
__rte_internal size_t rte_mem_page_size (void)
 
__rte_internal int rte_mem_lock (const void *virt, size_t size)
 

Enumeration Type Documentation

◆ rte_mem_prot

Memory protection flags.

Enumerator
RTE_PROT_READ 

Read access.

RTE_PROT_WRITE 

Write access.

RTE_PROT_EXECUTE 

Code execution.

Definition at line 17 of file rte_eal_paging.h.

◆ rte_map_flags

Additional flags for memory mapping.

Enumerator
RTE_MAP_SHARED 

Changes to the mapped memory are visible to other processes.

RTE_MAP_ANONYMOUS 

Mapping is not backed by a regular file.

RTE_MAP_PRIVATE 

Copy-on-write mapping, changes are invisible to other processes.

RTE_MAP_FORCE_ADDRESS 

Force mapping to the requested address. This flag should be used with caution, because to fulfill the request implementation may remove all other mappings in the requested region. However, it is not required to do so, thus mapping with this flag may fail.

Definition at line 24 of file rte_eal_paging.h.

Function Documentation

◆ rte_mem_map()

__rte_internal void* rte_mem_map ( void *  requested_addr,
size_t  size,
int  prot,
int  flags,
int  fd,
uint64_t  offset 
)

Map a portion of an opened file or the page file into memory.

This function is similar to POSIX mmap(3) with common MAP_ANONYMOUS extension, except for the return value.

Parameters
requested_addrDesired virtual address for mapping. Can be NULL to let OS choose.
sizeSize of the mapping in bytes.
protProtection flags, a combination of rte_mem_prot values.
flagsAdditional mapping flags, a combination of rte_map_flags.
fdMapped file descriptor. Can be negative for anonymous mapping.
offsetOffset of the mapped region in fd. Must be 0 for anonymous mappings.
Returns
Mapped address or NULL on failure and rte_errno is set to OS error.

◆ rte_mem_unmap()

__rte_internal int rte_mem_unmap ( void *  virt,
size_t  size 
)

OS-independent implementation of POSIX munmap(3).

◆ rte_mem_page_size()

__rte_internal size_t rte_mem_page_size ( void  )

Get system page size. This function never fails.

Returns
Page size in bytes.

◆ rte_mem_lock()

__rte_internal int rte_mem_lock ( const void *  virt,
size_t  size 
)

Lock in physical memory all pages crossed by the address region.

Parameters
virtBase virtual address of the region.
sizeSize of the region.
Returns
0 on success, negative on error.
See also
rte_mem_page_size() to retrieve the page size.
rte_mem_lock_page() to lock an entire single page.