aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-05-17 19:09:33 -0700
committerDamjan Marion <dmarion@me.com>2021-05-19 19:34:12 +0000
commit46b8b1a4c0743ef91d41db6dea582eb590f5f31b (patch)
treef1af283c36657fdf9a873cdeeb58fb04a61aeed4 /src/vnet
parent6e9964e6c0a5d2a7102f22695f796054fd8f2b95 (diff)
session: cleanup event llist usage
Type: refactor Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I750c856ac81d951e8c0e62c710e0f35a0c80d6f9
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/session.h30
-rw-r--r--src/vnet/session/session_cli.c4
-rw-r--r--src/vnet/session/session_node.c34
3 files changed, 27 insertions, 41 deletions
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index b583c3ef0dd..db9220d8c3b 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -257,32 +257,18 @@ typedef enum session_q_process_evt_
#define TRANSPORT_PROTO_INVALID (session_main.last_transport_proto_type + 1)
#define TRANSPORT_N_PROTOS (session_main.last_transport_proto_type + 1)
-static inline session_evt_elt_t *
-session_evt_elt_alloc (session_worker_t * wrk)
-{
- session_evt_elt_t *elt;
- pool_get (wrk->event_elts, elt);
- return elt;
-}
-
-static inline void
-session_evt_elt_free (session_worker_t * wrk, session_evt_elt_t * elt)
-{
- pool_put (wrk->event_elts, elt);
-}
-
static inline void
session_evt_add_old (session_worker_t * wrk, session_evt_elt_t * elt)
{
clib_llist_add_tail (wrk->event_elts, evt_list, elt,
- pool_elt_at_index (wrk->event_elts, wrk->old_head));
+ clib_llist_elt (wrk->event_elts, wrk->old_head));
}
static inline void
session_evt_add_head_old (session_worker_t * wrk, session_evt_elt_t * elt)
{
clib_llist_add (wrk->event_elts, evt_list, elt,
- pool_elt_at_index (wrk->event_elts, wrk->old_head));
+ clib_llist_elt (wrk->event_elts, wrk->old_head));
}
@@ -298,9 +284,9 @@ static inline session_evt_elt_t *
session_evt_alloc_ctrl (session_worker_t * wrk)
{
session_evt_elt_t *elt;
- elt = session_evt_elt_alloc (wrk);
+ clib_llist_get (wrk->event_elts, elt);
clib_llist_add_tail (wrk->event_elts, evt_list, elt,
- pool_elt_at_index (wrk->event_elts, wrk->ctrl_head));
+ clib_llist_elt (wrk->event_elts, wrk->ctrl_head));
return elt;
}
@@ -322,9 +308,9 @@ static inline session_evt_elt_t *
session_evt_alloc_new (session_worker_t * wrk)
{
session_evt_elt_t *elt;
- elt = session_evt_elt_alloc (wrk);
+ clib_llist_get (wrk->event_elts, elt);
clib_llist_add_tail (wrk->event_elts, evt_list, elt,
- pool_elt_at_index (wrk->event_elts, wrk->new_head));
+ clib_llist_elt (wrk->event_elts, wrk->new_head));
return elt;
}
@@ -332,9 +318,9 @@ static inline session_evt_elt_t *
session_evt_alloc_old (session_worker_t * wrk)
{
session_evt_elt_t *elt;
- elt = session_evt_elt_alloc (wrk);
+ clib_llist_get (wrk->event_elts, elt);
clib_llist_add_tail (wrk->event_elts, evt_list, elt,
- pool_elt_at_index (wrk->event_elts, wrk->old_head));
+ clib_llist_elt (wrk->event_elts, wrk->old_head));
return elt;
}
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 1505a95f41a..24d8cfb1e24 100644
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -455,9 +455,9 @@ session_cli_show_events_thread (vlib_main_t * vm, u32 thread_index)
vlib_cli_output (vm, "Thread %d:\n", thread_index);
vlib_cli_output (vm, " evt elements alloc: %u",
- pool_elts (wrk->event_elts));
+ clib_llist_elts (wrk->event_elts));
vlib_cli_output (vm, " ctrl evt elt data alloc: %d",
- pool_elts (wrk->ctrl_evts_data));
+ clib_llist_elts (wrk->ctrl_evts_data));
}
static void
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 6e3afa57664..af7a6ed50fe 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -216,7 +216,7 @@ session_mq_handle_connects_rpc (void *arg)
vlib_worker_thread_barrier_sync (vm);
- he = pool_elt_at_index (fwrk->event_elts, fwrk->pending_connects);
+ he = clib_llist_elt (fwrk->event_elts, fwrk->pending_connects);
elt = clib_llist_next (fwrk->event_elts, evt_list, he);
/* Avoid holding the barrier for too long */
@@ -225,7 +225,7 @@ session_mq_handle_connects_rpc (void *arg)
next = clib_llist_next (fwrk->event_elts, evt_list, elt);
clib_llist_remove (fwrk->event_elts, evt_list, elt);
session_mq_connect_one (session_evt_ctrl_data (fwrk, elt));
- session_evt_elt_free (fwrk, elt);
+ clib_llist_put (fwrk->event_elts, elt);
elt = next;
n_connects += 1;
}
@@ -289,7 +289,7 @@ session_mq_connect_handler (session_worker_t *wrk, session_evt_elt_t *elt)
}
/* Add to pending list to be handled by main thread */
- he = pool_elt_at_index (wrk->event_elts, wrk->pending_connects);
+ he = clib_llist_elt (wrk->event_elts, wrk->pending_connects);
clib_llist_add_tail (wrk->event_elts, evt_list, elt, he);
if (!wrk->pending_connects_ntf)
@@ -1504,13 +1504,13 @@ session_event_dispatch_ctrl (session_worker_t * wrk, session_evt_elt_t * elt)
}
/* Regrab elements in case pool moved */
- elt = pool_elt_at_index (wrk->event_elts, ei);
+ elt = clib_llist_elt (wrk->event_elts, ei);
if (!clib_llist_elt_is_linked (elt, evt_list))
{
e = &elt->evt;
if (e->event_type >= SESSION_CTRL_EVT_BOUND)
session_evt_ctrl_data_free (wrk, elt);
- session_evt_elt_free (wrk, elt);
+ clib_llist_put (wrk->event_elts, elt);
}
SESSION_EVT (SESSION_EVT_COUNTS, CNT_CTRL_EVTS, 1, wrk);
}
@@ -1569,9 +1569,9 @@ session_event_dispatch_io (session_worker_t * wrk, vlib_node_runtime_t * node,
SESSION_EVT (SESSION_IO_EVT_COUNTS, e->event_type, 1, wrk);
/* Regrab elements in case pool moved */
- elt = pool_elt_at_index (wrk->event_elts, ei);
+ elt = clib_llist_elt (wrk->event_elts, ei);
if (!clib_llist_elt_is_linked (elt, evt_list))
- session_evt_elt_free (wrk, elt);
+ clib_llist_put (wrk->event_elts, elt);
}
/* *INDENT-OFF* */
@@ -1648,7 +1648,7 @@ session_wrk_update_state (session_worker_t *wrk)
if (wrk->state == SESSION_WRK_POLLING)
{
- if (pool_elts (wrk->event_elts) == 3 &&
+ if (clib_llist_elts (wrk->event_elts) == 4 &&
vlib_last_vectors_per_main_loop (vm) < 1)
{
session_wrk_set_state (wrk, SESSION_WRK_INTERRUPT);
@@ -1658,7 +1658,7 @@ session_wrk_update_state (session_worker_t *wrk)
}
else if (wrk->state == SESSION_WRK_INTERRUPT)
{
- if (pool_elts (wrk->event_elts) > 3 ||
+ if (clib_llist_elts (wrk->event_elts) > 4 ||
vlib_last_vectors_per_main_loop (vm) > 1)
{
session_wrk_set_state (wrk, SESSION_WRK_POLLING);
@@ -1672,7 +1672,7 @@ session_wrk_update_state (session_worker_t *wrk)
}
else
{
- if (pool_elts (wrk->event_elts))
+ if (clib_llist_elts (wrk->event_elts))
{
session_wrk_set_state (wrk, SESSION_WRK_INTERRUPT);
}
@@ -1713,13 +1713,13 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
*/
ei = wrk->ctrl_head;
- ctrl_he = pool_elt_at_index (wrk->event_elts, ei);
+ ctrl_he = clib_llist_elt (wrk->event_elts, ei);
next_ei = clib_llist_next_index (ctrl_he, evt_list);
old_ti = clib_llist_prev_index (ctrl_he, evt_list);
while (ei != old_ti)
{
ei = next_ei;
- elt = pool_elt_at_index (wrk->event_elts, next_ei);
+ elt = clib_llist_elt (wrk->event_elts, next_ei);
next_ei = clib_llist_next_index (elt, evt_list);
clib_llist_remove (wrk->event_elts, evt_list, elt);
session_event_dispatch_ctrl (wrk, elt);
@@ -1731,14 +1731,14 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* Handle the new io events.
*/
- new_he = pool_elt_at_index (wrk->event_elts, wrk->new_head);
- old_he = pool_elt_at_index (wrk->event_elts, wrk->old_head);
+ new_he = clib_llist_elt (wrk->event_elts, wrk->new_head);
+ old_he = clib_llist_elt (wrk->event_elts, wrk->old_head);
old_ti = clib_llist_prev_index (old_he, evt_list);
ei = clib_llist_next_index (new_he, evt_list);
while (ei != wrk->new_head && n_tx_packets < SESSION_NODE_FRAME_SIZE)
{
- elt = pool_elt_at_index (wrk->event_elts, ei);
+ elt = clib_llist_elt (wrk->event_elts, ei);
ei = clib_llist_next_index (elt, evt_list);
clib_llist_remove (wrk->event_elts, evt_list, elt);
session_event_dispatch_io (wrk, node, elt, &n_tx_packets);
@@ -1752,12 +1752,12 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
if (old_ti != wrk->old_head)
{
- old_he = pool_elt_at_index (wrk->event_elts, wrk->old_head);
+ old_he = clib_llist_elt (wrk->event_elts, wrk->old_head);
ei = clib_llist_next_index (old_he, evt_list);
while (n_tx_packets < SESSION_NODE_FRAME_SIZE)
{
- elt = pool_elt_at_index (wrk->event_elts, ei);
+ elt = clib_llist_elt (wrk->event_elts, ei);
next_ei = clib_llist_next_index (elt, evt_list);
clib_llist_remove (wrk->event_elts, evt_list, elt);