app/crypto-perf: fix number of segments

Message ID 20221220045533.1401-1-anoobj@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series app/crypto-perf: fix number of segments |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing fail Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Anoob Joseph Dec. 20, 2022, 4:55 a.m. UTC
  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 <anoobj@marvell.com>
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test-crypto-perf/cperf_test_common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Patch

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);