FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
svm_fifo.h File Reference
+ Include dependency graph for svm_fifo.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  svm_fifo_seg_
 

Macros

#define OOO_SEGMENT_INVALID_INDEX   ((u32)~0)
 
#define SVM_FIFO_INVALID_SESSION_INDEX   ((u32)~0)
 
#define SVM_FIFO_INVALID_INDEX   ((u32)~0)
 
#define svm_fifo_trace_add(_f, _s, _l, _t)
 

Typedefs

typedef enum svm_fifo_deq_ntf_ svm_fifo_deq_ntf_t
 
typedef enum svm_fifo_flag_ svm_fifo_flag_t
 
typedef struct svm_fifo_seg_ svm_fifo_seg_t
 

Enumerations

enum  svm_fifo_deq_ntf_ { SVM_FIFO_NO_DEQ_NOTIF = 0, SVM_FIFO_WANT_DEQ_NOTIF = 1, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL = 2, SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY = 4 }
 
enum  svm_fifo_flag_ { SVM_FIFO_F_LL_TRACKED = 1 << 0 }
 
enum  svm_fifo_err_t { SVM_FIFO_EFULL = -2, SVM_FIFO_EEMPTY = -3, SVM_FIFO_EGROW = -4 }
 

Functions

u8svm_fifo_dump_trace (u8 *s, svm_fifo_t *f)
 
u8svm_fifo_replay (u8 *s, svm_fifo_t *f, u8 no_read, u8 verbose)
 
static void f_load_head_tail_cons (svm_fifo_t *f, u32 *head, u32 *tail)
 Load head and tail optimized for consumer. More...
 
static void f_load_head_tail_prod (svm_fifo_t *f, u32 *head, u32 *tail)
 Load head and tail optimized for producer. More...
 
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. More...
 
static u32 f_cursize (svm_fifo_t *f, u32 head, u32 tail)
 Fifo current size, i.e., number of bytes enqueued. More...
 
static u32 f_free_count (svm_fifo_t *f, u32 head, u32 tail)
 Fifo free bytes, i.e., number of free bytes. More...
 
static u32 f_chunk_end (svm_fifo_chunk_t *c)
 
static int f_pos_lt (u32 a, u32 b)
 
static int f_pos_leq (u32 a, u32 b)
 
static int f_pos_gt (u32 a, u32 b)
 
static int f_pos_geq (u32 a, u32 b)
 
static u8 f_chunk_includes_pos (svm_fifo_chunk_t *c, u32 pos)
 
static svm_fifo_chunk_tf_start_cptr (svm_fifo_t *f)
 
static svm_fifo_chunk_tf_end_cptr (svm_fifo_t *f)
 
static svm_fifo_chunk_tf_head_cptr (svm_fifo_t *f)
 
static svm_fifo_chunk_tf_tail_cptr (svm_fifo_t *f)
 
static svm_fifo_chunk_tf_cptr (svm_fifo_t *f, fs_sptr_t cp)
 
static fs_sptr_t f_csptr (svm_fifo_t *f, svm_fifo_chunk_t *c)
 
static void f_csptr_link (svm_fifo_t *f, fs_sptr_t cp, svm_fifo_chunk_t *c)
 
svm_fifo_tsvm_fifo_alloc (u32 size)
 Create fifo of requested size. More...
 
void svm_fifo_init (svm_fifo_t *f, u32 size)
 Initialize fifo. More...
 
svm_fifo_chunk_tsvm_fifo_chunk_alloc (u32 size)
 Allocate a fifo chunk on heap. More...
 
int svm_fifo_fill_chunk_list (svm_fifo_t *f)
 Ensure the whole fifo size is writeable. More...
 
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. More...
 
void svm_fifo_init_ooo_lookup (svm_fifo_t *f, u8 ooo_type)
 Initialize rbtrees used for ooo lookups. More...
 
void svm_fifo_free (svm_fifo_t *f)
 Free fifo and associated state. More...
 
void svm_fifo_free_chunk_lookup (svm_fifo_t *f)
 Cleanup fifo chunk lookup rb tree. More...
 
void svm_fifo_free_ooo_data (svm_fifo_t *f)
 Cleanup fifo ooo data. More...
 
