FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
fifo_segment.h File Reference
+ Include dependency graph for fifo_segment.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fifo_segment_t
 
struct  fifo_segment_main_t
 
struct  fifo_segment_create_args_t
 

Macros

#define FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE   12
 4kB min fifo size More...
 
#define FIFO_SEGMENT_MIN_FIFO_SIZE   4096
 4kB min fifo size More...
 
#define FIFO_SEGMENT_MAX_FIFO_SIZE   (2 << 30)
 2GB max fifo size More...
 
#define FIFO_SEGMENT_ALLOC_BATCH_SIZE   32 /* Allocation quantum */
 
#define foreach_segment_mem_status
 
#define fifo_segment_flags(_fs)   _fs->h->flags
 

Typedefs

typedef enum fifo_segment_flags_ fifo_segment_flags_t
 

Enumerations

enum  fifo_segment_ftype_t { FIFO_SEGMENT_FTYPE_NONE = -1, FIFO_SEGMENT_RX_FIFO = 0, FIFO_SEGMENT_TX_FIFO, FIFO_SEGMENT_N_FTYPES }
 
enum  fifo_segment_flags_ { FIFO_SEGMENT_F_IS_PREALLOCATED = 1 << 0, FIFO_SEGMENT_F_WILL_DELETE = 1 << 1, FIFO_SEGMENT_F_MEM_LIMIT = 1 << 2 }
 
enum  fifo_segment_mem_status_t { MEMORY_N_PRESSURE }
 

Functions

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 *fs)
 
fifo_segment_tfifo_segment_get_segment (fifo_segment_main_t *sm, u32 fs_index)
 
u32 fifo_segment_index (fifo_segment_main_t *sm, fifo_segment_t *fs)
 
void fifo_segment_info (fifo_segment_t *seg, char **address, size_t *size)
 
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...
 
void fifo_segment_detach_fifo (fifo_segment_t *fs, svm_fifo_t *f)
 
void fifo_segment_attach_fifo (fifo_segment_t *fs, svm_fifo_t *f, u32 slice_index)
 
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...
 
svm_fifo_chunk_tfsh_alloc_chunk (fifo_segment_header_t *fsh, u32 slice_index, u32 chunk_size)
 Allocate chunks in fifo segment. More...
 
void fsh_collect_chunks (fifo_segment_header_t *fsh, u32 slice_index, svm_fifo_chunk_t *c)
 Return chunks to fifo segment. More...
 
u8 fsh_has_reached_mem_limit (fifo_segment_header_t *fsh)
 Fifo segment has reached mem limit. More...
 
void fsh_reset_mem_limit (fifo_segment_header_t *fsh)
 Fifo segment reset mem limit flag. More...
 
uword fifo_segment_size (fifo_segment_t *fs)
 Fifo segment allocated size. More...
 
uword fifo_segment_free_bytes (fifo_segment_t *fs)
 Fifo segment estimate of number of free bytes. More...
 
void fifo_segment_update_free_bytes (fifo_segment_t *fs)
 Update fifo segment free bytes estimate. More...
 
uword fifo_segment_cached_bytes (fifo_segment_t *fs)
 Fifo segment number of cached bytes. More...
 
uword fifo_segment_available_bytes (fifo_segment_t *fs)
 
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)
 
u32 fifo_segment_num_fifos (fifo_segment_t *fs)
 Get number of active fifos. More...
 
u32 fifo_segment_num_free_fifos (fifo_segment_t *fs)
 
u32 fifo_segment_num_free_chunks (fifo_segment_t *fs, u32 size)
 Find number of free chunks of given size. More...
 
u8 fifo_segment_get_mem_usage (fifo_segment_t *fs)
 
fifo_segment_mem_status_t fifo_segment_determine_status (fifo_segment_header_t *fsh, u8 usage)
 
fifo_segment_mem_status_t fifo_segment_get_mem_status (fifo_segment_t *fs)
 
void fifo_segment_main_init (fifo_segment_main_t *sm, u64 baseva, u32 timeout_in_seconds)
 

Variables

format_function_t format_fifo_segment
 
format_function_t format_fifo_segment_type
 

Macro Definition Documentation

◆ FIFO_SEGMENT_ALLOC_BATCH_SIZE

#define FIFO_SEGMENT_ALLOC_BATCH_SIZE   32 /* Allocation quantum */

Definition at line 33 of file fifo_segment.h.

◆ fifo_segment_flags

#define fifo_segment_flags (   _fs)    _fs->h->flags

Definition at line 89 of file fifo_segment.h.

◆ FIFO_SEGMENT_MAX_FIFO_SIZE

#define FIFO_SEGMENT_MAX_FIFO_SIZE   (2 << 30)

2GB max fifo size

Definition at line 32 of file fifo_segment.h.

◆ FIFO_SEGMENT_MIN_FIFO_SIZE

#define FIFO_SEGMENT_MIN_FIFO_SIZE   4096

4kB min fifo size

Definition at line 31 of file fifo_segment.h.

◆ FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE

#define FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE   12

4kB min fifo size

Definition at line 30 of file fifo_segment.h.

◆ foreach_segment_mem_status

