aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,