summaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-05-05 13:19:57 -0700
committerDave Barach <openvpp@barachs.net>2019-05-07 20:33:44 +0000
commitcefd5d8806b9db7210192f53fdc2b8a60d4dc271 (patch)
tree60d10021e940d58d40ddbdfd03bd5dc82aacf085 /src/svm/svm_fifo.c
parent749a89c3179d86a791ec779b6c2006e4649883f6 (diff)
svm: decouple fifo and default chunk allocation
Default chunk is no longer embedded into the fifo and on free is returned to its respective chunk list. Change-Id: Ifc5d214eaa6eca44356eb79dd75650fb8569113f Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/svm_fifo.c')
-rw-r--r--src/svm/svm_fifo.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index 3824d998866..6b4ea68ca17 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -400,9 +400,7 @@ svm_fifo_init (svm_fifo_t * f, u32 size)
f->ooos_list_head = OOO_SEGMENT_INVALID_INDEX;
f->segment_index = SVM_FIFO_INVALID_INDEX;
f->refcnt = 1;
- f->default_chunk.start_byte = 0;
- f->default_chunk.length = f->size;
- f->default_chunk.next = f->start_chunk = f->end_chunk = &f->default_chunk;
+ f->flags = 0;
f->head_chunk = f->tail_chunk = f->ooo_enq = f->ooo_deq = f->start_chunk;
}
@@ -412,17 +410,31 @@ svm_fifo_init (svm_fifo_t * f, u32 size)
svm_fifo_t *
svm_fifo_create (u32 data_size_in_bytes)
{
- svm_fifo_t *f;
u32 rounded_data_size;
+ svm_fifo_chunk_t *c;
+ svm_fifo_t *f;
- /* always round fifo data size to the next highest power-of-two */
- rounded_data_size = (1 << (max_log2 (data_size_in_bytes)));
- f = clib_mem_alloc_aligned_or_null (sizeof (*f) + rounded_data_size,
- CLIB_CACHE_LINE_BYTES);
+ f = clib_mem_alloc_aligned_or_null (sizeof (*f), CLIB_CACHE_LINE_BYTES);
if (f == 0)
return 0;
clib_memset (f, 0, sizeof (*f));
+
+ /* always round fifo data size to the next highest power-of-two */
+ rounded_data_size = (1 << (max_log2 (data_size_in_bytes)));
+ c = clib_mem_alloc_aligned_or_null (sizeof (*c) + rounded_data_size,
+ CLIB_CACHE_LINE_BYTES);
+ if (!c)
+ {
+ clib_mem_free (f);
+ return 0;
+ }
+
+ c->next = c;
+ c->start_byte = 0;
+ c->length = data_size_in_bytes;
+ f->start_chunk = f->end_chunk = c;
+
svm_fifo_init (f, data_size_in_bytes);
return f;
}