aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-05-03 11:46:55 -0700
committerFlorin Coras <florin.coras@gmail.com>2019-05-03 20:27:45 +0000
commit344ce4277885e448912fdfc35bcfaf130c74d086 (patch)
treee2ecaf3ad0c4ca224a32815af44ffd781bcfae5d /src/svm/fifo_segment.c
parenta7570b0378b071129937a89a5632011a962cdb43 (diff)
session/svm: apis for fifo shrinking
Change-Id: Ie519683bb90aae6fb95f2a09e251cded1890ed41 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 9c332d6f1fa..0263d1a57cc 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -570,6 +570,35 @@ fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, u32 chunk_size)
return 0;
}
+int
+fifo_segment_collect_fifo_chunks (fifo_segment_t * fs, svm_fifo_t * f)
+{
+ svm_fifo_chunk_t *cur, *next;
+ ssvm_shared_header_t *sh;
+ void *oldheap;
+ int fl_index;
+
+ sh = fs->ssvm.sh;
+ ssvm_lock_non_recursive (sh, 1);
+
+ oldheap = ssvm_push_heap (sh);
+ cur = svm_fifo_collect_chunks (f);
+
+ while (cur)
+ {
+ next = cur->next;
+ fl_index = fs_free_list_for_size (cur->length);
+ cur->next = fs->h->free_chunks[fl_index];
+ fs->h->free_chunks[fl_index] = cur;
+ cur = next;
+ }
+
+ ssvm_pop_heap (oldheap);
+ ssvm_unlock_non_recursive (sh);
+
+ return 0;
+}
+
/**
* Get number of active fifos
*/