From af588825ba4586fadbdb742953ca640e94cd59ef Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 9 Dec 2020 12:51:13 -0800 Subject: svm: change fifo pointers to offsets Type: improvement Signed-off-by: Florin Coras Change-Id: I113a630d6db4741f54e508f7e0ed77be139df0e4 --- src/svm/svm_fifo.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'src/svm/svm_fifo.h') 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)); } /** -- cgit 1.2.3-korg