aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-01-05 03:20:25 -0800
committerDave Barach <openvpp@barachs.net>2018-01-09 18:33:08 +0000
commite86a8edd3c14fb41ace2a12efd17bc7772bf623f (patch)
tree480219864cadd743fdb95c21379aeaf88a985e23 /src/vnet/session
parent4363ad6c96b5641fca1b16c5a6ec22e2364adcfd (diff)
api: refactor vlibmemory
- separate client/server code for both memory and socket apis - separate memory api code from generic vlib api code - move unix_shared_memory_fifo to svm and rename to svm_fifo_t - overall declutter Change-Id: I90cdd98ff74d0787d58825b914b0f1eafcfa4dc2 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c2
-rw-r--r--src/vnet/session/application.h2
-rw-r--r--src/vnet/session/segment_manager.c16
-rw-r--r--src/vnet/session/segment_manager.h10
-rw-r--r--src/vnet/session/session.c12
-rw-r--r--src/vnet/session/session.h6
-rwxr-xr-xsrc/vnet/session/session_api.c27
-rw-r--r--src/vnet/session/session_node.c10
8 files changed, 40 insertions, 45 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index f6151b6b487..8090e75a6dc 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -76,7 +76,7 @@ application_local_session_table (application_t * app)
int
application_api_queue_is_full (application_t * app)
{
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
/* builtin servers are always OK */
if (app->api_client_index == ~0)
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index 2892bc59f12..fd6454f21af 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -72,7 +72,7 @@ typedef struct _application
u32 ns_index;
/** Application listens for events on this svm queue */
- unix_shared_memory_queue_t *event_queue;
+ svm_queue_t *event_queue;
/*
* Callbacks: shoulder-taps for the server/client
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 9e6a1b55cbb..dc3e4c9e648 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -530,12 +530,12 @@ segment_manager_dealloc_fifos (u32 svm_segment_index, svm_fifo_t * rx_fifo,
/**
* Allocates shm queue in the first segment
*/
-unix_shared_memory_queue_t *
+svm_queue_t *
segment_manager_alloc_queue (segment_manager_t * sm, u32 queue_size)
{
ssvm_shared_header_t *sh;
svm_fifo_segment_private_t *segment;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
void *oldheap;
ASSERT (sm->segment_indices != 0);
@@ -544,10 +544,9 @@ segment_manager_alloc_queue (segment_manager_t * sm, u32 queue_size)
sh = segment->ssvm.sh;
oldheap = ssvm_push_heap (sh);
- q = unix_shared_memory_queue_init (queue_size,
- sizeof (session_fifo_event_t),
- 0 /* consumer pid */ ,
- 0 /* signal when queue non-empty */ );
+ q = svm_queue_init (queue_size,
+ sizeof (session_fifo_event_t), 0 /* consumer pid */ ,
+ 0 /* signal when queue non-empty */ );
ssvm_pop_heap (oldheap);
return q;
}
@@ -556,8 +555,7 @@ segment_manager_alloc_queue (segment_manager_t * sm, u32 queue_size)
* Frees shm queue allocated in the first segment
*/
void
-segment_manager_dealloc_queue (segment_manager_t * sm,
- unix_shared_memory_queue_t * q)
+segment_manager_dealloc_queue (segment_manager_t * sm, svm_queue_t * q)
{
ssvm_shared_header_t *sh;
svm_fifo_segment_private_t *segment;
@@ -569,7 +567,7 @@ segment_manager_dealloc_queue (segment_manager_t * sm,
sh = segment->ssvm.sh;
oldheap = ssvm_push_heap (sh);
- unix_shared_memory_queue_free (q);
+ svm_queue_free (q);
ssvm_pop_heap (oldheap);
}
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index 9d2d141e7b4..41e2308928f 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -17,8 +17,7 @@
#include <vnet/vnet.h>
#include <svm/svm_fifo_segment.h>
-
-#include <vlibmemory/unix_shared_memory_queue.h>
+#include <svm/queue.h>
#include <vlibmemory/api.h>
#include <vppinfra/lock.h>
@@ -113,10 +112,9 @@ segment_manager_alloc_session_fifos (segment_manager_t * sm,
void
segment_manager_dealloc_fifos (u32 svm_segment_index, svm_fifo_t * rx_fifo,
svm_fifo_t * tx_fifo);
-unix_shared_memory_queue_t *segment_manager_alloc_queue (segment_manager_t *
- sm, u32 queue_size);
-void segment_manager_dealloc_queue (segment_manager_t * sm,
- unix_shared_memory_queue_t * q);
+svm_queue_t *segment_manager_alloc_queue (segment_manager_t *
+ sm, u32 queue_size);
+void segment_manager_dealloc_queue (segment_manager_t * sm, svm_queue_t * q);
void segment_manager_app_detach (segment_manager_t * sm);
segment_manager_properties_t *segment_manager_properties_alloc (void);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 408a1f5caf0..adcbb2924d8 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -33,7 +33,7 @@ session_send_evt_to_thread (u64 session_handle, fifo_event_type_t evt_type,
{
u32 tries = 0;
session_fifo_event_t evt = { {0}, };
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
evt.event_type = evt_type;
if (evt_type == FIFO_EVENT_RPC)
@@ -45,7 +45,7 @@ session_send_evt_to_thread (u64 session_handle, fifo_event_type_t evt_type,
evt.session_handle = session_handle;
q = session_manager_get_vpp_event_queue (thread_index);
- while (unix_shared_memory_queue_add (q, (u8 *) & evt, 1))
+ while (svm_queue_add (q, (u8 *) & evt, 1))
{
if (tries++ == 3)
{
@@ -443,7 +443,7 @@ session_enqueue_notify (stream_session_t * s, u8 block)
{
application_t *app;
session_fifo_event_t evt;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
if (PREDICT_FALSE (s->session_state == SESSION_STATE_CLOSED))
{
@@ -479,8 +479,8 @@ session_enqueue_notify (stream_session_t * s, u8 block)
/* Based on request block (or not) for lack of space */
if (block || PREDICT_TRUE (q->cursize < q->maxsize))
- unix_shared_memory_queue_add (app->event_queue, (u8 *) & evt,
- 0 /* do wait for mutex */ );
+ svm_queue_add (app->event_queue, (u8 *) & evt,
+ 0 /* do wait for mutex */ );
else
{
clib_warning ("fifo full");
@@ -980,7 +980,7 @@ session_vpp_event_queue_allocate (session_manager_main_t * smm,
event_queue_length = smm->configured_event_queue_length;
smm->vpp_event_queues[thread_index] =
- unix_shared_memory_queue_init
+ svm_queue_init
(event_queue_length,
sizeof (session_fifo_event_t), 0 /* consumer pid */ ,
0 /* (do not) send signal when queue non-empty */ );
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index b76e56de50b..5e017c6c852 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -18,9 +18,9 @@
#include <vnet/session/stream_session.h>
#include <vnet/session/session_lookup.h>
#include <vnet/session/transport_interface.h>
-#include <vlibmemory/unix_shared_memory_queue.h>
#include <vnet/session/session_debug.h>
#include <vnet/session/segment_manager.h>
+#include <svm/queue.h>
#define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0)
#define INVALID_INDEX ((u32)~0)
@@ -147,7 +147,7 @@ struct _session_manager_main
session_fifo_event_t **pending_disconnects;
/** vpp fifo event queue */
- unix_shared_memory_queue_t **vpp_event_queues;
+ svm_queue_t **vpp_event_queues;
/** Unique segment name counter */
u32 unique_segment_name_counter;
@@ -455,7 +455,7 @@ void session_register_transport (transport_proto_t transport_proto,
clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en);
-always_inline unix_shared_memory_queue_t *
+always_inline svm_queue_t *
session_manager_get_vpp_event_queue (u32 thread_index)
{
return session_manager_main.vpp_event_queues[thread_index];
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 804fc23539a..75bdedfe9ce 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -62,7 +62,7 @@ send_add_segment_callback (u32 api_client_index, const u8 * segment_name,
u32 segment_size)
{
vl_api_map_another_segment_t *mp;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
q = vl_api_client_index_to_input_queue (api_client_index);
@@ -85,7 +85,7 @@ static int
send_session_accept_callback (stream_session_t * s)
{
vl_api_accept_session_t *mp;
- unix_shared_memory_queue_t *q, *vpp_queue;
+ svm_queue_t *q, *vpp_queue;
application_t *server = application_get (s->app_index);
transport_connection_t *tc;
transport_proto_vft_t *tp_vft;
@@ -132,7 +132,7 @@ static void
send_session_disconnect_callback (stream_session_t * s)
{
vl_api_disconnect_session_t *mp;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
application_t *app = application_get (s->app_index);
q = vl_api_client_index_to_input_queue (app->api_client_index);
@@ -151,7 +151,7 @@ static void
send_session_reset_callback (stream_session_t * s)
{
vl_api_reset_session_t *mp;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
application_t *app = application_get (s->app_index);
q = vl_api_client_index_to_input_queue (app->api_client_index);
@@ -171,9 +171,9 @@ send_session_connected_callback (u32 app_index, u32 api_context,
stream_session_t * s, u8 is_fail)
{
vl_api_connect_session_reply_t *mp;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
application_t *app;
- unix_shared_memory_queue_t *vpp_queue;
+ svm_queue_t *vpp_queue;
transport_connection_t *tc;
app = application_get (app_index);
@@ -221,7 +221,7 @@ static int
redirect_connect_callback (u32 server_api_client_index, void *mp_arg)
{
vl_api_connect_sock_t *mp = mp_arg;
- unix_shared_memory_queue_t *server_q, *client_q;
+ svm_queue_t *server_q, *client_q;
segment_manager_properties_t *props;
vlib_main_t *vm = vlib_get_main ();
f64 timeout = vlib_time_now (vm) + 0.5;
@@ -263,8 +263,7 @@ redirect_connect_callback (u32 server_api_client_index, void *mp_arg)
while (vlib_time_now (vm) < timeout)
{
- rv =
- unix_shared_memory_queue_add (server_q, (u8 *) & mp, 1 /*nowait */ );
+ rv = svm_queue_add (server_q, (u8 *) & mp, 1 /*nowait */ );
switch (rv)
{
/* correctly enqueued */
@@ -736,7 +735,7 @@ vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
app = application_lookup (mp->client_index);
if (app)
{
- unix_shared_memory_queue_t *client_q;
+ svm_queue_t *client_q;
ip46_address_t *ip46 = (ip46_address_t *) mp->ip;
client_q = vl_api_client_index_to_input_queue (mp->client_index);
@@ -871,7 +870,7 @@ vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp)
static void
send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
u8 transport_proto, u32 appns_index, u8 * tag,
- unix_shared_memory_queue_t * q, u32 context)
+ svm_queue_t * q, u32 context)
{
vl_api_session_rules_details_t *rmp = 0;
session_mask_or_match_4_t *match =
@@ -908,7 +907,7 @@ send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
static void
send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
u8 transport_proto, u32 appns_index, u8 * tag,
- unix_shared_memory_queue_t * q, u32 context)
+ svm_queue_t * q, u32 context)
{
vl_api_session_rules_details_t *rmp = 0;
session_mask_or_match_6_t *match =
@@ -945,7 +944,7 @@ send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
static void
send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto,
u8 tp, u8 is_local, u32 appns_index,
- unix_shared_memory_queue_t * q, u32 context)
+ svm_queue_t * q, u32 context)
{
mma_rule_16_t *rule16;
mma_rule_40_t *rule40;
@@ -984,7 +983,7 @@ send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto,
static void
vl_api_session_rules_dump_t_handler (vl_api_one_map_server_dump_t * mp)
{
- unix_shared_memory_queue_t *q = NULL;
+ svm_queue_t *q = NULL;
session_table_t *st;
u8 tp;
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index e9cfc7be8aa..a1608f4a412 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -20,7 +20,7 @@
#include <vnet/session/transport.h>
#include <vnet/session/application.h>
#include <vnet/session/session_debug.h>
-#include <vlibmemory/unix_shared_memory_queue.h>
+#include <svm/queue.h>
vlib_node_registration_t session_queue_node;
@@ -406,7 +406,7 @@ dump_thread_0_event_queue (void)
int i, index;
i8 *headp;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
q = smm->vpp_event_queues[my_thread_index];
index = q->head;
@@ -486,7 +486,7 @@ u8
session_node_lookup_fifo_event (svm_fifo_t * f, session_fifo_event_t * e)
{
session_manager_main_t *smm = vnet_get_session_manager_main ();
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
session_fifo_event_t *pending_event_vector, *evt;
int i, index, found = 0;
i8 *headp;
@@ -533,7 +533,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
session_fifo_event_t *my_pending_event_vector, *pending_disconnects, *e;
session_fifo_event_t *my_fifo_events;
u32 n_to_dequeue, n_events;
- unix_shared_memory_queue_t *q;
+ svm_queue_t *q;
application_t *app;
int n_tx_packets = 0;
u32 my_thread_index = vm->thread_index;
@@ -586,7 +586,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
for (i = 0; i < n_to_dequeue; i++)
{
vec_add2 (my_fifo_events, e, 1);
- unix_shared_memory_queue_sub_raw (q, (u8 *) e);
+ svm_queue_sub_raw (q, (u8 *) e);
}
/* The other side of the connection is not polling */