void svm_fifo_init_pointers (svm_fifo_t *f, u32 head, u32 tail)
 Init fifo head and tail. More...
 
void svm_fifo_clone (svm_fifo_t *df, svm_fifo_t *sf)
 Clone fifo. More...
 
int svm_fifo_enqueue (svm_fifo_t *f, u32 len, const u8 *src)
 Enqueue data to fifo. More...
 
int svm_fifo_enqueue_with_offset (svm_fifo_t *f, u32 offset, u32 len, u8 *src)
 Enqueue data to fifo with offset. More...
 
void svm_fifo_enqueue_nocopy (svm_fifo_t *f, u32 len)
 Advance tail pointer. More...
 
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. More...
 
void svm_fifo_overwrite_head (svm_fifo_t *f, u8 *src, u32 len)
 Overwrite fifo head with new data. More...
 
int svm_fifo_dequeue (svm_fifo_t *f, u32 len, u8 *dst)
 Dequeue data from fifo. More...
 
int svm_fifo_peek (svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
 Peek data from fifo. More...
 
int svm_fifo_dequeue_drop (svm_fifo_t *f, u32 len)
 Dequeue and drop bytes from fifo. More...
 
void svm_fifo_dequeue_drop_all (svm_fifo_t *f)
 Dequeue and drop all bytes from fifo. More...
 
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. More...
 
void svm_fifo_add_subscriber (svm_fifo_t *f, u8 sub)
 Add io events subscriber to list. More...
 
void svm_fifo_del_subscriber (svm_fifo_t *f, u8 subscriber)
 Remove io events subscriber form list. More...
 
u32 svm_fifo_n_ooo_segments (svm_fifo_t *f)
 Number of out-of-order segments for fifo. More...
 
ooo_segment_tsvm_fifo_first_ooo_segment (svm_fifo_t *f)
 First out-of-order segment for fifo. More...
 
u8 svm_fifo_is_sane (svm_fifo_t *f)
 Check if fifo is sane. More...
 
u32 svm_fifo_n_chunks (svm_fifo_t *f)
 Number of chunks linked into the fifo. More...
 
static u32 svm_fifo_max_dequeue_cons (svm_fifo_t *f)
 Fifo max bytes to dequeue optimized for consumer. More...
 
static u32 svm_fifo_max_dequeue_prod (svm_fifo_t *f)
 Fifo max bytes to dequeue optimized for producer. More...
 
static u32 svm_fifo_max_dequeue (svm_fifo_t *f)
 Fifo max bytes to dequeue. More...
 
static int svm_fifo_is_full_prod (svm_fifo_t *f)
 Check if fifo is full optimized for producer. More...
 
static int svm_fifo_is_full (svm_fifo_t *f)
 
static int svm_fifo_is_empty_cons (svm_fifo_t *f)
 Check if fifo is empty optimized for consumer. More...
 
static int svm_fifo_is_empty_prod (svm_fifo_t *f)
 Check if fifo is empty optimized for producer. More...
 
static int svm_fifo_is_empty (svm_fifo_t *f)
 Check if fifo is empty. More...
 
static u8 svm_fifo_is_wrapped (svm_fifo_t *f)
 Check if fifo is wrapped. More...
 
static u32 svm_fifo_max_enqueue_prod (svm_fifo_t *f)
 Maximum number of bytes that can be enqueued into fifo. More...
 
static u32 svm_fifo_max_enqueue (svm_fifo_t *f)
 
u32 svm_fifo_max_read_chunk (svm_fifo_t *f)
 Max contiguous chunk of data that can be read. More...
 
u32 svm_fifo_max_write_chunk (svm_fifo_t *f)
 Max contiguous chunk of data that can be written. More...
 
static svm_fifo_chunk_tsvm_fifo_head_chunk (svm_fifo_t *f)
 Fifo head chunk getter. More...
 
static u8svm_fifo_head (svm_fifo_t *f)
 Fifo head pointer getter. More...
 
static svm_fifo_chunk_tsvm_fifo_tail_chunk (svm_fifo_t *f)
 Fifo tail chunk getter. More...
 
static u8svm_fifo_tail (svm_fifo_t *f)
 Fifo tail pointer getter. More...
 
static u8 svm_fifo_n_subscribers (svm_fifo_t *f)
 Fifo number of subscribers getter. More...
 
static u8 svm_fifo_has_ooo_data (svm_fifo_t *f)
 Check if fifo has out-of-order data. More...
 
static ooo_segment_tsvm_fifo_newest_ooo_segment (svm_fifo_t *f)
 
static void svm_fifo_newest_ooo_segment_reset (svm_fifo_t *f)
 
static u32 ooo_segment_offset_prod (svm_fifo_t *f, ooo_segment_t *s)
 
static u32 ooo_segment_length (svm_fifo_t *f, ooo_segment_t *s)
 
static u32 svm_fifo_size (svm_fifo_t *f)
 
static void svm_fifo_set_size (svm_fifo_t *f, u32 size)
 
static int svm_fifo_has_event (svm_fifo_t *f)
 Check if fifo has io event. More...
 
static u8 svm_fifo_set_event (svm_fifo_t *f)
 Set fifo event flag. More...
 
static void svm_fifo_unset_event (svm_fifo_t *f)
 Unset fifo event flag. More...
 
static void svm_fifo_add_want_deq_ntf (svm_fifo_t *f, u8 ntf_type)
 Set specific want notification flag. More...
 
static void svm_fifo_del_want_deq_ntf (svm_fifo_t *f, u8 ntf_type)
 Clear specific want notification flag. More...
 
static void svm_fifo_clear_deq_ntf (svm_fifo_t *f)
 Clear the want notification flag and set has notification. More...
 
static void svm_fifo_reset_has_deq_ntf (svm_fifo_t *f)
 Clear has notification flag. More...
 
static u8 svm_fifo_needs_deq_ntf (svm_fifo_t *f, u32 n_last_deq)
 Check if fifo needs dequeue notification. More...
 

Variables

format_function_t format_svm_fifo
 

Macro Definition Documentation

◆ OOO_SEGMENT_INVALID_INDEX

#define OOO_SEGMENT_INVALID_INDEX   ((u32)~0)

Definition at line 28 of file svm_fifo.h.

◆ SVM_FIFO_INVALID_INDEX

#define SVM_FIFO_INVALID_INDEX   ((u32)~0)

Definition at line 30 of file svm_fifo.h.

◆ SVM_FIFO_INVALID_SESSION_INDEX

#define SVM_FIFO_INVALID_SESSION_INDEX   ((u32)~0)

Definition at line 29 of file svm_fifo.h.

◆ svm_fifo_trace_add

#define svm_fifo_trace_add (   _f,
  _s,
  _l,
  _t 
)

