summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-07-13 18:53:27 +0200
committerDave Barach <openvpp@barachs.net>2017-07-14 15:39:24 +0000
commit072401e8096c648b91f958bd911f64ce24fecff9 (patch)
tree5ef774bbcf5e9c072b8795d39115b012015e05f1 /src/vlib/buffer.c
parent0f09b77778644577545235156a2ea2798ec9ee6c (diff)
Introduce l{2,3,4}_hdr_offset fields in the buffer metadata
To save space in the first cacheline following is changed: - total_length_not_including_first_buffer moved to the 2nd cacheline. This field is used only when VLIB_BUFFER_TOTAL_LENGTH_VALID and VLIB_BUFFER_NEXT_PRESENT are both set. - free_list_index is now stored in 4bits inside flags, which allows up to 16 free lists. In case we need more we can store index in the 2nd cachelin Change-Id: Ic8521350819391af470d31d3fa1013e67ecb7681 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer.c')
-rw-r--r--src/vlib/buffer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index b2a095cfb1a..53b60c165c1 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -72,8 +72,8 @@ format_vlib_buffer (u8 * s, va_list * args)
uword indent = format_get_indent (s);
s = format (s, "current data %d, length %d, free-list %d, clone-count %u",
- b->current_data, b->current_length, b->free_list_index,
- b->n_add_refs);
+ b->current_data, b->current_length,
+ vlib_buffer_get_free_list_index (b), b->n_add_refs);
if (b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID)
s = format (s, ", totlen-nifb %d",
@@ -163,10 +163,14 @@ vlib_validate_buffer_helper (vlib_main_t * vm,
vlib_buffer_main_t *bm = vm->buffer_main;
vlib_buffer_free_list_t *fl;
- if (pool_is_free_index (bm->buffer_free_list_pool, b->free_list_index))
- return format (0, "unknown free list 0x%x", b->free_list_index);
+ if (pool_is_free_index
+ (bm->buffer_free_list_pool, vlib_buffer_get_free_list_index (b)))
+ return format (0, "unknown free list 0x%x",
+ vlib_buffer_get_free_list_index (b));
- fl = pool_elt_at_index (bm->buffer_free_list_pool, b->free_list_index);
+ fl =
+ pool_elt_at_index (bm->buffer_free_list_pool,
+ vlib_buffer_get_free_list_index (b));
if ((signed) b->current_data < (signed) -VLIB_BUFFER_PRE_DATA_SIZE)
return format (0, "current data %d before pre-data", b->current_data);
@@ -388,7 +392,7 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
f->name = clib_mem_is_vec (name) ? name : format (0, "%s", name);
/* Setup free buffer template. */
- f->buffer_init_template.free_list_index = f->index;
+ vlib_buffer_set_free_list_index (&f->buffer_init_template, f->index);
f->buffer_init_template.n_add_refs = 0;
if (is_public)