FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
fifo_segment.c File Reference
+ Include dependency graph for fifo_segment.c:

Go to the source code of this file.

Functions

static uword fsh_free_space (fifo_segment_header_t *fsh)
 Fifo segment free space. More...
 
static void fsh_free_bytes_sub (fifo_segment_header_t *fsh, int size)
 
static uword fsh_n_free_bytes (fifo_segment_header_t *fsh)
 
static void fsh_update_free_bytes (fifo_segment_header_t *fsh)
 
static void fsh_check_mem (fifo_segment_header_t *fsh)
 
static fifo_segment_slice_tfsh_slice_get (fifo_segment_header_t *fsh, u32 slice_index)
 
static void fsh_active_fifos_update (fifo_segment_header_t *fsh, int inc)
 
int fifo_segment_init (fifo_segment_t *fs)
 Initialize fifo segment shared header. More...
 
int fifo_segment_create (fifo_segment_main_t *sm, fifo_segment_create_args_t *a)
 Create a fifo segment and initialize as master. More...
 
int fifo_segment_attach (fifo_segment_main_t *sm, fifo_segment_create_args_t *a)
 Attach as slave to a fifo segment. More...
 
void fifo_segment_delete (fifo_segment_main_t *sm, fifo_segment_t *s)
 
u32 fifo_segment_index (fifo_segment_main_t *sm, fifo_segment_t *s)
 
fifo_segment_tfifo_segment_get_segment (fifo_segment_main_t *sm, u32 segment_index)
 
void fifo_segment_info (fifo_segment_t *seg, char **address, size_t *size)
 
void fifo_segment_main_init (fifo_segment_main_t *sm, u64 baseva, u32 timeout_in_seconds)
 
static u32 fs_freelist_for_size (u32 size)
 
static u32 fs_freelist_index_to_size (u32 fl_index)
 
static int fs_chunk_size_is_valid (fifo_segment_header_t *fsh, u32 size)
 
static svm_fifo_tfs_try_alloc_fifo_freelist (fifo_segment_slice_t *fss, u32 fl_index, u32 data_bytes)
 
static svm_fifo_tfs_try_alloc_fifo_freelist_multi_chunk (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss, u32 data_bytes)
 
static int fs_try_alloc_fifo_batch (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss, u32 fl_index, u32 batch_size)
 
static svm_fifo_tfs_try_alloc_fifo (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss, u32 data_bytes)
 Try to allocate new fifo. More...
 
svm_fifo_tfifo_segment_alloc_fifo_w_slice (fifo_segment_t *fs, u32 slice_index, u32 data_bytes, fifo_segment_ftype_t ftype)
 Allocate fifo in fifo segment. More...
 
void fifo_segment_free_fifo (fifo_segment_t *fs, svm_fifo_t *f)
 Free fifo allocated in fifo segment. More...
 
int fifo_segment_prealloc_fifo_hdrs (fifo_segment_t *fs, u32 slice_index, u32 batch_size)
 Try to preallocate fifo headers. More...
 
int fifo_segment_prealloc_fifo_chunks (fifo_segment_t *fs, u32 slice_index, u32 chunk_size, u32 batch_size)
 Try to preallocate fifo chunks on segment. More...
 
void fifo_segment_preallocate_fifo_pairs (fifo_segment_t *fs, u32 rx_fifo_size, u32 tx_fifo_size, u32 *n_fifo_pairs)
 Pre-allocates fifo pairs in fifo segment. More...
 
int fifo_segment_grow_fifo (fifo_segment_t *fs, svm_fifo_t *f, u32 chunk_size)
 Grow fifo size by adding an additional chunk of memory. More...
 
int fifo_segment_collect_fifo_chunks (fifo_segment_t *fs, svm_fifo_t *f)
 Collect unused chunks for fifo. More...
 
u32 fifo_segment_num_fifos (fifo_segment_t *fs)
 Get number of active fifos. More...
 
static u32 fs_slice_num_free_fifos (fifo_segment_slice_t *fss)
 
u32 fifo_segment_num_free_fifos (fifo_segment_t *fs)
 
static u32 fs_slice_num_free_chunks (fifo_segment_slice_t *fss, u32 size)
 
u32 fifo_segment_num_free_chunks (fifo_segment_t *fs, u32 size)
 Find number of free chunks of given size. More...
 
void fifo_segment_update_free_bytes (fifo_segment_t *fs)
 Update fifo segment free bytes estimate. More...
 
uword fifo_segment_free_bytes (fifo_segment_t *fs)
 Fifo segment estimate of number of free bytes. More...
 
uword fifo_segment_fl_chunk_bytes (fifo_segment_t *fs)
 Number of bytes on chunk free lists. More...
 
u8 fifo_segment_has_fifos (fifo_segment_t *fs)
 
svm_fifo_tfifo_segment_get_slice_fifo_list (fifo_segment_t *fs, u32 slice_index)
 
u8format_fifo_segment_type (u8 *s, va_list *args)
 
