aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-01 12:41:21 -0800
committerDave Barach <openvpp@barachs.net>2019-03-02 23:39:51 +0000
commitf6c4313b6aa7746fe97afd398ce68c2efbef0600 (patch)
tree72b551a33adf3ae6017ca792c2f4c3a5f05c2477 /src/vnet
parent5fd3210be3a043c12c598df3d75dbe0aa606bfe5 (diff)
session: cleanup session event types
Change-Id: I87bdf705341dd760f0be907a663aa64140977d39 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session-apps/echo_client.c6
-rw-r--r--src/vnet/session-apps/echo_server.c7
-rw-r--r--src/vnet/session-apps/http_server.c2
-rw-r--r--src/vnet/session-apps/proxy.c6
-rw-r--r--src/vnet/session/application_interface.h4
-rw-r--r--src/vnet/session/application_worker.c6
-rw-r--r--src/vnet/session/session.c31
-rw-r--r--src/vnet/session/session.h2
-rw-r--r--src/vnet/session/session_node.c36
-rw-r--r--src/vnet/session/session_types.h37
10 files changed, 63 insertions, 74 deletions
diff --git a/src/vnet/session-apps/echo_client.c b/src/vnet/session-apps/echo_client.c
index cb93e81054c..44e6ffce842 100644
--- a/src/vnet/session-apps/echo_client.c
+++ b/src/vnet/session-apps/echo_client.c
@@ -63,7 +63,7 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
rv = clib_min (svm_fifo_max_enqueue (f), bytes_this_chunk);
svm_fifo_enqueue_nocopy (f, rv);
session_send_io_evt_to_thread_custom (f, s->thread_index,
- FIFO_EVENT_APP_TX);
+ SESSION_IO_EVT_TX);
}
else
rv = app_send_stream (&s->data, test_data + test_buf_offset,
@@ -96,7 +96,7 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
svm_fifo_enqueue_nowait (f, sizeof (hdr), (u8 *) & hdr);
svm_fifo_enqueue_nocopy (f, rv);
session_send_io_evt_to_thread_custom (f, s->thread_index,
- FIFO_EVENT_APP_TX);
+ SESSION_IO_EVT_TX);
}
else
rv = app_send_dgram (&s->data, test_data + test_buf_offset,
@@ -481,7 +481,7 @@ echo_clients_rx_callback (session_t * s)
if (svm_fifo_max_dequeue (s->rx_fifo))
{
if (svm_fifo_set_event (s->rx_fifo))
- session_send_io_evt_to_thread (s->rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ session_send_io_evt_to_thread (s->rx_fifo, SESSION_IO_EVT_BUILTIN_RX);
}
return 0;
}
diff --git a/src/vnet/session-apps/echo_server.c b/src/vnet/session-apps/echo_server.c
index f9d3d93c4e7..1d99ff17a0f 100644
--- a/src/vnet/session-apps/echo_server.c
+++ b/src/vnet/session-apps/echo_server.c
@@ -195,7 +195,8 @@ echo_server_rx_callback (session_t * s)
/* Program self-tap to retry */
if (svm_fifo_set_event (rx_fifo))
{
- if (session_send_io_evt_to_thread (rx_fifo, FIFO_EVENT_BUILTIN_RX))
+ if (session_send_io_evt_to_thread (rx_fifo,
+ SESSION_IO_EVT_BUILTIN_RX))
clib_warning ("failed to enqueue self-tap");
vec_validate (esm->rx_retries[s->thread_index], s->session_index);
@@ -239,14 +240,14 @@ echo_server_rx_callback (session_t * s)
n_written = app_send_stream_raw (tx_fifo,
esm->vpp_queue[thread_index],
esm->rx_buf[thread_index],
- actual_transfer, FIFO_EVENT_APP_TX, 0);
+ actual_transfer, SESSION_IO_EVT_TX, 0);
}
else
{
n_written = app_send_dgram_raw (tx_fifo, &at,
esm->vpp_queue[s->thread_index],
esm->rx_buf[thread_index],
- actual_transfer, FIFO_EVENT_APP_TX, 0);
+ actual_transfer, SESSION_IO_EVT_TX, 0);
}
if (n_written != max_transfer)
diff --git a/src/vnet/session-apps/http_server.c b/src/vnet/session-apps/http_server.c
index 2dfb6a485b8..f702b741f95 100644
--- a/src/vnet/session-apps/http_server.c
+++ b/src/vnet/session-apps/http_server.c
@@ -571,7 +571,7 @@ close_session:
postpone:
(void) svm_fifo_set_event (hs->rx_fifo);
- session_send_io_evt_to_thread (hs->rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ session_send_io_evt_to_thread (hs->rx_fifo, SESSION_IO_EVT_BUILTIN_RX);
return 0;
wait_for_data:
diff --git a/src/vnet/session-apps/proxy.c b/src/vnet/session-apps/proxy.c
index ba7b05784fa..92a3910efbf 100644
--- a/src/vnet/session-apps/proxy.c
+++ b/src/vnet/session-apps/proxy.c
@@ -214,7 +214,7 @@ proxy_rx_callback (session_t * s)
u32 ao_thread_index = active_open_tx_fifo->master_thread_index;
if (session_send_io_evt_to_thread_custom (active_open_tx_fifo,
ao_thread_index,
- FIFO_EVENT_APP_TX))
+ SESSION_IO_EVT_TX))
clib_warning ("failed to enqueue tx evt");
}
}
@@ -320,7 +320,7 @@ active_open_connected_callback (u32 app_index, u32 opaque,
*/
ASSERT (s->thread_index == thread_index);
if (svm_fifo_set_event (s->tx_fifo))
- session_send_io_evt_to_thread (s->tx_fifo, FIFO_EVENT_APP_TX);
+ session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX);
return 0;
}
@@ -358,7 +358,7 @@ active_open_rx_callback (session_t * s)
u8 thread_index = proxy_tx_fifo->master_thread_index;
return session_send_io_evt_to_thread_custom (proxy_tx_fifo,
thread_index,
- FIFO_EVENT_APP_TX);
+ SESSION_IO_EVT_TX);
}
return 0;
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 441b5f613a7..66037a56e34 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -490,7 +490,7 @@ always_inline int
app_send_dgram (app_session_t * s, u8 * data, u32 len, u8 noblock)
{
return app_send_dgram_raw (s->tx_fifo, &s->transport, s->vpp_evt_q, data,
- len, FIFO_EVENT_APP_TX, noblock);
+ len, SESSION_IO_EVT_TX, noblock);
}
always_inline int
@@ -511,7 +511,7 @@ always_inline int
app_send_stream (app_session_t * s, u8 * data, u32 len, u8 noblock)
{
return app_send_stream_raw (s->tx_fifo, s->vpp_evt_q, data, len,
- FIFO_EVENT_APP_TX, noblock);
+ SESSION_IO_EVT_TX, noblock);
}
always_inline int
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index d02149dc58f..2717ef01870 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -564,7 +564,7 @@ app_send_io_evt_rx (app_worker_t * app_wrk, session_t * s, u8 lock)
evt = (session_event_t *) svm_msg_q_msg_data (mq, &msg);
evt->fifo = s->rx_fifo;
- evt->event_type = FIFO_EVENT_APP_RX;
+ evt->event_type = SESSION_IO_EVT_RX;
(void) svm_fifo_set_event (s->rx_fifo);
@@ -599,7 +599,7 @@ app_send_io_evt_tx (app_worker_t * app_wrk, session_t * s, u8 lock)
ASSERT (!svm_msg_q_msg_is_invalid (&msg));
evt = (session_event_t *) svm_msg_q_msg_data (mq, &msg);
- evt->event_type = FIFO_EVENT_APP_TX;
+ evt->event_type = SESSION_IO_EVT_TX;
evt->fifo = s->tx_fifo;
return app_enqueue_evt (mq, &msg, lock);
@@ -625,7 +625,7 @@ static app_send_evt_handler_fn * const app_send_evt_handler_fns[3] = {
int
app_worker_send_event (app_worker_t * app, session_t * s, u8 evt_type)
{
- ASSERT (app && evt_type <= FIFO_EVENT_APP_TX);
+ ASSERT (app && evt_type <= SESSION_IO_EVT_TX);
return app_send_evt_handler_fns[evt_type] (app, s, 0 /* lock */ );
}
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 36aadcb7c40..97636a7ac8e 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -59,17 +59,17 @@ session_send_evt_to_thread (void *data, void *args, u32 thread_index,
evt->event_type = evt_type;
switch (evt_type)
{
- case FIFO_EVENT_RPC:
+ case SESSION_CTRL_EVT_RPC:
evt->rpc_args.fp = data;
evt->rpc_args.arg = args;
break;
- case FIFO_EVENT_APP_TX:
+ case SESSION_IO_EVT_TX:
case SESSION_IO_EVT_TX_FLUSH:
- case FIFO_EVENT_BUILTIN_RX:
+ case SESSION_IO_EVT_BUILTIN_RX:
evt->fifo = data;
break;
- case FIFO_EVENT_BUILTIN_TX:
- case FIFO_EVENT_DISCONNECT:
+ case SESSION_IO_EVT_BUILTIN_TX:
+ case SESSION_CTRL_EVT_CLOSE:
evt->session_handle = session_handle ((session_t *) data);
break;
default:
@@ -99,16 +99,17 @@ int
session_send_ctrl_evt_to_thread (session_t * s, session_evt_type_t evt_type)
{
/* only event supported for now is disconnect */
- ASSERT (evt_type == FIFO_EVENT_DISCONNECT);
+ ASSERT (evt_type == SESSION_CTRL_EVT_CLOSE);
return session_send_evt_to_thread (s, 0, s->thread_index,
- FIFO_EVENT_DISCONNECT);
+ SESSION_CTRL_EVT_CLOSE);
}
void
session_send_rpc_evt_to_thread (u32 thread_index, void *fp, void *rpc_args)
{
if (thread_index != vlib_get_thread_index ())
- session_send_evt_to_thread (fp, rpc_args, thread_index, FIFO_EVENT_RPC);
+ session_send_evt_to_thread (fp, rpc_args, thread_index,
+ SESSION_CTRL_EVT_RPC);
else
{
void (*fnp) (void *) = fp;
@@ -138,10 +139,10 @@ session_program_transport_close (session_t * s)
vec_add2 (wrk->pending_disconnects, evt, 1);
clib_memset (evt, 0, sizeof (*evt));
evt->session_handle = session_handle (s);
- evt->event_type = FIFO_EVENT_DISCONNECT;
+ evt->event_type = SESSION_CTRL_EVT_CLOSE;
}
else
- session_send_ctrl_evt_to_thread (s, FIFO_EVENT_DISCONNECT);
+ session_send_ctrl_evt_to_thread (s, SESSION_CTRL_EVT_CLOSE);
}
session_t *
@@ -521,18 +522,18 @@ session_enqueue_notify (session_t * s)
/* *INDENT-OFF* */
SESSION_EVT_DBG(SESSION_EVT_ENQ, s, ({
- ed->data[0] = FIFO_EVENT_APP_RX;
+ ed->data[0] = SESSION_IO_EVT_RX;
ed->data[1] = svm_fifo_max_dequeue (s->rx_fifo);
}));
/* *INDENT-ON* */
if (PREDICT_FALSE (app_worker_lock_and_send_event (app_wrk, s,
- FIFO_EVENT_APP_RX)))
+ SESSION_IO_EVT_RX)))
return -1;
if (PREDICT_FALSE (svm_fifo_n_subscribers (s->rx_fifo)))
return session_notify_subscribers (app_wrk->app_index, s,
- s->rx_fifo, FIFO_EVENT_APP_RX);
+ s->rx_fifo, SESSION_IO_EVT_RX);
return 0;
}
@@ -547,12 +548,12 @@ session_dequeue_notify (session_t * s)
return -1;
if (PREDICT_FALSE (app_worker_lock_and_send_event (app_wrk, s,
- FIFO_EVENT_APP_TX)))
+ SESSION_IO_EVT_TX)))
return -1;
if (PREDICT_FALSE (s->tx_fifo->n_subscribers))
return session_notify_subscribers (app_wrk->app_index, s,
- s->tx_fifo, FIFO_EVENT_APP_TX);
+ s->tx_fifo, SESSION_IO_EVT_TX);
svm_fifo_clear_tx_ntf (s->tx_fifo);
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 6a52be31b49..92fd5fafe7a 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -449,7 +449,7 @@ transport_add_tx_event (transport_connection_t * tc)
session_t *s = session_get (tc->s_index, tc->thread_index);
if (svm_fifo_has_event (s->tx_fifo))
return;
- session_send_io_evt_to_thread (s->tx_fifo, FIFO_EVENT_APP_TX);
+ session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX);
}
/*
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index e6309429194..974c28a7210 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -83,7 +83,7 @@ session_mq_accepted_reply_handler (void *data)
old_state = s->session_state;
s->session_state = SESSION_STATE_READY;
if (!svm_fifo_is_empty (s->rx_fifo))
- app_worker_lock_and_send_event (app_wrk, s, FIFO_EVENT_APP_RX);
+ app_worker_lock_and_send_event (app_wrk, s, SESSION_IO_EVT_RX);
/* Closed while waiting for app to reply. Resend disconnect */
if (old_state >= SESSION_STATE_TRANSPORT_CLOSING)
@@ -283,10 +283,10 @@ session_mq_worker_update_handler (void *data)
* Retransmit messages that may have been lost
*/
if (s->tx_fifo && !svm_fifo_is_empty (s->tx_fifo))
- session_send_io_evt_to_thread (s->tx_fifo, FIFO_EVENT_APP_TX);
+ session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX);
if (s->rx_fifo && !svm_fifo_is_empty (s->rx_fifo))
- app_worker_lock_and_send_event (app_wrk, s, FIFO_EVENT_APP_RX);
+ app_worker_lock_and_send_event (app_wrk, s, SESSION_IO_EVT_RX);
if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSING)
app->cb_fns.session_disconnect_callback (s);
@@ -510,7 +510,7 @@ session_tx_fill_buffer (vlib_main_t * vm, session_tx_context_t * ctx,
/* *INDENT-OFF* */
SESSION_EVT_DBG(SESSION_EVT_DEQ, ctx->s, ({
- ed->data[0] = FIFO_EVENT_APP_TX;
+ ed->data[0] = SESSION_IO_EVT_TX;
ed->data[1] = ctx->max_dequeue;
ed->data[2] = len_to_deq;
ed->data[3] = ctx->left_to_snd;
@@ -916,7 +916,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
switch (e->event_type)
{
case SESSION_IO_EVT_TX_FLUSH:
- case FIFO_EVENT_APP_TX:
+ case SESSION_IO_EVT_TX:
/* Don't try to send more that one frame per dispatch cycle */
if (n_tx_packets == VLIB_FRAME_SIZE)
{
@@ -949,7 +949,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
continue;
}
break;
- case FIFO_EVENT_DISCONNECT:
+ case SESSION_CTRL_EVT_CLOSE:
s = session_get_from_handle_if_valid (e->session_handle);
if (PREDICT_FALSE (!s))
break;
@@ -968,7 +968,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
session_transport_close (s);
break;
- case FIFO_EVENT_BUILTIN_RX:
+ case SESSION_IO_EVT_BUILTIN_RX:
s = session_event_get_session (e, thread_index);
if (PREDICT_FALSE (!s || s->session_state >= SESSION_STATE_CLOSING))
continue;
@@ -977,14 +977,14 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
app = application_get (app_wrk->app_index);
app->cb_fns.builtin_app_rx_callback (s);
break;
- case FIFO_EVENT_BUILTIN_TX:
+ case SESSION_IO_EVT_BUILTIN_TX:
s = session_get_from_handle_if_valid (e->session_handle);
wrk->ctx.s = s;
if (PREDICT_TRUE (s != 0))
session_tx_fifo_dequeue_internal (vm, node, wrk, e,
&n_tx_packets);
break;
- case FIFO_EVENT_RPC:
+ case SESSION_CTRL_EVT_RPC:
fp = e->rpc_args.fp;
(*fp) (e->rpc_args.arg);
break;
@@ -1059,23 +1059,23 @@ dump_thread_0_event_queue (void)
switch (e->event_type)
{
- case FIFO_EVENT_APP_TX:
+ case SESSION_IO_EVT_TX:
s0 = session_event_get_session (e, my_thread_index);
fformat (stdout, "[%04d] TX session %d\n", i, s0->session_index);
break;
- case FIFO_EVENT_DISCONNECT:
+ case SESSION_CTRL_EVT_CLOSE:
s0 = session_get_from_handle (e->session_handle);
fformat (stdout, "[%04d] disconnect session %d\n", i,
s0->session_index);
break;
- case FIFO_EVENT_BUILTIN_RX:
+ case SESSION_IO_EVT_BUILTIN_RX:
s0 = session_event_get_session (e, my_thread_index);
fformat (stdout, "[%04d] builtin_rx %d\n", i, s0->session_index);
break;
- case FIFO_EVENT_RPC:
+ case SESSION_CTRL_EVT_RPC:
fformat (stdout, "[%04d] RPC call %llx with %llx\n",
i, (u64) (uword) (e->rpc_args.fp),
(u64) (uword) (e->rpc_args.arg));
@@ -1100,15 +1100,15 @@ session_node_cmp_event (session_event_t * e, svm_fifo_t * f)
session_t *s;
switch (e->event_type)
{
- case FIFO_EVENT_APP_RX:
- case FIFO_EVENT_APP_TX:
- case FIFO_EVENT_BUILTIN_RX:
+ case SESSION_IO_EVT_RX:
+ case SESSION_IO_EVT_TX:
+ case SESSION_IO_EVT_BUILTIN_RX:
if (e->fifo == f)
return 1;
break;
- case FIFO_EVENT_DISCONNECT:
+ case SESSION_CTRL_EVT_CLOSE:
break;
- case FIFO_EVENT_RPC:
+ case SESSION_CTRL_EVT_RPC:
s = session_get_from_handle (e->session_handle);
if (!s)
{
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 7f1acdd5bf4..c4240ab420a 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -277,15 +277,15 @@ session_parse_handle (session_handle_t handle, u32 * index,
typedef enum
{
- FIFO_EVENT_APP_RX,
+ SESSION_IO_EVT_RX,
SESSION_IO_EVT_CT_RX,
- FIFO_EVENT_APP_TX,
+ SESSION_IO_EVT_TX,
SESSION_IO_EVT_CT_TX,
SESSION_IO_EVT_TX_FLUSH,
- FIFO_EVENT_DISCONNECT,
- FIFO_EVENT_BUILTIN_RX,
- FIFO_EVENT_BUILTIN_TX,
- FIFO_EVENT_RPC,
+ SESSION_IO_EVT_BUILTIN_RX,
+ SESSION_IO_EVT_BUILTIN_TX,
+ SESSION_CTRL_EVT_RPC,
+ SESSION_CTRL_EVT_CLOSE,
SESSION_CTRL_EVT_BOUND,
SESSION_CTRL_EVT_UNLISTEN_REPLY,
SESSION_CTRL_EVT_ACCEPTED,
@@ -301,25 +301,12 @@ typedef enum
SESSION_CTRL_EVT_WORKER_UPDATE_REPLY,
} session_evt_type_t;
-static inline const char *
-fifo_event_type_str (session_evt_type_t et)
-{
- switch (et)
- {
- case FIFO_EVENT_APP_RX:
- return "FIFO_EVENT_APP_RX";
- case FIFO_EVENT_APP_TX:
- return "FIFO_EVENT_APP_TX";
- case FIFO_EVENT_DISCONNECT:
- return "FIFO_EVENT_DISCONNECT";
- case FIFO_EVENT_BUILTIN_RX:
- return "FIFO_EVENT_BUILTIN_RX";
- case FIFO_EVENT_RPC:
- return "FIFO_EVENT_RPC";
- default:
- return "UNKNOWN FIFO EVENT";
- }
-}
+/* Deprecated and will be removed. Use types above */
+#define FIFO_EVENT_APP_RX SESSION_IO_EVT_RX
+#define FIFO_EVENT_APP_TX SESSION_IO_EVT_TX
+#define FIFO_EVENT_DISCONNECT SESSION_CTRL_EVT_CLOSE
+#define FIFO_EVENT_BUILTIN_RX SESSION_IO_EVT_BUILTIN_RX
+#define FIFO_EVENT_BUILTIN_TX SESSION_IO_EVT_BUILTIN_TX
typedef enum
{