diff options
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r-- | src/vnet/session/segment_manager.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index 31bb0c3aab5..b00bcd5bbc8 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -599,25 +599,52 @@ segment_manager_dealloc_fifos (u32 segment_index, svm_fifo_t * rx_fifo, segment_manager_segment_reader_unlock (sm); } +u32 +segment_manager_evt_q_expected_size (u32 q_len) +{ + u32 fifo_evt_size, notif_q_size, q_hdrs; + u32 msg_q_sz, fifo_evt_ring_sz, session_ntf_ring_sz; + + fifo_evt_size = 1 << max_log2 (sizeof (session_fifo_event_t)); + notif_q_size = clib_max (16, q_len >> 4); + + msg_q_sz = q_len * sizeof (svm_msg_q_msg_t); + fifo_evt_ring_sz = q_len * fifo_evt_size; + session_ntf_ring_sz = notif_q_size * 256; + q_hdrs = sizeof (svm_queue_t) + sizeof (svm_msg_q_t); + + return (msg_q_sz + fifo_evt_ring_sz + session_ntf_ring_sz + q_hdrs); +} + /** * Allocates shm queue in the first segment * * Must be called with lock held */ -svm_queue_t * +svm_msg_q_t * segment_manager_alloc_queue (svm_fifo_segment_private_t * segment, u32 queue_size) { - ssvm_shared_header_t *sh; - svm_queue_t *q; + u32 fifo_evt_size, session_evt_size = 256, notif_q_size; + svm_msg_q_cfg_t _cfg, *cfg = &_cfg; + svm_msg_q_t *q; void *oldheap; - sh = segment->ssvm.sh; + fifo_evt_size = sizeof (session_fifo_event_t); + notif_q_size = clib_max (16, queue_size >> 4); + /* *INDENT-OFF* */ + svm_msg_q_ring_cfg_t rc[SESSION_MQ_N_RINGS] = { + {queue_size, fifo_evt_size, 0}, + {notif_q_size, session_evt_size, 0} + }; + /* *INDENT-ON* */ + cfg->consumer_pid = 0; + cfg->n_rings = 2; + cfg->q_nitems = queue_size; + cfg->ring_cfgs = rc; - oldheap = ssvm_push_heap (sh); - q = svm_queue_init (queue_size, sizeof (session_fifo_event_t), - 0 /* consumer pid */ , - 0 /* signal when queue non-empty */ ); + oldheap = ssvm_push_heap (segment->ssvm.sh); + q = svm_msg_q_alloc (cfg); ssvm_pop_heap (oldheap); return q; } |