aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-09-25 15:18:13 -0700
committerDamjan Marion <dmarion@me.com>2020-09-29 09:02:48 +0000
commitd68faf8559da72aa6ad0526d5a86fb16587b1508 (patch)
tree8438ccf4ef312017465f073e5b7086abdd094cf3 /src/vcl
parenta880b276d9998fa06c92355c4144fe3ca574c915 (diff)
vcl svm: provide apps access to fifo chunks
Type: feature Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I2191b8594b1e87ecc00f237316457db249f73603
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vppcom.c35
-rw-r--r--src/vcl/vppcom.h8
2 files changed, 21 insertions, 22 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 8a934c3686a..56f50ad5cba 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1929,7 +1929,8 @@ vppcom_session_peek (uint32_t session_handle, void *buf, int n)
int
vppcom_session_read_segments (uint32_t session_handle,
- vppcom_data_segments_t ds)
+ vppcom_data_segment_t * ds, uint32_t n_segments,
+ uint32_t max_bytes)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
int n_read = 0, is_nonblocking;
@@ -1982,15 +1983,13 @@ vppcom_session_read_segments (uint32_t session_handle,
}
}
- n_read = svm_fifo_segments (rx_fifo, (svm_fifo_seg_t *) ds);
- svm_fifo_unset_event (rx_fifo);
-
+ n_read = svm_fifo_segments (rx_fifo, (svm_fifo_seg_t *) ds, n_segments,
+ max_bytes);
return n_read;
}
void
-vppcom_session_free_segments (uint32_t session_handle,
- vppcom_data_segments_t ds)
+vppcom_session_free_segments (uint32_t session_handle, uint32_t n_bytes)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
vcl_session_t *s;
@@ -1999,20 +1998,20 @@ vppcom_session_free_segments (uint32_t session_handle,
if (PREDICT_FALSE (!s || s->is_vep))
return;
- svm_fifo_segments_free (s->rx_fifo, (svm_fifo_seg_t *) ds);
-}
-
-int
-vppcom_data_segment_copy (void *buf, vppcom_data_segments_t ds, u32 max_bytes)
-{
- u32 first_copy = clib_min (ds[0].len, max_bytes);
- clib_memcpy_fast (buf, ds[0].data, first_copy);
- if (first_copy < max_bytes)
+ svm_fifo_dequeue_drop (s->rx_fifo, n_bytes);
+ if (svm_fifo_is_empty_cons (s->rx_fifo))
{
- clib_memcpy_fast (buf + first_copy, ds[1].data,
- clib_min (ds[1].len, max_bytes - first_copy));
+ 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;
+ }
}
- return 0;
}
static u8
diff --git a/src/vcl/vppcom.h b/src/vcl/vppcom.h
index 61df64a6852..f4386682a1b 100644
--- a/src/vcl/vppcom.h
+++ b/src/vcl/vppcom.h
@@ -199,15 +199,15 @@ extern int vppcom_session_index (vcl_session_handle_t session_handle);
extern int vppcom_session_worker (vcl_session_handle_t session_handle);
extern int vppcom_session_read_segments (uint32_t session_handle,
- vppcom_data_segments_t ds);
+ vppcom_data_segment_t * ds,
+ uint32_t n_segments,
+ uint32_t max_bytes);
extern void vppcom_session_free_segments (uint32_t session_handle,
- vppcom_data_segments_t ds);
+ uint32_t n_bytes);
extern int vppcom_session_tls_add_cert (uint32_t session_handle, char *cert,
uint32_t cert_len);
extern int vppcom_session_tls_add_key (uint32_t session_handle, char *key,
uint32_t key_len);
-extern int vppcom_data_segment_copy (void *buf, vppcom_data_segments_t ds,
- uint32_t max_bytes);
extern int vppcom_unformat_proto (uint8_t * proto, char *proto_str);
extern int vppcom_session_is_connectable_listener (uint32_t session_handle);
extern int vppcom_session_listener (uint32_t session_handle);