|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
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)
140 return c->start_byte +
c->length;
146 return ((
i32) (
a -
b) < 0);
152 return ((
i32) (
a -
b) <= 0);
158 return ((
i32) (
a -
b) > 0);
164 return ((
i32) (
a -
b) >= 0);
171 &&
f_pos_lt (pos,
c->start_byte +
c->length));
361 u32 n_segs,
u8 allow_partial);
435 u32 n_segs,
u32 max_bytes);
664 if (!
f->shr->head_chunk)
708 return f->shr->n_subscribers;
744 return (s->
start - tail);
762 if (
size > (1 <<
f->fs_hdr->max_log2_fifo_size))
765 (
int)
f->shr->size -
size);
778 return f->shr->has_event;
819 f->shr->want_deq_ntf |= ntf_type;
833 f->shr->want_deq_ntf &= ~ntf_type;
851 f->shr->has_deq_ntf =
868 f->shr->has_deq_ntf = 0;
884 u8 want_ntf =
f->shr->want_deq_ntf;
894 if (!
f->shr->has_deq_ntf && max_deq <
size &&
895 max_deq + n_last_deq >=
size)
static int svm_fifo_is_full_prod(svm_fifo_t *f)
Check if fifo is full optimized for producer.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
static svm_fifo_chunk_t * svm_fifo_tail_chunk(svm_fifo_t *f)
Fifo tail chunk getter.
static void f_load_head_tail_prod(svm_fifo_t *f, u32 *head, u32 *tail)
Load head and tail optimized for producer.
static u32 svm_fifo_size(svm_fifo_t *f)
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
@ SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL
Notify on transition from full.
static u8 svm_fifo_n_subscribers(svm_fifo_t *f)
Fifo number of subscribers getter.
void svm_fifo_free(svm_fifo_t *f)
Free fifo and associated state.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static fs_sptr_t fs_chunk_sptr(fifo_segment_header_t *fsh, svm_fifo_chunk_t *c)
static u8 svm_fifo_needs_deq_ntf(svm_fifo_t *f, u32 n_last_deq)
Check if fifo needs dequeue notification.
int svm_fifo_enqueue_with_offset(svm_fifo_t *f, u32 offset, u32 len, u8 *src)
Enqueue data to fifo with offset.
u32 start_byte
chunk start byte
static svm_fifo_chunk_t * f_tail_cptr(svm_fifo_t *f)
void svm_fifo_overwrite_head(svm_fifo_t *f, u8 *src, u32 len)
Overwrite fifo head with new data.
static int f_pos_lt(u32 a, u32 b)
svm_fifo_t * svm_fifo_alloc(u32 size)
Create fifo of requested size.
enum svm_fifo_flag_ svm_fifo_flag_t
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_prod(svm_fifo_t *f)
Check if fifo is empty optimized for producer.
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.
int svm_fifo_fill_chunk_list(svm_fifo_t *f)
Ensure the whole fifo size is writeable.
void svm_fifo_free_ooo_data(svm_fifo_t *f)
Cleanup fifo ooo data.
u32 length
Length of segment.
int svm_fifo_provision_chunks(svm_fifo_t *f, svm_fifo_seg_t *fs, u32 n_segs, u32 len)
Provision and return chunks for number of bytes requested.
struct _svm_fifo svm_fifo_t
u32 svm_fifo_n_chunks(svm_fifo_t *f)
Number of chunks linked into the fifo.
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Check if fifo has out-of-order data.
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.
enum svm_fifo_deq_ntf_ svm_fifo_deq_ntf_t
void fsh_virtual_mem_update(fifo_segment_header_t *fsh, u32 slice_index, int n_bytes)
void svm_fifo_dequeue_drop_all(svm_fifo_t *f)
Dequeue and drop all bytes from fifo.
@ SVM_FIFO_WANT_DEQ_NOTIF
Notify on dequeue.
static void svm_fifo_clear_deq_ntf(svm_fifo_t *f)
Clear the want notification flag and set has notification.
static int svm_fifo_is_empty_cons(svm_fifo_t *f)
Check if fifo is empty optimized for consumer.
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
u32 start
Start of segment, normalized.
u8 svm_fifo_is_sane(svm_fifo_t *f)
Check if fifo is sane.
void svm_fifo_init_ooo_lookup(svm_fifo_t *f, u8 ooo_type)
Initialize rbtrees used for ooo lookups.
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
int svm_fifo_dequeue(svm_fifo_t *f, u32 len, u8 *dst)
Dequeue data from fifo.
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
u32 svm_fifo_max_write_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be written.
static u32 ooo_segment_offset_prod(svm_fifo_t *f, ooo_segment_t *s)
u8 * svm_fifo_replay(u8 *s, svm_fifo_t *f, u8 no_read, u8 verbose)
static int f_pos_gt(u32 a, u32 b)
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
static int svm_fifo_is_full(svm_fifo_t *f)
static svm_fifo_chunk_t * f_end_cptr(svm_fifo_t *f)
#define OOO_SEGMENT_INVALID_INDEX
static u32 svm_fifo_max_dequeue_prod(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for producer.
#define clib_atomic_swap_acq_n(a, b)
static svm_fifo_chunk_t * svm_fifo_head_chunk(svm_fifo_t *f)
Fifo head chunk getter.
fs_sptr_t next
pointer to next chunk in linked-lists
u8 * svm_fifo_dump_trace(u8 *s, svm_fifo_t *f)
static int f_pos_geq(u32 a, u32 b)
u32 svm_fifo_n_ooo_segments(svm_fifo_t *f)
Number of out-of-order segments for fifo.
static u32 ooo_segment_length(svm_fifo_t *f, ooo_segment_t *s)
static svm_fifo_chunk_t * f_cptr(svm_fifo_t *f, fs_sptr_t cp)
template key/value backing page structure
static int f_pos_leq(u32 a, u32 b)
static svm_fifo_chunk_t * f_start_cptr(svm_fifo_t *f)
static u8 * svm_fifo_tail(svm_fifo_t *f)
Fifo tail pointer getter.
void svm_fifo_add_subscriber(svm_fifo_t *f, u8 sub)
Add io events subscriber to list.
u8 data[0]
start of chunk data
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.
@ SVM_FIFO_NO_DEQ_NOTIF
No notification requested.
static void svm_fifo_set_size(svm_fifo_t *f, u32 size)
svm_fifo_chunk_t * svm_fifo_chunk_alloc(u32 size)
Allocate a fifo chunk on heap.
@ SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY
Notify on transition to empty.
static svm_fifo_chunk_t * f_head_cptr(svm_fifo_t *f)
void svm_fifo_init(svm_fifo_t *f, u32 size)
Initialize fifo.
#define clib_atomic_swap_rel_n(a, b)
void svm_fifo_init_pointers(svm_fifo_t *f, u32 head, u32 tail)
Init fifo head and tail.
ooo_segment_t * svm_fifo_first_ooo_segment(svm_fifo_t *f)
First out-of-order segment for fifo.
static u8 svm_fifo_is_wrapped(svm_fifo_t *f)
Check if fifo is wrapped.
u32 svm_fifo_max_read_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be read.
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.
static svm_fifo_chunk_t * fs_chunk_ptr(fifo_segment_header_t *fsh, fs_sptr_t cp)
static u32 f_cursize(svm_fifo_t *f, u32 head, u32 tail)
Fifo current size, i.e., number of bytes enqueued.
void svm_fifo_del_subscriber(svm_fifo_t *f, u8 subscriber)
Remove io events subscriber form list.
static void f_csptr_link(svm_fifo_t *f, fs_sptr_t cp, svm_fifo_chunk_t *c)
static u32 f_chunk_end(svm_fifo_chunk_t *c)
void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 len)
Advance tail pointer.
void svm_fifo_free_chunk_lookup(svm_fifo_t *f)
Cleanup fifo chunk lookup rb tree.
struct svm_fifo_seg_ svm_fifo_seg_t
static void svm_fifo_reset_has_deq_ntf(svm_fifo_t *f)
Clear has notification flag.
static u8 * svm_fifo_head(svm_fifo_t *f)
Fifo head pointer getter.
#define clib_atomic_load_acq_n(a)
static u8 f_chunk_includes_pos(svm_fifo_chunk_t *c, u32 pos)
format_function_t format_svm_fifo
static u32 f_free_count(svm_fifo_t *f, u32 head, u32 tail)
Fifo free bytes, i.e., number of free bytes.
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
static int svm_fifo_is_empty(svm_fifo_t *f)
Check if fifo is empty.
static void svm_fifo_del_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Clear specific want notification flag.
static int svm_fifo_has_event(svm_fifo_t *f)
Check if fifo has io event.
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
static fs_sptr_t f_csptr(svm_fifo_t *f, svm_fifo_chunk_t *c)
static void svm_fifo_newest_ooo_segment_reset(svm_fifo_t *f)