Definition at line 68 of file svm_fifo.h.

Typedef Documentation

◆ svm_fifo_deq_ntf_t

◆ svm_fifo_flag_t

◆ svm_fifo_seg_t

typedef struct svm_fifo_seg_ svm_fifo_seg_t

Enumeration Type Documentation

◆ svm_fifo_deq_ntf_

Enumerator
SVM_FIFO_NO_DEQ_NOTIF 

No notification requested.

SVM_FIFO_WANT_DEQ_NOTIF 

Notify on dequeue.

SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL 

Notify on transition from full.

SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY 

Notify on transition to empty.

Definition at line 32 of file svm_fifo.h.

◆ svm_fifo_err_t

Enumerator
SVM_FIFO_EFULL 
SVM_FIFO_EEMPTY 
SVM_FIFO_EGROW 

Definition at line 45 of file svm_fifo.h.

◆ svm_fifo_flag_

Enumerator
SVM_FIFO_F_LL_TRACKED 

Definition at line 40 of file svm_fifo.h.

Function Documentation

◆ f_chunk_end()

static u32 f_chunk_end ( svm_fifo_chunk_t c)
inlinestatic

Definition at line 138 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_chunk_includes_pos()

static u8 f_chunk_includes_pos ( svm_fifo_chunk_t c,
u32  pos 
)
inlinestatic

Definition at line 168 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_cptr()

static svm_fifo_chunk_t* f_cptr ( svm_fifo_t f,
fs_sptr_t  cp 
)
inlinestatic

Definition at line 199 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_csptr()

static fs_sptr_t f_csptr ( svm_fifo_t f,
svm_fifo_chunk_t c 
)
inlinestatic

Definition at line 205 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_csptr_link()

