diff options
Diffstat (limited to 'src/vlib')
-rw-r--r-- | src/vlib/buffer.c | 21 | ||||
-rw-r--r-- | src/vlib/buffer.h | 16 | ||||
-rw-r--r-- | src/vlib/buffer_funcs.h | 51 | ||||
-rw-r--r-- | src/vlib/main.c | 1 |
4 files changed, 19 insertions, 70 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c index 07f91c39a0e..0251f52bd87 100644 --- a/src/vlib/buffer.c +++ b/src/vlib/buffer.c @@ -87,9 +87,9 @@ format_vlib_buffer (u8 * s, va_list * args) a = format (a, "%s ", v); foreach_vlib_buffer_flag #undef _ - s = format (s, "current data %d, length %d, free-list %d, clone-count %u", - b->current_data, b->current_length, - vlib_buffer_get_free_list_index (b), b->n_add_refs); + s = format (s, "current data %d, length %d, buffer-pool %d, " + "clone-count %u", b->current_data, b->current_length, + b->buffer_pool_index, b->n_add_refs); if (b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID) s = format (s, ", totlen-nifb %d", @@ -182,14 +182,8 @@ vlib_validate_buffer_helper (vlib_main_t * vm, vlib_buffer_t *b = vlib_get_buffer (vm, bi); vlib_buffer_free_list_t *fl; - if (pool_is_free_index - (vm->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 (vm->buffer_free_list_pool, - vlib_buffer_get_free_list_index (b)); + fl = pool_elt_at_index (vm->buffer_free_list_pool, + VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); if ((signed) b->current_data < (signed) -VLIB_BUFFER_PRE_DATA_SIZE) return format (0, "current data %d before pre-data", b->current_data); @@ -394,7 +388,6 @@ 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. */ - vlib_buffer_set_free_list_index (&f->buffer_init_template, f->index); f->buffer_init_template.n_add_refs = 0; if (is_public) @@ -567,10 +560,10 @@ recycle_or_free (vlib_main_t * vm, vlib_buffer_main_t * bm, u32 bi, vlib_buffer_t * b, u32 follow_buffer_next) { vlib_buffer_free_list_t *fl; - vlib_buffer_free_list_index_t fi; u32 flags, next; - fl = vlib_buffer_get_buffer_free_list (vm, b, &fi); + fl = pool_elt_at_index (vm->buffer_free_list_pool, + VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); do { diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index 68d6c5eb32b..56d855101d5 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -72,11 +72,10 @@ typedef u8 vlib_buffer_free_list_index_t; * Buffer Flags */ #define foreach_vlib_buffer_flag \ - _( 0, NON_DEFAULT_FREELIST, "non-default-fl") \ - _( 1, IS_TRACED, 0) \ - _( 2, NEXT_PRESENT, 0) \ - _( 3, TOTAL_LENGTH_VALID, 0) \ - _( 4, EXT_HDR_VALID, "ext-hdr-valid") + _( 0, IS_TRACED, 0) \ + _( 1, NEXT_PRESENT, 0) \ + _( 2, TOTAL_LENGTH_VALID, 0) \ + _( 3, EXT_HDR_VALID, "ext-hdr-valid") /* NOTE: only buffer generic flags should be defined here, please consider using user flags. i.e. src/vnet/buffer.h */ @@ -98,7 +97,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) +#define VLIB_BUFFER_FLAGS_ALL (0x0f) /* VLIB buffer representation. */ typedef struct @@ -161,10 +160,7 @@ typedef struct /**< Only valid for first buffer in chain. Current length plus total length given here give total number of bytes in buffer chain. */ - vlib_buffer_free_list_index_t free_list_index; /** < only used if - VLIB_BUFFER_NON_DEFAULT_FREELIST - flag is set */ - u8 align_pad[3]; /**< available */ + u8 align_pad[4]; /**< available */ u32 opaque2[12]; /**< More opaque data, see ../vnet/vnet/buffer.h */ /***** end of second cache line */ diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index cc72c57d5e8..41b5164e0d8 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -400,28 +400,6 @@ vlib_buffer_round_size (u32 size) return round_pow2 (size, sizeof (vlib_buffer_t)); } -always_inline vlib_buffer_free_list_index_t -vlib_buffer_get_free_list_index (vlib_buffer_t * b) -{ - if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NON_DEFAULT_FREELIST)) - return b->free_list_index; - - return 0; -} - -always_inline void -vlib_buffer_set_free_list_index (vlib_buffer_t * b, - vlib_buffer_free_list_index_t index) -{ - if (PREDICT_FALSE (index)) - { - b->flags |= VLIB_BUFFER_NON_DEFAULT_FREELIST; - b->free_list_index = index; - } - else - b->flags &= ~VLIB_BUFFER_NON_DEFAULT_FREELIST; -} - /** \brief Allocate buffers from specific freelist into supplied array @param vm - (vlib_main_t *) vlib main data structure pointer @@ -652,16 +630,6 @@ void vlib_buffer_free_list_fill_unaligned (vlib_main_t * vm, uword n_unaligned_buffers); always_inline vlib_buffer_free_list_t * -vlib_buffer_get_buffer_free_list (vlib_main_t * vm, vlib_buffer_t * b, - vlib_buffer_free_list_index_t * index) -{ - vlib_buffer_free_list_index_t i; - - *index = i = vlib_buffer_get_free_list_index (b); - return pool_elt_at_index (vm->buffer_free_list_pool, i); -} - -always_inline vlib_buffer_free_list_t * vlib_buffer_get_free_list (vlib_main_t * vm, vlib_buffer_free_list_index_t free_list_index) { @@ -789,18 +757,13 @@ vlib_buffer_clone_256 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, return 1; } - n_buffers = vlib_buffer_alloc_from_free_list (vm, buffers, n_buffers, - vlib_buffer_get_free_list_index - (s)); + n_buffers = vlib_buffer_alloc (vm, buffers, n_buffers); for (i = 0; i < n_buffers; i++) { vlib_buffer_t *d = vlib_get_buffer (vm, buffers[i]); d->current_data = s->current_data; d->current_length = head_end_offset; - vlib_buffer_set_free_list_index (d, - vlib_buffer_get_free_list_index (s)); - d->total_length_not_including_first_buffer = s->current_length - head_end_offset; if (PREDICT_FALSE (s->flags & VLIB_BUFFER_NEXT_PRESENT)) @@ -875,8 +838,6 @@ vlib_buffer_attach_clone (vlib_main_t * vm, vlib_buffer_t * head, vlib_buffer_t * tail) { ASSERT ((head->flags & VLIB_BUFFER_NEXT_PRESENT) == 0); - ASSERT (vlib_buffer_get_free_list_index (head) == - vlib_buffer_get_free_list_index (tail)); head->flags |= VLIB_BUFFER_NEXT_PRESENT; head->flags &= ~VLIB_BUFFER_TOTAL_LENGTH_VALID; @@ -1026,7 +987,6 @@ vlib_buffer_init_for_free_list (vlib_buffer_t * dst, /* Not in the first 16 octets. */ dst->n_add_refs = src->n_add_refs; - vlib_buffer_set_free_list_index (dst, fl->index); /* Make sure it really worked. */ #define _(f) ASSERT (dst->f == src->f); @@ -1159,9 +1119,10 @@ vlib_buffer_chain_compress (vlib_main_t * vm, return; } /* probe free list to find allocated buffer size to avoid overfill */ - vlib_buffer_free_list_index_t index; - vlib_buffer_free_list_t *free_list = - vlib_buffer_get_buffer_free_list (vm, first, &index); + vlib_buffer_free_list_t *free_list; + + free_list = pool_elt_at_index (vm->buffer_free_list_pool, + VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); u32 want_first_size = clib_min (VLIB_BUFFER_CHAIN_MIN_FIRST_DATA_SIZE, free_list->n_data_bytes - @@ -1212,7 +1173,7 @@ vlib_buffer_chain_linearize (vlib_main_t * vm, vlib_buffer_t * first) { vlib_buffer_t *b = first; vlib_buffer_free_list_t *fl = - vlib_buffer_get_free_list (vm, vlib_buffer_get_free_list_index (b)); + vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); u32 buf_len = fl->n_data_bytes; // free buffer chain starting from the second buffer int free_count = (b->flags & VLIB_BUFFER_NEXT_PRESENT) != 0; diff --git a/src/vlib/main.c b/src/vlib/main.c index ae78c430134..650fa281746 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -987,7 +987,6 @@ format_buffer_metadata (u8 * s, va_list * args) "trace_index: %d, recycle_count: %d, len_not_first_buf: %d\n", b->trace_index, b->recycle_count, b->total_length_not_including_first_buffer); - s = format (s, "free_list_index: %d\n", (u32) (b->free_list_index)); return s; } |