test/crypto-perf: populate mbuf in latency test
authorArchana Muniganti <marchana@marvell.com>
Fri, 8 Apr 2022 10:18:34 +0000 (15:48 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 29 Apr 2022 09:31:39 +0000 (11:31 +0200)
For decrypt, ICV mismatch can come as data is dummy and
latency will be calculated for error path. Hence populate
mbuf with test vector data.

Signed-off-by: Archana Muniganti <marchana@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test-crypto-perf/cperf_ops.c
app/test-crypto-perf/cperf_test_common.c
app/test-crypto-perf/cperf_test_common.h
app/test-crypto-perf/cperf_test_latency.c
app/test-crypto-perf/cperf_test_verify.c

index 7bb7a26..cbefce8 100644 (file)
@@ -620,7 +620,8 @@ cperf_set_ops_aead(struct rte_crypto_op **ops,
                }
        }
 
-       if (options->test == CPERF_TEST_TYPE_VERIFY) {
+       if ((options->test == CPERF_TEST_TYPE_VERIFY) ||
+                       (options->test == CPERF_TEST_TYPE_LATENCY)) {
                for (i = 0; i < nb_ops; i++) {
                        uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
                                        uint8_t *, iv_offset);
index 97a1ea4..00aadc9 100644 (file)
@@ -262,3 +262,39 @@ cperf_alloc_common_memory(const struct cperf_options *options,
 
        return 0;
 }
+
+void
+cperf_mbuf_set(struct rte_mbuf *mbuf,
+               const struct cperf_options *options,
+               const struct cperf_test_vector *test_vector)
+{
+       uint32_t segment_sz = options->segment_sz;
+       uint8_t *mbuf_data;
+       uint8_t *test_data;
+       uint32_t remaining_bytes = options->max_buffer_size;
+
+       if (options->op_type == CPERF_AEAD) {
+               test_data = (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
+                                       test_vector->plaintext.data :
+                                       test_vector->ciphertext.data;
+       } else {
+               test_data =
+                       (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
+                               test_vector->plaintext.data :
+                               test_vector->ciphertext.data;
+       }
+
+       while (remaining_bytes) {
+               mbuf_data = rte_pktmbuf_mtod(mbuf, uint8_t *);
+
+               if (remaining_bytes <= segment_sz) {
+                       memcpy(mbuf_data, test_data, remaining_bytes);
+                       return;
+               }
+
+               memcpy(mbuf_data, test_data, segment_sz);
+               remaining_bytes -= segment_sz;
+               test_data += segment_sz;
+               mbuf = mbuf->next;
+       }
+}
index 3ace0d2..a603a60 100644 (file)
@@ -21,4 +21,9 @@ cperf_alloc_common_memory(const struct cperf_options *options,
                        uint32_t *dst_buf_offset,
                        struct rte_mempool **pool);
 
+void
+cperf_mbuf_set(struct rte_mbuf *mbuf,
+               const struct cperf_options *options,
+               const struct cperf_test_vector *test_vector);
+
 #endif /* _CPERF_TEST_COMMON_H_ */
index 9ada431..6f972ce 100644 (file)
@@ -201,6 +201,12 @@ cperf_latency_test_runner(void *arg)
                                        ctx->test_vector, iv_offset,
                                        &imix_idx, &tsc_start);
 
+                       /* Populate the mbuf with the test vector */
+                       for (i = 0; i < burst_size; i++)
+                               cperf_mbuf_set(ops[i]->sym->m_src,
+                                               ctx->options,
+                                               ctx->test_vector);
+
                        tsc_start = rte_rdtsc_precise();
 
 #ifdef CPERF_LINEARIZATION_ENABLE
index c031330..5c0dc82 100644 (file)
@@ -195,42 +195,6 @@ out:
        return !!res;
 }
 
-static void
-cperf_mbuf_set(struct rte_mbuf *mbuf,
-               const struct cperf_options *options,
-               const struct cperf_test_vector *test_vector)
-{
-       uint32_t segment_sz = options->segment_sz;
-       uint8_t *mbuf_data;
-       uint8_t *test_data;
-       uint32_t remaining_bytes = options->max_buffer_size;
-
-       if (options->op_type == CPERF_AEAD) {
-               test_data = (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
-                                       test_vector->plaintext.data :
-                                       test_vector->ciphertext.data;
-       } else {
-               test_data =
-                       (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
-                               test_vector->plaintext.data :
-                               test_vector->ciphertext.data;
-       }
-
-       while (remaining_bytes) {
-               mbuf_data = rte_pktmbuf_mtod(mbuf, uint8_t *);
-
-               if (remaining_bytes <= segment_sz) {
-                       memcpy(mbuf_data, test_data, remaining_bytes);
-                       return;
-               }
-
-               memcpy(mbuf_data, test_data, segment_sz);
-               remaining_bytes -= segment_sz;
-               test_data += segment_sz;
-               mbuf = mbuf->next;
-       }
-}
-
 int
 cperf_verify_test_runner(void *test_ctx)
 {