aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo_segment.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-09 18:29:14 -0700
committerDamjan Marion <dmarion@me.com>2019-04-18 13:16:18 +0000
commit0a846806742922d98f1aff9cf1370715e57a2ae5 (patch)
tree5214807e20731453254635ed2d9afa9649eb4469 /src/svm/svm_fifo_segment.c
parent5a8844bdbf4b055812cce2d7755a175b2cc90b75 (diff)
svm: allow indirect fifo data chunks
Fifos can use multiple memory chunks for simple read/write operations. Adding/removing chunks after assignment not yet supported. Change-Id: I2aceab6aea78059d74e0d3a9993c40d5196d077b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/svm_fifo_segment.c')
-rw-r--r--src/svm/svm_fifo_segment.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/svm/svm_fifo_segment.c b/src/svm/svm_fifo_segment.c
index 94bf6a5e73e..90bf593f74c 100644
--- a/src/svm/svm_fifo_segment.c
+++ b/src/svm/svm_fifo_segment.c
@@ -16,6 +16,23 @@
#include <svm/svm_fifo_segment.h>
static void
+fifo_init_for_segment (svm_fifo_segment_header_t * fsh, u8 * fifo_space,
+ u32 size, u32 freelist_index)
+{
+ svm_fifo_t *f;
+
+ f = (svm_fifo_t *) fifo_space;
+ f->freelist_index = freelist_index;
+ f->default_chunk.next = &f->default_chunk;
+ f->default_chunk.start_byte = 0;
+ f->default_chunk.length = size;
+ f->head_chunk = &f->default_chunk;
+ f->tail_chunk = &f->default_chunk;
+ f->next = fsh->free_fifos[freelist_index];
+ fsh->free_fifos[freelist_index] = f;
+}
+
+static void
allocate_new_fifo_chunk (svm_fifo_segment_header_t * fsh,
u32 data_size_in_bytes, int chunk_size)
{
@@ -43,14 +60,11 @@ allocate_new_fifo_chunk (svm_fifo_segment_header_t * fsh,
return;
/* Carve fifo space */
- f = (svm_fifo_t *) fifo_space;
for (i = 0; i < chunk_size; i++)
{
- f->freelist_index = freelist_index;
- f->next = fsh->free_fifos[freelist_index];
- fsh->free_fifos[freelist_index] = f;
+ fifo_init_for_segment (fsh, fifo_space, rounded_data_size,
+ freelist_index);
fifo_space += sizeof (*f) + rounded_data_size;
- f = (svm_fifo_t *) fifo_space;
}
}
@@ -149,24 +163,18 @@ svm_fifo_segment_preallocate_fifo_pairs (svm_fifo_segment_private_t * s,
}
/* Carve rx fifo space */
- f = (svm_fifo_t *) rx_fifo_space;
for (i = 0; i < pairs_to_allocate; i++)
{
- f->freelist_index = rx_freelist_index;
- f->next = fsh->free_fifos[rx_freelist_index];
- fsh->free_fifos[rx_freelist_index] = f;
+ fifo_init_for_segment (fsh, rx_fifo_space, rx_rounded_data_size,
+ rx_freelist_index);
rx_fifo_space += sizeof (*f) + rx_rounded_data_size;
- f = (svm_fifo_t *) rx_fifo_space;
}
/* Carve tx fifo space */
- f = (svm_fifo_t *) tx_fifo_space;
for (i = 0; i < pairs_to_allocate; i++)
{
- f->freelist_index = tx_freelist_index;
- f->next = fsh->free_fifos[tx_freelist_index];
- fsh->free_fifos[tx_freelist_index] = f;
+ fifo_init_for_segment (fsh, tx_fifo_space, tx_rounded_data_size,
+ tx_freelist_index);
tx_fifo_space += sizeof (*f) + tx_rounded_data_size;
- f = (svm_fifo_t *) tx_fifo_space;
}
/* Account for the pairs allocated */
@@ -381,16 +389,7 @@ svm_fifo_segment_alloc_fifo (svm_fifo_segment_private_t * fs,
fsh->free_fifos[freelist_index] = f->next;
/* (re)initialize the fifo, as in svm_fifo_create */
clib_memset (f, 0, sizeof (*f));
- f->size = (1 << (max_log2 (data_size_in_bytes)));
- /*
- * usable size of the fifo set to rounded_data_size - 1
- * to differentiate between free fifo and empty fifo.
- */
- f->nitems = f->size - 1;
- f->ooos_list_head = OOO_SEGMENT_INVALID_INDEX;
- f->ct_session_index = SVM_FIFO_INVALID_SESSION_INDEX;
- f->refcnt = 1;
- f->freelist_index = freelist_index;
+ svm_fifo_init (f, data_size_in_bytes);
goto found;
}
break;