15 #ifndef __included_ssvm_fifo_h__ 16 #define __included_ssvm_fifo_h__ 39 #define SVM_FIFO_TRACE (0) 40 #define OOO_SEGMENT_INVALID_INDEX ((u32)~0) 41 #define SVM_FIFO_INVALID_SESSION_INDEX ((u32)~0) 42 #define SVM_FIFO_INVALID_INDEX ((u32)~0) 43 #define SVM_FIFO_MAX_EVT_SUBSCRIBERS 8 59 typedef struct _svm_fifo
66 volatile u32 has_event;
68 u32 master_session_index;
69 u32 client_session_index;
70 u8 master_thread_index;
71 u8 client_thread_index;
80 volatile u32 want_tx_ntf;
81 volatile u32 has_tx_ntf;
89 struct _svm_fifo *next;
90 struct _svm_fifo *prev;
91 volatile u8 n_subscribers;
113 #define svm_fifo_trace_add(_f, _s, _l, _t) \ 115 svm_fifo_trace_elem_t *trace_elt; \ 116 vec_add2(_f->trace, trace_elt, 1); \ 117 trace_elt->offset = _s; \ 118 trace_elt->len = _l; \ 119 trace_elt->action = _t; \ 122 #define svm_fifo_trace_add(_f, _s, _l, _t) 194 const u8 * copy_from_here);
196 u32 required_bytes,
u8 * copy_from_here);
216 return ((f->tail > f->head) ? (f->tail - f->head) : (f->nitems - f->head));
225 return ((f->tail >= f->head) ? (f->nitems - f->tail) : (f->head - f->tail));
237 f->tail = (f->tail + bytes) % f->nitems;
244 return (f->data + f->head);
250 return (f->data + f->tail);
262 f->want_tx_ntf |= ntf_type;
268 f->want_tx_ntf &= ~ntf_type;
288 u8 want_ntf = f->want_tx_ntf;
298 if (!f->has_tx_ntf && max_deq < nitems
299 && max_deq + n_last_deq >= nitems)
310 return f->n_subscribers;
337 return (((f->nitems + pos) - f->tail) % f->nitems);
343 return (((f->nitems + f->tail) - pos) % f->nitems);
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 max_bytes)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
format_function_t format_ooo_segment
static int svm_fifo_is_full(svm_fifo_t *f)
u8 * svm_fifo_replay(u8 *s, svm_fifo_t *f, u8 no_read, u8 verbose)
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
format_function_t format_svm_fifo
Fixed length block allocator.
u32 prev
Previous linked-list element pool index.
void svm_fifo_segments_free(svm_fifo_t *f, svm_fifo_segment_t *fs)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
svm_fifo_t * svm_fifo_create(u32 data_size_in_bytes)
create an svm fifo, in the current heap.
static void svm_fifo_add_want_tx_ntf(svm_fifo_t *f, u8 ntf_type)
static u8 * svm_fifo_tail(svm_fifo_t *f)
static u32 ooo_segment_distance_from_tail(svm_fifo_t *f, u32 pos)
struct _svm_fifo svm_fifo_t
static void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 bytes)
Advance tail pointer.
static int svm_fifo_is_empty(svm_fifo_t *f)
static u32 ooo_segment_end_offset(svm_fifo_t *f, ooo_segment_t *s)
void svm_fifo_add_subscriber(svm_fifo_t *f, u8 subscriber)
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
static u32 svm_fifo_max_write_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be written.
static u32 ooo_segment_length(svm_fifo_t *f, ooo_segment_t *s)
u8 * svm_fifo_dump_trace(u8 *s, svm_fifo_t *f)
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
static u8 * svm_fifo_head(svm_fifo_t *f)
static u32 svm_fifo_nitems(svm_fifo_t *f)
static u32 svm_fifo_max_read_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be read.
static void svm_fifo_newest_ooo_segment_reset(svm_fifo_t *f)
static u8 svm_fifo_needs_tx_ntf(svm_fifo_t *f, u32 n_last_deq)
void svm_fifo_overwrite_head(svm_fifo_t *f, u8 *data, u32 len)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void svm_fifo_dequeue_drop_all(svm_fifo_t *f)
static void svm_fifo_clear_tx_ntf(svm_fifo_t *f)
static u32 ooo_segment_offset(svm_fifo_t *f, ooo_segment_t *s)
static ooo_segment_t * ooo_segment_next(svm_fifo_t *f, ooo_segment_t *s)
static void svm_fifo_unset_event(svm_fifo_t *f)
Unsets fifo event flag.
#define clib_atomic_fetch_add_rel(a, b)
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
static void svm_fifo_del_want_tx_ntf(svm_fifo_t *f, u8 ntf_type)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
struct svm_fifo_segment_ svm_fifo_segment_t
#define SVM_FIFO_MAX_EVT_SUBSCRIBERS
format_function_t format_ooo_list
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, const u8 *copy_from_here)
static ooo_segment_t * ooo_segment_get_prev(svm_fifo_t *f, ooo_segment_t *s)
#define OOO_SEGMENT_INVALID_INDEX
void svm_fifo_init_pointers(svm_fifo_t *f, u32 pointer)
Set fifo pointers to requested offset.
int svm_fifo_segments(svm_fifo_t *f, svm_fifo_segment_t *fs)
#define clib_atomic_swap_acq_n(a, b)
void svm_fifo_free(svm_fifo_t *f)
u32 length
Length of segment.
u32 next
Next linked-list element pool index.
template key/value backing page structure
#define clib_atomic_swap_rel_n(a, b)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 max_bytes, u8 *copy_here)
static void svm_fifo_reset_tx_ntf(svm_fifo_t *f)
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
u32 svm_fifo_number_ooo_segments(svm_fifo_t *f)
static int svm_fifo_has_event(svm_fifo_t *f)
#define clib_atomic_load_acq_n(a)
void svm_fifo_del_subscriber(svm_fifo_t *f, u8 subscriber)
u32 start
Start of segment, normalized.
ooo_segment_t * svm_fifo_first_ooo_segment(svm_fifo_t *f)
int svm_fifo_enqueue_with_offset(svm_fifo_t *f, u32 offset, u32 required_bytes, u8 *copy_from_here)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static u32 ooo_segment_distance_to_tail(svm_fifo_t *f, u32 pos)