Skip to content

Commit

Permalink
Intel QAT Z.I.A. provider for ZFS only
Browse files Browse the repository at this point in the history
This provider takes the original Intel QAT code found in ZFS
and moves it into a Z.I.A. provider. Because the original
code uses symbols from ZFS, this provider should be treated
as only usable by ZFS.

The original QAT code in ZFS did not use the new operation
chaining capability that was added to the QAT API in March
2019. This provider does not update the code to use it as
using chaining would cause operations to be performed out of
sync with ZFS.

The Intel QAT does not maintain memory locally and instead
always reads from in-memory buffers and write results to
in-memory buffers. This results in a lot of memory traffic.
Additionally, because the DPUSM (intentionally) does not have
an interface for passing raw pointers from the caller to the
accelerator, this provider will allocate another in-memory
buffer to copy each offloaded ZFS buffer into, doubling
memory usage.

The vdev_raidz, vdev_file, and vdev_disk code was copied
from the example software provider.

Encryption is not supported by the DPUSM. The original
code was moved along with the rest of the QAT code, but
is now not used by ZFS.

Signed-off-by: Jason Lee <[email protected]>
  • Loading branch information
calccrypto committed Jul 23, 2024
1 parent 9c676fd commit 5a951c8
Show file tree
Hide file tree
Showing 12 changed files with 680 additions and 384 deletions.
1 change: 0 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ COMMON_H = \
sys/nvpair_impl.h \
sys/objlist.h \
sys/pathname.h \
sys/qat.h \
sys/range_tree.h \
sys/rrwlock.h \
sys/sa.h \
Expand Down
31 changes: 21 additions & 10 deletions module/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ CFLAGS_zfs/zap_micro.o += -mllvm -x86-cmov-converter=false
endif
endif

ifneq ($(KBUILD_EXTMOD),)
@CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
@CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
endif

asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)

Expand Down Expand Up @@ -439,9 +434,6 @@ ZFS_OBJS_OS := \
arc_os.o \
mmp_os.o \
policy.o \
qat.o \
qat_compress.o \
qat_crypt.o \
spa_misc_os.o \
trace.o \
vdev_disk.o \
Expand Down Expand Up @@ -505,6 +497,8 @@ $(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec
endif

ifneq ("@DPUSM_SYMBOLS@","")
@ZIA_ENABLED_TRUE@KBUILD_EXTRA_SYMBOLS += @DPUSM_SYMBOLS@

obj-$(CONFIG_ZFS) += zia-software-provider.o

ZIA_SOFTWARE_PROVIDER_OBJS := \
Expand All @@ -517,5 +511,22 @@ zia-software-provider-objs += os/linux/zfs/zfs_file_os.o

$(addprefix $(obj)/zia-software-provider/,$(ZIA_SOFTWARE_PROVIDER_OBJS)) : ccflags-y += -I@abs_top_builddir@ $(ZFS_MODULE_CFLAGS) -I@abs_srcdir@/zia-software-provider/ -I@DPUSM_ROOT@/include

@ZIA_ENABLED_TRUE@KBUILD_EXTRA_SYMBOLS += @DPUSM_SYMBOLS@
endif
ifeq ($(CONFIG_QAT_TRUE),y)

obj-$(CONFIG_ZFS) += zfs-qat-provider.o

ZFS_QAT_PROVIDER_OBJS := \
qat.o \
qat_compress.o \
qat_crypt.o \
provider.o

zfs-qat-provider-objs += $(addprefix zfs-qat-provider/,$(ZFS_QAT_PROVIDER_OBJS))

$(addprefix $(obj)/zfs-qat-provider/,$(ZFS_QAT_PROVIDER_OBJS)) : ccflags-y += -I@abs_top_builddir@ $(ZFS_MODULE_CFLAGS) -I@abs_srcdir@/zfs-qat-provider/ -I@DPUSM_ROOT@/include -I@QAT_SRC@/include

@ZIA_ENABLED_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@

endif

endif
105 changes: 0 additions & 105 deletions module/os/linux/zfs/qat.c

This file was deleted.

37 changes: 5 additions & 32 deletions module/os/linux/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <sys/zil.h>
#include <sys/sha2.h>
#include <sys/hkdf.h>
#include <sys/qat.h>

/*
* This file is responsible for handling all of the details of generating
Expand Down Expand Up @@ -1955,37 +1954,6 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key,
tmpl = NULL;
}

/*
* Attempt to use QAT acceleration if we can. We currently don't
* do this for metadnode and ZIL blocks, since they have a much
* more involved buffer layout and the qat_crypt() function only
* works in-place.
*/
if (qat_crypt_use_accel(datalen) &&
ot != DMU_OT_INTENT_LOG && ot != DMU_OT_DNODE) {
uint8_t *srcbuf, *dstbuf;

if (encrypt) {
srcbuf = plainbuf;
dstbuf = cipherbuf;
} else {
srcbuf = cipherbuf;
dstbuf = plainbuf;
}

ret = qat_crypt((encrypt) ? QAT_ENCRYPT : QAT_DECRYPT, srcbuf,
dstbuf, NULL, 0, iv, mac, ckey, key->zk_crypt, datalen);
if (ret == CPA_STATUS_SUCCESS) {
if (locked) {
rw_exit(&key->zk_salt_lock);
locked = B_FALSE;
}

return (0);
}
/* If the hardware implementation fails fall back to software */
}

/* create uios for encryption */
ret = zio_crypt_init_uios(encrypt, key->zk_version, ot, plainbuf,
cipherbuf, datalen, byteswap, mac, &puio, &cuio, &enc_len,
Expand Down Expand Up @@ -2077,4 +2045,9 @@ zio_do_crypt_abd(boolean_t encrypt, zio_crypt_key_t *key, dmu_object_type_t ot,
module_param(zfs_key_max_salt_uses, ulong, 0644);
MODULE_PARM_DESC(zfs_key_max_salt_uses, "Max number of times a salt value "
"can be used for generating encryption keys before it is rotated");

#if defined(ZIA) && defined(HAVE_QAT)
EXPORT_SYMBOL(zio_crypt_table);
#endif

#endif
Loading

0 comments on commit 5a951c8

Please sign in to comment.