aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/cmd
diff options
context:
space:
mode:
authorTino Reichardt <[email protected]>2023-03-01 09:40:28 +0100
committerBrian Behlendorf <[email protected]>2023-03-02 13:52:21 -0800
commit4c5fec01a48acc184614ab8735e6954961990235 (patch)
tree9977aaac33b46c9b998255d54695ec4f7840a3e2 /tests/zfs-tests/cmd
parentac678c8eee3384b54c364d54b323265037f408c0 (diff)
Add generic implementation handling and SHA2 impl
The skeleton file module/icp/include/generic_impl.c can be used for iterating over different implementations of algorithms. It is used by SHA256, SHA512 and BLAKE3 currently. The Solaris SHA2 implementation got replaced with a version which is based on public domain code of cppcrypto v0.10. These assembly files are taken from current openssl master: - sha256-x86_64.S: x64, SSSE3, AVX, AVX2, SHA-NI (x86_64) - sha512-x86_64.S: x64, AVX, AVX2 (x86_64) - sha256-armv7.S: ARMv7, NEON, ARMv8-CE (arm) - sha512-armv7.S: ARMv7, NEON (arm) - sha256-armv8.S: ARMv7, NEON, ARMv8-CE (aarch64) - sha512-armv8.S: ARMv7, ARMv8-CE (aarch64) - sha256-ppc.S: Generic PPC64 LE/BE (ppc64) - sha512-ppc.S: Generic PPC64 LE/BE (ppc64) - sha256-p8.S: Power8 ISA Version 2.07 LE/BE (ppc64) - sha512-p8.S: Power8 ISA Version 2.07 LE/BE (ppc64) Tested-by: Rich Ercolani <[email protected]> Tested-by: Sebastian Gottschall <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tino Reichardt <[email protected]> Closes #13741
Diffstat (limited to 'tests/zfs-tests/cmd')
-rw-r--r--tests/zfs-tests/cmd/checksum/sha2_test.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/tests/zfs-tests/cmd/checksum/sha2_test.c b/tests/zfs-tests/cmd/checksum/sha2_test.c
index d99e8757a..efcf812d7 100644
--- a/tests/zfs-tests/cmd/checksum/sha2_test.c
+++ b/tests/zfs-tests/cmd/checksum/sha2_test.c
@@ -33,11 +33,11 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+
#include <sys/time.h>
-#define _SHA2_IMPL
#include <sys/sha2.h>
#include <sys/stdtypes.h>
-
+#include <sys/zfs_impl.h>
/*
* Test messages from:
@@ -174,9 +174,19 @@ main(int argc, char *argv[])
boolean_t failed = B_FALSE;
uint64_t cpu_mhz = 0;
+ const zfs_impl_t *sha256 = zfs_impl_get_ops("sha256");
+ const zfs_impl_t *sha512 = zfs_impl_get_ops("sha512");
+ uint32_t id;
+
if (argc == 2)
cpu_mhz = atoi(argv[1]);
+ if (!sha256)
+ return (1);
+
+ if (!sha512)
+ return (1);
+
#define SHA2_ALGO_TEST(_m, mode, diglen, testdigest) \
do { \
SHA2_CTX ctx; \
@@ -194,7 +204,7 @@ main(int argc, char *argv[])
} \
} while (0)
-#define SHA2_PERF_TEST(mode, diglen) \
+#define SHA2_PERF_TEST(mode, diglen, name) \
do { \
SHA2_CTX ctx; \
uint8_t digest[diglen / 8]; \
@@ -216,8 +226,8 @@ main(int argc, char *argv[])
cpb = (cpu_mhz * 1e6 * ((double)delta / \
1000000)) / (8192 * 128 * 1024); \
} \
- (void) printf("SHA%-9s%llu us (%.02f CPB)\n", #mode, \
- (u_longlong_t)delta, cpb); \
+ (void) printf("sha%s-%-9s%7llu us (%.02f CPB)\n", #mode,\
+ name, (u_longlong_t)delta, cpb); \
} while (0)
(void) printf("Running algorithm correctness tests:\n");
@@ -237,8 +247,18 @@ main(int argc, char *argv[])
(void) printf("Running performance tests (hashing 1024 MiB of "
"data):\n");
- SHA2_PERF_TEST(256, 256);
- SHA2_PERF_TEST(512, 512);
+
+ for (id = 0; id < sha256->getcnt(); id++) {
+ sha256->setid(id);
+ const char *name = sha256->getname();
+ SHA2_PERF_TEST(256, 256, name);
+ }
+
+ for (id = 0; id < sha512->getcnt(); id++) {
+ sha512->setid(id);
+ const char *name = sha512->getname();
+ SHA2_PERF_TEST(512, 512, name);
+ }
return (0);
}