aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-02-25 22:50:39 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-02-26 06:31:16 +0000
commita373149eef0323cb092cc78761871cd1f2bfc1e2 (patch)
tree1cb06da0c5983bc5d258596fd35d74924a69b637 /src
parentdc09133c33aa5f40a06533b06b136c8574e56ea9 (diff)
vlib: add vlib_buffer_free_from_ring
Change-Id: I63f7b14cd63eac9e64cace5d941190096ad148dc Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/buffer_funcs.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index cda44d6aa20..6ea804f8ec4 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -433,6 +433,32 @@ vlib_buffer_free_one (vlib_main_t * vm, u32 buffer_index)
vlib_buffer_free (vm, &buffer_index, /* n_buffers */ 1);
}
+/** \brief Free buffers from ring
+
+ @param vm - (vlib_main_t *) vlib main data structure pointer
+ @param buffers - (u32 * ) buffer index ring
+ @param start - (u32) first slot in the ring
+ @param ring_size - (u32) ring size
+ @param n_buffers - (u32) number of buffers
+*/
+always_inline void
+vlib_buffer_free_from_ring (vlib_main_t * vm, u32 * ring, u32 start,
+ u32 ring_size, u32 n_buffers)
+{
+ ASSERT (n_buffers <= ring_size);
+
+ if (PREDICT_TRUE (start + n_buffers <= ring_size))
+ {
+ vlib_buffer_free (vm, ring + start, n_buffers);
+ }
+ else
+ {
+ vlib_buffer_free (vm, ring + start, ring_size - start);
+ vlib_buffer_free (vm, ring, n_buffers - (ring_size - start));
+ }
+}
+
+
/* Add/delete buffer free lists. */
vlib_buffer_free_list_index_t vlib_buffer_create_free_list (vlib_main_t * vm,
u32 n_data_bytes,