summaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/fifo_segment.c44
-rw-r--r--src/svm/fifo_types.h2
2 files changed, 30 insertions, 16 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 008cca4f350..636f223cde1 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -52,6 +52,13 @@ fsh_slice_get (fifo_segment_header_t * fsh, u32 slice_index)
return &fsh->slices[slice_index];
}
+static inline fifo_slice_private_t *
+fs_slice_private_get (fifo_segment_t *fs, u32 slice_index)
+{
+ ASSERT (slice_index < fs->n_slices);
+ return &fs->slices[slice_index];
+}
+
static char *fifo_segment_mem_status_strings[] = {
#define _(sym,str) str,
foreach_segment_mem_status
@@ -194,25 +201,25 @@ fss_chunk_free_list_pop (fifo_segment_header_t *fsh, fifo_segment_slice_t *fss,
}
static inline void
-fss_fifo_add_active_list (fifo_segment_slice_t * fss, svm_fifo_t * f)
+pfss_fifo_add_active_list (fifo_slice_private_t *pfss, svm_fifo_t *f)
{
- if (fss->fifos)
+ if (pfss->active_fifos)
{
- fss->fifos->prev = f;
- f->next = fss->fifos;
+ pfss->active_fifos->prev = f;
+ f->next = pfss->active_fifos;
}
- fss->fifos = f;
+ pfss->active_fifos = f;
}
static inline void
-fss_fifo_del_active_list (fifo_segment_slice_t * fss, svm_fifo_t * f)
+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
- fss->fifos = f->next;
+ pfss->active_fifos = f->next;
if (f->next)
f->next->prev = f->prev;
}
@@ -770,6 +777,7 @@ fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs, u32 slice_index,
u32 data_bytes, fifo_segment_ftype_t ftype)
{
fifo_segment_header_t *fsh = fs->h;
+ fifo_slice_private_t *pfss;
fifo_segment_slice_t *fss;
svm_fifo_shared_t *sf;
svm_fifo_t *f = 0;
@@ -790,6 +798,7 @@ fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs, u32 slice_index,
svm_fifo_init (f, data_bytes);
fss = fsh_slice_get (fsh, slice_index);
+ pfss = fs_slice_private_get (fs, slice_index);
/* If rx fifo type add to active fifos list. When cleaning up segment,
* we need a list of active sessions that should be disconnected. Since
@@ -797,7 +806,7 @@ fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs, u32 slice_index,
* only one. */
if (ftype == FIFO_SEGMENT_RX_FIFO)
{
- fss_fifo_add_active_list (fss, f);
+ pfss_fifo_add_active_list (pfss, f);
f->flags |= SVM_FIFO_F_LL_TRACKED;
}
@@ -828,6 +837,7 @@ void
fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
{
fifo_segment_header_t *fsh = fs->h;
+ fifo_slice_private_t *pfss;
fifo_segment_slice_t *fss;
svm_fifo_shared_t *sf;
@@ -842,6 +852,7 @@ fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
sf = f->shr;
fss = fsh_slice_get (fsh, sf->slice_index);
+ pfss = fs_slice_private_get (fs, sf->slice_index);
/* Free fifo chunks */
fsh_slice_collect_chunks (fsh, fss, fs_chunk_ptr (fsh, f->shr->start_chunk));
@@ -862,7 +873,7 @@ fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
/* Remove from active list. Only rx fifos are tracked */
if (f->flags & SVM_FIFO_F_LL_TRACKED)
{
- fss_fifo_del_active_list (fss, f);
+ pfss_fifo_del_active_list (pfss, f);
f->flags &= ~SVM_FIFO_F_LL_TRACKED;
}
@@ -886,6 +897,7 @@ fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f)
void
fifo_segment_detach_fifo (fifo_segment_t * fs, svm_fifo_t * f)
{
+ fifo_slice_private_t *pfss;
fifo_segment_slice_t *fss;
svm_fifo_chunk_t *c;
u32 fl_index;
@@ -893,9 +905,10 @@ fifo_segment_detach_fifo (fifo_segment_t * fs, svm_fifo_t * f)
ASSERT (f->refcnt == 1);
fss = fsh_slice_get (fs->h, f->shr->slice_index);
+ pfss = fs_slice_private_get (fs, f->shr->slice_index);
fss->virtual_mem -= svm_fifo_size (f);
if (f->flags & SVM_FIFO_F_LL_TRACKED)
- fss_fifo_del_active_list (fss, f);
+ pfss_fifo_del_active_list (pfss, f);
c = fs_chunk_ptr (fs->h, f->shr->start_chunk);
while (c)
@@ -910,15 +923,17 @@ void
fifo_segment_attach_fifo (fifo_segment_t * fs, svm_fifo_t * f,
u32 slice_index)
{
+ fifo_slice_private_t *pfss;
fifo_segment_slice_t *fss;
svm_fifo_chunk_t *c;
u32 fl_index;
f->shr->slice_index = slice_index;
fss = fsh_slice_get (fs->h, f->shr->slice_index);
+ pfss = fs_slice_private_get (fs, f->shr->slice_index);
fss->virtual_mem += svm_fifo_size (f);
if (f->flags & SVM_FIFO_F_LL_TRACKED)
- fss_fifo_add_active_list (fss, f);
+ pfss_fifo_add_active_list (pfss, f);
c = fs_chunk_ptr (fs->h, f->shr->start_chunk);
while (c)
@@ -1201,11 +1216,10 @@ fifo_segment_has_fifos (fifo_segment_t * fs)
svm_fifo_t *
fifo_segment_get_slice_fifo_list (fifo_segment_t * fs, u32 slice_index)
{
- fifo_segment_header_t *fsh = fs->h;
- fifo_segment_slice_t *fss;
+ fifo_slice_private_t *pfss;
- fss = fsh_slice_get (fsh, slice_index);
- return fss->fifos;
+ pfss = fs_slice_private_get (fs, slice_index);
+ return pfss->active_fifos;
}
u8
diff --git a/src/svm/fifo_types.h b/src/svm/fifo_types.h
index a65b3a8831a..85e67bb039c 100644
--- a/src/svm/fifo_types.h
+++ b/src/svm/fifo_types.h
@@ -119,7 +119,6 @@ typedef struct fifo_segment_slice_
{
svm_fifo_chunk_ptr_t
free_chunks[FS_CHUNK_VEC_LEN]; /**< Free chunks by size */
- svm_fifo_t *fifos; /**< Linked list of active RX fifos */
svm_fifo_shared_t *free_fifos; /**< Freelists of fifo shared hdrs */
uword n_fl_chunk_bytes; /**< Chunk bytes on freelist */
uword virtual_mem; /**< Slice sum of all fifo sizes */
@@ -133,6 +132,7 @@ typedef struct fifo_slice_private_
{
clib_mem_bulk_handle_t fifos; /**< Bulk fifo allocator */
uword virtual_mem; /**< Slice sum of all fifo sizes */
+ svm_fifo_t *active_fifos; /**< Linked list of active RX fifos */
} fifo_slice_private_t;
struct fifo_segment_header_