summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch
diff options
context:
space:
mode:
authorChunrong Guo <chunrong.guo@nxp.com>2017-04-18 15:11:50 +0800
committerOtavio Salvador <otavio@ossystems.com.br>2017-05-02 17:54:58 -0300
commite756964ac2595d880304f227dec7bdb424d7d974 (patch)
tree28c067a5652216278a92e39144d48ac95f0e8f12 /recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch
parentcfb3ddaaaa78204ef5281c8627eed08f4f7e3f09 (diff)
downloadmeta-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/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch')
-rw-r--r--recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch439
1 files changed, 439 insertions, 0 deletions
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 @@
1From 13cb1f2dcf8865b076a7e8290d8f864d91a2d7c7 Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@nxp.com>
3Date: Mon, 24 Oct 2016 16:33:55 +0300
4Subject: [PATCH 050/104] add basic optargs support for async_speed test
5
6Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
7---
8 tests/async_speed.c | 302 +++++++++++++++++++++++++++++++++++-----------------
9 1 file changed, 202 insertions(+), 100 deletions(-)
10
11diff --git a/tests/async_speed.c b/tests/async_speed.c
12index 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--
4382.10.2
439