FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
segment_manager.h File Reference
+ Include dependency graph for segment_manager.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  segment_manager_main_init_args_
 

Macros

#define SEGMENT_MANAGER_INVALID_APP_INDEX   ((u32) ~0)
 

Typedefs

typedef struct _segment_manager_props segment_manager_props_t
 
typedef struct _segment_manager segment_manager_t
 
typedef struct segment_manager_main_init_args_ segment_manager_main_init_args_t
 

Functions

segment_manager_tsegment_manager_alloc (void)
 
int segment_manager_init (segment_manager_t *sm, uword first_seg_size, u32 prealloc_fifo_pairs)
 Initializes segment manager based on options provided. More...
 
void segment_manager_free (segment_manager_t *sm)
 Cleanup segment manager. More...
 
void segment_manager_init_free (segment_manager_t *sm)
 Initiate segment manager cleanup. More...
 
segment_manager_tsegment_manager_get (u32 index)
 
segment_manager_tsegment_manager_get_if_valid (u32 index)
 
u32 segment_manager_index (segment_manager_t *sm)
 
int segment_manager_add_segment (segment_manager_t *sm, uword segment_size)
 Adds segment to segment manager's pool. More...
 
void segment_manager_del_segment (segment_manager_t *sm, fifo_segment_t *fs)
 Remove segment without lock. More...
 
fifo_segment_tsegment_manager_get_segment (segment_manager_t *sm, u32 segment_index)
 Reads a segment from the segment manager's pool without lock. More...
 
fifo_segment_tsegment_manager_get_segment_w_handle (u64 sh)
 
fifo_segment_tsegment_manager_get_segment_w_lock (segment_manager_t *sm, u32 segment_index)
 Reads a segment from the segment manager's pool and acquires reader lock. More...
 
int segment_manager_add_first_segment (segment_manager_t *sm, u32 segment_size)
 
u64 segment_manager_make_segment_handle (u32 segment_manager_index, u32 segment_index)
 
u64 segment_manager_segment_handle (segment_manager_t *sm, fifo_segment_t *segment)
 
void segment_manager_segment_reader_unlock (segment_manager_t *sm)
 
void segment_manager_segment_writer_unlock (segment_manager_t *sm)
 
