FD.io VPP
v20.05.1-6-gf53edbc3b
Vector Packet Processing
|
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 | |
u8 * | svm_fifo_dump_trace (u8 *s, svm_fifo_t *f) |
u8 * | svm_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) |
svm_fifo_t * | svm_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_t * | svm_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... | |
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... | |
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, svm_fifo_seg_t *fs) |
void | svm_fifo_segments_free (svm_fifo_t *f, svm_fifo_seg_t *fs) |
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_t * | svm_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_t * | svm_fifo_head_chunk (svm_fifo_t *f) |
Fifo head chunk getter. More... | |
static u8 * | svm_fifo_head (svm_fifo_t *f) |
Fifo head pointer getter. More... | |
static svm_fifo_chunk_t * | svm_fifo_tail_chunk (svm_fifo_t *f) |
Fifo tail chunk getter. More... | |
static u8 * | svm_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_t * | svm_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 |
#define OOO_SEGMENT_INVALID_INDEX ((u32)~0) |
Definition at line 28 of file svm_fifo.h.
#define SVM_FIFO_INVALID_INDEX ((u32)~0) |
Definition at line 30 of file svm_fifo.h.
#define SVM_FIFO_INVALID_SESSION_INDEX ((u32)~0) |
Definition at line 29 of file svm_fifo.h.
#define svm_fifo_trace_add | ( | _f, | |
_s, | |||
_l, | |||
_t | |||
) |
Definition at line 68 of file svm_fifo.h.
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 |
enum svm_fifo_deq_ntf_ |
Definition at line 32 of file svm_fifo.h.
enum svm_fifo_err_t |
Enumerator | |
---|---|
SVM_FIFO_EFULL | |
SVM_FIFO_EEMPTY | |
SVM_FIFO_EGROW |
Definition at line 45 of file svm_fifo.h.
enum svm_fifo_flag_ |
Enumerator | |
---|---|
SVM_FIFO_F_LL_TRACKED |
Definition at line 40 of file svm_fifo.h.
|
inlinestatic |
|
inlinestatic |
Definition at line 168 of file svm_fifo.h.
|
inlinestatic |
Fifo current size, i.e., number of bytes enqueued.
Internal function.
Definition at line 121 of file svm_fifo.h.
|
inlinestatic |
Fifo free bytes, i.e., number of free bytes.
Internal function
Definition at line 132 of file svm_fifo.h.
|
inlinestatic |
Load head and tail independent of producer/consumer role.
Internal function.
Definition at line 107 of file svm_fifo.h.
|
inlinestatic |
Load head and tail optimized for consumer.
Internal function.
Definition at line 80 of file svm_fifo.h.
|
inlinestatic |
Load head and tail optimized for producer.
Internal function
Definition at line 93 of file svm_fifo.h.
|
inlinestatic |
|
inlinestatic |
void svm_fifo_add_subscriber | ( | svm_fifo_t * | f, |
u8 | sub | ||
) |
Add io events subscriber to list.
f | fifo |
sub | subscriber opaque index (typically app worker index) |
Definition at line 1234 of file svm_fifo.c.
|
inlinestatic |
Set specific want notification flag.
For list of flags see svm_fifo_deq_ntf_t
f | fifo |
ntf_type | type of notification requested |
Definition at line 726 of file svm_fifo.h.
svm_fifo_t* svm_fifo_alloc | ( | u32 | data_size_in_bytes | ) |
Create fifo of requested size.
Allocates fifo on current heap.
size | data size in bytes for fifo to be allocated. Will be rounded to the next highest power-of-two value. |
Create fifo of requested size.
Fails vs blow up the process
Definition at line 419 of file svm_fifo.c.
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.
size | chunk size in bytes. Will be rounded to the next highest power-of-two |
Allocate a fifo chunk on heap.
Definition at line 455 of file svm_fifo.c.
|
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.
f | fifo |
Definition at line 757 of file svm_fifo.h.
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:
Definition at line 1188 of file svm_fifo.c.
void svm_fifo_del_subscriber | ( | svm_fifo_t * | f, |
u8 | subscriber | ||
) |
Remove io events subscriber form list.
f | fifo |
sub | subscriber index to be removed |
Definition at line 1242 of file svm_fifo.c.
|
inlinestatic |
Clear specific want notification flag.
For list of flags see svm_fifo_ntf_t
f | fifo |
ntf_type | type of notification to be cleared |
Definition at line 740 of file svm_fifo.h.
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.
f | fifo |
len | length of data to dequeue |
dst | buffer to where to dequeue the data |
Definition at line 1007 of file svm_fifo.c.
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.
f | fifo |
len | number of bytes to drop |
Definition at line 1061 of file svm_fifo.c.
void svm_fifo_dequeue_drop_all | ( | svm_fifo_t * | f | ) |
Dequeue and drop all bytes from fifo.
Advances head to tail position.
f | fifo |
Dequeue and drop all bytes from fifo.
Definition at line 1099 of file svm_fifo.c.
u8* svm_fifo_dump_trace | ( | u8 * | s, |
svm_fifo_t * | f | ||
) |
Definition at line 1376 of file svm_fifo.c.
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.
f | fifo |
len | length of data to copy |
src | buffer from where to copy the data |
Definition at line 836 of file svm_fifo.c.
void svm_fifo_enqueue_nocopy | ( | svm_fifo_t * | f, |
u32 | len | ||
) |
Advance tail pointer.
Useful for moving tail pointer after external enqueue.
f | fifo |
len | number of bytes to add to tail |
Advance tail pointer.
Definition at line 931 of file svm_fifo.c.
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.
f | fifo |
offset | offset at which to copy the data |
len | len of data to copy |
src | buffer from where to copy the data |
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 894 of file svm_fifo.c.
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.
f | fifo |
Definition at line 1119 of file svm_fifo.c.
ooo_segment_t* svm_fifo_first_ooo_segment | ( | svm_fifo_t * | f | ) |
First out-of-order segment for fifo.
f | fifo |
Definition at line 1209 of file svm_fifo.c.
void svm_fifo_free | ( | svm_fifo_t * | f | ) |
Free fifo and associated state.
f | fifo |
Definition at line 758 of file svm_fifo.c.
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.
f | fifo to cleanup |
Definition at line 751 of file svm_fifo.c.
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.
f | fifo to cleanup |
Definition at line 111 of file svm_fifo.c.
|
inlinestatic |
Check if fifo has io event.
f | fifo |
Definition at line 685 of file svm_fifo.h.
|
inlinestatic |
Check if fifo has out-of-order data.
f | fifo |
Definition at line 628 of file svm_fifo.h.
|
inlinestatic |
Fifo head pointer getter.
f | fifo |
Definition at line 576 of file svm_fifo.h.
|
inlinestatic |
Fifo head chunk getter.
f | fifo |
Definition at line 564 of file svm_fifo.h.
void svm_fifo_init | ( | svm_fifo_t * | f, |
u32 | size | ||
) |
Initialize fifo.
f | fifo |
size | size for fifo |
Definition at line 368 of file svm_fifo.c.
void svm_fifo_init_ooo_lookup | ( | svm_fifo_t * | f, |
u8 | ooo_type | ||
) |
Initialize rbtrees used for ooo lookups.
f | fifo |
ooo_type | type of ooo operation (0 enqueue, 1 dequeue) |
Definition at line 401 of file svm_fifo.c.
void svm_fifo_init_pointers | ( | svm_fifo_t * | f, |
u32 | head, | ||
u32 | tail | ||
) |
Init fifo head and tail.
f | fifo |
head | head value that will be matched to a chunk |
tail | tail value that will be matched to a chunk |
Init fifo head and tail.
Definition at line 1218 of file svm_fifo.c.
|
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 494 of file svm_fifo.h.
|
inlinestatic |
Check if fifo is empty optimized for consumer.
f | fifo |
Definition at line 469 of file svm_fifo.h.
|
inlinestatic |
Check if fifo is empty optimized for producer.
f | fifo |
Definition at line 481 of file svm_fifo.h.
|
inlinestatic |
|
inlinestatic |
Check if fifo is full optimized for producer.
f | fifo |
Definition at line 445 of file svm_fifo.h.
u8 svm_fifo_is_sane | ( | svm_fifo_t * | f | ) |
Check if fifo is sane.
Debug only.
f | fifo |
Definition at line 1257 of file svm_fifo.c.
|
inlinestatic |
Check if fifo is wrapped.
f | fifo |
Definition at line 506 of file svm_fifo.h.
|
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 431 of file svm_fifo.h.
|
inlinestatic |
Fifo max bytes to dequeue optimized for consumer.
f | fifo |
Definition at line 402 of file svm_fifo.h.
|
inlinestatic |
Fifo max bytes to dequeue optimized for producer.
f | fifo |
Definition at line 416 of file svm_fifo.h.
|
inlinestatic |
Definition at line 536 of file svm_fifo.h.
|
inlinestatic |
Maximum number of bytes that can be enqueued into fifo.
Optimized for producer
f | fifo |
Definition at line 522 of file svm_fifo.h.
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 507 of file svm_fifo.c.
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 527 of file svm_fifo.c.
u32 svm_fifo_n_chunks | ( | svm_fifo_t * | f | ) |
Number of chunks linked into the fifo.
f | fifo |
Definition at line 1350 of file svm_fifo.c.
u32 svm_fifo_n_ooo_segments | ( | svm_fifo_t * | f | ) |
Number of out-of-order segments for fifo.
f | fifo |
Definition at line 1203 of file svm_fifo.c.
|
inlinestatic |
Fifo number of subscribers getter.
f | fifo |
Definition at line 616 of file svm_fifo.h.
|
inlinestatic |
Check if fifo needs dequeue notification.
Determines based on notification request flags and state of the fifo if an event should be generated.
f | fifo |
n_last_deq | number of bytes last dequeued |
Definition at line 790 of file svm_fifo.h.
|
inlinestatic |
|
inlinestatic |
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 dequeueing a chunk of data. It assumes that the dgram header is at most spread over two chunks.
f | fifo |
src | src of new data |
len | length of new data |
Definition at line 771 of file svm_fifo.c.
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.
f | fifo |
offset | offset from which to copy the data |
len | length of data to copy |
dst | buffer to where to dequeue the data |
Definition at line 1038 of file svm_fifo.c.
u8* svm_fifo_replay | ( | u8 * | s, |
svm_fifo_t * | f, | ||
u8 | no_read, | ||
u8 | verbose | ||
) |
Definition at line 1400 of file svm_fifo.c.
|
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.
f | fifo |
Definition at line 774 of file svm_fifo.h.
int svm_fifo_segments | ( | svm_fifo_t * | f, |
svm_fifo_seg_t * | fs | ||
) |
Definition at line 1135 of file svm_fifo.c.
void svm_fifo_segments_free | ( | svm_fifo_t * | f, |
svm_fifo_seg_t * | fs | ||
) |
|
inlinestatic |
Set fifo event flag.
Forces release semantics.
f | fifo |
Definition at line 699 of file svm_fifo.h.
|
inlinestatic |
Definition at line 670 of file svm_fifo.h.
|
inlinestatic |
|
inlinestatic |
Fifo tail pointer getter.
f | fifo |
Definition at line 603 of file svm_fifo.h.
|
inlinestatic |
Fifo tail chunk getter.
f | fifo |
Definition at line 591 of file svm_fifo.h.
|
inlinestatic |
Unset fifo event flag.
Forces acquire semantics
f | fifo |
Definition at line 712 of file svm_fifo.h.
format_function_t format_svm_fifo |
Definition at line 393 of file svm_fifo.h.