When segment size is provided, the total number of segments would be
calculated. Segment size updates due to headroom/tailroom need to be
accounted for when determining total number of segments required.

Fixes: c1670ae0022b ("app/crypto-perf: honour min headroom/tailroom")

Signed-off-by: Anoob Joseph <ano...@marvell.com>
Signed-off-by: Akhil Goyal <gak...@marvell.com>
---
 app/test-crypto-perf/cperf_test_common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/test-crypto-perf/cperf_test_common.c 
b/app/test-crypto-perf/cperf_test_common.c
index 00aadc9a47..cc03b33ac5 100644
--- a/app/test-crypto-perf/cperf_test_common.c
+++ b/app/test-crypto-perf/cperf_test_common.c
@@ -198,9 +198,11 @@ cperf_alloc_common_memory(const struct cperf_options 
*options,
                                RTE_CACHE_LINE_ROUNDUP(crypto_op_total_size);
        uint32_t mbuf_size = sizeof(struct rte_mbuf) + options->segment_sz;
        uint32_t max_size = options->max_buffer_size + options->digest_sz;
-       uint16_t segments_nb = (max_size % options->segment_sz) ?
-                       (max_size / options->segment_sz) + 1 :
-                       max_size / options->segment_sz;
+       uint32_t segment_data_len = options->segment_sz - options->headroom_sz -
+                                   options->tailroom_sz;
+       uint16_t segments_nb = (max_size % segment_data_len) ?
+                               (max_size / segment_data_len) + 1 :
+                               (max_size / segment_data_len);
        uint32_t obj_size = crypto_op_total_size_padded +
                                (mbuf_size * segments_nb);
 
-- 
2.25.1

Reply via email to