From 142eb8520041ece53d8d1e406bce0a6143a6e8d6 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 20 Nov 2018 09:56:01 +0100 Subject: vlib: add vlib_buffer_enqueue_to_single_next(...) function Change-Id: I485dd07ea0fe032bdd5990567578e73e9bcffe1e Signed-off-by: Damjan Marion --- src/vlib/buffer_node.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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, -- cgit 1.2.3-korg