summaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo_segment.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-05-30 09:30:07 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-06-01 16:02:55 +0000
commit10d8cc6bf92851fcaec4a6b4c6d3554dc1eb2386 (patch)
treec146b324f974aa13499a1d784a96ef96438c9d15 /src/svm/svm_fifo_segment.h
parent26261594a0b821770aa0a646cba8399aa6320c2e (diff)
Improve fifo allocator performance
- add option to preallocate fifos in a segment - track active fifos with doubly linked list instead of vector - update udp redirect test code to read fifo pointers from API call instead of digging them up from fifo segment header - input-node based active-open session generator Change-Id: I804b81e99d95f8690d17e12660c6645995e28a9a Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/svm/svm_fifo_segment.h')
-rw-r--r--src/svm/svm_fifo_segment.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/svm/svm_fifo_segment.h b/src/svm/svm_fifo_segment.h
index 4218013a9e4..31e14db50f6 100644
--- a/src/svm/svm_fifo_segment.h
+++ b/src/svm/svm_fifo_segment.h
@@ -19,10 +19,19 @@
#include <svm/ssvm.h>
#include <vppinfra/lock.h>
+typedef enum
+{
+ FIFO_SEGMENT_FREELIST_NONE = -1,
+ FIFO_SEGMENT_RX_FREELIST = 0,
+ FIFO_SEGMENT_TX_FREELIST,
+ FIFO_SEGMENT_N_FREELISTS
+} svm_fifo_segment_freelist_t;
+
typedef struct
{
- volatile svm_fifo_t **fifos;
- u8 *segment_name;
+ svm_fifo_t *fifos; /**< Linked list of active RX fifos */
+ u8 *segment_name; /**< Segment name */
+ svm_fifo_t *free_fifos[FIFO_SEGMENT_N_FREELISTS]; /**< Free lists */
} svm_fifo_segment_header_t;
typedef struct
@@ -49,6 +58,9 @@ typedef struct
char *segment_name;
u32 segment_size;
u32 new_segment_index;
+ u32 rx_fifo_size;
+ u32 tx_fifo_size;
+ u32 preallocated_fifo_pairs;
} svm_fifo_segment_create_args_t;
static inline svm_fifo_segment_private_t *
@@ -61,13 +73,13 @@ svm_fifo_get_segment (u32 segment_index)
static inline u8
svm_fifo_segment_has_fifos (svm_fifo_segment_private_t * fifo_segment)
{
- return vec_len ((svm_fifo_t **) fifo_segment->h->fifos) != 0;
+ return fifo_segment->h->fifos != 0;
}
-static inline svm_fifo_t **
-svm_fifo_segment_get_fifos (svm_fifo_segment_private_t * fifo_segment)
+static inline svm_fifo_t *
+svm_fifo_segment_get_fifo_list (svm_fifo_segment_private_t * fifo_segment)
{
- return (svm_fifo_t **) fifo_segment->h->fifos;
+ return fifo_segment->h->fifos;
}
#define foreach_ssvm_fifo_segment_api_error \
@@ -87,9 +99,11 @@ int svm_fifo_segment_attach (svm_fifo_segment_create_args_t * a);
void svm_fifo_segment_delete (svm_fifo_segment_private_t * s);
svm_fifo_t *svm_fifo_segment_alloc_fifo (svm_fifo_segment_private_t * s,
- u32 data_size_in_bytes);
+ u32 data_size_in_bytes,
+ svm_fifo_segment_freelist_t index);
void svm_fifo_segment_free_fifo (svm_fifo_segment_private_t * s,
- svm_fifo_t * f);
+ svm_fifo_t * f,
+ svm_fifo_segment_freelist_t index);
void svm_fifo_segment_init (u64 baseva, u32 timeout_in_seconds);
u32 svm_fifo_segment_index (svm_fifo_segment_private_t * s);