summaryrefslogtreecommitdiffstats
path: root/src/svm/message_queue.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-08-01 07:53:18 -0700
committerDamjan Marion <dmarion@me.com>2018-08-03 09:11:41 +0000
commitc470e22f12a68f06990f57f12f551fee50b6bb0d (patch)
tree9215cfda7e70ffd2f6789b638b895ea3a7d3d7a3 /src/svm/message_queue.c
parentc64ba6dc6ab9e3b06feac1a86c2f59d7052609ce (diff)
svm: add support for eventfd signaling to queue
Support the use of eventfds to signal queue updates between consumer and producer pairs. Change-Id: Idb6133be2b731fff78ed520daf9d2e0399642aab Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/message_queue.c')
-rw-r--r--src/svm/message_queue.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/svm/message_queue.c b/src/svm/message_queue.c
index 1b2d2e148ed..e97cab898e8 100644
--- a/src/svm/message_queue.c
+++ b/src/svm/message_queue.c
@@ -39,12 +39,12 @@ svm_msg_q_t *
svm_msg_q_alloc (svm_msg_q_cfg_t * cfg)
{
svm_msg_q_ring_cfg_t *ring_cfg;
+ uword rings_sz = 0, mq_sz;
svm_msg_q_ring_t *ring;
u8 *base, *rings_ptr;
- uword rings_sz = 0;
vec_header_t *vh;
+ u32 vec_sz, q_sz;
svm_msg_q_t *mq;
- u32 vec_sz;
int i;
ASSERT (cfg);
@@ -58,13 +58,17 @@ svm_msg_q_alloc (svm_msg_q_cfg_t * cfg)
rings_sz += (uword) ring_cfg->nitems * ring_cfg->elsize;
}
- base = clib_mem_alloc_aligned (sizeof (svm_msg_q_t) + vec_sz + rings_sz,
- CLIB_CACHE_LINE_BYTES);
+ q_sz = sizeof (svm_queue_t) + cfg->q_nitems * sizeof (svm_msg_q_msg_t);
+ mq_sz = sizeof (svm_msg_q_t) + vec_sz + rings_sz + q_sz;
+ base = clib_mem_alloc_aligned (mq_sz, CLIB_CACHE_LINE_BYTES);
if (!base)
return 0;
mq = (svm_msg_q_t *) base;
- vh = (vec_header_t *) (base + sizeof (svm_msg_q_t));
+ mq->q = svm_queue_init (base + sizeof (svm_msg_q_t), cfg->q_nitems,
+ sizeof (svm_msg_q_msg_t));
+ mq->q->consumer_pid = cfg->consumer_pid;
+ vh = (vec_header_t *) ((u8 *) mq->q + q_sz);
vh->len = cfg->n_rings;
mq->rings = (svm_msg_q_ring_t *) (vh + 1);
rings_ptr = (u8 *) mq->rings + vec_sz;
@@ -82,8 +86,6 @@ svm_msg_q_alloc (svm_msg_q_cfg_t * cfg)
rings_ptr += (uword) ring->nitems * ring->elsize;
}
}
- mq->q = svm_queue_init (cfg->q_nitems, sizeof (svm_msg_q_msg_t),
- cfg->consumer_pid, 0);
return mq;
}