diff options
author | Tom Caputi <[email protected]> | 2018-03-15 13:53:58 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-03-15 10:53:58 -0700 |
commit | 38742209322b5b3d93635a4820b2f9c755aadee8 (patch) | |
tree | 166b15847cb283cb710e93c73933fc0279cbcce5 /module/zfs/sha256.c | |
parent | 8a2a9db8df7d421aedeababf7b1ecbb51642f16c (diff) |
SHA256 QAT acceleration
This patch enables acceleration of SHA256 checksums using Intel
Quick Assist Technology. This patch also fixes up and refactors
some of the code from QAT encryption to make the behavior
consistent.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chengfeix Zhu <[email protected]>
Signed-off-by: Weigang Li <[email protected]>
Signed-off-by: Tom Caputi <[email protected]>
Closes #7295
Diffstat (limited to 'module/zfs/sha256.c')
-rw-r--r-- | module/zfs/sha256.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/module/zfs/sha256.c b/module/zfs/sha256.c index 23a97aa3d..2adadf56f 100644 --- a/module/zfs/sha256.c +++ b/module/zfs/sha256.c @@ -30,6 +30,7 @@ #include <sys/zio.h> #include <sys/sha2.h> #include <sys/abd.h> +#include "qat.h" static int sha_incremental(void *buf, size_t size, void *arg) @@ -44,13 +45,25 @@ void abd_checksum_SHA256(abd_t *abd, uint64_t size, const void *ctx_template, zio_cksum_t *zcp) { + int ret; SHA2_CTX ctx; zio_cksum_t tmp; + if (qat_checksum_use_accel(size)) { + uint8_t *buf = abd_borrow_buf_copy(abd, size); + ret = qat_checksum(ZIO_CHECKSUM_SHA256, buf, size, &tmp); + abd_return_buf(abd, buf, size); + if (ret == CPA_STATUS_SUCCESS) + goto bswap; + + /* If the hardware implementation fails fall back to software */ + } + SHA2Init(SHA256, &ctx); (void) abd_iterate_func(abd, 0, size, sha_incremental, &ctx); SHA2Final(&tmp, &ctx); +bswap: /* * A prior implementation of this function had a * private SHA256 implementation always wrote things out in |