diff options
author | Chunrong Guo <chunrong.guo@nxp.com> | 2017-04-18 15:11:50 +0800 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2017-05-02 17:54:58 -0300 |
commit | e756964ac2595d880304f227dec7bdb424d7d974 (patch) | |
tree | 28c067a5652216278a92e39144d48ac95f0e8f12 /recipes-kernel | |
parent | cfb3ddaaaa78204ef5281c8627eed08f4f7e3f09 (diff) | |
download | meta-freescale-e756964ac2595d880304f227dec7bdb424d7d974.tar.gz |
cryptodev: update to 6c2b61c
**include the following changes
6c2b61c - update copyright notes
f79d523 - fix: reset finish condition before test start
e8f7a91 - Merge remote-tracking branch 'upstream/master'
6818263 - Fix ablkcipher algorithms usage in v4.8+ kernels
26e167f - zc: Use the power of #elif
e49fe25 - adjust to API changes in kernel >=4.10
2b29be8 - adjust to API changes in kernel >=4.10
c3afb40 - add support for rsa speed tests
c9b7a80 - close the session after every test
ba49470 - add support for authenc(hmac(sha1), cbc(aes)) speed tests
690cd62 - Merge branch 'master' into hpe2016
5adf04e - Merge remote-tracking branch 'upstream/master'
840c7ba - remove not used variable
2dbbb23 - do more strict code checking to avoid maintenance issues
88223e4 - avoid implicit conversion between signed and unsigned char
8db6905 - use buf_align macro to reduce code duplication
b6d0e0f - rename header file to clarify purpose
1fd6062 - fix warnings of "implicit declaration of function" in async_speed
ff3c8ab - remove not used local variables
25a1276 - fix incorrect return code in case of error from openssl_cioccrypt
e7ef4ea - Merge pull request #17 from michaelweiser/gup_flags
99c6d21 - fix ignored SIGALRM signals on some platforms
71975fa - setting KERNEL_DIR is not necessary to build tests
a96ff97 - fix issues with install target
07748d3 - Merge branch 'master' into hpe2016
cc89148 - Fix ablkcipher algorithms usage in v4.8+ kernels
4d6e4fb - Merge remote-tracking branch 'upstream/master'
f126e48 - Adjust to another change in the user page API
4257fce - add -async option to run_crypto_tests.sh
f953164 - merge sync and async benchmarks into a single program
e7af57b - add % to cpu idle for convenience
1883c95 - add a wrapper script for running all tests
998b66b - add notes about configured limits in SEC driver
b1a35f3 - fix ignored SIGALRM signals on some platforms
b754517 - use the same algorithm names in sync_speed as in async_speed
8baefa4 - force LC_TIME value to avoid mpstat not using ISO8601 format
d0978b5 - add sync speed tests with the same format as async ones
15d890b - graceful exit if cryptodev is not built with ASYNC flags
9a595bf - fix typo, use consistent spacing
9461878 - remove output line because it does not add clarity to the results
b09c17f - the C standard used by cryptodev is C90 with GNU extensions
447808d - exit early if cryptodev tests are not installed
493afd3 - fix incorrect handling of error cases...
e0d2c88 - make default output tabular
abc007a - really fix (again...) the mpstat issue
2696cd5 - use $(...) instead of `...` for consistency
e8fb004 - fix the scale of the runtime value
119151b - remove old results to avoid incorrect reports
71ac3d5 - fix the reported unit
8c47a0c - setting KERNEL_DIR is not necessary to build tests
182b307 - fix issues with install target
5021828 - do more strict code checking to avoid maintenance issues
ab239d7 - return error code of the test if there is one
b5228f2 - remove not used local variables
90d67ce - avoid implicit conversion between signed and unsigned char
4b442ca - fix build warnings on implicit function declarations
2821b92 - add a little space in the output for clarity
9d0ef05 - more precision in running mpstat
0180e2b - fix some issues with parsing mpstat output
4257fce - add -async option to run_crypto_tests.sh
f953164 - merge sync and async benchmarks into a single program
e7af57b - add % to cpu idle for convenience
7d7a733 - sanity check on /dev/crypto availability
137c0c4 - gracefull stop for async speed tests
600eb70 - fix: set min value when allocating alligned memory buffers
18408c9 - add multithreaded wrapper for async speed test
854cc84 - rename algorithm names for clarity
216f235 - honor the -m flag in async_speed
1023ede - add flag to report in a machine friendly format
219a8b4 - enable async code by default
9def784 - Merge remote-tracking branch 'radualexe/new_tests`
149dc1c - add basic optargs support for async_speed test
9595499 - add support for crc32c hash sync speed test
83e3840 - add support for aes-256-xts sync speed test
fff72ae - add support for sha2-256 hash async speed test
b961800 - add support for sha1 hash async speed test
fea5006 - add support for crc32c hash async speed test
8768fad - add aes-256-xts support for async speed test
Signed-off-by: Chunrong Guo <B40290@freescale.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'recipes-kernel')
65 files changed, 8303 insertions, 13 deletions
diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc b/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc index 4c7cb93a..b55a33c4 100644 --- a/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc +++ b/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc | |||
@@ -64,7 +64,70 @@ file://0040-fix-structure-init-in-sha_speed-test.patch \ | |||
64 | file://0041-add-separate-target-for-building-tests.patch \ | 64 | file://0041-add-separate-target-for-building-tests.patch \ |
65 | file://0042-fix-destination-for-staged-installs.patch \ | 65 | file://0042-fix-destination-for-staged-installs.patch \ |
66 | file://0043-add-install-target-for-tests.patch \ | 66 | file://0043-add-install-target-for-tests.patch \ |
67 | file://0044-add-aes-256-xts-support-for-async-speed-test.patch \ | ||
68 | file://0045-add-support-for-crc32c-hash-async-speed-test.patch \ | ||
69 | file://0046-add-support-for-sha1-hash-async-speed-test.patch \ | ||
70 | file://0047-add-support-for-sha2-256-hash-async-speed-test.patch \ | ||
71 | file://0048-add-support-for-aes-256-xts-sync-speed-test.patch \ | ||
72 | file://0049-add-support-for-crc32c-hash-sync-speed-test.patch \ | ||
73 | file://0050-add-basic-optargs-support-for-async_speed-test.patch \ | ||
74 | file://0051-enable-async-code-by-default.patch \ | ||
75 | file://0052-add-flag-to-report-in-a-machine-friendly-format.patch \ | ||
76 | file://0053-honor-the-m-flag-in-async_speed.patch \ | ||
77 | file://0054-rename-algorithm-names-for-clarity.patch \ | ||
78 | file://0055-add-multithreaded-wrapper-for-async-speed-test.patch \ | ||
79 | file://0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch \ | ||
80 | file://0057-gracefull-stop-for-async-speed-tests.patch \ | ||
81 | file://0058-sanity-check-on-dev-crypto-availability.patch \ | ||
82 | file://0059-fix-some-issues-with-parsing-mpstat-output.patch \ | ||
83 | file://0060-more-precision-in-running-mpstat.patch \ | ||
84 | file://0061-add-a-little-space-in-the-output-for-clarity.patch \ | ||
85 | file://0062-fix-build-warnings-on-implicit-function-declarations.patch \ | ||
86 | file://0063-avoid-implicit-conversion-between-signed-and-unsigne.patch \ | ||
87 | file://0064-remove-not-used-local-variables.patch \ | ||
88 | file://0065-return-error-code-of-the-test-if-there-is-one.patch \ | ||
89 | file://0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch \ | ||
90 | file://0067-fix-issues-with-install-target.patch \ | ||
91 | file://0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch \ | ||
92 | file://0069-fix-the-reported-unit.patch \ | ||
93 | file://0070-remove-old-results-to-avoid-incorrect-reports.patch \ | ||
94 | file://0071-fix-the-scale-of-the-runtime-value.patch \ | ||
95 | file://0072-use-.-instead-of-.-for-consistency.patch \ | ||
96 | file://0073-really-fix-again.-the-mpstat-issue.patch \ | ||
97 | file://0074-make-default-output-tabular.patch \ | ||
98 | file://0075-fix-incorrect-handling-of-error-cases.patch \ | ||
99 | file://0076-exit-early-if-cryptodev-tests-are-not-installed.patch \ | ||
100 | file://0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch \ | ||
101 | file://0078-remove-output-line-because-it-does-not-add-clarity-t.patch \ | ||
102 | file://0079-fix-typo-use-consistent-spacing.patch \ | ||
103 | file://0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch \ | ||
104 | file://0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch \ | ||
105 | file://0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch \ | ||
106 | file://0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch \ | ||
107 | file://0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch \ | ||
108 | file://0085-add-notes-about-configured-limits-in-SEC-driver.patch \ | ||
109 | file://0086-add-a-wrapper-script-for-running-all-tests.patch \ | ||
110 | file://0087-add-to-cpu-idle-for-convenience.patch \ | ||
111 | file://0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch \ | ||
112 | file://0089-add-async-option-to-run_crypto_tests.sh.patch \ | ||
113 | file://0090-Adjust-to-recent-user-page-API-changes.patch \ | ||
114 | file://0091-Fix-test-compile-time-warnings.patch \ | ||
115 | file://0092-Support-skcipher-in-addition-to-ablkcipher-API.patch \ | ||
116 | file://0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch \ | ||
117 | file://0094-Adjust-to-another-change-in-the-user-page-API.patch \ | ||
118 | file://0095-rename-header-file-to-clarify-purpose.patch \ | ||
119 | file://0096-use-buf_align-macro-to-reduce-code-duplication.patch \ | ||
120 | file://0097-avoid-implicit-conversion-between-signed-and-unsigne.patch \ | ||
121 | file://0098-reduce-tests-Makefile-distance-with-upstream.patch \ | ||
122 | file://0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch \ | ||
123 | file://0100-close-the-session-after-every-test.patch \ | ||
124 | file://0101-add-support-for-rsa-speed-tests.patch \ | ||
125 | file://0102-adjust-to-API-changes-in-kernel-4.10.patch \ | ||
126 | file://0103-zc-Use-the-power-of-elif.patch \ | ||
127 | file://0104-fix-reset-finish-condition-before-test-start.patch \ | ||
128 | file://0105-update-copyright-notes.patch \ | ||
67 | " | 129 | " |
130 | SRC_URI_append = " file://0003-update-the-install-path-for-cryptodev-tests.patch" | ||
68 | 131 | ||
69 | # NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc | 132 | # NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc |
70 | # if pkc-host does not need customized cryptodev patches anymore | 133 | # if pkc-host does not need customized cryptodev patches anymore |
diff --git a/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch new file mode 100644 index 00000000..8a3c4f24 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch | |||
@@ -0,0 +1,64 @@ | |||
1 | From 6a89ac4c49068d4225f4c1cc94a1d20b3d174b3f Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <raduandrei.alexe@freescale.com> | ||
3 | Date: Sat, 22 Oct 2016 21:55:25 +0300 | ||
4 | Subject: [PATCH 044/104] add aes-256-xts support for async speed test | ||
5 | |||
6 | Signed-off-by: Radu Alexe <raduandrei.alexe@freescale.com> | ||
7 | --- | ||
8 | ioctl.c | 3 +++ | ||
9 | tests/async_speed.c | 25 +++++++++++++++++++++++++ | ||
10 | 2 files changed, 28 insertions(+) | ||
11 | |||
12 | diff --git a/ioctl.c b/ioctl.c | ||
13 | index 8d81b56..ca3c5ac 100644 | ||
14 | --- a/ioctl.c | ||
15 | +++ b/ioctl.c | ||
16 | @@ -172,6 +172,9 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
17 | case CRYPTO_AES_ECB: | ||
18 | alg_name = "ecb(aes)"; | ||
19 | break; | ||
20 | + case CRYPTO_AES_XTS: | ||
21 | + alg_name = "xts(aes)"; | ||
22 | + break; | ||
23 | case CRYPTO_CAMELLIA_CBC: | ||
24 | alg_name = "cbc(camellia)"; | ||
25 | break; | ||
26 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
27 | index 1188599..39a3d23 100644 | ||
28 | --- a/tests/async_speed.c | ||
29 | +++ b/tests/async_speed.c | ||
30 | @@ -211,6 +211,31 @@ int main(void) | ||
31 | break; | ||
32 | } | ||
33 | |||
34 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
35 | + memset(&sess, 0, sizeof(sess)); | ||
36 | + sess.cipher = CRYPTO_AES_XTS; | ||
37 | + sess.keylen = 32; | ||
38 | + memset(keybuf, 0x42, sess.keylen); | ||
39 | + sess.key = (unsigned char *)keybuf; | ||
40 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
41 | + perror("ioctl(CIOCGSESSION)"); | ||
42 | + return 1; | ||
43 | + } | ||
44 | +#ifdef CIOCGSESSINFO | ||
45 | + siop.ses = sess.ses; | ||
46 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
47 | + perror("ioctl(CIOCGSESSION)"); | ||
48 | + return 1; | ||
49 | + } | ||
50 | + alignmask = siop.alignmask; | ||
51 | +#endif | ||
52 | + | ||
53 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
54 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
55 | + break; | ||
56 | + } | ||
57 | + | ||
58 | +end: | ||
59 | close(fdc); | ||
60 | close(fd); | ||
61 | return 0; | ||
62 | -- | ||
63 | 2.10.2 | ||
64 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch new file mode 100644 index 00000000..b1a790eb --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch | |||
@@ -0,0 +1,92 @@ | |||
1 | From aa329106f586f8d055ceaa919e327ebc99bdd6e3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:15:37 +0300 | ||
4 | Subject: [PATCH 045/104] add support for crc32c hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | crypto/cryptodev.h | 1 + | ||
9 | ioctl.c | 4 ++++ | ||
10 | tests/async_speed.c | 25 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 30 insertions(+) | ||
12 | |||
13 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
14 | index 9ade102..05221a4 100644 | ||
15 | --- a/crypto/cryptodev.h | ||
16 | +++ b/crypto/cryptodev.h | ||
17 | @@ -46,6 +46,7 @@ enum cryptodev_crypto_op_t { | ||
18 | CRYPTO_AES_XTS = 22, | ||
19 | CRYPTO_AES_ECB = 23, | ||
20 | CRYPTO_AES_GCM = 50, | ||
21 | + CRYPTO_CRC32C, | ||
22 | |||
23 | CRYPTO_CAMELLIA_CBC = 101, | ||
24 | CRYPTO_RIPEMD160, | ||
25 | diff --git a/ioctl.c b/ioctl.c | ||
26 | index ca3c5ac..2e2bdeb 100644 | ||
27 | --- a/ioctl.c | ||
28 | +++ b/ioctl.c | ||
29 | @@ -286,6 +286,10 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
30 | hash_name = "sha512"; | ||
31 | hmac_mode = 0; | ||
32 | break; | ||
33 | + case CRYPTO_CRC32C: | ||
34 | + hash_name = "crc32c"; | ||
35 | + hmac_mode = 0; | ||
36 | + break; | ||
37 | default: | ||
38 | ddebug(1, "bad mac: %d", sop->mac); | ||
39 | return -EINVAL; | ||
40 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
41 | index 39a3d23..8978b4b 100644 | ||
42 | --- a/tests/async_speed.c | ||
43 | +++ b/tests/async_speed.c | ||
44 | @@ -65,6 +65,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
45 | { | ||
46 | struct crypt_op cop; | ||
47 | char *buffer[64], iv[32]; | ||
48 | + char mac[64][HASH_MAX_LEN]; | ||
49 | static int val = 23; | ||
50 | struct timeval start, end; | ||
51 | double total = 0; | ||
52 | @@ -114,6 +115,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
53 | cop.iv = (unsigned char *)iv; | ||
54 | cop.op = COP_ENCRYPT; | ||
55 | cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
56 | + cop.mac = mac[bufidx]; | ||
57 | bufidx = (bufidx + 1) % 64; | ||
58 | |||
59 | if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
60 | @@ -235,6 +237,29 @@ int main(void) | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
65 | + memset(&sess, 0, sizeof(sess)); | ||
66 | + sess.mac = CRYPTO_CRC32C; | ||
67 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
68 | + perror("ioctl(CIOCGSESSION)"); | ||
69 | + return 1; | ||
70 | + } | ||
71 | +#ifdef CIOCGSESSINFO | ||
72 | + siop.ses = sess.ses; | ||
73 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
74 | + perror("ioctl(CIOCGSESSION)"); | ||
75 | + return 1; | ||
76 | + } | ||
77 | + printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
78 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
79 | + alignmask = siop.alignmask; | ||
80 | +#endif | ||
81 | + | ||
82 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
83 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
84 | + break; | ||
85 | + } | ||
86 | + | ||
87 | end: | ||
88 | close(fdc); | ||
89 | close(fd); | ||
90 | -- | ||
91 | 2.10.2 | ||
92 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch new file mode 100644 index 00000000..fb902fbd --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From c2fed59ef63a1b9da26e8a5452004b07aad39261 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:21:47 +0300 | ||
4 | Subject: [PATCH 046/104] add support for sha1 hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 23 +++++++++++++++++++++++ | ||
9 | 1 file changed, 23 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 8978b4b..64d5603 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -260,6 +260,29 @@ int main(void) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.mac = CRYPTO_SHA1; | ||
22 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
23 | + perror("ioctl(CIOCGSESSION)"); | ||
24 | + return 1; | ||
25 | + } | ||
26 | +#ifdef CIOCGSESSINFO | ||
27 | + siop.ses = sess.ses; | ||
28 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
29 | + perror("ioctl(CIOCGSESSION)"); | ||
30 | + return 1; | ||
31 | + } | ||
32 | + printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", | ||
33 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
34 | + alignmask = siop.alignmask; | ||
35 | +#endif | ||
36 | + | ||
37 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
38 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
39 | + break; | ||
40 | + } | ||
41 | + | ||
42 | end: | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | -- | ||
46 | 2.10.2 | ||
47 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch new file mode 100644 index 00000000..2721ea84 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From 14c5355aa23f970c7941afa460b2335f8e67445f Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:28:09 +0300 | ||
4 | Subject: [PATCH 047/104] add support for sha2-256 hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 23 +++++++++++++++++++++++ | ||
9 | 1 file changed, 23 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 64d5603..15ab80c 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -283,6 +283,29 @@ int main(void) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.mac = CRYPTO_SHA2_256; | ||
22 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
23 | + perror("ioctl(CIOCGSESSION)"); | ||
24 | + return 1; | ||
25 | + } | ||
26 | +#ifdef CIOCGSESSINFO | ||
27 | + siop.ses = sess.ses; | ||
28 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
29 | + perror("ioctl(CIOCGSESSION)"); | ||
30 | + return 1; | ||
31 | + } | ||
32 | + printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", | ||
33 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
34 | + alignmask = siop.alignmask; | ||
35 | +#endif | ||
36 | + | ||
37 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
38 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
39 | + break; | ||
40 | + } | ||
41 | + | ||
42 | end: | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | -- | ||
46 | 2.10.2 | ||
47 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch new file mode 100644 index 00000000..85301aa8 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch | |||
@@ -0,0 +1,48 @@ | |||
1 | From 139268835b7d84472950e3ed866f41d79a0cb723 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 12:05:13 +0300 | ||
4 | Subject: [PATCH 048/104] add support for aes-256-xts sync speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 24 ++++++++++++++++++++++++ | ||
9 | 1 file changed, 24 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 81c5a65..16ad7b7 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -206,6 +206,30 @@ int main(int argc, char** argv) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.cipher = CRYPTO_AES_XTS; | ||
22 | + sess.keylen = 32; | ||
23 | + memset(keybuf, 0x42, sess.keylen); | ||
24 | + sess.key = (unsigned char *)keybuf; | ||
25 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
26 | + perror("ioctl(CIOCGSESSION)"); | ||
27 | + return 1; | ||
28 | + } | ||
29 | +#ifdef CIOCGSESSINFO | ||
30 | + siop.ses = sess.ses; | ||
31 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
32 | + perror("ioctl(CIOCGSESSINFO)"); | ||
33 | + return 1; | ||
34 | + } | ||
35 | + alignmask = siop.alignmask; | ||
36 | +#endif | ||
37 | + | ||
38 | + for (i = 512; i <= (64 * 1024); i *= 2) { | ||
39 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
40 | + break; | ||
41 | + } | ||
42 | + | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | return 0; | ||
46 | -- | ||
47 | 2.10.2 | ||
48 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch new file mode 100644 index 00000000..26279b68 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From af3d42a68f1e356d21e52e72f3f5ebc7cfd90e81 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 12:13:58 +0300 | ||
4 | Subject: [PATCH 049/104] add support for crc32c hash sync speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 25 +++++++++++++++++++++++++ | ||
9 | 1 file changed, 25 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 16ad7b7..bd6d2b2 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -74,6 +74,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
16 | { | ||
17 | struct crypt_op cop; | ||
18 | char *buffer, iv[32]; | ||
19 | + char mac[HASH_MAX_LEN]; | ||
20 | static int val = 23; | ||
21 | struct timeval start, end; | ||
22 | double total = 0; | ||
23 | @@ -110,6 +111,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
24 | cop.iv = (unsigned char *)iv; | ||
25 | cop.op = COP_ENCRYPT; | ||
26 | cop.src = cop.dst = (unsigned char *)buffer; | ||
27 | + cop.mac = mac; | ||
28 | |||
29 | if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
30 | perror("ioctl(CIOCCRYPT)"); | ||
31 | @@ -230,6 +232,29 @@ int main(int argc, char** argv) | ||
32 | break; | ||
33 | } | ||
34 | |||
35 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
36 | + memset(&sess, 0, sizeof(sess)); | ||
37 | + sess.mac = CRYPTO_CRC32C; | ||
38 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
39 | + perror("ioctl(CIOCGSESSION)"); | ||
40 | + return 1; | ||
41 | + } | ||
42 | +#ifdef CIOCGSESSINFO | ||
43 | + siop.ses = sess.ses; | ||
44 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
45 | + perror("ioctl(CIOCGSESSINFO)"); | ||
46 | + return 1; | ||
47 | + } | ||
48 | + printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
49 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
50 | + alignmask = siop.alignmask; | ||
51 | +#endif | ||
52 | + | ||
53 | + for (i = 512; i <= (64 * 1024); i *= 2) { | ||
54 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
55 | + break; | ||
56 | + } | ||
57 | + | ||
58 | close(fdc); | ||
59 | close(fd); | ||
60 | return 0; | ||
61 | -- | ||
62 | 2.10.2 | ||
63 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch new file mode 100644 index 00000000..f54286ae --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch | |||
@@ -0,0 +1,439 @@ | |||
1 | From 13cb1f2dcf8865b076a7e8290d8f864d91a2d7c7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Mon, 24 Oct 2016 16:33:55 +0300 | ||
4 | Subject: [PATCH 050/104] add basic optargs support for async_speed test | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 302 +++++++++++++++++++++++++++++++++++----------------- | ||
9 | 1 file changed, 202 insertions(+), 100 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 15ab80c..fff3414 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -27,9 +27,45 @@ | ||
16 | #include <sys/types.h> | ||
17 | #include <signal.h> | ||
18 | #include <crypto/cryptodev.h> | ||
19 | +#include <stdbool.h> | ||
20 | +#include <unistd.h> | ||
21 | |||
22 | #ifdef ENABLE_ASYNC | ||
23 | |||
24 | +struct test_params { | ||
25 | + bool tflag; | ||
26 | + bool nflag; | ||
27 | + int tvalue; | ||
28 | + int nvalue; | ||
29 | +}; | ||
30 | + | ||
31 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
32 | + "Run benchmark test for cipher or hash\n\n" | ||
33 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
34 | + " -n <bytes>\t" "size of the test buffer\n" | ||
35 | + " -h\t\t" "show this help\n" | ||
36 | +; | ||
37 | + | ||
38 | +int run_null(int fdc, struct test_params tp); | ||
39 | +int run_aes_cbc(int fdc, struct test_params tp); | ||
40 | +int run_aes_xts(int fdc, struct test_params tp); | ||
41 | +int run_crc32c(int fdc, struct test_params tp); | ||
42 | +int run_sha1(int fdc, struct test_params tp); | ||
43 | +int run_sha256(int fdc, struct test_params tp); | ||
44 | + | ||
45 | +#define ALG_COUNT 6 | ||
46 | +struct { | ||
47 | + char *name; | ||
48 | + int (*func)(int, struct test_params); | ||
49 | +} ciphers[ALG_COUNT] = { | ||
50 | + {"null", run_null}, | ||
51 | + {"aes-cbc", run_aes_cbc}, | ||
52 | + {"aes-xts", run_aes_xts}, | ||
53 | + {"crc32c", run_crc32c}, | ||
54 | + {"sha1", run_sha1}, | ||
55 | + {"sha256", run_sha256}, | ||
56 | +}; | ||
57 | + | ||
58 | static double udifftimeval(struct timeval start, struct timeval end) | ||
59 | { | ||
60 | return (double)(end.tv_usec - start.tv_usec) + | ||
61 | @@ -61,7 +97,7 @@ static void value2human(double bytes, double time, double* data, double* speed,c | ||
62 | } | ||
63 | |||
64 | |||
65 | -int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
66 | +int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
67 | { | ||
68 | struct crypt_op cop; | ||
69 | char *buffer[64], iv[32]; | ||
70 | @@ -72,31 +108,33 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
71 | double secs, ddata, dspeed; | ||
72 | char metric[16]; | ||
73 | int rc, wqueue = 0, bufidx = 0; | ||
74 | + int alignmask; | ||
75 | |||
76 | memset(iv, 0x23, 32); | ||
77 | |||
78 | - printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
79 | + printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
80 | fflush(stdout); | ||
81 | |||
82 | + alignmask = get_alignmask(fdc, sess); | ||
83 | for (rc = 0; rc < 64; rc++) { | ||
84 | if (alignmask) { | ||
85 | - if (posix_memalign((void **)(buffer + rc), alignmask + 1, chunksize)) { | ||
86 | + if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
87 | printf("posix_memalign() failed!\n"); | ||
88 | return 1; | ||
89 | } | ||
90 | } else { | ||
91 | - if (!(buffer[rc] = malloc(chunksize))) { | ||
92 | + if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
93 | perror("malloc()"); | ||
94 | return 1; | ||
95 | } | ||
96 | } | ||
97 | - memset(buffer[rc], val++, chunksize); | ||
98 | + memset(buffer[rc], val++, tp.nvalue); | ||
99 | } | ||
100 | pfd.fd = fdc; | ||
101 | pfd.events = POLLOUT | POLLIN; | ||
102 | |||
103 | must_finish = 0; | ||
104 | - alarm(5); | ||
105 | + alarm(tp.tvalue); | ||
106 | |||
107 | gettimeofday(&start, NULL); | ||
108 | do { | ||
109 | @@ -111,7 +149,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
110 | if (pfd.revents & POLLOUT) { | ||
111 | memset(&cop, 0, sizeof(cop)); | ||
112 | cop.ses = sess->ses; | ||
113 | - cop.len = chunksize; | ||
114 | + cop.len = tp.nvalue; | ||
115 | cop.iv = (unsigned char *)iv; | ||
116 | cop.op = COP_ENCRYPT; | ||
117 | cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
118 | @@ -146,25 +184,75 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | -int main(void) | ||
123 | +void usage(char *cmd_name) | ||
124 | { | ||
125 | - int fd, i, fdc = -1, alignmask = 0; | ||
126 | - struct session_op sess; | ||
127 | -#ifdef CIOCGSESSINFO | ||
128 | - struct session_info_op siop; | ||
129 | -#endif | ||
130 | - char keybuf[32]; | ||
131 | + printf(usage_str, cmd_name); | ||
132 | +} | ||
133 | |||
134 | - signal(SIGALRM, alarm_handler); | ||
135 | +int run_test(int id, struct test_params tp) | ||
136 | +{ | ||
137 | + int fd; | ||
138 | + int fdc; | ||
139 | |||
140 | - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { | ||
141 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
142 | + if (fd < 0) { | ||
143 | perror("open()"); | ||
144 | - return 1; | ||
145 | + return fd; | ||
146 | } | ||
147 | if (ioctl(fd, CRIOGET, &fdc)) { | ||
148 | perror("ioctl(CRIOGET)"); | ||
149 | - return 1; | ||
150 | + return -EINVAL; | ||
151 | + } | ||
152 | + | ||
153 | + ciphers[id].func(fdc, tp); | ||
154 | + | ||
155 | + close(fdc); | ||
156 | + close(fd); | ||
157 | +} | ||
158 | + | ||
159 | +int get_alignmask(int fdc, struct session_op *sess) | ||
160 | +{ | ||
161 | + int alignmask; | ||
162 | + | ||
163 | +#ifdef CIOCGSESSINFO | ||
164 | + struct session_info_op siop; | ||
165 | + | ||
166 | + siop.ses = sess->ses; | ||
167 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
168 | + perror("ioctl(CIOCGSESSINFO)"); | ||
169 | + return -EINVAL; | ||
170 | + } | ||
171 | + alignmask = siop.alignmask; | ||
172 | +#else | ||
173 | + alignmask = 0; | ||
174 | +#endif | ||
175 | + | ||
176 | + return alignmask; | ||
177 | +} | ||
178 | + | ||
179 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
180 | +{ | ||
181 | + int i; | ||
182 | + | ||
183 | + if (tp.nflag) { | ||
184 | + encrypt_data(fdc, tp, sess); | ||
185 | + } else { | ||
186 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
187 | + tp.nvalue = i; | ||
188 | + if (encrypt_data(fdc, tp, sess)) { | ||
189 | + break; | ||
190 | + } | ||
191 | + } | ||
192 | } | ||
193 | +} | ||
194 | + | ||
195 | + | ||
196 | +int run_null(int fdc, struct test_params tp) | ||
197 | +{ | ||
198 | + struct session_op sess; | ||
199 | + char keybuf[32]; | ||
200 | + int alignmask; | ||
201 | + int i; | ||
202 | |||
203 | fprintf(stderr, "Testing NULL cipher: \n"); | ||
204 | memset(&sess, 0, sizeof(sess)); | ||
205 | @@ -173,21 +261,19 @@ int main(void) | ||
206 | sess.key = (unsigned char *)keybuf; | ||
207 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
208 | perror("ioctl(CIOCGSESSION)"); | ||
209 | - return 1; | ||
210 | - } | ||
211 | -#ifdef CIOCGSESSINFO | ||
212 | - siop.ses = sess.ses; | ||
213 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
214 | - perror("ioctl(CIOCGSESSINFO)"); | ||
215 | - return 1; | ||
216 | + return -EINVAL; | ||
217 | } | ||
218 | - alignmask = siop.alignmask; | ||
219 | -#endif | ||
220 | |||
221 | - for (i = 256; i <= (64 * 4096); i *= 2) { | ||
222 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
223 | - break; | ||
224 | - } | ||
225 | + do_test_vectors(fdc, tp, &sess); | ||
226 | + return 0; | ||
227 | +} | ||
228 | + | ||
229 | +int run_aes_cbc(int fdc, struct test_params tp) | ||
230 | +{ | ||
231 | + struct session_op sess; | ||
232 | + char keybuf[32]; | ||
233 | + int alignmask; | ||
234 | + int i; | ||
235 | |||
236 | fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
237 | memset(&sess, 0, sizeof(sess)); | ||
238 | @@ -197,21 +283,17 @@ int main(void) | ||
239 | sess.key = (unsigned char *)keybuf; | ||
240 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
241 | perror("ioctl(CIOCGSESSION)"); | ||
242 | - return 1; | ||
243 | - } | ||
244 | -#ifdef CIOCGSESSINFO | ||
245 | - siop.ses = sess.ses; | ||
246 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
247 | - perror("ioctl(CIOCGSESSINFO)"); | ||
248 | - return 1; | ||
249 | + return -EINVAL; | ||
250 | } | ||
251 | - alignmask = siop.alignmask; | ||
252 | -#endif | ||
253 | |||
254 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
255 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
256 | - break; | ||
257 | - } | ||
258 | + do_test_vectors(fdc, tp, &sess); | ||
259 | + return 0; | ||
260 | +} | ||
261 | + | ||
262 | +int run_aes_xts(int fdc, struct test_params tp) | ||
263 | +{ | ||
264 | + struct session_op sess; | ||
265 | + char keybuf[32]; | ||
266 | |||
267 | fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
268 | memset(&sess, 0, sizeof(sess)); | ||
269 | @@ -221,21 +303,16 @@ int main(void) | ||
270 | sess.key = (unsigned char *)keybuf; | ||
271 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
272 | perror("ioctl(CIOCGSESSION)"); | ||
273 | - return 1; | ||
274 | + return -EINVAL; | ||
275 | } | ||
276 | -#ifdef CIOCGSESSINFO | ||
277 | - siop.ses = sess.ses; | ||
278 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
279 | - perror("ioctl(CIOCGSESSION)"); | ||
280 | - return 1; | ||
281 | - } | ||
282 | - alignmask = siop.alignmask; | ||
283 | -#endif | ||
284 | |||
285 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
286 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
287 | - break; | ||
288 | - } | ||
289 | + do_test_vectors(fdc, tp, &sess); | ||
290 | + return 0; | ||
291 | +} | ||
292 | + | ||
293 | +int run_crc32c(int fdc, struct test_params tp) | ||
294 | +{ | ||
295 | + struct session_op sess; | ||
296 | |||
297 | fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
298 | memset(&sess, 0, sizeof(sess)); | ||
299 | @@ -244,21 +321,14 @@ int main(void) | ||
300 | perror("ioctl(CIOCGSESSION)"); | ||
301 | return 1; | ||
302 | } | ||
303 | -#ifdef CIOCGSESSINFO | ||
304 | - siop.ses = sess.ses; | ||
305 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
306 | - perror("ioctl(CIOCGSESSION)"); | ||
307 | - return 1; | ||
308 | - } | ||
309 | - printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
310 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
311 | - alignmask = siop.alignmask; | ||
312 | -#endif | ||
313 | |||
314 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
315 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
316 | - break; | ||
317 | - } | ||
318 | + do_test_vectors(fdc, tp, &sess); | ||
319 | + return 0; | ||
320 | +} | ||
321 | + | ||
322 | +int run_sha1(int fdc, struct test_params tp) | ||
323 | +{ | ||
324 | + struct session_op sess; | ||
325 | |||
326 | fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
327 | memset(&sess, 0, sizeof(sess)); | ||
328 | @@ -267,21 +337,14 @@ int main(void) | ||
329 | perror("ioctl(CIOCGSESSION)"); | ||
330 | return 1; | ||
331 | } | ||
332 | -#ifdef CIOCGSESSINFO | ||
333 | - siop.ses = sess.ses; | ||
334 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
335 | - perror("ioctl(CIOCGSESSION)"); | ||
336 | - return 1; | ||
337 | - } | ||
338 | - printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", | ||
339 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
340 | - alignmask = siop.alignmask; | ||
341 | -#endif | ||
342 | |||
343 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
344 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
345 | - break; | ||
346 | - } | ||
347 | + do_test_vectors(fdc, tp, &sess); | ||
348 | + return 0; | ||
349 | +} | ||
350 | + | ||
351 | +int run_sha256(int fdc, struct test_params tp) | ||
352 | +{ | ||
353 | + struct session_op sess; | ||
354 | |||
355 | fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
356 | memset(&sess, 0, sizeof(sess)); | ||
357 | @@ -290,25 +353,64 @@ int main(void) | ||
358 | perror("ioctl(CIOCGSESSION)"); | ||
359 | return 1; | ||
360 | } | ||
361 | -#ifdef CIOCGSESSINFO | ||
362 | - siop.ses = sess.ses; | ||
363 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
364 | - perror("ioctl(CIOCGSESSION)"); | ||
365 | - return 1; | ||
366 | - } | ||
367 | - printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", | ||
368 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
369 | - alignmask = siop.alignmask; | ||
370 | -#endif | ||
371 | |||
372 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
373 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
374 | + do_test_vectors(fdc, tp, &sess); | ||
375 | + return 0; | ||
376 | +} | ||
377 | + | ||
378 | +int main(int argc, char **argv) | ||
379 | +{ | ||
380 | + int i; | ||
381 | + int c; | ||
382 | + int index; | ||
383 | + bool alg_flag; | ||
384 | + char *alg_name; | ||
385 | + struct test_params tp; | ||
386 | + | ||
387 | + tp.tflag = false; | ||
388 | + tp.nflag = false; | ||
389 | + alg_flag = false; | ||
390 | + opterr = 0; | ||
391 | + while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
392 | + switch (c) { | ||
393 | + case 'n': | ||
394 | + tp.nvalue = atoi(optarg); | ||
395 | + tp.nflag = true; | ||
396 | + break; | ||
397 | + case 't': | ||
398 | + tp.tvalue = atoi(optarg); | ||
399 | + tp.tflag = true; | ||
400 | break; | ||
401 | + case 'h': /* no break */ | ||
402 | + default: | ||
403 | + usage(argv[0]); | ||
404 | + exit(1); | ||
405 | + } | ||
406 | + } | ||
407 | + | ||
408 | + /* the name of a specific test asked on the command line */ | ||
409 | + if (optind < argc) { | ||
410 | + alg_name = argv[optind]; | ||
411 | + alg_flag = true; | ||
412 | + } | ||
413 | + | ||
414 | + /* default test time */ | ||
415 | + if (!tp.tflag) { | ||
416 | + tp.tvalue = 5; | ||
417 | + } | ||
418 | + | ||
419 | + signal(SIGALRM, alarm_handler); | ||
420 | + | ||
421 | + for (i = 0; i < ALG_COUNT; i++) { | ||
422 | + if (alg_flag) { | ||
423 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
424 | + run_test(i, tp); | ||
425 | + } | ||
426 | + } else { | ||
427 | + run_test(i, tp); | ||
428 | + } | ||
429 | } | ||
430 | |||
431 | -end: | ||
432 | - close(fdc); | ||
433 | - close(fd); | ||
434 | return 0; | ||
435 | } | ||
436 | |||
437 | -- | ||
438 | 2.10.2 | ||
439 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch b/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch new file mode 100644 index 00000000..cfe4cd96 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From 6b31215e77b89fd7bd4dcfb6e4e3a9ee53e7731d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 15:03:19 +0300 | ||
4 | Subject: [PATCH 051/104] enable async code by default | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | Makefile | 2 +- | ||
9 | tests/Makefile | 1 + | ||
10 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/Makefile b/Makefile | ||
13 | index 9871a8e..3934e1f 100644 | ||
14 | --- a/Makefile | ||
15 | +++ b/Makefile | ||
16 | @@ -3,7 +3,7 @@ | ||
17 | # disabled by default. To re-enable it uncomment the | ||
18 | # corresponding CFLAG. | ||
19 | # | ||
20 | -CRYPTODEV_CFLAGS ?= #-DENABLE_ASYNC | ||
21 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
22 | KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) | ||
23 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
24 | VERSION = 1.8 | ||
25 | diff --git a/tests/Makefile b/tests/Makefile | ||
26 | index 5e3111d..683f40b 100644 | ||
27 | --- a/tests/Makefile | ||
28 | +++ b/tests/Makefile | ||
29 | @@ -1,4 +1,5 @@ | ||
30 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
31 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
32 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
33 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
34 | |||
35 | -- | ||
36 | 2.10.2 | ||
37 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch b/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch new file mode 100644 index 00000000..c2b88a59 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From 6d2e0927c2ed2795267d7652d9413d7e01da202e Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 16:54:06 +0300 | ||
4 | Subject: [PATCH 052/104] add flag to report in a machine friendly format | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 8 +++++++- | ||
9 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index fff3414..1941750 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -35,6 +35,7 @@ | ||
16 | struct test_params { | ||
17 | bool tflag; | ||
18 | bool nflag; | ||
19 | + bool mflag; | ||
20 | int tvalue; | ||
21 | int nvalue; | ||
22 | }; | ||
23 | @@ -43,6 +44,7 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
24 | "Run benchmark test for cipher or hash\n\n" | ||
25 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
26 | " -n <bytes>\t" "size of the test buffer\n" | ||
27 | + " -m\t\t" "output in a machine readable format\n" | ||
28 | " -h\t\t" "show this help\n" | ||
29 | ; | ||
30 | |||
31 | @@ -369,9 +371,10 @@ int main(int argc, char **argv) | ||
32 | |||
33 | tp.tflag = false; | ||
34 | tp.nflag = false; | ||
35 | + tp.mflag = false; | ||
36 | alg_flag = false; | ||
37 | opterr = 0; | ||
38 | - while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
39 | + while ((c = getopt(argc, argv, "hn:t:m")) != -1) { | ||
40 | switch (c) { | ||
41 | case 'n': | ||
42 | tp.nvalue = atoi(optarg); | ||
43 | @@ -381,6 +384,9 @@ int main(int argc, char **argv) | ||
44 | tp.tvalue = atoi(optarg); | ||
45 | tp.tflag = true; | ||
46 | break; | ||
47 | + case 'm': | ||
48 | + tp.mflag = true; | ||
49 | + break; | ||
50 | case 'h': /* no break */ | ||
51 | default: | ||
52 | usage(argv[0]); | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch b/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch new file mode 100644 index 00000000..4653920d --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch | |||
@@ -0,0 +1,137 @@ | |||
1 | From 9aae91f24b42a9a812cd0518c0c4ef3f548d64d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 17:02:29 +0300 | ||
4 | Subject: [PATCH 053/104] honor the -m flag in async_speed | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 36 ++++++++++++++++++++++++------------ | ||
9 | 1 file changed, 24 insertions(+), 12 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 1941750..73ec9d2 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -29,6 +29,8 @@ | ||
16 | #include <crypto/cryptodev.h> | ||
17 | #include <stdbool.h> | ||
18 | #include <unistd.h> | ||
19 | +#include <stdint.h> | ||
20 | +#include <inttypes.h> | ||
21 | |||
22 | #ifdef ENABLE_ASYNC | ||
23 | |||
24 | @@ -85,7 +87,7 @@ static void alarm_handler(int signo) | ||
25 | |||
26 | static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
27 | |||
28 | -static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
29 | +static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
30 | { | ||
31 | int unit = 0; | ||
32 | |||
33 | @@ -98,6 +100,11 @@ static void value2human(double bytes, double time, double* data, double* speed,c | ||
34 | sprintf(metric, "%sB", units[unit]); | ||
35 | } | ||
36 | |||
37 | +static void value2machine(uint64_t bytes, double time, double* speed) | ||
38 | +{ | ||
39 | + *speed = bytes / time; | ||
40 | +} | ||
41 | + | ||
42 | |||
43 | int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
44 | { | ||
45 | @@ -106,7 +113,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
46 | char mac[64][HASH_MAX_LEN]; | ||
47 | static int val = 23; | ||
48 | struct timeval start, end; | ||
49 | - double total = 0; | ||
50 | + uint64_t total = 0; | ||
51 | double secs, ddata, dspeed; | ||
52 | char metric[16]; | ||
53 | int rc, wqueue = 0, bufidx = 0; | ||
54 | @@ -114,8 +121,10 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
55 | |||
56 | memset(iv, 0x23, 32); | ||
57 | |||
58 | - printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
59 | - fflush(stdout); | ||
60 | + if (!tp.mflag) { | ||
61 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
62 | + fflush(stdout); | ||
63 | + } | ||
64 | |||
65 | alignmask = get_alignmask(fdc, sess); | ||
66 | for (rc = 0; rc < 64; rc++) { | ||
67 | @@ -177,9 +186,14 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
68 | |||
69 | secs = udifftimeval(start, end)/ 1000000.0; | ||
70 | |||
71 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
72 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
73 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
74 | + if (tp.mflag) { | ||
75 | + value2machine(total, secs, &dspeed); | ||
76 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
77 | + } else { | ||
78 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
79 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
80 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
81 | + } | ||
82 | |||
83 | for (rc = 0; rc < 64; rc++) | ||
84 | free(buffer[rc]); | ||
85 | @@ -206,6 +220,9 @@ int run_test(int id, struct test_params tp) | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
89 | + if (!tp.mflag) { | ||
90 | + fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
91 | + } | ||
92 | ciphers[id].func(fdc, tp); | ||
93 | |||
94 | close(fdc); | ||
95 | @@ -277,7 +294,6 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
96 | int alignmask; | ||
97 | int i; | ||
98 | |||
99 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
100 | memset(&sess, 0, sizeof(sess)); | ||
101 | sess.cipher = CRYPTO_AES_CBC; | ||
102 | sess.keylen = 16; | ||
103 | @@ -297,7 +313,6 @@ int run_aes_xts(int fdc, struct test_params tp) | ||
104 | struct session_op sess; | ||
105 | char keybuf[32]; | ||
106 | |||
107 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
108 | memset(&sess, 0, sizeof(sess)); | ||
109 | sess.cipher = CRYPTO_AES_XTS; | ||
110 | sess.keylen = 32; | ||
111 | @@ -316,7 +331,6 @@ int run_crc32c(int fdc, struct test_params tp) | ||
112 | { | ||
113 | struct session_op sess; | ||
114 | |||
115 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
116 | memset(&sess, 0, sizeof(sess)); | ||
117 | sess.mac = CRYPTO_CRC32C; | ||
118 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
119 | @@ -332,7 +346,6 @@ int run_sha1(int fdc, struct test_params tp) | ||
120 | { | ||
121 | struct session_op sess; | ||
122 | |||
123 | - fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
124 | memset(&sess, 0, sizeof(sess)); | ||
125 | sess.mac = CRYPTO_SHA1; | ||
126 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
127 | @@ -348,7 +361,6 @@ int run_sha256(int fdc, struct test_params tp) | ||
128 | { | ||
129 | struct session_op sess; | ||
130 | |||
131 | - fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
132 | memset(&sess, 0, sizeof(sess)); | ||
133 | sess.mac = CRYPTO_SHA2_256; | ||
134 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
135 | -- | ||
136 | 2.10.2 | ||
137 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch b/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch new file mode 100644 index 00000000..242f4a62 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | From f71ba99a8943767c39df5104e86054c9c0e76fd8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 17:31:40 +0300 | ||
4 | Subject: [PATCH 054/104] rename algorithm names for clarity | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 12 ++++++------ | ||
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 73ec9d2..263ead7 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -51,8 +51,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
16 | ; | ||
17 | |||
18 | int run_null(int fdc, struct test_params tp); | ||
19 | -int run_aes_cbc(int fdc, struct test_params tp); | ||
20 | -int run_aes_xts(int fdc, struct test_params tp); | ||
21 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
22 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
23 | int run_crc32c(int fdc, struct test_params tp); | ||
24 | int run_sha1(int fdc, struct test_params tp); | ||
25 | int run_sha256(int fdc, struct test_params tp); | ||
26 | @@ -63,8 +63,8 @@ struct { | ||
27 | int (*func)(int, struct test_params); | ||
28 | } ciphers[ALG_COUNT] = { | ||
29 | {"null", run_null}, | ||
30 | - {"aes-cbc", run_aes_cbc}, | ||
31 | - {"aes-xts", run_aes_xts}, | ||
32 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
33 | + {"aes-256-xts", run_aes_256_xts}, | ||
34 | {"crc32c", run_crc32c}, | ||
35 | {"sha1", run_sha1}, | ||
36 | {"sha256", run_sha256}, | ||
37 | @@ -287,7 +287,7 @@ int run_null(int fdc, struct test_params tp) | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | -int run_aes_cbc(int fdc, struct test_params tp) | ||
42 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
43 | { | ||
44 | struct session_op sess; | ||
45 | char keybuf[32]; | ||
46 | @@ -308,7 +308,7 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | -int run_aes_xts(int fdc, struct test_params tp) | ||
51 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
52 | { | ||
53 | struct session_op sess; | ||
54 | char keybuf[32]; | ||
55 | -- | ||
56 | 2.10.2 | ||
57 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch new file mode 100644 index 00000000..4129010b --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch | |||
@@ -0,0 +1,173 @@ | |||
1 | From 789d3c5ecda60a6dc5d5b3597047ad65c412f10d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 15:30:59 +0300 | ||
4 | Subject: [PATCH 055/104] add multithreaded wrapper for async speed test | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 1 + | ||
9 | tests/async_speed_multi.sh | 140 +++++++++++++++++++++++++++++++++++++++++++++ | ||
10 | 2 files changed, 141 insertions(+) | ||
11 | create mode 100755 tests/async_speed_multi.sh | ||
12 | |||
13 | diff --git a/tests/Makefile b/tests/Makefile | ||
14 | index 683f40b..6424c11 100644 | ||
15 | --- a/tests/Makefile | ||
16 | +++ b/tests/Makefile | ||
17 | @@ -40,6 +40,7 @@ install: | ||
18 | for prog in $(hostprogs); do \ | ||
19 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
20 | done | ||
21 | + install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
22 | |||
23 | clean: | ||
24 | rm -f *.o *~ $(hostprogs) | ||
25 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
26 | new file mode 100755 | ||
27 | index 0000000..761c0cb | ||
28 | --- /dev/null | ||
29 | +++ b/tests/async_speed_multi.sh | ||
30 | @@ -0,0 +1,140 @@ | ||
31 | +#!/bin/bash | ||
32 | +# | ||
33 | +# Copyright 2016 NXP Semiconductors | ||
34 | +# | ||
35 | +# This program is free software: you can redistribute it and/or modify | ||
36 | +# it under the terms of the GNU General Public License as published by | ||
37 | +# the Free Software Foundation, either version 2 of the License, or | ||
38 | +# (at your option) any later version. | ||
39 | +# | ||
40 | +# This program is distributed in the hope that it will be useful, | ||
41 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | +# GNU General Public License for more details. | ||
44 | +# | ||
45 | +# You should have received a copy of the GNU General Public License | ||
46 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | +# no user-configurable options below this line | ||
51 | + | ||
52 | +NUM_CORES=`nproc` | ||
53 | +OUT_BASENAME="async_speed" | ||
54 | +MPSTAT="mpstat" | ||
55 | +MPSTAT_OUT="mpstat_out" | ||
56 | + | ||
57 | +function usage | ||
58 | +{ | ||
59 | +cat << EOF | ||
60 | +Usage: `basename $0` [OPTIONS] <alg_name> | ||
61 | + | ||
62 | + -m <threads> number of threads to run with (defaults to number of cores) | ||
63 | + -t <secs> time to run each test (default 10 secs) | ||
64 | + -n <bytes> size of the test buffer (default 256 bytes) | ||
65 | + -h show this help | ||
66 | + | ||
67 | +alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
68 | +EOF | ||
69 | +} | ||
70 | + | ||
71 | +function SUM { | ||
72 | + paste -sd+ - | bc -l | ||
73 | +} | ||
74 | + | ||
75 | +function get_cpu_idle | ||
76 | +{ | ||
77 | + header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
78 | + idle_column=`echo $header_line | wc -w` | ||
79 | + | ||
80 | + all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` | ||
81 | + mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` | ||
82 | + | ||
83 | + average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` | ||
84 | + echo $average_idle | ||
85 | +} | ||
86 | + | ||
87 | +function run_parallel | ||
88 | +{ | ||
89 | + trap control_c SIGINT | ||
90 | + | ||
91 | + OPTIONS="-t $tvalue -n $nvalue -m" | ||
92 | + CMD="async_speed $OPTIONS $alg_name" | ||
93 | + | ||
94 | + echo "Running $mvalue threads in parallel:" | ||
95 | + echo " $CMD" | ||
96 | + | ||
97 | + $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & | ||
98 | + MPSTAT_PID=$! | ||
99 | + | ||
100 | + PIDS="" | ||
101 | + start=`date +%s.%N` | ||
102 | + | ||
103 | + for i in `seq 0 $(($mvalue-1))` | ||
104 | + do | ||
105 | + CMD_OUT="${OUT_BASENAME}_${i}" | ||
106 | + | ||
107 | + $CMD &> $CMD_OUT & | ||
108 | + PID=$! | ||
109 | + AFFINITY=$(($i % $NUM_CORES)) | ||
110 | + taskset -pc $AFFINITY $PID > /dev/null | ||
111 | + | ||
112 | + PIDS="$PID $PIDS" | ||
113 | + done | ||
114 | + | ||
115 | + wait $PIDS | ||
116 | + end=`date +%s.%N` | ||
117 | + | ||
118 | + wait $MPSTAT_PID | ||
119 | + | ||
120 | + runtime=$(echo "scale=2; $end - $start" | bc -l ) | ||
121 | + total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
122 | + avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
123 | + cpu_idle=`get_cpu_idle` | ||
124 | + | ||
125 | + echo | ||
126 | + echo "buffer size : $nvalue" | ||
127 | + echo "running time : $runtime" | ||
128 | + echo "avg_speed : $avg_speed GiB/s" | ||
129 | + echo "all_cpu idle : $cpu_idle %" | ||
130 | + echo | ||
131 | +} | ||
132 | + | ||
133 | +function control_c | ||
134 | +{ | ||
135 | + killall async_speed > /dev/null | ||
136 | + killall mpstat > /dev/null | ||
137 | +} | ||
138 | + | ||
139 | +function main | ||
140 | +{ | ||
141 | + while getopts hm:t:n: option | ||
142 | + do | ||
143 | + case "$option" in | ||
144 | + m) mvalue="$OPTARG";; | ||
145 | + t) tvalue="$OPTARG";; | ||
146 | + n) nvalue="$OPTARG";; | ||
147 | + *) usage $0; exit 1;; | ||
148 | + esac | ||
149 | + done | ||
150 | + | ||
151 | + shift $((OPTIND-1)) | ||
152 | + alg_name=$1 | ||
153 | + | ||
154 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
155 | + [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
156 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
157 | + | ||
158 | + case "$alg_name" in | ||
159 | + "null" |\ | ||
160 | + "aes-128-cbc" |\ | ||
161 | + "aes-256-xts" |\ | ||
162 | + "sha1" |\ | ||
163 | + "sha256" |\ | ||
164 | + "crc32c" ) run_parallel;; | ||
165 | + * ) usage && exit 1;; | ||
166 | + esac | ||
167 | +} | ||
168 | + | ||
169 | +main "$@" | ||
170 | + | ||
171 | -- | ||
172 | 2.10.2 | ||
173 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch b/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch new file mode 100644 index 00000000..d98e5887 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | From ad7fee26da24fca57efee5ba10756e001769b2ce Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 16:46:11 +0300 | ||
4 | Subject: [PATCH 056/104] fix: set min value when allocating alligned memory | ||
5 | buffers | ||
6 | |||
7 | The function "posix_memalign()" requires that the alignment be at least | ||
8 | sizeof(void*). In some situations the alignmask for some crypto algorithms | ||
9 | is smaller then the minimum required. For ex. on 64-bit platforms where | ||
10 | the alignment may be 4 bytes. | ||
11 | |||
12 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
13 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
14 | --- | ||
15 | tests/async_speed.c | 4 ++++ | ||
16 | tests/speed.c | 2 ++ | ||
17 | 2 files changed, 6 insertions(+) | ||
18 | |||
19 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
20 | index 263ead7..b895a85 100644 | ||
21 | --- a/tests/async_speed.c | ||
22 | +++ b/tests/async_speed.c | ||
23 | @@ -232,6 +232,7 @@ int run_test(int id, struct test_params tp) | ||
24 | int get_alignmask(int fdc, struct session_op *sess) | ||
25 | { | ||
26 | int alignmask; | ||
27 | + int min_alignmask = sizeof(void*) - 1; | ||
28 | |||
29 | #ifdef CIOCGSESSINFO | ||
30 | struct session_info_op siop; | ||
31 | @@ -242,6 +243,9 @@ int get_alignmask(int fdc, struct session_op *sess) | ||
32 | return -EINVAL; | ||
33 | } | ||
34 | alignmask = siop.alignmask; | ||
35 | + if (alignmask < min_alignmask) { | ||
36 | + alignmask = min_alignmask; | ||
37 | + } | ||
38 | #else | ||
39 | alignmask = 0; | ||
40 | #endif | ||
41 | diff --git a/tests/speed.c b/tests/speed.c | ||
42 | index bd6d2b2..0b14c88 100644 | ||
43 | --- a/tests/speed.c | ||
44 | +++ b/tests/speed.c | ||
45 | @@ -80,8 +80,10 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
46 | double total = 0; | ||
47 | double secs, ddata, dspeed; | ||
48 | char metric[16]; | ||
49 | + int min_alignmask = sizeof(void*) - 1; | ||
50 | |||
51 | if (alignmask) { | ||
52 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
53 | if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { | ||
54 | printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); | ||
55 | return 1; | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch new file mode 100644 index 00000000..5ba0578a --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch | |||
@@ -0,0 +1,64 @@ | |||
1 | From f7e3566382bf22fc73c5a0edfde5c5349a92f8ea Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 18:35:13 +0300 | ||
4 | Subject: [PATCH 057/104] gracefull stop for async speed tests | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_speed.c | 16 ++++++++++++++++ | ||
10 | 1 file changed, 16 insertions(+) | ||
11 | |||
12 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
13 | index b895a85..e6bbeed 100644 | ||
14 | --- a/tests/async_speed.c | ||
15 | +++ b/tests/async_speed.c | ||
16 | @@ -77,6 +77,7 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
17 | } | ||
18 | |||
19 | static int must_finish = 0; | ||
20 | +static int must_exit = 0; | ||
21 | static struct pollfd pfd; | ||
22 | |||
23 | static void alarm_handler(int signo) | ||
24 | @@ -85,6 +86,12 @@ static void alarm_handler(int signo) | ||
25 | pfd.events = POLLIN; | ||
26 | } | ||
27 | |||
28 | +static void exit_handler(int signo) | ||
29 | +{ | ||
30 | + must_exit = 1; | ||
31 | + printf("\nexit requested by user through ctrl+c \n"); | ||
32 | +} | ||
33 | + | ||
34 | static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
35 | |||
36 | static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
37 | @@ -261,6 +268,10 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
38 | encrypt_data(fdc, tp, sess); | ||
39 | } else { | ||
40 | for (i = 256; i <= (64 * 1024); i *= 2) { | ||
41 | + if (must_exit) { | ||
42 | + break; | ||
43 | + } | ||
44 | + | ||
45 | tp.nvalue = i; | ||
46 | if (encrypt_data(fdc, tp, sess)) { | ||
47 | break; | ||
48 | @@ -422,8 +433,13 @@ int main(int argc, char **argv) | ||
49 | } | ||
50 | |||
51 | signal(SIGALRM, alarm_handler); | ||
52 | + signal(SIGINT, exit_handler); | ||
53 | |||
54 | for (i = 0; i < ALG_COUNT; i++) { | ||
55 | + if (must_exit) { | ||
56 | + break; | ||
57 | + } | ||
58 | + | ||
59 | if (alg_flag) { | ||
60 | if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
61 | run_test(i, tp); | ||
62 | -- | ||
63 | 2.10.2 | ||
64 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch b/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch new file mode 100644 index 00000000..62733301 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From b04d0b7ccb9150d4f16c712a830f8a4e3bdd2d05 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:29:36 +0300 | ||
4 | Subject: [PATCH 058/104] sanity check on /dev/crypto availability | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 2 ++ | ||
9 | 1 file changed, 2 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 761c0cb..94c2312 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -108,6 +108,8 @@ function control_c | ||
16 | |||
17 | function main | ||
18 | { | ||
19 | + [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
20 | + | ||
21 | while getopts hm:t:n: option | ||
22 | do | ||
23 | case "$option" in | ||
24 | -- | ||
25 | 2.10.2 | ||
26 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch b/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch new file mode 100644 index 00000000..fd2fedad --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch | |||
@@ -0,0 +1,42 @@ | |||
1 | From 28c87b3dd5ed2ac90185b09bdc7233648d5d89b5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:14:28 +0300 | ||
4 | Subject: [PATCH 059/104] fix some issues with parsing mpstat output | ||
5 | |||
6 | - mpstat with 'count' parameter will average the results for us on the | ||
7 | last line so we don't need to do this ourselves. | ||
8 | - set time format to ISO to avoid incorrect parsing of the header line | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | tests/async_speed_multi.sh | 7 +++---- | ||
13 | 1 file changed, 3 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
16 | index 94c2312..a28f72d 100755 | ||
17 | --- a/tests/async_speed_multi.sh | ||
18 | +++ b/tests/async_speed_multi.sh | ||
19 | @@ -21,6 +21,7 @@ | ||
20 | |||
21 | NUM_CORES=`nproc` | ||
22 | OUT_BASENAME="async_speed" | ||
23 | +S_TIME_FORMAT=ISO | ||
24 | MPSTAT="mpstat" | ||
25 | MPSTAT_OUT="mpstat_out" | ||
26 | |||
27 | @@ -47,10 +48,8 @@ function get_cpu_idle | ||
28 | header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
29 | idle_column=`echo $header_line | wc -w` | ||
30 | |||
31 | - all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` | ||
32 | - mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` | ||
33 | - | ||
34 | - average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` | ||
35 | + average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
36 | + | ||
37 | echo $average_idle | ||
38 | } | ||
39 | |||
40 | -- | ||
41 | 2.10.2 | ||
42 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch b/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch new file mode 100644 index 00000000..ae749bdc --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From 26291db7df602d3d3d5601817229822b13904fe9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:48:44 +0300 | ||
4 | Subject: [PATCH 060/104] more precision in running mpstat | ||
5 | |||
6 | Start mpstat one second later than the tests so we don't measure | ||
7 | transient issues. Likewise, stop mpstat just before the tests terminate | ||
8 | so we don't record incorrect CPU idle. | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | tests/async_speed_multi.sh | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
16 | index a28f72d..5268c86 100755 | ||
17 | --- a/tests/async_speed_multi.sh | ||
18 | +++ b/tests/async_speed_multi.sh | ||
19 | @@ -22,7 +22,6 @@ | ||
20 | NUM_CORES=`nproc` | ||
21 | OUT_BASENAME="async_speed" | ||
22 | S_TIME_FORMAT=ISO | ||
23 | -MPSTAT="mpstat" | ||
24 | MPSTAT_OUT="mpstat_out" | ||
25 | |||
26 | function usage | ||
27 | @@ -47,7 +46,6 @@ function get_cpu_idle | ||
28 | { | ||
29 | header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
30 | idle_column=`echo $header_line | wc -w` | ||
31 | - | ||
32 | average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
33 | |||
34 | echo $average_idle | ||
35 | @@ -63,7 +61,7 @@ function run_parallel | ||
36 | echo "Running $mvalue threads in parallel:" | ||
37 | echo " $CMD" | ||
38 | |||
39 | - $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & | ||
40 | + (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
41 | MPSTAT_PID=$! | ||
42 | |||
43 | PIDS="" | ||
44 | @@ -126,6 +124,8 @@ function main | ||
45 | [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
46 | [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
47 | |||
48 | + [ "$tvalue" -lt 5 ] && tvalue=5 | ||
49 | + | ||
50 | case "$alg_name" in | ||
51 | "null" |\ | ||
52 | "aes-128-cbc" |\ | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch b/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch new file mode 100644 index 00000000..9e3ec848 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | From 3bfdd0d1991a37c1adc82cc7e1938e2d9d175bd7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:01:57 +0300 | ||
4 | Subject: [PATCH 061/104] add a little space in the output for clarity | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 5268c86..331158b 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -58,7 +58,8 @@ function run_parallel | ||
16 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
17 | CMD="async_speed $OPTIONS $alg_name" | ||
18 | |||
19 | - echo "Running $mvalue threads in parallel:" | ||
20 | + echo | ||
21 | + echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
22 | echo " $CMD" | ||
23 | |||
24 | (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch b/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch new file mode 100644 index 00000000..dba2575f --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch | |||
@@ -0,0 +1,129 @@ | |||
1 | From 0fd37b5225bd26182b20588b200a4fc0a3f415e5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:10:47 +0300 | ||
4 | Subject: [PATCH 062/104] fix build warnings on implicit function declarations | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 2 +- | ||
9 | tests/async_speed.c | 47 +++++++++++++++++++++++------------------------ | ||
10 | tests/hashcrypt_speed.c | 1 + | ||
11 | tests/sha_speed.c | 1 + | ||
12 | tests/speed.c | 1 + | ||
13 | 5 files changed, 27 insertions(+), 25 deletions(-) | ||
14 | |||
15 | diff --git a/tests/Makefile b/tests/Makefile | ||
16 | index 6424c11..14ae2c7 100644 | ||
17 | --- a/tests/Makefile | ||
18 | +++ b/tests/Makefile | ||
19 | @@ -1,5 +1,5 @@ | ||
20 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
21 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
22 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration | ||
23 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
24 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
25 | |||
26 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
27 | index e6bbeed..a1a1b7e 100644 | ||
28 | --- a/tests/async_speed.c | ||
29 | +++ b/tests/async_speed.c | ||
30 | @@ -112,6 +112,29 @@ static void value2machine(uint64_t bytes, double time, double* speed) | ||
31 | *speed = bytes / time; | ||
32 | } | ||
33 | |||
34 | +int get_alignmask(int fdc, struct session_op *sess) | ||
35 | +{ | ||
36 | + int alignmask; | ||
37 | + int min_alignmask = sizeof(void*) - 1; | ||
38 | + | ||
39 | +#ifdef CIOCGSESSINFO | ||
40 | + struct session_info_op siop; | ||
41 | + | ||
42 | + siop.ses = sess->ses; | ||
43 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
44 | + perror("ioctl(CIOCGSESSINFO)"); | ||
45 | + return -EINVAL; | ||
46 | + } | ||
47 | + alignmask = siop.alignmask; | ||
48 | + if (alignmask < min_alignmask) { | ||
49 | + alignmask = min_alignmask; | ||
50 | + } | ||
51 | +#else | ||
52 | + alignmask = 0; | ||
53 | +#endif | ||
54 | + | ||
55 | + return alignmask; | ||
56 | +} | ||
57 | |||
58 | int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
59 | { | ||
60 | @@ -236,30 +259,6 @@ int run_test(int id, struct test_params tp) | ||
61 | close(fd); | ||
62 | } | ||
63 | |||
64 | -int get_alignmask(int fdc, struct session_op *sess) | ||
65 | -{ | ||
66 | - int alignmask; | ||
67 | - int min_alignmask = sizeof(void*) - 1; | ||
68 | - | ||
69 | -#ifdef CIOCGSESSINFO | ||
70 | - struct session_info_op siop; | ||
71 | - | ||
72 | - siop.ses = sess->ses; | ||
73 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
74 | - perror("ioctl(CIOCGSESSINFO)"); | ||
75 | - return -EINVAL; | ||
76 | - } | ||
77 | - alignmask = siop.alignmask; | ||
78 | - if (alignmask < min_alignmask) { | ||
79 | - alignmask = min_alignmask; | ||
80 | - } | ||
81 | -#else | ||
82 | - alignmask = 0; | ||
83 | -#endif | ||
84 | - | ||
85 | - return alignmask; | ||
86 | -} | ||
87 | - | ||
88 | void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
89 | { | ||
90 | int i; | ||
91 | diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c | ||
92 | index e60b73d..045bf8e 100644 | ||
93 | --- a/tests/hashcrypt_speed.c | ||
94 | +++ b/tests/hashcrypt_speed.c | ||
95 | @@ -25,6 +25,7 @@ | ||
96 | #include <sys/time.h> | ||
97 | #include <sys/types.h> | ||
98 | #include <signal.h> | ||
99 | +#include <unistd.h> | ||
100 | #include <crypto/cryptodev.h> | ||
101 | |||
102 | #define MAX(x,y) ((x)>(y)?(x):(y)) | ||
103 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
104 | index 75d0f42..e5c6efe 100644 | ||
105 | --- a/tests/sha_speed.c | ||
106 | +++ b/tests/sha_speed.c | ||
107 | @@ -25,6 +25,7 @@ | ||
108 | #include <sys/time.h> | ||
109 | #include <sys/types.h> | ||
110 | #include <signal.h> | ||
111 | +#include <unistd.h> | ||
112 | |||
113 | #include <crypto/cryptodev.h> | ||
114 | |||
115 | diff --git a/tests/speed.c b/tests/speed.c | ||
116 | index 0b14c88..d2e1aed 100644 | ||
117 | --- a/tests/speed.c | ||
118 | +++ b/tests/speed.c | ||
119 | @@ -24,6 +24,7 @@ | ||
120 | #include <sys/time.h> | ||
121 | #include <sys/types.h> | ||
122 | #include <signal.h> | ||
123 | +#include <unistd.h> | ||
124 | |||
125 | #include <crypto/cryptodev.h> | ||
126 | |||
127 | -- | ||
128 | 2.10.2 | ||
129 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch b/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch new file mode 100644 index 00000000..133d46c1 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch | |||
@@ -0,0 +1,698 @@ | |||
1 | From 5f3a9153f7685f6dde29f7cd2d58534126c5b9af Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:45:40 +0300 | ||
4 | Subject: [PATCH 063/104] avoid implicit conversion between signed and unsigned | ||
5 | char | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_cipher.c | 36 ++++++++++++++-------------- | ||
10 | tests/async_hmac.c | 8 +++---- | ||
11 | tests/async_speed.c | 2 +- | ||
12 | tests/cipher-aead-srtp.c | 50 +++++++++++++++++++------------------- | ||
13 | tests/cipher-aead.c | 48 ++++++++++++++++++------------------- | ||
14 | tests/cipher-gcm.c | 62 ++++++++++++++++++++++++------------------------ | ||
15 | tests/cipher.c | 35 ++++++++++++++------------- | ||
16 | tests/cipher_comp.c | 12 +++++----- | ||
17 | tests/fullspeed.c | 3 ++- | ||
18 | tests/hash_comp.c | 8 +++---- | ||
19 | tests/hmac.c | 8 +++---- | ||
20 | tests/speed.c | 3 ++- | ||
21 | 12 files changed, 138 insertions(+), 137 deletions(-) | ||
22 | |||
23 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
24 | index 162a695..dd08403 100644 | ||
25 | --- a/tests/async_cipher.c | ||
26 | +++ b/tests/async_cipher.c | ||
27 | @@ -9,7 +9,7 @@ | ||
28 | #include <string.h> | ||
29 | #include <unistd.h> | ||
30 | #include <fcntl.h> | ||
31 | - | ||
32 | +#include <stdint.h> | ||
33 | #include <sys/ioctl.h> | ||
34 | #include <crypto/cryptodev.h> | ||
35 | |||
36 | @@ -26,10 +26,10 @@ static int debug = 0; | ||
37 | static int | ||
38 | test_crypto(int cfd) | ||
39 | { | ||
40 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
41 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
42 | - char iv[BLOCK_SIZE]; | ||
43 | - char key[KEY_SIZE]; | ||
44 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
45 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
46 | + uint8_t iv[BLOCK_SIZE]; | ||
47 | + uint8_t key[KEY_SIZE]; | ||
48 | |||
49 | struct session_op sess; | ||
50 | #ifdef CIOCGSESSINFO | ||
51 | @@ -62,8 +62,8 @@ test_crypto(int cfd) | ||
52 | perror("ioctl(CIOCGSESSINFO)"); | ||
53 | return 1; | ||
54 | } | ||
55 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
56 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
57 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
58 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
59 | #else | ||
60 | plaintext = plaintext_raw; | ||
61 | ciphertext = ciphertext_raw; | ||
62 | @@ -127,15 +127,15 @@ test_crypto(int cfd) | ||
63 | |||
64 | static int test_aes(int cfd) | ||
65 | { | ||
66 | - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
67 | - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
68 | - char iv1[BLOCK_SIZE]; | ||
69 | - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
70 | - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
71 | - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
72 | - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
73 | - char iv2[BLOCK_SIZE]; | ||
74 | - char key2[KEY_SIZE]; | ||
75 | + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
76 | + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
77 | + uint8_t iv1[BLOCK_SIZE]; | ||
78 | + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
79 | + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
80 | + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
81 | + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
82 | + uint8_t iv2[BLOCK_SIZE]; | ||
83 | + uint8_t key2[KEY_SIZE]; | ||
84 | |||
85 | struct session_op sess1, sess2; | ||
86 | #ifdef CIOCGSESSINFO | ||
87 | @@ -162,7 +162,7 @@ static int test_aes(int cfd) | ||
88 | perror("ioctl(CIOCGSESSINFO)"); | ||
89 | return 1; | ||
90 | } | ||
91 | - plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
92 | + plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
93 | #else | ||
94 | plaintext1 = plaintext1_raw; | ||
95 | #endif | ||
96 | @@ -185,7 +185,7 @@ static int test_aes(int cfd) | ||
97 | perror("ioctl(CIOCGSESSINFO)"); | ||
98 | return 1; | ||
99 | } | ||
100 | - plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
101 | + plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
102 | #else | ||
103 | plaintext2 = plaintext2_raw; | ||
104 | #endif | ||
105 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
106 | index 97fd0c5..94a02c0 100644 | ||
107 | --- a/tests/async_hmac.c | ||
108 | +++ b/tests/async_hmac.c | ||
109 | @@ -61,7 +61,7 @@ test_crypto(int cfd) | ||
110 | |||
111 | cryp.ses = sess.ses; | ||
112 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
113 | - cryp.src = "what do ya want for nothing?"; | ||
114 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
115 | cryp.mac = mac; | ||
116 | cryp.op = COP_ENCRYPT; | ||
117 | |||
118 | @@ -98,7 +98,7 @@ test_crypto(int cfd) | ||
119 | |||
120 | cryp.ses = sess.ses; | ||
121 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
122 | - cryp.src = "what do ya want for nothing?"; | ||
123 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
124 | cryp.mac = mac; | ||
125 | cryp.op = COP_ENCRYPT; | ||
126 | |||
127 | @@ -208,7 +208,7 @@ test_extras(int cfd) | ||
128 | |||
129 | cryp.ses = sess.ses; | ||
130 | cryp.len = sizeof("what do")-1; | ||
131 | - cryp.src = "what do"; | ||
132 | + cryp.src = (uint8_t*)"what do"; | ||
133 | cryp.mac = mac; | ||
134 | cryp.op = COP_ENCRYPT; | ||
135 | cryp.flags = COP_FLAG_UPDATE; | ||
136 | @@ -218,7 +218,7 @@ test_extras(int cfd) | ||
137 | |||
138 | cryp.ses = sess.ses; | ||
139 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
140 | - cryp.src = " ya want for nothing?"; | ||
141 | + cryp.src = (uint8_t*)" ya want for nothing?"; | ||
142 | cryp.mac = mac; | ||
143 | cryp.op = COP_ENCRYPT; | ||
144 | cryp.flags = COP_FLAG_FINAL; | ||
145 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
146 | index a1a1b7e..dabbbc1 100644 | ||
147 | --- a/tests/async_speed.c | ||
148 | +++ b/tests/async_speed.c | ||
149 | @@ -140,7 +140,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
150 | { | ||
151 | struct crypt_op cop; | ||
152 | char *buffer[64], iv[32]; | ||
153 | - char mac[64][HASH_MAX_LEN]; | ||
154 | + uint8_t mac[64][HASH_MAX_LEN]; | ||
155 | static int val = 23; | ||
156 | struct timeval start, end; | ||
157 | uint64_t total = 0; | ||
158 | diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c | ||
159 | index fae04e7..c44877d 100644 | ||
160 | --- a/tests/cipher-aead-srtp.c | ||
161 | +++ b/tests/cipher-aead-srtp.c | ||
162 | @@ -77,13 +77,13 @@ int i; | ||
163 | static int | ||
164 | test_crypto(int cfd) | ||
165 | { | ||
166 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
167 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
168 | - char iv[BLOCK_SIZE]; | ||
169 | - char key[KEY_SIZE]; | ||
170 | - unsigned char sha1mac[20]; | ||
171 | - unsigned char tag[20]; | ||
172 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
173 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
174 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
175 | + uint8_t iv[BLOCK_SIZE]; | ||
176 | + uint8_t key[KEY_SIZE]; | ||
177 | + uint8_t sha1mac[20]; | ||
178 | + uint8_t tag[20]; | ||
179 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
180 | int mackey_len = 16; | ||
181 | |||
182 | struct session_op sess; | ||
183 | @@ -122,8 +122,8 @@ test_crypto(int cfd) | ||
184 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
185 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
186 | |||
187 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
188 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
189 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
190 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
191 | |||
192 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
193 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
194 | @@ -225,12 +225,12 @@ test_crypto(int cfd) | ||
195 | static int | ||
196 | test_encrypt_decrypt(int cfd) | ||
197 | { | ||
198 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
199 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
200 | - char iv[BLOCK_SIZE]; | ||
201 | - char key[KEY_SIZE]; | ||
202 | - unsigned char tag[20]; | ||
203 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
204 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
205 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
206 | + uint8_t iv[BLOCK_SIZE]; | ||
207 | + uint8_t key[KEY_SIZE]; | ||
208 | + uint8_t tag[20]; | ||
209 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
210 | int mackey_len = 16; | ||
211 | |||
212 | struct session_op sess; | ||
213 | @@ -265,8 +265,8 @@ test_encrypt_decrypt(int cfd) | ||
214 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
215 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
216 | |||
217 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
218 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
219 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
220 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
221 | |||
222 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
223 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
224 | @@ -367,12 +367,12 @@ test_encrypt_decrypt(int cfd) | ||
225 | static int | ||
226 | test_encrypt_decrypt_error(int cfd, int err) | ||
227 | { | ||
228 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
229 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
230 | - char iv[BLOCK_SIZE]; | ||
231 | - char key[KEY_SIZE]; | ||
232 | - unsigned char tag[20]; | ||
233 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
234 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
235 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
236 | + uint8_t iv[BLOCK_SIZE]; | ||
237 | + uint8_t key[KEY_SIZE]; | ||
238 | + uint8_t tag[20]; | ||
239 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
240 | int mackey_len = 16; | ||
241 | |||
242 | struct session_op sess; | ||
243 | @@ -407,8 +407,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
244 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
245 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
246 | |||
247 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
248 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
249 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
250 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
251 | |||
252 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
253 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
254 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
255 | index 164327f..da43aa6 100644 | ||
256 | --- a/tests/cipher-aead.c | ||
257 | +++ b/tests/cipher-aead.c | ||
258 | @@ -89,12 +89,12 @@ int i; | ||
259 | static int | ||
260 | test_crypto(int cfd) | ||
261 | { | ||
262 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
263 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
264 | - char iv[BLOCK_SIZE]; | ||
265 | - char key[KEY_SIZE]; | ||
266 | - char auth[AUTH_SIZE]; | ||
267 | - unsigned char sha1mac[20]; | ||
268 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
269 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
270 | + uint8_t iv[BLOCK_SIZE]; | ||
271 | + uint8_t key[KEY_SIZE]; | ||
272 | + uint8_t auth[AUTH_SIZE]; | ||
273 | + uint8_t sha1mac[20]; | ||
274 | int pad, i; | ||
275 | |||
276 | struct session_op sess; | ||
277 | @@ -133,8 +133,8 @@ test_crypto(int cfd) | ||
278 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
279 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
280 | |||
281 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
282 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
283 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
284 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
285 | memset(plaintext, 0x15, DATA_SIZE); | ||
286 | |||
287 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
288 | @@ -242,12 +242,12 @@ test_crypto(int cfd) | ||
289 | static int | ||
290 | test_encrypt_decrypt(int cfd) | ||
291 | { | ||
292 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
293 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
294 | - char iv[BLOCK_SIZE]; | ||
295 | - char key[KEY_SIZE]; | ||
296 | - char auth[AUTH_SIZE]; | ||
297 | - unsigned char sha1mac[20]; | ||
298 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
299 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
300 | + uint8_t iv[BLOCK_SIZE]; | ||
301 | + uint8_t key[KEY_SIZE]; | ||
302 | + uint8_t auth[AUTH_SIZE]; | ||
303 | + uint8_t sha1mac[20]; | ||
304 | int enc_len; | ||
305 | |||
306 | struct session_op sess; | ||
307 | @@ -285,8 +285,8 @@ test_encrypt_decrypt(int cfd) | ||
308 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
309 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
310 | |||
311 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
312 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
313 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
314 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
315 | |||
316 | memset(plaintext, 0x15, DATA_SIZE); | ||
317 | |||
318 | @@ -391,12 +391,12 @@ test_encrypt_decrypt(int cfd) | ||
319 | static int | ||
320 | test_encrypt_decrypt_error(int cfd, int err) | ||
321 | { | ||
322 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
323 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
324 | - char iv[BLOCK_SIZE]; | ||
325 | - char key[KEY_SIZE]; | ||
326 | - char auth[AUTH_SIZE]; | ||
327 | - unsigned char sha1mac[20]; | ||
328 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
329 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
330 | + uint8_t iv[BLOCK_SIZE]; | ||
331 | + uint8_t key[KEY_SIZE]; | ||
332 | + uint8_t auth[AUTH_SIZE]; | ||
333 | + uint8_t sha1mac[20]; | ||
334 | int enc_len; | ||
335 | |||
336 | struct session_op sess; | ||
337 | @@ -434,8 +434,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
338 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
339 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
340 | |||
341 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
342 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
343 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
344 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
345 | memset(plaintext, 0x15, DATA_SIZE); | ||
346 | |||
347 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
348 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
349 | index dfc3d84..3f6cc7b 100644 | ||
350 | --- a/tests/cipher-gcm.c | ||
351 | +++ b/tests/cipher-gcm.c | ||
352 | @@ -45,45 +45,45 @@ struct aes_gcm_vectors_st { | ||
353 | |||
354 | struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
355 | { | ||
356 | - .key = | ||
357 | + .key = (uint8_t*) | ||
358 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
359 | .auth = NULL, | ||
360 | .auth_size = 0, | ||
361 | - .plaintext = | ||
362 | + .plaintext = (uint8_t*) | ||
363 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
364 | .plaintext_size = 16, | ||
365 | - .ciphertext = | ||
366 | + .ciphertext = (uint8_t*) | ||
367 | "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", | ||
368 | - .iv = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
369 | - .tag = | ||
370 | + .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
371 | + .tag = (uint8_t*) | ||
372 | "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" | ||
373 | }, | ||
374 | { | ||
375 | - .key = | ||
376 | + .key = (uint8_t*) | ||
377 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
378 | .auth = NULL, | ||
379 | .auth_size = 0, | ||
380 | - .plaintext = | ||
381 | + .plaintext = (uint8_t*) | ||
382 | "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39\x1a\xaf\xd2\x55", | ||
383 | .plaintext_size = 64, | ||
384 | - .ciphertext = | ||
385 | + .ciphertext = (uint8_t*) | ||
386 | "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91\x47\x3f\x59\x85", | ||
387 | - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
388 | - .tag = "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
389 | + .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
390 | + .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
391 | }, | ||
392 | { | ||
393 | - .key = | ||
394 | + .key = (uint8_t*) | ||
395 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
396 | - .auth = | ||
397 | + .auth = (uint8_t*) | ||
398 | "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", | ||
399 | .auth_size = 20, | ||
400 | - .plaintext = | ||
401 | + .plaintext = (uint8_t*) | ||
402 | "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39", | ||
403 | .plaintext_size = 60, | ||
404 | - .ciphertext = | ||
405 | + .ciphertext = (uint8_t*) | ||
406 | "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91", | ||
407 | - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
408 | - .tag = | ||
409 | + .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
410 | + .tag = (uint8_t*) | ||
411 | "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" | ||
412 | } | ||
413 | }; | ||
414 | @@ -94,7 +94,7 @@ struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
415 | static int test_crypto(int cfd) | ||
416 | { | ||
417 | int i; | ||
418 | - int8_t tmp[128]; | ||
419 | + uint8_t tmp[128]; | ||
420 | |||
421 | struct session_op sess; | ||
422 | struct crypt_auth_op cao; | ||
423 | @@ -191,11 +191,11 @@ static int test_crypto(int cfd) | ||
424 | */ | ||
425 | static int test_encrypt_decrypt(int cfd) | ||
426 | { | ||
427 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
428 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
429 | - char iv[BLOCK_SIZE]; | ||
430 | - char key[KEY_SIZE]; | ||
431 | - char auth[AUTH_SIZE]; | ||
432 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
433 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
434 | + uint8_t iv[BLOCK_SIZE]; | ||
435 | + uint8_t key[KEY_SIZE]; | ||
436 | + uint8_t auth[AUTH_SIZE]; | ||
437 | int enc_len; | ||
438 | |||
439 | struct session_op sess; | ||
440 | @@ -233,10 +233,10 @@ static int test_encrypt_decrypt(int cfd) | ||
441 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
442 | |||
443 | plaintext = | ||
444 | - (char *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
445 | + (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
446 | ~siop.alignmask); | ||
447 | ciphertext = | ||
448 | - (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
449 | + (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
450 | ~siop.alignmask); | ||
451 | |||
452 | memset(plaintext, 0x15, DATA_SIZE); | ||
453 | @@ -336,11 +336,11 @@ static int test_encrypt_decrypt(int cfd) | ||
454 | |||
455 | static int test_encrypt_decrypt_error(int cfd, int err) | ||
456 | { | ||
457 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
458 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
459 | - char iv[BLOCK_SIZE]; | ||
460 | - char key[KEY_SIZE]; | ||
461 | - char auth[AUTH_SIZE]; | ||
462 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
463 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
464 | + uint8_t iv[BLOCK_SIZE]; | ||
465 | + uint8_t key[KEY_SIZE]; | ||
466 | + uint8_t auth[AUTH_SIZE]; | ||
467 | int enc_len; | ||
468 | |||
469 | struct session_op sess; | ||
470 | @@ -386,10 +386,10 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
471 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
472 | |||
473 | plaintext = | ||
474 | - (char *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
475 | + (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
476 | ~siop.alignmask); | ||
477 | ciphertext = | ||
478 | - (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
479 | + (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
480 | ~siop.alignmask); | ||
481 | |||
482 | memset(plaintext, 0x15, DATA_SIZE); | ||
483 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
484 | index 07144f2..f3ca2f0 100644 | ||
485 | --- a/tests/cipher.c | ||
486 | +++ b/tests/cipher.c | ||
487 | @@ -8,6 +8,7 @@ | ||
488 | #include <string.h> | ||
489 | #include <unistd.h> | ||
490 | #include <fcntl.h> | ||
491 | +#include <stdint.h> | ||
492 | |||
493 | #include <sys/ioctl.h> | ||
494 | #include <crypto/cryptodev.h> | ||
495 | @@ -21,10 +22,10 @@ static int debug = 0; | ||
496 | static int | ||
497 | test_crypto(int cfd) | ||
498 | { | ||
499 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
500 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
501 | - char iv[BLOCK_SIZE]; | ||
502 | - char key[KEY_SIZE]; | ||
503 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
504 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
505 | + uint8_t iv[BLOCK_SIZE]; | ||
506 | + uint8_t key[KEY_SIZE]; | ||
507 | |||
508 | struct session_op sess; | ||
509 | #ifdef CIOCGSESSINFO | ||
510 | @@ -57,8 +58,8 @@ test_crypto(int cfd) | ||
511 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
512 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
513 | |||
514 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
515 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
516 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
517 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
518 | #else | ||
519 | plaintext = plaintext_raw; | ||
520 | ciphertext = ciphertext_raw; | ||
521 | @@ -143,15 +144,15 @@ test_crypto(int cfd) | ||
522 | |||
523 | static int test_aes(int cfd) | ||
524 | { | ||
525 | - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
526 | - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
527 | - char iv1[BLOCK_SIZE]; | ||
528 | - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
529 | - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
530 | - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
531 | - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
532 | - char iv2[BLOCK_SIZE]; | ||
533 | - char key2[KEY_SIZE]; | ||
534 | + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
535 | + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
536 | + uint8_t iv1[BLOCK_SIZE]; | ||
537 | + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
538 | + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
539 | + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
540 | + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
541 | + uint8_t iv2[BLOCK_SIZE]; | ||
542 | + uint8_t key2[KEY_SIZE]; | ||
543 | |||
544 | struct session_op sess; | ||
545 | #ifdef CIOCGSESSINFO | ||
546 | @@ -176,7 +177,7 @@ static int test_aes(int cfd) | ||
547 | perror("ioctl(CIOCGSESSINFO)"); | ||
548 | return 1; | ||
549 | } | ||
550 | - plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
551 | + plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
552 | #else | ||
553 | plaintext1 = plaintext1_raw; | ||
554 | #endif | ||
555 | @@ -226,7 +227,7 @@ static int test_aes(int cfd) | ||
556 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
557 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
558 | |||
559 | - plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
560 | + plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
561 | #else | ||
562 | plaintext2 = plaintext2_raw; | ||
563 | #endif | ||
564 | diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c | ||
565 | index b2bc5af..03f67bf 100644 | ||
566 | --- a/tests/cipher_comp.c | ||
567 | +++ b/tests/cipher_comp.c | ||
568 | @@ -24,12 +24,12 @@ | ||
569 | static int | ||
570 | test_crypto(int cfd, struct session_op *sess, int datalen) | ||
571 | { | ||
572 | - char *data, *encrypted; | ||
573 | - char *encrypted_comp; | ||
574 | + uint8_t *data, *encrypted; | ||
575 | + uint8_t *encrypted_comp; | ||
576 | |||
577 | - char iv_in[BLOCK_SIZE]; | ||
578 | - char iv[BLOCK_SIZE]; | ||
579 | - char iv_comp[BLOCK_SIZE]; | ||
580 | + uint8_t iv_in[BLOCK_SIZE]; | ||
581 | + uint8_t iv[BLOCK_SIZE]; | ||
582 | + uint8_t iv_comp[BLOCK_SIZE]; | ||
583 | |||
584 | struct crypt_op cryp; | ||
585 | |||
586 | @@ -90,7 +90,7 @@ main(int argc, char **argv) | ||
587 | { | ||
588 | int fd; | ||
589 | struct session_op sess; | ||
590 | - unsigned char key[KEY_SIZE]; | ||
591 | + uint8_t key[KEY_SIZE]; | ||
592 | int datalen = BLOCK_SIZE; | ||
593 | int datalen_end = MAX_DATALEN; | ||
594 | int i; | ||
595 | diff --git a/tests/fullspeed.c b/tests/fullspeed.c | ||
596 | index 611859d..c025130 100644 | ||
597 | --- a/tests/fullspeed.c | ||
598 | +++ b/tests/fullspeed.c | ||
599 | @@ -25,6 +25,7 @@ | ||
600 | #include <sys/types.h> | ||
601 | #include <signal.h> | ||
602 | #include <unistd.h> | ||
603 | +#include <stdint.h> | ||
604 | |||
605 | #include <crypto/cryptodev.h> | ||
606 | |||
607 | @@ -74,7 +75,7 @@ static void value2human(int si, double bytes, double time, double* data, double* | ||
608 | int encrypt_data(int algo, void* keybuf, int key_size, int fdc, int chunksize) | ||
609 | { | ||
610 | struct crypt_op cop; | ||
611 | - char *buffer, iv[32]; | ||
612 | + uint8_t *buffer, iv[32]; | ||
613 | static int val = 23; | ||
614 | struct timeval start, end; | ||
615 | double total = 0; | ||
616 | diff --git a/tests/hash_comp.c b/tests/hash_comp.c | ||
617 | index 9e700a1..e6a4346 100644 | ||
618 | --- a/tests/hash_comp.c | ||
619 | +++ b/tests/hash_comp.c | ||
620 | @@ -30,11 +30,9 @@ static void printhex(unsigned char *buf, int buflen) | ||
621 | static int | ||
622 | test_crypto(int cfd, struct session_op *sess, int datalen) | ||
623 | { | ||
624 | - unsigned char *data; | ||
625 | - | ||
626 | - unsigned char mac[AALG_MAX_RESULT_LEN]; | ||
627 | - | ||
628 | - unsigned char mac_comp[AALG_MAX_RESULT_LEN]; | ||
629 | + uint8_t *data; | ||
630 | + uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
631 | + uint8_t mac_comp[AALG_MAX_RESULT_LEN]; | ||
632 | |||
633 | struct crypt_op cryp; | ||
634 | |||
635 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
636 | index 1d9349e..80a2c42 100644 | ||
637 | --- a/tests/hmac.c | ||
638 | +++ b/tests/hmac.c | ||
639 | @@ -69,7 +69,7 @@ test_crypto(int cfd) | ||
640 | |||
641 | cryp.ses = sess.ses; | ||
642 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
643 | - cryp.src = "what do ya want for nothing?"; | ||
644 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
645 | cryp.mac = mac; | ||
646 | cryp.op = COP_ENCRYPT; | ||
647 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
648 | @@ -113,7 +113,7 @@ test_crypto(int cfd) | ||
649 | |||
650 | cryp.ses = sess.ses; | ||
651 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
652 | - cryp.src = "what do ya want for nothing?"; | ||
653 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
654 | cryp.mac = mac; | ||
655 | cryp.op = COP_ENCRYPT; | ||
656 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
657 | @@ -246,7 +246,7 @@ test_extras(int cfd) | ||
658 | |||
659 | cryp.ses = sess.ses; | ||
660 | cryp.len = sizeof("what do")-1; | ||
661 | - cryp.src = "what do"; | ||
662 | + cryp.src = (uint8_t*)"what do"; | ||
663 | cryp.mac = mac; | ||
664 | cryp.op = COP_ENCRYPT; | ||
665 | cryp.flags = COP_FLAG_UPDATE; | ||
666 | @@ -257,7 +257,7 @@ test_extras(int cfd) | ||
667 | |||
668 | cryp.ses = sess.ses; | ||
669 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
670 | - cryp.src = " ya want for nothing?"; | ||
671 | + cryp.src = (uint8_t*)" ya want for nothing?"; | ||
672 | cryp.mac = mac; | ||
673 | cryp.op = COP_ENCRYPT; | ||
674 | cryp.flags = COP_FLAG_FINAL; | ||
675 | diff --git a/tests/speed.c b/tests/speed.c | ||
676 | index d2e1aed..0e2bbc3 100644 | ||
677 | --- a/tests/speed.c | ||
678 | +++ b/tests/speed.c | ||
679 | @@ -25,6 +25,7 @@ | ||
680 | #include <sys/types.h> | ||
681 | #include <signal.h> | ||
682 | #include <unistd.h> | ||
683 | +#include <stdint.h> | ||
684 | |||
685 | #include <crypto/cryptodev.h> | ||
686 | |||
687 | @@ -75,7 +76,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
688 | { | ||
689 | struct crypt_op cop; | ||
690 | char *buffer, iv[32]; | ||
691 | - char mac[HASH_MAX_LEN]; | ||
692 | + uint8_t mac[HASH_MAX_LEN]; | ||
693 | static int val = 23; | ||
694 | struct timeval start, end; | ||
695 | double total = 0; | ||
696 | -- | ||
697 | 2.10.2 | ||
698 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch b/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch new file mode 100644 index 00000000..24eac13e --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch | |||
@@ -0,0 +1,129 @@ | |||
1 | From c31ba5b149428cbbcd48fab649331a2d38003209 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:47:07 +0300 | ||
4 | Subject: [PATCH 064/104] remove not used local variables | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_hmac.c | 2 -- | ||
9 | tests/async_speed.c | 5 ----- | ||
10 | tests/cipher_comp.c | 2 +- | ||
11 | tests/hash_comp.c | 5 ++--- | ||
12 | tests/hmac.c | 2 -- | ||
13 | tests/sha_speed.c | 1 - | ||
14 | 6 files changed, 3 insertions(+), 14 deletions(-) | ||
15 | |||
16 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
17 | index 94a02c0..85d19c6 100644 | ||
18 | --- a/tests/async_hmac.c | ||
19 | +++ b/tests/async_hmac.c | ||
20 | @@ -185,8 +185,6 @@ test_extras(int cfd) | ||
21 | struct session_op sess; | ||
22 | struct crypt_op cryp; | ||
23 | uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
24 | - uint8_t oldmac[AALG_MAX_RESULT_LEN]; | ||
25 | - uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; | ||
26 | uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; | ||
27 | int i; | ||
28 | |||
29 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
30 | index dabbbc1..f2b9772 100644 | ||
31 | --- a/tests/async_speed.c | ||
32 | +++ b/tests/async_speed.c | ||
33 | @@ -284,8 +284,6 @@ int run_null(int fdc, struct test_params tp) | ||
34 | { | ||
35 | struct session_op sess; | ||
36 | char keybuf[32]; | ||
37 | - int alignmask; | ||
38 | - int i; | ||
39 | |||
40 | fprintf(stderr, "Testing NULL cipher: \n"); | ||
41 | memset(&sess, 0, sizeof(sess)); | ||
42 | @@ -305,8 +303,6 @@ int run_aes_128_cbc(int fdc, struct test_params tp) | ||
43 | { | ||
44 | struct session_op sess; | ||
45 | char keybuf[32]; | ||
46 | - int alignmask; | ||
47 | - int i; | ||
48 | |||
49 | memset(&sess, 0, sizeof(sess)); | ||
50 | sess.cipher = CRYPTO_AES_CBC; | ||
51 | @@ -390,7 +386,6 @@ int main(int argc, char **argv) | ||
52 | { | ||
53 | int i; | ||
54 | int c; | ||
55 | - int index; | ||
56 | bool alg_flag; | ||
57 | char *alg_name; | ||
58 | struct test_params tp; | ||
59 | diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c | ||
60 | index 03f67bf..dbf9977 100644 | ||
61 | --- a/tests/cipher_comp.c | ||
62 | +++ b/tests/cipher_comp.c | ||
63 | @@ -33,7 +33,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
64 | |||
65 | struct crypt_op cryp; | ||
66 | |||
67 | - int ret = 0, fail = 0; | ||
68 | + int ret = 0; | ||
69 | |||
70 | data = malloc(datalen); | ||
71 | encrypted = malloc(datalen); | ||
72 | diff --git a/tests/hash_comp.c b/tests/hash_comp.c | ||
73 | index e6a4346..73f85ed 100644 | ||
74 | --- a/tests/hash_comp.c | ||
75 | +++ b/tests/hash_comp.c | ||
76 | @@ -36,7 +36,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
77 | |||
78 | struct crypt_op cryp; | ||
79 | |||
80 | - int ret = 0, fail = 0; | ||
81 | + int ret = 0; | ||
82 | |||
83 | data = malloc(datalen); | ||
84 | memset(data, datalen & 0xff, datalen); | ||
85 | @@ -66,7 +66,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
86 | |||
87 | if (memcmp(mac, mac_comp, AALG_MAX_RESULT_LEN)) { | ||
88 | printf("fail for datalen %d, MACs do not match!\n", datalen); | ||
89 | - fail = 1; | ||
90 | + ret = 1; | ||
91 | printf("wrong mac: "); | ||
92 | printhex(mac, 20); | ||
93 | printf("right mac: "); | ||
94 | @@ -88,7 +88,6 @@ main(int argc, char **argv) | ||
95 | struct session_op sess; | ||
96 | int datalen = BLOCK_SIZE; | ||
97 | int datalen_end = MAX_DATALEN; | ||
98 | - int i; | ||
99 | |||
100 | if (argc > 1) { | ||
101 | datalen = min(max(atoi(argv[1]), BLOCK_SIZE), MAX_DATALEN); | ||
102 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
103 | index 80a2c42..3b248f3 100644 | ||
104 | --- a/tests/hmac.c | ||
105 | +++ b/tests/hmac.c | ||
106 | @@ -212,8 +212,6 @@ test_extras(int cfd) | ||
107 | #endif | ||
108 | struct crypt_op cryp; | ||
109 | uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
110 | - uint8_t oldmac[AALG_MAX_RESULT_LEN]; | ||
111 | - uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; | ||
112 | uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; | ||
113 | int i; | ||
114 | |||
115 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
116 | index e5c6efe..9f2c8cc 100644 | ||
117 | --- a/tests/sha_speed.c | ||
118 | +++ b/tests/sha_speed.c | ||
119 | @@ -296,7 +296,6 @@ int main(void) | ||
120 | int fd; | ||
121 | int fdc; | ||
122 | int err; | ||
123 | - int i; | ||
124 | struct session_op sess; | ||
125 | |||
126 | signal(SIGALRM, alarm_handler); | ||
127 | -- | ||
128 | 2.10.2 | ||
129 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch b/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch new file mode 100644 index 00000000..27752374 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch | |||
@@ -0,0 +1,68 @@ | |||
1 | From 58da37b93d2532e489514b810c63d735a165ff09 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:47:58 +0300 | ||
4 | Subject: [PATCH 065/104] return error code of the test if there is one | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 15 +++++++++++---- | ||
9 | 1 file changed, 11 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index f2b9772..d843c02 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -239,6 +239,7 @@ int run_test(int id, struct test_params tp) | ||
16 | { | ||
17 | int fd; | ||
18 | int fdc; | ||
19 | + int err; | ||
20 | |||
21 | fd = open("/dev/crypto", O_RDWR, 0); | ||
22 | if (fd < 0) { | ||
23 | @@ -253,10 +254,12 @@ int run_test(int id, struct test_params tp) | ||
24 | if (!tp.mflag) { | ||
25 | fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
26 | } | ||
27 | - ciphers[id].func(fdc, tp); | ||
28 | + err = ciphers[id].func(fdc, tp); | ||
29 | |||
30 | close(fdc); | ||
31 | close(fd); | ||
32 | + | ||
33 | + return err; | ||
34 | } | ||
35 | |||
36 | void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
37 | @@ -384,6 +387,7 @@ int run_sha256(int fdc, struct test_params tp) | ||
38 | |||
39 | int main(int argc, char **argv) | ||
40 | { | ||
41 | + int err = 0; | ||
42 | int i; | ||
43 | int c; | ||
44 | bool alg_flag; | ||
45 | @@ -436,14 +440,17 @@ int main(int argc, char **argv) | ||
46 | |||
47 | if (alg_flag) { | ||
48 | if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
49 | - run_test(i, tp); | ||
50 | + err = run_test(i, tp); | ||
51 | } | ||
52 | } else { | ||
53 | - run_test(i, tp); | ||
54 | + err = run_test(i, tp); | ||
55 | + if (err != 0) { | ||
56 | + break; | ||
57 | + } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | - return 0; | ||
62 | + return err; | ||
63 | } | ||
64 | |||
65 | #else | ||
66 | -- | ||
67 | 2.10.2 | ||
68 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch b/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch new file mode 100644 index 00000000..3255dd81 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch | |||
@@ -0,0 +1,25 @@ | |||
1 | From af792c280ec5d76f473487cd1ed9335a6ec534de Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:49:36 +0300 | ||
4 | Subject: [PATCH 066/104] do more strict code checking to avoid maintenance | ||
5 | issues | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/Makefile | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/tests/Makefile b/tests/Makefile | ||
13 | index 14ae2c7..a27cf9b 100644 | ||
14 | --- a/tests/Makefile | ||
15 | +++ b/tests/Makefile | ||
16 | @@ -1,5 +1,5 @@ | ||
17 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
18 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration | ||
19 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
20 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
21 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
22 | |||
23 | -- | ||
24 | 2.10.2 | ||
25 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch b/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch new file mode 100644 index 00000000..e60e90a9 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch | |||
@@ -0,0 +1,52 @@ | |||
1 | From bd36f9cda9fb5eeebec23cc966a81e93b4fa8bf7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 12:53:11 +0300 | ||
4 | Subject: [PATCH 067/104] fix issues with install target | ||
5 | |||
6 | Aparently, on some setups, 'sudo make' will clear the $PWD variable | ||
7 | on the first Makefile expansion. This leads to failures of "sudo make | ||
8 | install" or other issues when trying to preserve the environment with | ||
9 | sudo -E. | ||
10 | |||
11 | There are two solutions to this problem: | ||
12 | 1) Use $$PWD instead of $(PWD) to render `$PWD` as the actual string to | ||
13 | be used on the secondary Makefile expansion. | ||
14 | This is used (albeit inconsistently) in the Linux kernel guide for | ||
15 | external modules: | ||
16 | kernel https://www.kernel.org/doc/Documentation/kbuild/modules.txt | ||
17 | |||
18 | 2) A second solution is based on GNU make which sets CURDIR to the | ||
19 | pathname of current working directory. This variable is never touched | ||
20 | again by make. | ||
21 | This solution is choosen for it is just as clear as the PWD one would | ||
22 | have been had it worked in the first place. | ||
23 | |||
24 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
25 | |||
26 | |||
27 | |||
28 | --- a/Makefileold 2017-04-18 13:55:30.740561749 +0800 | ||
29 | +++ b/Makefile 2017-04-18 13:58:04.348556431 +0800 | ||
30 | @@ -15,7 +15,7 @@ | ||
31 | |||
32 | obj-m += cryptodev.o | ||
33 | |||
34 | -KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) | ||
35 | +KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(CURDIR) | ||
36 | ifneq ($(ARCH),) | ||
37 | KERNEL_MAKE_OPTS += ARCH=$(ARCH) | ||
38 | endif | ||
39 | @@ -32,11 +32,11 @@ | ||
40 | install: modules_install | ||
41 | |||
42 | modules_install: | ||
43 | - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install | ||
44 | + $(MAKE) $(KERNEL_MAKE_OPTS) modules_install | ||
45 | install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h | ||
46 | |||
47 | clean: | ||
48 | - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean | ||
49 | + $(MAKE) $(KERNEL_MAKE_OPTS) clean | ||
50 | rm -f $(hostprogs) *~ | ||
51 | CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
52 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch new file mode 100644 index 00000000..07156a6f --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch | |||
@@ -0,0 +1,24 @@ | |||
1 | From 39f0c5ae656f4b487a0950235e2371e4dd840594 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 13:11:11 +0300 | ||
4 | Subject: [PATCH 068/104] setting KERNEL_DIR is not necessary to build tests | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 2 -- | ||
9 | 1 file changed, 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index a27cf9b..e7a60cb 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -1,6 +1,4 @@ | ||
16 | -KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
17 | CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
18 | -KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
19 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
20 | |||
21 | comp_progs := cipher_comp hash_comp hmac_comp | ||
22 | -- | ||
23 | 2.10.2 | ||
24 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch b/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch new file mode 100644 index 00000000..91a3c0db --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From 99ce54741ccbbe8581ab83b73ab11d2dae4f01b1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 14:55:28 +0300 | ||
4 | Subject: [PATCH 069/104] fix the reported unit | ||
5 | |||
6 | 1GiB = 1024*1024*1024 | ||
7 | 1GB = 1000000000 | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index 331158b..bf5f1c6 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -93,7 +93,7 @@ function run_parallel | ||
19 | echo | ||
20 | echo "buffer size : $nvalue" | ||
21 | echo "running time : $runtime" | ||
22 | - echo "avg_speed : $avg_speed GiB/s" | ||
23 | + echo "avg_speed : $avg_speed GB/s" | ||
24 | echo "all_cpu idle : $cpu_idle %" | ||
25 | echo | ||
26 | } | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch b/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch new file mode 100644 index 00000000..270b69e1 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | From 73748415251dbf3d6e3fc9531e38b8e61ff63e20 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 15:09:04 +0300 | ||
4 | Subject: [PATCH 070/104] remove old results to avoid incorrect reports | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 +++ | ||
9 | 1 file changed, 3 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index bf5f1c6..10b2348 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -108,6 +108,9 @@ function main | ||
16 | { | ||
17 | [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
18 | |||
19 | + rm -f ${OUT_BASENAME}_* | ||
20 | + rm -f ${MPSTAT_OUT} | ||
21 | + | ||
22 | while getopts hm:t:n: option | ||
23 | do | ||
24 | case "$option" in | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch b/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch new file mode 100644 index 00000000..f52e09a8 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From d9de6a0f342b2291e2f2d82b594fbb3b8ed7f468 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 09:29:24 +0300 | ||
4 | Subject: [PATCH 071/104] fix the scale of the runtime value | ||
5 | |||
6 | Subtraction operation does not honor the scale variable. Only | ||
7 | division does. | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index 10b2348..659be0e 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -85,7 +85,7 @@ function run_parallel | ||
19 | |||
20 | wait $MPSTAT_PID | ||
21 | |||
22 | - runtime=$(echo "scale=2; $end - $start" | bc -l ) | ||
23 | + runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
24 | total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
25 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
26 | cpu_idle=`get_cpu_idle` | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch b/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch new file mode 100644 index 00000000..0cf2a0c2 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch | |||
@@ -0,0 +1,82 @@ | |||
1 | From abcf5983f6d69c5ff35e77fb79ea7afe2149411a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 09:33:11 +0300 | ||
4 | Subject: [PATCH 072/104] use $(...) instead of `...` for consistency | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 24 ++++++++++++------------ | ||
9 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 659be0e..e10dc0d 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -19,7 +19,7 @@ | ||
16 | |||
17 | # no user-configurable options below this line | ||
18 | |||
19 | -NUM_CORES=`nproc` | ||
20 | +NUM_CORES=$(nproc) | ||
21 | OUT_BASENAME="async_speed" | ||
22 | S_TIME_FORMAT=ISO | ||
23 | MPSTAT_OUT="mpstat_out" | ||
24 | @@ -44,9 +44,9 @@ function SUM { | ||
25 | |||
26 | function get_cpu_idle | ||
27 | { | ||
28 | - header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
29 | - idle_column=`echo $header_line | wc -w` | ||
30 | - average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
31 | + header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
32 | + idle_column=$(echo $header_line | wc -w) | ||
33 | + average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
34 | |||
35 | echo $average_idle | ||
36 | } | ||
37 | @@ -66,9 +66,9 @@ function run_parallel | ||
38 | MPSTAT_PID=$! | ||
39 | |||
40 | PIDS="" | ||
41 | - start=`date +%s.%N` | ||
42 | + start=$(date +%s.%N) | ||
43 | |||
44 | - for i in `seq 0 $(($mvalue-1))` | ||
45 | + for i in $(seq 0 $(($mvalue-1))) | ||
46 | do | ||
47 | CMD_OUT="${OUT_BASENAME}_${i}" | ||
48 | |||
49 | @@ -81,14 +81,14 @@ function run_parallel | ||
50 | done | ||
51 | |||
52 | wait $PIDS | ||
53 | - end=`date +%s.%N` | ||
54 | + end=$(date +%s.%N) | ||
55 | |||
56 | wait $MPSTAT_PID | ||
57 | |||
58 | runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
59 | - total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
60 | + total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
61 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
62 | - cpu_idle=`get_cpu_idle` | ||
63 | + cpu_idle=$(get_cpu_idle) | ||
64 | |||
65 | echo | ||
66 | echo "buffer size : $nvalue" | ||
67 | @@ -124,9 +124,9 @@ function main | ||
68 | shift $((OPTIND-1)) | ||
69 | alg_name=$1 | ||
70 | |||
71 | - [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
72 | - [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
73 | - [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
74 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
75 | + [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
76 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
77 | |||
78 | [ "$tvalue" -lt 5 ] && tvalue=5 | ||
79 | |||
80 | -- | ||
81 | 2.10.2 | ||
82 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch b/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch new file mode 100644 index 00000000..54108701 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch | |||
@@ -0,0 +1,34 @@ | |||
1 | From 787cbdf6b032964df00c4379d9a81ba4384a492e Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:06:08 +0300 | ||
4 | Subject: [PATCH 073/104] really fix (again...) the mpstat issue | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 +-- | ||
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index e10dc0d..22a12cb 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -21,7 +21,6 @@ | ||
16 | |||
17 | NUM_CORES=$(nproc) | ||
18 | OUT_BASENAME="async_speed" | ||
19 | -S_TIME_FORMAT=ISO | ||
20 | MPSTAT_OUT="mpstat_out" | ||
21 | |||
22 | function usage | ||
23 | @@ -62,7 +61,7 @@ function run_parallel | ||
24 | echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
25 | echo " $CMD" | ||
26 | |||
27 | - (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
28 | + (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
29 | MPSTAT_PID=$! | ||
30 | |||
31 | PIDS="" | ||
32 | -- | ||
33 | 2.10.2 | ||
34 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch b/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch new file mode 100644 index 00000000..16eadacd --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch | |||
@@ -0,0 +1,83 @@ | |||
1 | From 826f2feb22f5391e985930af40782b2fb980e028 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:12:25 +0300 | ||
4 | Subject: [PATCH 074/104] make default output tabular | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 33 +++++++++++++++++++++++---------- | ||
9 | 1 file changed, 23 insertions(+), 10 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 22a12cb..b509c25 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -31,6 +31,7 @@ Usage: `basename $0` [OPTIONS] <alg_name> | ||
16 | -m <threads> number of threads to run with (defaults to number of cores) | ||
17 | -t <secs> time to run each test (default 10 secs) | ||
18 | -n <bytes> size of the test buffer (default 256 bytes) | ||
19 | + -v make output more verbose (default tabular) | ||
20 | -h show this help | ||
21 | |||
22 | alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
23 | @@ -57,9 +58,12 @@ function run_parallel | ||
24 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
25 | CMD="async_speed $OPTIONS $alg_name" | ||
26 | |||
27 | - echo | ||
28 | - echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
29 | - echo " $CMD" | ||
30 | + if [ ! -z "$vvalue" ] | ||
31 | + then | ||
32 | + echo | ||
33 | + echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
34 | + echo " $CMD" | ||
35 | + fi | ||
36 | |||
37 | (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
38 | MPSTAT_PID=$! | ||
39 | @@ -89,12 +93,20 @@ function run_parallel | ||
40 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
41 | cpu_idle=$(get_cpu_idle) | ||
42 | |||
43 | - echo | ||
44 | - echo "buffer size : $nvalue" | ||
45 | - echo "running time : $runtime" | ||
46 | - echo "avg_speed : $avg_speed GB/s" | ||
47 | - echo "all_cpu idle : $cpu_idle %" | ||
48 | - echo | ||
49 | + if [ ! -z "$vvalue" ] | ||
50 | + then | ||
51 | + echo | ||
52 | + echo "buffer size : $nvalue" | ||
53 | + echo "running time : $runtime" | ||
54 | + echo "avg_speed : $avg_speed GB/s" | ||
55 | + echo "all_cpu idle : $cpu_idle %" | ||
56 | + echo | ||
57 | + else | ||
58 | + echo -e "algorithm\t""threads\t""runtime\t"\ | ||
59 | + "buf_size\t""GB/s\t""%cpu_idle" | ||
60 | + echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
61 | + "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
62 | + fi | ||
63 | } | ||
64 | |||
65 | function control_c | ||
66 | @@ -110,12 +122,13 @@ function main | ||
67 | rm -f ${OUT_BASENAME}_* | ||
68 | rm -f ${MPSTAT_OUT} | ||
69 | |||
70 | - while getopts hm:t:n: option | ||
71 | + while getopts vhm:t:n: option | ||
72 | do | ||
73 | case "$option" in | ||
74 | m) mvalue="$OPTARG";; | ||
75 | t) tvalue="$OPTARG";; | ||
76 | n) nvalue="$OPTARG";; | ||
77 | + v) vvalue="verbose";; | ||
78 | *) usage $0; exit 1;; | ||
79 | esac | ||
80 | done | ||
81 | -- | ||
82 | 2.10.2 | ||
83 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch b/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch new file mode 100644 index 00000000..79ca7d2f --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | From fbf88220797a95281457680a18e9241b3af1f3fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:27:16 +0300 | ||
4 | Subject: [PATCH 075/104] fix incorrect handling of error cases... | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index b509c25..862f39d 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -117,7 +117,8 @@ function control_c | ||
16 | |||
17 | function main | ||
18 | { | ||
19 | - [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
20 | + [ ! -e "/dev/crypto" ] && | ||
21 | + (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
22 | |||
23 | rm -f ${OUT_BASENAME}_* | ||
24 | rm -f ${MPSTAT_OUT} | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch b/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch new file mode 100644 index 00000000..0570e1a2 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch | |||
@@ -0,0 +1,48 @@ | |||
1 | From 87214642cbfc6dbd43948940b5d1ce9528f451bd Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:46:01 +0300 | ||
4 | Subject: [PATCH 076/104] exit early if cryptodev tests are not installed | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 10 +++++++++- | ||
9 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 862f39d..62c4759 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -20,6 +20,7 @@ | ||
16 | # no user-configurable options below this line | ||
17 | |||
18 | NUM_CORES=$(nproc) | ||
19 | +CMD_BIN="async_speed" | ||
20 | OUT_BASENAME="async_speed" | ||
21 | MPSTAT_OUT="mpstat_out" | ||
22 | |||
23 | @@ -56,7 +57,7 @@ function run_parallel | ||
24 | trap control_c SIGINT | ||
25 | |||
26 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
27 | - CMD="async_speed $OPTIONS $alg_name" | ||
28 | + CMD="$CMD_BIN $OPTIONS $alg_name" | ||
29 | |||
30 | if [ ! -z "$vvalue" ] | ||
31 | then | ||
32 | @@ -120,6 +121,13 @@ function main | ||
33 | [ ! -e "/dev/crypto" ] && | ||
34 | (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
35 | |||
36 | + $(which ${CMD_BIN} &> /dev/null) | ||
37 | + if (($? != 0)) | ||
38 | + then | ||
39 | + echo "${CMD_BIN} test is not installed" | ||
40 | + exit 1 | ||
41 | + fi | ||
42 | + | ||
43 | rm -f ${OUT_BASENAME}_* | ||
44 | rm -f ${MPSTAT_OUT} | ||
45 | |||
46 | -- | ||
47 | 2.10.2 | ||
48 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch b/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch new file mode 100644 index 00000000..b4ab34ce --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch | |||
@@ -0,0 +1,66 @@ | |||
1 | From 76de6db1bc69b2239d8fb91fd65b74610cb8e22f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 16:41:10 +0300 | ||
4 | Subject: [PATCH 077/104] the C standard used by cryptodev is C90 with GNU | ||
5 | extensions | ||
6 | |||
7 | This avoids some problems with gcc>=5.0 which chaged the default to C11. | ||
8 | The choice for gnu90 is based on the C standard used by Linux kernel which | ||
9 | is gnu90 as well. | ||
10 | |||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
12 | --- | ||
13 | Makefile | 6 +++--- | ||
14 | lib/Makefile | 2 +- | ||
15 | tests/Makefile | 2 +- | ||
16 | 3 files changed, 5 insertions(+), 5 deletions(-) | ||
17 | |||
18 | diff --git a/Makefile b/Makefile | ||
19 | index 90e86d9..80439f6 100644 | ||
20 | --- a/Makefile | ||
21 | +++ b/Makefile | ||
22 | @@ -3,7 +3,7 @@ | ||
23 | # disabled by default. To re-enable it uncomment the | ||
24 | # corresponding CFLAG. | ||
25 | # | ||
26 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
27 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 | ||
28 | KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) | ||
29 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
30 | VERSION = 1.8 | ||
31 | @@ -38,10 +38,10 @@ modules_install: | ||
32 | clean: | ||
33 | $(MAKE) $(KERNEL_MAKE_OPTS) clean | ||
34 | rm -f $(hostprogs) *~ | ||
35 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
36 | + CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests clean | ||
37 | |||
38 | check: | ||
39 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check | ||
40 | + CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests check | ||
41 | |||
42 | testprogs: | ||
43 | KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests all | ||
44 | diff --git a/lib/Makefile b/lib/Makefile | ||
45 | index 3bedc34..0044613 100644 | ||
46 | --- a/lib/Makefile | ||
47 | +++ b/lib/Makefile | ||
48 | @@ -1,4 +1,4 @@ | ||
49 | -CFLAGS=-g -O2 -Wall | ||
50 | +CFLAGS=-g -O2 -Wall -std=gnu90 | ||
51 | |||
52 | all: benchmark | ||
53 | |||
54 | diff --git a/tests/Makefile b/tests/Makefile | ||
55 | index e7a60cb..23d67f9 100644 | ||
56 | --- a/tests/Makefile | ||
57 | +++ b/tests/Makefile | ||
58 | @@ -1,4 +1,4 @@ | ||
59 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
60 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror | ||
61 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
62 | |||
63 | comp_progs := cipher_comp hash_comp hmac_comp | ||
64 | -- | ||
65 | 2.10.2 | ||
66 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch b/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch new file mode 100644 index 00000000..3b474a38 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From 0bd3dada58288792f587712c95a1f125a7655535 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 09:05:26 +0300 | ||
4 | Subject: [PATCH 078/104] remove output line because it does not add clarity to | ||
5 | the results | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_speed_multi.sh | 7 ------- | ||
10 | 1 file changed, 7 deletions(-) | ||
11 | |||
12 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
13 | index 62c4759..991e190 100755 | ||
14 | --- a/tests/async_speed_multi.sh | ||
15 | +++ b/tests/async_speed_multi.sh | ||
16 | @@ -59,13 +59,6 @@ function run_parallel | ||
17 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
18 | CMD="$CMD_BIN $OPTIONS $alg_name" | ||
19 | |||
20 | - if [ ! -z "$vvalue" ] | ||
21 | - then | ||
22 | - echo | ||
23 | - echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
24 | - echo " $CMD" | ||
25 | - fi | ||
26 | - | ||
27 | (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
28 | MPSTAT_PID=$! | ||
29 | |||
30 | -- | ||
31 | 2.10.2 | ||
32 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch b/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch new file mode 100644 index 00000000..7003692b --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From 9c8d7ce749931de6c7604b3b8be44d4a17bcd7d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 09:11:13 +0300 | ||
4 | Subject: [PATCH 079/104] fix typo, use consistent spacing | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 991e190..125d45c 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -96,8 +96,8 @@ function run_parallel | ||
16 | echo "all_cpu idle : $cpu_idle %" | ||
17 | echo | ||
18 | else | ||
19 | - echo -e "algorithm\t""threads\t""runtime\t"\ | ||
20 | - "buf_size\t""GB/s\t""%cpu_idle" | ||
21 | + echo -e "algorithm\t""threads\t""run time\t"\ | ||
22 | + "buffer size\t""GB/s\t""%cpu idle" | ||
23 | echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
24 | "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
25 | fi | ||
26 | -- | ||
27 | 2.10.2 | ||
28 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch b/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch new file mode 100644 index 00000000..64450df9 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From 9a486f5ebf648971db9bdbd30f7e52251a659ddd Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 12:01:00 +0300 | ||
4 | Subject: [PATCH 080/104] graceful exit if cryptodev is not built with ASYNC | ||
5 | flags | ||
6 | |||
7 | --- | ||
8 | tests/async_speed_multi.sh | 7 +++++++ | ||
9 | 1 file changed, 7 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 125d45c..f2a8ba6 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -82,6 +82,13 @@ function run_parallel | ||
16 | |||
17 | wait $MPSTAT_PID | ||
18 | |||
19 | + grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
20 | + if (($? == 0)) | ||
21 | + then | ||
22 | + echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
23 | + exit 1 | ||
24 | + fi | ||
25 | + | ||
26 | runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
27 | total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
28 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
29 | -- | ||
30 | 2.10.2 | ||
31 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch b/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch new file mode 100644 index 00000000..5e8893b6 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch | |||
@@ -0,0 +1,718 @@ | |||
1 | From b13160357e683b9d42ba513433b4c09456a8332b Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 13:39:50 +0300 | ||
4 | Subject: [PATCH 081/104] add sync speed tests with the same format as async | ||
5 | ones | ||
6 | |||
7 | The file speed.c was removed because has the same functionality | ||
8 | as sync_speed.c | ||
9 | |||
10 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
11 | --- | ||
12 | tests/Makefile | 4 +- | ||
13 | tests/speed.c | 265 ----------------------------------- | ||
14 | tests/sync_speed.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | 3 files changed, 401 insertions(+), 267 deletions(-) | ||
16 | delete mode 100644 tests/speed.c | ||
17 | create mode 100644 tests/sync_speed.c | ||
18 | |||
19 | diff --git a/tests/Makefile b/tests/Makefile | ||
20 | index 23d67f9..400fb7a 100644 | ||
21 | --- a/tests/Makefile | ||
22 | +++ b/tests/Makefile | ||
23 | @@ -3,14 +3,14 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
24 | |||
25 | comp_progs := cipher_comp hash_comp hmac_comp | ||
26 | |||
27 | -hostprogs := cipher cipher-aead hmac speed async_cipher async_hmac \ | ||
28 | +hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ | ||
29 | async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
30 | cipher-aead-srtp $(comp_progs) | ||
31 | |||
32 | example-cipher-objs := cipher.o | ||
33 | example-cipher-aead-objs := cipher-aead.o | ||
34 | example-hmac-objs := hmac.o | ||
35 | -example-speed-objs := speed.c | ||
36 | +example-speed-objs := sync_speed.o | ||
37 | example-fullspeed-objs := fullspeed.c | ||
38 | example-sha-speed-objs := sha_speed.c | ||
39 | example-async-cipher-objs := async_cipher.o | ||
40 | diff --git a/tests/speed.c b/tests/speed.c | ||
41 | deleted file mode 100644 | ||
42 | index 0e2bbc3..0000000 | ||
43 | --- a/tests/speed.c | ||
44 | +++ /dev/null | ||
45 | @@ -1,265 +0,0 @@ | ||
46 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
47 | - * | ||
48 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
49 | - * | ||
50 | - * This program is free software; you can redistribute it and/or modify | ||
51 | - * it under the terms of the GNU General Public License as published by | ||
52 | - * the Free Software Foundation; either version 2 of the License, or | ||
53 | - * (at your option) any later version. | ||
54 | - * | ||
55 | - * This program is distributed in the hope that it will be useful, | ||
56 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
57 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
58 | - * GNU General Public License for more details. | ||
59 | - * | ||
60 | - * You should have received a copy of the GNU General Public License | ||
61 | - * along with this program; if not, write to the Free Software | ||
62 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
63 | - */ | ||
64 | -#include <fcntl.h> | ||
65 | -#include <stdio.h> | ||
66 | -#include <stdlib.h> | ||
67 | -#include <string.h> | ||
68 | -#include <sys/ioctl.h> | ||
69 | -#include <sys/time.h> | ||
70 | -#include <sys/types.h> | ||
71 | -#include <signal.h> | ||
72 | -#include <unistd.h> | ||
73 | -#include <stdint.h> | ||
74 | - | ||
75 | -#include <crypto/cryptodev.h> | ||
76 | - | ||
77 | -static int si = 1; /* SI by default */ | ||
78 | - | ||
79 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
80 | -{ | ||
81 | - return (double)(end.tv_usec - start.tv_usec) + | ||
82 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
83 | -} | ||
84 | - | ||
85 | -static int must_finish = 0; | ||
86 | - | ||
87 | -static void alarm_handler(int signo) | ||
88 | -{ | ||
89 | - must_finish = 1; | ||
90 | -} | ||
91 | - | ||
92 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
93 | -static char *si_units[] = { "", "K", "M", "G", "T", 0}; | ||
94 | - | ||
95 | -static void value2human(int si, double bytes, double time, double* data, double* speed,char* metric) | ||
96 | -{ | ||
97 | - int unit = 0; | ||
98 | - | ||
99 | - *data = bytes; | ||
100 | - | ||
101 | - if (si) { | ||
102 | - while (*data > 1000 && si_units[unit + 1]) { | ||
103 | - *data /= 1000; | ||
104 | - unit++; | ||
105 | - } | ||
106 | - *speed = *data / time; | ||
107 | - sprintf(metric, "%sB", si_units[unit]); | ||
108 | - } else { | ||
109 | - while (*data > 1024 && units[unit + 1]) { | ||
110 | - *data /= 1024; | ||
111 | - unit++; | ||
112 | - } | ||
113 | - *speed = *data / time; | ||
114 | - sprintf(metric, "%sB", units[unit]); | ||
115 | - } | ||
116 | -} | ||
117 | - | ||
118 | -#define MAX(x,y) ((x)>(y)?(x):(y)) | ||
119 | - | ||
120 | -int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
121 | -{ | ||
122 | - struct crypt_op cop; | ||
123 | - char *buffer, iv[32]; | ||
124 | - uint8_t mac[HASH_MAX_LEN]; | ||
125 | - static int val = 23; | ||
126 | - struct timeval start, end; | ||
127 | - double total = 0; | ||
128 | - double secs, ddata, dspeed; | ||
129 | - char metric[16]; | ||
130 | - int min_alignmask = sizeof(void*) - 1; | ||
131 | - | ||
132 | - if (alignmask) { | ||
133 | - alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
134 | - if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { | ||
135 | - printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); | ||
136 | - return 1; | ||
137 | - } | ||
138 | - } else { | ||
139 | - if (!(buffer = malloc(chunksize))) { | ||
140 | - perror("malloc()"); | ||
141 | - return 1; | ||
142 | - } | ||
143 | - } | ||
144 | - | ||
145 | - memset(iv, 0x23, 32); | ||
146 | - | ||
147 | - printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
148 | - fflush(stdout); | ||
149 | - | ||
150 | - memset(buffer, val++, chunksize); | ||
151 | - | ||
152 | - must_finish = 0; | ||
153 | - alarm(5); | ||
154 | - | ||
155 | - gettimeofday(&start, NULL); | ||
156 | - do { | ||
157 | - memset(&cop, 0, sizeof(cop)); | ||
158 | - cop.ses = sess->ses; | ||
159 | - cop.len = chunksize; | ||
160 | - cop.iv = (unsigned char *)iv; | ||
161 | - cop.op = COP_ENCRYPT; | ||
162 | - cop.src = cop.dst = (unsigned char *)buffer; | ||
163 | - cop.mac = mac; | ||
164 | - | ||
165 | - if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
166 | - perror("ioctl(CIOCCRYPT)"); | ||
167 | - return 1; | ||
168 | - } | ||
169 | - total+=chunksize; | ||
170 | - } while(must_finish==0); | ||
171 | - gettimeofday(&end, NULL); | ||
172 | - | ||
173 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
174 | - | ||
175 | - value2human(si, total, secs, &ddata, &dspeed, metric); | ||
176 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
177 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
178 | - | ||
179 | - free(buffer); | ||
180 | - return 0; | ||
181 | -} | ||
182 | - | ||
183 | -int main(int argc, char** argv) | ||
184 | -{ | ||
185 | - int fd, i, fdc = -1, alignmask = 0; | ||
186 | - struct session_op sess; | ||
187 | -#ifdef CIOCGSESSINFO | ||
188 | - struct session_info_op siop; | ||
189 | -#endif | ||
190 | - char keybuf[32]; | ||
191 | - | ||
192 | - signal(SIGALRM, alarm_handler); | ||
193 | - | ||
194 | - if (argc > 1) { | ||
195 | - if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { | ||
196 | - printf("Usage: speed [--kib]\n"); | ||
197 | - exit(0); | ||
198 | - } | ||
199 | - if (strcmp(argv[1], "--kib") == 0) { | ||
200 | - si = 0; | ||
201 | - } | ||
202 | - } | ||
203 | - | ||
204 | - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { | ||
205 | - perror("open()"); | ||
206 | - return 1; | ||
207 | - } | ||
208 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
209 | - perror("ioctl(CRIOGET)"); | ||
210 | - return 1; | ||
211 | - } | ||
212 | - | ||
213 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
214 | - memset(&sess, 0, sizeof(sess)); | ||
215 | - sess.cipher = CRYPTO_NULL; | ||
216 | - sess.keylen = 0; | ||
217 | - sess.key = (unsigned char *)keybuf; | ||
218 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
219 | - perror("ioctl(CIOCGSESSION)"); | ||
220 | - return 1; | ||
221 | - } | ||
222 | -#ifdef CIOCGSESSINFO | ||
223 | - siop.ses = sess.ses; | ||
224 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
225 | - perror("ioctl(CIOCGSESSINFO)"); | ||
226 | - return 1; | ||
227 | - } | ||
228 | - alignmask = siop.alignmask; | ||
229 | -#endif | ||
230 | - | ||
231 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
232 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
233 | - break; | ||
234 | - } | ||
235 | - | ||
236 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
237 | - memset(&sess, 0, sizeof(sess)); | ||
238 | - sess.cipher = CRYPTO_AES_CBC; | ||
239 | - sess.keylen = 16; | ||
240 | - memset(keybuf, 0x42, 16); | ||
241 | - sess.key = (unsigned char *)keybuf; | ||
242 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
243 | - perror("ioctl(CIOCGSESSION)"); | ||
244 | - return 1; | ||
245 | - } | ||
246 | -#ifdef CIOCGSESSINFO | ||
247 | - siop.ses = sess.ses; | ||
248 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
249 | - perror("ioctl(CIOCGSESSINFO)"); | ||
250 | - return 1; | ||
251 | - } | ||
252 | - alignmask = siop.alignmask; | ||
253 | -#endif | ||
254 | - | ||
255 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
256 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
257 | - break; | ||
258 | - } | ||
259 | - | ||
260 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
261 | - memset(&sess, 0, sizeof(sess)); | ||
262 | - sess.cipher = CRYPTO_AES_XTS; | ||
263 | - sess.keylen = 32; | ||
264 | - memset(keybuf, 0x42, sess.keylen); | ||
265 | - sess.key = (unsigned char *)keybuf; | ||
266 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
267 | - perror("ioctl(CIOCGSESSION)"); | ||
268 | - return 1; | ||
269 | - } | ||
270 | -#ifdef CIOCGSESSINFO | ||
271 | - siop.ses = sess.ses; | ||
272 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
273 | - perror("ioctl(CIOCGSESSINFO)"); | ||
274 | - return 1; | ||
275 | - } | ||
276 | - alignmask = siop.alignmask; | ||
277 | -#endif | ||
278 | - | ||
279 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
280 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
281 | - break; | ||
282 | - } | ||
283 | - | ||
284 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
285 | - memset(&sess, 0, sizeof(sess)); | ||
286 | - sess.mac = CRYPTO_CRC32C; | ||
287 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
288 | - perror("ioctl(CIOCGSESSION)"); | ||
289 | - return 1; | ||
290 | - } | ||
291 | -#ifdef CIOCGSESSINFO | ||
292 | - siop.ses = sess.ses; | ||
293 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
294 | - perror("ioctl(CIOCGSESSINFO)"); | ||
295 | - return 1; | ||
296 | - } | ||
297 | - printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
298 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
299 | - alignmask = siop.alignmask; | ||
300 | -#endif | ||
301 | - | ||
302 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
303 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
304 | - break; | ||
305 | - } | ||
306 | - | ||
307 | - close(fdc); | ||
308 | - close(fd); | ||
309 | - return 0; | ||
310 | -} | ||
311 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
312 | new file mode 100644 | ||
313 | index 0000000..b0cb9ad | ||
314 | --- /dev/null | ||
315 | +++ b/tests/sync_speed.c | ||
316 | @@ -0,0 +1,399 @@ | ||
317 | +/* cryptodev_test - simple benchmark tool for cryptodev | ||
318 | + * | ||
319 | + * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
320 | + * | ||
321 | + * This program is free software; you can redistribute it and/or modify | ||
322 | + * it under the terms of the GNU General Public License as published by | ||
323 | + * the Free Software Foundation; either version 2 of the License, or | ||
324 | + * (at your option) any later version. | ||
325 | + * | ||
326 | + * This program is distributed in the hope that it will be useful, | ||
327 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
328 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
329 | + * GNU General Public License for more details. | ||
330 | + * | ||
331 | + * You should have received a copy of the GNU General Public License | ||
332 | + * along with this program; if not, write to the Free Software | ||
333 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
334 | + */ | ||
335 | +#include <errno.h> | ||
336 | +#include <fcntl.h> | ||
337 | +#include <poll.h> | ||
338 | +#include <stdio.h> | ||
339 | +#include <stdlib.h> | ||
340 | +#include <string.h> | ||
341 | +#include <sys/ioctl.h> | ||
342 | +#include <sys/time.h> | ||
343 | +#include <sys/types.h> | ||
344 | +#include <signal.h> | ||
345 | +#include <crypto/cryptodev.h> | ||
346 | +#include <stdbool.h> | ||
347 | +#include <unistd.h> | ||
348 | + | ||
349 | +struct test_params { | ||
350 | + bool tflag; | ||
351 | + bool nflag; | ||
352 | + int tvalue; | ||
353 | + int nvalue; | ||
354 | +}; | ||
355 | + | ||
356 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
357 | + "Run benchmark test for cipher or hash\n\n" | ||
358 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
359 | + " -n <bytes>\t" "size of the test buffer\n" | ||
360 | + " -h\t\t" "show this help\n" | ||
361 | +; | ||
362 | + | ||
363 | +int run_null(int fdc, struct test_params tp); | ||
364 | +int run_aes_cbc(int fdc, struct test_params tp); | ||
365 | +int run_aes_xts(int fdc, struct test_params tp); | ||
366 | +int run_crc32c(int fdc, struct test_params tp); | ||
367 | +int run_sha1(int fdc, struct test_params tp); | ||
368 | +int run_sha256(int fdc, struct test_params tp); | ||
369 | +int get_alignmask(int fdc, struct session_op *sess); | ||
370 | + | ||
371 | +#define ALG_COUNT 6 | ||
372 | +struct { | ||
373 | + char *name; | ||
374 | + int (*func)(int, struct test_params); | ||
375 | +} ciphers[ALG_COUNT] = { | ||
376 | + {"null", run_null}, | ||
377 | + {"aes-cbc", run_aes_cbc}, | ||
378 | + {"aes-xts", run_aes_xts}, | ||
379 | + {"crc32c", run_crc32c}, | ||
380 | + {"sha1", run_sha1}, | ||
381 | + {"sha256", run_sha256}, | ||
382 | +}; | ||
383 | + | ||
384 | +static double udifftimeval(struct timeval start, struct timeval end) | ||
385 | +{ | ||
386 | + return (double)(end.tv_usec - start.tv_usec) + | ||
387 | + (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
388 | +} | ||
389 | + | ||
390 | +static int must_finish = 0; | ||
391 | +static int must_exit = 0; | ||
392 | + | ||
393 | +static void alarm_handler(int signo) | ||
394 | +{ | ||
395 | + must_finish = 1; | ||
396 | +} | ||
397 | + | ||
398 | +static void exit_handler(int signo) | ||
399 | +{ | ||
400 | + must_exit = 1; | ||
401 | + printf("\nexit requested by user through ctrl+c \n"); | ||
402 | +} | ||
403 | + | ||
404 | +static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
405 | + | ||
406 | +static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
407 | +{ | ||
408 | + int unit = 0; | ||
409 | + | ||
410 | + *data = bytes; | ||
411 | + while (*data > 1024 && units[unit + 1]) { | ||
412 | + *data /= 1024; | ||
413 | + unit++; | ||
414 | + } | ||
415 | + *speed = *data / time; | ||
416 | + sprintf(metric, "%sB", units[unit]); | ||
417 | +} | ||
418 | + | ||
419 | +static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
420 | +{ | ||
421 | + struct crypt_op cop; | ||
422 | + char *buffer, iv[32]; | ||
423 | + char mac[HASH_MAX_LEN]; | ||
424 | + static int val = 23; | ||
425 | + struct timeval start, end; | ||
426 | + double total = 0; | ||
427 | + double secs, ddata, dspeed; | ||
428 | + char metric[16]; | ||
429 | + int alignmask; | ||
430 | + int min_alignmask = sizeof(void*) - 1; | ||
431 | + | ||
432 | + memset(iv, 0x23, 32); | ||
433 | + | ||
434 | + printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
435 | + fflush(stdout); | ||
436 | + | ||
437 | + alignmask = get_alignmask(fdc, sess); | ||
438 | + if (alignmask) { | ||
439 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
440 | + if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
441 | + printf("posix_memalign() failed!\n"); | ||
442 | + return 1; | ||
443 | + } | ||
444 | + } else { | ||
445 | + if (!(buffer = malloc(tp.nvalue))) { | ||
446 | + perror("malloc()"); | ||
447 | + return 1; | ||
448 | + } | ||
449 | + } | ||
450 | + memset(buffer, val++, tp.nvalue); | ||
451 | + | ||
452 | + must_finish = 0; | ||
453 | + alarm(tp.tvalue); | ||
454 | + | ||
455 | + gettimeofday(&start, NULL); | ||
456 | + do { | ||
457 | + memset(&cop, 0, sizeof(cop)); | ||
458 | + cop.ses = sess->ses; | ||
459 | + cop.len = tp.nvalue; | ||
460 | + cop.iv = (unsigned char *)iv; | ||
461 | + cop.op = COP_ENCRYPT; | ||
462 | + cop.src = cop.dst = (unsigned char *)buffer; | ||
463 | + cop.mac = (unsigned char *)mac; | ||
464 | + | ||
465 | + if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
466 | + perror("ioctl(CIOCCRYPT)"); | ||
467 | + return 1; | ||
468 | + } | ||
469 | + total += cop.len; | ||
470 | + } while(!must_finish); | ||
471 | + gettimeofday(&end, NULL); | ||
472 | + | ||
473 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
474 | + | ||
475 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
476 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
477 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
478 | + | ||
479 | + free(buffer); | ||
480 | + return 0; | ||
481 | +} | ||
482 | + | ||
483 | +void usage(char *cmd_name) | ||
484 | +{ | ||
485 | + printf(usage_str, cmd_name); | ||
486 | +} | ||
487 | + | ||
488 | +int run_test(int id, struct test_params tp) | ||
489 | +{ | ||
490 | + int fd; | ||
491 | + int fdc; | ||
492 | + | ||
493 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
494 | + if (fd < 0) { | ||
495 | + perror("open()"); | ||
496 | + return fd; | ||
497 | + } | ||
498 | + if (ioctl(fd, CRIOGET, &fdc)) { | ||
499 | + perror("ioctl(CRIOGET)"); | ||
500 | + return -EINVAL; | ||
501 | + } | ||
502 | + | ||
503 | + ciphers[id].func(fdc, tp); | ||
504 | + | ||
505 | + close(fdc); | ||
506 | + close(fd); | ||
507 | + | ||
508 | + return 0; | ||
509 | +} | ||
510 | + | ||
511 | +int get_alignmask(int fdc, struct session_op *sess) | ||
512 | +{ | ||
513 | + int alignmask; | ||
514 | + | ||
515 | +#ifdef CIOCGSESSINFO | ||
516 | + struct session_info_op siop; | ||
517 | + | ||
518 | + siop.ses = sess->ses; | ||
519 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
520 | + perror("ioctl(CIOCGSESSINFO)"); | ||
521 | + return -EINVAL; | ||
522 | + } | ||
523 | + alignmask = siop.alignmask; | ||
524 | +#else | ||
525 | + alignmask = 0; | ||
526 | +#endif | ||
527 | + | ||
528 | + return alignmask; | ||
529 | +} | ||
530 | + | ||
531 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
532 | +{ | ||
533 | + int i; | ||
534 | + | ||
535 | + if (tp.nflag) { | ||
536 | + encrypt_data(fdc, tp, sess); | ||
537 | + } else { | ||
538 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
539 | + if (must_exit) | ||
540 | + break; | ||
541 | + | ||
542 | + tp.nvalue = i; | ||
543 | + if (encrypt_data(fdc, tp, sess)) { | ||
544 | + break; | ||
545 | + } | ||
546 | + } | ||
547 | + } | ||
548 | +} | ||
549 | + | ||
550 | + | ||
551 | +int run_null(int fdc, struct test_params tp) | ||
552 | +{ | ||
553 | + struct session_op sess; | ||
554 | + char keybuf[32]; | ||
555 | + | ||
556 | + fprintf(stderr, "Testing NULL cipher: \n"); | ||
557 | + memset(&sess, 0, sizeof(sess)); | ||
558 | + sess.cipher = CRYPTO_NULL; | ||
559 | + sess.keylen = 0; | ||
560 | + sess.key = (unsigned char *)keybuf; | ||
561 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
562 | + perror("ioctl(CIOCGSESSION)"); | ||
563 | + return -EINVAL; | ||
564 | + } | ||
565 | + | ||
566 | + do_test_vectors(fdc, tp, &sess); | ||
567 | + return 0; | ||
568 | +} | ||
569 | + | ||
570 | +int run_aes_cbc(int fdc, struct test_params tp) | ||
571 | +{ | ||
572 | + struct session_op sess; | ||
573 | + char keybuf[32]; | ||
574 | + | ||
575 | + fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
576 | + memset(&sess, 0, sizeof(sess)); | ||
577 | + sess.cipher = CRYPTO_AES_CBC; | ||
578 | + sess.keylen = 16; | ||
579 | + memset(keybuf, 0x42, 16); | ||
580 | + sess.key = (unsigned char *)keybuf; | ||
581 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
582 | + perror("ioctl(CIOCGSESSION)"); | ||
583 | + return -EINVAL; | ||
584 | + } | ||
585 | + | ||
586 | + do_test_vectors(fdc, tp, &sess); | ||
587 | + return 0; | ||
588 | +} | ||
589 | + | ||
590 | +int run_aes_xts(int fdc, struct test_params tp) | ||
591 | +{ | ||
592 | + struct session_op sess; | ||
593 | + char keybuf[32]; | ||
594 | + | ||
595 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
596 | + memset(&sess, 0, sizeof(sess)); | ||
597 | + sess.cipher = CRYPTO_AES_XTS; | ||
598 | + sess.keylen = 32; | ||
599 | + memset(keybuf, 0x42, sess.keylen); | ||
600 | + sess.key = (unsigned char *)keybuf; | ||
601 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
602 | + perror("ioctl(CIOCGSESSION)"); | ||
603 | + return -EINVAL; | ||
604 | + } | ||
605 | + | ||
606 | + do_test_vectors(fdc, tp, &sess); | ||
607 | + return 0; | ||
608 | +} | ||
609 | + | ||
610 | +int run_crc32c(int fdc, struct test_params tp) | ||
611 | +{ | ||
612 | + struct session_op sess; | ||
613 | + | ||
614 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
615 | + memset(&sess, 0, sizeof(sess)); | ||
616 | + sess.mac = CRYPTO_CRC32C; | ||
617 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
618 | + perror("ioctl(CIOCGSESSION)"); | ||
619 | + return 1; | ||
620 | + } | ||
621 | + | ||
622 | + do_test_vectors(fdc, tp, &sess); | ||
623 | + return 0; | ||
624 | +} | ||
625 | + | ||
626 | +int run_sha1(int fdc, struct test_params tp) | ||
627 | +{ | ||
628 | + struct session_op sess; | ||
629 | + | ||
630 | + fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
631 | + memset(&sess, 0, sizeof(sess)); | ||
632 | + sess.mac = CRYPTO_SHA1; | ||
633 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
634 | + perror("ioctl(CIOCGSESSION)"); | ||
635 | + return 1; | ||
636 | + } | ||
637 | + | ||
638 | + do_test_vectors(fdc, tp, &sess); | ||
639 | + return 0; | ||
640 | +} | ||
641 | + | ||
642 | +int run_sha256(int fdc, struct test_params tp) | ||
643 | +{ | ||
644 | + struct session_op sess; | ||
645 | + | ||
646 | + fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
647 | + memset(&sess, 0, sizeof(sess)); | ||
648 | + sess.mac = CRYPTO_SHA2_256; | ||
649 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
650 | + perror("ioctl(CIOCGSESSION)"); | ||
651 | + return 1; | ||
652 | + } | ||
653 | + | ||
654 | + do_test_vectors(fdc, tp, &sess); | ||
655 | + return 0; | ||
656 | +} | ||
657 | + | ||
658 | +int main(int argc, char **argv) | ||
659 | +{ | ||
660 | + int i; | ||
661 | + int c; | ||
662 | + bool alg_flag; | ||
663 | + char *alg_name; | ||
664 | + struct test_params tp; | ||
665 | + | ||
666 | + tp.tflag = false; | ||
667 | + tp.nflag = false; | ||
668 | + alg_flag = false; | ||
669 | + opterr = 0; | ||
670 | + while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
671 | + switch (c) { | ||
672 | + case 'n': | ||
673 | + tp.nvalue = atoi(optarg); | ||
674 | + tp.nflag = true; | ||
675 | + break; | ||
676 | + case 't': | ||
677 | + tp.tvalue = atoi(optarg); | ||
678 | + tp.tflag = true; | ||
679 | + break; | ||
680 | + case 'h': /* no break */ | ||
681 | + default: | ||
682 | + usage(argv[0]); | ||
683 | + exit(1); | ||
684 | + } | ||
685 | + } | ||
686 | + | ||
687 | + /* the name of a specific test asked on the command line */ | ||
688 | + if (optind < argc) { | ||
689 | + alg_name = argv[optind]; | ||
690 | + alg_flag = true; | ||
691 | + } | ||
692 | + | ||
693 | + /* default test time */ | ||
694 | + if (!tp.tflag) { | ||
695 | + tp.tvalue = 5; | ||
696 | + } | ||
697 | + | ||
698 | + signal(SIGALRM, alarm_handler); | ||
699 | + signal(SIGINT, exit_handler); | ||
700 | + | ||
701 | + for (i = 0; i < ALG_COUNT; i++) { | ||
702 | + if (must_exit) | ||
703 | + break; | ||
704 | + | ||
705 | + if (alg_flag) { | ||
706 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
707 | + run_test(i, tp); | ||
708 | + } | ||
709 | + } else { | ||
710 | + run_test(i, tp); | ||
711 | + } | ||
712 | + } | ||
713 | + | ||
714 | + return 0; | ||
715 | +} | ||
716 | -- | ||
717 | 2.10.2 | ||
718 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch b/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch new file mode 100644 index 00000000..6f3df511 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From eee8668c6f0e558e77533edb80c1ca7d4dc486e2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:00:29 +0300 | ||
4 | Subject: [PATCH 082/104] force LC_TIME value to avoid mpstat not using ISO8601 | ||
5 | format | ||
6 | |||
7 | (not everybody has this locale - silent warnings on some systems) | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 4 ++++ | ||
12 | 1 file changed, 4 insertions(+) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index f2a8ba6..1901620 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -24,6 +24,10 @@ CMD_BIN="async_speed" | ||
19 | OUT_BASENAME="async_speed" | ||
20 | MPSTAT_OUT="mpstat_out" | ||
21 | |||
22 | +# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
23 | +export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
24 | + | ||
25 | + | ||
26 | function usage | ||
27 | { | ||
28 | cat << EOF | ||
29 | -- | ||
30 | 2.10.2 | ||
31 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch b/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch new file mode 100644 index 00000000..13dde817 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | From a6e777aba434533f726bc9d34b074b7f36429126 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:23:27 +0300 | ||
4 | Subject: [PATCH 083/104] use the same algorithm names in sync_speed as in | ||
5 | async_speed | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/sync_speed.c | 12 ++++++------ | ||
10 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
13 | index b0cb9ad..56cd3aa 100644 | ||
14 | --- a/tests/sync_speed.c | ||
15 | +++ b/tests/sync_speed.c | ||
16 | @@ -45,8 +45,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
17 | ; | ||
18 | |||
19 | int run_null(int fdc, struct test_params tp); | ||
20 | -int run_aes_cbc(int fdc, struct test_params tp); | ||
21 | -int run_aes_xts(int fdc, struct test_params tp); | ||
22 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
23 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
24 | int run_crc32c(int fdc, struct test_params tp); | ||
25 | int run_sha1(int fdc, struct test_params tp); | ||
26 | int run_sha256(int fdc, struct test_params tp); | ||
27 | @@ -58,8 +58,8 @@ struct { | ||
28 | int (*func)(int, struct test_params); | ||
29 | } ciphers[ALG_COUNT] = { | ||
30 | {"null", run_null}, | ||
31 | - {"aes-cbc", run_aes_cbc}, | ||
32 | - {"aes-xts", run_aes_xts}, | ||
33 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
34 | + {"aes-256-xts", run_aes_256_xts}, | ||
35 | {"crc32c", run_crc32c}, | ||
36 | {"sha1", run_sha1}, | ||
37 | {"sha256", run_sha256}, | ||
38 | @@ -251,7 +251,7 @@ int run_null(int fdc, struct test_params tp) | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | -int run_aes_cbc(int fdc, struct test_params tp) | ||
43 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
44 | { | ||
45 | struct session_op sess; | ||
46 | char keybuf[32]; | ||
47 | @@ -271,7 +271,7 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | -int run_aes_xts(int fdc, struct test_params tp) | ||
52 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
53 | { | ||
54 | struct session_op sess; | ||
55 | char keybuf[32]; | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch b/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch new file mode 100644 index 00000000..aa05f98f --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From 1bcef054cfc094e51c9c3cb1048b8bf909326082 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:41:09 +0300 | ||
4 | Subject: [PATCH 084/104] fix ignored SIGALRM signals on some platforms | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 4 ++-- | ||
9 | tests/sync_speed.c | 4 ++-- | ||
10 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
13 | index d843c02..eb8468d 100644 | ||
14 | --- a/tests/async_speed.c | ||
15 | +++ b/tests/async_speed.c | ||
16 | @@ -76,8 +76,8 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
17 | (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
18 | } | ||
19 | |||
20 | -static int must_finish = 0; | ||
21 | -static int must_exit = 0; | ||
22 | +static volatile int must_finish; | ||
23 | +static volatile int must_exit; | ||
24 | static struct pollfd pfd; | ||
25 | |||
26 | static void alarm_handler(int signo) | ||
27 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
28 | index 56cd3aa..ba1d170 100644 | ||
29 | --- a/tests/sync_speed.c | ||
30 | +++ b/tests/sync_speed.c | ||
31 | @@ -71,8 +71,8 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
32 | (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
33 | } | ||
34 | |||
35 | -static int must_finish = 0; | ||
36 | -static int must_exit = 0; | ||
37 | +static volatile int must_finish; | ||
38 | +static volatile int must_exit; | ||
39 | |||
40 | static void alarm_handler(int signo) | ||
41 | { | ||
42 | -- | ||
43 | 2.10.2 | ||
44 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch b/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch new file mode 100644 index 00000000..23f4b544 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch | |||
@@ -0,0 +1,56 @@ | |||
1 | From b682119d432af1190699c56039f6584ac83ae7b9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 18:03:07 +0300 | ||
4 | Subject: [PATCH 085/104] add notes about configured limits in SEC driver | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 3 ++- | ||
9 | tests/async_speed_multi.sh | 2 ++ | ||
10 | tests/sync_speed.c | 3 ++- | ||
11 | 3 files changed, 6 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
14 | index eb8468d..d16d17e 100644 | ||
15 | --- a/tests/async_speed.c | ||
16 | +++ b/tests/async_speed.c | ||
17 | @@ -47,7 +47,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
18 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
19 | " -n <bytes>\t" "size of the test buffer\n" | ||
20 | " -m\t\t" "output in a machine readable format\n" | ||
21 | - " -h\t\t" "show this help\n" | ||
22 | + " -h\t\t" "show this help\n\n" | ||
23 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
24 | ; | ||
25 | |||
26 | int run_null(int fdc, struct test_params tp); | ||
27 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
28 | index 1901620..f83e362 100755 | ||
29 | --- a/tests/async_speed_multi.sh | ||
30 | +++ b/tests/async_speed_multi.sh | ||
31 | @@ -40,6 +40,8 @@ Usage: `basename $0` [OPTIONS] <alg_name> | ||
32 | -h show this help | ||
33 | |||
34 | alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
35 | + | ||
36 | +Note: SEC driver is configured to support buffers smaller than 512K | ||
37 | EOF | ||
38 | } | ||
39 | |||
40 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
41 | index ba1d170..ceae645 100644 | ||
42 | --- a/tests/sync_speed.c | ||
43 | +++ b/tests/sync_speed.c | ||
44 | @@ -41,7 +41,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
45 | "Run benchmark test for cipher or hash\n\n" | ||
46 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
47 | " -n <bytes>\t" "size of the test buffer\n" | ||
48 | - " -h\t\t" "show this help\n" | ||
49 | + " -h\t\t" "show this help\n\n" | ||
50 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
51 | ; | ||
52 | |||
53 | int run_null(int fdc, struct test_params tp); | ||
54 | -- | ||
55 | 2.10.2 | ||
56 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch new file mode 100644 index 00000000..3e781aa3 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | From fc04b5a05fd4ab1fc0f581b52d52db7c709dfc6a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 18:55:09 +0300 | ||
4 | Subject: [PATCH 086/104] add a wrapper script for running all tests | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 1 + | ||
9 | tests/run_crypto_tests.sh | 25 +++++++++++++++++++++++++ | ||
10 | 2 files changed, 26 insertions(+) | ||
11 | create mode 100644 tests/run_crypto_tests.sh | ||
12 | |||
13 | diff --git a/tests/Makefile b/tests/Makefile | ||
14 | index 400fb7a..51469e8 100644 | ||
15 | --- a/tests/Makefile | ||
16 | +++ b/tests/Makefile | ||
17 | @@ -39,6 +39,7 @@ install: | ||
18 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
19 | done | ||
20 | install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
21 | + install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) | ||
22 | |||
23 | clean: | ||
24 | rm -f *.o *~ $(hostprogs) | ||
25 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
26 | new file mode 100644 | ||
27 | index 0000000..32ab8e2 | ||
28 | --- /dev/null | ||
29 | +++ b/tests/run_crypto_tests.sh | ||
30 | @@ -0,0 +1,25 @@ | ||
31 | +#!/bin/bash | ||
32 | + | ||
33 | + | ||
34 | +BUF_SIZE="8192 16384 65536 131072 262144" | ||
35 | +THREAD_CNT="1 8 12" | ||
36 | +ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" | ||
37 | + | ||
38 | +#restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 | ||
39 | +#restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 | ||
40 | + | ||
41 | + | ||
42 | +#grep DPIO /proc/interrupts | ||
43 | +for alg_name in ${ALG_NAMES} | ||
44 | +do | ||
45 | + for multi in ${THREAD_CNT} | ||
46 | + do | ||
47 | + for bsize in ${BUF_SIZE} | ||
48 | + do | ||
49 | + async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
50 | + tail -n 1 | ||
51 | + done | ||
52 | + done | ||
53 | +done | ||
54 | + | ||
55 | +#grep DPIO /proc/interrupts | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch b/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch new file mode 100644 index 00000000..edd47f7d --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From a2894f645e972b7dfc97b59ea1c1e91e741c04d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 19:07:29 +0300 | ||
4 | Subject: [PATCH 087/104] add % to cpu idle for convenience | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index f83e362..90f9b72 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -112,7 +112,7 @@ function run_parallel | ||
16 | echo -e "algorithm\t""threads\t""run time\t"\ | ||
17 | "buffer size\t""GB/s\t""%cpu idle" | ||
18 | echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
19 | - "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
20 | + "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
21 | fi | ||
22 | } | ||
23 | |||
24 | -- | ||
25 | 2.10.2 | ||
26 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch b/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch new file mode 100644 index 00000000..9f7709bb --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch | |||
@@ -0,0 +1,1858 @@ | |||
1 | From a7e42a9c9a2cd4b4ffd369ae57dfbd207536766a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 1 Nov 2016 12:01:33 +0200 | ||
4 | Subject: [PATCH 088/104] merge sync and async benchmarks into a single program | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 9 +- | ||
9 | tests/async_speed.c | 463 -------------------------------------- | ||
10 | tests/async_speed_multi.sh | 172 -------------- | ||
11 | tests/run_crypto_tests.sh | 2 +- | ||
12 | tests/speed.c | 546 +++++++++++++++++++++++++++++++++++++++++++++ | ||
13 | tests/speed_multi.sh | 174 +++++++++++++++ | ||
14 | tests/sync_speed.c | 400 --------------------------------- | ||
15 | 7 files changed, 725 insertions(+), 1041 deletions(-) | ||
16 | delete mode 100644 tests/async_speed.c | ||
17 | delete mode 100755 tests/async_speed_multi.sh | ||
18 | create mode 100644 tests/speed.c | ||
19 | create mode 100755 tests/speed_multi.sh | ||
20 | delete mode 100644 tests/sync_speed.c | ||
21 | |||
22 | diff --git a/tests/Makefile b/tests/Makefile | ||
23 | index 51469e8..88f5040 100644 | ||
24 | --- a/tests/Makefile | ||
25 | +++ b/tests/Makefile | ||
26 | @@ -3,19 +3,18 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
27 | |||
28 | comp_progs := cipher_comp hash_comp hmac_comp | ||
29 | |||
30 | -hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ | ||
31 | - async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
32 | +hostprogs := cipher cipher-aead hmac async_cipher async_hmac \ | ||
33 | + speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
34 | cipher-aead-srtp $(comp_progs) | ||
35 | |||
36 | example-cipher-objs := cipher.o | ||
37 | example-cipher-aead-objs := cipher-aead.o | ||
38 | example-hmac-objs := hmac.o | ||
39 | -example-speed-objs := sync_speed.o | ||
40 | example-fullspeed-objs := fullspeed.c | ||
41 | example-sha-speed-objs := sha_speed.c | ||
42 | example-async-cipher-objs := async_cipher.o | ||
43 | example-async-hmac-objs := async_hmac.o | ||
44 | -example-async-speed-objs := async_speed.o | ||
45 | +example-async-speed-objs := speed.o | ||
46 | example-hashcrypt-speed-objs := hashcrypt_speed.c | ||
47 | |||
48 | prefix ?= /usr/local | ||
49 | @@ -38,7 +37,7 @@ install: | ||
50 | for prog in $(hostprogs); do \ | ||
51 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
52 | done | ||
53 | - install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
54 | + install -m 755 speed_multi.sh $(DESTDIR)/$(bindir) | ||
55 | install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) | ||
56 | |||
57 | clean: | ||
58 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
59 | deleted file mode 100644 | ||
60 | index d16d17e..0000000 | ||
61 | --- a/tests/async_speed.c | ||
62 | +++ /dev/null | ||
63 | @@ -1,463 +0,0 @@ | ||
64 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
65 | - * | ||
66 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
67 | - * | ||
68 | - * This program is free software; you can redistribute it and/or modify | ||
69 | - * it under the terms of the GNU General Public License as published by | ||
70 | - * the Free Software Foundation; either version 2 of the License, or | ||
71 | - * (at your option) any later version. | ||
72 | - * | ||
73 | - * This program is distributed in the hope that it will be useful, | ||
74 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
75 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
76 | - * GNU General Public License for more details. | ||
77 | - * | ||
78 | - * You should have received a copy of the GNU General Public License | ||
79 | - * along with this program; if not, write to the Free Software | ||
80 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
81 | - */ | ||
82 | -#include <errno.h> | ||
83 | -#include <fcntl.h> | ||
84 | -#include <poll.h> | ||
85 | -#include <stdio.h> | ||
86 | -#include <stdlib.h> | ||
87 | -#include <string.h> | ||
88 | -#include <sys/ioctl.h> | ||
89 | -#include <sys/time.h> | ||
90 | -#include <sys/types.h> | ||
91 | -#include <signal.h> | ||
92 | -#include <crypto/cryptodev.h> | ||
93 | -#include <stdbool.h> | ||
94 | -#include <unistd.h> | ||
95 | -#include <stdint.h> | ||
96 | -#include <inttypes.h> | ||
97 | - | ||
98 | -#ifdef ENABLE_ASYNC | ||
99 | - | ||
100 | -struct test_params { | ||
101 | - bool tflag; | ||
102 | - bool nflag; | ||
103 | - bool mflag; | ||
104 | - int tvalue; | ||
105 | - int nvalue; | ||
106 | -}; | ||
107 | - | ||
108 | -const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
109 | - "Run benchmark test for cipher or hash\n\n" | ||
110 | - " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
111 | - " -n <bytes>\t" "size of the test buffer\n" | ||
112 | - " -m\t\t" "output in a machine readable format\n" | ||
113 | - " -h\t\t" "show this help\n\n" | ||
114 | - "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
115 | -; | ||
116 | - | ||
117 | -int run_null(int fdc, struct test_params tp); | ||
118 | -int run_aes_128_cbc(int fdc, struct test_params tp); | ||
119 | -int run_aes_256_xts(int fdc, struct test_params tp); | ||
120 | -int run_crc32c(int fdc, struct test_params tp); | ||
121 | -int run_sha1(int fdc, struct test_params tp); | ||
122 | -int run_sha256(int fdc, struct test_params tp); | ||
123 | - | ||
124 | -#define ALG_COUNT 6 | ||
125 | -struct { | ||
126 | - char *name; | ||
127 | - int (*func)(int, struct test_params); | ||
128 | -} ciphers[ALG_COUNT] = { | ||
129 | - {"null", run_null}, | ||
130 | - {"aes-128-cbc", run_aes_128_cbc}, | ||
131 | - {"aes-256-xts", run_aes_256_xts}, | ||
132 | - {"crc32c", run_crc32c}, | ||
133 | - {"sha1", run_sha1}, | ||
134 | - {"sha256", run_sha256}, | ||
135 | -}; | ||
136 | - | ||
137 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
138 | -{ | ||
139 | - return (double)(end.tv_usec - start.tv_usec) + | ||
140 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
141 | -} | ||
142 | - | ||
143 | -static volatile int must_finish; | ||
144 | -static volatile int must_exit; | ||
145 | -static struct pollfd pfd; | ||
146 | - | ||
147 | -static void alarm_handler(int signo) | ||
148 | -{ | ||
149 | - must_finish = 1; | ||
150 | - pfd.events = POLLIN; | ||
151 | -} | ||
152 | - | ||
153 | -static void exit_handler(int signo) | ||
154 | -{ | ||
155 | - must_exit = 1; | ||
156 | - printf("\nexit requested by user through ctrl+c \n"); | ||
157 | -} | ||
158 | - | ||
159 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
160 | - | ||
161 | -static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
162 | -{ | ||
163 | - int unit = 0; | ||
164 | - | ||
165 | - *data = bytes; | ||
166 | - while (*data > 1024 && units[unit + 1]) { | ||
167 | - *data /= 1024; | ||
168 | - unit++; | ||
169 | - } | ||
170 | - *speed = *data / time; | ||
171 | - sprintf(metric, "%sB", units[unit]); | ||
172 | -} | ||
173 | - | ||
174 | -static void value2machine(uint64_t bytes, double time, double* speed) | ||
175 | -{ | ||
176 | - *speed = bytes / time; | ||
177 | -} | ||
178 | - | ||
179 | -int get_alignmask(int fdc, struct session_op *sess) | ||
180 | -{ | ||
181 | - int alignmask; | ||
182 | - int min_alignmask = sizeof(void*) - 1; | ||
183 | - | ||
184 | -#ifdef CIOCGSESSINFO | ||
185 | - struct session_info_op siop; | ||
186 | - | ||
187 | - siop.ses = sess->ses; | ||
188 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
189 | - perror("ioctl(CIOCGSESSINFO)"); | ||
190 | - return -EINVAL; | ||
191 | - } | ||
192 | - alignmask = siop.alignmask; | ||
193 | - if (alignmask < min_alignmask) { | ||
194 | - alignmask = min_alignmask; | ||
195 | - } | ||
196 | -#else | ||
197 | - alignmask = 0; | ||
198 | -#endif | ||
199 | - | ||
200 | - return alignmask; | ||
201 | -} | ||
202 | - | ||
203 | -int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
204 | -{ | ||
205 | - struct crypt_op cop; | ||
206 | - char *buffer[64], iv[32]; | ||
207 | - uint8_t mac[64][HASH_MAX_LEN]; | ||
208 | - static int val = 23; | ||
209 | - struct timeval start, end; | ||
210 | - uint64_t total = 0; | ||
211 | - double secs, ddata, dspeed; | ||
212 | - char metric[16]; | ||
213 | - int rc, wqueue = 0, bufidx = 0; | ||
214 | - int alignmask; | ||
215 | - | ||
216 | - memset(iv, 0x23, 32); | ||
217 | - | ||
218 | - if (!tp.mflag) { | ||
219 | - printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
220 | - fflush(stdout); | ||
221 | - } | ||
222 | - | ||
223 | - alignmask = get_alignmask(fdc, sess); | ||
224 | - for (rc = 0; rc < 64; rc++) { | ||
225 | - if (alignmask) { | ||
226 | - if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
227 | - printf("posix_memalign() failed!\n"); | ||
228 | - return 1; | ||
229 | - } | ||
230 | - } else { | ||
231 | - if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
232 | - perror("malloc()"); | ||
233 | - return 1; | ||
234 | - } | ||
235 | - } | ||
236 | - memset(buffer[rc], val++, tp.nvalue); | ||
237 | - } | ||
238 | - pfd.fd = fdc; | ||
239 | - pfd.events = POLLOUT | POLLIN; | ||
240 | - | ||
241 | - must_finish = 0; | ||
242 | - alarm(tp.tvalue); | ||
243 | - | ||
244 | - gettimeofday(&start, NULL); | ||
245 | - do { | ||
246 | - if ((rc = poll(&pfd, 1, 100)) < 0) { | ||
247 | - if (errno & (ERESTART | EINTR)) | ||
248 | - continue; | ||
249 | - fprintf(stderr, "errno = %d ", errno); | ||
250 | - perror("poll()"); | ||
251 | - return 1; | ||
252 | - } | ||
253 | - | ||
254 | - if (pfd.revents & POLLOUT) { | ||
255 | - memset(&cop, 0, sizeof(cop)); | ||
256 | - cop.ses = sess->ses; | ||
257 | - cop.len = tp.nvalue; | ||
258 | - cop.iv = (unsigned char *)iv; | ||
259 | - cop.op = COP_ENCRYPT; | ||
260 | - cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
261 | - cop.mac = mac[bufidx]; | ||
262 | - bufidx = (bufidx + 1) % 64; | ||
263 | - | ||
264 | - if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
265 | - perror("ioctl(CIOCASYNCCRYPT)"); | ||
266 | - return 1; | ||
267 | - } | ||
268 | - wqueue++; | ||
269 | - } | ||
270 | - if (pfd.revents & POLLIN) { | ||
271 | - if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { | ||
272 | - perror("ioctl(CIOCASYNCFETCH)"); | ||
273 | - return 1; | ||
274 | - } | ||
275 | - wqueue--; | ||
276 | - total += cop.len; | ||
277 | - } | ||
278 | - } while(!must_finish || wqueue); | ||
279 | - gettimeofday(&end, NULL); | ||
280 | - | ||
281 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
282 | - | ||
283 | - if (tp.mflag) { | ||
284 | - value2machine(total, secs, &dspeed); | ||
285 | - printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
286 | - } else { | ||
287 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
288 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
289 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
290 | - } | ||
291 | - | ||
292 | - for (rc = 0; rc < 64; rc++) | ||
293 | - free(buffer[rc]); | ||
294 | - return 0; | ||
295 | -} | ||
296 | - | ||
297 | -void usage(char *cmd_name) | ||
298 | -{ | ||
299 | - printf(usage_str, cmd_name); | ||
300 | -} | ||
301 | - | ||
302 | -int run_test(int id, struct test_params tp) | ||
303 | -{ | ||
304 | - int fd; | ||
305 | - int fdc; | ||
306 | - int err; | ||
307 | - | ||
308 | - fd = open("/dev/crypto", O_RDWR, 0); | ||
309 | - if (fd < 0) { | ||
310 | - perror("open()"); | ||
311 | - return fd; | ||
312 | - } | ||
313 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
314 | - perror("ioctl(CRIOGET)"); | ||
315 | - return -EINVAL; | ||
316 | - } | ||
317 | - | ||
318 | - if (!tp.mflag) { | ||
319 | - fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
320 | - } | ||
321 | - err = ciphers[id].func(fdc, tp); | ||
322 | - | ||
323 | - close(fdc); | ||
324 | - close(fd); | ||
325 | - | ||
326 | - return err; | ||
327 | -} | ||
328 | - | ||
329 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
330 | -{ | ||
331 | - int i; | ||
332 | - | ||
333 | - if (tp.nflag) { | ||
334 | - encrypt_data(fdc, tp, sess); | ||
335 | - } else { | ||
336 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
337 | - if (must_exit) { | ||
338 | - break; | ||
339 | - } | ||
340 | - | ||
341 | - tp.nvalue = i; | ||
342 | - if (encrypt_data(fdc, tp, sess)) { | ||
343 | - break; | ||
344 | - } | ||
345 | - } | ||
346 | - } | ||
347 | -} | ||
348 | - | ||
349 | - | ||
350 | -int run_null(int fdc, struct test_params tp) | ||
351 | -{ | ||
352 | - struct session_op sess; | ||
353 | - char keybuf[32]; | ||
354 | - | ||
355 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
356 | - memset(&sess, 0, sizeof(sess)); | ||
357 | - sess.cipher = CRYPTO_NULL; | ||
358 | - sess.keylen = 0; | ||
359 | - sess.key = (unsigned char *)keybuf; | ||
360 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
361 | - perror("ioctl(CIOCGSESSION)"); | ||
362 | - return -EINVAL; | ||
363 | - } | ||
364 | - | ||
365 | - do_test_vectors(fdc, tp, &sess); | ||
366 | - return 0; | ||
367 | -} | ||
368 | - | ||
369 | -int run_aes_128_cbc(int fdc, struct test_params tp) | ||
370 | -{ | ||
371 | - struct session_op sess; | ||
372 | - char keybuf[32]; | ||
373 | - | ||
374 | - memset(&sess, 0, sizeof(sess)); | ||
375 | - sess.cipher = CRYPTO_AES_CBC; | ||
376 | - sess.keylen = 16; | ||
377 | - memset(keybuf, 0x42, 16); | ||
378 | - sess.key = (unsigned char *)keybuf; | ||
379 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
380 | - perror("ioctl(CIOCGSESSION)"); | ||
381 | - return -EINVAL; | ||
382 | - } | ||
383 | - | ||
384 | - do_test_vectors(fdc, tp, &sess); | ||
385 | - return 0; | ||
386 | -} | ||
387 | - | ||
388 | -int run_aes_256_xts(int fdc, struct test_params tp) | ||
389 | -{ | ||
390 | - struct session_op sess; | ||
391 | - char keybuf[32]; | ||
392 | - | ||
393 | - memset(&sess, 0, sizeof(sess)); | ||
394 | - sess.cipher = CRYPTO_AES_XTS; | ||
395 | - sess.keylen = 32; | ||
396 | - memset(keybuf, 0x42, sess.keylen); | ||
397 | - sess.key = (unsigned char *)keybuf; | ||
398 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
399 | - perror("ioctl(CIOCGSESSION)"); | ||
400 | - return -EINVAL; | ||
401 | - } | ||
402 | - | ||
403 | - do_test_vectors(fdc, tp, &sess); | ||
404 | - return 0; | ||
405 | -} | ||
406 | - | ||
407 | -int run_crc32c(int fdc, struct test_params tp) | ||
408 | -{ | ||
409 | - struct session_op sess; | ||
410 | - | ||
411 | - memset(&sess, 0, sizeof(sess)); | ||
412 | - sess.mac = CRYPTO_CRC32C; | ||
413 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
414 | - perror("ioctl(CIOCGSESSION)"); | ||
415 | - return 1; | ||
416 | - } | ||
417 | - | ||
418 | - do_test_vectors(fdc, tp, &sess); | ||
419 | - return 0; | ||
420 | -} | ||
421 | - | ||
422 | -int run_sha1(int fdc, struct test_params tp) | ||
423 | -{ | ||
424 | - struct session_op sess; | ||
425 | - | ||
426 | - memset(&sess, 0, sizeof(sess)); | ||
427 | - sess.mac = CRYPTO_SHA1; | ||
428 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
429 | - perror("ioctl(CIOCGSESSION)"); | ||
430 | - return 1; | ||
431 | - } | ||
432 | - | ||
433 | - do_test_vectors(fdc, tp, &sess); | ||
434 | - return 0; | ||
435 | -} | ||
436 | - | ||
437 | -int run_sha256(int fdc, struct test_params tp) | ||
438 | -{ | ||
439 | - struct session_op sess; | ||
440 | - | ||
441 | - memset(&sess, 0, sizeof(sess)); | ||
442 | - sess.mac = CRYPTO_SHA2_256; | ||
443 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
444 | - perror("ioctl(CIOCGSESSION)"); | ||
445 | - return 1; | ||
446 | - } | ||
447 | - | ||
448 | - do_test_vectors(fdc, tp, &sess); | ||
449 | - return 0; | ||
450 | -} | ||
451 | - | ||
452 | -int main(int argc, char **argv) | ||
453 | -{ | ||
454 | - int err = 0; | ||
455 | - int i; | ||
456 | - int c; | ||
457 | - bool alg_flag; | ||
458 | - char *alg_name; | ||
459 | - struct test_params tp; | ||
460 | - | ||
461 | - tp.tflag = false; | ||
462 | - tp.nflag = false; | ||
463 | - tp.mflag = false; | ||
464 | - alg_flag = false; | ||
465 | - opterr = 0; | ||
466 | - while ((c = getopt(argc, argv, "hn:t:m")) != -1) { | ||
467 | - switch (c) { | ||
468 | - case 'n': | ||
469 | - tp.nvalue = atoi(optarg); | ||
470 | - tp.nflag = true; | ||
471 | - break; | ||
472 | - case 't': | ||
473 | - tp.tvalue = atoi(optarg); | ||
474 | - tp.tflag = true; | ||
475 | - break; | ||
476 | - case 'm': | ||
477 | - tp.mflag = true; | ||
478 | - break; | ||
479 | - case 'h': /* no break */ | ||
480 | - default: | ||
481 | - usage(argv[0]); | ||
482 | - exit(1); | ||
483 | - } | ||
484 | - } | ||
485 | - | ||
486 | - /* the name of a specific test asked on the command line */ | ||
487 | - if (optind < argc) { | ||
488 | - alg_name = argv[optind]; | ||
489 | - alg_flag = true; | ||
490 | - } | ||
491 | - | ||
492 | - /* default test time */ | ||
493 | - if (!tp.tflag) { | ||
494 | - tp.tvalue = 5; | ||
495 | - } | ||
496 | - | ||
497 | - signal(SIGALRM, alarm_handler); | ||
498 | - signal(SIGINT, exit_handler); | ||
499 | - | ||
500 | - for (i = 0; i < ALG_COUNT; i++) { | ||
501 | - if (must_exit) { | ||
502 | - break; | ||
503 | - } | ||
504 | - | ||
505 | - if (alg_flag) { | ||
506 | - if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
507 | - err = run_test(i, tp); | ||
508 | - } | ||
509 | - } else { | ||
510 | - err = run_test(i, tp); | ||
511 | - if (err != 0) { | ||
512 | - break; | ||
513 | - } | ||
514 | - } | ||
515 | - } | ||
516 | - | ||
517 | - return err; | ||
518 | -} | ||
519 | - | ||
520 | -#else | ||
521 | -int | ||
522 | -main(int argc, char** argv) | ||
523 | -{ | ||
524 | - return (0); | ||
525 | -} | ||
526 | -#endif | ||
527 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
528 | deleted file mode 100755 | ||
529 | index 90f9b72..0000000 | ||
530 | --- a/tests/async_speed_multi.sh | ||
531 | +++ /dev/null | ||
532 | @@ -1,172 +0,0 @@ | ||
533 | -#!/bin/bash | ||
534 | -# | ||
535 | -# Copyright 2016 NXP Semiconductors | ||
536 | -# | ||
537 | -# This program is free software: you can redistribute it and/or modify | ||
538 | -# it under the terms of the GNU General Public License as published by | ||
539 | -# the Free Software Foundation, either version 2 of the License, or | ||
540 | -# (at your option) any later version. | ||
541 | -# | ||
542 | -# This program is distributed in the hope that it will be useful, | ||
543 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
544 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
545 | -# GNU General Public License for more details. | ||
546 | -# | ||
547 | -# You should have received a copy of the GNU General Public License | ||
548 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
549 | - | ||
550 | - | ||
551 | - | ||
552 | -# no user-configurable options below this line | ||
553 | - | ||
554 | -NUM_CORES=$(nproc) | ||
555 | -CMD_BIN="async_speed" | ||
556 | -OUT_BASENAME="async_speed" | ||
557 | -MPSTAT_OUT="mpstat_out" | ||
558 | - | ||
559 | -# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
560 | -export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
561 | - | ||
562 | - | ||
563 | -function usage | ||
564 | -{ | ||
565 | -cat << EOF | ||
566 | -Usage: `basename $0` [OPTIONS] <alg_name> | ||
567 | - | ||
568 | - -m <threads> number of threads to run with (defaults to number of cores) | ||
569 | - -t <secs> time to run each test (default 10 secs) | ||
570 | - -n <bytes> size of the test buffer (default 256 bytes) | ||
571 | - -v make output more verbose (default tabular) | ||
572 | - -h show this help | ||
573 | - | ||
574 | -alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
575 | - | ||
576 | -Note: SEC driver is configured to support buffers smaller than 512K | ||
577 | -EOF | ||
578 | -} | ||
579 | - | ||
580 | -function SUM { | ||
581 | - paste -sd+ - | bc -l | ||
582 | -} | ||
583 | - | ||
584 | -function get_cpu_idle | ||
585 | -{ | ||
586 | - header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
587 | - idle_column=$(echo $header_line | wc -w) | ||
588 | - average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
589 | - | ||
590 | - echo $average_idle | ||
591 | -} | ||
592 | - | ||
593 | -function run_parallel | ||
594 | -{ | ||
595 | - trap control_c SIGINT | ||
596 | - | ||
597 | - OPTIONS="-t $tvalue -n $nvalue -m" | ||
598 | - CMD="$CMD_BIN $OPTIONS $alg_name" | ||
599 | - | ||
600 | - (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
601 | - MPSTAT_PID=$! | ||
602 | - | ||
603 | - PIDS="" | ||
604 | - start=$(date +%s.%N) | ||
605 | - | ||
606 | - for i in $(seq 0 $(($mvalue-1))) | ||
607 | - do | ||
608 | - CMD_OUT="${OUT_BASENAME}_${i}" | ||
609 | - | ||
610 | - $CMD &> $CMD_OUT & | ||
611 | - PID=$! | ||
612 | - AFFINITY=$(($i % $NUM_CORES)) | ||
613 | - taskset -pc $AFFINITY $PID > /dev/null | ||
614 | - | ||
615 | - PIDS="$PID $PIDS" | ||
616 | - done | ||
617 | - | ||
618 | - wait $PIDS | ||
619 | - end=$(date +%s.%N) | ||
620 | - | ||
621 | - wait $MPSTAT_PID | ||
622 | - | ||
623 | - grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
624 | - if (($? == 0)) | ||
625 | - then | ||
626 | - echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
627 | - exit 1 | ||
628 | - fi | ||
629 | - | ||
630 | - runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
631 | - total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
632 | - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
633 | - cpu_idle=$(get_cpu_idle) | ||
634 | - | ||
635 | - if [ ! -z "$vvalue" ] | ||
636 | - then | ||
637 | - echo | ||
638 | - echo "buffer size : $nvalue" | ||
639 | - echo "running time : $runtime" | ||
640 | - echo "avg_speed : $avg_speed GB/s" | ||
641 | - echo "all_cpu idle : $cpu_idle %" | ||
642 | - echo | ||
643 | - else | ||
644 | - echo -e "algorithm\t""threads\t""run time\t"\ | ||
645 | - "buffer size\t""GB/s\t""%cpu idle" | ||
646 | - echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
647 | - "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
648 | - fi | ||
649 | -} | ||
650 | - | ||
651 | -function control_c | ||
652 | -{ | ||
653 | - killall async_speed > /dev/null | ||
654 | - killall mpstat > /dev/null | ||
655 | -} | ||
656 | - | ||
657 | -function main | ||
658 | -{ | ||
659 | - [ ! -e "/dev/crypto" ] && | ||
660 | - (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
661 | - | ||
662 | - $(which ${CMD_BIN} &> /dev/null) | ||
663 | - if (($? != 0)) | ||
664 | - then | ||
665 | - echo "${CMD_BIN} test is not installed" | ||
666 | - exit 1 | ||
667 | - fi | ||
668 | - | ||
669 | - rm -f ${OUT_BASENAME}_* | ||
670 | - rm -f ${MPSTAT_OUT} | ||
671 | - | ||
672 | - while getopts vhm:t:n: option | ||
673 | - do | ||
674 | - case "$option" in | ||
675 | - m) mvalue="$OPTARG";; | ||
676 | - t) tvalue="$OPTARG";; | ||
677 | - n) nvalue="$OPTARG";; | ||
678 | - v) vvalue="verbose";; | ||
679 | - *) usage $0; exit 1;; | ||
680 | - esac | ||
681 | - done | ||
682 | - | ||
683 | - shift $((OPTIND-1)) | ||
684 | - alg_name=$1 | ||
685 | - | ||
686 | - [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
687 | - [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
688 | - [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
689 | - | ||
690 | - [ "$tvalue" -lt 5 ] && tvalue=5 | ||
691 | - | ||
692 | - case "$alg_name" in | ||
693 | - "null" |\ | ||
694 | - "aes-128-cbc" |\ | ||
695 | - "aes-256-xts" |\ | ||
696 | - "sha1" |\ | ||
697 | - "sha256" |\ | ||
698 | - "crc32c" ) run_parallel;; | ||
699 | - * ) usage && exit 1;; | ||
700 | - esac | ||
701 | -} | ||
702 | - | ||
703 | -main "$@" | ||
704 | - | ||
705 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
706 | index 32ab8e2..e128637 100644 | ||
707 | --- a/tests/run_crypto_tests.sh | ||
708 | +++ b/tests/run_crypto_tests.sh | ||
709 | @@ -16,7 +16,7 @@ do | ||
710 | do | ||
711 | for bsize in ${BUF_SIZE} | ||
712 | do | ||
713 | - async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
714 | + speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
715 | tail -n 1 | ||
716 | done | ||
717 | done | ||
718 | diff --git a/tests/speed.c b/tests/speed.c | ||
719 | new file mode 100644 | ||
720 | index 0000000..3b36db1 | ||
721 | --- /dev/null | ||
722 | +++ b/tests/speed.c | ||
723 | @@ -0,0 +1,546 @@ | ||
724 | +/* cryptodev_test - simple benchmark tool for cryptodev | ||
725 | + * | ||
726 | + * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
727 | + * | ||
728 | + * This program is free software; you can redistribute it and/or modify | ||
729 | + * it under the terms of the GNU General Public License as published by | ||
730 | + * the Free Software Foundation; either version 2 of the License, or | ||
731 | + * (at your option) any later version. | ||
732 | + * | ||
733 | + * This program is distributed in the hope that it will be useful, | ||
734 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
735 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
736 | + * GNU General Public License for more details. | ||
737 | + * | ||
738 | + * You should have received a copy of the GNU General Public License | ||
739 | + * along with this program; if not, write to the Free Software | ||
740 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
741 | + */ | ||
742 | +#include <errno.h> | ||
743 | +#include <fcntl.h> | ||
744 | +#include <poll.h> | ||
745 | +#include <stdio.h> | ||
746 | +#include <stdlib.h> | ||
747 | +#include <string.h> | ||
748 | +#include <sys/ioctl.h> | ||
749 | +#include <sys/time.h> | ||
750 | +#include <sys/types.h> | ||
751 | +#include <signal.h> | ||
752 | +#include <crypto/cryptodev.h> | ||
753 | +#include <stdbool.h> | ||
754 | +#include <unistd.h> | ||
755 | +#include <stdint.h> | ||
756 | +#include <inttypes.h> | ||
757 | + | ||
758 | + | ||
759 | +struct test_params { | ||
760 | + bool tflag; | ||
761 | + bool nflag; | ||
762 | + bool mflag; | ||
763 | + bool aflag; | ||
764 | + int tvalue; | ||
765 | + int nvalue; | ||
766 | +}; | ||
767 | + | ||
768 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
769 | + "Run benchmark test for cipher or hash\n\n" | ||
770 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
771 | + " -n <bytes>\t" "size of the test buffer\n" | ||
772 | + " -m\t\t" "output in a machine readable format\n" | ||
773 | + " -a\t\t" "run the async tests (default sync)\n" | ||
774 | + " -h\t\t" "show this help\n\n" | ||
775 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
776 | +; | ||
777 | + | ||
778 | +int run_null(int fdc, struct test_params tp); | ||
779 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
780 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
781 | +int run_crc32c(int fdc, struct test_params tp); | ||
782 | +int run_sha1(int fdc, struct test_params tp); | ||
783 | +int run_sha256(int fdc, struct test_params tp); | ||
784 | + | ||
785 | +#define ALG_COUNT 6 | ||
786 | +struct { | ||
787 | + char *name; | ||
788 | + int (*func)(int, struct test_params); | ||
789 | +} ciphers[ALG_COUNT] = { | ||
790 | + {"null", run_null}, | ||
791 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
792 | + {"aes-256-xts", run_aes_256_xts}, | ||
793 | + {"crc32c", run_crc32c}, | ||
794 | + {"sha1", run_sha1}, | ||
795 | + {"sha256", run_sha256}, | ||
796 | +}; | ||
797 | + | ||
798 | +static double udifftimeval(struct timeval start, struct timeval end) | ||
799 | +{ | ||
800 | + return (double)(end.tv_usec - start.tv_usec) + | ||
801 | + (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
802 | +} | ||
803 | + | ||
804 | +static volatile int must_finish; | ||
805 | +static volatile int must_exit; | ||
806 | +static struct pollfd pfd; | ||
807 | + | ||
808 | +static void alarm_handler(int signo) | ||
809 | +{ | ||
810 | + must_finish = 1; | ||
811 | + pfd.events = POLLIN; | ||
812 | +} | ||
813 | + | ||
814 | +static void exit_handler(int signo) | ||
815 | +{ | ||
816 | + must_exit = 1; | ||
817 | + printf("\nexit requested by user through ctrl+c \n"); | ||
818 | +} | ||
819 | + | ||
820 | +static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
821 | + | ||
822 | +static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
823 | +{ | ||
824 | + int unit = 0; | ||
825 | + | ||
826 | + *data = bytes; | ||
827 | + while (*data > 1024 && units[unit + 1]) { | ||
828 | + *data /= 1024; | ||
829 | + unit++; | ||
830 | + } | ||
831 | + *speed = *data / time; | ||
832 | + sprintf(metric, "%sB", units[unit]); | ||
833 | +} | ||
834 | + | ||
835 | +static void value2machine(uint64_t bytes, double time, double* speed) | ||
836 | +{ | ||
837 | + *speed = bytes / time; | ||
838 | +} | ||
839 | + | ||
840 | +int get_alignmask(int fdc, struct session_op *sess) | ||
841 | +{ | ||
842 | + int alignmask; | ||
843 | + int min_alignmask = sizeof(void*) - 1; | ||
844 | + | ||
845 | +#ifdef CIOCGSESSINFO | ||
846 | + struct session_info_op siop; | ||
847 | + | ||
848 | + siop.ses = sess->ses; | ||
849 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
850 | + perror("ioctl(CIOCGSESSINFO)"); | ||
851 | + return -EINVAL; | ||
852 | + } | ||
853 | + alignmask = siop.alignmask; | ||
854 | + if (alignmask < min_alignmask) { | ||
855 | + alignmask = min_alignmask; | ||
856 | + } | ||
857 | +#else | ||
858 | + alignmask = 0; | ||
859 | +#endif | ||
860 | + | ||
861 | + return alignmask; | ||
862 | +} | ||
863 | + | ||
864 | +int encrypt_async(int fdc, struct test_params tp, struct session_op *sess) | ||
865 | +{ | ||
866 | + struct crypt_op cop; | ||
867 | + char *buffer[64], iv[32]; | ||
868 | + uint8_t mac[64][HASH_MAX_LEN]; | ||
869 | + static int val = 23; | ||
870 | + struct timeval start, end; | ||
871 | + uint64_t total = 0; | ||
872 | + double secs, ddata, dspeed; | ||
873 | + char metric[16]; | ||
874 | + int rc, wqueue = 0, bufidx = 0; | ||
875 | + int alignmask; | ||
876 | + | ||
877 | + memset(iv, 0x23, 32); | ||
878 | + | ||
879 | + if (!tp.mflag) { | ||
880 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
881 | + fflush(stdout); | ||
882 | + } | ||
883 | + | ||
884 | + alignmask = get_alignmask(fdc, sess); | ||
885 | + for (rc = 0; rc < 64; rc++) { | ||
886 | + if (alignmask) { | ||
887 | + if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
888 | + printf("posix_memalign() failed!\n"); | ||
889 | + return 1; | ||
890 | + } | ||
891 | + } else { | ||
892 | + if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
893 | + perror("malloc()"); | ||
894 | + return 1; | ||
895 | + } | ||
896 | + } | ||
897 | + memset(buffer[rc], val++, tp.nvalue); | ||
898 | + } | ||
899 | + pfd.fd = fdc; | ||
900 | + pfd.events = POLLOUT | POLLIN; | ||
901 | + | ||
902 | + must_finish = 0; | ||
903 | + alarm(tp.tvalue); | ||
904 | + | ||
905 | + gettimeofday(&start, NULL); | ||
906 | + do { | ||
907 | + if ((rc = poll(&pfd, 1, 100)) < 0) { | ||
908 | + if (errno & (ERESTART | EINTR)) | ||
909 | + continue; | ||
910 | + fprintf(stderr, "errno = %d ", errno); | ||
911 | + perror("poll()"); | ||
912 | + return 1; | ||
913 | + } | ||
914 | + | ||
915 | + if (pfd.revents & POLLOUT) { | ||
916 | + memset(&cop, 0, sizeof(cop)); | ||
917 | + cop.ses = sess->ses; | ||
918 | + cop.len = tp.nvalue; | ||
919 | + cop.iv = (unsigned char *)iv; | ||
920 | + cop.op = COP_ENCRYPT; | ||
921 | + cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
922 | + cop.mac = mac[bufidx]; | ||
923 | + bufidx = (bufidx + 1) % 64; | ||
924 | + | ||
925 | + if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
926 | + perror("ioctl(CIOCASYNCCRYPT)"); | ||
927 | + return 1; | ||
928 | + } | ||
929 | + wqueue++; | ||
930 | + } | ||
931 | + if (pfd.revents & POLLIN) { | ||
932 | + if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { | ||
933 | + perror("ioctl(CIOCASYNCFETCH)"); | ||
934 | + return 1; | ||
935 | + } | ||
936 | + wqueue--; | ||
937 | + total += cop.len; | ||
938 | + } | ||
939 | + } while(!must_finish || wqueue); | ||
940 | + gettimeofday(&end, NULL); | ||
941 | + | ||
942 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
943 | + | ||
944 | + if (tp.mflag) { | ||
945 | + value2machine(total, secs, &dspeed); | ||
946 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
947 | + } else { | ||
948 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
949 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
950 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
951 | + } | ||
952 | + | ||
953 | + for (rc = 0; rc < 64; rc++) | ||
954 | + free(buffer[rc]); | ||
955 | + return 0; | ||
956 | +} | ||
957 | + | ||
958 | + | ||
959 | +static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
960 | +{ | ||
961 | + struct crypt_op cop; | ||
962 | + char *buffer, iv[32]; | ||
963 | + char mac[HASH_MAX_LEN]; | ||
964 | + static int val = 23; | ||
965 | + struct timeval start, end; | ||
966 | + uint64_t total = 0; | ||
967 | + double secs, ddata, dspeed; | ||
968 | + char metric[16]; | ||
969 | + int alignmask; | ||
970 | + int min_alignmask = sizeof(void*) - 1; | ||
971 | + | ||
972 | + memset(iv, 0x23, 32); | ||
973 | + | ||
974 | + if (!tp.mflag) { | ||
975 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
976 | + fflush(stdout); | ||
977 | + } | ||
978 | + | ||
979 | + alignmask = get_alignmask(fdc, sess); | ||
980 | + if (alignmask) { | ||
981 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
982 | + if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
983 | + printf("posix_memalign() failed!\n"); | ||
984 | + return 1; | ||
985 | + } | ||
986 | + } else { | ||
987 | + if (!(buffer = malloc(tp.nvalue))) { | ||
988 | + perror("malloc()"); | ||
989 | + return 1; | ||
990 | + } | ||
991 | + } | ||
992 | + memset(buffer, val++, tp.nvalue); | ||
993 | + | ||
994 | + must_finish = 0; | ||
995 | + alarm(tp.tvalue); | ||
996 | + | ||
997 | + gettimeofday(&start, NULL); | ||
998 | + do { | ||
999 | + memset(&cop, 0, sizeof(cop)); | ||
1000 | + cop.ses = sess->ses; | ||
1001 | + cop.len = tp.nvalue; | ||
1002 | + cop.iv = (unsigned char *)iv; | ||
1003 | + cop.op = COP_ENCRYPT; | ||
1004 | + cop.src = cop.dst = (unsigned char *)buffer; | ||
1005 | + cop.mac = (unsigned char *)mac; | ||
1006 | + | ||
1007 | + if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
1008 | + perror("ioctl(CIOCCRYPT)"); | ||
1009 | + return 1; | ||
1010 | + } | ||
1011 | + total += cop.len; | ||
1012 | + } while(!must_finish); | ||
1013 | + gettimeofday(&end, NULL); | ||
1014 | + | ||
1015 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
1016 | + | ||
1017 | + if (tp.mflag) { | ||
1018 | + value2machine(total, secs, &dspeed); | ||
1019 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
1020 | + } else { | ||
1021 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
1022 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
1023 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
1024 | + } | ||
1025 | + | ||
1026 | + free(buffer); | ||
1027 | + return 0; | ||
1028 | +} | ||
1029 | + | ||
1030 | +void usage(char *cmd_name) | ||
1031 | +{ | ||
1032 | + printf(usage_str, cmd_name); | ||
1033 | +} | ||
1034 | + | ||
1035 | +int run_test(int id, struct test_params tp) | ||
1036 | +{ | ||
1037 | + int fd; | ||
1038 | + int fdc; | ||
1039 | + int err; | ||
1040 | + | ||
1041 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
1042 | + if (fd < 0) { | ||
1043 | + perror("open()"); | ||
1044 | + return fd; | ||
1045 | + } | ||
1046 | + if (ioctl(fd, CRIOGET, &fdc)) { | ||
1047 | + perror("ioctl(CRIOGET)"); | ||
1048 | + return -EINVAL; | ||
1049 | + } | ||
1050 | + | ||
1051 | + if (!tp.mflag) { | ||
1052 | + char *type; | ||
1053 | + type = tp.aflag ? "async" : "sync"; | ||
1054 | + | ||
1055 | + fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
1056 | + } | ||
1057 | + err = ciphers[id].func(fdc, tp); | ||
1058 | + | ||
1059 | + close(fdc); | ||
1060 | + close(fd); | ||
1061 | + | ||
1062 | + return err; | ||
1063 | +} | ||
1064 | + | ||
1065 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
1066 | +{ | ||
1067 | + int i; | ||
1068 | + int err; | ||
1069 | + | ||
1070 | + if (tp.nflag) { | ||
1071 | + if (tp.aflag) { | ||
1072 | + encrypt_async(fdc, tp, sess); | ||
1073 | + } else { | ||
1074 | + encrypt_sync(fdc, tp, sess); | ||
1075 | + } | ||
1076 | + } else { | ||
1077 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
1078 | + if (must_exit) { | ||
1079 | + break; | ||
1080 | + } | ||
1081 | + | ||
1082 | + tp.nvalue = i; | ||
1083 | + if (tp.aflag) { | ||
1084 | + err = encrypt_async(fdc, tp, sess); | ||
1085 | + } else { | ||
1086 | + err = encrypt_sync(fdc, tp, sess); | ||
1087 | + } | ||
1088 | + | ||
1089 | + if (err != 0) { | ||
1090 | + break; | ||
1091 | + } | ||
1092 | + } | ||
1093 | + } | ||
1094 | +} | ||
1095 | + | ||
1096 | + | ||
1097 | +int run_null(int fdc, struct test_params tp) | ||
1098 | +{ | ||
1099 | + struct session_op sess; | ||
1100 | + char keybuf[32]; | ||
1101 | + | ||
1102 | + fprintf(stderr, "Testing NULL cipher: \n"); | ||
1103 | + memset(&sess, 0, sizeof(sess)); | ||
1104 | + sess.cipher = CRYPTO_NULL; | ||
1105 | + sess.keylen = 0; | ||
1106 | + sess.key = (unsigned char *)keybuf; | ||
1107 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1108 | + perror("ioctl(CIOCGSESSION)"); | ||
1109 | + return -EINVAL; | ||
1110 | + } | ||
1111 | + | ||
1112 | + do_test_vectors(fdc, tp, &sess); | ||
1113 | + return 0; | ||
1114 | +} | ||
1115 | + | ||
1116 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
1117 | +{ | ||
1118 | + struct session_op sess; | ||
1119 | + char keybuf[32]; | ||
1120 | + | ||
1121 | + memset(&sess, 0, sizeof(sess)); | ||
1122 | + sess.cipher = CRYPTO_AES_CBC; | ||
1123 | + sess.keylen = 16; | ||
1124 | + memset(keybuf, 0x42, 16); | ||
1125 | + sess.key = (unsigned char *)keybuf; | ||
1126 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1127 | + perror("ioctl(CIOCGSESSION)"); | ||
1128 | + return -EINVAL; | ||
1129 | + } | ||
1130 | + | ||
1131 | + do_test_vectors(fdc, tp, &sess); | ||
1132 | + return 0; | ||
1133 | +} | ||
1134 | + | ||
1135 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
1136 | +{ | ||
1137 | + struct session_op sess; | ||
1138 | + char keybuf[32]; | ||
1139 | + | ||
1140 | + memset(&sess, 0, sizeof(sess)); | ||
1141 | + sess.cipher = CRYPTO_AES_XTS; | ||
1142 | + sess.keylen = 32; | ||
1143 | + memset(keybuf, 0x42, sess.keylen); | ||
1144 | + sess.key = (unsigned char *)keybuf; | ||
1145 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1146 | + perror("ioctl(CIOCGSESSION)"); | ||
1147 | + return -EINVAL; | ||
1148 | + } | ||
1149 | + | ||
1150 | + do_test_vectors(fdc, tp, &sess); | ||
1151 | + return 0; | ||
1152 | +} | ||
1153 | + | ||
1154 | +int run_crc32c(int fdc, struct test_params tp) | ||
1155 | +{ | ||
1156 | + struct session_op sess; | ||
1157 | + | ||
1158 | + memset(&sess, 0, sizeof(sess)); | ||
1159 | + sess.mac = CRYPTO_CRC32C; | ||
1160 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1161 | + perror("ioctl(CIOCGSESSION)"); | ||
1162 | + return 1; | ||
1163 | + } | ||
1164 | + | ||
1165 | + do_test_vectors(fdc, tp, &sess); | ||
1166 | + return 0; | ||
1167 | +} | ||
1168 | + | ||
1169 | +int run_sha1(int fdc, struct test_params tp) | ||
1170 | +{ | ||
1171 | + struct session_op sess; | ||
1172 | + | ||
1173 | + memset(&sess, 0, sizeof(sess)); | ||
1174 | + sess.mac = CRYPTO_SHA1; | ||
1175 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1176 | + perror("ioctl(CIOCGSESSION)"); | ||
1177 | + return 1; | ||
1178 | + } | ||
1179 | + | ||
1180 | + do_test_vectors(fdc, tp, &sess); | ||
1181 | + return 0; | ||
1182 | +} | ||
1183 | + | ||
1184 | +int run_sha256(int fdc, struct test_params tp) | ||
1185 | +{ | ||
1186 | + struct session_op sess; | ||
1187 | + | ||
1188 | + memset(&sess, 0, sizeof(sess)); | ||
1189 | + sess.mac = CRYPTO_SHA2_256; | ||
1190 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1191 | + perror("ioctl(CIOCGSESSION)"); | ||
1192 | + return 1; | ||
1193 | + } | ||
1194 | + | ||
1195 | + do_test_vectors(fdc, tp, &sess); | ||
1196 | + return 0; | ||
1197 | +} | ||
1198 | + | ||
1199 | +int main(int argc, char **argv) | ||
1200 | +{ | ||
1201 | + int err = 0; | ||
1202 | + int i; | ||
1203 | + int c; | ||
1204 | + bool alg_flag; | ||
1205 | + char *alg_name; | ||
1206 | + struct test_params tp; | ||
1207 | + | ||
1208 | + tp.tflag = false; | ||
1209 | + tp.nflag = false; | ||
1210 | + tp.mflag = false; | ||
1211 | + tp.aflag = false; | ||
1212 | + alg_flag = false; | ||
1213 | + opterr = 0; | ||
1214 | + while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { | ||
1215 | + switch (c) { | ||
1216 | + case 'n': | ||
1217 | + tp.nvalue = atoi(optarg); | ||
1218 | + tp.nflag = true; | ||
1219 | + break; | ||
1220 | + case 't': | ||
1221 | + tp.tvalue = atoi(optarg); | ||
1222 | + tp.tflag = true; | ||
1223 | + break; | ||
1224 | + case 'm': | ||
1225 | + tp.mflag = true; | ||
1226 | + break; | ||
1227 | + case 'a': | ||
1228 | + tp.aflag = true; | ||
1229 | + break; | ||
1230 | + case 'h': /* no break */ | ||
1231 | + default: | ||
1232 | + usage(argv[0]); | ||
1233 | + exit(1); | ||
1234 | + } | ||
1235 | + } | ||
1236 | + | ||
1237 | + /* the name of a specific test asked on the command line */ | ||
1238 | + if (optind < argc) { | ||
1239 | + alg_name = argv[optind]; | ||
1240 | + alg_flag = true; | ||
1241 | + } | ||
1242 | + | ||
1243 | + /* default test time */ | ||
1244 | + if (!tp.tflag) { | ||
1245 | + tp.tvalue = 5; | ||
1246 | + } | ||
1247 | + | ||
1248 | + signal(SIGALRM, alarm_handler); | ||
1249 | + signal(SIGINT, exit_handler); | ||
1250 | + | ||
1251 | + for (i = 0; i < ALG_COUNT; i++) { | ||
1252 | + if (must_exit) { | ||
1253 | + break; | ||
1254 | + } | ||
1255 | + | ||
1256 | + if (alg_flag) { | ||
1257 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
1258 | + err = run_test(i, tp); | ||
1259 | + } | ||
1260 | + } else { | ||
1261 | + err = run_test(i, tp); | ||
1262 | + if (err != 0) { | ||
1263 | + break; | ||
1264 | + } | ||
1265 | + } | ||
1266 | + } | ||
1267 | + | ||
1268 | + return err; | ||
1269 | +} | ||
1270 | diff --git a/tests/speed_multi.sh b/tests/speed_multi.sh | ||
1271 | new file mode 100755 | ||
1272 | index 0000000..b116483 | ||
1273 | --- /dev/null | ||
1274 | +++ b/tests/speed_multi.sh | ||
1275 | @@ -0,0 +1,174 @@ | ||
1276 | +#!/bin/bash | ||
1277 | +# | ||
1278 | +# Copyright 2016 NXP Semiconductors | ||
1279 | +# | ||
1280 | +# This program is free software: you can redistribute it and/or modify | ||
1281 | +# it under the terms of the GNU General Public License as published by | ||
1282 | +# the Free Software Foundation, either version 2 of the License, or | ||
1283 | +# (at your option) any later version. | ||
1284 | +# | ||
1285 | +# This program is distributed in the hope that it will be useful, | ||
1286 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1287 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1288 | +# GNU General Public License for more details. | ||
1289 | +# | ||
1290 | +# You should have received a copy of the GNU General Public License | ||
1291 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1292 | + | ||
1293 | + | ||
1294 | + | ||
1295 | +# no user-configurable options below this line | ||
1296 | + | ||
1297 | +NUM_CORES=$(nproc) | ||
1298 | +CMD_BIN="speed" | ||
1299 | +OUT_BASENAME="speed" | ||
1300 | +MPSTAT_OUT="mpstat_out" | ||
1301 | + | ||
1302 | +# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
1303 | +export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
1304 | + | ||
1305 | + | ||
1306 | +function usage | ||
1307 | +{ | ||
1308 | +cat << EOF | ||
1309 | +Usage: `basename $0` [OPTIONS] <alg_name> | ||
1310 | + | ||
1311 | + -m <threads> number of threads to run with (defaults to number of cores) | ||
1312 | + -t <secs> time to run each test (default 10 secs) | ||
1313 | + -n <bytes> size of the test buffer (default 256 bytes) | ||
1314 | + -v make output more verbose (default tabular) | ||
1315 | + -a run async version of the benchmark (default sync) | ||
1316 | + -h show this help | ||
1317 | + | ||
1318 | +alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
1319 | + | ||
1320 | +Note: SEC driver is configured to support buffers smaller than 512K | ||
1321 | +EOF | ||
1322 | +} | ||
1323 | + | ||
1324 | +function SUM { | ||
1325 | + paste -sd+ - | bc -l | ||
1326 | +} | ||
1327 | + | ||
1328 | +function get_cpu_idle | ||
1329 | +{ | ||
1330 | + header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
1331 | + idle_column=$(echo $header_line | wc -w) | ||
1332 | + average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
1333 | + | ||
1334 | + echo $average_idle | ||
1335 | +} | ||
1336 | + | ||
1337 | +function run_parallel | ||
1338 | +{ | ||
1339 | + trap control_c SIGINT | ||
1340 | + | ||
1341 | + OPTIONS="-t $tvalue -n $nvalue -m $aflag" | ||
1342 | + CMD="$CMD_BIN $OPTIONS $alg_name" | ||
1343 | + | ||
1344 | + (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
1345 | + MPSTAT_PID=$! | ||
1346 | + | ||
1347 | + PIDS="" | ||
1348 | + start=$(date +%s.%N) | ||
1349 | + | ||
1350 | + for i in $(seq 0 $(($mvalue-1))) | ||
1351 | + do | ||
1352 | + CMD_OUT="${OUT_BASENAME}_${i}" | ||
1353 | + | ||
1354 | + $CMD &> $CMD_OUT & | ||
1355 | + PID=$! | ||
1356 | + AFFINITY=$(($i % $NUM_CORES)) | ||
1357 | + taskset -pc $AFFINITY $PID > /dev/null | ||
1358 | + | ||
1359 | + PIDS="$PID $PIDS" | ||
1360 | + done | ||
1361 | + | ||
1362 | + wait $PIDS | ||
1363 | + end=$(date +%s.%N) | ||
1364 | + | ||
1365 | + wait $MPSTAT_PID | ||
1366 | + | ||
1367 | + grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
1368 | + if (($? == 0)) | ||
1369 | + then | ||
1370 | + echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
1371 | + exit 1 | ||
1372 | + fi | ||
1373 | + | ||
1374 | + runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
1375 | + total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
1376 | + avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
1377 | + cpu_idle=$(get_cpu_idle) | ||
1378 | + | ||
1379 | + if [ ! -z "$vflag" ] | ||
1380 | + then | ||
1381 | + echo | ||
1382 | + echo "buffer size : $nvalue" | ||
1383 | + echo "running time : $runtime" | ||
1384 | + echo "avg_speed : $avg_speed GB/s" | ||
1385 | + echo "all_cpu idle : $cpu_idle %" | ||
1386 | + echo | ||
1387 | + else | ||
1388 | + echo -e "algorithm\t""threads\t""run time\t"\ | ||
1389 | + "buffer size\t""GB/s\t""%cpu idle" | ||
1390 | + echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
1391 | + "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
1392 | + fi | ||
1393 | +} | ||
1394 | + | ||
1395 | +function control_c | ||
1396 | +{ | ||
1397 | + killall $CMD_BIN > /dev/null | ||
1398 | + killall mpstat > /dev/null | ||
1399 | +} | ||
1400 | + | ||
1401 | +function main | ||
1402 | +{ | ||
1403 | + [ ! -e "/dev/crypto" ] && | ||
1404 | + (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
1405 | + | ||
1406 | + $(which ${CMD_BIN} &> /dev/null) | ||
1407 | + if (($? != 0)) | ||
1408 | + then | ||
1409 | + echo "${CMD_BIN} test is not installed" | ||
1410 | + exit 1 | ||
1411 | + fi | ||
1412 | + | ||
1413 | + rm -f ${OUT_BASENAME}_* | ||
1414 | + rm -f ${MPSTAT_OUT} | ||
1415 | + | ||
1416 | + while getopts avhm:t:n: option | ||
1417 | + do | ||
1418 | + case "$option" in | ||
1419 | + m) mvalue="$OPTARG";; | ||
1420 | + t) tvalue="$OPTARG";; | ||
1421 | + n) nvalue="$OPTARG";; | ||
1422 | + v) vflag="verbose";; | ||
1423 | + a) aflag="-a";; | ||
1424 | + *) usage $0; exit 1;; | ||
1425 | + esac | ||
1426 | + done | ||
1427 | + | ||
1428 | + shift $((OPTIND-1)) | ||
1429 | + alg_name=$1 | ||
1430 | + | ||
1431 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
1432 | + [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
1433 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
1434 | + | ||
1435 | + [ "$tvalue" -lt 5 ] && tvalue=5 | ||
1436 | + | ||
1437 | + case "$alg_name" in | ||
1438 | + "null" |\ | ||
1439 | + "aes-128-cbc" |\ | ||
1440 | + "aes-256-xts" |\ | ||
1441 | + "sha1" |\ | ||
1442 | + "sha256" |\ | ||
1443 | + "crc32c" ) run_parallel;; | ||
1444 | + * ) usage && exit 1;; | ||
1445 | + esac | ||
1446 | +} | ||
1447 | + | ||
1448 | +main "$@" | ||
1449 | + | ||
1450 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
1451 | deleted file mode 100644 | ||
1452 | index ceae645..0000000 | ||
1453 | --- a/tests/sync_speed.c | ||
1454 | +++ /dev/null | ||
1455 | @@ -1,400 +0,0 @@ | ||
1456 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
1457 | - * | ||
1458 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
1459 | - * | ||
1460 | - * This program is free software; you can redistribute it and/or modify | ||
1461 | - * it under the terms of the GNU General Public License as published by | ||
1462 | - * the Free Software Foundation; either version 2 of the License, or | ||
1463 | - * (at your option) any later version. | ||
1464 | - * | ||
1465 | - * This program is distributed in the hope that it will be useful, | ||
1466 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1467 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1468 | - * GNU General Public License for more details. | ||
1469 | - * | ||
1470 | - * You should have received a copy of the GNU General Public License | ||
1471 | - * along with this program; if not, write to the Free Software | ||
1472 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1473 | - */ | ||
1474 | -#include <errno.h> | ||
1475 | -#include <fcntl.h> | ||
1476 | -#include <poll.h> | ||
1477 | -#include <stdio.h> | ||
1478 | -#include <stdlib.h> | ||
1479 | -#include <string.h> | ||
1480 | -#include <sys/ioctl.h> | ||
1481 | -#include <sys/time.h> | ||
1482 | -#include <sys/types.h> | ||
1483 | -#include <signal.h> | ||
1484 | -#include <crypto/cryptodev.h> | ||
1485 | -#include <stdbool.h> | ||
1486 | -#include <unistd.h> | ||
1487 | - | ||
1488 | -struct test_params { | ||
1489 | - bool tflag; | ||
1490 | - bool nflag; | ||
1491 | - int tvalue; | ||
1492 | - int nvalue; | ||
1493 | -}; | ||
1494 | - | ||
1495 | -const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
1496 | - "Run benchmark test for cipher or hash\n\n" | ||
1497 | - " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
1498 | - " -n <bytes>\t" "size of the test buffer\n" | ||
1499 | - " -h\t\t" "show this help\n\n" | ||
1500 | - "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
1501 | -; | ||
1502 | - | ||
1503 | -int run_null(int fdc, struct test_params tp); | ||
1504 | -int run_aes_128_cbc(int fdc, struct test_params tp); | ||
1505 | -int run_aes_256_xts(int fdc, struct test_params tp); | ||
1506 | -int run_crc32c(int fdc, struct test_params tp); | ||
1507 | -int run_sha1(int fdc, struct test_params tp); | ||
1508 | -int run_sha256(int fdc, struct test_params tp); | ||
1509 | -int get_alignmask(int fdc, struct session_op *sess); | ||
1510 | - | ||
1511 | -#define ALG_COUNT 6 | ||
1512 | -struct { | ||
1513 | - char *name; | ||
1514 | - int (*func)(int, struct test_params); | ||
1515 | -} ciphers[ALG_COUNT] = { | ||
1516 | - {"null", run_null}, | ||
1517 | - {"aes-128-cbc", run_aes_128_cbc}, | ||
1518 | - {"aes-256-xts", run_aes_256_xts}, | ||
1519 | - {"crc32c", run_crc32c}, | ||
1520 | - {"sha1", run_sha1}, | ||
1521 | - {"sha256", run_sha256}, | ||
1522 | -}; | ||
1523 | - | ||
1524 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
1525 | -{ | ||
1526 | - return (double)(end.tv_usec - start.tv_usec) + | ||
1527 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
1528 | -} | ||
1529 | - | ||
1530 | -static volatile int must_finish; | ||
1531 | -static volatile int must_exit; | ||
1532 | - | ||
1533 | -static void alarm_handler(int signo) | ||
1534 | -{ | ||
1535 | - must_finish = 1; | ||
1536 | -} | ||
1537 | - | ||
1538 | -static void exit_handler(int signo) | ||
1539 | -{ | ||
1540 | - must_exit = 1; | ||
1541 | - printf("\nexit requested by user through ctrl+c \n"); | ||
1542 | -} | ||
1543 | - | ||
1544 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
1545 | - | ||
1546 | -static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
1547 | -{ | ||
1548 | - int unit = 0; | ||
1549 | - | ||
1550 | - *data = bytes; | ||
1551 | - while (*data > 1024 && units[unit + 1]) { | ||
1552 | - *data /= 1024; | ||
1553 | - unit++; | ||
1554 | - } | ||
1555 | - *speed = *data / time; | ||
1556 | - sprintf(metric, "%sB", units[unit]); | ||
1557 | -} | ||
1558 | - | ||
1559 | -static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
1560 | -{ | ||
1561 | - struct crypt_op cop; | ||
1562 | - char *buffer, iv[32]; | ||
1563 | - char mac[HASH_MAX_LEN]; | ||
1564 | - static int val = 23; | ||
1565 | - struct timeval start, end; | ||
1566 | - double total = 0; | ||
1567 | - double secs, ddata, dspeed; | ||
1568 | - char metric[16]; | ||
1569 | - int alignmask; | ||
1570 | - int min_alignmask = sizeof(void*) - 1; | ||
1571 | - | ||
1572 | - memset(iv, 0x23, 32); | ||
1573 | - | ||
1574 | - printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
1575 | - fflush(stdout); | ||
1576 | - | ||
1577 | - alignmask = get_alignmask(fdc, sess); | ||
1578 | - if (alignmask) { | ||
1579 | - alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
1580 | - if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
1581 | - printf("posix_memalign() failed!\n"); | ||
1582 | - return 1; | ||
1583 | - } | ||
1584 | - } else { | ||
1585 | - if (!(buffer = malloc(tp.nvalue))) { | ||
1586 | - perror("malloc()"); | ||
1587 | - return 1; | ||
1588 | - } | ||
1589 | - } | ||
1590 | - memset(buffer, val++, tp.nvalue); | ||
1591 | - | ||
1592 | - must_finish = 0; | ||
1593 | - alarm(tp.tvalue); | ||
1594 | - | ||
1595 | - gettimeofday(&start, NULL); | ||
1596 | - do { | ||
1597 | - memset(&cop, 0, sizeof(cop)); | ||
1598 | - cop.ses = sess->ses; | ||
1599 | - cop.len = tp.nvalue; | ||
1600 | - cop.iv = (unsigned char *)iv; | ||
1601 | - cop.op = COP_ENCRYPT; | ||
1602 | - cop.src = cop.dst = (unsigned char *)buffer; | ||
1603 | - cop.mac = (unsigned char *)mac; | ||
1604 | - | ||
1605 | - if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
1606 | - perror("ioctl(CIOCCRYPT)"); | ||
1607 | - return 1; | ||
1608 | - } | ||
1609 | - total += cop.len; | ||
1610 | - } while(!must_finish); | ||
1611 | - gettimeofday(&end, NULL); | ||
1612 | - | ||
1613 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
1614 | - | ||
1615 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
1616 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
1617 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
1618 | - | ||
1619 | - free(buffer); | ||
1620 | - return 0; | ||
1621 | -} | ||
1622 | - | ||
1623 | -void usage(char *cmd_name) | ||
1624 | -{ | ||
1625 | - printf(usage_str, cmd_name); | ||
1626 | -} | ||
1627 | - | ||
1628 | -int run_test(int id, struct test_params tp) | ||
1629 | -{ | ||
1630 | - int fd; | ||
1631 | - int fdc; | ||
1632 | - | ||
1633 | - fd = open("/dev/crypto", O_RDWR, 0); | ||
1634 | - if (fd < 0) { | ||
1635 | - perror("open()"); | ||
1636 | - return fd; | ||
1637 | - } | ||
1638 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
1639 | - perror("ioctl(CRIOGET)"); | ||
1640 | - return -EINVAL; | ||
1641 | - } | ||
1642 | - | ||
1643 | - ciphers[id].func(fdc, tp); | ||
1644 | - | ||
1645 | - close(fdc); | ||
1646 | - close(fd); | ||
1647 | - | ||
1648 | - return 0; | ||
1649 | -} | ||
1650 | - | ||
1651 | -int get_alignmask(int fdc, struct session_op *sess) | ||
1652 | -{ | ||
1653 | - int alignmask; | ||
1654 | - | ||
1655 | -#ifdef CIOCGSESSINFO | ||
1656 | - struct session_info_op siop; | ||
1657 | - | ||
1658 | - siop.ses = sess->ses; | ||
1659 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
1660 | - perror("ioctl(CIOCGSESSINFO)"); | ||
1661 | - return -EINVAL; | ||
1662 | - } | ||
1663 | - alignmask = siop.alignmask; | ||
1664 | -#else | ||
1665 | - alignmask = 0; | ||
1666 | -#endif | ||
1667 | - | ||
1668 | - return alignmask; | ||
1669 | -} | ||
1670 | - | ||
1671 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
1672 | -{ | ||
1673 | - int i; | ||
1674 | - | ||
1675 | - if (tp.nflag) { | ||
1676 | - encrypt_data(fdc, tp, sess); | ||
1677 | - } else { | ||
1678 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
1679 | - if (must_exit) | ||
1680 | - break; | ||
1681 | - | ||
1682 | - tp.nvalue = i; | ||
1683 | - if (encrypt_data(fdc, tp, sess)) { | ||
1684 | - break; | ||
1685 | - } | ||
1686 | - } | ||
1687 | - } | ||
1688 | -} | ||
1689 | - | ||
1690 | - | ||
1691 | -int run_null(int fdc, struct test_params tp) | ||
1692 | -{ | ||
1693 | - struct session_op sess; | ||
1694 | - char keybuf[32]; | ||
1695 | - | ||
1696 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
1697 | - memset(&sess, 0, sizeof(sess)); | ||
1698 | - sess.cipher = CRYPTO_NULL; | ||
1699 | - sess.keylen = 0; | ||
1700 | - sess.key = (unsigned char *)keybuf; | ||
1701 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1702 | - perror("ioctl(CIOCGSESSION)"); | ||
1703 | - return -EINVAL; | ||
1704 | - } | ||
1705 | - | ||
1706 | - do_test_vectors(fdc, tp, &sess); | ||
1707 | - return 0; | ||
1708 | -} | ||
1709 | - | ||
1710 | -int run_aes_128_cbc(int fdc, struct test_params tp) | ||
1711 | -{ | ||
1712 | - struct session_op sess; | ||
1713 | - char keybuf[32]; | ||
1714 | - | ||
1715 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
1716 | - memset(&sess, 0, sizeof(sess)); | ||
1717 | - sess.cipher = CRYPTO_AES_CBC; | ||
1718 | - sess.keylen = 16; | ||
1719 | - memset(keybuf, 0x42, 16); | ||
1720 | - sess.key = (unsigned char *)keybuf; | ||
1721 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1722 | - perror("ioctl(CIOCGSESSION)"); | ||
1723 | - return -EINVAL; | ||
1724 | - } | ||
1725 | - | ||
1726 | - do_test_vectors(fdc, tp, &sess); | ||
1727 | - return 0; | ||
1728 | -} | ||
1729 | - | ||
1730 | -int run_aes_256_xts(int fdc, struct test_params tp) | ||
1731 | -{ | ||
1732 | - struct session_op sess; | ||
1733 | - char keybuf[32]; | ||
1734 | - | ||
1735 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
1736 | - memset(&sess, 0, sizeof(sess)); | ||
1737 | - sess.cipher = CRYPTO_AES_XTS; | ||
1738 | - sess.keylen = 32; | ||
1739 | - memset(keybuf, 0x42, sess.keylen); | ||
1740 | - sess.key = (unsigned char *)keybuf; | ||
1741 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1742 | - perror("ioctl(CIOCGSESSION)"); | ||
1743 | - return -EINVAL; | ||
1744 | - } | ||
1745 | - | ||
1746 | - do_test_vectors(fdc, tp, &sess); | ||
1747 | - return 0; | ||
1748 | -} | ||
1749 | - | ||
1750 | -int run_crc32c(int fdc, struct test_params tp) | ||
1751 | -{ | ||
1752 | - struct session_op sess; | ||
1753 | - | ||
1754 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
1755 | - memset(&sess, 0, sizeof(sess)); | ||
1756 | - sess.mac = CRYPTO_CRC32C; | ||
1757 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1758 | - perror("ioctl(CIOCGSESSION)"); | ||
1759 | - return 1; | ||
1760 | - } | ||
1761 | - | ||
1762 | - do_test_vectors(fdc, tp, &sess); | ||
1763 | - return 0; | ||
1764 | -} | ||
1765 | - | ||
1766 | -int run_sha1(int fdc, struct test_params tp) | ||
1767 | -{ | ||
1768 | - struct session_op sess; | ||
1769 | - | ||
1770 | - fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
1771 | - memset(&sess, 0, sizeof(sess)); | ||
1772 | - sess.mac = CRYPTO_SHA1; | ||
1773 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1774 | - perror("ioctl(CIOCGSESSION)"); | ||
1775 | - return 1; | ||
1776 | - } | ||
1777 | - | ||
1778 | - do_test_vectors(fdc, tp, &sess); | ||
1779 | - return 0; | ||
1780 | -} | ||
1781 | - | ||
1782 | -int run_sha256(int fdc, struct test_params tp) | ||
1783 | -{ | ||
1784 | - struct session_op sess; | ||
1785 | - | ||
1786 | - fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
1787 | - memset(&sess, 0, sizeof(sess)); | ||
1788 | - sess.mac = CRYPTO_SHA2_256; | ||
1789 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1790 | - perror("ioctl(CIOCGSESSION)"); | ||
1791 | - return 1; | ||
1792 | - } | ||
1793 | - | ||
1794 | - do_test_vectors(fdc, tp, &sess); | ||
1795 | - return 0; | ||
1796 | -} | ||
1797 | - | ||
1798 | -int main(int argc, char **argv) | ||
1799 | -{ | ||
1800 | - int i; | ||
1801 | - int c; | ||
1802 | - bool alg_flag; | ||
1803 | - char *alg_name; | ||
1804 | - struct test_params tp; | ||
1805 | - | ||
1806 | - tp.tflag = false; | ||
1807 | - tp.nflag = false; | ||
1808 | - alg_flag = false; | ||
1809 | - opterr = 0; | ||
1810 | - while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
1811 | - switch (c) { | ||
1812 | - case 'n': | ||
1813 | - tp.nvalue = atoi(optarg); | ||
1814 | - tp.nflag = true; | ||
1815 | - break; | ||
1816 | - case 't': | ||
1817 | - tp.tvalue = atoi(optarg); | ||
1818 | - tp.tflag = true; | ||
1819 | - break; | ||
1820 | - case 'h': /* no break */ | ||
1821 | - default: | ||
1822 | - usage(argv[0]); | ||
1823 | - exit(1); | ||
1824 | - } | ||
1825 | - } | ||
1826 | - | ||
1827 | - /* the name of a specific test asked on the command line */ | ||
1828 | - if (optind < argc) { | ||
1829 | - alg_name = argv[optind]; | ||
1830 | - alg_flag = true; | ||
1831 | - } | ||
1832 | - | ||
1833 | - /* default test time */ | ||
1834 | - if (!tp.tflag) { | ||
1835 | - tp.tvalue = 5; | ||
1836 | - } | ||
1837 | - | ||
1838 | - signal(SIGALRM, alarm_handler); | ||
1839 | - signal(SIGINT, exit_handler); | ||
1840 | - | ||
1841 | - for (i = 0; i < ALG_COUNT; i++) { | ||
1842 | - if (must_exit) | ||
1843 | - break; | ||
1844 | - | ||
1845 | - if (alg_flag) { | ||
1846 | - if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
1847 | - run_test(i, tp); | ||
1848 | - } | ||
1849 | - } else { | ||
1850 | - run_test(i, tp); | ||
1851 | - } | ||
1852 | - } | ||
1853 | - | ||
1854 | - return 0; | ||
1855 | -} | ||
1856 | -- | ||
1857 | 2.10.2 | ||
1858 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch b/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch new file mode 100644 index 00000000..50799f8d --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch | |||
@@ -0,0 +1,62 @@ | |||
1 | From bccc3add64bfd4a048bf7e5a2935b2fc719d8e13 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 1 Nov 2016 13:28:40 +0200 | ||
4 | Subject: [PATCH 089/104] add -async option to run_crypto_tests.sh | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/run_crypto_tests.sh | 31 ++++++++++++++++++++++++++++++- | ||
9 | 1 file changed, 30 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
12 | index e128637..321b013 100644 | ||
13 | --- a/tests/run_crypto_tests.sh | ||
14 | +++ b/tests/run_crypto_tests.sh | ||
15 | @@ -4,6 +4,31 @@ | ||
16 | BUF_SIZE="8192 16384 65536 131072 262144" | ||
17 | THREAD_CNT="1 8 12" | ||
18 | ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" | ||
19 | +TIME=10 | ||
20 | + | ||
21 | +############################ | ||
22 | + | ||
23 | +function usage | ||
24 | +{ | ||
25 | +cat << EOF | ||
26 | +Usage: `basename $0` [OPTIONS] | ||
27 | + | ||
28 | + -a run async version of the benchmark (default sync) | ||
29 | + -h show this help | ||
30 | + | ||
31 | +Run in sequence benchmarks for several crypto algorithms: | ||
32 | +$ALG_NAMES | ||
33 | +EOF | ||
34 | +} | ||
35 | + | ||
36 | +while getopts ah option | ||
37 | +do | ||
38 | + case "$option" in | ||
39 | + a) aflag="-a";; | ||
40 | + *) usage $0; exit 1;; | ||
41 | + esac | ||
42 | +done | ||
43 | + | ||
44 | |||
45 | #restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 | ||
46 | #restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 | ||
47 | @@ -16,7 +41,11 @@ do | ||
48 | do | ||
49 | for bsize in ${BUF_SIZE} | ||
50 | do | ||
51 | - speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
52 | + speed_multi.sh -t ${TIME}\ | ||
53 | + -n ${bsize}\ | ||
54 | + -m ${multi}\ | ||
55 | + ${aflag}\ | ||
56 | + ${alg_name} | | ||
57 | tail -n 1 | ||
58 | done | ||
59 | done | ||
60 | -- | ||
61 | 2.10.2 | ||
62 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch b/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch new file mode 100644 index 00000000..95959299 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From d40bcfdfb2c2c5aa4c47b5653fdea3ee317d234b Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 5 Aug 2016 18:43:55 +0200 | ||
4 | Subject: [PATCH 090/104] Adjust to recent user page API changes | ||
5 | |||
6 | 4.6.0 basically renamed get_user_pages() to get_user_pages_remote() and | ||
7 | introduced a new get_user_pages() that always works on the current | ||
8 | task.[1] Distinguish the two APIs based on kernel version we're | ||
9 | compiling for. | ||
10 | |||
11 | Also, there seems to have been a massive cleansing of | ||
12 | page_cache_release(page) in favour of put_page(page)[2] which was an | ||
13 | alias for put_page(page)[3] since 2.6.0. Before that beginning with | ||
14 | 2.4.0 both page_cache_release(page) and put_page(page) have been aliases | ||
15 | for __free_page(page). So using put_page() instead of | ||
16 | page_cache_release(page) will produce identical code for anything after | ||
17 | 2.4.0. | ||
18 | |||
19 | [1] https://lkml.org/lkml/2016/2/10/555 | ||
20 | [2] https://www.spinics.net/lists/linux-fsdevel/msg95923.html | ||
21 | [3] https://www.spinics.net/lists/linux-fsdevel/msg95922.html | ||
22 | --- | ||
23 | zc.c | 9 +++++++-- | ||
24 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
25 | |||
26 | diff --git a/zc.c b/zc.c | ||
27 | index 29b0501..a97b49f 100644 | ||
28 | --- a/zc.c | ||
29 | +++ b/zc.c | ||
30 | @@ -59,7 +59,12 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
31 | } | ||
32 | |||
33 | down_read(&mm->mmap_sem); | ||
34 | - ret = get_user_pages(task, mm, | ||
35 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) | ||
36 | + ret = get_user_pages_remote( | ||
37 | +#else | ||
38 | + ret = get_user_pages( | ||
39 | +#endif | ||
40 | + task, mm, | ||
41 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
42 | up_read(&mm->mmap_sem); | ||
43 | if (ret != pgcount) | ||
44 | @@ -119,7 +124,7 @@ void release_user_pages(struct csession *ses) | ||
45 | else | ||
46 | ses->readonly_pages--; | ||
47 | |||
48 | - page_cache_release(ses->pages[i]); | ||
49 | + put_page(ses->pages[i]); | ||
50 | } | ||
51 | ses->used_pages = 0; | ||
52 | } | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch b/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch new file mode 100644 index 00000000..639fe0fd --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch | |||
@@ -0,0 +1,65 @@ | |||
1 | From a715480416b33b0bacd2b58ec42b9c64bdb21c0c Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 19 Aug 2016 10:24:40 +0100 | ||
4 | Subject: [PATCH 091/104] Fix test compile time warnings | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | A number of tests cause compiler warnings like this: | ||
10 | |||
11 | hashcrypt_speed.c: In function ‘hash_data’: | ||
12 | hashcrypt_speed.c:101:2: warning: implicit declaration of function ‘alarm’ [-Wimplicit-function-declaration] | ||
13 | alarm(5); | ||
14 | ^~~~~ | ||
15 | hashcrypt_speed.c: In function ‘main’: | ||
16 | hashcrypt_speed.c:203:2: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration] | ||
17 | close(fdc); | ||
18 | ^~~~~ | ||
19 | |||
20 | Fix by including unistd.h. | ||
21 | --- | ||
22 | tests/hashcrypt_speed.c | 1 + | ||
23 | tests/sha_speed.c | 1 + | ||
24 | tests/speed.c | 1 + | ||
25 | 3 files changed, 3 insertions(+) | ||
26 | |||
27 | diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c | ||
28 | index 045bf8e..10c9f00 100644 | ||
29 | --- a/tests/hashcrypt_speed.c | ||
30 | +++ b/tests/hashcrypt_speed.c | ||
31 | @@ -21,6 +21,7 @@ | ||
32 | #include <stdint.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <string.h> | ||
35 | +#include <unistd.h> | ||
36 | #include <sys/ioctl.h> | ||
37 | #include <sys/time.h> | ||
38 | #include <sys/types.h> | ||
39 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
40 | index 9f2c8cc..30b40f5 100644 | ||
41 | --- a/tests/sha_speed.c | ||
42 | +++ b/tests/sha_speed.c | ||
43 | @@ -21,6 +21,7 @@ | ||
44 | #include <stdint.h> | ||
45 | #include <stdlib.h> | ||
46 | #include <string.h> | ||
47 | +#include <unistd.h> | ||
48 | #include <sys/ioctl.h> | ||
49 | #include <sys/time.h> | ||
50 | #include <sys/types.h> | ||
51 | diff --git a/tests/speed.c b/tests/speed.c | ||
52 | index 3b36db1..fc38a63 100644 | ||
53 | --- a/tests/speed.c | ||
54 | +++ b/tests/speed.c | ||
55 | @@ -22,6 +22,7 @@ | ||
56 | #include <stdio.h> | ||
57 | #include <stdlib.h> | ||
58 | #include <string.h> | ||
59 | +#include <unistd.h> | ||
60 | #include <sys/ioctl.h> | ||
61 | #include <sys/time.h> | ||
62 | #include <sys/types.h> | ||
63 | -- | ||
64 | 2.10.2 | ||
65 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch b/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch new file mode 100644 index 00000000..4a82955e --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch | |||
@@ -0,0 +1,281 @@ | |||
1 | From e41e73551c886366d741b5e401a3c4c661aa3020 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 5 Aug 2016 17:26:27 +0200 | ||
4 | Subject: [PATCH 092/104] Support skcipher in addition to ablkcipher API | ||
5 | |||
6 | The ablkcipher API is being phased out[1]. The unified skcipher API | ||
7 | seems to have made its entry with 4.3.[3, 4] By what can be seen from | ||
8 | migration patches[1.ff.], it's a drop-in replacement. | ||
9 | |||
10 | Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2]. | ||
11 | |||
12 | Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and | ||
13 | retain support for old kernels. Make it decide which API to use and provide | ||
14 | appropriate function calls and type definitions. Since the ablkcipher and | ||
15 | skcipher APIs are so similar, those are mainly defines for corresponding | ||
16 | pseudo-functions in namespace cryptodev_ derived directly from their API | ||
17 | counterparts. | ||
18 | |||
19 | Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel | ||
20 | as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for | ||
21 | changed page access API[5].) | ||
22 | |||
23 | [1] https://www.spinics.net/lists/linux-crypto/msg18133.html | ||
24 | [2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120 | ||
25 | [3] https://www.spinics.net/lists/linux-crypto/msg16373.html | ||
26 | [4] https://www.spinics.net/lists/linux-crypto/msg16294.html | ||
27 | [5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14 | ||
28 | --- | ||
29 | cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
30 | cryptlib.c | 40 ++++++++++++++++++---------------------- | ||
31 | cryptlib.h | 6 ++++-- | ||
32 | ioctl.c | 4 ++-- | ||
33 | 4 files changed, 84 insertions(+), 26 deletions(-) | ||
34 | create mode 100644 cipherapi.h | ||
35 | |||
36 | diff --git a/cipherapi.h b/cipherapi.h | ||
37 | new file mode 100644 | ||
38 | index 0000000..07d9923 | ||
39 | --- /dev/null | ||
40 | +++ b/cipherapi.h | ||
41 | @@ -0,0 +1,60 @@ | ||
42 | +#ifndef CIPHERAPI_H | ||
43 | +# define CIPHERAPI_H | ||
44 | + | ||
45 | +#include <linux/version.h> | ||
46 | + | ||
47 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) | ||
48 | +# include <linux/crypto.h> | ||
49 | + | ||
50 | +typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; | ||
51 | +typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; | ||
52 | +typedef struct ablkcipher_request cryptodev_blkcipher_request_t; | ||
53 | + | ||
54 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher | ||
55 | +# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg | ||
56 | +# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize | ||
57 | +# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize | ||
58 | +# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask | ||
59 | +# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey | ||
60 | + | ||
61 | +static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { | ||
62 | + if (c) | ||
63 | + crypto_free_ablkcipher(c); | ||
64 | +} | ||
65 | + | ||
66 | +# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc | ||
67 | +# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback | ||
68 | + | ||
69 | +static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { | ||
70 | + if (r) | ||
71 | + ablkcipher_request_free(r); | ||
72 | +} | ||
73 | + | ||
74 | +# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt | ||
75 | +# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt | ||
76 | +# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt | ||
77 | +# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm | ||
78 | +#else | ||
79 | +#include <crypto/skcipher.h> | ||
80 | + | ||
81 | +typedef struct skcipher_alg cryptodev_blkcipher_alg_t; | ||
82 | +typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; | ||
83 | +typedef struct skcipher_request cryptodev_blkcipher_request_t; | ||
84 | + | ||
85 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher | ||
86 | +# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg | ||
87 | +# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize | ||
88 | +# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize | ||
89 | +# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask | ||
90 | +# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey | ||
91 | +# define cryptodev_crypto_free_blkcipher crypto_free_skcipher | ||
92 | +# define cryptodev_blkcipher_request_alloc skcipher_request_alloc | ||
93 | +# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback | ||
94 | +# define cryptodev_blkcipher_request_free skcipher_request_free | ||
95 | +# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt | ||
96 | +# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt | ||
97 | +# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt | ||
98 | +# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm | ||
99 | +#endif | ||
100 | + | ||
101 | +#endif | ||
102 | diff --git a/cryptlib.c b/cryptlib.c | ||
103 | index 5d1a5a9..558d4b8 100644 | ||
104 | --- a/cryptlib.c | ||
105 | +++ b/cryptlib.c | ||
106 | @@ -24,7 +24,6 @@ | ||
107 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
108 | */ | ||
109 | |||
110 | -#include <linux/crypto.h> | ||
111 | #include <linux/mm.h> | ||
112 | #include <linux/highmem.h> | ||
113 | #include <linux/ioctl.h> | ||
114 | @@ -38,6 +37,7 @@ | ||
115 | #include <linux/rtnetlink.h> | ||
116 | #include <crypto/authenc.h> | ||
117 | #include "cryptodev_int.h" | ||
118 | +#include "cipherapi.h" | ||
119 | |||
120 | |||
121 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
122 | @@ -129,15 +129,15 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
123 | int ret; | ||
124 | |||
125 | if (aead == 0) { | ||
126 | - struct ablkcipher_alg *alg; | ||
127 | + cryptodev_blkcipher_alg_t *alg; | ||
128 | |||
129 | - out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); | ||
130 | + out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); | ||
131 | if (unlikely(IS_ERR(out->async.s))) { | ||
132 | ddebug(1, "Failed to load cipher %s", alg_name); | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | - alg = crypto_ablkcipher_alg(out->async.s); | ||
137 | + alg = cryptodev_crypto_blkcipher_alg(out->async.s); | ||
138 | if (alg != NULL) { | ||
139 | /* Was correct key length supplied? */ | ||
140 | if (alg->max_keysize > 0 && | ||
141 | @@ -150,11 +150,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
142 | } | ||
143 | } | ||
144 | |||
145 | - out->blocksize = crypto_ablkcipher_blocksize(out->async.s); | ||
146 | - out->ivsize = crypto_ablkcipher_ivsize(out->async.s); | ||
147 | - out->alignmask = crypto_ablkcipher_alignmask(out->async.s); | ||
148 | + out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); | ||
149 | + out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); | ||
150 | + out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s); | ||
151 | |||
152 | - ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen); | ||
153 | + ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen); | ||
154 | } else { | ||
155 | out->async.as = crypto_alloc_aead(alg_name, 0, 0); | ||
156 | if (unlikely(IS_ERR(out->async.as))) { | ||
157 | @@ -181,14 +181,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
158 | init_completion(&out->async.result.completion); | ||
159 | |||
160 | if (aead == 0) { | ||
161 | - out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
162 | + out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
163 | if (unlikely(!out->async.request)) { | ||
164 | derr(1, "error allocating async crypto request"); | ||
165 | ret = -ENOMEM; | ||
166 | goto error; | ||
167 | } | ||
168 | |||
169 | - ablkcipher_request_set_callback(out->async.request, 0, | ||
170 | + cryptodev_blkcipher_request_set_callback(out->async.request, 0, | ||
171 | cryptodev_complete, &out->async.result); | ||
172 | } else { | ||
173 | out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); | ||
174 | @@ -206,10 +206,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
175 | return 0; | ||
176 | error: | ||
177 | if (aead == 0) { | ||
178 | - if (out->async.request) | ||
179 | - ablkcipher_request_free(out->async.request); | ||
180 | - if (out->async.s) | ||
181 | - crypto_free_ablkcipher(out->async.s); | ||
182 | + cryptodev_blkcipher_request_free(out->async.request); | ||
183 | + cryptodev_crypto_free_blkcipher(out->async.s); | ||
184 | } else { | ||
185 | if (out->async.arequest) | ||
186 | aead_request_free(out->async.arequest); | ||
187 | @@ -224,10 +222,8 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) | ||
188 | { | ||
189 | if (cdata->init) { | ||
190 | if (cdata->aead == 0) { | ||
191 | - if (cdata->async.request) | ||
192 | - ablkcipher_request_free(cdata->async.request); | ||
193 | - if (cdata->async.s) | ||
194 | - crypto_free_ablkcipher(cdata->async.s); | ||
195 | + cryptodev_blkcipher_request_free(cdata->async.request); | ||
196 | + cryptodev_crypto_free_blkcipher(cdata->async.s); | ||
197 | } else { | ||
198 | if (cdata->async.arequest) | ||
199 | aead_request_free(cdata->async.arequest); | ||
200 | @@ -274,10 +270,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, | ||
201 | reinit_completion(&cdata->async.result.completion); | ||
202 | |||
203 | if (cdata->aead == 0) { | ||
204 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
205 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
206 | (struct scatterlist *)src, dst, | ||
207 | len, cdata->async.iv); | ||
208 | - ret = crypto_ablkcipher_encrypt(cdata->async.request); | ||
209 | + ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request); | ||
210 | } else { | ||
211 | aead_request_set_crypt(cdata->async.arequest, | ||
212 | (struct scatterlist *)src, dst, | ||
213 | @@ -296,10 +292,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
214 | |||
215 | reinit_completion(&cdata->async.result.completion); | ||
216 | if (cdata->aead == 0) { | ||
217 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
218 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
219 | (struct scatterlist *)src, dst, | ||
220 | len, cdata->async.iv); | ||
221 | - ret = crypto_ablkcipher_decrypt(cdata->async.request); | ||
222 | + ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request); | ||
223 | } else { | ||
224 | aead_request_set_crypt(cdata->async.arequest, | ||
225 | (struct scatterlist *)src, dst, | ||
226 | diff --git a/cryptlib.h b/cryptlib.h | ||
227 | index d8e8046..8200a1d 100644 | ||
228 | --- a/cryptlib.h | ||
229 | +++ b/cryptlib.h | ||
230 | @@ -11,6 +11,8 @@ struct cryptodev_result { | ||
231 | int err; | ||
232 | }; | ||
233 | |||
234 | +#include "cipherapi.h" | ||
235 | + | ||
236 | struct cipher_data { | ||
237 | int init; /* 0 uninitialized */ | ||
238 | int blocksize; | ||
239 | @@ -20,8 +22,8 @@ struct cipher_data { | ||
240 | int alignmask; | ||
241 | struct { | ||
242 | /* block ciphers */ | ||
243 | - struct crypto_ablkcipher *s; | ||
244 | - struct ablkcipher_request *request; | ||
245 | + cryptodev_crypto_blkcipher_t *s; | ||
246 | + cryptodev_blkcipher_request_t *request; | ||
247 | |||
248 | /* AEAD ciphers */ | ||
249 | struct crypto_aead *as; | ||
250 | diff --git a/ioctl.c b/ioctl.c | ||
251 | index 2e2bdeb..e3b8af1 100644 | ||
252 | --- a/ioctl.c | ||
253 | +++ b/ioctl.c | ||
254 | @@ -35,7 +35,6 @@ | ||
255 | */ | ||
256 | |||
257 | #include <crypto/hash.h> | ||
258 | -#include <linux/crypto.h> | ||
259 | #include <linux/mm.h> | ||
260 | #include <linux/highmem.h> | ||
261 | #include <linux/ioctl.h> | ||
262 | @@ -54,6 +53,7 @@ | ||
263 | #include "cryptodev_int.h" | ||
264 | #include "zc.h" | ||
265 | #include "version.h" | ||
266 | +#include "cipherapi.h" | ||
267 | |||
268 | MODULE_AUTHOR("Nikos Mavrogiannopoulos <nmav@gnutls.org>"); | ||
269 | MODULE_DESCRIPTION("CryptoDev driver"); | ||
270 | @@ -1052,7 +1052,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) | ||
271 | |||
272 | if (ses_ptr->cdata.init) { | ||
273 | if (ses_ptr->cdata.aead == 0) | ||
274 | - tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s); | ||
275 | + tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s); | ||
276 | else | ||
277 | tfm = crypto_aead_tfm(ses_ptr->cdata.async.as); | ||
278 | tfm_info_to_alg_info(&siop->cipher_info, tfm); | ||
279 | -- | ||
280 | 2.10.2 | ||
281 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch b/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch new file mode 100644 index 00000000..fcf2a3ee --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch | |||
@@ -0,0 +1,147 @@ | |||
1 | From 871ecc5c5ebfbb9c6e1b17a7ff7a531ed1fab644 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com> | ||
3 | Date: Wed, 16 Nov 2016 15:38:39 +0200 | ||
4 | Subject: [PATCH 093/104] Fix ablkcipher algorithms usage in v4.8+ kernels | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | ablkcipher API is not completely removed from kernels <= v4.9. | ||
10 | Thus it's still valid to use ablkcipher algorithms. | ||
11 | |||
12 | Fix the case when implementers register ablkcipher algorithms | ||
13 | and cryptodev casts them to skcipher without checking their type. | ||
14 | |||
15 | Note: alg returned by crypto_ablkcipher_alg() is no longer checked | ||
16 | to be non-NULL. This is guaranteed by the fact that ablkcipher_tfm | ||
17 | (out->async.s) is valid. | ||
18 | |||
19 | Fixes: cb186f682679 ("Support skcipher in addition to ablkcipher API") | ||
20 | Signed-off-by: Horia Geantă <horia.geanta@nxp.com> | ||
21 | --- | ||
22 | cipherapi.h | 4 ---- | ||
23 | cryptlib.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ | ||
24 | 2 files changed, 44 insertions(+), 16 deletions(-) | ||
25 | |||
26 | diff --git a/cipherapi.h b/cipherapi.h | ||
27 | index 07d9923..b6ed6c2 100644 | ||
28 | --- a/cipherapi.h | ||
29 | +++ b/cipherapi.h | ||
30 | @@ -6,12 +6,10 @@ | ||
31 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) | ||
32 | # include <linux/crypto.h> | ||
33 | |||
34 | -typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; | ||
35 | typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; | ||
36 | typedef struct ablkcipher_request cryptodev_blkcipher_request_t; | ||
37 | |||
38 | # define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher | ||
39 | -# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg | ||
40 | # define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize | ||
41 | # define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize | ||
42 | # define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask | ||
43 | @@ -37,12 +35,10 @@ static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_ | ||
44 | #else | ||
45 | #include <crypto/skcipher.h> | ||
46 | |||
47 | -typedef struct skcipher_alg cryptodev_blkcipher_alg_t; | ||
48 | typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; | ||
49 | typedef struct skcipher_request cryptodev_blkcipher_request_t; | ||
50 | |||
51 | # define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher | ||
52 | -# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg | ||
53 | # define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize | ||
54 | # define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize | ||
55 | # define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask | ||
56 | diff --git a/cryptlib.c b/cryptlib.c | ||
57 | index 558d4b8..dcac3ec 100644 | ||
58 | --- a/cryptlib.c | ||
59 | +++ b/cryptlib.c | ||
60 | @@ -39,6 +39,7 @@ | ||
61 | #include "cryptodev_int.h" | ||
62 | #include "cipherapi.h" | ||
63 | |||
64 | +extern const struct crypto_type crypto_givcipher_type; | ||
65 | |||
66 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
67 | { | ||
68 | @@ -122,6 +123,19 @@ error: | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | +/* Was correct key length supplied? */ | ||
73 | +static int check_key_size(size_t keylen, const char *alg_name, | ||
74 | + unsigned int min_keysize, unsigned int max_keysize) | ||
75 | +{ | ||
76 | + if (max_keysize > 0 && unlikely((keylen < min_keysize) || | ||
77 | + (keylen > max_keysize))) { | ||
78 | + ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
79 | + keylen, alg_name, min_keysize, max_keysize); | ||
80 | + return -EINVAL; | ||
81 | + } | ||
82 | + | ||
83 | + return 0; | ||
84 | +} | ||
85 | |||
86 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
87 | uint8_t *keyp, size_t keylen, int stream, int aead) | ||
88 | @@ -129,7 +143,12 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
89 | int ret; | ||
90 | |||
91 | if (aead == 0) { | ||
92 | - cryptodev_blkcipher_alg_t *alg; | ||
93 | + unsigned int min_keysize, max_keysize; | ||
94 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) | ||
95 | + struct crypto_tfm *tfm; | ||
96 | +#else | ||
97 | + struct ablkcipher_alg *alg; | ||
98 | +#endif | ||
99 | |||
100 | out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); | ||
101 | if (unlikely(IS_ERR(out->async.s))) { | ||
102 | @@ -137,18 +156,31 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
103 | return -EINVAL; | ||
104 | } | ||
105 | |||
106 | - alg = cryptodev_crypto_blkcipher_alg(out->async.s); | ||
107 | - if (alg != NULL) { | ||
108 | - /* Was correct key length supplied? */ | ||
109 | - if (alg->max_keysize > 0 && | ||
110 | - unlikely((keylen < alg->min_keysize) || | ||
111 | - (keylen > alg->max_keysize))) { | ||
112 | - ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
113 | - keylen, alg_name, alg->min_keysize, alg->max_keysize); | ||
114 | - ret = -EINVAL; | ||
115 | - goto error; | ||
116 | - } | ||
117 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) | ||
118 | + tfm = crypto_skcipher_tfm(out->async.s); | ||
119 | + if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) || | ||
120 | + (tfm->__crt_alg->cra_type == &crypto_givcipher_type)) { | ||
121 | + struct ablkcipher_alg *alg; | ||
122 | + | ||
123 | + alg = &tfm->__crt_alg->cra_ablkcipher; | ||
124 | + min_keysize = alg->min_keysize; | ||
125 | + max_keysize = alg->max_keysize; | ||
126 | + } else { | ||
127 | + struct skcipher_alg *alg; | ||
128 | + | ||
129 | + alg = crypto_skcipher_alg(out->async.s); | ||
130 | + min_keysize = alg->min_keysize; | ||
131 | + max_keysize = alg->max_keysize; | ||
132 | } | ||
133 | +#else | ||
134 | + alg = crypto_ablkcipher_alg(out->async.s); | ||
135 | + min_keysize = alg->min_keysize; | ||
136 | + max_keysize = alg->max_keysize; | ||
137 | +#endif | ||
138 | + ret = check_key_size(keylen, alg_name, min_keysize, | ||
139 | + max_keysize); | ||
140 | + if (ret) | ||
141 | + goto error; | ||
142 | |||
143 | out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); | ||
144 | out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); | ||
145 | -- | ||
146 | 2.10.2 | ||
147 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch b/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch new file mode 100644 index 00000000..9483d0c6 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch | |||
@@ -0,0 +1,36 @@ | |||
1 | From b7783948df06674da12352ff4f55c6e7c4213026 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 11 Nov 2016 18:09:32 +0100 | ||
4 | Subject: [PATCH 094/104] Adjust to another change in the user page API | ||
5 | |||
6 | 4.9.0 will replace the write and force flags of get_user_pages_remote() | ||
7 | with a gup_flags parameter[1]. Distinguish the two APIs based on kernel | ||
8 | version we're compiling for. | ||
9 | |||
10 | [1] https://github.com/torvalds/linux/commit/9beae1ea89305a9667ceaab6d0bf46a045ad71e7 | ||
11 | --- | ||
12 | zc.c | 8 +++++++- | ||
13 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/zc.c b/zc.c | ||
16 | index a97b49f..e766ee3 100644 | ||
17 | --- a/zc.c | ||
18 | +++ b/zc.c | ||
19 | @@ -65,7 +65,13 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
20 | ret = get_user_pages( | ||
21 | #endif | ||
22 | task, mm, | ||
23 | - (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
24 | + (unsigned long)addr, pgcount, | ||
25 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) | ||
26 | + write ? FOLL_WRITE : 0, | ||
27 | +#else | ||
28 | + write, 0, | ||
29 | +#endif | ||
30 | + pg, NULL); | ||
31 | up_read(&mm->mmap_sem); | ||
32 | if (ret != pgcount) | ||
33 | return -EINVAL; | ||
34 | -- | ||
35 | 2.10.2 | ||
36 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch b/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch new file mode 100644 index 00000000..d2784b1c --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch | |||
@@ -0,0 +1,173 @@ | |||
1 | From 1fff269afd1925f4e4c7e37cc8c52187c407bc56 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:21 +0200 | ||
4 | Subject: [PATCH 095/104] rename header file to clarify purpose | ||
5 | |||
6 | testhelper.h suggests a common repository of utility functions but | ||
7 | current content targets only async tests. If we include it in non-async | ||
8 | tests we are forced to include <poll.h> as well. | ||
9 | |||
10 | Rename this header file to clarify that it targets only async tests | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | tests/async_cipher.c | 2 +- | ||
15 | tests/async_hmac.c | 2 +- | ||
16 | tests/asynchelper.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ | ||
17 | tests/testhelper.h | 57 ---------------------------------------------------- | ||
18 | 4 files changed, 56 insertions(+), 59 deletions(-) | ||
19 | create mode 100644 tests/asynchelper.h | ||
20 | delete mode 100644 tests/testhelper.h | ||
21 | |||
22 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
23 | index dd08403..db6fb06 100644 | ||
24 | --- a/tests/async_cipher.c | ||
25 | +++ b/tests/async_cipher.c | ||
26 | @@ -13,7 +13,7 @@ | ||
27 | #include <sys/ioctl.h> | ||
28 | #include <crypto/cryptodev.h> | ||
29 | |||
30 | -#include "testhelper.h" | ||
31 | +#include "asynchelper.h" | ||
32 | |||
33 | #ifdef ENABLE_ASYNC | ||
34 | |||
35 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
36 | index 85d19c6..1bdaad3 100644 | ||
37 | --- a/tests/async_hmac.c | ||
38 | +++ b/tests/async_hmac.c | ||
39 | @@ -14,7 +14,7 @@ | ||
40 | #include <sys/ioctl.h> | ||
41 | #include <crypto/cryptodev.h> | ||
42 | |||
43 | -#include "testhelper.h" | ||
44 | +#include "asynchelper.h" | ||
45 | |||
46 | #ifdef ENABLE_ASYNC | ||
47 | |||
48 | diff --git a/tests/asynchelper.h b/tests/asynchelper.h | ||
49 | new file mode 100644 | ||
50 | index 0000000..b5ab16c | ||
51 | --- /dev/null | ||
52 | +++ b/tests/asynchelper.h | ||
53 | @@ -0,0 +1,54 @@ | ||
54 | +#ifndef __ASYNCHELPER_H | ||
55 | +#define __ASYNCHELPER_H | ||
56 | + | ||
57 | +/* poll until POLLOUT, then call CIOCASYNCCRYPT */ | ||
58 | +inline int do_async_crypt(int cfd, struct crypt_op *cryp) | ||
59 | +{ | ||
60 | + struct pollfd pfd; | ||
61 | + | ||
62 | + pfd.fd = cfd; | ||
63 | + pfd.events = POLLOUT; | ||
64 | + | ||
65 | + if (poll(&pfd, 1, -1) < 1) { | ||
66 | + perror("poll()"); | ||
67 | + return 1; | ||
68 | + } | ||
69 | + | ||
70 | + if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { | ||
71 | + perror("ioctl(CIOCCRYPT)"); | ||
72 | + return 1; | ||
73 | + } | ||
74 | + return 0; | ||
75 | +} | ||
76 | + | ||
77 | +/* poll until POLLIN, then call CIOCASYNCFETCH */ | ||
78 | +inline int do_async_fetch(int cfd, struct crypt_op *cryp) | ||
79 | +{ | ||
80 | + struct pollfd pfd; | ||
81 | + | ||
82 | + pfd.fd = cfd; | ||
83 | + pfd.events = POLLIN; | ||
84 | + | ||
85 | + if (poll(&pfd, 1, -1) < 1) { | ||
86 | + perror("poll()"); | ||
87 | + return 1; | ||
88 | + } | ||
89 | + | ||
90 | + if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { | ||
91 | + perror("ioctl(CIOCCRYPT)"); | ||
92 | + return 1; | ||
93 | + } | ||
94 | + return 0; | ||
95 | +} | ||
96 | + | ||
97 | +/* Check return value of stmt for identity with goodval. If they | ||
98 | + * don't match, call return with the value of stmt. */ | ||
99 | +#define DO_OR_DIE(stmt, goodval) { \ | ||
100 | + int __rc_val; \ | ||
101 | + if ((__rc_val = stmt) != goodval) { \ | ||
102 | + perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ | ||
103 | + return __rc_val; \ | ||
104 | + } \ | ||
105 | +} | ||
106 | + | ||
107 | +#endif /* __ASYNCHELPER_H */ | ||
108 | diff --git a/tests/testhelper.h b/tests/testhelper.h | ||
109 | deleted file mode 100644 | ||
110 | index ea0b100..0000000 | ||
111 | --- a/tests/testhelper.h | ||
112 | +++ /dev/null | ||
113 | @@ -1,57 +0,0 @@ | ||
114 | -/* | ||
115 | - * Some helper stuff shared between the sample programs. | ||
116 | - */ | ||
117 | -#ifndef _TESTHELPER_H | ||
118 | -#define _TESTHELPER_H | ||
119 | - | ||
120 | -/* poll until POLLOUT, then call CIOCASYNCCRYPT */ | ||
121 | -inline int do_async_crypt(int cfd, struct crypt_op *cryp) | ||
122 | -{ | ||
123 | - struct pollfd pfd; | ||
124 | - | ||
125 | - pfd.fd = cfd; | ||
126 | - pfd.events = POLLOUT; | ||
127 | - | ||
128 | - if (poll(&pfd, 1, -1) < 1) { | ||
129 | - perror("poll()"); | ||
130 | - return 1; | ||
131 | - } | ||
132 | - | ||
133 | - if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { | ||
134 | - perror("ioctl(CIOCCRYPT)"); | ||
135 | - return 1; | ||
136 | - } | ||
137 | - return 0; | ||
138 | -} | ||
139 | - | ||
140 | -/* poll until POLLIN, then call CIOCASYNCFETCH */ | ||
141 | -inline int do_async_fetch(int cfd, struct crypt_op *cryp) | ||
142 | -{ | ||
143 | - struct pollfd pfd; | ||
144 | - | ||
145 | - pfd.fd = cfd; | ||
146 | - pfd.events = POLLIN; | ||
147 | - | ||
148 | - if (poll(&pfd, 1, -1) < 1) { | ||
149 | - perror("poll()"); | ||
150 | - return 1; | ||
151 | - } | ||
152 | - | ||
153 | - if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { | ||
154 | - perror("ioctl(CIOCCRYPT)"); | ||
155 | - return 1; | ||
156 | - } | ||
157 | - return 0; | ||
158 | -} | ||
159 | - | ||
160 | -/* Check return value of stmt for identity with goodval. If they | ||
161 | - * don't match, call return with the value of stmt. */ | ||
162 | -#define DO_OR_DIE(stmt, goodval) { \ | ||
163 | - int __rc_val; \ | ||
164 | - if ((__rc_val = stmt) != goodval) { \ | ||
165 | - perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ | ||
166 | - return __rc_val; \ | ||
167 | - } \ | ||
168 | -} | ||
169 | - | ||
170 | -#endif /* _TESTHELPER_H */ | ||
171 | -- | ||
172 | 2.10.2 | ||
173 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch b/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch new file mode 100644 index 00000000..83d0be12 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch | |||
@@ -0,0 +1,248 @@ | |||
1 | From 6f4589ae57d141ea6257ae16df1709781d0fb8e4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:22 +0200 | ||
4 | Subject: [PATCH 096/104] use buf_align macro to reduce code duplication | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_cipher.c | 9 +++++---- | ||
9 | tests/cipher-aead-srtp.c | 13 +++++++------ | ||
10 | tests/cipher-aead.c | 13 +++++++------ | ||
11 | tests/cipher-gcm.c | 17 +++++------------ | ||
12 | tests/cipher.c | 9 +++++---- | ||
13 | tests/testhelper.h | 9 +++++++++ | ||
14 | 6 files changed, 38 insertions(+), 32 deletions(-) | ||
15 | create mode 100644 tests/testhelper.h | ||
16 | |||
17 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
18 | index db6fb06..7a184e5 100644 | ||
19 | --- a/tests/async_cipher.c | ||
20 | +++ b/tests/async_cipher.c | ||
21 | @@ -14,6 +14,7 @@ | ||
22 | #include <crypto/cryptodev.h> | ||
23 | |||
24 | #include "asynchelper.h" | ||
25 | +#include "testhelper.h" | ||
26 | |||
27 | #ifdef ENABLE_ASYNC | ||
28 | |||
29 | @@ -62,8 +63,8 @@ test_crypto(int cfd) | ||
30 | perror("ioctl(CIOCGSESSINFO)"); | ||
31 | return 1; | ||
32 | } | ||
33 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
34 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
35 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
36 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
37 | #else | ||
38 | plaintext = plaintext_raw; | ||
39 | ciphertext = ciphertext_raw; | ||
40 | @@ -162,7 +163,7 @@ static int test_aes(int cfd) | ||
41 | perror("ioctl(CIOCGSESSINFO)"); | ||
42 | return 1; | ||
43 | } | ||
44 | - plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
45 | + plaintext1 = buf_align(plaintext1_raw, siop1.alignmask); | ||
46 | #else | ||
47 | plaintext1 = plaintext1_raw; | ||
48 | #endif | ||
49 | @@ -185,7 +186,7 @@ static int test_aes(int cfd) | ||
50 | perror("ioctl(CIOCGSESSINFO)"); | ||
51 | return 1; | ||
52 | } | ||
53 | - plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
54 | + plaintext2 = buf_align(plaintext2_raw, siop2.alignmask); | ||
55 | #else | ||
56 | plaintext2 = plaintext2_raw; | ||
57 | #endif | ||
58 | diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c | ||
59 | index c44877d..578d2f7 100644 | ||
60 | --- a/tests/cipher-aead-srtp.c | ||
61 | +++ b/tests/cipher-aead-srtp.c | ||
62 | @@ -12,6 +12,7 @@ | ||
63 | |||
64 | #include <sys/ioctl.h> | ||
65 | #include <crypto/cryptodev.h> | ||
66 | +#include "testhelper.h" | ||
67 | |||
68 | #define DATA_SIZE (8*1024) | ||
69 | #define HEADER_SIZE 193 | ||
70 | @@ -122,8 +123,8 @@ test_crypto(int cfd) | ||
71 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
72 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
73 | |||
74 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
75 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
76 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
77 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
78 | |||
79 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
80 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
81 | @@ -265,8 +266,8 @@ test_encrypt_decrypt(int cfd) | ||
82 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
83 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
84 | |||
85 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
86 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
87 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
88 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
89 | |||
90 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
91 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
92 | @@ -407,8 +408,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
93 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
94 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
95 | |||
96 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
97 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
98 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
99 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
100 | |||
101 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
102 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
103 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
104 | index da43aa6..b329d12 100644 | ||
105 | --- a/tests/cipher-aead.c | ||
106 | +++ b/tests/cipher-aead.c | ||
107 | @@ -12,6 +12,7 @@ | ||
108 | |||
109 | #include <sys/ioctl.h> | ||
110 | #include <crypto/cryptodev.h> | ||
111 | +#include "testhelper.h" | ||
112 | |||
113 | #define DATA_SIZE (8*1024) | ||
114 | #define AUTH_SIZE 31 | ||
115 | @@ -133,8 +134,8 @@ test_crypto(int cfd) | ||
116 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
117 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
118 | |||
119 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
120 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
121 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
122 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
123 | memset(plaintext, 0x15, DATA_SIZE); | ||
124 | |||
125 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
126 | @@ -285,8 +286,8 @@ test_encrypt_decrypt(int cfd) | ||
127 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
128 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
129 | |||
130 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
131 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
132 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
133 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
134 | |||
135 | memset(plaintext, 0x15, DATA_SIZE); | ||
136 | |||
137 | @@ -434,8 +435,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
138 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
139 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
140 | |||
141 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
142 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
143 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
144 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
145 | memset(plaintext, 0x15, DATA_SIZE); | ||
146 | |||
147 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
148 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
149 | index 3f6cc7b..d5f8486 100644 | ||
150 | --- a/tests/cipher-gcm.c | ||
151 | +++ b/tests/cipher-gcm.c | ||
152 | @@ -12,6 +12,7 @@ | ||
153 | |||
154 | #include <sys/ioctl.h> | ||
155 | #include <crypto/cryptodev.h> | ||
156 | +#include "testhelper.h" | ||
157 | |||
158 | #define DATA_SIZE (8*1024) | ||
159 | #define AUTH_SIZE 31 | ||
160 | @@ -232,12 +233,8 @@ static int test_encrypt_decrypt(int cfd) | ||
161 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
162 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
163 | |||
164 | - plaintext = | ||
165 | - (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
166 | - ~siop.alignmask); | ||
167 | - ciphertext = | ||
168 | - (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
169 | - ~siop.alignmask); | ||
170 | + plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
171 | + ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
172 | |||
173 | memset(plaintext, 0x15, DATA_SIZE); | ||
174 | |||
175 | @@ -385,12 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
176 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
177 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
178 | |||
179 | - plaintext = | ||
180 | - (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
181 | - ~siop.alignmask); | ||
182 | - ciphertext = | ||
183 | - (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
184 | - ~siop.alignmask); | ||
185 | + plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
186 | + ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
187 | |||
188 | memset(plaintext, 0x15, DATA_SIZE); | ||
189 | memcpy(ciphertext, plaintext, DATA_SIZE); | ||
190 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
191 | index f3ca2f0..222f095 100644 | ||
192 | --- a/tests/cipher.c | ||
193 | +++ b/tests/cipher.c | ||
194 | @@ -12,6 +12,7 @@ | ||
195 | |||
196 | #include <sys/ioctl.h> | ||
197 | #include <crypto/cryptodev.h> | ||
198 | +#include "testhelper.h" | ||
199 | |||
200 | static int debug = 0; | ||
201 | |||
202 | @@ -58,8 +59,8 @@ test_crypto(int cfd) | ||
203 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
204 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
205 | |||
206 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
207 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
208 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
209 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
210 | #else | ||
211 | plaintext = plaintext_raw; | ||
212 | ciphertext = ciphertext_raw; | ||
213 | @@ -177,7 +178,7 @@ static int test_aes(int cfd) | ||
214 | perror("ioctl(CIOCGSESSINFO)"); | ||
215 | return 1; | ||
216 | } | ||
217 | - plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
218 | + plaintext1 = buf_align(plaintext1_raw, siop.alignmask); | ||
219 | #else | ||
220 | plaintext1 = plaintext1_raw; | ||
221 | #endif | ||
222 | @@ -227,7 +228,7 @@ static int test_aes(int cfd) | ||
223 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
224 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
225 | |||
226 | - plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
227 | + plaintext2 = buf_align(plaintext2_raw, siop.alignmask); | ||
228 | #else | ||
229 | plaintext2 = plaintext2_raw; | ||
230 | #endif | ||
231 | diff --git a/tests/testhelper.h b/tests/testhelper.h | ||
232 | new file mode 100644 | ||
233 | index 0000000..800d10d | ||
234 | --- /dev/null | ||
235 | +++ b/tests/testhelper.h | ||
236 | @@ -0,0 +1,9 @@ | ||
237 | +/* | ||
238 | + * Some helper stuff shared between the sample programs. | ||
239 | + */ | ||
240 | +#ifndef __TESTHELPER_H | ||
241 | +#define __TESTHELPER_H | ||
242 | + | ||
243 | +#define buf_align(buf, align) (void *)(((unsigned long)(buf) + (align)) & ~(align)) | ||
244 | + | ||
245 | +#endif /* __TESTHELPER_H */ | ||
246 | -- | ||
247 | 2.10.2 | ||
248 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch b/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch new file mode 100644 index 00000000..afd97515 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch | |||
@@ -0,0 +1,304 @@ | |||
1 | From 4843f76a74558b85944dbf923cf699bfd5b354eb Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:23 +0200 | ||
4 | Subject: [PATCH 097/104] avoid implicit conversion between signed and unsigned | ||
5 | char | ||
6 | |||
7 | Use uint8_t type for all variables with this problem and avoid casting | ||
8 | from char in assignments. With uint8_t we also convey the information | ||
9 | that we're using small numbers rather than strings. | ||
10 | |||
11 | Although cryptodev.h uses the synonym type __u8, we use uint8_t | ||
12 | for consistency with other files in tests directory and also because it | ||
13 | is a standard POSIX type. | ||
14 | |||
15 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
16 | --- | ||
17 | tests/async_hmac.c | 12 ++++++------ | ||
18 | tests/cipher-aead.c | 10 +++++----- | ||
19 | tests/cipher-gcm.c | 40 ++++++++++++++++++++-------------------- | ||
20 | tests/cipher.c | 1 - | ||
21 | tests/fullspeed.c | 1 + | ||
22 | tests/hmac.c | 12 ++++++------ | ||
23 | 6 files changed, 38 insertions(+), 38 deletions(-) | ||
24 | |||
25 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
26 | index 1bdaad3..014b8ed 100644 | ||
27 | --- a/tests/async_hmac.c | ||
28 | +++ b/tests/async_hmac.c | ||
29 | @@ -61,7 +61,7 @@ test_crypto(int cfd) | ||
30 | |||
31 | cryp.ses = sess.ses; | ||
32 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
33 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
34 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
35 | cryp.mac = mac; | ||
36 | cryp.op = COP_ENCRYPT; | ||
37 | |||
38 | @@ -88,7 +88,7 @@ test_crypto(int cfd) | ||
39 | memset(mac, 0, sizeof(mac)); | ||
40 | |||
41 | sess.cipher = 0; | ||
42 | - sess.mackey = (uint8_t*)"Jefe"; | ||
43 | + sess.mackey = (uint8_t *)"Jefe"; | ||
44 | sess.mackeylen = 4; | ||
45 | sess.mac = CRYPTO_MD5_HMAC; | ||
46 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
47 | @@ -98,7 +98,7 @@ test_crypto(int cfd) | ||
48 | |||
49 | cryp.ses = sess.ses; | ||
50 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
51 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
52 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
53 | cryp.mac = mac; | ||
54 | cryp.op = COP_ENCRYPT; | ||
55 | |||
56 | @@ -127,7 +127,7 @@ test_crypto(int cfd) | ||
57 | sess.keylen = KEY_SIZE; | ||
58 | sess.key = data.key; | ||
59 | sess.mackeylen = 16; | ||
60 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
61 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
62 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
63 | perror("ioctl(CIOCGSESSION)"); | ||
64 | return 1; | ||
65 | @@ -206,7 +206,7 @@ test_extras(int cfd) | ||
66 | |||
67 | cryp.ses = sess.ses; | ||
68 | cryp.len = sizeof("what do")-1; | ||
69 | - cryp.src = (uint8_t*)"what do"; | ||
70 | + cryp.src = (uint8_t *)"what do"; | ||
71 | cryp.mac = mac; | ||
72 | cryp.op = COP_ENCRYPT; | ||
73 | cryp.flags = COP_FLAG_UPDATE; | ||
74 | @@ -216,7 +216,7 @@ test_extras(int cfd) | ||
75 | |||
76 | cryp.ses = sess.ses; | ||
77 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
78 | - cryp.src = (uint8_t*)" ya want for nothing?"; | ||
79 | + cryp.src = (uint8_t *)" ya want for nothing?"; | ||
80 | cryp.mac = mac; | ||
81 | cryp.op = COP_ENCRYPT; | ||
82 | cryp.flags = COP_FLAG_FINAL; | ||
83 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
84 | index b329d12..305b720 100644 | ||
85 | --- a/tests/cipher-aead.c | ||
86 | +++ b/tests/cipher-aead.c | ||
87 | @@ -118,7 +118,7 @@ test_crypto(int cfd) | ||
88 | |||
89 | sess.mac = CRYPTO_SHA1_HMAC; | ||
90 | sess.mackeylen = 16; | ||
91 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
92 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
93 | |||
94 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
95 | perror("ioctl(CIOCGSESSION)"); | ||
96 | @@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd) | ||
97 | |||
98 | sess.mac = CRYPTO_SHA1_HMAC; | ||
99 | sess.mackeylen = 16; | ||
100 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
101 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
102 | |||
103 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
104 | perror("ioctl(CIOCGSESSION)"); | ||
105 | @@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd) | ||
106 | sess.key = key; | ||
107 | sess.mac = CRYPTO_SHA1_HMAC; | ||
108 | sess.mackeylen = 16; | ||
109 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
110 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
111 | |||
112 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
113 | perror("ioctl(CIOCGSESSION)"); | ||
114 | @@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
115 | |||
116 | sess.mac = CRYPTO_SHA1_HMAC; | ||
117 | sess.mackeylen = 16; | ||
118 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
119 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
120 | |||
121 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
122 | perror("ioctl(CIOCGSESSION)"); | ||
123 | @@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
124 | sess.key = key; | ||
125 | sess.mac = CRYPTO_SHA1_HMAC; | ||
126 | sess.mackeylen = 16; | ||
127 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
128 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
129 | |||
130 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
131 | perror("ioctl(CIOCGSESSION)"); | ||
132 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
133 | index d5f8486..36c827a 100644 | ||
134 | --- a/tests/cipher-gcm.c | ||
135 | +++ b/tests/cipher-gcm.c | ||
136 | @@ -46,45 +46,45 @@ struct aes_gcm_vectors_st { | ||
137 | |||
138 | struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
139 | { | ||
140 | - .key = (uint8_t*) | ||
141 | + .key = (uint8_t *) | ||
142 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
143 | .auth = NULL, | ||
144 | .auth_size = 0, | ||
145 | - .plaintext = (uint8_t*) | ||
146 | + .plaintext = (uint8_t *) | ||
147 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
148 | .plaintext_size = 16, | ||
149 | - .ciphertext = (uint8_t*) | ||
150 | + .ciphertext = (uint8_t *) | ||
151 | "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", | ||
152 | - .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
153 | - .tag = (uint8_t*) | ||
154 | + .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
155 | + .tag = (uint8_t *) | ||
156 | "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" | ||
157 | }, | ||
158 | { | ||
159 | - .key = (uint8_t*) | ||
160 | + .key = (uint8_t *) | ||
161 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
162 | .auth = NULL, | ||
163 | .auth_size = 0, | ||
164 | - .plaintext = (uint8_t*) | ||
165 | + .plaintext = (uint8_t *) | ||
166 | "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39\x1a\xaf\xd2\x55", | ||
167 | .plaintext_size = 64, | ||
168 | - .ciphertext = (uint8_t*) | ||
169 | + .ciphertext = (uint8_t *) | ||
170 | "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91\x47\x3f\x59\x85", | ||
171 | - .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
172 | - .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
173 | + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
174 | + .tag = (uint8_t *)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
175 | }, | ||
176 | { | ||
177 | - .key = (uint8_t*) | ||
178 | + .key = (uint8_t *) | ||
179 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
180 | - .auth = (uint8_t*) | ||
181 | + .auth = (uint8_t *) | ||
182 | "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", | ||
183 | .auth_size = 20, | ||
184 | - .plaintext = (uint8_t*) | ||
185 | + .plaintext = (uint8_t *) | ||
186 | "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39", | ||
187 | .plaintext_size = 60, | ||
188 | - .ciphertext = (uint8_t*) | ||
189 | + .ciphertext = (uint8_t *) | ||
190 | "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91", | ||
191 | - .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
192 | - .tag = (uint8_t*) | ||
193 | + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
194 | + .tag = (uint8_t *) | ||
195 | "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" | ||
196 | } | ||
197 | }; | ||
198 | @@ -233,8 +233,8 @@ static int test_encrypt_decrypt(int cfd) | ||
199 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
200 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
201 | |||
202 | - plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
203 | - ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
204 | + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); | ||
205 | + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); | ||
206 | |||
207 | memset(plaintext, 0x15, DATA_SIZE); | ||
208 | |||
209 | @@ -382,8 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
210 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
211 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
212 | |||
213 | - plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
214 | - ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
215 | + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); | ||
216 | + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); | ||
217 | |||
218 | memset(plaintext, 0x15, DATA_SIZE); | ||
219 | memcpy(ciphertext, plaintext, DATA_SIZE); | ||
220 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
221 | index 222f095..fab3de6 100644 | ||
222 | --- a/tests/cipher.c | ||
223 | +++ b/tests/cipher.c | ||
224 | @@ -9,7 +9,6 @@ | ||
225 | #include <unistd.h> | ||
226 | #include <fcntl.h> | ||
227 | #include <stdint.h> | ||
228 | - | ||
229 | #include <sys/ioctl.h> | ||
230 | #include <crypto/cryptodev.h> | ||
231 | #include "testhelper.h" | ||
232 | diff --git a/tests/fullspeed.c b/tests/fullspeed.c | ||
233 | index c025130..ae873e2 100644 | ||
234 | --- a/tests/fullspeed.c | ||
235 | +++ b/tests/fullspeed.c | ||
236 | @@ -24,6 +24,7 @@ | ||
237 | #include <sys/time.h> | ||
238 | #include <sys/types.h> | ||
239 | #include <signal.h> | ||
240 | +#include <stdint.h> | ||
241 | #include <unistd.h> | ||
242 | #include <stdint.h> | ||
243 | |||
244 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
245 | index 3b248f3..8d6492e 100644 | ||
246 | --- a/tests/hmac.c | ||
247 | +++ b/tests/hmac.c | ||
248 | @@ -69,7 +69,7 @@ test_crypto(int cfd) | ||
249 | |||
250 | cryp.ses = sess.ses; | ||
251 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
252 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
253 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
254 | cryp.mac = mac; | ||
255 | cryp.op = COP_ENCRYPT; | ||
256 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
257 | @@ -92,7 +92,7 @@ test_crypto(int cfd) | ||
258 | memset(mac, 0, sizeof(mac)); | ||
259 | |||
260 | sess.cipher = 0; | ||
261 | - sess.mackey = (uint8_t*)"Jefe"; | ||
262 | + sess.mackey = (uint8_t *)"Jefe"; | ||
263 | sess.mackeylen = 4; | ||
264 | sess.mac = CRYPTO_MD5_HMAC; | ||
265 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
266 | @@ -113,7 +113,7 @@ test_crypto(int cfd) | ||
267 | |||
268 | cryp.ses = sess.ses; | ||
269 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
270 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
271 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
272 | cryp.mac = mac; | ||
273 | cryp.op = COP_ENCRYPT; | ||
274 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
275 | @@ -138,7 +138,7 @@ test_crypto(int cfd) | ||
276 | sess.keylen = KEY_SIZE; | ||
277 | sess.key = data.key; | ||
278 | sess.mackeylen = 16; | ||
279 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
280 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
281 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
282 | perror("ioctl(CIOCGSESSION)"); | ||
283 | return 1; | ||
284 | @@ -244,7 +244,7 @@ test_extras(int cfd) | ||
285 | |||
286 | cryp.ses = sess.ses; | ||
287 | cryp.len = sizeof("what do")-1; | ||
288 | - cryp.src = (uint8_t*)"what do"; | ||
289 | + cryp.src = (uint8_t *)"what do"; | ||
290 | cryp.mac = mac; | ||
291 | cryp.op = COP_ENCRYPT; | ||
292 | cryp.flags = COP_FLAG_UPDATE; | ||
293 | @@ -255,7 +255,7 @@ test_extras(int cfd) | ||
294 | |||
295 | cryp.ses = sess.ses; | ||
296 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
297 | - cryp.src = (uint8_t*)" ya want for nothing?"; | ||
298 | + cryp.src = (uint8_t *)" ya want for nothing?"; | ||
299 | cryp.mac = mac; | ||
300 | cryp.op = COP_ENCRYPT; | ||
301 | cryp.flags = COP_FLAG_FINAL; | ||
302 | -- | ||
303 | 2.10.2 | ||
304 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch b/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch new file mode 100644 index 00000000..42b5cbe1 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch | |||
@@ -0,0 +1,25 @@ | |||
1 | From badd002fe5bdcaf7a7d856f174e2abb10b939467 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:24 +0200 | ||
4 | Subject: [PATCH 098/104] reduce tests/Makefile distance with upstream | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index 88f5040..5a09414 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -1,5 +1,5 @@ | ||
16 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror | ||
17 | -CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
18 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 | ||
19 | +CFLAGS += -I.. $(CRYPTODEV_CFLAGS) -Wall -Werror | ||
20 | |||
21 | comp_progs := cipher_comp hash_comp hmac_comp | ||
22 | |||
23 | -- | ||
24 | 2.10.2 | ||
25 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch new file mode 100644 index 00000000..f65979af --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch | |||
@@ -0,0 +1,288 @@ | |||
1 | From d2cb6745bb166818b6bd9e9011990453fedbccef Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 9 Dec 2016 15:25:20 +0200 | ||
4 | Subject: [PATCH 099/104] add support for authenc(hmac(sha1), cbc(aes)) speed | ||
5 | tests | ||
6 | |||
7 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
8 | --- | ||
9 | crypto/cryptodev.h | 1 + | ||
10 | ioctl.c | 5 ++ | ||
11 | tests/speed.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++------ | ||
12 | 3 files changed, 146 insertions(+), 15 deletions(-) | ||
13 | |||
14 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
15 | index 05221a4..05dc57b 100644 | ||
16 | --- a/crypto/cryptodev.h | ||
17 | +++ b/crypto/cryptodev.h | ||
18 | @@ -62,6 +62,7 @@ enum cryptodev_crypto_op_t { | ||
19 | CRYPTO_TLS12_3DES_CBC_HMAC_SHA1, | ||
20 | CRYPTO_TLS12_AES_CBC_HMAC_SHA1, | ||
21 | CRYPTO_TLS12_AES_CBC_HMAC_SHA256, | ||
22 | + CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES, | ||
23 | CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ | ||
24 | }; | ||
25 | |||
26 | diff --git a/ioctl.c b/ioctl.c | ||
27 | index e3b8af1..7288ffc 100644 | ||
28 | --- a/ioctl.c | ||
29 | +++ b/ioctl.c | ||
30 | @@ -222,6 +222,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
31 | stream = 0; | ||
32 | aead = 1; | ||
33 | break; | ||
34 | + case CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES: | ||
35 | + alg_name = "authenc(hmac(sha1),cbc(aes))"; | ||
36 | + stream = 0; | ||
37 | + aead = 1; | ||
38 | + break; | ||
39 | case CRYPTO_NULL: | ||
40 | alg_name = "ecb(cipher_null)"; | ||
41 | stream = 1; | ||
42 | diff --git a/tests/speed.c b/tests/speed.c | ||
43 | index fc38a63..61259b9 100644 | ||
44 | --- a/tests/speed.c | ||
45 | +++ b/tests/speed.c | ||
46 | @@ -33,12 +33,15 @@ | ||
47 | #include <stdint.h> | ||
48 | #include <inttypes.h> | ||
49 | |||
50 | +#define AUTH_SIZE 31 | ||
51 | +#define TAG_LEN 20 | ||
52 | |||
53 | struct test_params { | ||
54 | bool tflag; | ||
55 | bool nflag; | ||
56 | bool mflag; | ||
57 | bool aflag; | ||
58 | + bool authflag; | ||
59 | int tvalue; | ||
60 | int nvalue; | ||
61 | }; | ||
62 | @@ -59,8 +62,9 @@ int run_aes_256_xts(int fdc, struct test_params tp); | ||
63 | int run_crc32c(int fdc, struct test_params tp); | ||
64 | int run_sha1(int fdc, struct test_params tp); | ||
65 | int run_sha256(int fdc, struct test_params tp); | ||
66 | +int run_authenc(int fdc, struct test_params tp); | ||
67 | |||
68 | -#define ALG_COUNT 6 | ||
69 | +#define ALG_COUNT 7 | ||
70 | struct { | ||
71 | char *name; | ||
72 | int (*func)(int, struct test_params); | ||
73 | @@ -71,6 +75,7 @@ struct { | ||
74 | {"crc32c", run_crc32c}, | ||
75 | {"sha1", run_sha1}, | ||
76 | {"sha256", run_sha256}, | ||
77 | + {"authenc", run_authenc}, | ||
78 | }; | ||
79 | |||
80 | static double udifftimeval(struct timeval start, struct timeval end) | ||
81 | @@ -269,7 +274,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
82 | } | ||
83 | memset(buffer, val++, tp.nvalue); | ||
84 | |||
85 | - must_finish = 0; | ||
86 | + must_finish = 1; | ||
87 | alarm(tp.tvalue); | ||
88 | |||
89 | gettimeofday(&start, NULL); | ||
90 | @@ -305,6 +310,84 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | +static int encrypt_auth(int fdc, struct test_params tp, struct session_op *sess) | ||
95 | +{ | ||
96 | + struct crypt_auth_op cao; | ||
97 | + char *buffer, iv[32]; | ||
98 | + uint8_t auth[AUTH_SIZE]; | ||
99 | + static int val = 23; | ||
100 | + struct timeval start, end; | ||
101 | + uint64_t total = 0; | ||
102 | + double secs, ddata, dspeed; | ||
103 | + char metric[16]; | ||
104 | + int alignmask; | ||
105 | + int min_alignmask = sizeof(void*) - 1; | ||
106 | + int alloc_size; | ||
107 | + | ||
108 | + memset(iv, 0x23, 32); | ||
109 | + memset(auth, 0xf1, sizeof(auth)); | ||
110 | + | ||
111 | + if (!tp.mflag) { | ||
112 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
113 | + fflush(stdout); | ||
114 | + } | ||
115 | + | ||
116 | + alloc_size = tp.nvalue + TAG_LEN; | ||
117 | + alignmask = get_alignmask(fdc, sess); | ||
118 | + if (alignmask) { | ||
119 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
120 | + if (posix_memalign((void **)(&buffer), alignmask + 1, alloc_size)) { | ||
121 | + printf("posix_memalign() failed!\n"); | ||
122 | + return 1; | ||
123 | + } | ||
124 | + } else { | ||
125 | + if (!(buffer = malloc(alloc_size))) { | ||
126 | + perror("malloc()"); | ||
127 | + return 1; | ||
128 | + } | ||
129 | + } | ||
130 | + memset(buffer, val++, tp.nvalue); | ||
131 | + | ||
132 | + must_finish = 0; | ||
133 | + alarm(tp.tvalue); | ||
134 | + | ||
135 | + gettimeofday(&start, NULL); | ||
136 | + do { | ||
137 | + memset(&cao, 0, sizeof(cao)); | ||
138 | + cao.ses = sess->ses; | ||
139 | + cao.auth_src = auth; | ||
140 | + cao.auth_len = sizeof(auth); | ||
141 | + cao.len = tp.nvalue; | ||
142 | + cao.iv = (unsigned char *)iv; | ||
143 | + cao.op = COP_ENCRYPT; | ||
144 | + cao.src = (unsigned char *)buffer; | ||
145 | + cao.dst = cao.src; | ||
146 | + cao.tag_len = TAG_LEN; | ||
147 | + cao.flags = COP_FLAG_AEAD_TLS_TYPE; | ||
148 | + | ||
149 | + if (ioctl(fdc, CIOCAUTHCRYPT, &cao)) { | ||
150 | + perror("ioctl(CIOCAUTHCRYPT)"); | ||
151 | + return 1; | ||
152 | + } | ||
153 | + total += cao.len; | ||
154 | + } while(!must_finish); | ||
155 | + gettimeofday(&end, NULL); | ||
156 | + | ||
157 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
158 | + | ||
159 | + if (tp.mflag) { | ||
160 | + value2machine(total, secs, &dspeed); | ||
161 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
162 | + } else { | ||
163 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
164 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
165 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
166 | + } | ||
167 | + | ||
168 | + free(buffer); | ||
169 | + return 0; | ||
170 | +} | ||
171 | + | ||
172 | void usage(char *cmd_name) | ||
173 | { | ||
174 | printf(usage_str, cmd_name); | ||
175 | @@ -326,11 +409,19 @@ int run_test(int id, struct test_params tp) | ||
176 | return -EINVAL; | ||
177 | } | ||
178 | |||
179 | + if (strcmp("authenc", ciphers[id].name) == 0) { | ||
180 | + tp.authflag = true; | ||
181 | + } | ||
182 | + | ||
183 | if (!tp.mflag) { | ||
184 | - char *type; | ||
185 | - type = tp.aflag ? "async" : "sync"; | ||
186 | + if (tp.authflag) { | ||
187 | + fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
188 | + } else { | ||
189 | + char *type; | ||
190 | + type = tp.aflag ? "async" : "sync"; | ||
191 | |||
192 | - fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
193 | + fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
194 | + } | ||
195 | } | ||
196 | err = ciphers[id].func(fdc, tp); | ||
197 | |||
198 | @@ -340,17 +431,30 @@ int run_test(int id, struct test_params tp) | ||
199 | return err; | ||
200 | } | ||
201 | |||
202 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
203 | +static int start_test (int fdc, struct test_params tp, struct session_op *sess) | ||
204 | { | ||
205 | - int i; | ||
206 | int err; | ||
207 | |||
208 | - if (tp.nflag) { | ||
209 | + if (tp.authflag) { | ||
210 | + err = encrypt_auth(fdc, tp, sess); | ||
211 | + } else { | ||
212 | if (tp.aflag) { | ||
213 | - encrypt_async(fdc, tp, sess); | ||
214 | + err = encrypt_async(fdc, tp, sess); | ||
215 | } else { | ||
216 | - encrypt_sync(fdc, tp, sess); | ||
217 | + err = encrypt_sync(fdc, tp, sess); | ||
218 | } | ||
219 | + } | ||
220 | + | ||
221 | + return err; | ||
222 | +} | ||
223 | + | ||
224 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
225 | +{ | ||
226 | + int i; | ||
227 | + int err; | ||
228 | + | ||
229 | + if (tp.nflag) { | ||
230 | + err = start_test(fdc, tp, sess); | ||
231 | } else { | ||
232 | for (i = 256; i <= (64 * 1024); i *= 2) { | ||
233 | if (must_exit) { | ||
234 | @@ -358,11 +462,7 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
235 | } | ||
236 | |||
237 | tp.nvalue = i; | ||
238 | - if (tp.aflag) { | ||
239 | - err = encrypt_async(fdc, tp, sess); | ||
240 | - } else { | ||
241 | - err = encrypt_sync(fdc, tp, sess); | ||
242 | - } | ||
243 | + err = start_test(fdc, tp, sess); | ||
244 | |||
245 | if (err != 0) { | ||
246 | break; | ||
247 | @@ -474,6 +574,30 @@ int run_sha256(int fdc, struct test_params tp) | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | +int run_authenc(int fdc, struct test_params tp) | ||
252 | +{ | ||
253 | + struct session_op sess; | ||
254 | + char *mkeybuf = "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
255 | + "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
256 | + "\x00\x00\x00\x00"; | ||
257 | + char *ckeybuf = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" | ||
258 | + "\x51\x2e\x03\xd5\x34\x12\x00\x06"; | ||
259 | + | ||
260 | + memset(&sess, 0, sizeof(sess)); | ||
261 | + sess.cipher = CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES; | ||
262 | + sess.keylen = 16; | ||
263 | + sess.key = (unsigned char *)ckeybuf; | ||
264 | + sess.mackeylen = 20; | ||
265 | + sess.mackey = (unsigned char *)mkeybuf; | ||
266 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
267 | + perror("ioctl(CIOCGSESSION)"); | ||
268 | + return -EINVAL; | ||
269 | + } | ||
270 | + | ||
271 | + do_test_vectors(fdc, tp, &sess); | ||
272 | + return 0; | ||
273 | +} | ||
274 | + | ||
275 | int main(int argc, char **argv) | ||
276 | { | ||
277 | int err = 0; | ||
278 | @@ -487,6 +611,7 @@ int main(int argc, char **argv) | ||
279 | tp.nflag = false; | ||
280 | tp.mflag = false; | ||
281 | tp.aflag = false; | ||
282 | + tp.authflag = false; | ||
283 | alg_flag = false; | ||
284 | opterr = 0; | ||
285 | while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { | ||
286 | -- | ||
287 | 2.10.2 | ||
288 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch b/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch new file mode 100644 index 00000000..a108b9d0 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch | |||
@@ -0,0 +1,108 @@ | |||
1 | From 3ca93181fbcaa0acac01588738eb50270cf4999a Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 9 Dec 2016 16:05:56 +0200 | ||
4 | Subject: [PATCH 100/104] close the session after every test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 42 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 61259b9..99ef75b 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -488,6 +488,12 @@ int run_null(int fdc, struct test_params tp) | ||
16 | } | ||
17 | |||
18 | do_test_vectors(fdc, tp, &sess); | ||
19 | + | ||
20 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
21 | + perror("ioctl(CIOCFSESSION)"); | ||
22 | + return -EINVAL; | ||
23 | + } | ||
24 | + | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | @@ -507,6 +513,12 @@ int run_aes_128_cbc(int fdc, struct test_params tp) | ||
29 | } | ||
30 | |||
31 | do_test_vectors(fdc, tp, &sess); | ||
32 | + | ||
33 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
34 | + perror("ioctl(CIOCFSESSION)"); | ||
35 | + return -EINVAL; | ||
36 | + } | ||
37 | + | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | @@ -526,6 +538,12 @@ int run_aes_256_xts(int fdc, struct test_params tp) | ||
42 | } | ||
43 | |||
44 | do_test_vectors(fdc, tp, &sess); | ||
45 | + | ||
46 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
47 | + perror("ioctl(CIOCFSESSION)"); | ||
48 | + return -EINVAL; | ||
49 | + } | ||
50 | + | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | @@ -541,6 +559,12 @@ int run_crc32c(int fdc, struct test_params tp) | ||
55 | } | ||
56 | |||
57 | do_test_vectors(fdc, tp, &sess); | ||
58 | + | ||
59 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
60 | + perror("ioctl(CIOCFSESSION)"); | ||
61 | + return -EINVAL; | ||
62 | + } | ||
63 | + | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | @@ -556,6 +580,12 @@ int run_sha1(int fdc, struct test_params tp) | ||
68 | } | ||
69 | |||
70 | do_test_vectors(fdc, tp, &sess); | ||
71 | + | ||
72 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
73 | + perror("ioctl(CIOCFSESSION)"); | ||
74 | + return -EINVAL; | ||
75 | + } | ||
76 | + | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | @@ -571,6 +601,12 @@ int run_sha256(int fdc, struct test_params tp) | ||
81 | } | ||
82 | |||
83 | do_test_vectors(fdc, tp, &sess); | ||
84 | + | ||
85 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
86 | + perror("ioctl(CIOCFSESSION)"); | ||
87 | + return -EINVAL; | ||
88 | + } | ||
89 | + | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | @@ -595,6 +631,12 @@ int run_authenc(int fdc, struct test_params tp) | ||
94 | } | ||
95 | |||
96 | do_test_vectors(fdc, tp, &sess); | ||
97 | + | ||
98 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
99 | + perror("ioctl(CIOCFSESSION)"); | ||
100 | + return -EINVAL; | ||
101 | + } | ||
102 | + | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | -- | ||
107 | 2.10.2 | ||
108 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch new file mode 100644 index 00000000..a70f3685 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch | |||
@@ -0,0 +1,179 @@ | |||
1 | From d67b28fb68f1ea56fdf794f516816b6c3ef5649a Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <radu.alexe@nxp.com> | ||
3 | Date: Thu, 12 Jan 2017 19:44:57 +0200 | ||
4 | Subject: [PATCH 101/104] add support for rsa speed tests | ||
5 | |||
6 | Tests are only for rsa 1024 and 2048 and only sync variant. | ||
7 | |||
8 | Signed-off-by: Radu Alexe <radu.alexe@nxp.com> | ||
9 | --- | ||
10 | tests/speed.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- | ||
11 | 1 file changed, 137 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tests/speed.c b/tests/speed.c | ||
14 | index 99ef75b..b52938c 100644 | ||
15 | --- a/tests/speed.c | ||
16 | +++ b/tests/speed.c | ||
17 | @@ -63,8 +63,9 @@ int run_crc32c(int fdc, struct test_params tp); | ||
18 | int run_sha1(int fdc, struct test_params tp); | ||
19 | int run_sha256(int fdc, struct test_params tp); | ||
20 | int run_authenc(int fdc, struct test_params tp); | ||
21 | +int run_rsa(int fdc, struct test_params tp); | ||
22 | |||
23 | -#define ALG_COUNT 7 | ||
24 | +#define ALG_COUNT 8 | ||
25 | struct { | ||
26 | char *name; | ||
27 | int (*func)(int, struct test_params); | ||
28 | @@ -76,6 +77,7 @@ struct { | ||
29 | {"sha1", run_sha1}, | ||
30 | {"sha256", run_sha256}, | ||
31 | {"authenc", run_authenc}, | ||
32 | + {"rsa", run_rsa}, | ||
33 | }; | ||
34 | |||
35 | static double udifftimeval(struct timeval start, struct timeval end) | ||
36 | @@ -640,6 +642,140 @@ int run_authenc(int fdc, struct test_params tp) | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | +char *n_2048 = "\xFA\xBE\x23\x01\x5D\x11\x50\xAA\xAB\xED\x50\xA7\x9B\x93\x7B\xCE" | ||
41 | + "\x1E\x11\xAE\xC1\x05\xAF\xBA\x57\x18\x6B\xE3\x27\x85\x3A\xFA\xB9" | ||
42 | + "\x15\x5A\x39\xB2\x38\x60\xB8\x5B\xDF\xD0\x8F\xA3\x37\xEE\xE5\xFD" | ||
43 | + "\xE2\x98\xF9\x40\xD2\x0A\xE9\x15\x69\x8A\x9D\xBC\x1F\x00\x0B\x95" | ||
44 | + "\x5A\x19\x14\x4C\x14\x19\x38\x47\x30\x96\x17\xCB\x28\x1C\x1C\x09" | ||
45 | + "\x14\x79\x55\x26\xAF\x6E\x38\x41\x91\x9D\xF5\x31\x6C\xFB\xCC\x68" | ||
46 | + "\x08\xA2\x60\xA2\xA4\xE0\x68\x59\x24\xF5\xEB\x57\x88\x5C\x3D\xA3" | ||
47 | + "\x41\x95\xFF\xD1\x03\xBA\xAE\x18\x55\x5D\xF4\x93\x57\x4D\x02\x11" | ||
48 | + "\x66\xD8\x44\xF8\x63\x9D\x70\xBE\x98\x93\x43\xE0\x1F\x80\x7A\xE1" | ||
49 | + "\x6D\xA0\x5D\xC3\xE5\x56\x1C\xDA\x96\x16\xB1\xD8\xBD\x62\x1E\x51" | ||
50 | + "\x28\xF7\x06\xB7\x6D\xB0\x5A\x5F\x09\x28\xEF\x9B\x33\xA3\x04\x02" | ||
51 | + "\x08\x4D\xD7\x2C\x22\x77\x3D\x9B\x2E\x45\xE7\x78\x5C\x64\x50\xF3" | ||
52 | + "\x5B\x98\x6E\x0F\xDE\xA6\xDC\x19\x4D\xFF\xAB\xBE\x6D\xC7\xB1\x55" | ||
53 | + "\x36\xDD\x40\x07\xEF\x78\xCC\xA1\x8D\x96\x6B\xDA\x48\x4C\x40\x29" | ||
54 | + "\x46\x7C\xF0\x1A\x6B\xC5\xBB\x8B\xD1\xB0\x6F\x9B\xB7\xC0\x06\xF5" | ||
55 | + "\x3B\x6F\x2B\x45\xEA\x17\x4C\x16\x2A\xC5\x5E\xB6\x1C\xCB\x3B\xFB"; | ||
56 | + | ||
57 | +char *f_2048 = "\x69\xeb\xb3\xb3\x68\xc1\xbf\x17\x57\x63\xca\xa2\x21\xee\x1f\x56" | ||
58 | + "\x8c\xee\x58\x96\x86\x86\x95\x44\xc7\xff\x75\xeb\xb4\xe8\xf6\x55" | ||
59 | + "\x20\xa0\xad\x62\x50\xe4\x83\x07\x31\xe9\x41\x03\xf3\x69\x9b\x9b" | ||
60 | + "\x0d\x68\xf3\x6e\x21\x02\x79\xc5\xa4\xd1\xe5\x11\x56\x9a\x2c\xb8" | ||
61 | + "\xf5\x76\xab\x04\x03\xcc\x6d\xa3\xf1\xa3\x6a\x57\xfd\x6e\x87\x82" | ||
62 | + "\xcf\x19\xf8\x0f\x97\x4d\x6e\xb5\xa0\x10\x27\x40\x12\x8b\x9f\x24" | ||
63 | + "\xb4\x4a\x95\xbe\x6a\x49\x49\x67\xb0\x8f\x77\x5f\x1d\x56\x22\xc6" | ||
64 | + "\x7d\xb3\x2f\x9e\x62\x4a\x0b\xf2\xca\x9e\xd1\x57\xf8\xf4\x25\x36" | ||
65 | + "\x54\xe9\x4a\xcd\x4d\x9b\x14\xd5\xe5\x35\x59\x6b\xf5\xd0\x50\x69" | ||
66 | + "\x5c\xde\x21\x32\xc9\x31\x8f\x21\x66\xda\x32\xb8\x45\x18\x18\x57" | ||
67 | + "\xb0\x37\xff\xea\xee\x7a\xd5\x01\x36\x72\xb3\xfb\x23\xe2\x5c\xa2" | ||
68 | + "\x10\xb9\xf3\x8b\xda\x37\x46\x7e\xac\xf5\x6c\xae\x18\x69\xbc\x9d" | ||
69 | + "\x6e\xd7\x61\x7c\x85\x63\x41\x5e\x8b\xab\x12\xbe\x37\x1a\x67\xdd" | ||
70 | + "\x86\xf2\xf9\xc8\x3a\xd7\xcd\x92\x72\xaf\xad\x46\xb0\x5b\x33\xd9" | ||
71 | + "\x1c\x32\x02\x3c\xae\xe0\x5d\x87\xde\x95\x59\x10\x4e\xa7\xdf\x7f" | ||
72 | + "\x94\x2d\xea\x9b\x7a\x53\x54\xc7\xf9\x66\xd1\x14\x0b\xd7\xef\x00"; | ||
73 | + | ||
74 | +char *n_1024 = "\xF8\x99\x5E\xC7\xED\x60\x4B\xBA\x77\x0A\x52\xD0\xFF\xE6\x45\x47" | ||
75 | + "\x04\xDE\xB3\x40\x16\x23\xB4\x58\x0A\xFF\xAF\x0D\x26\x1B\x5E\x0D" | ||
76 | + "\x61\xA2\x4A\x7B\x2E\x70\x2A\x54\x21\xCB\x01\x31\xBC\xBE\xAE\xC9" | ||
77 | + "\x5B\x3B\x20\x0B\x95\x06\x41\x03\xDB\xEF\x81\xE2\xFB\x42\xE8\x02" | ||
78 | + "\x1D\xD2\xA7\xFD\xC3\xA0\x3F\x74\x6D\x99\x8D\x60\xBA\x43\x82\x6C" | ||
79 | + "\x96\x24\x1D\xE5\xE3\x2C\xB7\x66\xAB\x2B\x4C\xFD\x23\xFF\xE0\x09" | ||
80 | + "\x17\x3E\x01\xCB\xDC\xB2\xD2\xA9\x98\x99\x01\x91\x16\xAB\x77\xD7" | ||
81 | + "\x97\x52\xBD\x49\xB2\xAF\x61\x95\xE8\xA2\x34\x9C\xC4\x00\xCC\x17"; | ||
82 | + | ||
83 | +char *f_1024 = "\x8f\x2d\x06\x83\xee\x08\x97\xa4\x86\x3a\xf2\xa3\xd1\x6d\x33\x10" | ||
84 | + "\x49\x1d\xb6\xd0\xe3\x7b\x16\x5a\x1a\x5c\x98\x36\xab\xd2\xa9\x82" | ||
85 | + "\x5c\x1b\xc1\x9e\xdc\x50\x45\x05\xe0\x2e\x14\x83\x86\x47\x21\xc5" | ||
86 | + "\x27\xad\xb1\x74\x5d\x7b\xe2\x92\xfc\x15\xf0\x14\x6c\x8d\x80\xe5" | ||
87 | + "\x85\x72\x26\xc7\xa3\xd8\xc7\x5a\x10\xcd\x64\xde\x5d\x82\xc1\x53" | ||
88 | + "\xd7\x2e\x03\xe0\xe2\xe6\xc6\x85\xcc\x07\x25\xa9\x61\xf7\x52\x3f" | ||
89 | + "\x63\xb1\x54\x6e\x23\xbe\xf0\x6c\xa4\x93\x8c\x39\xe2\xdb\xcb\x1c" | ||
90 | + "\x4b\x95\x3d\x57\x06\xc9\xce\x44\xe5\xaf\xac\x6b\x67\xdb\x92\x00"; | ||
91 | + | ||
92 | +int run_rsa(int fdc, struct test_params tp) | ||
93 | +{ | ||
94 | + struct timeval start, end; | ||
95 | + double secs, ddata, dspeed; | ||
96 | + uint64_t total = 0; | ||
97 | + char metric[16]; | ||
98 | + struct crypt_kop kop; | ||
99 | + char *n, *f; | ||
100 | + char *e = "\x01\x00\x01"; | ||
101 | + char g[256]; | ||
102 | + | ||
103 | + if (!tp.nflag) | ||
104 | + tp.nvalue = 2048; | ||
105 | + | ||
106 | + switch (tp.nvalue) { | ||
107 | + case 2048: | ||
108 | + n = n_2048; | ||
109 | + f = f_2048; | ||
110 | + break; | ||
111 | + | ||
112 | + case 1024: | ||
113 | + n = n_1024; | ||
114 | + f = f_1024; | ||
115 | + break; | ||
116 | + | ||
117 | + default: | ||
118 | + if (!tp.mflag) { | ||
119 | + printf("Error: rsa-%d not supported\n", tp.nvalue); | ||
120 | + fflush(stdout); | ||
121 | + } | ||
122 | + | ||
123 | + return 1; | ||
124 | + } | ||
125 | + | ||
126 | + kop.crk_op = CRK_MOD_EXP; | ||
127 | + kop.crk_iparams = 3; | ||
128 | + kop.crk_oparams = 1; | ||
129 | + | ||
130 | + kop.crk_param[0].crp_p = (__u8*)f; | ||
131 | + kop.crk_param[0].crp_nbits = tp.nvalue; | ||
132 | + | ||
133 | + kop.crk_param[1].crp_p = (__u8*)e; | ||
134 | + kop.crk_param[1].crp_nbits = 24; | ||
135 | + | ||
136 | + kop.crk_param[2].crp_p = (__u8*)n; | ||
137 | + kop.crk_param[2].crp_nbits = tp.nvalue; | ||
138 | + | ||
139 | + kop.crk_param[3].crp_p = (__u8*)g; | ||
140 | + kop.crk_param[3].crp_nbits = sizeof(g) << 3; | ||
141 | + | ||
142 | + if (!tp.mflag) { | ||
143 | + printf("\trsa %d: ", tp.nvalue); | ||
144 | + fflush(stdout); | ||
145 | + } | ||
146 | + | ||
147 | + must_finish = 0; | ||
148 | + alarm(tp.tvalue); | ||
149 | + | ||
150 | + gettimeofday(&start, NULL); | ||
151 | + do { | ||
152 | + if (ioctl(fdc, CIOCKEY, &kop)) { | ||
153 | + perror("ioctl(CIOCKEY)"); | ||
154 | + return -EINVAL; | ||
155 | + } | ||
156 | + total += (tp.nvalue >> 3); | ||
157 | + } while (!must_finish); | ||
158 | + gettimeofday(&end, NULL); | ||
159 | + | ||
160 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
161 | + | ||
162 | + if (tp.mflag) { | ||
163 | + value2machine(total, secs, &dspeed); | ||
164 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
165 | + } else { | ||
166 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
167 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
168 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
169 | + } | ||
170 | + | ||
171 | + return 0; | ||
172 | +} | ||
173 | + | ||
174 | int main(int argc, char **argv) | ||
175 | { | ||
176 | int err = 0; | ||
177 | -- | ||
178 | 2.10.2 | ||
179 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch b/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch new file mode 100644 index 00000000..5ffc4508 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | From 008516c6a1dd0afe0eadff3ad00c1200c198983f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 8 Feb 2017 10:19:34 +0200 | ||
4 | Subject: [PATCH 102/104] adjust to API changes in kernel >=4.10 | ||
5 | |||
6 | There are many changes related to get_user_pages and the code is rewritten | ||
7 | for clarity. | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | zc.c | 28 +++++++++++++++++----------- | ||
12 | 1 file changed, 17 insertions(+), 11 deletions(-) | ||
13 | |||
14 | diff --git a/zc.c b/zc.c | ||
15 | index e766ee3..2f4ea99 100644 | ||
16 | --- a/zc.c | ||
17 | +++ b/zc.c | ||
18 | @@ -59,19 +59,25 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
19 | } | ||
20 | |||
21 | down_read(&mm->mmap_sem); | ||
22 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) | ||
23 | - ret = get_user_pages_remote( | ||
24 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) | ||
25 | + ret = get_user_pages(task, mm, | ||
26 | + (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
27 | #else | ||
28 | - ret = get_user_pages( | ||
29 | -#endif | ||
30 | - task, mm, | ||
31 | - (unsigned long)addr, pgcount, | ||
32 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) | ||
33 | - write ? FOLL_WRITE : 0, | ||
34 | -#else | ||
35 | - write, 0, | ||
36 | -#endif | ||
37 | +# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
38 | + ret = get_user_pages_remote(task, mm, | ||
39 | + (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
40 | +# else | ||
41 | +# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
42 | + ret = get_user_pages_remote(task, mm, | ||
43 | + (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
44 | pg, NULL); | ||
45 | +# else | ||
46 | + ret = get_user_pages_remote(task, mm, | ||
47 | + (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
48 | + pg, NULL, NULL); | ||
49 | +# endif | ||
50 | +# endif | ||
51 | +#endif | ||
52 | up_read(&mm->mmap_sem); | ||
53 | if (ret != pgcount) | ||
54 | return -EINVAL; | ||
55 | -- | ||
56 | 2.10.2 | ||
57 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch b/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch new file mode 100644 index 00000000..5c121077 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | From e2fa367d968926500584912e98cf7b17bd9487a6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Phil Sutter <phil@nwl.cc> | ||
3 | Date: Thu, 9 Feb 2017 11:40:46 +0100 | ||
4 | Subject: [PATCH 103/104] zc: Use the power of #elif | ||
5 | |||
6 | While here, get rid of that trailing newline as well. | ||
7 | |||
8 | Fixes: 2b29be8ac4141 ("adjust to API changes in kernel >=4.10") | ||
9 | Suggested-by: Frediano Ziglio <freddy77@gmail.com> | ||
10 | Signed-off-by: Phil Sutter <phil@nwl.cc> | ||
11 | --- | ||
12 | zc.c | 11 +++-------- | ||
13 | 1 file changed, 3 insertions(+), 8 deletions(-) | ||
14 | |||
15 | diff --git a/zc.c b/zc.c | ||
16 | index 2f4ea99..ae464ff 100644 | ||
17 | --- a/zc.c | ||
18 | +++ b/zc.c | ||
19 | @@ -62,21 +62,17 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
20 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) | ||
21 | ret = get_user_pages(task, mm, | ||
22 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
23 | -#else | ||
24 | -# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
25 | +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
26 | ret = get_user_pages_remote(task, mm, | ||
27 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
28 | -# else | ||
29 | -# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
30 | +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
31 | ret = get_user_pages_remote(task, mm, | ||
32 | (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
33 | pg, NULL); | ||
34 | -# else | ||
35 | +#else | ||
36 | ret = get_user_pages_remote(task, mm, | ||
37 | (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
38 | pg, NULL, NULL); | ||
39 | -# endif | ||
40 | -# endif | ||
41 | #endif | ||
42 | up_read(&mm->mmap_sem); | ||
43 | if (ret != pgcount) | ||
44 | @@ -222,4 +218,3 @@ int get_userbuf(struct csession *ses, | ||
45 | } | ||
46 | return 0; | ||
47 | } | ||
48 | - | ||
49 | -- | ||
50 | 2.10.2 | ||
51 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch b/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch new file mode 100644 index 00000000..1038bed2 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From a4b33ea30c86fb727c1d3ac3531c5548b6c194ba Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <radu.alexe@nxp.com> | ||
3 | Date: Tue, 14 Feb 2017 12:52:33 +0200 | ||
4 | Subject: [PATCH 104/104] fix: reset finish condition before test start | ||
5 | |||
6 | Typo from previous commit: ba494703 | ||
7 | "add support for authenc(hmac(sha1), cbc(aes)) speed tests" | ||
8 | |||
9 | Signed-off-by: Radu Alexe <radu.alexe@nxp.com> | ||
10 | --- | ||
11 | tests/speed.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/speed.c b/tests/speed.c | ||
15 | index b52938c..ae0b658 100644 | ||
16 | --- a/tests/speed.c | ||
17 | +++ b/tests/speed.c | ||
18 | @@ -276,7 +276,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
19 | } | ||
20 | memset(buffer, val++, tp.nvalue); | ||
21 | |||
22 | - must_finish = 1; | ||
23 | + must_finish = 0; | ||
24 | alarm(tp.tvalue); | ||
25 | |||
26 | gettimeofday(&start, NULL); | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
diff --git a/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch b/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch new file mode 100644 index 00000000..f2cd9065 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch | |||
@@ -0,0 +1,77 @@ | |||
1 | From 6c2b61c17681d0e6ddc44b0438c9712fb2810ba6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 28 Mar 2017 13:16:14 +0300 | ||
4 | Subject: [PATCH] update copyright notes | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/run_crypto_tests.sh | 16 ++++++++++++++++ | ||
9 | tests/sha_speed.c | 1 + | ||
10 | tests/speed.c | 1 + | ||
11 | zc.c | 1 + | ||
12 | 4 files changed, 19 insertions(+) | ||
13 | |||
14 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
15 | index 321b013..225ad7a 100644 | ||
16 | --- a/tests/run_crypto_tests.sh | ||
17 | +++ b/tests/run_crypto_tests.sh | ||
18 | @@ -1,4 +1,20 @@ | ||
19 | #!/bin/bash | ||
20 | +# | ||
21 | +# Copyright 2016 NXP Semiconductors | ||
22 | +# | ||
23 | +# This program is free software: you can redistribute it and/or modify | ||
24 | +# it under the terms of the GNU General Public License as published by | ||
25 | +# the Free Software Foundation, either version 2 of the License, or | ||
26 | +# (at your option) any later version. | ||
27 | +# | ||
28 | +# This program is distributed in the hope that it will be useful, | ||
29 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | +# GNU General Public License for more details. | ||
32 | +# | ||
33 | +# You should have received a copy of the GNU General Public License | ||
34 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
35 | + | ||
36 | |||
37 | |||
38 | BUF_SIZE="8192 16384 65536 131072 262144" | ||
39 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
40 | index 30b40f5..e6a2ac5 100644 | ||
41 | --- a/tests/sha_speed.c | ||
42 | +++ b/tests/sha_speed.c | ||
43 | @@ -1,6 +1,7 @@ | ||
44 | /* sha_speed - simple SHA benchmark tool for cryptodev | ||
45 | * | ||
46 | * Copyright (C) 2011 by Phil Sutter <phil.sutter@viprinet.com> | ||
47 | + * Copyright 2016 NXP | ||
48 | * | ||
49 | * This program is free software; you can redistribute it and/or modify | ||
50 | * it under the terms of the GNU General Public License as published by | ||
51 | diff --git a/tests/speed.c b/tests/speed.c | ||
52 | index ae0b658..6e18960 100644 | ||
53 | --- a/tests/speed.c | ||
54 | +++ b/tests/speed.c | ||
55 | @@ -1,6 +1,7 @@ | ||
56 | /* cryptodev_test - simple benchmark tool for cryptodev | ||
57 | * | ||
58 | * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
59 | + * Copyright 2016-2017 NXP | ||
60 | * | ||
61 | * This program is free software; you can redistribute it and/or modify | ||
62 | * it under the terms of the GNU General Public License as published by | ||
63 | diff --git a/zc.c b/zc.c | ||
64 | index ae464ff..63e7c23 100644 | ||
65 | --- a/zc.c | ||
66 | +++ b/zc.c | ||
67 | @@ -4,6 +4,7 @@ | ||
68 | * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
69 | * Copyright (c) 2010 Phil Sutter | ||
70 | * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. | ||
71 | + * Copyright 2017 NXP | ||
72 | * | ||
73 | * This file is part of linux cryptodev. | ||
74 | * | ||
75 | -- | ||
76 | 1.9.2 | ||
77 | |||
diff --git a/recipes-kernel/cryptodev/yocto_patches/0001-Disable-installing-header-file-provided-by-another-p.patch b/recipes-kernel/cryptodev/yocto_patches/0001-Disable-installing-header-file-provided-by-another-p.patch index 6d8db4ed..35aad600 100644 --- a/recipes-kernel/cryptodev/yocto_patches/0001-Disable-installing-header-file-provided-by-another-p.patch +++ b/recipes-kernel/cryptodev/yocto_patches/0001-Disable-installing-header-file-provided-by-another-p.patch | |||
@@ -8,22 +8,15 @@ Subject: [PATCH 1/2] Disable installing header file provided by another | |||
8 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | 8 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> |
9 | 9 | ||
10 | Upstream-Status: Inappropriate [ OE specific ] | 10 | Upstream-Status: Inappropriate [ OE specific ] |
11 | --- | ||
12 | Makefile | 1 - | ||
13 | 1 file changed, 1 deletion(-) | ||
14 | 11 | ||
15 | diff --git a/Makefile b/Makefile | 12 | |
16 | index 9871a8e..06202bd 100644 | 13 | --- a/Makefileold 2017-04-18 14:54:40.588438842 +0800 |
17 | --- a/Makefile | 14 | +++ b/Makefile 2017-04-18 14:55:40.308436774 +0800 |
18 | +++ b/Makefile | 15 | @@ -33,7 +33,6 @@ |
19 | @@ -33,7 +33,6 @@ install: modules_install | ||
20 | 16 | ||
21 | modules_install: | 17 | modules_install: |
22 | $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install | 18 | $(MAKE) $(KERNEL_MAKE_OPTS) modules_install |
23 | - install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h | 19 | - install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h |
24 | 20 | ||
25 | clean: | 21 | clean: |
26 | $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean | 22 | $(MAKE) $(KERNEL_MAKE_OPTS) clean |
27 | -- | ||
28 | 2.7.0 | ||
29 | |||
diff --git a/recipes-kernel/cryptodev/yocto_patches/0003-update-the-install-path-for-cryptodev-tests.patch b/recipes-kernel/cryptodev/yocto_patches/0003-update-the-install-path-for-cryptodev-tests.patch new file mode 100644 index 00000000..4f92dbab --- /dev/null +++ b/recipes-kernel/cryptodev/yocto_patches/0003-update-the-install-path-for-cryptodev-tests.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From 5b0d2cf5abaaa3bffb4a9e874dba88bdab15b69d Mon Sep 17 00:00:00 2001 | ||
2 | From: Ting Liu <ting.liu@nxp.com> | ||
3 | Date: Mon, 20 Feb 2017 22:43:00 +0800 | ||
4 | Subject: [PATCH] update the install path for cryptodev tests | ||
5 | |||
6 | Signed-off-by: Ting Liu <ting.liu@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index dd7d5ff..e1c5039 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -37,8 +37,8 @@ install: | ||
16 | for prog in $(hostprogs); do \ | ||
17 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
18 | done | ||
19 | - install -m 755 speed_multi.sh $(DESTDIR)/$(bindir) | ||
20 | - install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) | ||
21 | + install -m 755 speed_multi.sh $(DESTDIR)/$(bindir)/tests_cryptodev/ | ||
22 | + install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir)/tests_cryptodev/ | ||
23 | |||
24 | clean: | ||
25 | rm -f *.o *~ $(hostprogs) | ||
26 | -- | ||
27 | 1.9.2 | ||
28 | |||