svm: change fifo pointers to offsets
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I113a630d6db4741f54e508f7e0ed77be139df0e4
diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h
index 5845d70..f5b6080 100644
--- a/src/svm/svm_fifo.h
+++ b/src/svm/svm_fifo.h
@@ -171,6 +171,48 @@
&& f_pos_lt (pos, c->start_byte + c->length));
}
+always_inline svm_fifo_chunk_t *
+f_start_cptr (svm_fifo_t *f)
+{
+ return fs_chunk_ptr (f->fs_hdr, f->shr->start_chunk);
+}
+
+always_inline svm_fifo_chunk_t *
+f_end_cptr (svm_fifo_t *f)
+{
+ return fs_chunk_ptr (f->fs_hdr, f->shr->end_chunk);
+}
+
+always_inline svm_fifo_chunk_t *
+f_head_cptr (svm_fifo_t *f)
+{
+ return fs_chunk_ptr (f->fs_hdr, f->shr->head_chunk);
+}
+
+always_inline svm_fifo_chunk_t *
+f_tail_cptr (svm_fifo_t *f)
+{
+ return fs_chunk_ptr (f->fs_hdr, f->shr->tail_chunk);
+}
+
+always_inline svm_fifo_chunk_t *
+f_cptr (svm_fifo_t *f, svm_fifo_chunk_ptr_t cp)
+{
+ return fs_chunk_ptr (f->fs_hdr, cp);
+}
+
+always_inline svm_fifo_chunk_ptr_t
+f_csptr (svm_fifo_t *f, svm_fifo_chunk_t *c)
+{
+ return fs_chunk_sptr (f->fs_hdr, c);
+}
+
+always_inline void
+f_csptr_link (svm_fifo_t *f, svm_fifo_chunk_ptr_t cp, svm_fifo_chunk_t *c)
+{
+ fs_chunk_ptr (f->fs_hdr, cp)->next = fs_chunk_sptr (f->fs_hdr, c);
+}
+
/**
* Create fifo of requested size
*
@@ -606,7 +648,7 @@
static inline svm_fifo_chunk_t *
svm_fifo_head_chunk (svm_fifo_t * f)
{
- return f->shr->head_chunk;
+ return f_head_cptr (f);
}
/**
@@ -618,11 +660,12 @@
static inline u8 *
svm_fifo_head (svm_fifo_t * f)
{
+ svm_fifo_chunk_t *head_chunk;
if (!f->shr->head_chunk)
return 0;
/* load-relaxed: consumer owned index */
- return (f->shr->head_chunk->data +
- (f->shr->head - f->shr->head_chunk->start_byte));
+ head_chunk = f_head_cptr (f);
+ return (head_chunk->data + (f->shr->head - head_chunk->start_byte));
}
/**
@@ -634,7 +677,7 @@
static inline svm_fifo_chunk_t *
svm_fifo_tail_chunk (svm_fifo_t * f)
{
- return f->shr->tail_chunk;
+ return f_tail_cptr (f);
}
/**
@@ -646,9 +689,11 @@
static inline u8 *
svm_fifo_tail (svm_fifo_t * f)
{
+ svm_fifo_chunk_t *tail_chunk;
+
/* load-relaxed: producer owned index */
- return (f->shr->tail_chunk->data +
- (f->shr->tail - f->shr->tail_chunk->start_byte));
+ tail_chunk = f_tail_cptr (f);
+ return (tail_chunk->data + (f->shr->tail - tail_chunk->start_byte));
}
/**