FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
segment_manager.c File Reference
+ Include dependency graph for segment_manager.c:

Go to the source code of this file.

Data Structures

struct  segment_manager_main_
 

Macros

#define segment_manager_foreach_segment_w_lock(VAR, SM, BODY)
 

Typedefs

typedef struct segment_manager_main_ segment_manager_main_t
 

Functions

static segment_manager_props_tsegment_manager_properties_get (segment_manager_t *sm)
 
segment_manager_props_tsegment_manager_props_init (segment_manager_props_t *props)
 
u8 segment_manager_app_detached (segment_manager_t *sm)
 
void segment_manager_app_detach (segment_manager_t *sm)
 
static u32 segment_manager_segment_index (segment_manager_t *sm, fifo_segment_t *seg)
 
static int segment_manager_add_segment_inline (segment_manager_t *sm, uword segment_size, u8 notify_app, u8 flags)
 Adds segment to segment manager's pool. More...
 
int segment_manager_add_segment (segment_manager_t *sm, uword segment_size, u8 notify_app)
 
int segment_manager_add_segment2 (segment_manager_t *sm, uword segment_size, u8 flags)
 
void segment_manager_del_segment (segment_manager_t *sm, fifo_segment_t *fs)
 Remove segment without lock. More...
 
static fifo_segment_tsegment_manager_get_segment_if_valid (segment_manager_t *sm, u32 segment_index)
 
static void sm_lock_and_del_segment_inline (segment_manager_t *sm, u32 fs_index)
 Removes segment after acquiring writer lock. More...
 
void segment_manager_lock_and_del_segment (segment_manager_t *sm, u32 fs_index)
 
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...
 
u64 segment_manager_segment_handle (segment_manager_t *sm, fifo_segment_t *segment)
 
u64 segment_manager_make_segment_handle (u32 segment_manager_index, u32 segment_index)
 
fifo_segment_tsegment_manager_get_segment_w_handle (u64 segment_handle)
 
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...
 
void segment_manager_segment_reader_lock (segment_manager_t *sm)
 
void segment_manager_segment_reader_unlock (segment_manager_t *sm)
 
void segment_manager_segment_writer_unlock (segment_manager_t *sm)
 
segment_manager_tsegment_manager_alloc (void)
 
int segment_manager_init (segment_manager_t *sm)
 
int segment_manager_init_first (segment_manager_t *sm)
 Initializes segment manager based on options provided. More...
 
void segment_manager_cleanup_detached_listener (segment_manager_t *sm)
 
void segment_manager_free (segment_manager_t *sm)
 Cleanup segment manager. More...
 
static void sm_free_w_index_helper (void *arg)
 
void segment_manager_free_safe (segment_manager_t *sm)
 
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)
 
u8 segment_manager_has_fifos (segment_manager_t *sm)
 
void segment_manager_del_sessions (segment_manager_t *sm)
 Initiate disconnects for all sessions 'owned' by a segment manager. More...
 
void segment_manager_del_sessions_filter (segment_manager_t *sm, session_state_t *states)
 Initiate disconnects for sessions in specified state 'owned' by a segment manager. More...
 
int segment_manager_try_alloc_fifos (fifo_segment_t *fifo_segment, u32 thread_index, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
 
int segment_manager_alloc_session_fifos (segment_manager_t *sm, u32 thread_index, 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)
 
void segment_manager_detach_fifo (segment_manager_t *sm, svm_fifo_t **f)
 
void segment_manager_attach_fifo (segment_manager_t *sm, svm_fifo_t **f, session_t *s)
 
u32 segment_manager_evt_q_expected_size (u32 q_len)
 
svm_msg_q_tsegment_manager_alloc_queue (fifo_segment_t *segment, segment_manager_props_t *props)
 Allocates shm queue in the first segment. More...
 
svm_msg_q_tsegment_manager_event_queue (segment_manager_t *sm)
 
void segment_manager_dealloc_queue (segment_manager_t *sm, svm_queue_t *q)
 Frees shm queue allocated in the first segment. More...
 
void segment_manager_main_init (void)
 
static clib_error_tsegment_manager_show_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
void segment_manager_format_sessions (segment_manager_t *sm, int verbose)
 
void segment_manager_set_watermarks (segment_manager_t *sm, u8 high_watermark, u8 low_watermark)
 

Variables

static segment_manager_main_t sm_main
 
static vlib_cli_command_t segment_manager_show_command
 (constructor) VLIB_CLI_COMMAND (segment_manager_show_command) More...
 

Macro Definition Documentation

◆ segment_manager_foreach_segment_w_lock

#define segment_manager_foreach_segment_w_lock (   VAR,
  SM,
  BODY 
)
Value:
do { \
clib_rwlock_reader_lock (&(SM)->segments_rwlock); \
pool_foreach((VAR), ((SM)->segments)) (BODY); \
clib_rwlock_reader_unlock (&(SM)->segments_rwlock); \
} while (0)

Definition at line 38 of file segment_manager.c.

Typedef Documentation

◆ segment_manager_main_t

Function Documentation

◆ segment_manager_add_segment()

int segment_manager_add_segment ( segment_manager_t sm,
uword  segment_size,
u8  notify_app 
)

