+static svm_fifo_chunk_t *
+fss_chunk_free_list_pop (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss,
+ u32 fl_index)
+{
+ fs_sptr_t old_head, new_head;
+ svm_fifo_chunk_t *c;
+
+ ASSERT (fss_chunk_fl_index_is_valid (fss, fl_index));
+
+ old_head = clib_atomic_load_acq_n (&fss->free_chunks[fl_index]);
+
+ /* Lock-free stacks are affected by ABA if a side allocates a chunk and
+ * shortly thereafter frees it. To circumvent that, reuse the upper bits
+ * of the head of the list shared pointer, i.e., offset to where the chunk
+ * is, as a tag. The tag is incremented with each push/pop operation and
+ * therefore collisions can only happen if an element is popped and pushed
+ * exactly after a complete wrap of the tag (16 bits). It's unlikely either
+ * of the sides will be descheduled for that long */
+ do
+ {
+ if (!(old_head & FS_CL_HEAD_MASK))
+ return 0;
+ c = fs_chunk_ptr (fsh, old_head & FS_CL_HEAD_MASK);
+ new_head = c->next + ((old_head + FS_CL_HEAD_TINC) & FS_CL_HEAD_TMASK);
+ }
+ while (!__atomic_compare_exchange (&fss->free_chunks[fl_index], &old_head,
+ &new_head, 0 /* weak */, __ATOMIC_RELEASE,
+ __ATOMIC_ACQUIRE));
+
+ return c;
+}
+
+static void
+fss_fifo_free_list_push (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss,
+ svm_fifo_shared_t *sf)
+{
+ sf->next = fss->free_fifos;
+ fss->free_fifos = fs_sptr (fsh, sf);
+}
+
+static void
+fss_fifo_free_list_push_list (fifo_segment_header_t *fsh,
+ fifo_segment_slice_t *fss,
+ svm_fifo_shared_t *head, svm_fifo_shared_t *tail)
+{
+ tail->next = fss->free_fifos;
+ fss->free_fifos = fs_sptr (fsh, head);
+}
+
+svm_fifo_shared_t *
+fss_fifo_free_list_pop (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss)
+{
+ svm_fifo_shared_t *sf;
+ sf = fs_ptr (fsh, fss->free_fifos);
+ fss->free_fifos = sf->next;
+ return sf;
+}
+
+static inline void
+pfss_fifo_add_active_list (fifo_slice_private_t *pfss, svm_fifo_t *f)
+{
+ if (pfss->active_fifos)
+ {
+ pfss->active_fifos->prev = f;
+ f->next = pfss->active_fifos;
+ }
+ pfss->active_fifos = f;
+}
+
+static inline void
+pfss_fifo_del_active_list (fifo_slice_private_t *pfss, svm_fifo_t *f)
+{
+ if (f->flags & SVM_FIFO_F_LL_TRACKED)
+ {
+ if (f->prev)
+ f->prev->next = f->next;
+ else
+ pfss->active_fifos = f->next;
+ if (f->next)
+ f->next->prev = f->prev;
+ }
+}
+
+static inline uword
+fss_fl_chunk_bytes (fifo_segment_slice_t * fss)
+{
+ return clib_atomic_load_relax_n (&fss->n_fl_chunk_bytes);
+}
+
+static inline void
+fss_fl_chunk_bytes_add (fifo_segment_slice_t * fss, uword size)
+{
+ clib_atomic_fetch_add_relax (&fss->n_fl_chunk_bytes, size);
+}
+
+static inline void
+fss_fl_chunk_bytes_sub (fifo_segment_slice_t * fss, uword size)
+{
+ clib_atomic_fetch_sub_relax (&fss->n_fl_chunk_bytes, size);