From 0a846806742922d98f1aff9cf1370715e57a2ae5 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 9 Apr 2019 18:29:14 -0700 Subject: svm: allow indirect fifo data chunks Fifos can use multiple memory chunks for simple read/write operations. Adding/removing chunks after assignment not yet supported. Change-Id: I2aceab6aea78059d74e0d3a9993c40d5196d077b Signed-off-by: Florin Coras --- src/svm/svm_fifo.h | 25 +++++++++++++++++++------ 1 file changed, 19 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 94a05938d26..f311576f5af 100644 --- a/src/svm/svm_fifo.h +++ b/src/svm/svm_fifo.h @@ -60,11 +60,21 @@ typedef struct u32 action; } svm_fifo_trace_elem_t; +typedef struct svm_fifo_chunk_ +{ + u32 start_byte; + u32 length; + struct svm_fifo_chunk_ *next; + u8 data[0]; +} svm_fifo_chunk_t; + typedef struct _svm_fifo { CLIB_CACHE_LINE_ALIGN_MARK (shared_first); - u32 size; /**< size of the fifo(must be power of 2) */ + u32 size; /**< size of the fifo */ u32 nitems; /**< usable size(size-1) */ + struct _svm_fifo *next; /**< next in freelist/active chain */ + struct _svm_fifo *prev; /**< prev in active chain */ CLIB_CACHE_LINE_ALIGN_MARK (shared_second); volatile u32 has_event; /**< non-zero if deq event exists */ @@ -81,17 +91,17 @@ typedef struct _svm_fifo CLIB_CACHE_LINE_ALIGN_MARK (consumer); u32 head; + svm_fifo_chunk_t *head_chunk; volatile u32 want_tx_ntf; /**< producer wants nudge */ volatile u32 has_tx_ntf; CLIB_CACHE_LINE_ALIGN_MARK (producer); u32 tail; + svm_fifo_chunk_t *tail_chunk; ooo_segment_t *ooo_segments; /**< Pool of ooo segments */ u32 ooos_list_head; /**< Head of out-of-order linked-list */ u32 ooos_newest; /**< Last segment to have been updated */ - struct _svm_fifo *next; /**< next in freelist/active chain */ - struct _svm_fifo *prev; /**< prev in active chain */ volatile u8 n_subscribers; u8 subscribers[SVM_FIFO_MAX_EVT_SUBSCRIBERS]; @@ -99,7 +109,7 @@ typedef struct _svm_fifo svm_fifo_trace_elem_t *trace; #endif - CLIB_CACHE_LINE_ALIGN_MARK (data); + svm_fifo_chunk_t default_chunk; } svm_fifo_t; typedef enum @@ -305,6 +315,7 @@ svm_fifo_unset_event (svm_fifo_t * f) } svm_fifo_t *svm_fifo_create (u32 data_size_in_bytes); +void svm_fifo_init (svm_fifo_t * f, u32 size); void svm_fifo_free (svm_fifo_t * f); int svm_fifo_enqueue_nowait (svm_fifo_t * f, u32 max_bytes, @@ -373,14 +384,16 @@ always_inline u8 * svm_fifo_head (svm_fifo_t * f) { /* load-relaxed: consumer owned index */ - return (f->data + (f->head % f->size)); + return (f->head_chunk->data + + ((f->head % f->size) - f->head_chunk->start_byte)); } always_inline u8 * svm_fifo_tail (svm_fifo_t * f) { /* load-relaxed: producer owned index */ - return (f->data + (f->tail % f->size)); + return (f->tail_chunk->data + + ((f->tail % f->size) - f->tail_chunk->start_byte)); } static inline void -- cgit 1.2.3-korg