aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-01-18 20:51:08 -0800
committerDamjan Marion <dmarion@me.com>2022-01-19 15:58:20 +0000
commitb85de19145a01d3acdf326c3cfa4e94b585bb59f (patch)
treee2fe6345574c36138737921bd0afa11d459cec2b /src/svm/svm_fifo.c
parent95bbbe479eb5179fa61dd691d8d7d726fb71a885 (diff)
svm: update number of segments in svm_fifo_segments
In addition to returning the number of bytes also update the number of segments to reflect the number used. Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ia87dc2aa62cea38b18dfa83df94dc2abe29d5121
Diffstat (limited to 'src/svm/svm_fifo.c')
-rw-r--r--src/svm/svm_fifo.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index 7197e386dbd..83cad42ee9b 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -1281,8 +1281,8 @@ svm_fifo_provision_chunks (svm_fifo_t *f, svm_fifo_seg_t *fs, u32 n_segs,
}
int
-svm_fifo_segments (svm_fifo_t * f, u32 offset, svm_fifo_seg_t * fs,
- u32 n_segs, u32 max_bytes)
+svm_fifo_segments (svm_fifo_t *f, u32 offset, svm_fifo_seg_t *fs, u32 *n_segs,
+ u32 max_bytes)
{
u32 cursize, to_read, head, tail, fs_index = 1;
u32 n_bytes, head_pos, len, start;
@@ -1315,7 +1315,7 @@ svm_fifo_segments (svm_fifo_t * f, u32 offset, svm_fifo_seg_t * fs,
fs[0].len = clib_min (c->length - head_pos, to_read);
n_bytes = fs[0].len;
- while (n_bytes < to_read && fs_index < n_segs)
+ while (n_bytes < to_read && fs_index < *n_segs)
{
c = f_cptr (f, c->next);
len = clib_min (c->length, to_read - n_bytes);
@@ -1324,6 +1324,7 @@ svm_fifo_segments (svm_fifo_t * f, u32 offset, svm_fifo_seg_t * fs,
n_bytes += len;
fs_index += 1;
}
+ *n_segs = fs_index;
return n_bytes;
}