svm_fifo_t *f = va_arg (*args, svm_fifo_t *);
int verbose = va_arg (*args, int);
+ if (!s)
+ return s;
+
s = format (s, "cursize %u nitems %u has_event %d\n",
f->cursize, f->nitems, f->has_event);
s = format (s, " head %d tail %d\n", f->head, f->tail);
}
static int
-svm_fifo_enqueue_internal (svm_fifo_t * f, u32 max_bytes, u8 * copy_from_here)
+svm_fifo_enqueue_internal (svm_fifo_t * f, u32 max_bytes,
+ const u8 * copy_from_here)
{
u32 total_copy_bytes, first_copy_bytes, second_copy_bytes;
u32 cursize, nitems;
f->ooos_newest = OOO_SEGMENT_INVALID_INDEX;
if (PREDICT_FALSE (cursize == f->nitems))
- return -2; /* fifo stuffed */
+ return SVM_FIFO_FULL;
nitems = f->nitems;
static int
svm_fifo_enqueue_nowait_ma (svm_fifo_t * f, u32 max_bytes,
- u8 * copy_from_here)
+ const u8 * copy_from_here)
{
return svm_fifo_enqueue_internal (f, max_bytes, copy_from_here);
}
CLIB_MULTIARCH_SELECT_FN (svm_fifo_enqueue_nowait_ma);
int
-svm_fifo_enqueue_nowait (svm_fifo_t * f, u32 max_bytes, u8 * copy_from_here)
+svm_fifo_enqueue_nowait (svm_fifo_t * f, u32 max_bytes,
+ const u8 * copy_from_here)
{
#if CLIB_DEBUG > 0
return svm_fifo_enqueue_nowait_ma (f, max_bytes, copy_from_here);
#else
- static int (*fp) (svm_fifo_t *, u32, u8 *);
+ static int (*fp) (svm_fifo_t *, u32, const u8 *);
if (PREDICT_FALSE (fp == 0))
fp = (void *) svm_fifo_enqueue_nowait_ma_multiarch_select ();
copy_from_here);
}
+void
+svm_fifo_overwrite_head (svm_fifo_t * f, u8 * data, u32 len)
+{
+ u32 first_chunk;
+ ASSERT (len <= f->nitems);
+ if (len < f->nitems - f->head)
+ clib_memcpy (&f->data[f->head], data, len);
+ else
+ {
+ first_chunk = len - (f->nitems - f->head);
+ clib_memcpy (&f->data[f->head], data, first_chunk);
+ clib_memcpy (f->data, data + first_chunk, len - first_chunk);
+ }
+}
static int
svm_fifo_dequeue_internal (svm_fifo_t * f, u32 max_bytes, u8 * copy_here)