static void f_csptr_link ( svm_fifo_t f,
fs_sptr_t  cp,
svm_fifo_chunk_t c 
)
inlinestatic

Definition at line 211 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_cursize()

static u32 f_cursize ( svm_fifo_t f,
u32  head,
u32  tail 
)
inlinestatic

Fifo current size, i.e., number of bytes enqueued.

Internal function.

Definition at line 121 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_end_cptr()

static svm_fifo_chunk_t* f_end_cptr ( svm_fifo_t f)
inlinestatic

Definition at line 181 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_free_count()

static u32 f_free_count ( svm_fifo_t f,
u32  head,
u32  tail 
)
inlinestatic

Fifo free bytes, i.e., number of free bytes.

Internal function

Definition at line 132 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_head_cptr()

static svm_fifo_chunk_t* f_head_cptr ( svm_fifo_t f)
inlinestatic

Definition at line 187 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_load_head_tail_all_acq()

static void f_load_head_tail_all_acq ( svm_fifo_t f,
u32 head,
u32 tail 
)
inlinestatic

Load head and tail independent of producer/consumer role.

Internal function.

Definition at line 107 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_load_head_tail_cons()

static void f_load_head_tail_cons ( svm_fifo_t f,
u32 head,
u32 tail 
)
inlinestatic

Load head and tail optimized for consumer.

Internal function.

Definition at line 80 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_load_head_tail_prod()

static void f_load_head_tail_prod ( svm_fifo_t f,
u32 head,
u32 tail 
)
inlinestatic

Load head and tail optimized for producer.

Internal function

Definition at line 93 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_pos_geq()

static int f_pos_geq ( u32  a,
u32  b 
)
inlinestatic

Definition at line 162 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_pos_gt()

static int f_pos_gt ( u32  a,
u32  b 
)
inlinestatic

Definition at line 156 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_pos_leq()

static int f_pos_leq ( u32  a,
u32  b 
)
inlinestatic

Definition at line 150 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_pos_lt()

static int f_pos_lt ( u32  a,
u32  b 
)
inlinestatic

Definition at line 144 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ f_start_cptr()

static svm_fifo_chunk_t* f_start_cptr ( svm_fifo_t f)
inlinestatic

Definition at line 175 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ f_tail_cptr()

static svm_fifo_chunk_t* f_tail_cptr ( svm_fifo_t f)
inlinestatic

Definition at line 193 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ooo_segment_length()

static u32 ooo_segment_length ( svm_fifo_t f,
ooo_segment_t s 
)
inlinestatic

Definition at line 748 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ ooo_segment_offset_prod()

static u32 ooo_segment_offset_prod ( svm_fifo_t f,
ooo_segment_t s 
)
inlinestatic

Definition at line 738 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_add_subscriber()

void svm_fifo_add_subscriber ( svm_fifo_t f,
u8  sub 
)

Add io events subscriber to list.

Parameters
ffifo
subsubscriber opaque index (typically app worker index)

Definition at line 1387 of file svm_fifo.c.

◆ svm_fifo_add_want_deq_ntf()

static void svm_fifo_add_want_deq_ntf ( svm_fifo_t f,
u8  ntf_type 
)
inlinestatic

Set specific want notification flag.

For list of flags see svm_fifo_deq_ntf_t

Parameters
ffifo
ntf_typetype of notification requested

Definition at line 817 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_alloc()

svm_fifo_t* svm_fifo_alloc ( u32  data_size_in_bytes)

Create fifo of requested size.

Allocates fifo on current heap.

Parameters
sizedata size in bytes for fifo to be allocated. Will be rounded to the next highest power-of-two value.
Returns
pointer to new fifo

Create fifo of requested size.

Fails vs blow up the process

Definition at line 426 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_chunk_alloc()

svm_fifo_chunk_t* svm_fifo_chunk_alloc ( u32  size)

Allocate a fifo chunk on heap.

If the chunk is allocated on a fifo segment, this should be called with the segment's heap pushed.

Parameters
sizechunk size in bytes. Will be rounded to the next highest power-of-two
Returns
new chunk or 0 if alloc failed

Allocate a fifo chunk on heap.

Definition at line 462 of file svm_fifo.c.

+ Here is the call graph for this function:

