diff options
author | Florin Coras <fcoras@cisco.com> | 2020-09-25 15:18:13 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-09-29 09:02:48 +0000 |
commit | d68faf8559da72aa6ad0526d5a86fb16587b1508 (patch) | |
tree | 8438ccf4ef312017465f073e5b7086abdd094cf3 /src/plugins/hs_apps/vcl | |
parent | a880b276d9998fa06c92355c4144fe3ca574c915 (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/plugins/hs_apps/vcl')
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test.h | 5 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_server.c | 23 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h index c6b9230e6c9..6bb3446cf48 100644 --- a/src/plugins/hs_apps/vcl/vcl_test.h +++ b/src/plugins/hs_apps/vcl/vcl_test.h @@ -444,7 +444,8 @@ vcl_test_read (int fd, uint8_t * buf, uint32_t nbytes, } static inline int -vcl_test_read_ds (int fd, vppcom_data_segments_t ds, vcl_test_stats_t * stats) +vcl_test_read_ds (int fd, vppcom_data_segment_t * ds, + vcl_test_stats_t * stats) { int rx_bytes; @@ -452,7 +453,7 @@ vcl_test_read_ds (int fd, vppcom_data_segments_t ds, vcl_test_stats_t * stats) { if (stats) stats->rx_xacts++; - rx_bytes = vppcom_session_read_segments (fd, ds); + rx_bytes = vppcom_session_read_segments (fd, ds, 2, ~0); if (rx_bytes < 0) { diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c index af5b914cdac..d55fef30e89 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_server.c +++ b/src/plugins/hs_apps/vcl/vcl_test_server.c @@ -38,7 +38,7 @@ typedef struct vcl_test_stats_t stats; vppcom_endpt_t endpt; uint8_t ip[16]; - vppcom_data_segments_t ds; + vppcom_data_segment_t ds[2]; } vcl_test_server_conn_t; typedef struct @@ -246,20 +246,33 @@ vts_server_rx (vcl_test_server_conn_t * conn, int rx_bytes) } if (vsm->use_ds) - vppcom_session_free_segments (conn->fd, conn->ds); + vppcom_session_free_segments (conn->fd, rx_bytes); if (conn->stats.rx_bytes >= conn->cfg.total_bytes) clock_gettime (CLOCK_REALTIME, &conn->stats.stop); } static void +vts_copy_ds (void *buf, vppcom_data_segment_t * ds, u32 max_bytes) +{ + uint32_t n_bytes = 0, ds_idx = 0; + + while (n_bytes < max_bytes) + { + clib_memcpy_fast (buf + n_bytes, ds[ds_idx].data, + clib_min (ds[ds_idx].len, max_bytes - n_bytes)); + ds_idx += 1; + } +} + +static void vts_server_echo (vcl_test_server_conn_t * conn, int rx_bytes) { vcl_test_server_main_t *vsm = &vcl_server_main; int tx_bytes, nbytes, pos; if (vsm->use_ds) - vppcom_data_segment_copy (conn->buf, conn->ds, rx_bytes); + vts_copy_ds (conn->buf, conn->ds, rx_bytes); /* If it looks vaguely like a string, make sure it's terminated */ pos = rx_bytes < conn->buf_size ? rx_bytes : conn->buf_size - 1; @@ -590,7 +603,7 @@ vts_conn_read_config (vcl_test_server_conn_t * conn) { /* We could avoid the copy if the first segment is big enough but this * just simplifies things */ - vppcom_data_segment_copy (conn->buf, conn->ds, sizeof (vcl_test_cfg_t)); + vts_copy_ds (conn->buf, conn->ds, sizeof (vcl_test_cfg_t)); } return (vcl_test_cfg_t *) conn->buf; } @@ -692,7 +705,7 @@ vts_worker_loop (void *arg) if (rx_cfg->magic == VCL_TEST_CFG_CTRL_MAGIC) { if (vsm->use_ds) - vppcom_session_free_segments (conn->fd, conn->ds); + vppcom_session_free_segments (conn->fd, rx_bytes); vts_handle_cfg (wrk, rx_cfg, conn, rx_bytes); if (!wrk->nfds) { |