if (!(s->flags & SESSION_F_CUSTOM_TX))
{
s->flags |= SESSION_F_CUSTOM_TX;
- if (svm_fifo_set_event (s->tx_fifo))
+ if (svm_fifo_set_event (s->tx_fifo)
+ || transport_connection_is_descheduled (tc))
{
session_worker_t *wrk;
session_evt_elt_t *elt;
elt = session_evt_alloc_old (wrk);
elt->evt.session_index = tc->s_index;
elt->evt.event_type = SESSION_IO_EVT_TX;
+ tc->flags &= ~TRANSPORT_CONNECTION_F_DESCHED;
}
}
}
+void
+sesssion_reschedule_tx (transport_connection_t * tc)
+{
+ session_worker_t *wrk = session_main_get_worker (tc->thread_index);
+ session_evt_elt_t *elt;
+
+ ASSERT (tc->thread_index == vlib_get_thread_index ());
+
+ elt = session_evt_alloc_new (wrk);
+ elt->evt.session_index = tc->s_index;
+ elt->evt.event_type = SESSION_IO_EVT_TX;
+}
+
static void
session_program_transport_ctrl_evt (session_t * s, session_evt_type_t evt)
{
session_free_w_fifos (s);
}
-static session_t *
+session_t *
session_alloc_for_connection (transport_connection_t * tc)
{
session_t *s;
return 0;
}
+void
+session_fifo_tuning (session_t * s, svm_fifo_t * f,
+ session_ft_action_t act, u32 len)
+{
+ if (s->flags & SESSION_F_CUSTOM_FIFO_TUNING)
+ {
+ app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
+ app_worker_session_fifo_tuning (app_wrk, s, f, act, len);
+ if (CLIB_ASSERT_ENABLE)
+ {
+ segment_manager_t *sm;
+ sm = segment_manager_get (f->segment_manager);
+ ASSERT (f->size >= 4096);
+ ASSERT (f->size <= sm->max_fifo_size);
+ }
+ }
+}
+
/*
* Enqueue data for delivery to session peer. Does not notify peer of enqueue
* event but on request can queue notification events for later delivery by
s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[tc->proto], s->session_index);
}
+
+ session_fifo_tuning (s, s->rx_fifo, SESSION_FT_ACTION_ENQUEUED, 0);
}
return enqueued;
s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[proto], s->session_index);
}
+
+ session_fifo_tuning (s, s->rx_fifo, SESSION_FT_ACTION_ENQUEUED, 0);
}
return enqueued;
}
u32 rv;
rv = svm_fifo_dequeue_drop (s->tx_fifo, max_bytes);
+ session_fifo_tuning (s, s->tx_fifo, SESSION_FT_ACTION_DEQUEUED, rv);
if (svm_fifo_needs_deq_ntf (s->tx_fifo, max_bytes))
session_dequeue_notify (s);
continue;
}
+ session_fifo_tuning (s, s->rx_fifo, SESSION_FT_ACTION_ENQUEUED,
+ 0 /* TODO/not needed */ );
+
if (PREDICT_FALSE (session_enqueue_notify_inline (s)))
errors++;
}
}
static inline int
-session_stream_connect_notify_inline (transport_connection_t * tc, u8 is_fail,
+session_stream_connect_notify_inline (transport_connection_t * tc,
+ session_error_t err,
session_state_t opened_state)
{
u32 opaque = 0, new_ti, new_si;
opaque = tc->s_index;
- if (is_fail)
- return app_worker_connect_notify (app_wrk, s, opaque);
+ if (err)
+ return app_worker_connect_notify (app_wrk, s, err, opaque);
s = session_alloc_for_connection (tc);
s->session_state = SESSION_STATE_CONNECTING;
new_si = s->session_index;
new_ti = s->thread_index;
- if (app_worker_init_connected (app_wrk, s))
+ if ((err = app_worker_init_connected (app_wrk, s)))
{
session_free (s);
- app_worker_connect_notify (app_wrk, 0, opaque);
+ app_worker_connect_notify (app_wrk, 0, err, opaque);
return -1;
}
s->session_state = opened_state;
session_lookup_add_connection (tc, session_handle (s));
- if (app_worker_connect_notify (app_wrk, s, opaque))
+ if (app_worker_connect_notify (app_wrk, s, SESSION_E_NONE, opaque))
{
s = session_get (new_si, new_ti);
session_free_w_fifos (s);
}
int
-session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
+session_stream_connect_notify (transport_connection_t * tc,
+ session_error_t err)
{
- return session_stream_connect_notify_inline (tc, is_fail,
- SESSION_STATE_READY);
+ return session_stream_connect_notify_inline (tc, err, SESSION_STATE_READY);
}
int
-session_ho_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
+session_ho_stream_connect_notify (transport_connection_t * tc,
+ session_error_t err)
{
- return session_stream_connect_notify_inline (tc, is_fail,
- SESSION_STATE_OPENED);
+ return session_stream_connect_notify_inline (tc, err, SESSION_STATE_OPENED);
}
typedef struct _session_switch_pool_args
return 0;
}
+int
+session_dgram_accept (transport_connection_t * tc, u32 listener_index,
+ u32 thread_index)
+{
+ app_worker_t *app_wrk;
+ session_t *s;
+ int rv;
+
+ s = session_alloc_for_connection (tc);
+ s->listener_handle = ((u64) thread_index << 32) | (u64) listener_index;
+
+ if ((rv = app_worker_init_accepted (s)))
+ {
+ session_free (s);
+ return rv;
+ }
+
+ app_wrk = app_worker_get (s->app_wrk_index);
+ if ((rv = app_worker_accept_notify (app_wrk, s)))
+ {
+ session_free_w_fifos (s);
+ return rv;
+ }
+
+ s->session_state = SESSION_STATE_READY;
+ session_lookup_add_connection (tc, session_handle (s));
+
+ return 0;
+}
+
int
session_open_cl (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
{
if (rv < 0)
{
SESSION_DBG ("Transport failed to open connection.");
- return VNET_API_ERROR_SESSION_CONNECT;
+ return rv;
}
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
sh = session_handle (s);
session_lookup_add_connection (tc, sh);
- return app_worker_connect_notify (app_wrk, s, opaque);
+ return app_worker_connect_notify (app_wrk, s, SESSION_E_NONE, opaque);
}
int
if (rv < 0)
{
SESSION_DBG ("Transport failed to open connection.");
- return VNET_API_ERROR_SESSION_CONNECT;
+ return rv;
}
tc = transport_get_half_open (rmt->transport_proto, (u32) rv);
session_listen (session_t * ls, session_endpoint_cfg_t * sep)
{
transport_endpoint_t *tep;
- u32 tc_index, s_index;
+ int tc_index;
+ u32 s_index;
/* Transport bind/listen */
tep = session_endpoint_to_transport (sep);
tc_index = transport_start_listen (session_get_transport_proto (ls),
s_index, tep);
- if (tc_index == (u32) ~ 0)
- return -1;
+ if (tc_index < 0)
+ return tc_index;
/* Attach transport to session. Lookup tables are populated by the app
* worker because local tables (for ct sessions) are not backed by a fib */
transport_connection_t *tc;
if (s->session_state != SESSION_STATE_LISTENING)
- return -1;
+ return SESSION_E_NOLISTEN;
tc = transport_get_listener (tp, s->connection_index);
+
+ /* If no transport, assume everything was cleaned up already */
if (!tc)
- return VNET_API_ERROR_ADDRESS_NOT_IN_USE;
+ return SESSION_E_NONE;
if (!(tc->flags & TRANSPORT_CONNECTION_F_NO_LOOKUP))
session_lookup_del_connection (tc);
+
transport_stop_listen (tp, s->connection_index);
return 0;
}
};
/* *INDENT-ON* */
-/**
- * Initialize session layer for given transport proto and ip version
- *
- * Allocates per session type (transport proto + ip version) data structures
- * and adds arc from session queue node to session type output node.
- */
void
session_register_transport (transport_proto_t transport_proto,
const transport_proto_vft_t * vft, u8 is_ip4,
session_tx_fns[vft->transport_options.tx_type];
}
+transport_proto_t
+session_add_transport_proto (void)
+{
+ session_main_t *smm = &session_main;
+ session_worker_t *wrk;
+ u32 thread;
+
+ smm->last_transport_proto_type += 1;
+
+ for (thread = 0; thread < vec_len (smm->wrk); thread++)
+ {
+ wrk = session_main_get_worker (thread);
+ vec_validate (wrk->session_to_enqueue, smm->last_transport_proto_type);
+ }
+
+ return smm->last_transport_proto_type;
+}
+
transport_connection_t *
session_get_transport (session_t * s)
{
}
void
-session_flush_frames_main_thread (vlib_main_t * vm)
+session_queue_run_on_main_thread (vlib_main_t * vm)
{
ASSERT (vlib_get_thread_index () == 0);
vlib_process_signal_event_mt (vm, session_queue_process_node.index,
- SESSION_Q_PROCESS_FLUSH_FRAMES, 0);
+ SESSION_Q_PROCESS_RUN_ON_MAIN, 0);
}
static clib_error_t *
wrk->vm = vlib_mains[i];
wrk->last_vlib_time = vlib_time_now (vlib_mains[i]);
wrk->last_vlib_us_time = wrk->last_vlib_time * CLIB_US_TIME_FREQ;
+ vec_validate (wrk->session_to_enqueue, smm->last_transport_proto_type);
if (num_threads > 1)
clib_rwlock_init (&smm->wrk[i].peekers_rw_locks);
}
clib_error_t *
-session_manager_main_init (vlib_main_t * vm)
+session_main_init (vlib_main_t * vm)
{
session_main_t *smm = &session_main;
+
+ smm->is_enabled = 0;
+ smm->session_enable_asap = 0;
smm->session_baseva = HIGH_SEGMENT_BASEVA;
+
#if (HIGH_SEGMENT_BASEVA > (4ULL << 30))
smm->session_va_space_size = 128ULL << 30;
smm->evt_qs_segment_size = 64 << 20;
smm->session_va_space_size = 128 << 20;
smm->evt_qs_segment_size = 1 << 20;
#endif
- smm->is_enabled = 0;
- smm->session_enable_asap = 0;
+
+ smm->last_transport_proto_type = TRANSPORT_PROTO_QUIC;
+
return 0;
}
static clib_error_t *
-session_main_init (vlib_main_t * vm)
+session_main_loop_init (vlib_main_t * vm)
{
session_main_t *smm = &session_main;
if (smm->session_enable_asap)
return 0;
}
-VLIB_INIT_FUNCTION (session_manager_main_init);
-VLIB_MAIN_LOOP_ENTER_FUNCTION (session_main_init);
+VLIB_INIT_FUNCTION (session_main_init);
+VLIB_MAIN_LOOP_ENTER_FUNCTION (session_main_loop_init);
static clib_error_t *
session_config_fn (vlib_main_t * vm, unformat_input_t * input)