diff options
author | Damjan Marion <damarion@cisco.com> | 2018-11-20 09:56:01 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-11-20 10:57:26 +0000 |
commit | 142eb8520041ece53d8d1e406bce0a6143a6e8d6 (patch) | |
tree | 71d0f59eef08e4f992cd66ff58d6ea3b2b6e2672 /src | |
parent | 0724357f6d05116e8d73f83e5743d91a1597990f (diff) |
vlib: add vlib_buffer_enqueue_to_single_next(...) function
Change-Id: I485dd07ea0fe032bdd5990567578e73e9bcffe1e
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vlib/buffer_node.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/vlib/buffer_node.h b/src/vlib/buffer_node.h index bff7a78cb94..2163b72de5e 100644 --- a/src/vlib/buffer_node.h +++ b/src/vlib/buffer_node.h @@ -448,6 +448,41 @@ vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } +static_always_inline void +vlib_buffer_enqueue_to_single_next (vlib_main_t * vm, + vlib_node_runtime_t * node, u32 * buffers, + u16 next_index, u32 count) +{ + u32 *to_next, n_left_to_next, n_enq; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + if (PREDICT_TRUE (n_left_to_next >= count)) + { + clib_memcpy_fast (to_next, buffers, count * sizeof (u32)); + n_left_to_next -= count; + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + return; + } + + n_enq = n_left_to_next; +next: + clib_memcpy_fast (to_next, buffers, n_enq * sizeof (u32)); + n_left_to_next -= n_enq; + + if (PREDICT_FALSE (count > n_enq)) + { + count -= n_enq; + buffers += n_enq; + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + n_enq = clib_min (n_left_to_next, count); + goto next; + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); +} + static_always_inline u32 vlib_buffer_enqueue_to_thread (vlib_main_t * vm, u32 frame_queue_index, u32 * buffer_indices, u16 * thread_indices, |