FD.io VPP  v18.07-34-g55fbdb9
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_
 
struct  segment_manager_main_init_args_
 

Macros

#define segment_manager_foreach_segment_w_lock(VAR, SM, BODY)
 
#define SEGMENT_MANAGER_INVALID_APP_INDEX   ((u32) ~0)
 

Typedefs

typedef struct _segment_manager_properties segment_manager_properties_t
 
typedef struct _segment_manager segment_manager_t
 
typedef struct segment_manager_main_ segment_manager_main_t
 
typedef struct segment_manager_main_init_args_ segment_manager_main_init_args_t
 

Functions

static segment_manager_tsegment_manager_get (u32 index)
 
static segment_manager_tsegment_manager_get_if_valid (u32 index)
 
static u32 segment_manager_index (segment_manager_t *sm)
 
static svm_queue_tsegment_manager_event_queue (segment_manager_t *sm)
 
segment_manager_tsegment_manager_new ()
 
int segment_manager_init (segment_manager_t *sm, u32 first_seg_size, u32 prealloc_fifo_pairs)
 Initializes segment manager based on options provided. More...
 
svm_fifo_segment_private_tsegment_manager_get_segment (segment_manager_t *sm, u32 segment_index)
 Reads a segment from the segment manager's pool without lock. More...
 
svm_fifo_segment_private_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_segment (segment_manager_t *sm, u32 segment_size)
 Adds segment to segment manager's pool. More...
 
void segment_manager_del_segment (segment_manager_t *sm, svm_fifo_segment_private_t *fs)
 Remove segment without lock. More...
 
void segment_manager_segment_reader_unlock (segment_manager_t *sm)
 
void segment_manager_segment_writer_unlock (segment_manager_t *sm)
 
int segment_manager_add_first_segment (segment_manager_t *sm, u32 segment_size)
 
void segment_manager_del_sessions (segment_manager_t *sm)
 Initiate disconnects for all sessions 'owned' by a segment manager. More...
 
void segment_manager_del (segment_manager_t *sm)
 Removes segment manager. More...
 
void segment_manager_init_del (segment_manager_t *sm)
 
u8 segment_manager_has_fifos (segment_manager_t *sm)
 
int segment_manager_alloc_session_fifos (segment_manager_t *sm, svm_fifo_t **server_rx_fifo, svm_fifo_t **server_tx_fifo, u32 *fifo_segment_index)
 
int segment_manager_try_alloc_fifos (svm_fifo_segment_private_t *fs, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
 
void segment_manager_dealloc_fifos (u32 segment_index, svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
 
svm_queue_tsegment_manager_alloc_queue (svm_fifo_segment_private_t *fs, u32 queue_size)
 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...
 
void segment_manager_app_detach (segment_manager_t *sm)
 
void segment_manager_main_init (segment_manager_main_init_args_t *a)
 
segment_manager_properties_tsegment_manager_properties_init (segment_manager_properties_t *sm)
 

Variables

segment_manager_main_t segment_manager_main
 
segment_manager_tsegment_managers
 Pool of segment managers. More...
 

Macro Definition Documentation

#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)
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
Definition: lock.h:139
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
Definition: lock.h:157

Definition at line 67 of file segment_manager.h.

#define SEGMENT_MANAGER_INVALID_APP_INDEX   ((u32) ~0)

Definition at line 92 of file segment_manager.h.

Typedef Documentation

typedef struct _segment_manager_properties segment_manager_properties_t
typedef struct _segment_manager segment_manager_t

Function Documentation

int segment_manager_add_first_segment ( segment_manager_t sm,
u32  segment_size 
)

+ Here is the caller graph for this function:

int segment_manager_add_segment ( segment_manager_t sm,
u32  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 153 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

svm_queue_t* segment_manager_alloc_queue ( svm_fifo_segment_private_t segment,
u32  queue_size 
)

Allocates shm queue in the first segment.

Must be called with lock held

Definition at line 606 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int segment_manager_alloc_session_fifos ( segment_manager_t sm,
svm_fifo_t **  server_rx_fifo,
svm_fifo_t **  server_tx_fifo,
u32 fifo_segment_index 
)

Definition at line 478 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_app_detach ( segment_manager_t sm)

Definition at line 57 of file segment_manager.c.

+ Here is the caller graph for this function:

void segment_manager_dealloc_fifos ( u32  segment_index,
svm_fifo_t rx_fifo,
svm_fifo_t tx_fifo 
)

Definition at line 560 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_dealloc_queue ( segment_manager_t sm,
svm_queue_t q 
)

Frees shm queue allocated in the first segment.

Definition at line 627 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_del ( segment_manager_t sm)

Removes segment manager.

Since the fifos allocated in the segment keep backpointers to the sessions prior to removing the segment, we call session disconnect. This subsequently propagates into transport.

Definition at line 398 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_del_segment ( segment_manager_t sm,
svm_fifo_segment_private_t fs 
)

Remove segment without lock.

Definition at line 73 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_del_sessions ( segment_manager_t sm)

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

Definition at line 349 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static svm_queue_t* segment_manager_event_queue ( segment_manager_t sm)
inlinestatic

Definition at line 118 of file segment_manager.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static segment_manager_t* segment_manager_get ( u32  index)
inlinestatic

Definition at line 98 of file segment_manager.h.

+ Here is the caller graph for this function:

static segment_manager_t* segment_manager_get_if_valid ( u32  index)
inlinestatic

Definition at line 104 of file segment_manager.h.

+ Here is the caller graph for this function:

svm_fifo_segment_private_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 114 of file segment_manager.c.

+ Here is the caller graph for this function:

svm_fifo_segment_private_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 127 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8 segment_manager_has_fifos ( segment_manager_t sm)

Definition at line 320 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 segment_manager_index ( segment_manager_t sm)
inlinestatic

Definition at line 112 of file segment_manager.h.

+ Here is the caller graph for this function:

int segment_manager_init ( segment_manager_t sm,
u32  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 248 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_init_del ( segment_manager_t sm)

Definition at line 427 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_main_init ( segment_manager_main_init_args_t a)

Definition at line 648 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

segment_manager_t* segment_manager_new ( )

Definition at line 233 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

segment_manager_properties_t* segment_manager_properties_init ( segment_manager_properties_t sm)

Definition at line 41 of file segment_manager.c.

+ Here is the caller graph for this function:

void segment_manager_segment_reader_unlock ( segment_manager_t sm)

Definition at line 134 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void segment_manager_segment_writer_unlock ( segment_manager_t sm)

Definition at line 141 of file segment_manager.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 440 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_main_t segment_manager_main

Definition at line 20 of file segment_manager.c.

segment_manager_t* segment_managers

Pool of segment managers.