◆ svm_fifo_clear_deq_ntf()

static void svm_fifo_clear_deq_ntf ( svm_fifo_t f)
inlinestatic

Clear the want notification flag and set has notification.

Should be used after enqueuing an event. This clears the SVM_FIFO_WANT_NOTIF flag but it does not clear SVM_FIFO_WANT_NOTIF_IF_FULL. If the latter was set, has_ntf is set to avoid enqueueing events for for all dequeue operations until it is manually cleared.

Parameters
ffifo

Definition at line 848 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_clone()

void svm_fifo_clone ( svm_fifo_t df,
svm_fifo_t sf 
)

Clone fifo.

Clones single/default chunk fifo. It does not work for fifos with multiple chunks.

Clone fifo.

Assumptions:

  • no prod and cons are accessing either dest or src fifo
  • fifo is not multi chunk

Definition at line 1338 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_del_subscriber()

void svm_fifo_del_subscriber ( svm_fifo_t f,
u8  subscriber 
)

Remove io events subscriber form list.

Parameters
ffifo
subsubscriber index to be removed

Definition at line 1395 of file svm_fifo.c.

◆ svm_fifo_del_want_deq_ntf()

static void svm_fifo_del_want_deq_ntf ( svm_fifo_t f,
u8  ntf_type 
)
inlinestatic

Clear specific want notification flag.

For list of flags see svm_fifo_ntf_t

Parameters
ffifo
ntf_typetype of notification to be cleared

Definition at line 831 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_dequeue()

int svm_fifo_dequeue ( svm_fifo_t f,
u32  len,
u8 dst 
)

Dequeue data from fifo.

Data is dequeued to consumer provided buffer and head is atomically updated. This should not be used in combination with ooo lookups. If ooo peeking of data is needed in combination with dequeuing use svm_fifo_dequeue_drop.

Parameters
ffifo
lenlength of data to dequeue
dstbuffer to where to dequeue the data
Returns
number of bytes dequeued or error

Definition at line 1105 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_dequeue_drop()

int svm_fifo_dequeue_drop ( svm_fifo_t f,
u32  len 
)

Dequeue and drop bytes from fifo.

Advances fifo head by requested amount of bytes.

Parameters
ffifo
lennumber of bytes to drop
Returns
number of bytes dropped

Definition at line 1168 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_dequeue_drop_all()

void svm_fifo_dequeue_drop_all ( svm_fifo_t f)

Dequeue and drop all bytes from fifo.

Advances head to tail position.

Parameters
ffifo

Dequeue and drop all bytes from fifo.

Definition at line 1207 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_dump_trace()

u8* svm_fifo_dump_trace ( u8 s,
svm_fifo_t f 
)

Definition at line 1531 of file svm_fifo.c.

+ Here is the caller graph for this function:

◆ svm_fifo_enqueue()

int svm_fifo_enqueue ( svm_fifo_t f,
u32  len,
const u8 src 
)

Enqueue data to fifo.

Data is enqueued and tail pointer is updated atomically. If the new data enqueued partly overlaps or "touches" an out-of-order segment, said segment is "consumed" and the number of bytes returned is appropriately updated.

Parameters
ffifo
lenlength of data to copy
srcbuffer from where to copy the data
Returns
number of contiguous bytes that can be consumed or error

Definition at line 847 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_enqueue_nocopy()

void svm_fifo_enqueue_nocopy ( svm_fifo_t f,
u32  len 
)

Advance tail pointer.

Useful for moving tail pointer after external enqueue.

Parameters
ffifo
lennumber of bytes to add to tail

Advance tail pointer.

Definition at line 946 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_enqueue_segments()

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.

Parameters
ffifo
segsarray of segments to enqueue
n_segsnumber of segments
allow_partialif set partial enqueues are allowed
Returns
len if enqueue was successful, error otherwise

Definition at line 972 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_enqueue_with_offset()

int svm_fifo_enqueue_with_offset ( svm_fifo_t f,
u32  offset,
u32  len,
u8 src 
)

Enqueue data to fifo with offset.

Data is enqueued without updating tail pointer. Instead, an out-of-order list of segments is generated and maintained. Fifo takes care of coalescing contiguous or overlapping segments.