Definition at line 186 of file segment_manager.c.

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

◆ segment_manager_add_segment2()

int segment_manager_add_segment2 ( segment_manager_t sm,
uword  segment_size,
u8  flags 
)

Definition at line 193 of file segment_manager.c.

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

◆ segment_manager_add_segment_inline()

static int segment_manager_add_segment_inline ( segment_manager_t sm,
uword  segment_size,
u8  notify_app,
u8  flags 
)
inlinestatic

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 91 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 336 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 914 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 737 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 73 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_app_detached()

u8 segment_manager_app_detached ( segment_manager_t sm)

Definition at line 67 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_attach_fifo()

void segment_manager_attach_fifo ( segment_manager_t sm,
svm_fifo_t **  f,
session_t s 
)

Definition at line 878 of file segment_manager.c.

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

◆ segment_manager_cleanup_detached_listener()

void segment_manager_cleanup_detached_listener ( segment_manager_t sm)

Definition at line 456 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 825 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 954 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 203 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)

Initiate disconnects for all sessions 'owned' by a segment manager.

Cleanup segment manager sessions.

Definition at line 596 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_filter()

void segment_manager_del_sessions_filter ( segment_manager_t sm,
session_state_t states 
)

Initiate disconnects for sessions in specified state 'owned' by a segment manager.

Definition at line 649 of file segment_manager.c.

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

◆ segment_manager_detach_fifo()

void segment_manager_detach_fifo ( segment_manager_t sm,
svm_fifo_t **  f 
)

Definition at line 868 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 945 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_len)

Definition at line 892 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 1062 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 471 of file segment_manager.c.

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

◆ segment_manager_free_safe()

void segment_manager_free_safe ( segment_manager_t sm)

Definition at line 517 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 547 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 553 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 269 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_get_segment_if_valid()

static fifo_segment_t* segment_manager_get_segment_if_valid ( segment_manager_t sm,
u32  segment_index 
)
static

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  segment_handle)

Definition at line 290 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 311 of file segment_manager.c.

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

◆ segment_manager_has_fifos()

u8 segment_manager_has_fifos ( segment_manager_t sm)

Definition at line 567 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 561 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_init()

int segment_manager_init ( segment_manager_t sm)

Definition at line 347 of file segment_manager.c.

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

◆ segment_manager_init_first()

int segment_manager_init_first ( segment_manager_t sm)

Initializes segment manager based on options provided.

Returns error if ssvm segment(s) allocation fails.

Definition at line 368 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 532 of file segment_manager.c.

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

◆ segment_manager_lock_and_del_segment()

void segment_manager_lock_and_del_segment ( segment_manager_t sm,
u32  fs_index 
)

Definition at line 260 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 ( void  )

Definition at line 975 of file segment_manager.c.

+ 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 283 of file segment_manager.c.

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

◆ segment_manager_properties_get()

static segment_manager_props_t* segment_manager_properties_get ( segment_manager_t sm)
static

Definition at line 46 of file segment_manager.c.

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

◆ segment_manager_props_init()

segment_manager_props_t* segment_manager_props_init ( segment_manager_props_t props)

Definition at line 53 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 275 of file segment_manager.c.

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

◆ segment_manager_segment_index()

static u32 segment_manager_segment_index ( segment_manager_t sm,
fifo_segment_t seg 
)
inlinestatic

Definition at line 79 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_segment_reader_lock()

void segment_manager_segment_reader_lock ( segment_manager_t sm)

Definition at line 318 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 324 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 330 of file segment_manager.c.

+ Here is the call graph for this function:

◆ segment_manager_set_watermarks()

void segment_manager_set_watermarks ( segment_manager_t sm,
u8  high_watermark,
u8  low_watermark 
)

Definition at line 1126 of file segment_manager.c.

+ Here is the caller graph for this function:

◆ segment_manager_show_fn()

static clib_error_t* segment_manager_show_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 988 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 fifo_segment,
u32  thread_index,
u32  rx_fifo_size,
u32  tx_fifo_size,
svm_fifo_t **  rx_fifo,
svm_fifo_t **  tx_fifo 
)

Definition at line 698 of file segment_manager.c.

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

◆ sm_free_w_index_helper()

static void sm_free_w_index_helper ( void *  arg)
static

Definition at line 505 of file segment_manager.c.

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

◆ sm_lock_and_del_segment_inline()

static void sm_lock_and_del_segment_inline ( segment_manager_t sm,
u32  fs_index 
)
inlinestatic

Removes segment after acquiring writer lock.

Definition at line 238 of file segment_manager.c.

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

Variable Documentation

◆ segment_manager_show_command

vlib_cli_command_t segment_manager_show_command
static
Initial value:
=
{
.path = "show segment-manager",
.short_help = "show segment-manager [segments][verbose]",
}

(constructor) VLIB_CLI_COMMAND (segment_manager_show_command)

Definition at line 1053 of file segment_manager.c.

◆ sm_main

segment_manager_main_t sm_main
static

Definition at line 36 of file segment_manager.c.

segment_manager_show_fn
static clib_error_t * segment_manager_show_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: segment_manager.c:988