summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c18
-rw-r--r--src/vnet/session/application_interface.h2
-rw-r--r--src/vnet/session/segment_manager.c79
-rw-r--r--src/vnet/session/segment_manager.h3
-rw-r--r--src/vnet/session/session.c38
-rw-r--r--src/vnet/session/session.h8
-rwxr-xr-xsrc/vnet/session/session_api.c2
7 files changed, 83 insertions, 67 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index ccf9837f4cc..c679b1f53f8 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -160,6 +160,7 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
props->rx_fifo_size = options[SESSION_OPTIONS_RX_FIFO_SIZE];
props->tx_fifo_size = options[SESSION_OPTIONS_TX_FIFO_SIZE];
props->add_segment = props->add_segment_size != 0;
+ props->preallocated_fifo_pairs = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
props->use_private_segment = options[APP_OPTIONS_FLAGS]
& APP_OPTIONS_FLAGS_BUILTIN_APP;
@@ -395,7 +396,7 @@ application_format_connects (application_t * app, int verbose)
vlib_main_t *vm = vlib_get_main ();
segment_manager_t *sm;
u8 *app_name, *s = 0;
- int i, j;
+ int j;
/* Header */
if (app == 0)
@@ -419,22 +420,16 @@ application_format_connects (application_t * app, int verbose)
for (j = 0; j < vec_len (sm->segment_indices); j++)
{
svm_fifo_segment_private_t *fifo_segment;
- svm_fifo_t **fifos;
+ svm_fifo_t *fifo;
u8 *str;
fifo_segment = svm_fifo_get_segment (sm->segment_indices[j]);
- fifos = svm_fifo_segment_get_fifos (fifo_segment);
- for (i = 0; i < vec_len (fifos); i++)
+ fifo = svm_fifo_segment_get_fifo_list (fifo_segment);
+ while (fifo)
{
- svm_fifo_t *fifo;
u32 session_index, thread_index;
stream_session_t *session;
- /* There are 2 fifos/session. Avoid printing twice. */
- if (i % 2)
- continue;
-
- fifo = fifos[i];
session_index = fifo->master_session_index;
thread_index = fifo->master_thread_index;
@@ -448,9 +443,10 @@ application_format_connects (application_t * app, int verbose)
s = format (s, "%-40s%-20s", str, app_name);
vlib_cli_output (vm, "%v", s);
-
vec_reset_length (s);
vec_free (str);
+
+ fifo = fifo->next;
}
vec_free (s);
}
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 7d924c146a4..4d6f9def026 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -119,10 +119,12 @@ typedef enum
{
APP_EVT_QUEUE_SIZE,
APP_OPTIONS_FLAGS,
+ APP_OPTIONS_PREALLOC_FIFO_PAIRS,
SESSION_OPTIONS_SEGMENT_SIZE,
SESSION_OPTIONS_ADD_SEGMENT_SIZE,
SESSION_OPTIONS_RX_FIFO_SIZE,
SESSION_OPTIONS_TX_FIFO_SIZE,
+ SESSION_OPTIONS_PREALLOCATED_FIFO_PAIRS,
SESSION_OPTIONS_ACCEPT_COOKIE,
SESSION_OPTIONS_N_OPTIONS
} app_attach_options_index_t;
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index b13df21ca9e..caf8eaa308a 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -58,6 +58,9 @@ session_manager_add_segment_i (segment_manager_t * sm, u32 segment_size,
ca->segment_name = (char *) segment_name;
ca->segment_size = segment_size;
+ ca->rx_fifo_size = sm->properties->rx_fifo_size;
+ ca->tx_fifo_size = sm->properties->tx_fifo_size;
+ ca->preallocated_fifo_pairs = sm->properties->preallocated_fifo_pairs;
rv = svm_fifo_segment_create (ca);
if (rv)
@@ -104,7 +107,8 @@ session_manager_add_first_segment (segment_manager_t * sm, u32 segment_size)
}
static void
-segment_manager_alloc_process_private_segment ()
+ segment_manager_alloc_process_private_segment
+ (segment_manager_properties_t * props)
{
svm_fifo_segment_create_args_t _a, *a = &_a;
@@ -115,6 +119,9 @@ segment_manager_alloc_process_private_segment ()
a->segment_name = "process-private-segment";
a->segment_size = ~0;
a->new_segment_index = ~0;
+ a->rx_fifo_size = props->rx_fifo_size;
+ a->tx_fifo_size = props->tx_fifo_size;
+ a->preallocated_fifo_pairs = props->preallocated_fifo_pairs;
if (svm_fifo_segment_create_process_private (a))
clib_warning ("Failed to create process private segment");
@@ -151,7 +158,7 @@ segment_manager_init (segment_manager_t * sm,
else
{
if (private_segment_index == ~0)
- segment_manager_alloc_process_private_segment ();
+ segment_manager_alloc_process_private_segment (properties);
ASSERT (private_segment_index != ~0);
vec_add1 (sm->segment_indices, private_segment_index);
}
@@ -170,74 +177,46 @@ segment_manager_init (segment_manager_t * sm,
void
segment_manager_del (segment_manager_t * sm)
{
- u32 *deleted_sessions = 0;
- u32 *deleted_thread_indices = 0;
- int i, j;
+ int j;
/* Across all fifo segments used by the server */
for (j = 0; j < vec_len (sm->segment_indices); j++)
{
svm_fifo_segment_private_t *fifo_segment;
- svm_fifo_t **fifos;
+ svm_fifo_t *fifo;
+
/* Vector of fifos allocated in the segment */
fifo_segment = svm_fifo_get_segment (sm->segment_indices[j]);
- fifos = svm_fifo_segment_get_fifos (fifo_segment);
+ fifo = svm_fifo_segment_get_fifo_list (fifo_segment);
/*
* Remove any residual sessions from the session lookup table
* Don't bother deleting the individual fifos, we're going to
* throw away the fifo segment in a minute.
*/
- for (i = 0; i < vec_len (fifos); i++)
+ while (fifo)
{
- svm_fifo_t *fifo;
u32 session_index, thread_index;
stream_session_t *session;
- fifo = fifos[i];
session_index = fifo->master_session_index;
thread_index = fifo->master_thread_index;
session = stream_session_get (session_index, thread_index);
- /* Add to the deleted_sessions vector (once!) */
- if (!session->is_deleted)
- {
- session->is_deleted = 1;
- vec_add1 (deleted_sessions, session_index);
- vec_add1 (deleted_thread_indices, thread_index);
- }
- }
-
- for (i = 0; i < vec_len (deleted_sessions); i++)
- {
- stream_session_t *session;
- session = stream_session_get (deleted_sessions[i],
- deleted_thread_indices[i]);
-
/* Instead of directly removing the session call disconnect */
session_send_session_evt_to_thread (stream_session_handle (session),
FIFO_EVENT_DISCONNECT,
- deleted_thread_indices[i]);
-
- /*
- stream_session_table_del (smm, session);
- pool_put(smm->sessions[deleted_thread_indices[i]], session);
- */
+ thread_index);
+ fifo = fifo->next;
}
- vec_reset_length (deleted_sessions);
- vec_reset_length (deleted_thread_indices);
-
- /* Instead of removing the segment, test when removing the session if
- * the segment can be removed
+ /* Instead of removing the segment, test when cleaning up disconnected
+ * sessions if the segment can be removed.
*/
- /* svm_fifo_segment_delete (fifo_segment); */
}
clib_spinlock_free (&sm->lockp);
- vec_free (deleted_sessions);
- vec_free (deleted_thread_indices);
pool_put (segment_managers, sm);
}
@@ -281,20 +260,27 @@ again:
*fifo_segment_index = sm->segment_indices[i];
fifo_segment = svm_fifo_get_segment (*fifo_segment_index);
+ /* FC: cleanup, make sure sm->properties->xxx_fifo_size always set */
fifo_size = sm->properties->rx_fifo_size;
fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
- *server_rx_fifo = svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size);
+ *server_rx_fifo =
+ svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size,
+ FIFO_SEGMENT_RX_FREELIST);
+ /* FC: cleanup, make sure sm->properties->xxx_fifo_size always set */
fifo_size = sm->properties->tx_fifo_size;
fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
- *server_tx_fifo = svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size);
+ *server_tx_fifo =
+ svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size,
+ FIFO_SEGMENT_TX_FREELIST);
if (*server_rx_fifo == 0)
{
/* This would be very odd, but handle it... */
if (*server_tx_fifo != 0)
{
- svm_fifo_segment_free_fifo (fifo_segment, *server_tx_fifo);
+ svm_fifo_segment_free_fifo (fifo_segment, *server_tx_fifo,
+ FIFO_SEGMENT_TX_FREELIST);
*server_tx_fifo = 0;
}
continue;
@@ -303,7 +289,8 @@ again:
{
if (*server_rx_fifo != 0)
{
- svm_fifo_segment_free_fifo (fifo_segment, *server_rx_fifo);
+ svm_fifo_segment_free_fifo (fifo_segment, *server_rx_fifo,
+ FIFO_SEGMENT_RX_FREELIST);
*server_rx_fifo = 0;
}
continue;
@@ -365,8 +352,10 @@ segment_manager_dealloc_fifos (u32 svm_segment_index, svm_fifo_t * rx_fifo,
return;
fifo_segment = svm_fifo_get_segment (svm_segment_index);
- svm_fifo_segment_free_fifo (fifo_segment, rx_fifo);
- svm_fifo_segment_free_fifo (fifo_segment, tx_fifo);
+ svm_fifo_segment_free_fifo (fifo_segment, rx_fifo,
+ FIFO_SEGMENT_RX_FREELIST);
+ svm_fifo_segment_free_fifo (fifo_segment, tx_fifo,
+ FIFO_SEGMENT_TX_FREELIST);
/* Remove segment only if it holds no fifos and not the first */
if (sm->segment_indices[0] != svm_segment_index
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index 2710bb544d7..d4b73208257 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -28,6 +28,9 @@ typedef struct _segment_manager_properties
u32 rx_fifo_size;
u32 tx_fifo_size;
+ /** Preallocated pool sizes */
+ u32 preallocated_fifo_pairs;
+
/** Configured additional segment size */
u32 add_segment_size;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index c5aaf2e2b15..02b0cced3f7 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1048,19 +1048,21 @@ session_vpp_event_queue_allocate (session_manager_main_t * smm,
{
api_main_t *am = &api_main;
void *oldheap;
+ u32 event_queue_length = 2048;
if (smm->vpp_event_queues[thread_index] == 0)
{
/* Allocate event fifo in the /vpe-api shared-memory segment */
oldheap = svm_push_data_heap (am->vlib_rp);
+ if (smm->configured_event_queue_length)
+ event_queue_length = smm->configured_event_queue_length;
+
smm->vpp_event_queues[thread_index] =
- unix_shared_memory_queue_init (2048 /* nels $$$$ config */ ,
- sizeof (session_fifo_event_t),
- 0 /* consumer pid */ ,
- 0
- /* (do not) send signal when queue non-empty */
- );
+ unix_shared_memory_queue_init
+ (event_queue_length,
+ sizeof (session_fifo_event_t), 0 /* consumer pid */ ,
+ 0 /* (do not) send signal when queue non-empty */ );
svm_pop_heap (oldheap);
}
@@ -1187,6 +1189,30 @@ session_manager_main_init (vlib_main_t * vm)
}
VLIB_INIT_FUNCTION (session_manager_main_init)
+ static clib_error_t *session_config_fn (vlib_main_t * vm,
+ unformat_input_t * input)
+{
+ session_manager_main_t *smm = &session_manager_main;
+ u32 nitems;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "event-queue-length %d", &nitems))
+ {
+ if (nitems >= 2048)
+ smm->configured_event_queue_length = nitems;
+ else
+ clib_warning ("event queue length %d too small, ignored", nitems);
+ }
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ return 0;
+}
+
+VLIB_CONFIG_FUNCTION (session_config_fn, "session");
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index d60cca29fc6..a87286498de 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -125,14 +125,11 @@ typedef struct _stream_session_t
u8 thread_index;
- /** used during unbind processing */
- u8 is_deleted;
-
/** To avoid n**2 "one event per frame" check */
u8 enqueue_epoch;
/** Pad to a multiple of 8 octets */
- u8 align_pad[2];
+ u8 align_pad[4];
/** svm segment index where fifos were allocated */
u32 svm_segment_index;
@@ -205,6 +202,9 @@ struct _session_manager_main
/** vpp fifo event queue */
unix_shared_memory_queue_t **vpp_event_queues;
+ /** vpp fifo event queue configured length */
+ u32 configured_event_queue_length;
+
/** Unique segment name counter */
u32 unique_segment_name_counter;
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 8c073a08070..98d6946af85 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -419,7 +419,7 @@ done:
REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
}
-static void
+void
vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
{
vl_api_connect_uri_reply_t *rmp;