buffers: remove free-list information from buffer metadata
Change-Id: I6048c6a51efa826ac333f7d15919cb87dd766d74
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index 7093b01..768d661 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -290,8 +290,7 @@
vlib_buffer_t *bufp[n_buffers], **b = bufp;
u32 thread_index = vlib_get_thread_index ();
int i = 0;
- u32 simple_mask = (VLIB_BUFFER_NON_DEFAULT_FREELIST |
- VLIB_BUFFER_NEXT_PRESENT);
+ u32 simple_mask = VLIB_BUFFER_NEXT_PRESENT;
u32 n_left, *bi;
u32 (*cb) (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
u32 follow_buffer_next);
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 07f91c3..0251f52 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -87,9 +87,9 @@
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_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 @@
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 @@
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 68d6c5e..56d8551 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -72,11 +72,10 @@
* 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 @@
/* 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 @@
/**< 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 cc72c57..41b5164 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -400,28 +400,6 @@
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 @@
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 @@
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_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 @@
/* 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 @@
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_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 ae78c43..650fa28 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -987,7 +987,6 @@
"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;
}
diff --git a/src/vnet/dhcp/dhcp6_proxy_node.c b/src/vnet/dhcp/dhcp6_proxy_node.c
index 432bc8d..ea06c18 100644
--- a/src/vnet/dhcp/dhcp6_proxy_node.c
+++ b/src/vnet/dhcp/dhcp6_proxy_node.c
@@ -315,9 +315,8 @@
copy_ip6_address (&r1->link_addr, ia0);
link_address_set:
- fl =
- vlib_buffer_get_free_list (vm,
- vlib_buffer_get_free_list_index (b0));
+ fl = vlib_buffer_get_free_list
+ (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
if ((b0->current_length + sizeof (*id1) + sizeof (*vss1) +
sizeof (*cmac)) > fl->n_data_bytes)
diff --git a/src/vnet/dns/dns.c b/src/vnet/dns/dns.c
index 93b7fb8..15d40be 100644
--- a/src/vnet/dns/dns.c
+++ b/src/vnet/dns/dns.c
@@ -2810,7 +2810,6 @@
* In the resolution-required / deferred case, resetting a freshly-allocated
* buffer won't hurt. We hope.
*/
- b0->flags &= VLIB_BUFFER_NON_DEFAULT_FREELIST;
b0->flags |= (VNET_BUFFER_F_LOCALLY_ORIGINATED
| VLIB_BUFFER_TOTAL_LENGTH_VALID);
b0->current_data = 0;
diff --git a/src/vnet/ip/ping.c b/src/vnet/ip/ping.c
index f147e47..92a92e5 100755
--- a/src/vnet/ip/ping.c
+++ b/src/vnet/ip/ping.c
@@ -404,8 +404,7 @@
int this_buf_data_len =
remaining_data_len <
VLIB_BUFFER_DATA_SIZE ? remaining_data_len : VLIB_BUFFER_DATA_SIZE;
- int n_alloc = vlib_buffer_alloc_from_free_list (vm, &b0->next_buffer, 1,
- hb->free_list_index);
+ int n_alloc = vlib_buffer_alloc (vm, &b0->next_buffer, 1);
if (n_alloc < 1)
{
/* That is how much we have so far - return it... */
diff --git a/src/vnet/sctp/sctp_output.c b/src/vnet/sctp/sctp_output.c
index c0e1a6e..17b28a8 100644
--- a/src/vnet/sctp/sctp_output.c
+++ b/src/vnet/sctp/sctp_output.c
@@ -271,7 +271,6 @@
sctp_init_buffer (vlib_main_t * vm, vlib_buffer_t * b)
{
ASSERT ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
- b->flags &= VLIB_BUFFER_NON_DEFAULT_FREELIST;
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->total_length_not_including_first_buffer = 0;
vnet_buffer (b)->sctp.flags = 0;
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 97f5b81..8d06ea3 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -519,7 +519,6 @@
tcp_init_buffer (vlib_main_t * vm, vlib_buffer_t * b)
{
ASSERT ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
- b->flags &= VLIB_BUFFER_NON_DEFAULT_FREELIST;
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->total_length_not_including_first_buffer = 0;
b->current_data = 0;