app/test: add crypto continual performance tests
[dpdk.git] / app / test / test_cryptodev_perf.c
index e8fc097..e931ac5 100644 (file)
@@ -426,14 +426,12 @@ testsuite_setup(void)
 
        /*
         * Using Crypto Device Id 0 by default.
-        * Since we can't free and re-allocate queue memory always set the queues
-        * on this device up to max size first so enough memory is allocated for
-        * any later re-configures needed by other tests
+        * Set up all the qps on this device
         */
 
        rte_cryptodev_info_get(ts_params->dev_id, &info);
 
-       ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
+       ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
        ts_params->conf.socket_id = SOCKET_ID_ANY;
        ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
 
@@ -442,19 +440,6 @@ testsuite_setup(void)
                        "Failed to configure cryptodev %u",
                        ts_params->dev_id);
 
-
-       ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
-
-       for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
-               TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
-                       ts_params->dev_id, qp_id,
-                       &ts_params->qp_conf,
-                       rte_cryptodev_socket_id(ts_params->dev_id)),
-                       "Failed to setup queue pair %u on cryptodev %u",
-                       qp_id, ts_params->dev_id);
-       }
-
-       /*Now reconfigure queues to size we actually want to use in this testsuite.*/
        ts_params->qp_conf.nb_descriptors = PERF_NUM_OPS_INFLIGHT;
        for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
 
@@ -2737,9 +2722,12 @@ test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
        op->sym->auth.aad.length = AES_CIPHER_IV_LENGTH;
 
        /* Cipher Parameters */
-       op->sym->cipher.iv.data = aes_iv;
+       op->sym->cipher.iv.data = (uint8_t *)m->buf_addr + m->data_off;
+       op->sym->cipher.iv.phys_addr = rte_pktmbuf_mtophys(m);
        op->sym->cipher.iv.length = AES_CIPHER_IV_LENGTH;
 
+       rte_memcpy(op->sym->cipher.iv.data, aes_iv, AES_CIPHER_IV_LENGTH);
+
        /* Data lengths/offsets Parameters */
        op->sym->auth.data.offset = 0;
        op->sym->auth.data.length = data_len;
@@ -2908,7 +2896,9 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
                                rte_pktmbuf_free(mbufs[k]);
                        return -1;
                }
-
+               /* Make room for Digest and IV in mbuf */
+               rte_pktmbuf_append(mbufs[i], digest_length);
+               rte_pktmbuf_prepend(mbufs[i], AES_CIPHER_IV_LENGTH);
        }
 
 
@@ -3435,7 +3425,7 @@ test_perf_snow3G_vary_pkt_size(void)
 static int
 test_perf_libcrypto_vary_pkt_size(void)
 {
-       unsigned int total_operations = 1000000;
+       unsigned int total_operations = 10000;
        unsigned int burst_size = { 64 };
        unsigned int buf_lengths[] = { 64, 128, 256, 512, 768, 1024, 1280, 1536,
                        1792, 2048 };
@@ -3891,9 +3881,9 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
 }
 
 static int
-test_perf_AES_GCM(void)
+test_perf_AES_GCM(int continual_buf_len, int continual_size)
 {
-       uint16_t i, j;
+       uint16_t i, j, k, loops = 1;
 
        uint16_t buf_lengths[] = { 64, 128, 256, 512, 1024, 1536, 2048 };
 
@@ -3901,6 +3891,9 @@ test_perf_AES_GCM(void)
                        &AES_GCM_128_12IV_0AAD
        };
 
+       if (continual_buf_len)
+               loops = continual_size;
+
        int TEST_CASES_GCM = RTE_DIM(gcm_tests);
 
        const unsigned burst_size = 32;
@@ -3945,21 +3938,42 @@ test_perf_AES_GCM(void)
                params_set[i].chain = CIPHER_HASH;
                params_set[i].session_attrs = &session_attrs[i];
                params_set[i].symmetric_op = &ops_set[i];
-               params_set[i].total_operations = 1000000;
+               if (continual_buf_len)
+                       params_set[i].total_operations = 0xFFFFFF;
+               else
+                       params_set[i].total_operations = 1000000;
+
                params_set[i].burst_size = burst_size;
 
        }
 
+       if (continual_buf_len)
+               printf("\nCipher algo: %s Cipher hash: %s cipher key size: %ub"
+                       " burst size: %u", "AES_GCM", "AES_GCM",
+                       gcm_test->key.len << 3, burst_size);
+
        for (i = 0; i < RTE_DIM(gcm_tests); i++) {
 
-               printf("\nCipher algo: %s Cipher hash: %s cipher key size: %ub"
+               if (!continual_buf_len) {
+                       printf("\nCipher algo: %s Cipher hash: %s cipher key size: %ub"
                                " burst size: %u", "AES_GCM", "AES_GCM",
-                               gcm_test->key.len << 3, burst_size
-                               );
-               printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
-                       " Retries\tEmptyPolls");
+                               gcm_test->key.len << 3, burst_size);
+                       printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
+                               " Retries\tEmptyPolls");
+               }
 
-               for (j = 0; j < RTE_DIM(buf_lengths); ++j) {
+               uint16_t len = RTE_DIM(buf_lengths);
+               uint16_t p = 0;
+
+               if (continual_buf_len) {
+                       for (k = 0; k < RTE_DIM(buf_lengths); k++)
+                               if (buf_lengths[k] == continual_buf_len) {
+                                       len = k + 1;
+                                       p = k;
+                                       break;
+                               }
+               }
+               for (j = p; j < len; ++j) {
 
                        params_set[i].symmetric_op->c_len = buf_lengths[j];
                        params_set[i].symmetric_op->p_len = buf_lengths[j];
@@ -3974,9 +3988,18 @@ test_perf_AES_GCM(void)
                                        &params_set[i], 1))
                                return TEST_FAILED;
 
