19 #ifndef __included_ssvm_fifo_h__ 20 #define __included_ssvm_fifo_h__ 28 #define OOO_SEGMENT_INVALID_INDEX ((u32)~0) 29 #define SVM_FIFO_INVALID_SESSION_INDEX ((u32)~0) 30 #define SVM_FIFO_INVALID_INDEX ((u32)~0) 59 #define svm_fifo_trace_add(_f, _s, _l, _t) \ 61 svm_fifo_trace_elem_t *trace_elt; \ 62 vec_add2(_f->trace, trace_elt, 1); \ 63 trace_elt->offset = _s; \ 64 trace_elt->len = _l; \ 65 trace_elt->action = _t; \ 68 #define svm_fifo_trace_add(_f, _s, _l, _t) 134 return (f->size -
f_cursize (f, head, tail));
146 return ((
i32) (a - b) < 0);
152 return ((
i32) (a - b) <= 0);
158 return ((
i32) (a - b) > 0);
164 return ((
i32) (a - b) >= 0);
304 u32 n_segs,
u8 allow_partial);
378 u32 n_segs,
u32 max_bytes);
594 return f->head_chunk;
609 return (f->head_chunk->data + (f->head - f->head_chunk->start_byte));
621 return f->tail_chunk;
634 return (f->tail_chunk->data + (f->tail - f->tail_chunk->start_byte));
646 return f->n_subscribers;
682 return (s->
start - tail);
700 if (size > (1 << f->fs_hdr->max_log2_chunk_size))
756 f->want_deq_ntf |= ntf_type;
770 f->want_deq_ntf &= ~ntf_type;
820 u8 want_ntf = f->want_deq_ntf;
830 if (!f->has_deq_ntf && max_deq < size && max_deq + n_last_deq >= size)
void svm_fifo_add_subscriber(svm_fifo_t *f, u8 sub)
Add io events subscriber to list.
u32 length
length of chunk in bytes
static void f_load_head_tail_all_acq(svm_fifo_t *f, u32 *head, u32 *tail)
Load head and tail independent of producer/consumer role.
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
void svm_fifo_clone(svm_fifo_t *df, svm_fifo_t *sf)
Clone fifo.
static void svm_fifo_set_size(svm_fifo_t *f, u32 size)
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 u32 svm_fifo_size(svm_fifo_t *f)
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Check if fifo has out-of-order data.
format_function_t format_svm_fifo
void svm_fifo_free_ooo_data(svm_fifo_t *f)
Cleanup fifo ooo data.
static u32 f_free_count(svm_fifo_t *f, u32 head, u32 tail)
Fifo free bytes, i.e., number of free bytes.
Fixed length block allocator.
static int svm_fifo_is_empty_prod(svm_fifo_t *f)
Check if fifo is empty optimized for producer.
static void f_load_head_tail_cons(svm_fifo_t *f, u32 *head, u32 *tail)
Load head and tail optimized for consumer.
static int svm_fifo_is_empty_cons(svm_fifo_t *f)
Check if fifo is empty optimized for consumer.
static void svm_fifo_reset_has_deq_ntf(svm_fifo_t *f)
Clear has notification flag.
u32 svm_fifo_max_read_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be read.
void fsh_virtual_mem_update(fifo_segment_header_t *fsh, u32 slice_index, int n_bytes)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
static u8 * svm_fifo_tail(svm_fifo_t *f)
Fifo tail pointer getter.
static int svm_fifo_is_empty(svm_fifo_t *f)
Check if fifo is empty.
static svm_fifo_chunk_t * svm_fifo_head_chunk(svm_fifo_t *f)
Fifo head chunk getter.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
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_fill_chunk_list(svm_fifo_t *f)
Ensure the whole fifo size is writeable.
struct svm_fifo_seg_ svm_fifo_seg_t
static u8 * svm_fifo_head(svm_fifo_t *f)
Fifo head pointer getter.
void svm_fifo_init_ooo_lookup(svm_fifo_t *f, u8 ooo_type)
Initialize rbtrees used for ooo lookups.
static int svm_fifo_is_full_prod(svm_fifo_t *f)
Check if fifo is full optimized for producer.
static void svm_fifo_newest_ooo_segment_reset(svm_fifo_t *f)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
u8 svm_fifo_is_sane(svm_fifo_t *f)
Check if fifo is sane.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static int f_pos_gt(u32 a, u32 b)
void svm_fifo_dequeue_drop_all(svm_fifo_t *f)
Dequeue and drop all bytes from fifo.
u32 svm_fifo_n_ooo_segments(svm_fifo_t *f)
Number of out-of-order segments for fifo.
static u32 f_chunk_end(svm_fifo_chunk_t *c)
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
static u32 svm_fifo_max_dequeue_prod(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for producer.
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
svm_fifo_chunk_t * svm_fifo_chunk_alloc(u32 size)
Allocate a fifo chunk on heap.
static u8 svm_fifo_needs_deq_ntf(svm_fifo_t *f, u32 n_last_deq)
Check if fifo needs dequeue notification.
static u32 f_cursize(svm_fifo_t *f, u32 head, u32 tail)
Fifo current size, i.e., number of bytes enqueued.
int svm_fifo_dequeue(svm_fifo_t *f, u32 len, u8 *dst)
Dequeue data from fifo.
void svm_fifo_overwrite_head(svm_fifo_t *f, u8 *src, u32 len)
Overwrite fifo head with new data.
static void f_load_head_tail_prod(svm_fifo_t *f, u32 *head, u32 *tail)
Load head and tail optimized for producer.
u32 start_byte
chunk start byte
#define OOO_SEGMENT_INVALID_INDEX
svm_fifo_t * svm_fifo_alloc(u32 size)
Create fifo of requested size.
static u8 f_chunk_includes_pos(svm_fifo_chunk_t *c, u32 pos)
u32 svm_fifo_max_write_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be written.
void svm_fifo_free_chunk_lookup(svm_fifo_t *f)
Cleanup fifo chunk lookup rb tree.
#define clib_atomic_swap_acq_n(a, b)
static int f_pos_geq(u32 a, u32 b)
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Notify on transition to empty.
void svm_fifo_free(svm_fifo_t *f)
Free fifo and associated state.
int svm_fifo_enqueue_segments(svm_fifo_t *f, const svm_fifo_seg_t segs[], u32 n_segs, u8 allow_partial)
Enqueue array of svm_fifo_seg_t in order.
static void svm_fifo_clear_deq_ntf(svm_fifo_t *f)
Clear the want notification flag and set has notification.
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
u32 svm_fifo_n_chunks(svm_fifo_t *f)
Number of chunks linked into the fifo.
static u8 svm_fifo_is_wrapped(svm_fifo_t *f)
Check if fifo is wrapped.
Notify on transition from full.
u32 length
Length of segment.
void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 len)
Advance tail pointer.
void svm_fifo_init(svm_fifo_t *f, u32 size)
Initialize fifo.
static int f_pos_leq(u32 a, u32 b)
template key/value backing page structure
#define clib_atomic_swap_rel_n(a, b)
enum svm_fifo_deq_ntf_ svm_fifo_deq_ntf_t
No notification requested.
enum svm_fifo_flag_ svm_fifo_flag_t
static void svm_fifo_del_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Clear specific want notification flag.
int svm_fifo_segments(svm_fifo_t *f, u32 offset, svm_fifo_seg_t *fs, u32 n_segs, u32 max_bytes)
Get pointers to fifo chunks data in svm_fifo_seg_t array.
static u32 ooo_segment_offset_prod(svm_fifo_t *f, ooo_segment_t *s)
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
Fifo number of subscribers getter.
void svm_fifo_init_pointers(svm_fifo_t *f, u32 head, u32 tail)
Init fifo head and tail.
static int svm_fifo_has_event(svm_fifo_t *f)
Check if fifo has io event.
#define clib_atomic_load_acq_n(a)
void svm_fifo_del_subscriber(svm_fifo_t *f, u8 subscriber)
Remove io events subscriber form list.
struct _svm_fifo svm_fifo_t
int svm_fifo_enqueue_with_offset(svm_fifo_t *f, u32 offset, u32 len, u8 *src)
Enqueue data to fifo with offset.
u32 start
Start of segment, normalized.
ooo_segment_t * svm_fifo_first_ooo_segment(svm_fifo_t *f)
First out-of-order segment for fifo.
static svm_fifo_chunk_t * svm_fifo_tail_chunk(svm_fifo_t *f)
Fifo tail chunk getter.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static int f_pos_lt(u32 a, u32 b)