From 00338e09122e803cb31187cd85af69b8d6dbcb9c Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 20 Apr 2021 14:26:46 -0700 Subject: svm: allow external chunk alloc on segment Type: improvement Signed-off-by: Florin Coras Change-Id: I89f9caa8dd44dc640615a58fe7708f388fdd84e9 --- src/svm/fifo_segment.c | 24 ++++++++++++++++++++++++ src/svm/fifo_segment.h | 8 ++++++++ 2 files changed, 32 insertions(+) (limited to 'src/svm') diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c index 3e728eca71a..cde906fe799 100644 --- a/src/svm/fifo_segment.c +++ b/src/svm/fifo_segment.c @@ -1038,6 +1038,30 @@ fifo_segment_fifo_offset (svm_fifo_t *f) return (u8 *) f->shr - (u8 *) f->fs_hdr; } +svm_fifo_chunk_t * +fifo_segment_alloc_chunk_w_slice (fifo_segment_t *fs, u32 slice_index, + u32 chunk_size) +{ + fifo_segment_header_t *fsh = fs->h; + fifo_segment_slice_t *fss; + + fss = fsh_slice_get (fsh, slice_index); + return fsh_try_alloc_chunk (fsh, fss, chunk_size); +} + +void +fifo_segment_collect_chunk (fifo_segment_t *fs, u32 slice_index, + svm_fifo_chunk_t *c) +{ + fsh_collect_chunks (fs->h, slice_index, c); +} + +uword +fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c) +{ + return (u8 *) c - (u8 *) fs->h; +} + svm_msg_q_t * fifo_segment_msg_q_alloc (fifo_segment_t *fs, u32 mq_index, svm_msg_q_cfg_t *cfg) diff --git a/src/svm/fifo_segment.h b/src/svm/fifo_segment.h index 64dfce87b6d..a4290bb1dc7 100644 --- a/src/svm/fifo_segment.h +++ b/src/svm/fifo_segment.h @@ -329,6 +329,14 @@ svm_fifo_t *fifo_segment_get_slice_fifo_list (fifo_segment_t * fs, u32 slice_index); u32 fifo_segment_num_fifos (fifo_segment_t * fs); u32 fifo_segment_num_free_fifos (fifo_segment_t * fs); + +svm_fifo_chunk_t *fifo_segment_alloc_chunk_w_slice (fifo_segment_t *fs, + u32 slice_index, + u32 chunk_size); +void fifo_segment_collect_chunk (fifo_segment_t *fs, u32 slice_index, + svm_fifo_chunk_t *c); +uword fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c); + /** * Find number of free chunks of given size * -- cgit 1.2.3-korg