summaryrefslogtreecommitdiffstats
path: root/src/vlib/node_funcs.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-06-03 12:20:41 +0200
committerDave Barach <openvpp@barachs.net>2020-06-03 13:21:57 +0000
commit1033b4997e4194e5172b7b12ddf638bfdfdaae22 (patch)
tree8e7d29685dee34f066688ae4ffe06b29a15f2c5b /src/vlib/node_funcs.h
parentec62d0a436be00bcc084a56548c8c7fa55b2cb61 (diff)
vlib: improve node interrupt handling
- add ability to pass data together with interrupt - avoid locking for local interrupts (same thread) Type: improvement Change-Id: I73a2ab2e716bb887a1f02c87788ae83e329f9b40 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/node_funcs.h')
-rw-r--r--src/vlib/node_funcs.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index d6d04fb16c2..263017d0ec7 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -194,14 +194,36 @@ vlib_node_get_state (vlib_main_t * vm, u32 node_index)
}
always_inline void
-vlib_node_set_interrupt_pending (vlib_main_t * vm, u32 node_index)
+vlib_node_set_interrupt_pending_with_data (vlib_main_t * vm, u32 node_index,
+ u32 data)
{
vlib_node_main_t *nm = &vm->node_main;
vlib_node_t *n = vec_elt (nm->nodes, node_index);
+ vlib_node_interrupt_t *i;
ASSERT (n->type == VLIB_NODE_TYPE_INPUT);
- clib_spinlock_lock_if_init (&nm->pending_interrupt_lock);
- vec_add1 (nm->pending_interrupt_node_runtime_indices, n->runtime_index);
- clib_spinlock_unlock_if_init (&nm->pending_interrupt_lock);
+
+ if (vm == vlib_get_main ())
+ {
+ /* local thread */
+ vec_add2 (nm->pending_local_interrupts, i, 1);
+ i->node_runtime_index = n->runtime_index;
+ i->data = data;
+ }
+ else
+ {
+ /* remote thread */
+ clib_spinlock_lock (&nm->pending_interrupt_lock);
+ vec_add2 (nm->pending_remote_interrupts, i, 1);
+ i->node_runtime_index = n->runtime_index;
+ i->data = data;
+ clib_spinlock_unlock (&nm->pending_interrupt_lock);
+ }
+}
+
+always_inline void
+vlib_node_set_interrupt_pending (vlib_main_t * vm, u32 node_index)
+{
+ vlib_node_set_interrupt_pending_with_data (vm, node_index, 0);
}
always_inline vlib_process_t *