aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
diff options
context:
space:
mode:
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;
}