X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Ffifo_segment.h;h=85548063972614283c4f196263cada62a148eb4d;hb=f22f4e562e1b922cff036ef628b77fd2d479d015;hp=ff36f45c4f27523a019996e296dc16e90db96d90;hpb=62ddc030296e9f65c59cd25fa81112e0a09cf20d;p=vpp.git diff --git a/src/svm/fifo_segment.h b/src/svm/fifo_segment.h index ff36f45c4f2..85548063972 100644 --- a/src/svm/fifo_segment.h +++ b/src/svm/fifo_segment.h @@ -16,6 +16,7 @@ #define __included_fifo_segment_h__ #include +#include #include typedef enum @@ -35,27 +36,9 @@ typedef enum fifo_segment_flags_ { FIFO_SEGMENT_F_IS_PREALLOCATED = 1 << 0, FIFO_SEGMENT_F_WILL_DELETE = 1 << 1, + FIFO_SEGMENT_F_MEM_LIMIT = 1 << 2, } fifo_segment_flags_t; -typedef struct fifo_segment_slice_ -{ - svm_fifo_t *fifos; /**< Linked list of active RX fifos */ - svm_fifo_t *free_fifos; /**< Freelists by fifo size */ - svm_fifo_chunk_t **free_chunks; /**< Freelists by chunk size */ - u32 n_fl_chunk_bytes; /**< Chunk bytes on freelist */ -} fifo_segment_slice_t; - -typedef struct -{ - fifo_segment_slice_t *slices; /** Fixed array of slices */ - ssvm_shared_header_t *ssvm_sh; /**< Pointer to fs ssvm shared hdr */ - uword n_free_bytes; /**< Segment free bytes */ - u32 n_active_fifos; /**< Number of active fifos */ - u32 max_log2_chunk_size; /**< Max log2(chunk size) for fs */ - u8 flags; /**< Segment flags */ - u8 n_slices; /**< Number of slices */ -} fifo_segment_header_t; - typedef struct { ssvm_private_t ssvm; /**< ssvm segment data */ @@ -66,7 +49,7 @@ typedef struct typedef struct { fifo_segment_t *segments; /**< pool of fifo segments */ - u64 next_baseva; /**< Where to put the next one */ + uword next_baseva; /**< Where to put the next one */ u32 timeout_in_seconds; /**< Time to wait during attach */ } fifo_segment_main_t; @@ -156,25 +139,12 @@ void fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, u32 rx_fifo_size, u32 tx_fifo_size, u32 * n_fifo_pairs); -/** - * Grow fifo size by adding an additional chunk of memory - * - * @param fs fifo segment for fifo - * @param f fifo to be grown - * @param chunk_size number of bytes to be added to fifo - * @return 0 on success or a negative number otherwise - */ -int fifo_segment_grow_fifo (fifo_segment_t * fs, svm_fifo_t * f, - u32 chunk_size); -/** - * Collect unused chunks for fifo - * - * @param fs fifo segment for fifo - * @param f fifo whose chunks are to be collected - * @return 0 on success, error otherwise - */ -int fifo_segment_collect_fifo_chunks (fifo_segment_t * fs, svm_fifo_t * f); +svm_fifo_chunk_t *fsh_alloc_chunk (fifo_segment_header_t * fsh, + u32 slice_index, u32 chunk_size); + +void fsh_collect_chunks (fifo_segment_header_t * fsh, u32 slice_index, + svm_fifo_chunk_t * cur); /** * Fifo segment estimate of number of free bytes @@ -186,7 +156,7 @@ int fifo_segment_collect_fifo_chunks (fifo_segment_t * fs, svm_fifo_t * f); * @param fs fifo segment * @return free bytes estimate */ -u32 fifo_segment_free_bytes (fifo_segment_t * fs); +uword fifo_segment_free_bytes (fifo_segment_t * fs); /** * Update fifo segment free bytes estimate