Parameters
ffifo
offsetoffset at which to copy the data
lenlen of data to copy
srcbuffer from where to copy the data
Returns
0 if enqueue was successful, error otherwise

Enqueue data to fifo with offset.

Two choices: either copies the entire segment, or copies nothing Returns 0 of the entire segment was copied Returns -1 if none of the segment was copied due to lack of space

Definition at line 906 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_fill_chunk_list()

int svm_fifo_fill_chunk_list ( svm_fifo_t f)

Ensure the whole fifo size is writeable.

Allocates enough chunks to cover the whole fifo size.

Parameters
ffifo

Definition at line 1228 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_first_ooo_segment()

ooo_segment_t* svm_fifo_first_ooo_segment ( svm_fifo_t f)

First out-of-order segment for fifo.

Parameters
ffifo
Returns
first out-of-order segment for fifo

Definition at line 1360 of file svm_fifo.c.

+ Here is the caller graph for this function:

◆ svm_fifo_free()

void svm_fifo_free ( svm_fifo_t f)

Free fifo and associated state.

Parameters
ffifo

Definition at line 768 of file svm_fifo.c.

+ Here is the call graph for this function:

◆ svm_fifo_free_chunk_lookup()

void svm_fifo_free_chunk_lookup ( svm_fifo_t f)

Cleanup fifo chunk lookup rb tree.

The rb tree is allocated in segment heap so this should be called with it pushed.

Parameters
ffifo to cleanup

Definition at line 761 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_free_ooo_data()

void svm_fifo_free_ooo_data ( svm_fifo_t f)

Cleanup fifo ooo data.

The ooo data is allocated in producer process memory. The fifo segment heap should not be pushed.

Parameters
ffifo to cleanup

Definition at line 115 of file svm_fifo.c.

+ Here is the caller graph for this function:

◆ svm_fifo_has_event()

static int svm_fifo_has_event ( svm_fifo_t f)
inlinestatic

Check if fifo has io event.

Parameters
ffifo
Returns
1 if fifo has event, 0 otherwise

Definition at line 776 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_has_ooo_data()

static u8 svm_fifo_has_ooo_data ( svm_fifo_t f)
inlinestatic

Check if fifo has out-of-order data.

Parameters
ffifo
Returns
1 if fifo has ooo data, 0 otherwise

Definition at line 718 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_head()

static u8* svm_fifo_head ( svm_fifo_t f)
inlinestatic

Fifo head pointer getter.

Parameters
ffifo
Returns
head pointer

Definition at line 661 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_head_chunk()

static svm_fifo_chunk_t* svm_fifo_head_chunk ( svm_fifo_t f)
inlinestatic

Fifo head chunk getter.

Parameters
ffifo
Returns
head chunk pointer

Definition at line 649 of file svm_fifo.h.

+ Here is the call graph for this function:

◆ svm_fifo_init()

void svm_fifo_init ( svm_fifo_t f,
u32  size 
)

Initialize fifo.

Parameters
ffifo
sizesize for fifo

Definition at line 372 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_init_ooo_lookup()

void svm_fifo_init_ooo_lookup ( svm_fifo_t f,
u8  ooo_type 
)

Initialize rbtrees used for ooo lookups.

Parameters
ffifo
ooo_typetype of ooo operation (0 enqueue, 1 dequeue)

Definition at line 408 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_init_pointers()

void svm_fifo_init_pointers ( svm_fifo_t f,
u32  head,
u32  tail 
)

Init fifo head and tail.

Parameters
ffifo
headhead value that will be matched to a chunk
tailtail value that will be matched to a chunk

Init fifo head and tail.

Definition at line 1369 of file svm_fifo.c.

+ Here is the call graph for this function:

◆ svm_fifo_is_empty()

static int svm_fifo_is_empty ( svm_fifo_t f)
inlinestatic

Check if fifo is empty.

Note: use producer or consumer specific functions for perfomance. svm_fifo_is_empty_cons (svm_fifo_t * f) svm_fifo_is_empty_prod (svm_fifo_t * f)

Definition at line 579 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_is_empty_cons()

static int svm_fifo_is_empty_cons ( svm_fifo_t f)
inlinestatic

Check if fifo is empty optimized for consumer.

Parameters
ffifo
Returns
1 if fifo is empty 0 otherwise

