aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/session.c1
-rw-r--r--src/vnet/session/session.h2
-rw-r--r--src/vnet/session/session_node.c11
-rw-r--r--src/vnet/session/transport.c23
-rw-r--r--src/vnet/session/transport_interface.h3
5 files changed, 29 insertions, 11 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 3dd80ad337a..f6894868a3a 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1366,6 +1366,7 @@ session_manager_main_enable (vlib_main_t * vm)
_vec_len (wrk->postponed_event_vector) = 0;
wrk->last_vlib_time = vlib_time_now (vlib_mains[i]);
+ wrk->dispatch_period = 500e-6;
if (num_threads > 1)
clib_rwlock_init (&smm->wrk[i].peekers_rw_locks);
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 131652a8c6e..3bdf6c9d93e 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -229,6 +229,8 @@ typedef struct session_manager_worker_
/** Peekers rw lock */
clib_rwlock_t peekers_rw_locks;
+ u32 last_tx_packets;
+
} session_manager_worker_t;
struct _session_manager_main
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 34131723665..5ed681d03c7 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -751,10 +751,12 @@ static void
session_update_dispatch_period (session_manager_worker_t * wrk, f64 now,
u32 thread_index)
{
- f64 sample, prev_period = wrk->dispatch_period, a = 0.8;
-
- sample = now - wrk->last_vlib_time;
- wrk->dispatch_period = a * sample + (1 - a) * prev_period;
+ if (wrk->last_tx_packets > 8)
+ {
+ f64 sample = now - wrk->last_vlib_time;
+ sample = (sample * wrk->last_tx_packets) / VLIB_FRAME_SIZE;
+ wrk->dispatch_period = (wrk->dispatch_period + sample) * 0.5;
+ }
wrk->last_vlib_time = now;
}
@@ -917,6 +919,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
_vec_len (fifo_events) = 0;
wrk->free_event_vector = fifo_events;
+ wrk->last_tx_packets = n_tx_packets;
vlib_node_increment_counter (vm, session_queue_node.index,
SESSION_QUEUE_ERROR_TX, n_tx_packets);
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 0dd9ccd3213..42149eb36a6 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -529,23 +529,32 @@ spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec)
}
void
-transport_connection_tx_pacer_init (transport_connection_t * tc,
- u32 rate_bytes_per_sec,
- u32 initial_bucket)
+transport_connection_tx_pacer_reset (transport_connection_t * tc,
+ u32 rate_bytes_per_sec,
+ u32 start_bucket, u64 time_now)
{
- vlib_main_t *vm = vlib_get_main ();
- u64 time_now = vm->clib_time.last_cpu_time;
spacer_t *pacer = &tc->pacer;
f64 dispatch_period;
u32 burst_size;
- tc->flags |= TRANSPORT_CONNECTION_F_IS_TX_PACED;
dispatch_period = transport_dispatch_period (tc->thread_index);
burst_size = rate_bytes_per_sec * dispatch_period;
spacer_update_max_burst_size (&tc->pacer, burst_size);
spacer_set_pace_rate (&tc->pacer, rate_bytes_per_sec);
pacer->last_update = time_now >> SPACER_CPU_TICKS_PER_PERIOD_SHIFT;
- pacer->bucket = initial_bucket;
+ pacer->bucket = start_bucket;
+}
+
+void
+transport_connection_tx_pacer_init (transport_connection_t * tc,
+ u32 rate_bytes_per_sec,
+ u32 initial_bucket)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ tc->flags |= TRANSPORT_CONNECTION_F_IS_TX_PACED;
+ transport_connection_tx_pacer_reset (tc, rate_bytes_per_sec,
+ initial_bucket,
+ vm->clib_time.last_cpu_time);
}
void
diff --git a/src/vnet/session/transport_interface.h b/src/vnet/session/transport_interface.h
index b7aa4b7fa3c..3bfed415874 100644
--- a/src/vnet/session/transport_interface.h
+++ b/src/vnet/session/transport_interface.h
@@ -102,6 +102,9 @@ transport_tx_fn_type_t transport_protocol_tx_fn_type (transport_proto_t tp);
void transport_update_time (f64 time_now, u8 thread_index);
void transport_enable_disable (vlib_main_t * vm, u8 is_en);
+void transport_connection_tx_pacer_reset (transport_connection_t * tc,
+ u32 rate_bytes_per_sec,
+ u32 initial_bucket, u64 time_now);
/**
* Initialize tx pacer for connection
*