summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-02-06 14:22:32 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-02-06 18:00:17 +0000
commit5de3fec531691a81b3f77ed965488dc8dbf1e9a1 (patch)
tree57b8dde55804ab52a6ef40767f1fe705c1968d2a /src/vlib/buffer.c
parent672ab690182f3d4941d2640c68bb6ced38880bc3 (diff)
buffers: make buffer data size configurable from startup config
Example: buffers { default data-size 1536 } Change-Id: I5b4436850ca18025c9fdcfc7ed648c2c2732d660 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer.c')
-rw-r--r--src/vlib/buffer.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 345cd5c564b..a45b9bf2fc7 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -192,9 +192,9 @@ vlib_validate_buffer_helper (vlib_main_t * vm,
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 > VLIB_BUFFER_DATA_SIZE)
+ if (b->current_data + b->current_length > vlib_bufer_get_default_size (vm))
return format (0, "%d-%d beyond end of buffer %d", b->current_data,
- b->current_length, VLIB_BUFFER_DATA_SIZE);
+ b->current_length, vlib_bufer_get_default_size (vm));
if (follow_buffer_next && (b->flags & VLIB_BUFFER_NEXT_PRESENT))
{
@@ -407,7 +407,7 @@ vlib_buffer_add_data (vlib_main_t * vm, u32 * buffer_index, void *data,
d = data;
n_left = n_data_bytes;
- n_buffer_bytes = VLIB_BUFFER_DATA_SIZE;
+ n_buffer_bytes = vlib_bufer_get_default_size (vm);
b = vlib_get_buffer (vm, bi);
b->flags &= ~VLIB_BUFFER_TOTAL_LENGTH_VALID;
@@ -455,7 +455,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_DATA_SIZE;
+ u32 n_buffer_bytes = vlib_bufer_get_default_size (vm);
u16 copied = 0;
ASSERT (n_buffer_bytes >= l->current_length + l->current_data);
while (data_len)
@@ -655,7 +655,7 @@ vlib_buffer_main_init_numa_node (struct vlib_main_t *vm, u32 numa_node)
u32 buffers_per_numa;
u32 buffer_size = CLIB_CACHE_LINE_ROUND (bm->ext_hdr_size +
sizeof (vlib_buffer_t) +
- VLIB_BUFFER_DATA_SIZE);
+ vlib_bufer_get_default_size (vm));
u8 *name;
pagesize = clib_mem_get_default_hugepage_size ();
@@ -690,7 +690,21 @@ retry:
name = format (name, "default-numa-%d%c", numa_node, 0);
return vlib_buffer_pool_create (vm, numa_node, (char *) name,
- VLIB_BUFFER_DATA_SIZE, physmem_map_index);
+ vlib_bufer_get_default_size (vm),
+ physmem_map_index);
+}
+
+void
+vlib_buffer_main_alloc (vlib_main_t * vm)
+{
+ vlib_buffer_main_t *bm;
+
+ if (vm->buffer_main)
+ return;
+
+ vm->buffer_main = bm = clib_mem_alloc (sizeof (bm[0]));
+ clib_memset (vm->buffer_main, 0, sizeof (bm[0]));
+ bm->default_data_size = VLIB_BUFFER_DEFAULT_DATA_SIZE;
}
clib_error_t *
@@ -701,11 +715,7 @@ vlib_buffer_main_init (struct vlib_main_t *vm)
clib_bitmap_t *bmp = 0;
u32 numa_node;
- if (vm->buffer_main == 0)
- {
- vm->buffer_main = clib_mem_alloc (sizeof (bm[0]));
- clib_memset (vm->buffer_main, 0, sizeof (bm[0]));
- }
+ vlib_buffer_main_alloc (vm);
bm = vm->buffer_main;
bm->log_default = vlib_log_register_class ("buffer", 0);
@@ -741,11 +751,7 @@ vlib_buffers_configure (vlib_main_t * vm, unformat_input_t * input)
{
vlib_buffer_main_t *bm;
- if (vm->buffer_main == 0)
- {
- vm->buffer_main = clib_mem_alloc (sizeof (bm[0]));
- clib_memset (vm->buffer_main, 0, sizeof (bm[0]));
- }
+ vlib_buffer_main_alloc (vm);
bm = vm->buffer_main;
@@ -753,6 +759,9 @@ vlib_buffers_configure (vlib_main_t * vm, unformat_input_t * input)
{
if (unformat (input, "buffers-per-numa %u", &bm->buffers_per_numa))
;
+ else if (unformat (input, "default data-size %u",
+ &bm->default_data_size))
+ ;
else
return unformat_parse_error (input);
}