aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-18 09:06:35 -0700
committerDave Barach <openvpp@barachs.net>2019-03-18 22:07:37 +0000
commitd5c604d6872bdb5576a900d51b96f2e6736b63a5 (patch)
treec4237b278cebc4603e8cfc7efeeeeebd28709ba2 /src/vnet
parent1ee346a0a61b454a1ce879f97cb9c06267d1e107 (diff)
session: add session flags
- use flag instead of enqueue_epoch for enqueueing rx events. - use flag for proxy sessions Change-Id: Iec3eee55a68d02536ece6329348a3369c7c7412e Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application.c2
-rw-r--r--src/vnet/session/application_worker.c5
-rw-r--r--src/vnet/session/session.c19
-rw-r--r--src/vnet/session/session.h5
-rw-r--r--src/vnet/session/session_types.h10
5 files changed, 17 insertions, 24 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index f6fcc4f85b7..91e800d1dc8 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -1207,7 +1207,7 @@ application_start_stop_proxy_fib_proto (application_t * app, u8 fib_proto,
app_worker_start_listen (app_wrk, al);
s = listen_session_get (al->session_index);
- s->enqueue_epoch = SESSION_PROXY_LISTENER_INDEX;
+ s->flags |= SESSION_F_PROXY;
}
}
else
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 6b294ecf3fb..08b42f38f16 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -453,7 +453,7 @@ app_worker_first_listener (app_worker_t * app_wrk, u8 fib_proto,
hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
listener = listen_session_get_from_handle (handle);
if (listener->session_type == sst
- && listener->enqueue_epoch != SESSION_PROXY_LISTENER_INDEX)
+ && !(listener->flags & SESSION_F_PROXY))
return listener;
}));
/* *INDENT-ON* */
@@ -476,8 +476,7 @@ app_worker_proxy_listener (app_worker_t * app_wrk, u8 fib_proto,
/* *INDENT-OFF* */
hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
listener = listen_session_get_from_handle (handle);
- if (listener->session_type == sst
- && listener->enqueue_epoch == SESSION_PROXY_LISTENER_INDEX)
+ if (listener->session_type == sst && (listener->flags & SESSION_F_PROXY))
return listener;
}));
/* *INDENT-ON* */
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index c9eea1d2aad..cd8da50a5c9 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -207,7 +207,6 @@ session_alloc_for_connection (transport_connection_t * tc)
s = session_alloc (thread_index);
s->session_type = session_type_from_proto_and_ip (tc->proto, tc->is_ip4);
- s->enqueue_epoch = (u64) ~ 0;
s->session_state = SESSION_STATE_CLOSED;
/* Attach transport to session and vice versa */
@@ -382,9 +381,9 @@ session_enqueue_stream_connection (transport_connection_t * tc,
session_worker_t *wrk;
wrk = session_main_get_worker (s->thread_index);
- if (s->enqueue_epoch != wrk->current_enqueue_epoch[tc->proto])
+ if (!(s->flags & SESSION_F_RX_EVT))
{
- s->enqueue_epoch = wrk->current_enqueue_epoch[tc->proto];
+ s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[tc->proto], s->session_index);
}
}
@@ -420,9 +419,9 @@ session_enqueue_dgram_connection (session_t * s,
session_worker_t *wrk;
wrk = session_main_get_worker (s->thread_index);
- if (s->enqueue_epoch != wrk->current_enqueue_epoch[proto])
+ if (!(s->flags & SESSION_F_RX_EVT))
{
- s->enqueue_epoch = wrk->current_enqueue_epoch[proto];
+ s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[proto], s->session_index);
}
}
@@ -495,6 +494,7 @@ session_enqueue_notify_inline (session_t * s)
}));
/* *INDENT-ON* */
+ s->flags &= ~SESSION_F_RX_EVT;
if (PREDICT_FALSE (app_worker_lock_and_send_event (app_wrk, s,
SESSION_IO_EVT_RX)))
return -1;
@@ -570,7 +570,6 @@ session_main_flush_enqueue_events (u8 transport_proto, u32 thread_index)
vec_reset_length (indices);
wrk->session_to_enqueue[transport_proto] = indices;
- wrk->current_enqueue_epoch[transport_proto]++;
return errors;
}
@@ -1294,7 +1293,7 @@ session_manager_main_enable (vlib_main_t * vm)
vlib_thread_main_t *vtm = vlib_get_thread_main ();
u32 num_threads, preallocated_sessions_per_worker;
session_worker_t *wrk;
- int i, j;
+ int i;
num_threads = 1 /* main thread */ + vtm->n_threads;
@@ -1304,12 +1303,6 @@ session_manager_main_enable (vlib_main_t * vm)
/* Allocate cache line aligned worker contexts */
vec_validate_aligned (smm->wrk, num_threads - 1, CLIB_CACHE_LINE_BYTES);
- for (i = 0; i < TRANSPORT_N_PROTO; i++)
- {
- for (j = 0; j < num_threads; j++)
- smm->wrk[j].current_enqueue_epoch[i] = 1;
- }
-
for (i = 0; i < num_threads; i++)
{
wrk = &smm->wrk[i];
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index cea1b375108..26506cae3bc 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -21,8 +21,6 @@
#include <svm/message_queue.h>
#include <svm/ssvm.h>
-#define SESSION_PROXY_LISTENER_INDEX ((u8)~0 - 1)
-
#define foreach_session_input_error \
_(NO_SESSION, "No session drops") \
_(NO_LISTENER, "No listener for dst port drops") \
@@ -80,9 +78,6 @@ typedef struct session_worker_
/** vlib_time_now last time around the track */
f64 last_vlib_time;
- /** Per-proto enqueue epoch counters */
- u64 current_enqueue_epoch[TRANSPORT_N_PROTO];
-
/** Per-proto vector of sessions to enqueue */
u32 *session_to_enqueue[TRANSPORT_N_PROTO];
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index a0d33622d6f..0845f023ad9 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -128,6 +128,12 @@ typedef enum
SESSION_STATE_N_STATES,
} session_state_t;
+typedef enum session_flags_
+{
+ SESSION_F_RX_EVT,
+ SESSION_F_PROXY
+} session_flags_t;
+
typedef struct session_
{
/** Pointers to rx/tx buffers. Once allocated, these do not move */
@@ -149,8 +155,8 @@ typedef struct session_
/** Index of the thread that allocated the session */
u8 thread_index;
- /** Tracks last enqueue epoch to avoid generating multiple enqueue events */
- u64 enqueue_epoch;
+ /** Session flags. See @ref session_flags_t */
+ u32 flags;
/** Index of the transport connection associated to the session */
u32 connection_index;