u8format_fifo_segment (u8 *s, va_list *args)
 Segment format function. More...
 

Function Documentation

◆ fifo_segment_alloc_fifo_w_slice()

svm_fifo_t* fifo_segment_alloc_fifo_w_slice ( fifo_segment_t fs,
u32  slice_index,
u32  data_bytes,
fifo_segment_ftype_t  ftype 
)

Allocate fifo in fifo segment.

Parameters
fsfifo segment for fifo
data_bytessize of default fifo chunk in bytes
ftypefifo type fifo_segment_ftype_t
Returns
new fifo or 0 if alloc failed

Definition at line 487 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_attach()

int fifo_segment_attach ( fifo_segment_main_t sm,
fifo_segment_create_args_t a 
)

Attach as slave to a fifo segment.

Definition at line 179 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_collect_fifo_chunks()

int fifo_segment_collect_fifo_chunks ( fifo_segment_t fs,
svm_fifo_t f 
)

Collect unused chunks for fifo.

Parameters
fsfifo segment for fifo
ffifo whose chunks are to be collected
Returns
0 on success, error otherwise

Definition at line 804 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_create()

int fifo_segment_create ( fifo_segment_main_t sm,
fifo_segment_create_args_t a 
)

Create a fifo segment and initialize as master.

Definition at line 145 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_delete()

void fifo_segment_delete ( fifo_segment_main_t sm,
fifo_segment_t s 
)

Definition at line 209 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_fl_chunk_bytes()

uword fifo_segment_fl_chunk_bytes ( fifo_segment_t fs)

Number of bytes on chunk free lists.

Parameters
fsfifo segment
Returns
free bytes on chunk free lists

Definition at line 946 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_free_bytes()

uword fifo_segment_free_bytes ( fifo_segment_t fs)

Fifo segment estimate of number of free bytes.

Returns fifo segment's internal estimate of the number of free bytes. To force a synchronization between the segment and the underlying memory allocator, call fifo_segment_update_free_bytes

Parameters
fsfifo segment
Returns
free bytes estimate

Definition at line 940 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_free_fifo()

void fifo_segment_free_fifo ( fifo_segment_t fs,
svm_fifo_t f 
)

Free fifo allocated in fifo segment.

Parameters
fsfifo segment for fifo
ffifo to be freed

Definition at line 538 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_get_segment()

fifo_segment_t* fifo_segment_get_segment ( fifo_segment_main_t sm,
u32  segment_index 
)

Definition at line 223 of file fifo_segment.c.

◆ fifo_segment_get_slice_fifo_list()

svm_fifo_t* fifo_segment_get_slice_fifo_list ( fifo_segment_t fs,
u32  slice_index 
)

Definition at line 979 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_grow_fifo()

int fifo_segment_grow_fifo ( fifo_segment_t fs,
svm_fifo_t f,
u32  chunk_size 
)

Grow fifo size by adding an additional chunk of memory.

Parameters
fsfifo segment for fifo
ffifo to be grown
chunk_sizenumber of bytes to be added to fifo
Returns
0 on success or a negative number otherwise

Definition at line 758 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_has_fifos()

u8 fifo_segment_has_fifos ( fifo_segment_t fs)

Definition at line 963 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_index()

u32 fifo_segment_index ( fifo_segment_main_t sm,
fifo_segment_t s 
)

Definition at line 217 of file fifo_segment.c.

◆ fifo_segment_info()

void fifo_segment_info ( fifo_segment_t seg,
char **  address,
size_t *  size 
)

Definition at line 229 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fifo_segment_init()

int fifo_segment_init ( fifo_segment_t fs)

Initialize fifo segment shared header.

Definition at line 89 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_main_init()

void fifo_segment_main_init ( fifo_segment_main_t sm,
u64  baseva,
u32  timeout_in_seconds 
)

Definition at line 236 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fifo_segment_num_fifos()

u32 fifo_segment_num_fifos ( fifo_segment_t fs)

Get number of active fifos.

Definition at line 835 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fifo_segment_num_free_chunks()

u32 fifo_segment_num_free_chunks ( fifo_segment_t fs,
u32  size 
)

Find number of free chunks of given size.

Parameters
fsfifo segment
sizechunk size of interest or ~0 if all should be counted
Returns
number of chunks of given size

Definition at line 918 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_num_free_fifos()

u32 fifo_segment_num_free_fifos ( fifo_segment_t fs)

Definition at line 859 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_prealloc_fifo_chunks()

int fifo_segment_prealloc_fifo_chunks ( fifo_segment_t fs,
u32  slice_index,
u32  chunk_size,
u32  batch_size 
)

Try to preallocate fifo chunks on segment.

Tries to preallocate chunks of requested size on segment and adds them to chunk freelist.

Parameters
fsfifo segment
chunk_sizesize of chunks to be allocated in bytes
batch_sizenumber of chunks to be allocated
Returns
0 on success, negative number otherwise

