cryptodev: move IV parameters to session
[dpdk.git] / app / test-crypto-perf / cperf_test_throughput.c
index 70ec4ff..d043f60 100644 (file)
@@ -195,7 +195,11 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
        ctx->options = options;
        ctx->test_vector = test_vector;
 
-       ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+       /* IV goes at the end of the cryptop operation */
+       uint16_t iv_offset = sizeof(struct rte_crypto_op) +
+               sizeof(struct rte_crypto_sym_op);
+
+       ctx->sess = op_fns->sess_create(dev_id, options, test_vector, iv_offset);
        if (ctx->sess == NULL)
                goto err;
 
@@ -262,9 +266,11 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
        snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d",
                        dev_id);
 
+       uint16_t priv_size = test_vector->iv.length;
+
        ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name,
-                       RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 0, 0,
-                       rte_socket_id());
+                       RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz,
+                       512, priv_size, rte_socket_id());
        if (ctx->crypto_op_pool == NULL)
                goto err;
 
@@ -315,6 +321,9 @@ cperf_throughput_test_runner(void *test_ctx)
        else
                test_burst_size = ctx->options->burst_size_list[0];
 
+       uint16_t iv_offset = sizeof(struct rte_crypto_op) +
+               sizeof(struct rte_crypto_sym_op);
+
        while (test_burst_size <= ctx->options->max_burst_size) {
                uint64_t ops_enqd = 0, ops_enqd_total = 0, ops_enqd_failed = 0;
                uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0;
@@ -346,7 +355,20 @@ cperf_throughput_test_runner(void *test_ctx)
                        (ctx->populate_ops)(ops, &ctx->mbufs_in[m_idx],
                                        &ctx->mbufs_out[m_idx],
                                        ops_needed, ctx->sess, ctx->options,
-                                       ctx->test_vector);
+                                       ctx->test_vector, iv_offset);
+
+                       /**
+                        * When ops_needed is smaller than ops_enqd, the
+                        * unused ops need to be moved to the front for
+                        * next round use.
+                        */
+                       if (unlikely(ops_enqd > ops_needed)) {
+                               size_t nb_b_to_mov = ops_unused * sizeof(
+                                               struct rte_crypto_op *);
+
+                               memmove(&ops[ops_needed], &ops[ops_enqd],
+                                       nb_b_to_mov);
+                       }
 
 #ifdef CPERF_LINEARIZATION_ENABLE
                        if (linearize) {
@@ -383,8 +405,8 @@ cperf_throughput_test_runner(void *test_ctx)
                                 * the crypto operation will change the data and cause
                                 * failures.
                                 */
-                               for (i = 0; i < ops_deqd; i++)
-                                       rte_crypto_op_free(ops_processed[i]);
+                               rte_mempool_put_bulk(ctx->crypto_op_pool,
+                                               (void **)ops_processed, ops_deqd);
 
                                ops_deqd_total += ops_deqd;
                        } else {
@@ -413,8 +435,8 @@ cperf_throughput_test_runner(void *test_ctx)
                        if (ops_deqd == 0)
                                ops_deqd_failed++;
                        else {
-                               for (i = 0; i < ops_deqd; i++)
-                                       rte_crypto_op_free(ops_processed[i]);
+                               rte_mempool_put_bulk(ctx->crypto_op_pool,
+                                               (void **)ops_processed, ops_deqd);
 
                                ops_deqd_total += ops_deqd;
                        }