57 memset (ca, 0,
sizeof (*ca));
68 clib_warning (
"svm_fifo_segment_create ('%s', %d) failed",
71 return VNET_API_ERROR_SVM_SEGMENT_CREATE_FAIL;
87 memset (ca, 0,
sizeof (*ca));
88 segment_name =
format (0,
"%d-%d%c", getpid (), segment_name_counter++, 0);
89 add_segment_size = sm->properties->add_segment_size ?
103 segment_name =
format (0,
"%d-%d%c", getpid (), segment_name_counter++, 0);
115 if (private_segment_index != ~0)
118 memset (a, 0,
sizeof (*a));
127 clib_warning (
"Failed to create process private segment");
130 ASSERT (private_segment_index != ~0);
145 sm->properties = properties;
149 if (sm->properties->use_private_segment == 0)
160 if (private_segment_index == ~0)
162 ASSERT (private_segment_index != ~0);
163 vec_add1 (sm->segment_indices, private_segment_index);
183 for (j = 0; j <
vec_len (sm->segment_indices); j++)
199 u32 session_index, thread_index;
202 session_index = fifo->master_session_index;
203 thread_index = fifo->master_thread_index;
225 u32 fifo_segment_index)
232 ASSERT (app->cb_fns.add_segment_callback);
235 return app->cb_fns.add_segment_callback (app->api_client_index, seg_name,
243 u32 * fifo_segment_index)
246 u32 fifo_size, sm_index;
247 u8 added_a_segment = 0;
258 for (i = 0; i <
vec_len (sm->segment_indices); i++)
260 *fifo_segment_index = sm->segment_indices[
i];
264 fifo_size = sm->properties->rx_fifo_size;
265 fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
271 fifo_size = sm->properties->tx_fifo_size;
272 fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
277 if (*server_rx_fifo == 0)
280 if (*server_tx_fifo != 0)
288 if (*server_tx_fifo == 0)
290 if (*server_rx_fifo != 0)
302 if (*server_rx_fifo == 0)
304 if (sm->properties->add_segment)
308 clib_warning (
"added a segment, still cant allocate a fifo");
310 return SESSION_ERROR_NEW_SEG_NO_SPACE;
316 return VNET_API_ERROR_URI_FIFO_CREATE_FAILED;
326 return SESSION_ERROR_NO_SPACE;
332 (*server_tx_fifo)->segment_manager = sm_index;
333 (*server_rx_fifo)->segment_manager = sm_index;
364 if (sm->segment_indices[0] != svm_segment_index
369 vec_del1 (sm->segment_indices, svm_segment_index);
385 ASSERT (sm->segment_indices != 0);
410 ASSERT (sm->segment_indices != 0);
static void segment_manager_alloc_process_private_segment(segment_manager_properties_t *props)
sll srl srl sll sra u16x4 i
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
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)
struct _segment_manager_properties segment_manager_properties_t
void unix_shared_memory_queue_free(unix_shared_memory_queue_t *q)
int session_manager_add_first_segment(segment_manager_t *sm, u32 segment_size)
segment_manager_t * segment_managers
Pool of segment managers.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
ssvm_shared_header_t * sh
u32 private_segment_index
Process private segment index.
static void clib_spinlock_free(clib_spinlock_t *p)
struct _stream_session_t stream_session_t
struct _svm_fifo svm_fifo_t
static int session_manager_add_segment_i(segment_manager_t *sm, u32 segment_size, u8 *segment_name)
void segment_manager_get_segment_info(u32 index, u8 **name, u32 *size)
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
unix_shared_memory_queue_t * segment_manager_alloc_queue(segment_manager_t *sm, u32 queue_size)
Allocates shm queue in the first segment.
static void ssvm_pop_heap(void *oldheap)
void session_send_session_evt_to_thread(u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
static void clib_spinlock_init(clib_spinlock_t *p)
int svm_fifo_segment_create_process_private(svm_fifo_segment_create_args_t *a)
Create an svm fifo segment in process-private memory.
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_del1(v, i)
Delete the element at index I.
svm_fifo_segment_header_t * h
static u8 svm_fifo_segment_has_fifos(svm_fifo_segment_private_t *fifo_segment)
void segment_manager_dealloc_queue(segment_manager_t *sm, unix_shared_memory_queue_t *q)
Frees shm queue allocated in the first segment.
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
struct _application application_t
static int segment_manager_notify_app_seg_add(segment_manager_t *sm, u32 fifo_segment_index)
static svm_fifo_segment_private_t * svm_fifo_get_segment(u32 segment_index)
static u32 segment_manager_index(segment_manager_t *sm)
unix_shared_memory_queue_t * unix_shared_memory_queue_init(int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty)
void svm_fifo_segment_free_fifo(svm_fifo_segment_private_t *s, svm_fifo_t *f, svm_fifo_segment_freelist_t list_index)
int svm_fifo_segment_create(svm_fifo_segment_create_args_t *a)
(master) create an svm fifo segment
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
static u64 stream_session_handle(stream_session_t *s)
int segment_manager_init(segment_manager_t *sm, segment_manager_properties_t *properties, u32 first_seg_size)
Initializes segment manager based on options provided.
void segment_manager_dealloc_fifos(u32 svm_segment_index, svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 segment_name_counter
Counter used to build segment names.
application_t * application_get(u32 index)
struct _segment_manager segment_manager_t
u32 preallocated_fifo_pairs
int session_manager_add_segment(segment_manager_t *sm)
u32 default_fifo_size
Default fifo and segment size.
void svm_fifo_segment_delete(svm_fifo_segment_private_t *s)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static stream_session_t * stream_session_get(u32 si, u32 thread_index)
svm_fifo_t * svm_fifo_segment_alloc_fifo(svm_fifo_segment_private_t *s, u32 data_size_in_bytes, svm_fifo_segment_freelist_t list_index)