summaryrefslogtreecommitdiffstats
path: root/src/plugins/unittest/svm_fifo_test.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-05-02 12:52:19 -0700
committerDave Barach <openvpp@barachs.net>2019-05-03 14:34:46 +0000
commit29a59c3ae18573043d9f9baa2796ab0b841bf6aa (patch)
treee14b3f88d6ec06d9d6c54ca740fe81a9a99ef703 /src/plugins/unittest/svm_fifo_test.c
parent14e2e2a5715ddf938db5b3884e268ec09e112935 (diff)
svm: store normalized head/tail for fifo
If head/tail are stored as "absolute" values that are normalized to [0, fifo_size] interval, when fifo is shrunk/grown the consumer and producer have to independently update to the new fifo size and fix head and tail, respectively. If the head and tail are stored as normalized values, under the right conditions, they don't need to be fixed when fifo size changes. This reverts one of the changes in gerrit 18223. Change-Id: I55a908828afe90925cf7c20186a940b25e5805f9 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins/unittest/svm_fifo_test.c')
-rw-r--r--src/plugins/unittest/svm_fifo_test.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/unittest/svm_fifo_test.c b/src/plugins/unittest/svm_fifo_test.c
index 99f0e5044d6..d2afc36e0d0 100644
--- a/src/plugins/unittest/svm_fifo_test.c
+++ b/src/plugins/unittest/svm_fifo_test.c
@@ -806,7 +806,7 @@ sfifo_test_fifo4 (vlib_main_t * vm, unformat_input_t * input)
static u32
fifo_pos (svm_fifo_t * f, u32 pos)
{
- return pos;
+ return pos % f->size;
}
/* Avoids exposing svm_fifo.c internal function */
@@ -1194,6 +1194,7 @@ sfifo_test_fifo_grow (vlib_main_t * vm, unformat_input_t * input)
svm_fifo_chunk_t *c, *next, *prev;
u8 *test_data = 0, *data_buf = 0;
svm_fifo_t *f;
+ u32 old_tail;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -1288,10 +1289,14 @@ sfifo_test_fifo_grow (vlib_main_t * vm, unformat_input_t * input)
SFIFO_TEST (f->size == fifo_size + 200, "size expected %u is %u",
fifo_size + 200, f->size);
- svm_fifo_dequeue (f, 201, data_buf);
+ old_tail = f->tail;
+ svm_fifo_dequeue (f, 101, data_buf);
SFIFO_TEST (f->size == fifo_size + 200 + 10 * 100, "size expected %u is %u",
fifo_size + 200 + 10 * 100, f->size);
+ SFIFO_TEST (f->tail == old_tail, "new tail expected %u is %u", old_tail,
+ f->tail);
+
/*
* Enqueue/dequeue tests
*/