summaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/svm/svm_fifo.h')
-rw-r--r--src/svm/svm_fifo.h65
1 files changed, 35 insertions, 30 deletions
diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h
index 5656e63d998..5845d7042af 100644
--- a/src/svm/svm_fifo.h
+++ b/src/svm/svm_fifo.h
@@ -80,9 +80,9 @@ static inline void
f_load_head_tail_cons (svm_fifo_t * f, u32 * head, u32 * tail)
{
/* load-relaxed: consumer owned index */
- *head = f->head;
+ *head = f->shr->head;
/* load-acq: consumer foreign index (paired with store-rel in producer) */
- *tail = clib_atomic_load_acq_n (&f->tail);
+ *tail = clib_atomic_load_acq_n (&f->shr->tail);
}
/** Load head and tail optimized for producer
@@ -93,9 +93,9 @@ static inline void
f_load_head_tail_prod (svm_fifo_t * f, u32 * head, u32 * tail)
{
/* load relaxed: producer owned index */
- *tail = f->tail;
+ *tail = f->shr->tail;
/* load-acq: producer foreign index (paired with store-rel in consumer) */
- *head = clib_atomic_load_acq_n (&f->head);
+ *head = clib_atomic_load_acq_n (&f->shr->head);
}
/**
@@ -107,9 +107,9 @@ static inline void
f_load_head_tail_all_acq (svm_fifo_t * f, u32 * head, u32 * tail)
{
/* load-acq : consumer foreign index (paired with store-rel) */
- *tail = clib_atomic_load_acq_n (&f->tail);
+ *tail = clib_atomic_load_acq_n (&f->shr->tail);
/* load-acq : producer foriegn index (paired with store-rel) */
- *head = clib_atomic_load_acq_n (&f->head);
+ *head = clib_atomic_load_acq_n (&f->shr->head);
}
/**
@@ -131,7 +131,7 @@ f_cursize (svm_fifo_t * f, u32 head, u32 tail)
static inline u32
f_free_count (svm_fifo_t * f, u32 head, u32 tail)
{
- return (f->size - f_cursize (f, head, tail));
+ return (f->shr->size - f_cursize (f, head, tail));
}
always_inline u32
@@ -487,7 +487,7 @@ svm_fifo_max_dequeue (svm_fifo_t * f)
static inline int
svm_fifo_is_full_prod (svm_fifo_t * f)
{
- return (svm_fifo_max_dequeue_prod (f) == f->size);
+ return (svm_fifo_max_dequeue_prod (f) == f->shr->size);
}
/* Check if fifo is full.
@@ -499,7 +499,7 @@ svm_fifo_is_full_prod (svm_fifo_t * f)
static inline int
svm_fifo_is_full (svm_fifo_t * f)
{
- return (svm_fifo_max_dequeue (f) == f->size);
+ return (svm_fifo_max_dequeue (f) == f->shr->size);
}
/**
@@ -606,7 +606,7 @@ u32 svm_fifo_max_write_chunk (svm_fifo_t * f);
static inline svm_fifo_chunk_t *
svm_fifo_head_chunk (svm_fifo_t * f)
{
- return f->head_chunk;
+ return f->shr->head_chunk;
}
/**
@@ -618,10 +618,11 @@ svm_fifo_head_chunk (svm_fifo_t * f)
static inline u8 *
svm_fifo_head (svm_fifo_t * f)
{
- if (!f->head_chunk)
+ if (!f->shr->head_chunk)
return 0;
/* load-relaxed: consumer owned index */
- return (f->head_chunk->data + (f->head - f->head_chunk->start_byte));
+ return (f->shr->head_chunk->data +
+ (f->shr->head - f->shr->head_chunk->start_byte));
}
/**
@@ -633,7 +634,7 @@ svm_fifo_head (svm_fifo_t * f)
static inline svm_fifo_chunk_t *
svm_fifo_tail_chunk (svm_fifo_t * f)
{
- return f->tail_chunk;
+ return f->shr->tail_chunk;
}
/**
@@ -646,7 +647,8 @@ static inline u8 *
svm_fifo_tail (svm_fifo_t * f)
{
/* load-relaxed: producer owned index */
- return (f->tail_chunk->data + (f->tail - f->tail_chunk->start_byte));
+ return (f->shr->tail_chunk->data +
+ (f->shr->tail - f->shr->tail_chunk->start_byte));
}
/**
@@ -658,7 +660,7 @@ svm_fifo_tail (svm_fifo_t * f)
static inline u8
svm_fifo_n_subscribers (svm_fifo_t * f)
{
- return f->n_subscribers;
+ return f->shr->n_subscribers;
}
/**
@@ -692,7 +694,7 @@ ooo_segment_offset_prod (svm_fifo_t * f, ooo_segment_t * s)
{
u32 tail;
/* load-relaxed: producer owned index */
- tail = f->tail;
+ tail = f->shr->tail;
return (s->start - tail);
}
@@ -706,7 +708,7 @@ ooo_segment_length (svm_fifo_t * f, ooo_segment_t * s)
static inline u32
svm_fifo_size (svm_fifo_t * f)
{
- return f->size;
+ return f->shr->size;
}
static inline void
@@ -714,8 +716,9 @@ svm_fifo_set_size (svm_fifo_t * f, u32 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;
+ fsh_virtual_mem_update (f->fs_hdr, f->shr->slice_index,
+ (int) f->shr->size - size);
+ f->shr->size = size;
}
/**
@@ -727,7 +730,7 @@ svm_fifo_set_size (svm_fifo_t * f, u32 size)
static inline int
svm_fifo_has_event (svm_fifo_t * f)
{
- return f->has_event;
+ return f->shr->has_event;
}
/**
@@ -741,7 +744,7 @@ svm_fifo_has_event (svm_fifo_t * f)
always_inline u8
svm_fifo_set_event (svm_fifo_t * f)
{
- return !clib_atomic_swap_rel_n (&f->has_event, 1);
+ return !clib_atomic_swap_rel_n (&f->shr->has_event, 1);
}
/**
@@ -754,7 +757,7 @@ svm_fifo_set_event (svm_fifo_t * f)
always_inline void
svm_fifo_unset_event (svm_fifo_t * f)
{
- clib_atomic_swap_acq_n (&f->has_event, 0);
+ clib_atomic_swap_acq_n (&f->shr->has_event, 0);
}
/**
@@ -768,7 +771,7 @@ svm_fifo_unset_event (svm_fifo_t * f)
static inline void
svm_fifo_add_want_deq_ntf (svm_fifo_t * f, u8 ntf_type)
{
- f->want_deq_ntf |= ntf_type;
+ f->shr->want_deq_ntf |= ntf_type;
}
/**
@@ -782,7 +785,7 @@ svm_fifo_add_want_deq_ntf (svm_fifo_t * f, u8 ntf_type)
static inline void
svm_fifo_del_want_deq_ntf (svm_fifo_t * f, u8 ntf_type)
{
- f->want_deq_ntf &= ~ntf_type;
+ f->shr->want_deq_ntf &= ~ntf_type;
}
/**
@@ -800,7 +803,8 @@ static inline void
svm_fifo_clear_deq_ntf (svm_fifo_t * f)
{
/* Set the flag if want_notif_if_full was the only ntf requested */
- f->has_deq_ntf = f->want_deq_ntf == SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL;
+ f->shr->has_deq_ntf =
+ f->shr->want_deq_ntf == SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL;
svm_fifo_del_want_deq_ntf (f, SVM_FIFO_WANT_DEQ_NOTIF);
}
@@ -816,7 +820,7 @@ svm_fifo_clear_deq_ntf (svm_fifo_t * f)
static inline void
svm_fifo_reset_has_deq_ntf (svm_fifo_t * f)
{
- f->has_deq_ntf = 0;
+ f->shr->has_deq_ntf = 0;
}
/**
@@ -832,7 +836,7 @@ svm_fifo_reset_has_deq_ntf (svm_fifo_t * f)
static inline u8
svm_fifo_needs_deq_ntf (svm_fifo_t * f, u32 n_last_deq)
{
- u8 want_ntf = f->want_deq_ntf;
+ u8 want_ntf = f->shr->want_deq_ntf;
if (PREDICT_TRUE (want_ntf == SVM_FIFO_NO_DEQ_NOTIF))
return 0;
@@ -841,13 +845,14 @@ svm_fifo_needs_deq_ntf (svm_fifo_t * f, u32 n_last_deq)
if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL)
{
u32 max_deq = svm_fifo_max_dequeue_cons (f);
- u32 size = f->size;
- if (!f->has_deq_ntf && max_deq < size && max_deq + n_last_deq >= size)
+ u32 size = f->shr->size;
+ if (!f->shr->has_deq_ntf && max_deq < size &&
+ max_deq + n_last_deq >= size)
return 1;
}
if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY)
{
- if (!f->has_deq_ntf && svm_fifo_is_empty (f))
+ if (!f->shr->has_deq_ntf && svm_fifo_is_empty (f))
return 1;
}
return 0;