svm: separate private from shared fifo segment ptrs
[vpp.git] / src / svm / fifo_types.h
index 9182a2a..e839e7e 100644 (file)
 #include <vppinfra/rbtree.h>
 #include <vppinfra/lock.h>
 
+#define FS_MIN_LOG2_CHUNK_SZ 12 /**< also min fifo size */
+#define FS_MAX_LOG2_CHUNK_SZ 22 /**< 4MB max chunk size */
+#define FS_CHUNK_VEC_LEN     11 /**< number of chunk sizes */
+
+STATIC_ASSERT ((FS_MAX_LOG2_CHUNK_SZ - FS_MIN_LOG2_CHUNK_SZ) ==
+                FS_CHUNK_VEC_LEN - 1,
+              "update chunk sizes");
+
 #define SVM_FIFO_TRACE                         (0)
 #define SVM_FIFO_MAX_EVT_SUBSCRIBERS   7
 
@@ -101,24 +109,23 @@ typedef struct _svm_fifo
 
 typedef struct fifo_segment_slice_
 {
+  svm_fifo_chunk_t *free_chunks[FS_CHUNK_VEC_LEN]; /**< Free chunks by size */
   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 *num_chunks;                     /**< Allocated chunks by chunk size */
   uword n_fl_chunk_bytes;              /**< Chunk bytes on freelist */
   uword virtual_mem;                   /**< Slice sum of all fifo sizes */
-  u32 n_chunk_lens;
+  u32 num_chunks[FS_CHUNK_VEC_LEN];    /**< Allocated chunks by chunk size */
+
   CLIB_CACHE_LINE_ALIGN_MARK (lock);
   u32 chunk_lock;
 } fifo_segment_slice_t;
 
 struct fifo_segment_header_
 {
-  fifo_segment_slice_t *slices;                /** Fixed array of slices */
   uword n_cached_bytes;                        /**< Cached bytes */
   u32 n_active_fifos;                  /**< Number of active fifos */
   u32 n_reserved_bytes;                        /**< Bytes not to be allocated */
-  u32 max_log2_chunk_size;             /**< Max log2(chunk size) for fs */
+  u32 max_log2_fifo_size;              /**< Max log2(chunk size) for fs */
   u8 flags;                            /**< Segment flags */
   u8 n_slices;                         /**< Number of slices */
   u8 high_watermark;                   /**< Memory pressure watermark high */
@@ -127,6 +134,8 @@ struct fifo_segment_header_
   CLIB_CACHE_LINE_ALIGN_MARK (allocator);
   uword byte_index;
   uword max_byte_index;
+  CLIB_CACHE_LINE_ALIGN_MARK (slice);
+  fifo_segment_slice_t slices[0]; /** Fixed array of slices */
 };
 
 void fsh_virtual_mem_update (fifo_segment_header_t * fsh, u32 slice_index,