vlib: define minimum chained buffer segment size
[vpp.git] / src / vlib / buffer.h
index f9750ec..99f40e8 100644 (file)
 #define VLIB_BUFFER_DATA_SIZE          (2048)
 #define VLIB_BUFFER_PRE_DATA_SIZE      __PRE_DATA_SIZE
 
+/* Minimum buffer chain segment size. Does not apply to last buffer in chain.
+   Dataplane code can safely asume that specified amount of data is not split
+   into 2 chained buffers */
+#define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128)
+
+/* Amount of head buffer data copied to each replica head buffer */
+#define VLIB_BUFFER_CLONE_HEAD_SIZE (256)
+
 typedef u8 vlib_buffer_free_list_index_t;
 
 /** \file
@@ -224,6 +232,9 @@ vlib_buffer_advance (vlib_buffer_t * b, word l)
   ASSERT (b->current_length >= l);
   b->current_data += l;
   b->current_length -= l;
+
+  ASSERT ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0 ||
+         b->current_length >= VLIB_BUFFER_MIN_CHAIN_SEG_SIZE);
 }
 
 /** \brief Check if there is enough space in buffer to advance