Definition at line 644 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_prealloc_fifo_hdrs()

int fifo_segment_prealloc_fifo_hdrs ( fifo_segment_t fs,
u32  slice_index,
u32  batch_size 
)

Try to preallocate fifo headers.

Tries to preallocate fifo headers and adds them to freelist.

Parameters
fsfifo segment
batch_sizenumber of chunks to be allocated
Returns
0 on success, negative number otherwise

Definition at line 604 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_preallocate_fifo_pairs()

void fifo_segment_preallocate_fifo_pairs ( fifo_segment_t fs,
u32  rx_fifo_size,
u32  tx_fifo_size,
u32 n_fifo_pairs 
)

Pre-allocates fifo pairs in fifo segment.

The number of fifos pre-allocated is the minimum of the requested number of pairs and the maximum number that fit within the segment. If the maximum is hit, the number of fifo pairs requested is updated by subtracting the number of fifos that have been successfully allocated.

Parameters
fsfifo segment for fifo
rx_fifo_sizedata size of rx fifos
tx_fifo_sizedata size of tx fifos
n_fifo_pairsnumber of pairs requested. Prior to returning, this is decremented by the the number of pairs allocated.

Definition at line 698 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fifo_segment_update_free_bytes()

void fifo_segment_update_free_bytes ( fifo_segment_t fs)

Update fifo segment free bytes estimate.

Forces fifo segment free bytes estimate synchronization with underlying memory allocator.

Parameters
fsfifo segment

Definition at line 934 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_fifo_segment()

u8* format_fifo_segment ( u8 s,
va_list *  args 
)

Segment format function.

Definition at line 1010 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ format_fifo_segment_type()

u8* format_fifo_segment_type ( u8 s,
va_list *  args 
)

Definition at line 989 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_chunk_size_is_valid()

static int fs_chunk_size_is_valid ( fifo_segment_header_t fsh,
u32  size 
)
inlinestatic

Definition at line 256 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fs_freelist_for_size()

static u32 fs_freelist_for_size ( u32  size)
inlinestatic

Definition at line 244 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_freelist_index_to_size()

static u32 fs_freelist_index_to_size ( u32  fl_index)
inlinestatic

Definition at line 250 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fs_slice_num_free_chunks()

static u32 fs_slice_num_free_chunks ( fifo_segment_slice_t fss,
u32  size 
)
static

Definition at line 875 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_slice_num_free_fifos()

static u32 fs_slice_num_free_fifos ( fifo_segment_slice_t fss)
static

Definition at line 841 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fs_try_alloc_fifo()

static svm_fifo_t* fs_try_alloc_fifo ( fifo_segment_header_t fsh,
fifo_segment_slice_t fss,
u32  data_bytes 
)
static

Try to allocate new fifo.

Tries the following steps in order:

  • grab fifo and chunk from freelists
  • batch fifo and chunk allocation
  • single fifo allocation
  • grab multiple fifo chunks from freelists

Definition at line 435 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_try_alloc_fifo_batch()

static int fs_try_alloc_fifo_batch ( fifo_segment_header_t fsh,
fifo_segment_slice_t fss,
u32  fl_index,
u32  batch_size 
)
static

Definition at line 379 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_try_alloc_fifo_freelist()

static svm_fifo_t* fs_try_alloc_fifo_freelist ( fifo_segment_slice_t fss,
u32  fl_index,
u32  data_bytes 
)
static

Definition at line 267 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fs_try_alloc_fifo_freelist_multi_chunk()

static svm_fifo_t* fs_try_alloc_fifo_freelist_multi_chunk ( fifo_segment_header_t fsh,
fifo_segment_slice_t fss,
u32  data_bytes 
)
static

Definition at line 293 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fsh_active_fifos_update()

static void fsh_active_fifos_update ( fifo_segment_header_t fsh,
int  inc 
)
inlinestatic

Definition at line 80 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fsh_check_mem()

static void fsh_check_mem ( fifo_segment_header_t fsh)
static

Definition at line 57 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fsh_free_bytes_sub()

static void fsh_free_bytes_sub ( fifo_segment_header_t fsh,
int  size 
)
inlinestatic

Definition at line 38 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fsh_free_space()

static uword fsh_free_space ( fifo_segment_header_t fsh)
static

Fifo segment free space.

Queries the underlying memory manager, dlmalloc, for free space. Since this ends up walking the internal data structures, it should not be called indiscriminately.

Parameters
fsfifo segment
Returns
number of free bytes

Definition at line 29 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fsh_n_free_bytes()

static uword fsh_n_free_bytes ( fifo_segment_header_t fsh)
inlinestatic

Definition at line 44 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fsh_slice_get()

static fifo_segment_slice_t* fsh_slice_get ( fifo_segment_header_t fsh,
u32  slice_index 
)
inlinestatic

Definition at line 74 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fsh_update_free_bytes()

static void fsh_update_free_bytes ( fifo_segment_header_t fsh)
inlinestatic

Definition at line 51 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: