[dpdk-dev] [PATCH v2 5/9] test/crypto: use existing algorithm strings

Pablo de Lara pablo.de.lara.guarch at intel.com
Thu Jun 22 14:02:31 CEST 2017


Instead of using duplicated functions to get the algorithm
strings, use the functions from the cryptodev library.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch at intel.com>
Acked-by: Fiona Trahe <fiona.trahe at intel.com>
---
 test/test/test_cryptodev_perf.c | 119 ++++++++++++----------------------------
 1 file changed, 36 insertions(+), 83 deletions(-)

diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 6be7012..7a90667 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -214,57 +214,6 @@ static const char *pmd_name(enum rte_cryptodev_type pmd)
 	}
 }
 
-static const char *cipher_algo_name(enum rte_crypto_cipher_algorithm cipher_algo)
-{
-	switch (cipher_algo) {
-	case RTE_CRYPTO_CIPHER_NULL: return "NULL";
-	case RTE_CRYPTO_CIPHER_3DES_CBC: return "3DES_CBC";
-	case RTE_CRYPTO_CIPHER_3DES_CTR: return "3DES_CTR";
-	case RTE_CRYPTO_CIPHER_3DES_ECB: return "3DES_ECB";
-	case RTE_CRYPTO_CIPHER_AES_CBC: return "AES_CBC";
-	case RTE_CRYPTO_CIPHER_AES_CCM: return "AES_CCM";
-	case RTE_CRYPTO_CIPHER_AES_CTR: return "AES_CTR";
-	case RTE_CRYPTO_CIPHER_AES_ECB: return "AES_ECB";
-	case RTE_CRYPTO_CIPHER_AES_F8: return "AES_F8";
-	case RTE_CRYPTO_CIPHER_AES_GCM: return "AES_GCM";
-	case RTE_CRYPTO_CIPHER_AES_XTS: return "AES_XTS";
-	case RTE_CRYPTO_CIPHER_ARC4: return "ARC4";
-	case RTE_CRYPTO_CIPHER_KASUMI_F8: return "KASUMI_F8";
-	case RTE_CRYPTO_CIPHER_SNOW3G_UEA2: return "SNOW3G_UEA2";
-	case RTE_CRYPTO_CIPHER_ZUC_EEA3: return "ZUC_EEA3";
-	default: return "Another cipher algo";
-	}
-}
-
-static const char *auth_algo_name(enum rte_crypto_auth_algorithm auth_algo)
-{
-	switch (auth_algo) {
-	case RTE_CRYPTO_AUTH_NULL: return "NULL"; break;
-	case RTE_CRYPTO_AUTH_AES_CBC_MAC: return "AES_CBC_MAC"; break;
-	case RTE_CRYPTO_AUTH_AES_CCM: return "AES_CCM"; break;
-	case RTE_CRYPTO_AUTH_AES_CMAC: return "AES_CMAC,"; break;
-	case RTE_CRYPTO_AUTH_AES_GCM: return "AES_GCM"; break;
-	case RTE_CRYPTO_AUTH_AES_GMAC: return "AES_GMAC"; break;
-	case RTE_CRYPTO_AUTH_AES_XCBC_MAC: return "AES_XCBC_MAC"; break;
-	case RTE_CRYPTO_AUTH_KASUMI_F9: return "KASUMI_F9"; break;
-	case RTE_CRYPTO_AUTH_MD5: return "MD5"; break;
-	case RTE_CRYPTO_AUTH_MD5_HMAC: return "MD5_HMAC,"; break;
-	case RTE_CRYPTO_AUTH_SHA1: return "SHA1"; break;
-	case RTE_CRYPTO_AUTH_SHA1_HMAC: return "SHA1_HMAC"; break;
-	case RTE_CRYPTO_AUTH_SHA224: return "SHA224"; break;
-	case RTE_CRYPTO_AUTH_SHA224_HMAC: return "SHA224_HMAC"; break;
-	case RTE_CRYPTO_AUTH_SHA256: return "SHA256"; break;
-	case RTE_CRYPTO_AUTH_SHA256_HMAC: return "SHA256_HMAC"; break;
-	case RTE_CRYPTO_AUTH_SHA384: return "SHA384,"; break;
-	case RTE_CRYPTO_AUTH_SHA384_HMAC: return "SHA384_HMAC,"; break;
-	case RTE_CRYPTO_AUTH_SHA512: return "SHA512,"; break;
-	case RTE_CRYPTO_AUTH_SHA512_HMAC: return "SHA512_HMAC,"; break;
-	case RTE_CRYPTO_AUTH_SNOW3G_UIA2: return "SNOW3G_UIA2"; break;
-	case RTE_CRYPTO_AUTH_ZUC_EIA3: return "RTE_CRYPTO_AUTH_ZUC_EIA3"; break;
-	default: return "Another auth algo"; break;
-	};
-}
-
 static struct rte_mbuf *
 setup_test_string(struct rte_mempool *mpool,
 		const uint8_t *data, size_t len, uint8_t blocksize)
@@ -2168,8 +2117,8 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 			pmd_name(gbl_cryptodev_perftest_devtype),
 			ts_params->dev_id, 0,
 			chain_mode_name(pparams->chain),
-			cipher_algo_name(pparams->cipher_algo),
-			auth_algo_name(pparams->auth_algo),
+			rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
+			rte_crypto_auth_algorithm_strings[pparams->auth_algo],
 			pparams->buf_size);
 	printf("\nOps Tx\tOps Rx\tOps/burst  ");
 	printf("Retries  EmptyPolls\tIACycles/CyOp\tIACycles/Burst\tIACycles/Byte");
@@ -2363,9 +2312,9 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 			pmd_name(gbl_cryptodev_perftest_devtype),
 			ts_params->dev_id, 0,
 			chain_mode_name(pparams->chain),
-			cipher_algo_name(pparams->cipher_algo),
+			rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
 			pparams->cipher_key_length,
-			auth_algo_name(pparams->auth_algo),
+			rte_crypto_auth_algorithm_strings[pparams->auth_algo],
 			pparams->buf_size);
 	printf("\nOps Tx\tOps Rx\tOps/burst  ");
 	printf("Retries  EmptyPolls\tIACycles/CyOp\tIACycles/Burst\t"
@@ -2498,9 +2447,9 @@ test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
 			pmd_name(gbl_cryptodev_perftest_devtype),
 			ts_params->dev_id, 0,
 			chain_mode_name(pparams->chain),
-			cipher_algo_name(pparams->cipher_algo),
+			rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
 			pparams->cipher_key_length,
-			auth_algo_name(pparams->auth_algo),
+			rte_crypto_auth_algorithm_strings[pparams->auth_algo],
 			pparams->buf_size);
 	printf("\nOps Tx\tOps Rx\tOps/burst  ");
 	printf("Retries  "
@@ -3792,12 +3741,12 @@ test_perf_aes_cbc_encrypt_digest_vary_pkt_size(void)
 		params_set[i].total_operations = total_operations;
 		params_set[i].burst_size = burst_size;
 		printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
-				" burst_size: %d ops\n",
-				chain_mode_name(params_set[i].chain),
-				cipher_algo_name(params_set[i].cipher_algo),
-				auth_algo_name(params_set[i].auth_algo),
-				params_set[i].cipher_key_length,
-				burst_size);
+			" burst_size: %d ops\n",
+			chain_mode_name(params_set[i].chain),
+			rte_crypto_cipher_algorithm_strings[params_set[i].cipher_algo],
+			rte_crypto_auth_algorithm_strings[params_set[i].auth_algo],
+			params_set[i].cipher_key_length,
+			burst_size);
 		printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
 			"Retries\tEmptyPolls\n");
 		for (j = 0; j < RTE_DIM(buf_lengths); j++) {
@@ -3842,13 +3791,17 @@ test_perf_snow3G_vary_pkt_size(void)
 		printf("\n\n");
 		params_set[i].total_operations = total_operations;
 		for (k = 0; k < RTE_DIM(burst_sizes); k++) {
+			enum rte_crypto_cipher_algorithm cipher_algo =
+				params_set[i].cipher_algo;
+			enum rte_crypto_auth_algorithm auth_algo =
+				params_set[i].auth_algo;
 			printf("\nOn %s dev%u qp%u, %s, "
 				"cipher algo:%s, auth algo:%s, burst_size: %d ops",
 				pmd_name(gbl_cryptodev_perftest_devtype),
 				testsuite_params.dev_id, 0,
 				chain_mode_name(params_set[i].chain),
-				cipher_algo_name(params_set[i].cipher_algo),
-				auth_algo_name(params_set[i].auth_algo),
+				rte_crypto_cipher_algorithm_strings[cipher_algo],
+				rte_crypto_auth_algorithm_strings[auth_algo],
 				burst_sizes[k]);
 
 			params_set[i].burst_size = burst_sizes[k];
@@ -3931,12 +3884,12 @@ test_perf_openssl_vary_pkt_size(void)
 		params_set[i].total_operations = total_operations;
 		params_set[i].burst_size = burst_size;
 		printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
-				" burst_size: %d ops\n",
-				chain_mode_name(params_set[i].chain),
-				cipher_algo_name(params_set[i].cipher_algo),
-				auth_algo_name(params_set[i].auth_algo),
-				params_set[i].cipher_key_length,
-				burst_size);
+			" burst_size: %d ops\n",
+			chain_mode_name(params_set[i].chain),
+			rte_crypto_cipher_algorithm_strings[params_set[i].cipher_algo],
+			rte_crypto_auth_algorithm_strings[params_set[i].auth_algo],
+			params_set[i].cipher_key_length,
+			burst_size);
 		printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\tRetries\t"
 				"EmptyPolls\n");
 		for (j = 0; j < RTE_DIM(buf_lengths); j++) {
@@ -4071,12 +4024,12 @@ test_perf_armv8_vary_pkt_size(void)
 		params_set[i].total_operations = total_operations;
 		params_set[i].burst_size = burst_size;
 		printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
-				" burst_size: %d ops\n",
-				chain_mode_name(params_set[i].chain),
-				cipher_algo_name(params_set[i].cipher_algo),
-				auth_algo_name(params_set[i].auth_algo),
-				params_set[i].cipher_key_length,
-				burst_size);
+			" burst_size: %d ops\n",
+			chain_mode_name(params_set[i].chain),
+			rte_crypto_cipher_algorithm_strings[params_set[i].cipher_algo],
+			rte_crypto_auth_algorithm_strings[params_set[i].auth_algo],
+			params_set[i].cipher_key_length,
+			burst_size);
 		printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\tRetries\t"
 				"EmptyPolls\n");
 		for (j = 0; j < RTE_DIM(buf_lengths); j++) {
@@ -4607,12 +4560,12 @@ test_perf_continual_performance_test(void)
 
 	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);
+			" burst_size: %d ops\n",
+			chain_mode_name(params_set.chain),
+			rte_crypto_cipher_algorithm_strings[params_set.cipher_algo],
+			rte_crypto_auth_algorithm_strings[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,
-- 
2.9.4



More information about the dev mailing list