Definition at line 554 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_is_empty_prod()

static int svm_fifo_is_empty_prod ( svm_fifo_t f)
inlinestatic

Check if fifo is empty optimized for producer.

Parameters
ffifo
Returns
1 if fifo is empty 0 otherwise

Definition at line 566 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_is_full()

static int svm_fifo_is_full ( svm_fifo_t f)
inlinestatic

Definition at line 542 of file svm_fifo.h.

+ Here is the call graph for this function:

◆ svm_fifo_is_full_prod()

static int svm_fifo_is_full_prod ( svm_fifo_t f)
inlinestatic

Check if fifo is full optimized for producer.

Parameters
ffifo
Returns
1 if fifo is full 0 otherwise

Definition at line 530 of file svm_fifo.h.

+ Here is the call graph for this function:

◆ svm_fifo_is_sane()

u8 svm_fifo_is_sane ( svm_fifo_t f)

Check if fifo is sane.

Debug only.

Parameters
ffifo
Returns
1 if sane, 0 otherwise

Definition at line 1410 of file svm_fifo.c.

+ Here is the call graph for this function:

◆ svm_fifo_is_wrapped()

static u8 svm_fifo_is_wrapped ( svm_fifo_t f)
inlinestatic

Check if fifo is wrapped.

Parameters
ffifo
Returns
1 if 'normalized' head is ahead of tail

Definition at line 591 of file svm_fifo.h.

+ Here is the call graph for this function:

◆ svm_fifo_max_dequeue()

static u32 svm_fifo_max_dequeue ( svm_fifo_t f)
inlinestatic

Fifo max bytes to dequeue.

Note: use producer or consumer specific functions for performance: svm_fifo_max_dequeue_cons (svm_fifo_t *f) svm_fifo_max_dequeue_prod (svm_fifo_t *f)

Definition at line 516 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_dequeue_cons()

static u32 svm_fifo_max_dequeue_cons ( svm_fifo_t f)
inlinestatic

Fifo max bytes to dequeue optimized for consumer.

Parameters
ffifo
Returns
max number of bytes that can be dequeued

Definition at line 487 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_dequeue_prod()

static u32 svm_fifo_max_dequeue_prod ( svm_fifo_t f)
inlinestatic

Fifo max bytes to dequeue optimized for producer.

Parameters
ffifo
Returns
max number of bytes that can be dequeued

Definition at line 501 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_enqueue()

static u32 svm_fifo_max_enqueue ( svm_fifo_t f)
inlinestatic

Definition at line 621 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_enqueue_prod()

static u32 svm_fifo_max_enqueue_prod ( svm_fifo_t f)
inlinestatic

Maximum number of bytes that can be enqueued into fifo.

Optimized for producer

Parameters
ffifo
Returns
max number of bytes that can be enqueued into fifo

Definition at line 607 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_read_chunk()

u32 svm_fifo_max_read_chunk ( svm_fifo_t f)

Max contiguous chunk of data that can be read.

Should only be called by consumers.

Definition at line 514 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_max_write_chunk()

u32 svm_fifo_max_write_chunk ( svm_fifo_t f)

Max contiguous chunk of data that can be written.

Should only be called by producers

Definition at line 534 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_n_chunks()

u32 svm_fifo_n_chunks ( svm_fifo_t f)

Number of chunks linked into the fifo.

Parameters
ffifo
Returns
number of chunks in fifo linked list

Definition at line 1505 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_n_ooo_segments()

u32 svm_fifo_n_ooo_segments ( svm_fifo_t f)

Number of out-of-order segments for fifo.

Parameters
ffifo
Returns
number of out of order segments

Definition at line 1354 of file svm_fifo.c.

+ Here is the call graph for this function:

◆ svm_fifo_n_subscribers()

static u8 svm_fifo_n_subscribers ( svm_fifo_t f)
inlinestatic

Fifo number of subscribers getter.

Parameters
ffifo
Returns
number of subscribers

Definition at line 706 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_needs_deq_ntf()

static u8 svm_fifo_needs_deq_ntf ( svm_fifo_t f,
u32  n_last_deq 
)
inlinestatic

Check if fifo needs dequeue notification.

Determines based on notification request flags and state of the fifo if an event should be generated.