int segment_manager_alloc_session_fifos (segment_manager_t *sm, u32 thread_index, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
 
int segment_manager_try_alloc_fifos (fifo_segment_t *fs, u32 thread_index, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
 
void segment_manager_dealloc_fifos (svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
 
int segment_manager_grow_fifo (segment_manager_t *sm, svm_fifo_t *f, u32 size)
 Grows fifo owned by segment manager. More...
 
int segment_manager_shrink_fifo (segment_manager_t *sm, svm_fifo_t *f, u32 size, u8 is_producer)
 Request to shrink fifo owned by segment manager. More...
 
int segment_manager_collect_fifo_chunks (segment_manager_t *sm, svm_fifo_t *f)
 Collect fifo chunks that are no longer used. More...
 
u8 segment_manager_has_fifos (segment_manager_t *sm)
 
svm_msg_q_tsegment_manager_alloc_queue (fifo_segment_t *fs, segment_manager_props_t *props)
 Allocates shm queue in the first segment. More...
 
void segment_manager_dealloc_queue (segment_manager_t *sm, svm_queue_t *q)
 Frees shm queue allocated in the first segment. More...
 
svm_msg_q_tsegment_manager_event_queue (segment_manager_t *sm)
 
u32 segment_manager_evt_q_expected_size (u32 q_size)
 
void segment_manager_app_detach (segment_manager_t *sm)
 
void segment_manager_del_sessions (segment_manager_t *sm)
 Cleanup segment manager sessions. More...
 
void segment_manager_format_sessions (segment_manager_t *sm, int verbose)
 
void segment_manager_main_init (segment_manager_main_init_args_t *a)
 
segment_manager_props_tsegment_manager_props_init (segment_manager_props_t *sm)
 

Macro Definition Documentation

◆ SEGMENT_MANAGER_INVALID_APP_INDEX

#define SEGMENT_MANAGER_INVALID_APP_INDEX   ((u32) ~0)

Definition at line 69 of file segment_manager.h.

Typedef Documentation

◆ segment_manager_main_init_args_t

◆ segment_manager_props_t

typedef struct _segment_manager_props segment_manager_props_t

◆ segment_manager_t

typedef struct _segment_manager segment_manager_t

Function Documentation

◆ segment_manager_add_first_segment()

int segment_manager_add_first_segment ( segment_manager_t sm,
u32  segment_size 
)

◆ segment_manager_add_segment()

int segment_manager_add_segment ( segment_manager_t sm,
uword  segment_size 
)

Adds segment to segment manager's pool.

If needed a writer's lock is acquired before allocating a new segment to avoid affecting any of the segments pool readers.

Definition at line 86 of file segment_manager.c.

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

◆ segment_manager_alloc()

segment_manager_t* segment_manager_alloc ( void  )

Definition at line 295 of file segment_manager.c.

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

◆ segment_manager_alloc_queue()

svm_msg_q_t* segment_manager_alloc_queue ( fifo_segment_t segment,
segment_manager_props_t props 
)

Allocates shm queue in the first segment.

Must be called with lock held

Definition at line 756 of file segment_manager.c.

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

◆ segment_manager_alloc_session_fifos()

int segment_manager_alloc_session_fifos ( segment_manager_t sm,
u32  thread_index,
svm_fifo_t **  rx_fifo,
svm_fifo_t **  tx_fifo 
)

Definition at line 555 of file segment_manager.c.

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

◆ segment_manager_app_detach()

void segment_manager_app_detach ( segment_manager_t sm)

Definition at line 68 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_collect_fifo_chunks()

int segment_manager_collect_fifo_chunks ( segment_manager_t sm,
svm_fifo_t f 
)

Collect fifo chunks that are no longer used.

This should not be called unless SVM_FIFO_F_COLLECT_CHUNKS is set for the fifo. The chunks are returned to the fifo segment freelist.

Parameters
smsegment manager that owns the fifo
ffifo whose chunks are to be collected
Returns
0 on success, error otherwise

Definition at line 703 of file segment_manager.c.

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

◆ segment_manager_dealloc_fifos()

void segment_manager_dealloc_fifos ( svm_fifo_t rx_fifo,
svm_fifo_t tx_fifo 
)

Definition at line 645 of file segment_manager.c.

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

◆ segment_manager_dealloc_queue()

void segment_manager_dealloc_queue ( segment_manager_t sm,
svm_queue_t q 
)

Frees shm queue allocated in the first segment.

Definition at line 800 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_del_segment()

void segment_manager_del_segment ( segment_manager_t sm,
fifo_segment_t fs 
)

Remove segment without lock.

Definition at line 175 of file segment_manager.c.

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

◆ segment_manager_del_sessions()

void segment_manager_del_sessions ( segment_manager_t sm)

Cleanup segment manager sessions.

Initiates disconnects for all sessions 'owned' by a segment manager by leveraging the backpointers that fifos keep.

Parameters
smsegment manager whose sessions are to be disconnected

Cleanup segment manager sessions.

Definition at line 473 of file segment_manager.c.

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

◆ segment_manager_event_queue()

svm_msg_q_t* segment_manager_event_queue ( segment_manager_t sm)

Definition at line 791 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_evt_q_expected_size()

u32 segment_manager_evt_q_expected_size ( u32  q_size)

Definition at line 734 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_format_sessions()

void segment_manager_format_sessions ( segment_manager_t sm,
int  verbose 
)

Definition at line 896 of file segment_manager.c.

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

◆ segment_manager_free()

void segment_manager_free ( segment_manager_t sm)

Cleanup segment manager.

Parameters
smsegment manager to be freed

Definition at line 382 of file segment_manager.c.

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

◆ segment_manager_get()

segment_manager_t* segment_manager_get ( u32  index)

Definition at line 424 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_get_if_valid()

segment_manager_t* segment_manager_get_if_valid ( u32  index)

Definition at line 430 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_get_segment()

fifo_segment_t* segment_manager_get_segment ( segment_manager_t sm,
u32  segment_index 
)

Reads a segment from the segment manager's pool without lock.

Definition at line 226 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_get_segment_w_handle()

fifo_segment_t* segment_manager_get_segment_w_handle ( u64  sh)

Definition at line 255 of file segment_manager.c.

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

◆ segment_manager_get_segment_w_lock()

fifo_segment_t* segment_manager_get_segment_w_lock ( segment_manager_t sm,
u32  segment_index 
)

Reads a segment from the segment manager's pool and acquires reader lock.

Caller must drop the reader's lock by calling segment_manager_segment_reader_unlock once it finishes working with the segment.

Definition at line 276 of file segment_manager.c.

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

◆ segment_manager_grow_fifo()

int segment_manager_grow_fifo ( segment_manager_t sm,
svm_fifo_t f,
u32  size 
)

Grows fifo owned by segment manager.

Parameters
smsegment manager that owns the fifo
ffifo to be grown
sizeamount of bytes to add to fifo
Returns
0 on success, negative number otherwise

Definition at line 690 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_has_fifos()

u8 segment_manager_has_fifos ( segment_manager_t sm)

Definition at line 444 of file segment_manager.c.

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

◆ segment_manager_index()

u32 segment_manager_index ( segment_manager_t sm)

Definition at line 438 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_init()

int segment_manager_init ( segment_manager_t sm,
uword  first_seg_size,
u32  prealloc_fifo_pairs 
)

Initializes segment manager based on options provided.

Returns error if ssvm segment(s) allocation fails.

Definition at line 310 of file segment_manager.c.

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

◆ segment_manager_init_free()

void segment_manager_init_free ( segment_manager_t sm)

Initiate segment manager cleanup.

Parameters
smsegment manager to be freed

Definition at line 411 of file segment_manager.c.

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

◆ segment_manager_main_init()

void segment_manager_main_init ( segment_manager_main_init_args_t a)

Definition at line 821 of file segment_manager.c.

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

◆ segment_manager_make_segment_handle()

u64 segment_manager_make_segment_handle ( u32  segment_manager_index,
u32  segment_index 
)

Definition at line 248 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_props_init()

segment_manager_props_t* segment_manager_props_init ( segment_manager_props_t sm)

Definition at line 51 of file segment_manager.c.

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

◆ segment_manager_segment_handle()

u64 segment_manager_segment_handle ( segment_manager_t sm,
fifo_segment_t segment 
)

Definition at line 232 of file segment_manager.c.

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

◆ segment_manager_segment_reader_unlock()

void segment_manager_segment_reader_unlock ( segment_manager_t sm)

Definition at line 283 of file segment_manager.c.

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

◆ segment_manager_segment_writer_unlock()

void segment_manager_segment_writer_unlock ( segment_manager_t sm)

Definition at line 289 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_shrink_fifo()

int segment_manager_shrink_fifo ( segment_manager_t sm,
svm_fifo_t f,
u32  size,
u8  is_producer 
)

Request to shrink fifo owned by segment manager.

If this is not called by the producer, no attempt is made to reduce the size until the producer tries to enqueue more data. To collect the chunks that are to be removed call segment_manager_collect_fifo_chunks

Size reduction does not affect fifo chunk boundaries. Therefore chunks are not split and the amount of bytes to be removed can be equal to or less than what was requested.

Parameters
smsegment manager that owns the fifo
ffifo to be shrunk
sizeamount of bytes to remove from fifo
is_producerflag that indicates is caller is the producer for the fifo.
Returns
actual number of bytes to be removed

Definition at line 716 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_try_alloc_fifos()

int segment_manager_try_alloc_fifos ( fifo_segment_t fs,
u32  thread_index,
u32  rx_fifo_size,
u32  tx_fifo_size,
svm_fifo_t **  rx_fifo,
svm_fifo_t **  tx_fifo 
)

Definition at line 516 of file segment_manager.c.

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