X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvcl%2Fvppcom.c;h=b91c3a3bff47e5e871e9af46a2b275b7804167fb;hb=41bc8615096b8a7d92707792dfd2b14ded40773e;hp=73ec40b42b82ea04deeb9e1842f5922bab731e8e;hpb=fa3884f8a1cf5493dd7733404811b63ee9c1e4d9;p=vpp.git diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 73ec40b42b8..b91c3a3bff4 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -455,9 +455,9 @@ vcl_session_accepted_handler (vcl_worker_t * wrk, session_accepted_msg_t * mp, goto error; } - if (vcl_segment_attach_session (mp->segment_handle, mp->server_rx_fifo, - mp->server_tx_fifo, - mp->vpp_event_queue_address, 0, session)) + if (vcl_segment_attach_session ( + mp->segment_handle, mp->server_rx_fifo, mp->server_tx_fifo, + mp->vpp_event_queue_address, mp->mq_index, 0, session)) { VDBG (0, "failed to attach fifos for %u", session->session_index); goto error; @@ -525,9 +525,9 @@ vcl_session_connected_handler (vcl_worker_t * wrk, session->vpp_handle = mp->handle; - if (vcl_segment_attach_session (mp->segment_handle, mp->server_rx_fifo, - mp->server_tx_fifo, - mp->vpp_event_queue_address, 0, session)) + if (vcl_segment_attach_session ( + mp->segment_handle, mp->server_rx_fifo, mp->server_tx_fifo, + mp->vpp_event_queue_address, mp->mq_index, 0, session)) { VDBG (0, "failed to attach fifos for %u", session->session_index); session->session_state = VCL_STATE_DETACHED; @@ -538,7 +538,8 @@ vcl_session_connected_handler (vcl_worker_t * wrk, if (mp->ct_rx_fifo) { if (vcl_segment_attach_session (mp->ct_segment_handle, mp->ct_rx_fifo, - mp->ct_tx_fifo, (uword) ~0, 1, session)) + mp->ct_tx_fifo, (uword) ~0, ~0, 1, + session)) { VDBG (0, "failed to attach ct fifos for %u", session->session_index); session->session_state = VCL_STATE_DETACHED; @@ -654,7 +655,8 @@ vcl_session_bound_handler (vcl_worker_t * wrk, session_bound_msg_t * mp) if (vcl_session_is_cl (session)) { if (vcl_segment_attach_session (mp->segment_handle, mp->rx_fifo, - mp->tx_fifo, mp->vpp_evt_q, 0, session)) + mp->tx_fifo, mp->vpp_evt_q, mp->mq_index, + 0, session)) { VDBG (0, "failed to attach fifos for %u", session->session_index); session->session_state = VCL_STATE_DETACHED; @@ -984,7 +986,7 @@ vcl_session_worker_update_reply_handler (vcl_worker_t * wrk, void *data) if (s->rx_fifo) { if (vcl_segment_attach_session (msg->segment_handle, msg->rx_fifo, - msg->tx_fifo, (uword) ~0, 0, s)) + msg->tx_fifo, (uword) ~0, ~0, 0, s)) { VDBG (0, "failed to attach fifos for %u", s->session_index); return; @@ -1366,8 +1368,8 @@ vppcom_app_create (const char *app_name) vcm->main_cpu = pthread_self (); vcm->main_pid = getpid (); vcm->app_name = format (0, "%s", app_name); - fifo_segment_main_init (&vcm->segment_main, vcl_cfg->segment_baseva, - 20 /* timeout in secs */ ); + fifo_segment_main_init (&vcm->segment_main, (uword) ~0, + 20 /* timeout in secs */); pool_alloc (vcm->workers, vcl_cfg->max_workers); clib_spinlock_init (&vcm->workers_lock); clib_rwlock_init (&vcm->segment_table_lock); @@ -1643,9 +1645,6 @@ vppcom_session_listen (uint32_t listen_sh, uint32_t q_len) if (!listen_session || (listen_session->flags & VCL_SESSION_F_IS_VEP)) return VPPCOM_EBADFD; - if (q_len == 0 || q_len == ~0) - q_len = vcm->cfg.listen_queue_size; - listen_vpp_handle = listen_session->vpp_handle; if (listen_session->session_state == VCL_STATE_LISTEN) { @@ -1988,7 +1987,7 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n, u8 is_ct; if (PREDICT_FALSE (!buf)) - return VPPCOM_EINVAL; + return VPPCOM_EFAULT; s = vcl_session_get_w_handle (wrk, session_handle); if (PREDICT_FALSE (!s || (s->flags & VCL_SESSION_F_IS_VEP))) @@ -2194,7 +2193,7 @@ vppcom_session_free_segments (uint32_t session_handle, uint32_t 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); + ASSERT (s->rx_bytes_pending >= n_bytes); s->rx_bytes_pending -= n_bytes; } @@ -3014,8 +3013,9 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, break; vcl_fifo_rx_evt_valid_or_break (s); session_events = s->vep.ev.events; - if (!(EPOLLIN & s->vep.ev.events) - || (s->flags & VCL_SESSION_F_HAS_RX_EVT)) + if (!(EPOLLIN & s->vep.ev.events) || + (s->flags & VCL_SESSION_F_HAS_RX_EVT) || + (s->vep.lt_next != VCL_INVALID_SESSION_INDEX)) break; add_event = 1; events[*num_ev].events = EPOLLIN; @@ -3045,7 +3045,8 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, break; session_events = s->vep.ev.events; sid = s->session_index; - if (!(EPOLLIN & session_events)) + if (!(EPOLLIN & session_events) || + (s->vep.lt_next != VCL_INVALID_SESSION_INDEX)) break; add_event = 1; events[*num_ev].events = EPOLLIN; @@ -3266,7 +3267,7 @@ static void vcl_epoll_wait_handle_lt (vcl_worker_t *wrk, struct epoll_event *events, int maxevents, u32 *n_evts) { - u32 add_event, next; + u32 add_event = 0, next; vcl_session_t *s; u64 evt_data; int rv; @@ -3361,6 +3362,10 @@ vppcom_epoll_wait (uint32_t vep_handle, struct epoll_event *events, } vec_reset_length (wrk->unhandled_evts_vector); } + + if (PREDICT_FALSE (wrk->ep_lt_current != VCL_INVALID_SESSION_INDEX)) + vcl_epoll_wait_handle_lt (wrk, events, maxevents, &n_evts); + /* Request to only drain unhandled */ if ((int) wait_for_time == -2) return n_evts; @@ -3373,9 +3378,6 @@ vppcom_epoll_wait (uint32_t vep_handle, struct epoll_event *events, n_evts = vppcom_epoll_wait_condvar (wrk, events, maxevents, n_evts, wait_for_time); - if (PREDICT_FALSE (wrk->ep_lt_current != VCL_INVALID_SESSION_INDEX)) - vcl_epoll_wait_handle_lt (wrk, events, maxevents, &n_evts); - return n_evts; } @@ -4058,6 +4060,10 @@ vppcom_session_sendto (uint32_t session_handle, void *buffer, if (!vcl_session_is_cl (s)) return VPPCOM_EINVAL; + s->transport.is_ip4 = ep->is_ip4; + s->transport.rmt_port = ep->port; + vcl_ip_copy_from_ep (&s->transport.rmt_ip, ep); + /* Session not connected/bound in vpp. Create it by 'connecting' it */ if (PREDICT_FALSE (s->session_state == VCL_STATE_CLOSED)) { @@ -4073,10 +4079,6 @@ vppcom_session_sendto (uint32_t session_handle, void *buffer, return rv; s = vcl_session_get (wrk, session_index); } - - s->transport.is_ip4 = ep->is_ip4; - s->transport.rmt_port = ep->port; - vcl_ip_copy_from_ep (&s->transport.rmt_ip, ep); } if (flags) @@ -4386,22 +4388,18 @@ int vppcom_add_cert_key_pair (vppcom_cert_key_pair_t *ckpair) { if (vcm->cfg.vpp_app_socket_api) - { - clib_warning ("not supported"); - return VPPCOM_EINVAL; - } - return vcl_bapi_add_cert_key_pair (ckpair); + return vcl_sapi_add_cert_key_pair (ckpair); + else + return vcl_bapi_add_cert_key_pair (ckpair); } int vppcom_del_cert_key_pair (uint32_t ckpair_index) { if (vcm->cfg.vpp_app_socket_api) - { - clib_warning ("not supported"); - return VPPCOM_EINVAL; - } - return vcl_bapi_del_cert_key_pair (ckpair_index); + return vcl_sapi_del_cert_key_pair (ckpair_index); + else + return vcl_bapi_del_cert_key_pair (ckpair_index); } /*