summaryrefslogtreecommitdiffstats
path: root/src/vcl
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-07-04 04:15:05 -0700
committerDamjan Marion <dmarion@me.com>2018-07-17 09:02:17 +0000
commit3c2fed5145d9e40a9ecd178c2866c813eddc6203 (patch)
tree7ff2408f3b1c4a52fb6d7cd091508de1ce950e5f /src/vcl
parent5da96a77a84ae5414debbc46d390464d51010113 (diff)
session: use msg queue for events
Change-Id: I3c58367eec2243fe19b75be78a175c5261863e9e Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vcl_bapi.c6
-rw-r--r--src/vcl/vcl_private.h2
-rw-r--r--src/vcl/vppcom.c31
3 files changed, 19 insertions, 20 deletions
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index cc3179d860a..ca65782e9c6 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -99,7 +99,7 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
}
vcm->app_event_queue =
- uword_to_pointer (mp->app_event_queue_address, svm_queue_t *);
+ uword_to_pointer (mp->app_event_queue_address, svm_msg_q_t *);
vcm->app_state = STATE_APP_ATTACHED;
}
@@ -291,7 +291,7 @@ done:
VCL_IO_SESSIONS_UNLOCK ();
}
session->vpp_evt_q = uword_to_pointer (mp->vpp_event_queue_address,
- svm_queue_t *);
+ svm_msg_q_t *);
rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
rx_fifo->client_session_index = session_index;
@@ -431,7 +431,7 @@ vl_api_accept_session_t_handler (vl_api_accept_session_t * mp)
session->rx_fifo = rx_fifo;
session->tx_fifo = tx_fifo;
session->vpp_evt_q = uword_to_pointer (mp->vpp_event_queue_address,
- svm_queue_t *);
+ svm_msg_q_t *);
session->session_state = STATE_ACCEPT;
session->transport.rmt_port = mp->port;
session->transport.is_ip4 = mp->is_ip4;
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 4283b6e1167..aba4839f129 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -194,7 +194,7 @@ typedef struct vppcom_main_t_
clib_bitmap_t *ex_bitmap;
/* Our event queue */
- svm_queue_t *app_event_queue;
+ svm_msg_q_t *app_event_queue;
/* unique segment name counter */
u32 unique_segment_index;
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 1fd138e6dd3..0d077caa797 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1164,16 +1164,19 @@ vppcom_session_read_ready (vcl_session_t * session, u32 session_index)
}
rv = ready;
- if (vcm->app_event_queue->cursize &&
- !pthread_mutex_trylock (&vcm->app_event_queue->mutex))
+ if (!svm_msg_q_is_empty (vcm->app_event_queue) &&
+ !pthread_mutex_trylock (&vcm->app_event_queue->q->mutex))
{
- u32 i, n_to_dequeue = vcm->app_event_queue->cursize;
- session_fifo_event_t e;
+ u32 i, n_to_dequeue = vcm->app_event_queue->q->cursize;
+ svm_msg_q_msg_t msg;
for (i = 0; i < n_to_dequeue; i++)
- svm_queue_sub_raw (vcm->app_event_queue, (u8 *) & e);
+ {
+ svm_queue_sub_raw (vcm->app_event_queue->q, (u8 *) & msg);
+ svm_msg_q_free_msg (vcm->app_event_queue, &msg);
+ }
- pthread_mutex_unlock (&vcm->app_event_queue->mutex);
+ pthread_mutex_unlock (&vcm->app_event_queue->q->mutex);
}
done:
return rv;
@@ -1184,8 +1187,7 @@ vppcom_session_write (uint32_t session_index, void *buf, size_t n)
{
vcl_session_t *session = 0;
svm_fifo_t *tx_fifo = 0;
- svm_queue_t *q;
- session_fifo_event_t evt;
+ svm_msg_q_t *mq;
session_state_t state;
int rv, n_write, is_nonblocking;
u32 poll_et;
@@ -1241,18 +1243,15 @@ vppcom_session_write (uint32_t session_index, void *buf, size_t n)
if ((n_write > 0) && svm_fifo_set_event (tx_fifo))
{
- /* Fabricate TX event, send to vpp */
- evt.fifo = tx_fifo;
- evt.event_type = FIFO_EVENT_APP_TX;
-
+ /* Send TX event to vpp */
VCL_SESSION_LOCK_AND_GET (session_index, &session);
- q = session->vpp_evt_q;
- ASSERT (q);
- svm_queue_add (q, (u8 *) & evt, 0 /* do wait for mutex */ );
+ mq = session->vpp_evt_q;
+ ASSERT (mq);
+ app_send_io_evt_to_vpp (mq, tx_fifo, FIFO_EVENT_APP_TX, SVM_Q_WAIT);
VCL_SESSION_UNLOCK ();
VDBG (1, "VCL<%d>: vpp handle 0x%llx, sid %u: added FIFO_EVENT_APP_TX "
"to vpp_event_q %p, n_write %d", getpid (),
- vpp_handle, session_index, q, n_write);
+ vpp_handle, session_index, mq, n_write);
}
if (n_write <= 0)