1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2015, Linaro Limited
4  * All rights reserved.
5  */
6 
7 #ifndef XTEST_CRYPTO_COMMON_H
8 #define XTEST_CRYPTO_COMMON_H
9 
10 #include "ta_aes_perf.h"
11 #include "ta_hash_perf.h"
12 
13 
14 #define AES_PERF_INPLACE 0
15 
16 #define CRYPTO_DEF_LOOPS 1 /* Default amount of inner loops */
17 
18 #define CRYPTO_USE_ZEROS  0 /* Init input data to zero */
19 #define CRYPTO_USE_RANDOM 1 /* Get input data from /dev/urandom */
20 #define CRYPTO_NOT_INITED 2 /* Input data are not initialized */
21 
22 #define CRYPTO_DEF_WARMUP 2 /* Start with a 2-second busy loop  */
23 #define CRYPTO_DEF_COUNT 5000	/* Default number of measurements */
24 #define CRYPTO_DEF_VERBOSITY 0
25 #define CRYPTO_DEF_UNIT_SIZE 0 /* Process whole buffer */
26 
27 
28 #define _verbose(lvl, ...)			\
29 	do {					\
30 		if (verbosity >= lvl) {		\
31 			printf(__VA_ARGS__);	\
32 			fflush(stdout);		\
33 		}				\
34 	} while (0)
35 
36 #define verbose(...)  _verbose(1, __VA_ARGS__)
37 #define vverbose(...) _verbose(2, __VA_ARGS__)
38 
39 
40 int aes_perf_runner_cmd_parser(int argc, char *argv[]);
41 void aes_perf_run_test(int mode, int keysize, int decrypt, size_t size,
42 		       size_t unit, unsigned int n, unsigned int l,
43 		       int random_in, int in_place, int warmup, int verbosity);
44 
45 int hash_perf_runner_cmd_parser(int argc, char *argv[]);
46 void hash_perf_run_test(int algo, size_t size, unsigned int n,
47 				unsigned int l, int random_in, int offset,
48 				int warmup, int verbosity);
49 
50 #ifdef CFG_SECURE_DATA_PATH
51 int sdp_basic_runner_cmd_parser(int argc, char *argv[]);
52 #endif
53 
54 #endif /* XTEST_CRYPTO_PERF_H */
55