crypto: qat - add support for zstd
Subsystems (3)
Giovanni Cabiddu
maintainerv2 cover crypto: qat - add support for zstd
The Intel QuickAssist Technology (QAT) driver currently supports deflate compression via the acomp API, but lacks support for the ZSTD algorithm.
This series adds ZSTD compression support for QAT GEN4, QAT GEN5 and QAT GEN6 devices.
On GEN4 and GEN5, hardware compresses data using LZ4s (a QAT-specific variant of LZ4). The LZ4s output is then parsed and passed to the kernel zstd library via zstd_compress_sequences_and_literals() to produce a standard ZSTD stream. The post-processing step uses per-CPU scratch buffers managed via the acomp stream infrastructure.
On GEN6, both compression and decompression are natively offloaded to the accelerator. Decompression of frames with a history window exceeding the 64 KB hardware limit falls back to software.
A filtering mechanism is also introduced to prevent GEN2 plug-in cards, which do not support ZSTD or LZ4s, from being selected for these algorithms when a GEN4, GEN5 or GEN6 embedded device is also present on the system.
In summary:
- Patch #1 fixes a build error on architectures without a native byte-swap instruction
- Patch #2 exposes the ZSTD algorithm through the acomp API for QAT GEN4, GEN5 and GEN6 accelerators
Changes since v1:
- Add a patch to fix a build error on architectures without a native byte-swap instruction
Giovanni Cabiddu (2):
crypto: qat - use swab32 macro
crypto: qat - add support for zstd
drivers/crypto/intel/qat/Kconfig | 1 + .../intel/qat/qat_420xx/adf_420xx_hw_data.c | 1 + .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 1 + .../intel/qat/qat_6xxx/adf_6xxx_hw_data.c | 17 + drivers/crypto/intel/qat/qat_common/Makefile | 1 + .../intel/qat/qat_common/adf_accel_devices.h | 6 + .../intel/qat/qat_common/adf_common_drv.h | 6 +- .../intel/qat/qat_common/adf_gen4_hw_data.c | 18 +- .../crypto/intel/qat/qat_common/adf_init.c | 6 +- .../crypto/intel/qat/qat_common/icp_qat_fw.h | 7 + .../intel/qat/qat_common/icp_qat_fw_comp.h | 2 + .../crypto/intel/qat/qat_common/icp_qat_hw.h | 3 +- .../intel/qat/qat_common/icp_qat_hw_20_comp.h | 10 +- .../intel/qat/qat_common/qat_comp_algs.c | 524 +++++++++++++++++- .../intel/qat/qat_common/qat_comp_req.h | 9 + .../qat/qat_common/qat_comp_zstd_utils.c | 165 ++++++ .../qat/qat_common/qat_comp_zstd_utils.h | 13 + .../intel/qat/qat_common/qat_compression.c | 23 +- 18 files changed, 779 insertions(+), 34 deletions(-) create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.h
base-commit: 93e03a16c015b8e55e2ec97865f67d9bf1ec1921
Signature · 1 line
2.53.0
Giovanni Cabiddu
maintainerPATCH v2 1/2 crypto: qat - use swab32 macro
Replace __builtin_bswap32() with swab32 in icp_qat_hw_20_comp.h to fix the following build errors on architectures without native byte-swap support:
alpha-linux-ld: drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.o: in function `adf_gen4_build_decomp_block':
drivers/crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h:141:(.text+0xeec): undefined reference to `__bswapsi2'
alpha-linux-ld: drivers/crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h:141:(.text+0xef8): undefined reference to `__bswapsi2'
alpha-linux-ld: drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.o: in function `adf_gen4_build_comp_block':
drivers/crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h:57:(.text+0xf64): undefined reference to `__bswapsi2'
alpha-linux-ld: drivers/crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h:57:(.text+0xf7c): undefined reference to `__bswapsi2'
--- .../crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/crypto/intel/qat/qat_common/icp_qat_hw_20_comp.h +6 -4
@@ -3,6 +3,8 @@#ifndef _ICP_QAT_HW_20_COMP_H_#define _ICP_QAT_HW_20_COMP_H_ +#include <linux/swab.h> +#include "icp_qat_hw_20_comp_defs.h" #include "icp_qat_fw.h"
@@ -54,7 +56,7 @@ ICP_QAT_FW_COMP_20_BUILD_CONFIG_LOWER(struct icp_qat_hw_comp_20_config_csr_lowerQAT_FIELD_SET (val32, csr.abd,ICP_QAT_HW_COMP_20_CONFIG_CSR_ABD_BITPOS ,ICP_QAT_HW_COMP_20_CONFIG_CSR_ABD_MASK ); -return __builtin_bswap32 (val32); +return swab32 (val32); }struct icp_qat_hw_comp_20_config_csr_upper {
@@ -106,7 +108,7 @@ ICP_QAT_FW_COMP_20_BUILD_CONFIG_UPPER(struct icp_qat_hw_comp_20_config_csr_upperICP_QAT_HW_COMP_20_CONFIG_CSR_NICE_PARAM_BITPOS , ICP_QAT_HW_COMP_20_CONFIG_CSR_NICE_PARAM_MASK); -return __builtin_bswap32 (val32); +return swab32 (val32); }struct icp_qat_hw_decomp_20_config_csr_lower {
@@ -138,7 +140,7 @@ ICP_QAT_FW_DECOMP_20_BUILD_CONFIG_LOWER(struct icp_qat_hw_decomp_20_config_csr_lICP_QAT_HW_DECOMP_20_CONFIG_CSR_LZ4_BLOCK_CHECKSUM_PRESENT_BITPOS , ICP_QAT_HW_DECOMP_20_CONFIG_CSR_LZ4_BLOCK_CHECKSUM_PRESENT_MASK); -return __builtin_bswap32 (val32); +return swab32 (val32); }struct icp_qat_hw_decomp_20_config_csr_upper {
@@ -158,7 +160,7 @@ ICP_QAT_FW_DECOMP_20_BUILD_CONFIG_UPPER(struct icp_qat_hw_decomp_20_config_csr_uICP_QAT_HW_DECOMP_20_CONFIG_CSR_MINI_CAM_CONTROL_BITPOS , ICP_QAT_HW_DECOMP_20_CONFIG_CSR_MINI_CAM_CONTROL_MASK); - return __builtin_bswap32(val32); + return swab32(val32); }#endif
Signature · 1 line
2.53.0
Giovanni Cabiddu
maintainerPATCH v2 2/2 crypto: qat - add support for zstd
In reply to Giovanni CabidduAdd support for the ZSTD algorithm for QAT GEN4, GEN5 and GEN6 via the acomp API.
For GEN4 and GEN5, compression is performed in hardware using LZ4s, a QAT-specific variant of LZ4. The compressed output is post-processed to generate ZSTD sequences, and the ZSTD library is then used to produce the final ZSTD stream via zstd_compress_sequences_and_literals(). Only inputs between 8 KB and 512 KB are offloaded to the device. The minimum size restriction will be relaxed once polling support is added. The maximum size is limited by the use of pre-allocated per-CPU scratch buffers. On these generations, only compression is offloaded to hardware; decompression always falls back to software.
For GEN6, both compression and decompression are offloaded to the accelerator, which natively supports the ZSTD algorithm. There is no limit on the input buffer size supported. However, since GEN6 is limited to a history size of 64 KB, decompression of frames compressed with a larger history falls back to software.
Since GEN2 devices do not support ZSTD or LZ4s, add a mechanism that prevents selecting GEN2 compression instances for ZSTD or LZ4s when a GEN2 plug-in card is present on a system with an embedded GEN4, GEN5 or GEN6 device.
In addition, modify the algorithm registration logic to allow registering the correct implementation, i.e. LZ4s based for GEN4 and GEN5 or native ZSTD for GEN6.
--- drivers/crypto/intel/qat/Kconfig | 1 + .../intel/qat/qat_420xx/adf_420xx_hw_data.c | 1 + .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 1 + .../intel/qat/qat_6xxx/adf_6xxx_hw_data.c | 17 + drivers/crypto/intel/qat/qat_common/Makefile | 1 + .../intel/qat/qat_common/adf_accel_devices.h | 6 + .../intel/qat/qat_common/adf_common_drv.h | 6 +- .../intel/qat/qat_common/adf_gen4_hw_data.c | 18 +- .../crypto/intel/qat/qat_common/adf_init.c | 6 +- .../crypto/intel/qat/qat_common/icp_qat_fw.h | 7 + .../intel/qat/qat_common/icp_qat_fw_comp.h | 2 + .../crypto/intel/qat/qat_common/icp_qat_hw.h | 3 +- .../intel/qat/qat_common/qat_comp_algs.c | 524 +++++++++++++++++- .../intel/qat/qat_common/qat_comp_req.h | 9 + .../qat/qat_common/qat_comp_zstd_utils.c | 165 ++++++ .../qat/qat_common/qat_comp_zstd_utils.h | 13 + .../intel/qat/qat_common/qat_compression.c | 23 +- 17 files changed, 773 insertions(+), 30 deletions(-) create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.h
drivers/crypto/intel/qat/Kconfig +1 -0
@@ -11,6 +11,7 @@ config CRYPTO_DEV_QAT select CRYPTO_LIB_SHA1 select CRYPTO_LIB_SHA256 select CRYPTO_LIB_SHA512 + select CRYPTO_ZSTD select FW_LOADER select CRC8
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c +1 -0
@@ -488,6 +488,7 @@ void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->clock_frequency =ADF_420XX_AE_FREQ ; hw_data->services_supported = adf_gen4_services_supported; hw_data->get_svc_slice_cnt = adf_gen4_get_svc_slice_cnt; + hw_data->accel_capabilities_ext_mask =ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S ;adf_gen4_set_err_mask (&hw_data->dev_err_mask);adf_gen4_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +1 -0
@@ -473,6 +473,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->clock_frequency =ADF_4XXX_AE_FREQ ; hw_data->services_supported = adf_gen4_services_supported; hw_data->get_svc_slice_cnt = adf_gen4_get_svc_slice_cnt; + hw_data->accel_capabilities_ext_mask =ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S ;adf_gen4_set_err_mask (&hw_data->dev_err_mask);adf_gen4_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/intel/qat/qat_6xxx/adf_6xxx_hw_data.c +17 -0
@@ -33,6 +33,8 @@#define ADF_AE_GROUP_1 GENMASK(7, 4)#define ADF_AE_GROUP_2 BIT(8) +#define ASB_MULTIPLIER 9 +struct adf_ring_config {u32 ring_mask;enum adf_cfg_service_type ring_type;
@@ -509,6 +511,9 @@ static int build_comp_block(void *ctx, enum adf_dc_algo algo)case QAT_DEFLATE : header->service_cmd_id =ICP_QAT_FW_COMP_CMD_DYNAMIC ;break ; +case QAT_ZSTD : + header->service_cmd_id =ICP_QAT_FW_COMP_CMD_ZSTD_COMPRESS ; +break ;default :return -EINVAL ; }
@@ -519,6 +524,13 @@ static int build_comp_block(void *ctx, enum adf_dc_algo algo) cd_pars->u.sl.comp_slice_cfg_word[0 ] = lower_val; cd_pars->u.sl.comp_slice_cfg_word[1 ] =0 ; +/* +* Store Auto Select Best (ASB) multiplier in the request template. +* This will be used in the data path to set the actual threshold +* value based on the input data size. +*/ + req_tmpl->u3.asb_threshold.asb_value =ASB_MULTIPLIER ; +return 0 ; }
@@ -532,12 +544,16 @@ static int build_decomp_block(void *ctx, enum adf_dc_algo algo)case QAT_DEFLATE : header->service_cmd_id =ICP_QAT_FW_COMP_CMD_DECOMPRESS ;break ; +case QAT_ZSTD : + header->service_cmd_id =ICP_QAT_FW_COMP_CMD_ZSTD_DECOMPRESS ; +break ;default :return -EINVAL ; } cd_pars->u.sl.comp_slice_cfg_word[0 ] =0 ; cd_pars->u.sl.comp_slice_cfg_word[1 ] =0 ; + req_tmpl->u3.asb_threshold.asb_value =0 ;return 0 ; }
@@ -1030,6 +1046,7 @@ void adf_init_hw_data_6xxx(struct adf_hw_device_data *hw_data) hw_data->num_rps =ADF_GEN6_ETR_MAX_BANKS ; hw_data->clock_frequency =ADF_6XXX_AE_FREQ ; hw_data->get_svc_slice_cnt = adf_gen6_get_svc_slice_cnt; + hw_data->accel_capabilities_ext_mask =ADF_ACCEL_CAPABILITIES_EXT_ZSTD ;adf_gen6_init_services_supported (hw_data);adf_gen6_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/intel/qat/qat_common/Makefile +1 -0
@@ -41,6 +41,7 @@ intel_qat-y := adf_accel_engine.o \ qat_bl.o \ qat_comp_algs.o \ qat_compression.o \ + qat_comp_zstd_utils.o \ qat_crypto.o \ qat_hal.o \ qat_mig_dev.o \
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +6 -0
@@ -59,6 +59,11 @@ enum adf_accel_capabilities {ADF_ACCEL_CAPABILITIES_RANDOM_NUMBER =128 }; +enum adf_accel_capabilities_ext { +ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S =BIT (0 ), +ADF_ACCEL_CAPABILITIES_EXT_ZSTD =BIT (1 ), +}; +enum adf_fuses {ADF_FUSECTL0 ,ADF_FUSECTL1 ,
@@ -336,6 +341,7 @@ struct adf_hw_device_data {u32 fuses[ADF_MAX_FUSES ];u32 straps;u32 accel_capabilities_mask; +u32 accel_capabilities_ext_mask;u32 extended_dc_capabilities;u16 fw_capabilities;u32 clock_frequency;
drivers/crypto/intel/qat/qat_common/adf_common_drv.h +3 -3
@@ -111,12 +111,12 @@ void qat_algs_unregister(void);int qat_asym_algs_register (void );void qat_asym_algs_unregister (void ); -struct qat_compression_instance *qat_compression_get_instance_node (int node); +struct qat_compression_instance *qat_compression_get_instance_node (int node,int alg);void qat_compression_put_instance (struct qat_compression_instance *inst);int qat_compression_register (void );int qat_compression_unregister (void ); -int qat_comp_algs_register (void ); -void qat_comp_algs_unregister (void ); +int qat_comp_algs_register (u32 caps); +void qat_comp_algs_unregister (u32 caps);void qat_comp_alg_callback (void *resp);int adf_isr_resource_alloc (struct adf_accel_dev *accel_dev);
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c +14 -4
@@ -504,14 +504,20 @@ static int adf_gen4_build_comp_block(void *ctx, enum adf_dc_algo algo)switch (algo) {case QAT_DEFLATE : header->service_cmd_id =ICP_QAT_FW_COMP_CMD_DYNAMIC ; + hw_comp_lower_csr.algo =ICP_QAT_HW_COMP_20_HW_COMP_FORMAT_ILZ77 ; + hw_comp_lower_csr.lllbd =ICP_QAT_HW_COMP_20_LLLBD_CTRL_LLLBD_ENABLED ; + hw_comp_lower_csr.skip_ctrl =ICP_QAT_HW_COMP_20_BYTE_SKIP_3BYTE_LITERAL ; +break ; +case QAT_LZ4S : + header->service_cmd_id =ICP_QAT_FW_COMP_20_CMD_LZ4S_COMPRESS ; + hw_comp_lower_csr.algo =ICP_QAT_HW_COMP_20_HW_COMP_FORMAT_LZ4S ; + hw_comp_lower_csr.lllbd =ICP_QAT_HW_COMP_20_LLLBD_CTRL_LLLBD_DISABLED ; + hw_comp_lower_csr.abd =ICP_QAT_HW_COMP_20_ABD_ABD_DISABLED ;break ;default :return -EINVAL ; } - hw_comp_lower_csr.skip_ctrl =ICP_QAT_HW_COMP_20_BYTE_SKIP_3BYTE_LITERAL ; - hw_comp_lower_csr.algo =ICP_QAT_HW_COMP_20_HW_COMP_FORMAT_ILZ77 ; - hw_comp_lower_csr.lllbd =ICP_QAT_HW_COMP_20_LLLBD_CTRL_LLLBD_ENABLED ; hw_comp_lower_csr.sd =ICP_QAT_HW_COMP_20_SEARCH_DEPTH_LEVEL_1 ; hw_comp_lower_csr.hash_update =ICP_QAT_HW_COMP_20_SKIP_HASH_UPDATE_DONT_ALLOW ; hw_comp_lower_csr.edmm =ICP_QAT_HW_COMP_20_EXTENDED_DELAY_MATCH_MODE_EDMM_ENABLED ;
@@ -538,12 +544,16 @@ static int adf_gen4_build_decomp_block(void *ctx, enum adf_dc_algo algo)switch (algo) {case QAT_DEFLATE : header->service_cmd_id =ICP_QAT_FW_COMP_CMD_DECOMPRESS ; + hw_decomp_lower_csr.algo =ICP_QAT_HW_DECOMP_20_HW_DECOMP_FORMAT_DEFLATE ; +break ; +case QAT_LZ4S : + header->service_cmd_id =ICP_QAT_FW_COMP_20_CMD_LZ4S_DECOMPRESS ; + hw_decomp_lower_csr.algo =ICP_QAT_HW_DECOMP_20_HW_DECOMP_FORMAT_LZ4S ;break ;default :return -EINVAL ; } - hw_decomp_lower_csr.algo =ICP_QAT_HW_DECOMP_20_HW_DECOMP_FORMAT_DEFLATE ; lower_val =ICP_QAT_FW_DECOMP_20_BUILD_CONFIG_LOWER (hw_decomp_lower_csr); cd_pars->u.sl.comp_slice_cfg_word[0 ] = lower_val;
drivers/crypto/intel/qat/qat_common/adf_init.c +4 -2
@@ -180,6 +180,7 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_data = accel_dev->hw_device;struct service_hndl *service; +u32 caps;int ret;set_bit (ADF_STATUS_STARTING , &accel_dev->status);
@@ -253,7 +254,8 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev) }set_bit (ADF_STATUS_CRYPTO_ALGS_REGISTERED , &accel_dev->status); -if (!list_empty (&accel_dev->compression_list) &&qat_comp_algs_register ()) { + caps = hw_data->accel_capabilities_ext_mask; +if (!list_empty (&accel_dev->compression_list) &&qat_comp_algs_register (caps)) {dev_err (&GET_DEV (accel_dev),"Failed to register compression algs\n" );set_bit (ADF_STATUS_STARTING , &accel_dev->status);
@@ -308,7 +310,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev)if (!list_empty (&accel_dev->compression_list) &&test_bit (ADF_STATUS_COMP_ALGS_REGISTERED , &accel_dev->status)) -qat_comp_algs_unregister (); +qat_comp_algs_unregister (hw_data->accel_capabilities_ext_mask);clear_bit (ADF_STATUS_COMP_ALGS_REGISTERED , &accel_dev->status);list_for_each_entry (service, &service_table, list) {
drivers/crypto/intel/qat/qat_common/icp_qat_fw.h +7 -0
@@ -151,6 +151,13 @@ struct icp_qat_fw_comn_resp { ICP_QAT_FW_COMN_CNV_FLAG_BITPOS, \ ICP_QAT_FW_COMN_CNV_FLAG_MASK) +#define ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS 4 +#define ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK 0x1 +#define ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_GET (hdr_flags) \ + QAT_FIELD_GET(hdr_flags, \ + ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS, \ + ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK) +#define ICP_QAT_FW_COMN_HDR_CNV_FLAG_SET (hdr_t, val) \ QAT_FIELD_SET((hdr_t.hdr_flags), (val), \ ICP_QAT_FW_COMN_CNV_FLAG_BITPOS, \
drivers/crypto/intel/qat/qat_common/icp_qat_fw_comp.h +2 -0
@@ -8,6 +8,8 @@ enum icp_qat_fw_comp_cmd_id {ICP_QAT_FW_COMP_CMD_STATIC =0 ,ICP_QAT_FW_COMP_CMD_DYNAMIC =1 ,ICP_QAT_FW_COMP_CMD_DECOMPRESS =2 , +ICP_QAT_FW_COMP_CMD_ZSTD_COMPRESS =10 , +ICP_QAT_FW_COMP_CMD_ZSTD_DECOMPRESS =11 , ICP_QAT_FW_COMP_CMD_DELIMITER };
drivers/crypto/intel/qat/qat_common/icp_qat_hw.h +2 -1
@@ -336,7 +336,8 @@ enum icp_qat_hw_compression_delayed_match {enum icp_qat_hw_compression_algo {ICP_QAT_HW_COMPRESSION_ALGO_DEFLATE =0 ,ICP_QAT_HW_COMPRESSION_ALGO_LZS =1 , -ICP_QAT_HW_COMPRESSION_ALGO_DELIMITER =2 +ICP_QAT_HW_COMPRESSION_ALGO_ZSTD =2 , +ICP_QAT_HW_COMPRESSION_ALGO_DELIMITER };enum icp_qat_hw_compression_depth {
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c +505 -19
643 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/qat_comp_req.h +9 -0
@@ -23,6 +23,7 @@ static inline void qat_comp_create_req(void *ctx, void *req, u64 src, u32 slen, fw_req->comn_mid.opaque_data = opaque; req_pars->comp_len = slen; req_pars->out_buffer_sz = dlen; + fw_req->u3.asb_threshold.asb_value *= slen >>4 ; } static inline void qat_comp_create_compression_req(void *ctx, void *req,
@@ -110,4 +111,12 @@ static inline u8 qat_comp_get_cmp_cnv_flag(void *resp) return ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(flags); } +static inline u8 qat_comp_get_cmp_uncomp_flag (void *resp) +{ +struct icp_qat_fw_comp_resp *qat_resp = resp; +u8 flags = qat_resp->comn_resp.hdr_flags; + +return ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_GET (flags); +} +#endif
drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c new file +165 -0
165 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2026 Intel Corporation */ +#ifndef QAT_COMP_ZSTD_UTILS_H_ +#define QAT_COMP_ZSTD_UTILS_H_ +#include <linux/zstd_lib.h> + +#define QAT_ZSTD_LIT_COPY_LEN 8 + +int qat_alg_dec_lz4s (ZSTD_Sequence *out_seqs,size_t out_seqs_capacity, +unsigned char *lz4s_buff,unsigned int lz4s_buff_size, +unsigned char *literals,unsigned int *lit_len); + +#endif
drivers/crypto/intel/qat/qat_common/qat_compression.c +22 -1
@@ -46,12 +46,14 @@ static int qat_compression_free_instances(struct adf_accel_dev *accel_dev)return 0 ; } -struct qat_compression_instance *qat_compression_get_instance_node (int node) +struct qat_compression_instance *qat_compression_get_instance_node (int node,int alg) {struct qat_compression_instance *inst =NULL ; +struct adf_hw_device_data *hw_data =NULL ;struct adf_accel_dev *accel_dev =NULL ;unsigned long best = ~0 ;struct list_head *itr; +u32 caps, mask;list_for_each (itr,adf_devmgr_get_head ()) {struct adf_accel_dev *tmp_dev;
@@ -61,6 +63,15 @@ struct qat_compression_instance *qat_compression_get_instance_node(int node) tmp_dev = list_entry(itr, struct adf_accel_dev, list); tmp_dev_node =dev_to_node (&GET_DEV (tmp_dev)); +if (alg ==QAT_ZSTD || alg ==QAT_LZ4S ) { + hw_data = tmp_dev->hw_device; + caps = hw_data->accel_capabilities_ext_mask; + mask =ADF_ACCEL_CAPABILITIES_EXT_ZSTD | +ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S ; +if (!(caps & mask)) +continue ; + } +if ((node == tmp_dev_node || tmp_dev_node <0 ) &&adf_dev_started (tmp_dev) && !list_empty (&tmp_dev->compression_list)) { ctr =atomic_read (&tmp_dev->ref_count);
@@ -78,6 +89,16 @@ struct qat_compression_instance *qat_compression_get_instance_node(int node)struct adf_accel_dev *tmp_dev; tmp_dev = list_entry(itr, struct adf_accel_dev, list); + +if (alg ==QAT_ZSTD || alg ==QAT_LZ4S ) { + hw_data = tmp_dev->hw_device; + caps = hw_data->accel_capabilities_ext_mask; + mask =ADF_ACCEL_CAPABILITIES_EXT_ZSTD | +ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S ; +if (!(caps & mask)) +continue ; + } +if (adf_dev_started (tmp_dev) && !list_empty (&tmp_dev->compression_list)) { accel_dev = tmp_dev;
Signature · 1 line
2.53.0
Herbert Xu
maintainerQuoted 58 lines · Giovanni Cabiddu
The Intel QuickAssist Technology (QAT) driver currently supports deflate compression via the acomp API, but lacks support for the ZSTD algorithm.
This series adds ZSTD compression support for QAT GEN4, QAT GEN5 and QAT GEN6 devices.
On GEN4 and GEN5, hardware compresses data using LZ4s (a QAT-specific variant of LZ4). The LZ4s output is then parsed and passed to the kernel zstd library via
zstd_compress_sequences_and_literals()to produce a standard ZSTD stream. The post-processing step uses per-CPU scratch buffers managed via the acomp stream infrastructure.On GEN6, both compression and decompression are natively offloaded to the accelerator. Decompression of frames with a history window exceeding the 64 KB hardware limit falls back to software.
A filtering mechanism is also introduced to prevent GEN2 plug-in cards, which do not support ZSTD or LZ4s, from being selected for these algorithms when a GEN4, GEN5 or GEN6 embedded device is also present on the system.
In summary:
- Patch #1 fixes a build error on architectures without a native byte-swap instruction
- Patch #2 exposes the ZSTD algorithm through the acomp API for QAT GEN4, GEN5 and GEN6 acceleratorsChanges since v1:
- Add a patch to fix a build error on architectures without a native byte-swap instructionGiovanni Cabiddu (2):
crypto: qat - use swab32 macro
crypto: qat - add support for zstddrivers/crypto/intel/qat/Kconfig | 1 + .../intel/qat/qat_420xx/adf_420xx_hw_data.c | 1 + .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 1 + .../intel/qat/qat_6xxx/adf_6xxx_hw_data.c | 17 + drivers/crypto/intel/qat/qat_common/Makefile | 1 + .../intel/qat/qat_common/adf_accel_devices.h | 6 + .../intel/qat/qat_common/adf_common_drv.h | 6 +- .../intel/qat/qat_common/adf_gen4_hw_data.c | 18 +- .../crypto/intel/qat/qat_common/adf_init.c | 6 +- .../crypto/intel/qat/qat_common/icp_qat_fw.h | 7 + .../intel/qat/qat_common/icp_qat_fw_comp.h | 2 + .../crypto/intel/qat/qat_common/icp_qat_hw.h | 3 +- .../intel/qat/qat_common/icp_qat_hw_20_comp.h | 10 +- .../intel/qat/qat_common/qat_comp_algs.c | 524 +++++++++++++++++- .../intel/qat/qat_common/qat_comp_req.h | 9 + .../qat/qat_common/qat_comp_zstd_utils.c | 165 ++++++ .../qat/qat_common/qat_comp_zstd_utils.h | 13 + .../intel/qat/qat_common/qat_compression.c | 23 +- 18 files changed, 779 insertions(+), 34 deletions(-) create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.h
Quoted 3 lines
base-commit:
93e03a16c015b8e55e2ec97865f67d9bf1ec1921Signature · 1 line
2.53.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt