summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/plugins/tlsopenssl/tls_openssl.c4
-rw-r--r--src/plugins/tlspicotls/tls_picotls.c12
-rw-r--r--src/svm/svm_fifo.c7
-rw-r--r--src/svm/svm_fifo.h4
-rw-r--r--src/vcl/vppcom.c2
5 files changed, 15 insertions, 14 deletions
diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c
index ac8529926bd..964230f178f 100644
--- a/src/plugins/tlsopenssl/tls_openssl.c
+++ b/src/plugins/tlsopenssl/tls_openssl.c
@@ -194,10 +194,10 @@ static int
openssl_write_from_fifo_into_ssl (svm_fifo_t *f, SSL *ssl, u32 max_len)
{
int wrote = 0, rv, i = 0, len;
- const int n_segs = 2;
+ u32 n_segs = 2;
svm_fifo_seg_t fs[n_segs];
- len = svm_fifo_segments (f, 0, fs, n_segs, max_len);
+ len = svm_fifo_segments (f, 0, fs, &n_segs, max_len);
if (len <= 0)
return 0;
diff --git a/src/plugins/tlspicotls/tls_picotls.c b/src/plugins/tlspicotls/tls_picotls.c
index ba1fdd8c05c..54a9d19fe65 100644
--- a/src/plugins/tlspicotls/tls_picotls.c
+++ b/src/plugins/tlspicotls/tls_picotls.c
@@ -224,14 +224,14 @@ picotls_do_handshake (picotls_ctx_t *ptls_ctx, session_t *tcp_session)
int rv = PTLS_ERROR_IN_PROGRESS, write = 0, i = 0, read = 0, len;
svm_fifo_t *tcp_rx_fifo = tcp_session->rx_fifo;
ptls_buffer_t *buf = &ptls_ctx->read_buffer;
- const int n_segs = 2, max_len = 16384;
+ u32 n_segs = 2, max_len = 16384;
ptls_t *tls = ptls_ctx->tls;
svm_fifo_seg_t fs[n_segs];
uword deq_now;
ptls_buffer_init (buf, "", 0);
- len = svm_fifo_segments (tcp_rx_fifo, 0, fs, n_segs, max_len);
+ len = svm_fifo_segments (tcp_rx_fifo, 0, fs, &n_segs, max_len);
if (len <= 0)
return 0;
@@ -309,7 +309,7 @@ ptls_tcp_to_app_write (picotls_ctx_t *ptls_ctx, svm_fifo_t *app_rx_fifo,
u32 ai = 0, thread_index, min_buf_len, to_copy, left, wrote = 0;
ptls_buffer_t *buf = &ptls_ctx->read_buffer;
int ret, i = 0, read = 0, tcp_len, n_fs_app;
- const int n_segs = 4, max_len = 1 << 16;
+ u32 n_segs = 4, max_len = 1 << 16;
svm_fifo_seg_t tcp_fs[n_segs], app_fs[n_segs];
picotls_main_t *pm = &picotls_main;
uword deq_now;
@@ -321,7 +321,7 @@ ptls_tcp_to_app_write (picotls_ctx_t *ptls_ctx, svm_fifo_t *app_rx_fifo,
if (n_fs_app <= 0)
return 0;
- tcp_len = svm_fifo_segments (tcp_rx_fifo, 0, tcp_fs, n_segs, max_len);
+ tcp_len = svm_fifo_segments (tcp_rx_fifo, 0, tcp_fs, &n_segs, max_len);
if (tcp_len <= 0)
return 0;
@@ -489,7 +489,7 @@ ptls_app_to_tcp_write (picotls_ctx_t *ptls_ctx, session_t *app_session,
{
u32 wrote = 0, max_enq, thread_index, app_buf_len, left, ti = 0;
int read = 0, rv, i = 0, len, n_tcp_segs = 4, deq_len;
- const int n_app_segs = 2, min_chunk = 2048;
+ u32 n_app_segs = 2, min_chunk = 2048;
svm_fifo_seg_t app_fs[n_app_segs], tcp_fs[n_tcp_segs];
picotls_main_t *pm = &picotls_main;
ptls_buffer_t _buf, *buf = &_buf;
@@ -500,7 +500,7 @@ ptls_app_to_tcp_write (picotls_ctx_t *ptls_ctx, session_t *app_session,
thread_index = app_session->thread_index;
app_tx_fifo = app_session->tx_fifo;
- len = svm_fifo_segments (app_tx_fifo, 0, app_fs, n_app_segs, max_len);
+ len = svm_fifo_segments (app_tx_fifo, 0, app_fs, &n_app_segs, max_len);
if (len <= 0)
return 0;
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;
}
diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h
index 9b55f720e5b..c4cc0382ab7 100644
--- a/src/svm/svm_fifo.h
+++ b/src/svm/svm_fifo.h
@@ -431,8 +431,8 @@ void svm_fifo_dequeue_drop_all (svm_fifo_t * f);
* @param max_bytes max bytes to be mapped to fifo segments
* @return number of bytes in fifo segments or SVM_FIFO_EEMPTY
*/
-int svm_fifo_segments (svm_fifo_t * f, u32 offset, svm_fifo_seg_t * fs,
- u32 n_segs, u32 max_bytes);
+int svm_fifo_segments (svm_fifo_t *f, u32 offset, svm_fifo_seg_t *fs,
+ u32 *n_segs, u32 max_bytes);
/**
* Add io events subscriber to list
*
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 44543bb86ef..4a6c46b3f3b 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -2084,7 +2084,7 @@ vppcom_session_read_segments (uint32_t session_handle,
}
n_read = svm_fifo_segments (rx_fifo, s->rx_bytes_pending,
- (svm_fifo_seg_t *) ds, n_segments, max_bytes);
+ (svm_fifo_seg_t *) ds, &n_segments, max_bytes);
if (n_read < 0)
return VPPCOM_EAGAIN;