summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-03-07 13:21:04 +0100
committerDave Barach <openvpp@barachs.net>2018-03-07 14:01:40 +0000
commitef2e584543619e037d735e61f0576658c6764ae6 (patch)
tree598c866d4702a330d70b7a9307f0a0a7a7f53b12 /src/vnet
parent8f89dd01289ea9e97405432d2351a19c842dd6d5 (diff)
packet-generator: use default free list
Change-Id: I2a34546f9b32edc9bfb86b5492dde34aaef49ccc Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/pg/input.c52
-rw-r--r--src/vnet/pg/stream.c19
2 files changed, 8 insertions, 63 deletions
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index f31152c3889..1cbffedd480 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -1178,25 +1178,6 @@ init_buffers_inline (vlib_main_t * vm,
}
}
-static void
-pg_buffer_init (vlib_main_t * vm,
- vlib_buffer_free_list_t * fl, u32 * buffers, u32 n_buffers)
-{
- pg_main_t *pg = &pg_main;
- pg_stream_t *s;
- uword bi, si;
-
- si = fl->buffer_init_function_opaque & pow2_mask (24);
- bi = fl->buffer_init_function_opaque >> 24;
-
- s = pool_elt_at_index (pg->streams, si);
-
- init_buffers_inline (vm, s, buffers, n_buffers,
- /* data_offset */ bi * s->buffer_bytes,
- /* n_data */ s->buffer_bytes,
- /* set_data */ 1);
-}
-
static u32
pg_stream_fill_helper (pg_main_t * pg,
pg_stream_t * s,
@@ -1204,26 +1185,9 @@ pg_stream_fill_helper (pg_main_t * pg,
u32 * buffers, u32 * next_buffers, u32 n_alloc)
{
vlib_main_t *vm = vlib_get_main ();
- vlib_buffer_free_list_t *f;
uword is_start_of_packet = bi == s->buffer_indices;
u32 n_allocated;
- f = vlib_buffer_get_free_list (vm, bi->free_list_index);
-
- /*
- * Historically, the pg maintained its own free lists and
- * device drivers tx paths would return pkts.
- */
- if (vm->buffer_main->callbacks_registered == 0 &&
- !(s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE))
- f->buffer_init_function = pg_buffer_init;
- f->buffer_init_function_opaque =
- (s - pg->streams) | ((bi - s->buffer_indices) << 24);
-
- if (is_start_of_packet)
- vnet_buffer (&f->buffer_init_template)->sw_if_index[VLIB_RX]
- = vnet_main.local_interface_sw_if_index;
-
n_allocated = vlib_buffer_alloc_from_free_list (vm,
buffers,
n_alloc,
@@ -1238,16 +1202,12 @@ pg_stream_fill_helper (pg_main_t * pg,
n_alloc = n_allocated;
/* Reinitialize buffers */
- if (vm->buffer_main->callbacks_registered == 0 || CLIB_DEBUG > 0
- || (s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE))
- init_buffers_inline
- (vm, s,
- buffers,
- n_alloc, (bi - s->buffer_indices) * s->buffer_bytes /* data offset */ ,
- s->buffer_bytes,
- /* set_data */
- vm->buffer_main->callbacks_registered != 0
- || (s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE) != 0);
+ init_buffers_inline
+ (vm, s,
+ buffers,
+ n_alloc, (bi - s->buffer_indices) * s->buffer_bytes /* data offset */ ,
+ s->buffer_bytes,
+ /* set_data */ 1);
if (next_buffers)
pg_set_next_buffer_pointers (pg, s, buffers, next_buffers, n_alloc);
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index 762f241d001..2837d800421 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -438,27 +438,14 @@ pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
pg_buffer_index_t *bi;
int n;
- if (vm->buffer_main->callbacks_registered)
- s->buffer_bytes = VLIB_BUFFER_DATA_SIZE;
-
- if (!s->buffer_bytes)
- s->buffer_bytes = s->max_packet_bytes;
-
- s->buffer_bytes = vlib_buffer_round_size (s->buffer_bytes);
-
+ s->buffer_bytes = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES;
n = s->max_packet_bytes / s->buffer_bytes;
n += (s->max_packet_bytes % s->buffer_bytes) != 0;
vec_resize (s->buffer_indices, n);
vec_foreach (bi, s->buffer_indices)
- {
- bi->free_list_index =
- vlib_buffer_create_free_list (vm, s->buffer_bytes,
- "pg stream %d buffer #%d",
- s - pg->streams,
- 1 + (bi - s->buffer_indices));
- }
+ bi->free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX;
}
/* Find an interface to use. */
@@ -483,7 +470,6 @@ pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
void
pg_stream_del (pg_main_t * pg, uword index)
{
- vlib_main_t *vm = vlib_get_main ();
pg_stream_t *s;
pg_buffer_index_t *bi;
@@ -494,7 +480,6 @@ pg_stream_del (pg_main_t * pg, uword index)
vec_foreach (bi, s->buffer_indices)
{
- vlib_buffer_delete_free_list (vm, bi->free_list_index);
clib_fifo_free (bi->buffer_fifo);
}