b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
- free0 = b0->clone_count == 0;
- free1 = b1->clone_count == 0;
+ free0 = (b0->flags & VLIB_BUFFER_RECYCLE) == 0;
+ free1 = (b1->flags & VLIB_BUFFER_RECYCLE) == 0;
/* Must be before init which will over-write buffer flags. */
if (follow_buffer_next)
b0 = vlib_get_buffer (vm, bi0);
- free0 = b0->clone_count == 0;
+ free0 = (b0->flags & VLIB_BUFFER_RECYCLE) == 0;
/* Must be before init which will over-write buffer flags. */
if (follow_buffer_next)
<br> VLIB_BUFFER_NEXT_PRESENT: this is a multi-chunk buffer.
<br> VLIB_BUFFER_TOTAL_LENGTH_VALID: as it says
<br> VLIB_BUFFER_REPL_FAIL: packet replication failure
+ <br> VLIB_BUFFER_RECYCLE: as it says
<br> VLIB_BUFFER_FLAG_USER(n): user-defined bit N
*/
#define VLIB_BUFFER_IS_TRACED (1 << 0)
#define VLIB_BUFFER_IS_RECYCLED (1 << 2)
#define VLIB_BUFFER_TOTAL_LENGTH_VALID (1 << 3)
#define VLIB_BUFFER_REPL_FAIL (1 << 4)
+#define VLIB_BUFFER_RECYCLE (1 << 5)
/* User defined buffer flags. */
#define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n))
Only valid if VLIB_BUFFER_NEXT_PRESENT flag is set.
*/
- u32 clone_count; /**< Specifies whether this buffer should be
- reinitialized when freed. It will be reinitialized
- if the value is 0. This field can be used
- as a counter or for other state during packet
- replication. The buffer free function does not
- modify this value.
- */
-
vlib_error_t error; /**< Error code for buffers to be enqueued
to error handler.
*/
visit enabled feature nodes
*/
+ u32 dont_waste_me; /**< Available space in the (precious)
+ first 32 octets of buffer metadata
+ Before allocating any of it, discussion required!
+ */
+
u32 opaque[8]; /**< Opaque data used by sub-graphs for their own purposes.
See .../vnet/vnet/buffer.h
*/
u32 trace_index; /**< Specifies index into trace buffer
if VLIB_PACKET_IS_TRACED flag is set.
*/
- u32 opaque2[15]; /**< More opaque data, currently unused */
+ u32 recycle_count; /**< Used by L2 path recycle code */
+ u32 opaque2[14]; /**< More opaque data, currently unused */
/***** end of second cache line */
CLIB_CACHE_LINE_ALIGN_MARK(cacheline2);
{
int j;
- add_buffer_to_free_list (vm, fl, buffers[i], b->clone_count == 0);
+ add_buffer_to_free_list
+ (vm, fl, buffers[i],
+ (b->flags & VLIB_BUFFER_RECYCLE) == 0);
for (j = 0; j < vec_len (bm->announce_list); j++)
{
}
else
{
- if (PREDICT_TRUE (b->clone_count == 0))
+ if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_RECYCLE) == 0))
{
mb = rte_mbuf_from_vlib_buffer(b);
ASSERT(rte_mbuf_refcnt_read(mb) == 1);
clib_memcpy (vlib_buffer_get_current (b0), (u8 *) tph + tph->tp_mac + offset, bytes_to_copy);
/* fill buffer header */
- b0->clone_count = 0;
b0->current_length = bytes_to_copy;
if (offset == 0)
mb0 = rte_mbuf_from_vlib_buffer(b0);
mb1 = rte_mbuf_from_vlib_buffer(b1);
- any_clone = b0->clone_count | b1->clone_count;
+ any_clone = (b0->flags & VLIB_BUFFER_RECYCLE)
+ | (b1->flags & VLIB_BUFFER_RECYCLE);
if (PREDICT_FALSE(any_clone != 0))
{
- if (PREDICT_FALSE(b0->clone_count != 0))
+ if (PREDICT_FALSE
+ ((b0->flags & VLIB_BUFFER_RECYCLE) != 0))
{
struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0);
if (PREDICT_FALSE(mb0_new == 0))
mb0 = mb0_new;
vec_add1 (dm->recycle[my_cpu], bi0);
}
- if (PREDICT_FALSE(b1->clone_count != 0))
+ if (PREDICT_FALSE
+ ((b1->flags & VLIB_BUFFER_RECYCLE) != 0))
{
struct rte_mbuf * mb1_new = dpdk_replicate_packet_mb (b1);
if (PREDICT_FALSE(mb1_new == 0))
b0 = vlib_get_buffer (vm, bi0);
mb0 = rte_mbuf_from_vlib_buffer(b0);
- if (PREDICT_FALSE(b0->clone_count != 0))
+ if (PREDICT_FALSE((b0->flags & VLIB_BUFFER_RECYCLE) != 0))
{
struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0);
if (PREDICT_FALSE(mb0_new == 0))
}
vlib_buffer_init_for_free_list (b0, fl);
- b0->clone_count = 0;
bi0 = vlib_get_buffer_index (vm, b0);
b_seg = vlib_buffer_from_rte_mbuf(mb_seg);
vlib_buffer_init_for_free_list (b_seg, fl);
- b_seg->clone_count = 0;
ASSERT((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
ASSERT(b_seg->current_data == 0);
bytes_to_copy);
/* fill buffer header */
- b0->clone_count = 0;
b0->current_length = bytes_to_copy;
if (offset == 0)
while (1)
{
vlib_buffer_init_for_free_list (b0, fl);
- b0->clone_count = 0;
b0->current_data = elt->current_data_hint;
b0->current_length = elt->length_this_buffer;
/*
* Make sure that intermediate "frees" don't screw up
*/
- b0->clone_count = vec_len (g0->members);
+ b0->recycle_count = vec_len (g0->members);
+ b0->flags |= VLIB_BUFFER_RECYCLE;
/* Set up for the recycle node */
vnet_buffer(b0)->mcast.mcast_current_index = 1;
vnet_buffer(b0)->mcast.mcast_group_index);
/* No more replicas? */
- if (b0->clone_count == 1)
+ if (b0->recycle_count == 1)
{
/* Restore the original free list index */
b0->free_list_index =
vnet_buffer(b0)->mcast.original_free_list_index;
+ b0->flags &= ~(VLIB_BUFFER_RECYCLE);
}
current_member0 = vnet_buffer(b0)->mcast.mcast_current_index;
ctx_id = ctx - rm->contexts[cpu_number];
// Save state from vlib buffer
- ctx->saved_clone_count = b0->clone_count;
ctx->saved_free_list_index = b0->free_list_index;
ctx->current_data = b0->current_data;
// Set up vlib buffer hooks
- b0->clone_count = ctx_id;
+ b0->recycle_count = ctx_id;
b0->free_list_index = rm->recycle_list_index;
+ b0->flags |= VLIB_BUFFER_RECYCLE;
// Save feature state
ctx->recycle_node_index = recycle_node_index;
ip4_header_t * ip;
// Get access to the replication context
- ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->clone_count);
+ ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
// Restore vnet buffer state
clib_memcpy (vnet_buffer(b0), ctx->vnet_buffer, sizeof(vnet_buffer_opaque_t));
if (is_last) {
// This is the last replication in the list.
// Restore original buffer free functionality.
- b0->clone_count = ctx->saved_clone_count;
b0->free_list_index = ctx->saved_free_list_index;
// Free context back to its pool
bi0 = fl->aligned_buffers[0];
b0 = vlib_get_buffer (vm, bi0);
ctx = pool_elt_at_index (rm->contexts[cpu_number],
- b0->clone_count);
+ b0->recycle_count);
feature_node_index = ctx->recycle_node_index;
} else if (vec_len (fl->unaligned_buffers) > 0) {
bi0 = fl->unaligned_buffers[0];
b0 = vlib_get_buffer (vm, bi0);
- ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->clone_count);
+ ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
feature_node_index = ctx->recycle_node_index;
}
u32 recycle_node_index; // feature's recycle node index
// data saved from the start of replication and restored at the end of replication
- u32 saved_clone_count; // from vlib buffer
u32 saved_free_list_index; // from vlib buffer
// data saved from the original packet and restored for each replica
replication_main_t * rm = &replication_main;
return replication_is_recycled (b0) ?
- pool_elt_at_index (rm->contexts[os_get_cpu_number()], b0->clone_count) :
+ pool_elt_at_index (rm->contexts[os_get_cpu_number()], b0->recycle_count) :
0;
}
vec_validate (tm->iovecs, tm->mtu_buffers - 1);
for (j = 0; j < tm->mtu_buffers; j++) {
b = vlib_get_buffer (vm, tm->rx_buffers[i_rx - j]);
- b->clone_count = 0;
tm->iovecs[j].iov_base = b->data;
tm->iovecs[j].iov_len = buffer_size;
}