X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fbuffer.h;h=ceab94f25fd34e4a4ecbf95b0810ecc0eac382bb;hb=bb5d22d;hp=f9750ecf3e1cdba5dd4c7ab02736b073f95eb4a2;hpb=68b4da67deb2e8ca224bb5abaeb9dbc7ae8e378c;p=vpp.git diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index f9750ecf3e1..ceab94f25fd 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -51,6 +51,14 @@ #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 @@ -90,6 +98,7 @@ enum /* User defined buffer flags. */ #define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n)) #define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n)) +#define VLIB_BUFFER_FLAGS_ALL (0x1f) /* VLIB buffer representation. */ typedef struct @@ -177,6 +186,8 @@ typedef struct */ #define vlib_prefetch_buffer_header(b,type) CLIB_PREFETCH (b, 64, type) +#define vlib_prefetch_buffer_data(b,type) \ + CLIB_PREFETCH (vlib_buffer_get_current(b), CLIB_CACHE_LINE_BYTES, type) always_inline void vlib_buffer_struct_is_sane (vlib_buffer_t * b) @@ -224,6 +235,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 @@ -289,7 +303,7 @@ vlib_buffer_get_tail (vlib_buffer_t * b) * @return pointer to beginning of uninitialized data */ always_inline void * -vlib_buffer_put_uninit (vlib_buffer_t * b, u8 size) +vlib_buffer_put_uninit (vlib_buffer_t * b, u16 size) { void *p = vlib_buffer_get_tail (b); /* XXX make sure there's enough space */