X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Fsvm_fifo.h;h=0b7c70790c036bcd1d4da9f405327acf34d2045c;hb=4d39f9c61c48d033ed5c9f729bdc975b58da29e8;hp=d5dfc9c4aa35f1c99508ec42e430a0104c53954c;hpb=eaacce4753c33342a6512039fe4153b15b476fb3;p=vpp.git diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h index d5dfc9c4aa3..0b7c70790c0 100644 --- a/src/svm/svm_fifo.h +++ b/src/svm/svm_fifo.h @@ -70,6 +70,7 @@ typedef enum svm_fifo_flag_ SVM_FIFO_F_SHRINK = 1 << 2, SVM_FIFO_F_COLLECT_CHUNKS = 1 << 3, SVM_FIFO_F_LL_TRACKED = 1 << 4, + SVM_FIFO_F_SINGLE_THREAD_OWNED = 1 << 5, } svm_fifo_flag_t; typedef struct _svm_fifo @@ -77,11 +78,12 @@ typedef struct _svm_fifo CLIB_CACHE_LINE_ALIGN_MARK (shared_first); u32 size; /**< size of the fifo in bytes */ u32 nitems; /**< usable size (size-1) */ - u8 flags; /**< fifo flags */ svm_fifo_chunk_t *start_chunk;/**< first chunk in fifo chunk list */ svm_fifo_chunk_t *end_chunk; /**< end chunk in fifo chunk list */ svm_fifo_chunk_t *new_chunks; /**< chunks yet to be added to list */ - rb_tree_t chunk_lookup; + rb_tree_t chunk_lookup; /**< rbtree for chunk lookup */ + u8 flags; /**< fifo flags */ + u8 slice_index; /**< segment slice for fifo */ CLIB_CACHE_LINE_ALIGN_MARK (shared_second); volatile u32 has_event; /**< non-zero if deq event exists */ @@ -477,6 +479,14 @@ ooo_segment_t *svm_fifo_first_ooo_segment (svm_fifo_t * f); * @return 1 if sane, 0 otherwise */ u8 svm_fifo_is_sane (svm_fifo_t * f); +/** + * Declare this fifo is used by only a single thread. + * In this special case, fifo-growth can be done in an efficient way without delay. + * + * @param f fifo + * @return 1 if the fifo is already owned by another thread, 0 otherwise + */ +u8 svm_fifo_set_single_thread_owned (svm_fifo_t * f); format_function_t format_svm_fifo; /** @@ -650,7 +660,7 @@ svm_fifo_max_write_chunk (svm_fifo_t * f) { u32 head, tail; f_load_head_tail_prod (f, &head, &tail); - return tail > head ? f->size - tail : f_free_count (f, head, tail); + return tail >= head ? f->size - tail : f_free_count (f, head, tail); } static inline u8 *