Parameters
ffifo
n_last_deqnumber of bytes last dequeued
Returns
1 if event should be generated, 0 otherwise

Definition at line 882 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_newest_ooo_segment()

static ooo_segment_t* svm_fifo_newest_ooo_segment ( svm_fifo_t f)
inlinestatic

Definition at line 724 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_newest_ooo_segment_reset()

static void svm_fifo_newest_ooo_segment_reset ( svm_fifo_t f)
inlinestatic

Definition at line 732 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_overwrite_head()

void svm_fifo_overwrite_head ( svm_fifo_t f,
u8 src,
u32  len 
)

Overwrite fifo head with new data.

This should be typically used by dgram transport protocols that need to update the dgram header after dequeuing a chunk of data. It assumes that the dgram header is at most spread over two chunks.

Parameters
ffifo
srcsrc of new data
lenlength of new data

Definition at line 781 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_peek()

int svm_fifo_peek ( svm_fifo_t f,
u32  offset,
u32  len,
u8 dst 
)

Peek data from fifo.

Data is copied from requested offset into provided dst buffer. Head is not updated.

Parameters
ffifo
offsetoffset from which to copy the data
lenlength of data to copy
dstbuffer to where to dequeue the data
Returns
number of bytes peeked

Definition at line 1141 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_provision_chunks()

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.

Allocates enough chunks to cover the bytes requested and returns them in the fifo segment array. The number of bytes provisioned may be less than requested if not enough segments were provided.

Parameters
ffifo
fsarray of fifo segments
n_segslength of fifo segments array
lennumber of bytes to preallocate
Returns
number of fifo segments provisioned or error

Definition at line 1244 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_replay()

u8* svm_fifo_replay ( u8 s,
svm_fifo_t f,
u8  no_read,
u8  verbose 
)

Definition at line 1555 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_reset_has_deq_ntf()

static void svm_fifo_reset_has_deq_ntf ( svm_fifo_t f)
inlinestatic

Clear has notification flag.

The fifo generates only one event per SVM_FIFO_WANT_NOTIF_IF_FULL request and sets has_ntf. To received new events the flag must be cleared using this function.

Parameters
ffifo

Definition at line 866 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_segments()

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.

Populates fifo segment array with pointers to fifo chunk data and lengths. Because this returns pointers to data, it must be paired with svm_fifo_dequeue_drop to actually release the fifo chunks after the data is consumed.

Parameters
ffifo
offsetoffset from where to retrieve segments
fsarray of fifo segments allocated by caller
n_segsnumber of fifo segments in array
max_bytesmax bytes to be mapped to fifo segments
Returns
number of bytes in fifo segments or SVM_FIFO_EEMPTY

Definition at line 1283 of file svm_fifo.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_set_event()

static u8 svm_fifo_set_event ( svm_fifo_t f)
inlinestatic

Set fifo event flag.

Forces release semantics.

Parameters
ffifo
Returns
1 if flag was not set, 0 otherwise

Definition at line 790 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_set_size()

static void svm_fifo_set_size ( svm_fifo_t f,
u32  size 
)
inlinestatic

Definition at line 760 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_size()

static u32 svm_fifo_size ( svm_fifo_t f)
inlinestatic

Definition at line 754 of file svm_fifo.h.

+ Here is the caller graph for this function:

◆ svm_fifo_tail()

static u8* svm_fifo_tail ( svm_fifo_t f)
inlinestatic

Fifo tail pointer getter.

Parameters
ffifo
Returns
tail pointer

Definition at line 690 of file svm_fifo.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ svm_fifo_tail_chunk()

static svm_fifo_chunk_t* svm_fifo_tail_chunk ( svm_fifo_t f)
inlinestatic

Fifo tail chunk getter.

Parameters
ffifo
Returns
tail chunk pointer

Definition at line 678 of file svm_fifo.h.

+ Here is the call graph for this function:

◆ svm_fifo_unset_event()

static void svm_fifo_unset_event ( svm_fifo_t f)
inlinestatic

Unset fifo event flag.

Forces acquire semantics

Parameters
ffifo

Definition at line 803 of file svm_fifo.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ format_svm_fifo

format_function_t format_svm_fifo

Definition at line 478 of file svm_fifo.h.