-                       if (perf_AES_GCM(testsuite_params.dev_id, 0,
-                                       &params_set[i], 0))
-                               return TEST_FAILED;
+                       for (k = 0; k < loops; k++) {
+                               if (continual_buf_len)
+                                       printf("\n\nBuffer Size(B)\tOPS(M)\t"
+                                               "Throughput(Gbps)\t"
+                                               "Retries\tEmptyPolls");
+                               if (perf_AES_GCM(testsuite_params.dev_id, 0,
+                                               &params_set[i], 0))
+                                       return TEST_FAILED;
+                               if (continual_buf_len)
+                                       printf("\n\nCompleted loop %i of %i ...",
+                                               k+1, loops);
+                       }
                }
 
        }
@@ -3984,6 +4007,70 @@ test_perf_AES_GCM(void)
        return 0;
 }
 
+static int test_cryptodev_perf_AES_GCM(void)
+{
+       return test_perf_AES_GCM(0, 0);
+}
+/*
+ * This function calls AES GCM performance tests providing
+ * size of packet as an argument. If size of packet is not
+ * in the buf_lengths array, all sizes will be used
+ */
+static int test_continual_perf_AES_GCM(void)
+{
+       return test_perf_AES_GCM(1024, 10);
+}
+
+static int
+test_perf_continual_performance_test(void)
+{
+       unsigned int total_operations = 0xFFFFFF;
+       unsigned int total_loops = 10;
+       unsigned int burst_size = 32;
+       uint8_t i;
+
+       struct perf_test_params params_set = {
+               .total_operations = total_operations,
+               .burst_size = burst_size,
+               .buf_size = 1024,
+
+               .chain = CIPHER_HASH,
+
+               .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
+               .cipher_key_length = 16,
+               .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
+       };
+
+       for (i = 1; i <= total_loops; ++i) {
+               printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
+                               " burst_size: %d ops\n",
+                               chain_mode_name(params_set.chain),
+                               cipher_algo_name(params_set.cipher_algo),
+                               auth_algo_name(params_set.auth_algo),
+                               params_set.cipher_key_length,
+                               burst_size);
+               printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
+                               "Retries\tEmptyPolls\n");
+                               test_perf_aes_sha(testsuite_params.dev_id, 0,
+                                       &params_set);
+               printf("\nCompleted loop %i of %i ...", i, total_loops);
+       }
+       return 0;
+}
+
+static struct unit_test_suite cryptodev_qat_continual_testsuite  = {
+       .suite_name = "Crypto Device Continual Performance Test",
+       .setup = testsuite_setup,
+       .teardown = testsuite_teardown,
+       .unit_test_cases = {
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                               test_perf_continual_performance_test),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                               test_continual_perf_AES_GCM),
+               TEST_CASES_END() /**< NULL terminate unit test array */
+       }
+};
+
 static struct unit_test_suite cryptodev_testsuite  = {
        .suite_name = "Crypto Device Unit Test Suite",
        .setup = testsuite_setup,
@@ -3992,7 +4079,7 @@ static struct unit_test_suite cryptodev_testsuite  = {
                TEST_CASE_ST(ut_setup, ut_teardown,
                                test_perf_aes_cbc_encrypt_digest_vary_pkt_size),
                TEST_CASE_ST(ut_setup, ut_teardown,
-                               test_perf_AES_GCM),
+                               test_cryptodev_perf_AES_GCM),
                TEST_CASE_ST(ut_setup, ut_teardown,
                                test_perf_aes_cbc_vary_burst_size),
                TEST_CASES_END() /**< NULL terminate unit test array */
@@ -4005,7 +4092,7 @@ static struct unit_test_suite cryptodev_gcm_testsuite  = {
        .teardown = testsuite_teardown,
        .unit_test_cases = {
                TEST_CASE_ST(ut_setup, ut_teardown,
-                               test_perf_AES_GCM),
+                               test_cryptodev_perf_AES_GCM),
                TEST_CASES_END() /**< NULL terminate unit test array */
        }
 };
@@ -4095,6 +4182,14 @@ perftest_libcrypto_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
        return unit_test_suite_runner(&cryptodev_libcrypto_testsuite);
 }
 
+static int
+perftest_qat_continual_cryptodev(void)
+{
+       gbl_cryptodev_perftest_devtype = RTE_CRYPTODEV_QAT_SYM_PMD;
+
+       return unit_test_suite_runner(&cryptodev_qat_continual_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_perftest, perftest_aesni_mb_cryptodev);
 REGISTER_TEST_COMMAND(cryptodev_qat_perftest, perftest_qat_cryptodev);
 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perftest, perftest_sw_snow3g_cryptodev);
@@ -4102,3 +4197,5 @@ REGISTER_TEST_COMMAND(cryptodev_qat_snow3g_perftest, perftest_qat_snow3g_cryptod
 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_perftest, perftest_aesni_gcm_cryptodev);
 REGISTER_TEST_COMMAND(cryptodev_libcrypto_perftest,
                perftest_libcrypto_cryptodev);
+REGISTER_TEST_COMMAND(cryptodev_qat_continual_perftest,
+               perftest_qat_continual_cryptodev);