svm: add custom q implementation for mq
Add separate queue implementation for the message queue as it's custom
tailored for fifo segments as opposed to binary api.
Also move eventfds to the private data structures.
Type: refactor
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I6df0c824ecd94c7904516373f92a9fffc6b04736
diff --git a/src/vnet/session/session_debug.c b/src/vnet/session/session_debug.c
index cd4198c..c042e9e 100644
--- a/src/vnet/session/session_debug.c
+++ b/src/vnet/session/session_debug.c
@@ -123,6 +123,7 @@
vlib_main_t *vm = &vlib_global_main;
u32 my_thread_index = vm->thread_index;
session_event_t _e, *e = &_e;
+ svm_msg_q_shared_queue_t *sq;
svm_msg_q_ring_t *ring;
session_t *s0;
svm_msg_q_msg_t *msg;
@@ -130,11 +131,12 @@
int i, index;
mq = session_main_get_vpp_event_queue (my_thread_index);
- index = mq->q->head;
+ sq = mq->q.shr;
+ index = sq->head;
- for (i = 0; i < mq->q->cursize; i++)
+ for (i = 0; i < sq->cursize; i++)
{
- msg = (svm_msg_q_msg_t *) (&mq->q->data[0] + mq->q->elsize * index);
+ msg = (svm_msg_q_msg_t *) (&sq->data[0] + sq->elsize * index);
ring = svm_msg_q_ring (mq, msg->ring_index);
clib_memcpy_fast (e, svm_msg_q_msg_data (mq, msg), ring->elsize);
@@ -170,7 +172,7 @@
index++;
- if (index == mq->q->maxsize)
+ if (index == sq->maxsize)
index = 0;
}
}
@@ -210,6 +212,7 @@
u8
session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e)
{
+ svm_msg_q_shared_queue_t *sq;
session_evt_elt_t *elt;
session_worker_t *wrk;
int i, index, found = 0;
@@ -226,16 +229,17 @@
* Search evt queue
*/
mq = wrk->vpp_event_queue;
- index = mq->q->head;
- for (i = 0; i < mq->q->cursize; i++)
+ sq = mq->q.shr;
+ index = sq->head;
+ for (i = 0; i < sq->cursize; i++)
{
- msg = (svm_msg_q_msg_t *) (&mq->q->data[0] + mq->q->elsize * index);
+ msg = (svm_msg_q_msg_t *) (&sq->data[0] + sq->elsize * index);
ring = svm_msg_q_ring (mq, msg->ring_index);
clib_memcpy_fast (e, svm_msg_q_msg_data (mq, msg), ring->elsize);
found = session_node_cmp_event (e, f);
if (found)
return 1;
- index = (index + 1) % mq->q->maxsize;
+ index = (index + 1) % sq->maxsize;
}
/*
* Search pending events vector