summaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-18 18:58:10 -0700
committerDave Barach <openvpp@barachs.net>2019-04-19 15:15:39 +0000
commit2309e7a481f64e9dee21c43da4e48974cfee1156 (patch)
tree801a827d3c455f92da9f682090ebce9970f03c85 /src/svm/svm_fifo.c
parent3b62e29c3adc8e4114cb10dc794f4b3f814015b0 (diff)
svm: support addition of chunks to fifos
Change-Id: Ia56cad89b85b7a99ab4bfb85318a45a71381fb53 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/svm_fifo.c')
-rw-r--r--src/svm/svm_fifo.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index de1997452d5..41cd752914a 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -216,11 +216,10 @@ svm_fifo_init (svm_fifo_t * f, u32 size)
f->ct_session_index = SVM_FIFO_INVALID_SESSION_INDEX;
f->segment_index = SVM_FIFO_INVALID_INDEX;
f->refcnt = 1;
- f->head_chunk = &f->default_chunk;
- f->tail_chunk = &f->default_chunk;
- f->default_chunk.next = &f->default_chunk;
f->default_chunk.start_byte = 0;
f->default_chunk.length = f->size;
+ f->default_chunk.next = f->start_chunk = &f->default_chunk;
+ f->end_chunk = f->head_chunk = f->tail_chunk = f->start_chunk;
}
/** create an svm fifo, in the current heap. Fails vs blow up the process */
@@ -650,6 +649,7 @@ CLIB_MARCH_FN (svm_fifo_dequeue_nowait, int, svm_fifo_t * f, u32 len,
return -2; /* nothing in the fifo */
to_copy = len = clib_min (cursize, len);
+ ASSERT (cursize >= to_copy);
c = f->head_chunk;
head_idx = head % f->size;
@@ -673,7 +673,9 @@ CLIB_MARCH_FN (svm_fifo_dequeue_nowait, int, svm_fifo_t * f, u32 len,
}
head += len;
- ASSERT (cursize >= to_copy);
+ if (PREDICT_FALSE (f->flags & SVM_FIFO_F_SIZE_UPDATE))
+ svm_fifo_try_size_update (f, head);
+
/* store-rel: consumer owned index (paired with load-acq in producer) */
clib_atomic_store_rel_n (&f->head, head);