}
static void
-vcl_send_session_disconnected_reply (svm_msg_q_t * mq, u32 context,
- session_handle_t handle, int retval)
+vcl_send_session_disconnected_reply (vcl_worker_t * wrk, vcl_session_t * s,
+ int retval)
{
app_session_evt_t _app_evt, *app_evt = &_app_evt;
session_disconnected_reply_msg_t *rmp;
- app_alloc_ctrl_evt_to_vpp (mq, app_evt,
+ app_alloc_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt,
SESSION_CTRL_EVT_DISCONNECTED_REPLY);
rmp = (session_disconnected_reply_msg_t *) app_evt->evt->data;
- rmp->handle = handle;
- rmp->context = context;
+ rmp->handle = s->vpp_handle;
+ rmp->context = wrk->api_client_handle;
rmp->retval = retval;
- app_send_ctrl_evt_to_vpp (mq, app_evt);
+ app_send_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt);
}
static void
-vcl_send_session_reset_reply (svm_msg_q_t * mq, u32 context,
- session_handle_t handle, int retval)
+vcl_send_session_reset_reply (vcl_worker_t * wrk, vcl_session_t * s,
+ int retval)
{
app_session_evt_t _app_evt, *app_evt = &_app_evt;
session_reset_reply_msg_t *rmp;
- app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_RESET_REPLY);
+ app_alloc_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt,
+ SESSION_CTRL_EVT_RESET_REPLY);
rmp = (session_reset_reply_msg_t *) app_evt->evt->data;
- rmp->handle = handle;
- rmp->context = context;
+ rmp->handle = s->vpp_handle;
+ rmp->context = wrk->api_client_handle;
rmp->retval = retval;
- app_send_ctrl_evt_to_vpp (mq, app_evt);
+ app_send_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt);
}
void
{
app_session_evt_t _app_evt, *app_evt = &_app_evt;
session_worker_update_msg_t *mp;
- svm_msg_q_t *mq;
- mq = vcl_session_vpp_evt_q (wrk, s);
- app_alloc_ctrl_evt_to_vpp (mq, app_evt, SESSION_CTRL_EVT_WORKER_UPDATE);
+ app_alloc_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt,
+ SESSION_CTRL_EVT_WORKER_UPDATE);
mp = (session_worker_update_msg_t *) app_evt->evt->data;
mp->client_index = wrk->api_client_handle;
mp->handle = s->vpp_handle;
mp->req_wrk_index = wrk->vpp_wrk_index;
mp->wrk_index = wrk_index;
- app_send_ctrl_evt_to_vpp (mq, app_evt);
+ app_send_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt);
}
int
{
vcl_session_t *session, *listen_session;
svm_fifo_t *rx_fifo, *tx_fifo;
- u32 vpp_wrk_index;
svm_msg_q_t *evt_q;
session = vcl_session_alloc (wrk);
tx_fifo->client_session_index = session->session_index;
rx_fifo->client_thread_index = vcl_get_worker_index ();
tx_fifo->client_thread_index = vcl_get_worker_index ();
- vpp_wrk_index = tx_fifo->master_thread_index;
- vec_validate (wrk->vpp_event_queues, vpp_wrk_index);
- wrk->vpp_event_queues[vpp_wrk_index] = session->vpp_evt_q;
session->vpp_handle = mp->handle;
- session->vpp_thread_index = rx_fifo->master_thread_index;
session->rx_fifo = rx_fifo;
session->tx_fifo = tx_fifo;
vcl_session_connected_handler (vcl_worker_t * wrk,
session_connected_msg_t * mp)
{
- u32 session_index, vpp_wrk_index;
svm_fifo_t *rx_fifo, *tx_fifo;
vcl_session_t *session = 0;
+ u32 session_index;
session_index = mp->context;
session = vcl_session_get (wrk, session_index);
rx_fifo->client_thread_index = vcl_get_worker_index ();
tx_fifo->client_thread_index = vcl_get_worker_index ();
- vpp_wrk_index = tx_fifo->master_thread_index;
- vec_validate (wrk->vpp_event_queues, vpp_wrk_index);
- wrk->vpp_event_queues[vpp_wrk_index] = session->vpp_evt_q;
-
if (mp->ct_rx_fifo)
{
session->ct_rx_fifo = uword_to_pointer (mp->ct_rx_fifo, svm_fifo_t *);
session->rx_fifo = rx_fifo;
session->tx_fifo = tx_fifo;
- session->vpp_thread_index = rx_fifo->master_thread_index;
session->transport.is_ip4 = mp->lcl.is_ip4;
clib_memcpy_fast (&session->transport.lcl_ip, &mp->lcl.ip,
sizeof (session->transport.lcl_ip));
session->transport.lcl_port = mp->lcl_port;
vcl_session_table_add_listener (wrk, mp->handle, sid);
session->session_state = VCL_STATE_LISTEN;
-
session->vpp_evt_q = uword_to_pointer (mp->vpp_evt_q, svm_msg_q_t *);
- vec_validate (wrk->vpp_event_queues, 0);
- wrk->vpp_event_queues[0] = session->vpp_evt_q;
if (vcl_session_is_cl (session))
{
return;
}
- s->vpp_thread_index = mp->vpp_thread_index;
s->vpp_handle = mp->new_handle;
s->vpp_evt_q = uword_to_pointer (mp->vpp_evt_q, svm_msg_q_t *);
- vec_validate (wrk->vpp_event_queues, s->vpp_thread_index);
- wrk->vpp_event_queues[s->vpp_thread_index] = s->vpp_evt_q;
-
vcl_session_table_del_vpp_handle (wrk, mp->handle);
vcl_session_table_add_vpp_handle (wrk, mp->new_handle, s->session_index);
SESSION_IO_EVT_TX, SVM_Q_WAIT);
VDBG (0, "Migrated 0x%lx to thread %u 0x%lx", mp->handle,
- s->vpp_thread_index, mp->new_handle);
+ mp->vpp_thread_index, mp->new_handle);
}
static vcl_session_t *
vppcom_session_disconnect (u32 session_handle)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
- svm_msg_q_t *vpp_evt_q;
vcl_session_t *session, *listen_session;
vcl_session_state_t state;
u64 vpp_handle;
if (state == VCL_STATE_VPP_CLOSING)
{
- vpp_evt_q = vcl_session_vpp_evt_q (wrk, session);
- vcl_send_session_disconnected_reply (vpp_evt_q, wrk->api_client_handle,
- vpp_handle, 0);
+ vcl_send_session_disconnected_reply (wrk, session, 0);
VDBG (1, "session %u [0x%llx]: sending disconnect REPLY...",
session->session_index, vpp_handle);
}
}
else if (session->session_state == VCL_STATE_DISCONNECT)
{
- vcl_send_session_reset_reply (vcl_session_vpp_evt_q (wrk, session),
- wrk->api_client_handle,
- session->vpp_handle, 0);
+ vcl_send_session_reset_reply (wrk, session, 0);
session->session_state = VCL_STATE_UPDATED;
}
return;
vcl_session_table_del_vpp_handle (wrk, accepted_msg->handle);
vcl_send_session_accepted_reply (session->vpp_evt_q,
accepted_msg->context,
- session->vpp_handle, -1);
+ accepted_msg->handle, -1);
}
clib_fifo_free (session->accept_evts_fifo);
s->vep.vep_sh, rv, vppcom_retval_str (rv));
next_sh = s->vep.next_sh;
}
- goto cleanup;
+ goto free_session;
}
if (s->flags & VCL_SESSION_F_IS_VEP_SESSION)
}
else if (s->session_state == VCL_STATE_DISCONNECT)
{
- svm_msg_q_t *mq = vcl_session_vpp_evt_q (wrk, s);
- vcl_send_session_reset_reply (mq, wrk->api_client_handle,
- s->vpp_handle, 0);
+ vcl_send_session_reset_reply (wrk, s, 0);
}
else if (s->session_state == VCL_STATE_DETACHED)
{
{
if (vcl_session_is_closing (s))
return vcl_session_closing_error (s);
- svm_fifo_unset_event (s->rx_fifo);
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
+ svm_fifo_unset_event (rx_fifo);
return VPPCOM_EWOULDBLOCK;
}
while (svm_fifo_is_empty_cons (rx_fifo))
if (vcl_session_is_closing (s))
return vcl_session_closing_error (s);
- svm_fifo_unset_event (s->rx_fifo);
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
+ svm_fifo_unset_event (rx_fifo);
svm_msg_q_lock (mq);
if (svm_msg_q_is_empty (mq))
svm_msg_q_wait (mq);
if (svm_fifo_is_empty_cons (rx_fifo))
{
- svm_fifo_unset_event (s->rx_fifo);
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
+ svm_fifo_unset_event (rx_fifo);
if (!svm_fifo_is_empty_cons (rx_fifo)
- && svm_fifo_set_event (s->rx_fifo) && is_nonblocking)
+ && svm_fifo_set_event (rx_fifo) && is_nonblocking)
{
vec_add2 (wrk->unhandled_evts_vector, e, 1);
e->event_type = SESSION_IO_EVT_RX;
e->session_index = s->session_index;
}
}
- else if (PREDICT_FALSE (rv < n))
+ else if (PREDICT_FALSE (rv < n && !s->is_dgram))
{
/* More data enqueued while reading. Try to drain it
- * or fill the buffer */
+ * or fill the buffer. Avoid doing that for dgrams */
buf += rv;
n -= rv;
goto read_again;
is_nonblocking = vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK);
is_ct = vcl_session_is_ct (s);
mq = wrk->app_event_queue;
- rx_fifo = s->rx_fifo;
+ rx_fifo = is_ct ? s->ct_rx_fifo : s->rx_fifo;
s->flags &= ~VCL_SESSION_F_HAS_RX_EVT;
- if (is_ct)
- svm_fifo_unset_event (s->rx_fifo);
-
if (svm_fifo_is_empty_cons (rx_fifo))
{
if (is_nonblocking)
{
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
svm_fifo_unset_event (rx_fifo);
return VPPCOM_EWOULDBLOCK;
}
if (vcl_session_is_closing (s))
return vcl_session_closing_error (s);
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
svm_fifo_unset_event (rx_fifo);
svm_msg_q_lock (mq);
if (svm_msg_q_is_empty (mq))
if (svm_fifo_max_dequeue_cons (rx_fifo) == n_read)
{
- svm_fifo_unset_event (s->rx_fifo);
+ if (is_ct)
+ svm_fifo_unset_event (s->rx_fifo);
+ svm_fifo_unset_event (rx_fifo);
if (svm_fifo_max_dequeue_cons (rx_fifo) != n_read
- && svm_fifo_set_event (s->rx_fifo)
+ && svm_fifo_set_event (rx_fifo)
&& vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK))
{
session_event_t *e;
{
vcl_worker_t *wrk = vcl_worker_get_current ();
vcl_session_t *s;
+ u8 is_ct;
s = vcl_session_get_w_handle (wrk, session_handle);
if (PREDICT_FALSE (!s || (s->flags & VCL_SESSION_F_IS_VEP)))
return;
- svm_fifo_dequeue_drop (s->rx_fifo, n_bytes);
+ is_ct = vcl_session_is_ct (s);
+ svm_fifo_dequeue_drop (is_ct ? s->ct_rx_fifo : s->rx_fifo, n_bytes);
ASSERT (s->rx_bytes_pending < n_bytes);
s->rx_bytes_pending -= n_bytes;