#define foreach_segment_mem_status
Value:
_(NO_PRESSURE, "No pressure") \
_(LOW_PRESSURE, "Low pressure") \
_(HIGH_PRESSURE, "High pressure") \
_(NO_MEMORY, "No memory")

Definition at line 42 of file fifo_segment.h.

Typedef Documentation

◆ fifo_segment_flags_t

Enumeration Type Documentation

◆ fifo_segment_flags_

Enumerator
FIFO_SEGMENT_F_IS_PREALLOCATED 
FIFO_SEGMENT_F_WILL_DELETE 
FIFO_SEGMENT_F_MEM_LIMIT 

Definition at line 35 of file fifo_segment.h.

◆ fifo_segment_ftype_t

Enumerator
FIFO_SEGMENT_FTYPE_NONE 
FIFO_SEGMENT_RX_FIFO 
FIFO_SEGMENT_TX_FIFO 
FIFO_SEGMENT_N_FTYPES 

Definition at line 22 of file fifo_segment.h.

◆ fifo_segment_mem_status_t

Enumerator
MEMORY_N_PRESSURE 

Definition at line 48 of file fifo_segment.h.

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 842 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 235 of file fifo_segment.c.

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

◆ fifo_segment_attach_fifo()

void fifo_segment_attach_fifo ( fifo_segment_t fs,
svm_fifo_t f,
u32  slice_index 
)

Definition at line 959 of file fifo_segment.c.

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

◆ fifo_segment_available_bytes()

uword fifo_segment_available_bytes ( fifo_segment_t fs)

Definition at line 1277 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_cached_bytes()

uword fifo_segment_cached_bytes ( fifo_segment_t fs)

Fifo segment number of cached bytes.

Returns fifo segment's number of cached bytes.

Parameters
fsfifo segment
Returns
cached bytes

Definition at line 1271 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 201 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 fs 
)

Definition at line 265 of file fifo_segment.c.

+ Here is the call graph for this function:

◆ fifo_segment_detach_fifo()

void fifo_segment_detach_fifo ( fifo_segment_t fs,
svm_fifo_t f 
)

Definition at line 936 of file fifo_segment.c.

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

◆ fifo_segment_determine_status()

fifo_segment_mem_status_t fifo_segment_determine_status ( fifo_segment_header_t fsh,
u8  usage 
)

Definition at line 1327 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller 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 1283 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 1265 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 890 of file fifo_segment.c.

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

◆ fifo_segment_get_mem_status()

fifo_segment_mem_status_t fifo_segment_get_mem_status ( fifo_segment_t fs)

Definition at line 1353 of file fifo_segment.c.

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

◆ fifo_segment_get_mem_usage()

u8 fifo_segment_get_mem_usage ( fifo_segment_t fs)

Definition at line 1316 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  fs_index 
)

Definition at line 279 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 1306 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 1300 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 fs 
)

Definition at line 273 of file fifo_segment.c.

◆ fifo_segment_info()

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

Definition at line 285 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 143 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 292 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 1142 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_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 1225 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 1166 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 1022 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 982 of file fifo_segment.c.

+ Here is the call graph for this function:
+ Here is the caller 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 1079 of file fifo_segment.c.

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

◆ fifo_segment_size()

uword fifo_segment_size ( fifo_segment_t fs)

Fifo segment allocated size.

Returns fifo segment's allocated size

Parameters
fsfifo segment
Returns
allocated size in bytes

Definition at line 1247 of file fifo_segment.c.

+ 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 1241 of file fifo_segment.c.

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

◆ fsh_alloc_chunk()

svm_fifo_chunk_t* fsh_alloc_chunk ( fifo_segment_header_t fsh,
u32  slice_index,
u32  chunk_size 
)

Allocate chunks in fifo segment.

Parameters
fshfifo segment header
slice_indexslice where chunks should be alocated
chunk_sizechunk size needed
Returns
chunk (or chunks) that cover at least chunk_size bytes on success, 0 on failure.

Definition at line 695 of file fifo_segment.c.

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

◆ fsh_collect_chunks()

void fsh_collect_chunks ( fifo_segment_header_t fsh,
u32  slice_index,
svm_fifo_chunk_t c 
)

Return chunks to fifo segment.

Parameters
fshfifo segment header
slice_indexslice where chunks should be returned
cpointer to first chunk in 0 terminated linked list

Definition at line 805 of file fifo_segment.c.

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

◆ fsh_has_reached_mem_limit()

u8 fsh_has_reached_mem_limit ( fifo_segment_header_t fsh)

Fifo segment has reached mem limit.

Parameters
fshfifo segment header
Returns
1 (if reached) or 0 (otherwise)

Definition at line 1253 of file fifo_segment.c.

+ Here is the caller graph for this function:

◆ fsh_reset_mem_limit()

void fsh_reset_mem_limit ( fifo_segment_header_t fsh)

Fifo segment reset mem limit flag.

Parameters
fsfifo segment

Definition at line 1259 of file fifo_segment.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ format_fifo_segment

format_function_t format_fifo_segment

Definition at line 281 of file fifo_segment.h.

◆ format_fifo_segment_type

format_function_t format_fifo_segment_type

Definition at line 282 of file fifo_segment.h.