aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl
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
parent355791c13f7cbd943b4864b097cf3c9598d2db20 (diff)
vcl svm: segments improvements
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I717c64666972bb4e440cb3d1180a5cb26ee25577
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vcl_private.h2
-rw-r--r--src/vcl/vppcom.c38
2 files changed, 25 insertions, 15 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 51bdd65a102..89151faa316 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -184,6 +184,8 @@ typedef struct
int libc_epfd;
svm_msg_q_t *our_evt_q;
vcl_session_msg_t *accept_evts_fifo;
+ /** bytes delivered as segment but not yet freed */
+ u32 rx_bytes_pending;
#if VCL_ELOG
elog_track_t elog_track;
#endif
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