app/crypto-perf: do not append digest if not used
[dpdk.git] / app / test-crypto-perf / cperf_test_throughput.c
index 6c04697..7108075 100644 (file)
@@ -45,8 +45,6 @@ struct cperf_throughput_results {
        uint64_t ops_enqueued_failed;
        uint64_t ops_dequeued_failed;
 
-       uint64_t ops_failed;
-
        double ops_per_second;
        double throughput_gbps;
        double cycles_per_byte;
@@ -67,7 +65,6 @@ struct cperf_throughput_ctx {
        struct rte_cryptodev_sym_session *sess;
 
        cperf_populate_ops_t populate_ops;
-       cperf_verify_crypto_op_t verify_op_output;
 
        const struct cperf_options *options;
        const struct cperf_test_vector *test_vector;
@@ -75,10 +72,6 @@ struct cperf_throughput_ctx {
 
 };
 
-struct cperf_op_result {
-       enum rte_crypto_op_status status;
-};
-
 static void
 cperf_throughput_test_free(struct cperf_throughput_ctx *ctx, uint32_t mbuf_nb)
 {
@@ -170,10 +163,12 @@ cperf_mbuf_create(struct rte_mempool *mempool,
                memcpy(mbuf_data, test_data, last_sz);
        }
 
-       mbuf_data = (uint8_t *)rte_pktmbuf_append(mbuf,
-                       options->auth_digest_sz);
-       if (mbuf_data == NULL)
-               goto error;
+       if (options->op_type != CPERF_CIPHER_ONLY) {
+               mbuf_data = (uint8_t *)rte_pktmbuf_append(mbuf,
+                               options->auth_digest_sz);
+               if (mbuf_data == NULL)
+                       goto error;
+       }
 
        if (options->op_type == CPERF_AEAD) {
                uint8_t *aead = (uint8_t *)rte_pktmbuf_prepend(mbuf,
@@ -297,112 +292,10 @@ err:
        return NULL;
 }
 
-static int
-cperf_throughput_test_verifier(struct rte_mbuf *mbuf,
-               const struct cperf_options *options,
-               const struct cperf_test_vector *vector)
-{
-       const struct rte_mbuf *m;
-       uint32_t len;
-       uint16_t nb_segs;
-       uint8_t *data;
-       uint32_t cipher_offset, auth_offset;
-       uint8_t cipher, auth;
-       int res = 0;
-
-       m = mbuf;
-       nb_segs = m->nb_segs;
-       len = 0;
-       while (m && nb_segs != 0) {
-               len += m->data_len;
-               m = m->next;
-               nb_segs--;
-       }
-
-       data = rte_malloc(NULL, len, 0);
-       if (data == NULL)
-               return 1;
-
-       m = mbuf;
-       nb_segs = m->nb_segs;
-       len = 0;
-       while (m && nb_segs != 0) {
-               memcpy(data + len, rte_pktmbuf_mtod(m, uint8_t *),
-                               m->data_len);
-               len += m->data_len;
-               m = m->next;
-               nb_segs--;
-       }
-
-       switch (options->op_type) {
-       case CPERF_CIPHER_ONLY:
-               cipher = 1;
-               cipher_offset = 0;
-               auth = 0;
-               auth_offset = 0;
-               break;
-       case CPERF_CIPHER_THEN_AUTH:
-               cipher = 1;
-               cipher_offset = 0;
-               auth = 1;
-               auth_offset = vector->plaintext.length;
-               break;
-       case CPERF_AUTH_ONLY:
-               cipher = 0;
-               cipher_offset = 0;
-               auth = 1;
-               auth_offset = vector->plaintext.length;
-               break;
-       case CPERF_AUTH_THEN_CIPHER:
-               cipher = 1;
-               cipher_offset = 0;
-               auth = 1;
-               auth_offset = vector->plaintext.length;
-               break;
-       case CPERF_AEAD:
-               cipher = 1;
-               cipher_offset = vector->aad.length;
-               auth = 1;
-               auth_offset = vector->aad.length + vector->plaintext.length;
-               break;
-       }
-
-       if (cipher == 1) {
-               if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
-                       res += memcmp(data + cipher_offset,
-                                       vector->ciphertext.data,
-                                       vector->ciphertext.length);
-               else
-                       res += memcmp(data + cipher_offset,
-                                       vector->plaintext.data,
-                                       vector->plaintext.length);
-       }
-
-       if (auth == 1) {
-               if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
-                       res += memcmp(data + auth_offset,
-                                       vector->digest.data,
-                                       vector->digest.length);
-       }
-
-       if (res != 0)
-               res = 1;
-
-       return res;
-}
-
 int
 cperf_throughput_test_runner(void *test_ctx)
 {
        struct cperf_throughput_ctx *ctx = test_ctx;
-       struct cperf_op_result *res, *pres;
-
-       if (ctx->options->verify) {
-               res = rte_malloc(NULL, sizeof(struct cperf_op_result) *
-                               ctx->options->total_ops, 0);
-               if (res == NULL)
-                       return 0;
-       }
 
        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;
@@ -410,7 +303,6 @@ cperf_throughput_test_runner(void *test_ctx)
        uint64_t i, m_idx = 0, tsc_start, tsc_end, tsc_duration;
 
        uint16_t ops_unused = 0;
-       uint64_t idx = 0;
 
        struct rte_crypto_op *ops[ctx->options->burst_sz];
        struct rte_crypto_op *ops_processed[ctx->options->burst_sz];
@@ -465,13 +357,6 @@ cperf_throughput_test_runner(void *test_ctx)
                                ops_needed, ctx->sess, ctx->options,
                                ctx->test_vector);
 
-               if (ctx->options->verify) {
-                       for (i = 0; i < ops_needed; i++) {
-                               ops[i]->opaque_data = (void *)&res[idx];
-                               idx++;
-                       }
-               }
-
 #ifdef CPERF_LINEARIZATION_ENABLE
                if (linearize) {
                        /* PMD doesn't support scatter-gather and source buffer
@@ -502,16 +387,6 @@ cperf_throughput_test_runner(void *test_ctx)
                                ops_processed, ctx->options->burst_sz);
 
                if (likely(ops_deqd))  {
-
-                       if (ctx->options->verify) {
-                               void *opq;
-                               for (i = 0; i < ops_deqd; i++) {
-                                       opq = (ops_processed[i]->opaque_data);
-                                       pres = (struct cperf_op_result *)opq;
-                                       pres->status = ops_processed[i]->status;
-                               }
-                       }
-
                        /* free crypto ops so they can be reused. We don't free
                         * the mbufs here as we don't want to reuse them as
                         * the crypto operation will change the data and cause
@@ -547,15 +422,6 @@ cperf_throughput_test_runner(void *test_ctx)
                if (ops_deqd == 0)
                        ops_deqd_failed++;
                else {
-                       if (ctx->options->verify) {
-                               void *opq;
-                               for (i = 0; i < ops_deqd; i++) {
-                                       opq = (ops_processed[i]->opaque_data);
-                                       pres = (struct cperf_op_result *)opq;
-                                       pres->status = ops_processed[i]->status;
-                               }
-                       }
-
                        for (i = 0; i < ops_deqd; i++)
                                rte_crypto_op_free(ops_processed[i]);
 
@@ -566,28 +432,6 @@ cperf_throughput_test_runner(void *test_ctx)
        tsc_end = rte_rdtsc_precise();
        tsc_duration = (tsc_end - tsc_start);
 
-       if (ctx->options->verify) {
-               struct rte_mbuf **mbufs;
-
-               if (ctx->options->out_of_place == 1)
-                       mbufs = ctx->mbufs_out;
-               else
-                       mbufs = ctx->mbufs_in;
-
-               for (i = 0; i < ctx->options->total_ops; i++) {
-
-                       if (res[i].status != RTE_CRYPTO_OP_STATUS_SUCCESS ||
-                                       cperf_throughput_test_verifier(
-                                       mbufs[i], ctx->options,
-                                       ctx->test_vector)) {
-
-                               ctx->results.ops_failed++;
-                       }
-               }
-
-               rte_free(res);
-       }
-
        /* Calculate average operations processed per second */
        ctx->results.ops_per_second = ((double)ctx->options->total_ops /
                        tsc_duration) * rte_get_tsc_hz();
@@ -596,7 +440,6 @@ cperf_throughput_test_runner(void *test_ctx)
        ctx->results.throughput_gbps = ((ctx->results.ops_per_second *
                        ctx->options->buffer_sz * 8) / 1000000000);
 
-
        /* Calculate average cycles per byte */
        ctx->results.cycles_per_byte =  ((double)tsc_duration /
                        ctx->options->total_ops) / ctx->options->buffer_sz;
@@ -611,7 +454,6 @@ cperf_throughput_test_runner(void *test_ctx)
 }
 
 
-
 void
 cperf_throughput_test_destructor(void *arg)
 {