aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-12-09 12:51:13 -0800
committerDamjan Marion <dmarion@me.com>2020-12-26 16:58:10 +0000
commitaf588825ba4586fadbdb742953ca640e94cd59ef (patch)
treefc4e36bd9b9ef760247ec6e8ab41ba70f9e84152 /src/svm/svm_fifo.h
parent2c1084a69bccac812bf2d763b113d1e5b7f08686 (diff)
svm: change fifo pointers to offsets
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I113a630d6db4741f54e508f7e0ed77be139df0e4
Diffstat (limited to 'src/svm/svm_fifo.h')
-rw-r--r--src/svm/svm_fifo.h57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h
index 5845d7042af..f5b60807c28 100644
--- a/src/svm/svm_fifo.h
+++ b/src/svm/svm_fifo.h
@@ -171,6 +171,48 @@ f_chunk_includes_pos (svm_fifo_chunk_t * c, u32 pos)
&& 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 @@ u32 svm_fifo_max_write_chunk (svm_fifo_t * f);
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 @@ svm_fifo_head_chunk (svm_fifo_t * f)
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 @@ svm_fifo_head (svm_fifo_t * f)
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 @@ svm_fifo_tail_chunk (svm_fifo_t * f)
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));
}
/**