15 #ifndef SRC_VNET_SESSION_SEGMENT_MANAGER_H_ 16 #define SRC_VNET_SESSION_SEGMENT_MANAGER_H_ 25 typedef struct _segment_manager_properties
40 typedef struct _segment_manager
56 u8 first_is_protected;
64 #define segment_manager_foreach_segment_w_lock(VAR, SM, BODY) \ 66 clib_rwlock_reader_lock (&(SM)->segments_rwlock); \ 67 pool_foreach((VAR), ((SM)->segments), (BODY)); \ 68 clib_rwlock_reader_unlock (&(SM)->segments_rwlock); \ 89 #define SEGMENT_MANAGER_INVALID_APP_INDEX ((u32) ~0) 117 return sm->event_queue;
122 u32 prealloc_fifo_pairs);
145 u32 * fifo_segment_index);
147 u32 rx_fifo_size,
u32 tx_fifo_size,
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)
static segment_manager_t * segment_manager_get_if_valid(u32 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)
struct _segment_manager_properties segment_manager_properties_t
int segment_manager_init(segment_manager_t *sm, u32 first_seg_size, u32 prealloc_fifo_pairs)
Initializes segment manager based on options provided.
clib_valloc_main_t va_allocator
Virtual address allocator.
struct segment_manager_main_init_args_ segment_manager_main_init_args_t
segment_manager_t * segment_managers
Pool of segment managers.
segment_manager_main_t segment_manager_main
u8 segment_manager_has_fifos(segment_manager_t *sm)
struct _svm_fifo svm_fifo_t
void segment_manager_segment_reader_unlock(segment_manager_t *sm)
enum ssvm_segment_type_ ssvm_segment_type_t
void segment_manager_app_detach(segment_manager_t *sm)
int segment_manager_add_first_segment(segment_manager_t *sm, u32 segment_size)
Simple first-fit virtual space allocator.
void segment_manager_del_segment(segment_manager_t *sm, svm_fifo_segment_private_t *fs)
Remove segment without lock.
u32 segment_manager_evt_q_expected_size(u32 q_size)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
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.
int segment_manager_add_segment(segment_manager_t *sm, u32 segment_size)
Adds segment to segment manager's pool.
segment_manager_properties_t * segment_manager_properties_init(segment_manager_properties_t *sm)
Unidirectional shared-memory multi-ring message queue.
void segment_manager_dealloc_fifos(u32 segment_index, svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void segment_manager_segment_writer_unlock(segment_manager_t *sm)
static u32 segment_manager_index(segment_manager_t *sm)
svm_msg_q_t * segment_manager_alloc_queue(svm_fifo_segment_private_t *fs, segment_manager_properties_t *props)
Allocates shm queue in the first segment.
void segment_manager_init_del(segment_manager_t *sm)
struct segment_manager_main_ segment_manager_main_t
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
static svm_msg_q_t * segment_manager_event_queue(segment_manager_t *sm)
struct _segment_manager segment_manager_t
struct _svm_queue svm_queue_t
void segment_manager_dealloc_queue(segment_manager_t *sm, svm_queue_t *q)
Frees shm queue allocated in the first segment.
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.
segment_manager_t * segment_managers
Pool of segment managers.
static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped)
void segment_manager_main_init(segment_manager_main_init_args_t *a)
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions 'owned' by a segment manager.
static segment_manager_t * segment_manager_get(u32 index)
segment_manager_t * segment_manager_new()