aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-20 02:24:53 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-01-20 21:01:03 +0000
commit3235382f23074e7f5b413b862f8cfed37142dbcd (patch)
tree13bd34d93a9334314469134addd5a57dd14d792c /src
parentb67196d8233ee89e79e0e6b05c3fa95a5fb6a579 (diff)
buffers: remove VLIB_BUFFER_DEFAULT_FREE_LIST macro and fl->n_data_bytes
Change-Id: I0ba5175be077c40556f2a3ce629c5bbcd71e0a81 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/avf/device.c2
-rw-r--r--src/plugins/marvell/pp2/pp2.c2
-rw-r--r--src/vlib/buffer.c27
-rw-r--r--src/vlib/buffer.h4
-rw-r--r--src/vlib/buffer_funcs.h36
-rw-r--r--src/vlib/main.c3
-rw-r--r--src/vlib/unix/mc_socket.c8
7 files changed, 19 insertions, 63 deletions
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index 38af1cbcf8b..ff893056de9 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -590,7 +590,7 @@ avf_op_config_vsi_queues (vlib_main_t * vm, avf_device_t * ad)
{
avf_rxq_t *q = vec_elt_at_index (ad->rxqs, i);
rxq->ring_len = q->size;
- rxq->databuffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES;
+ rxq->databuffer_size = VLIB_BUFFER_DATA_SIZE;
rxq->dma_ring_addr = avf_dma_addr (vm, ad, (void *) q->descs);
avf_reg_write (ad, AVF_QRX_TAIL (i), q->size - 1);
}
diff --git a/src/plugins/marvell/pp2/pp2.c b/src/plugins/marvell/pp2/pp2.c
index 016ad53cc96..ec35a0d92b7 100644
--- a/src/plugins/marvell/pp2/pp2.c
+++ b/src/plugins/marvell/pp2/pp2.c
@@ -244,7 +244,7 @@ mrvl_pp2_create_if (mrvl_pp2_create_if_args_t * args)
/* FIXME bpool bit select per pp */
s = format (s, "pool-%d:%d%c", pp2_id, pp2_id + 8, 0);
bpool_params.match = (char *) s;
- bpool_params.buff_len = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES;
+ bpool_params.buff_len = VLIB_BUFFER_DATA_SIZE;
/* FIXME +64 ? */
if (pp2_bpool_init (&bpool_params, &ppif->inqs[0].bpool))
{
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 9459551a0fc..643f2c50342 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -178,17 +178,13 @@ vlib_validate_buffer_helper (vlib_main_t * vm,
uword follow_buffer_next, uword ** unique_hash)
{
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
- vlib_buffer_free_list_t *fl;
-
- 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);
- if (b->current_data + b->current_length > fl->n_data_bytes)
+ if (b->current_data + b->current_length > VLIB_BUFFER_DATA_SIZE)
return format (0, "%d-%d beyond end of buffer %d",
- b->current_data, b->current_length, fl->n_data_bytes);
+ b->current_data, b->current_length, VLIB_BUFFER_DATA_SIZE);
if (follow_buffer_next && (b->flags & VLIB_BUFFER_NEXT_PRESENT))
{
@@ -362,7 +358,7 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
default_free_free_list_index =
vlib_buffer_create_free_list_helper
(vm,
- /* default buffer size */ VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES,
+ /* default buffer size */ VLIB_BUFFER_DATA_SIZE,
/* is_public */ 1,
/* is_default */ 1,
(u8 *) "default");
@@ -370,7 +366,7 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
ASSERT (default_free_free_list_index ==
VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
- if (n_data_bytes == VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES && is_public)
+ if (n_data_bytes == VLIB_BUFFER_DATA_SIZE && is_public)
return default_free_free_list_index;
}
@@ -380,7 +376,6 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
f->index = f - vm->buffer_free_list_pool;
vec_validate (f->buffers, 0);
vec_reset_length (f->buffers);
- f->n_data_bytes = vlib_buffer_round_size (n_data_bytes);
f->min_n_buffers_each_alloc = VLIB_FRAME_SIZE;
f->buffer_pool_index = 0;
f->name = clib_mem_is_vec (name) ? name : format (0, "%s", name);
@@ -390,9 +385,9 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
if (is_public)
{
- uword *p = hash_get (bm->free_list_by_size, f->n_data_bytes);
+ uword *p = hash_get (bm->free_list_by_size, VLIB_BUFFER_DATA_SIZE);
if (!p)
- hash_set (bm->free_list_by_size, f->n_data_bytes, f->index);
+ hash_set (bm->free_list_by_size, VLIB_BUFFER_DATA_SIZE, f->index);
}
for (i = 1; i < vec_len (vlib_mains); i++)
@@ -718,8 +713,7 @@ vlib_buffer_chain_append_data_with_alloc (vlib_main_t * vm,
u16 data_len)
{
vlib_buffer_t *l = *last;
- u32 n_buffer_bytes =
- vlib_buffer_free_list_buffer_size (vm, free_list_index);
+ u32 n_buffer_bytes = VLIB_BUFFER_DATA_SIZE;
u16 copied = 0;
ASSERT (n_buffer_bytes >= l->current_length + l->current_data);
while (data_len)
@@ -800,13 +794,13 @@ format_vlib_buffer_free_list (u8 * s, va_list * va)
"Thread", "Name", "Index", "Size", "Alloc", "Free",
"#Alloc", "#Free");
- size = sizeof (vlib_buffer_t) + f->n_data_bytes;
+ size = sizeof (vlib_buffer_t) + VLIB_BUFFER_DATA_SIZE;
n_free = vec_len (f->buffers);
bytes_alloc = size * f->n_alloc;
bytes_free = size * n_free;
s = format (s, "%7d%30v%12d%12d%=12U%=12U%=12d%=12d", threadnum,
- f->name, f->index, f->n_data_bytes,
+ f->name, f->index, VLIB_BUFFER_DATA_SIZE,
format_memory_size, bytes_alloc,
format_memory_size, bytes_free, f->n_alloc, n_free);
@@ -900,8 +894,7 @@ retry:
pool_index = vlib_buffer_register_physmem_map (vm, physmem_map_index);
vlib_buffer_pool_t *bp = vlib_buffer_pool_get (vm, pool_index);
clib_spinlock_init (&bp->lock);
- bp->buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES +
- sizeof (vlib_buffer_t);
+ bp->buffer_size = VLIB_BUFFER_DATA_SIZE + sizeof (vlib_buffer_t);
return 0;
}
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index af9df685376..505a5839a18 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -367,9 +367,6 @@ typedef struct vlib_buffer_free_list_t
/* Our index into vlib_main_t's buffer_free_list_pool. */
vlib_buffer_free_list_index_t index;
- /* Number of data bytes for buffers in this free list. */
- u32 n_data_bytes;
-
/* Number of buffers to allocate when we need to allocate new buffers */
u32 min_n_buffers_each_alloc;
@@ -437,7 +434,6 @@ typedef struct
u32 * buffers,
u32 n_buffers, u32 follow_buffer_next);
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX (0)
-#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES VLIB_BUFFER_DATA_SIZE
/* Hash table mapping buffer size (rounded to next unit of
sizeof (vlib_buffer_t)) to free list index. */
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index db1d9611005..60eb8cde09a 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -614,28 +614,6 @@ vlib_buffer_free_list_index_t vlib_buffer_create_free_list (vlib_main_t * vm,
u32 n_data_bytes,
char *fmt, ...);
-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)
-{
- vlib_buffer_free_list_t *f;
-
- f = pool_elt_at_index (vm->buffer_free_list_pool, free_list_index);
-
- /* Sanity: indices must match. */
- ASSERT (f->index == free_list_index);
-
- return f;
-}
-
-always_inline u32
-vlib_buffer_free_list_buffer_size (vlib_main_t * vm,
- vlib_buffer_free_list_index_t index)
-{
- vlib_buffer_free_list_t *f = vlib_buffer_get_free_list (vm, index);
- return f->n_data_bytes;
-}
-
/* Append given data to end of buffer, possibly allocating new buffers. */
int vlib_buffer_add_data (vlib_main_t * vm, u32 * buffer_index, void *data,
u32 n_data_bytes);
@@ -886,8 +864,7 @@ vlib_buffer_chain_append_data (vlib_main_t * vm,
vlib_buffer_t * first,
vlib_buffer_t * last, void *data, u16 data_len)
{
- u32 n_buffer_bytes =
- vlib_buffer_free_list_buffer_size (vm, free_list_index);
+ u32 n_buffer_bytes = VLIB_BUFFER_DATA_SIZE;
ASSERT (n_buffer_bytes >= last->current_length + last->current_data);
u16 len = clib_min (data_len,
n_buffer_bytes - last->current_length -
@@ -1073,14 +1050,9 @@ vlib_buffer_chain_compress (vlib_main_t * vm,
/* this is already big enough or not a chain */
return;
}
- /* probe free list to find allocated buffer size to avoid overfill */
- 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 -
+ VLIB_BUFFER_DATA_SIZE -
first->current_data);
do
{
@@ -1127,9 +1099,7 @@ always_inline int
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_DEFAULT_FREE_LIST_INDEX);
- u32 buf_len = fl->n_data_bytes;
+ u32 buf_len = VLIB_BUFFER_DATA_SIZE;
// free buffer chain starting from the second buffer
int free_count = (b->flags & VLIB_BUFFER_NEXT_PRESENT) != 0;
u32 chain_to_free = b->next_buffer;
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 160050486c5..afdf2e42c69 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1990,8 +1990,7 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
/* Create default buffer free list. */
- vlib_buffer_create_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES,
- "default");
+ vlib_buffer_create_free_list (vm, VLIB_BUFFER_DATA_SIZE, "default");
nm->timing_wheel = clib_mem_alloc_aligned (sizeof (TWT (tw_timer_wheel)),
CLIB_CACHE_LINE_BYTES);
diff --git a/src/vlib/unix/mc_socket.c b/src/vlib/unix/mc_socket.c
index c820981dae0..aaf73ae5e1e 100644
--- a/src/vlib/unix/mc_socket.c
+++ b/src/vlib/unix/mc_socket.c
@@ -165,7 +165,7 @@ recvmsg_helper (mc_socket_main_t * msm,
vlib_main_t *vm = msm->mc_main.vlib_main;
vlib_buffer_t *b;
uword n_left, n_alloc, n_mtu, i, i_rx;
- const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES;
+ const uword buffer_size = VLIB_BUFFER_DATA_SIZE;
word n_bytes_left;
/* Make sure we have at least a MTU worth of buffers. */
@@ -1011,10 +1011,8 @@ mc_socket_main_init (mc_socket_main_t * msm, char **intfc_probe_list,
}
msm->rx_mtu_n_bytes = mtu;
- msm->rx_mtu_n_buffers =
- msm->rx_mtu_n_bytes / VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES;
- msm->rx_mtu_n_buffers +=
- (msm->rx_mtu_n_bytes % VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES) != 0;
+ msm->rx_mtu_n_buffers = msm->rx_mtu_n_bytes / VLIB_BUFFER_DATA_SIZE;
+ msm->rx_mtu_n_buffers += (msm->rx_mtu_n_bytes % VLIB_BUFFER_DATA_SIZE) != 0;
error = socket_setup (msm);
if (error)