hsa: detach fifo segments in echo app
[vpp.git] / src / svm / svm_fifo.h
index 93ef006..5656e63 100644 (file)
@@ -207,6 +207,21 @@ svm_fifo_chunk_t *svm_fifo_chunk_alloc (u32 size);
  * @param f    fifo
  */
 int svm_fifo_fill_chunk_list (svm_fifo_t * f);
+/**
+ * Provision and return chunks for number of bytes requested
+ *
+ * Allocates enough chunks to cover the bytes requested and returns them
+ * in the fifo segment array. The number of bytes provisioned may be less
+ * than requested if not enough segments were provided.
+ *
+ * @param f            fifo
+ * @param fs           array of fifo segments
+ * @param n_segs       length of fifo segments array
+ * @param len          number of bytes to preallocate
+ * @return             number of fifo segments provisioned or error
+ */
+int svm_fifo_provision_chunks (svm_fifo_t *f, svm_fifo_seg_t *fs, u32 n_segs,
+                              u32 len);
 /**
  * Initialize rbtrees used for ooo lookups
  *
@@ -291,6 +306,17 @@ int svm_fifo_enqueue_with_offset (svm_fifo_t * f, u32 offset, u32 len,
  * @param len          number of bytes to add to tail
  */
 void svm_fifo_enqueue_nocopy (svm_fifo_t * f, u32 len);
+/**
+ * Enqueue array of @ref svm_fifo_seg_t in order
+ *
+ * @param f            fifo
+ * @param segs         array of segments to enqueue
+ * @param n_segs       number of segments
+ * @param allow_partial        if set partial enqueues are allowed
+ * @return             len if enqueue was successful, error otherwise
+ */
+int svm_fifo_enqueue_segments (svm_fifo_t * f, const svm_fifo_seg_t segs[],
+                              u32 n_segs, u8 allow_partial);
 /**
  * Overwrite fifo head with new data
  *
@@ -357,13 +383,14 @@ void svm_fifo_dequeue_drop_all (svm_fifo_t * f);
  * data is consumed.
  *
  * @param f            fifo
+ * @param offset       offset from where to retrieve segments
  * @param fs           array of fifo segments allocated by caller
  * @param n_segs       number of fifo segments in array
  * @param max_bytes    max bytes to be mapped to fifo segments
  * @return             number of bytes in fifo segments or SVM_FIFO_EEMPTY
  */
-int svm_fifo_segments (svm_fifo_t * f, svm_fifo_seg_t * fs, u32 n_segs,
-                      u32 max_bytes);
+int svm_fifo_segments (svm_fifo_t * f, u32 offset, svm_fifo_seg_t * fs,
+                      u32 n_segs, u32 max_bytes);
 /**
  * Add io events subscriber to list
  *
@@ -685,7 +712,7 @@ svm_fifo_size (svm_fifo_t * f)
 static inline void
 svm_fifo_set_size (svm_fifo_t * f, u32 size)
 {
-  if (size > (1 << f->fs_hdr->max_log2_chunk_size))
+  if (size > (1 << f->fs_hdr->max_log2_fifo_size))
     return;
   fsh_virtual_mem_update (f->fs_hdr, f->slice_index, (int) f->size - size);
   f->size = size;