summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-10-11 11:05:04 -0700
committerDave Barach <openvpp@barachs.net>2020-10-12 15:03:01 +0000
commitd1cc38d5ad6d50de7e5589bda8ad68a6bf2c84a2 (patch)
tree95163d327da370d106323f9af252bb3f6b410c0c /src/vcl/vppcom.c
parent355791c13f7cbd943b4864b097cf3c9598d2db20 (diff)
vcl svm: segments improvements
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I717c64666972bb4e440cb3d1180a5cb26ee25577
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 56f50ad5cba..f1bb2b0def5 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1983,8 +1983,26 @@ vppcom_session_read_segments (uint32_t session_handle,
}
}
- n_read = svm_fifo_segments (rx_fifo, (svm_fifo_seg_t *) ds, n_segments,
- max_bytes);
+ n_read = svm_fifo_segments (rx_fifo, s->rx_bytes_pending,
+ (svm_fifo_seg_t *) ds, n_segments, max_bytes);
+ if (n_read < 0)
+ return VPPCOM_EAGAIN;
+
+ if (svm_fifo_max_dequeue_cons (rx_fifo) == n_read)
+ {
+ svm_fifo_unset_event (s->rx_fifo);
+ if (svm_fifo_max_dequeue_cons (rx_fifo) != n_read
+ && svm_fifo_set_event (s->rx_fifo)
+ && VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK))
+ {
+ session_event_t *e;
+ vec_add2 (wrk->unhandled_evts_vector, e, 1);
+ e->event_type = SESSION_IO_EVT_RX;
+ e->session_index = s->session_index;
+ }
+ }
+
+ s->rx_bytes_pending += n_read;
return n_read;
}
@@ -1999,19 +2017,9 @@ vppcom_session_free_segments (uint32_t session_handle, uint32_t n_bytes)
return;
svm_fifo_dequeue_drop (s->rx_fifo, n_bytes);
- if (svm_fifo_is_empty_cons (s->rx_fifo))
- {
- svm_fifo_unset_event (s->rx_fifo);
- if (!svm_fifo_is_empty_cons (s->rx_fifo)
- && svm_fifo_set_event (s->rx_fifo)
- && VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK))
- {
- session_event_t *e;
- vec_add2 (wrk->unhandled_evts_vector, e, 1);
- e->event_type = SESSION_IO_EVT_RX;
- e->session_index = s->session_index;
- }
- }
+
+ ASSERT (s->rx_bytes_pending < n_bytes);
+ s->rx_bytes_pending -= n_bytes;
}
static u8