crypto: qat - enable compression deflate algorithm
v3 cover crypto: qat - enable compression deflate algorithm
This set enables the offload of the compression deflate algorithm to QAT accelerators through the acomp API.
The first part of the set (patches 1 to 8) reworks and refactors logic that is specific to the crypto service in order to be used by the compression service.
In particular, the first 6 patches rework the buffer list logic, which is used to map, unmap and convert scatterlists into the format that the QAT firmware can understand. These relocate the bufferlist logic to a separate file, change the interfaces so that the logic is service agnostic (not tied to compression or crypto) and extend the interface to allow an additional pre-allocated buffer for each destination scatter list which will be used to avoid premature overflows reported by the compression hardware.
Patch 7 relocates the function qat_algs_alloc_flags() from a crypto specific header to qat_bl.h.
Patch 8 moves and renames the configuration function for GEN2, qat_crypto_dev_config(), to a new file, adf_gen2_config.h, which contains the configuration logic for both crypto and compression instances for QAT GEN2 devices.
The last 2 patches in the set introduce all the infrastructure required to enable the compression service in the QAT driver and expose it through the acomp APIs.
In particular, patch 9 introduces the logic related to the creation and handling of compression instances and their configuration. In addition, it adds the back-end for qat_deflate to plug into acomp, including the logic to build descriptors for the newly added GEN2 compression firmware APIs. This was all kept in a single patch to avoid introducing unused logic in the QAT driver in previous patches.
Patch 10, extends the compression logic to support to QAT GEN4 devices.
Patch 11 extends the acomp api by defining the max size for the destination buffer when a request is submitted with NULL destination buffer. This value is then used in the followin patch.
Patch 12 implements the resubmission logic for decompression requests that is triggered if the destination buffer, allocated by the driver, is not sufficiently big to store the output from the operation.
Changes from v1:
- Implemented resubmission logic for decompression triggered when the output buffer allocated by the driver is not sufficiently large to store the result from the operation
- Renamed buffer list functions that are moved to the qat_bl module
Changes from v2:
- Reworked decompression re-submission logic. For decompression operations submitted specifying NULL as destination buffer, resubmit once with a destination buffer of size 128KB instead of retying multiple times doubling every time the size of the destination buffer.
- Added define in acomp api to specify the destination maximum size.
Giovanni Cabiddu (12):
crypto: qat - relocate bufferlist logic
crypto: qat - rename bufferlist functions
crypto: qat - change bufferlist logic interface
crypto: qat - generalize crypto request buffers
crypto: qat - extend buffer list interface
crypto: qat - relocate backlog related structures
crypto: qat - relocate qat_algs_alloc_flags()
crypto: qat - rename and relocate GEN2 config function
crypto: qat - expose deflate through acomp api for QAT GEN2
crypto: qat - enable deflate for QAT GEN4
crypto: acomp - define max size for destination
crypto: qat - add resubmit logic for decompression
.../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 4 +- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.h | 2 +- drivers/crypto/qat/qat_4xxx/adf_drv.c | 145 ++++++- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 4 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 2 +- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 4 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 4 + drivers/crypto/qat/qat_c62x/adf_drv.c | 2 +- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 4 + drivers/crypto/qat/qat_common/Makefile | 8 +- .../crypto/qat/qat_common/adf_accel_devices.h | 14 + .../crypto/qat/qat_common/adf_cfg_strings.h | 1 + .../crypto/qat/qat_common/adf_common_drv.h | 9 +- drivers/crypto/qat/qat_common/adf_ctl_drv.c | 6 + .../crypto/qat/qat_common/adf_gen2_config.c | 206 +++++++++ .../crypto/qat/qat_common/adf_gen2_config.h | 10 + drivers/crypto/qat/qat_common/adf_gen2_dc.c | 70 +++ drivers/crypto/qat/qat_common/adf_gen2_dc.h | 10 + drivers/crypto/qat/qat_common/adf_gen4_dc.c | 83 ++++ drivers/crypto/qat/qat_common/adf_gen4_dc.h | 10 + drivers/crypto/qat/qat_common/adf_init.c | 11 + drivers/crypto/qat/qat_common/adf_sriov.c | 4 + drivers/crypto/qat/qat_common/icp_qat_fw.h | 24 ++ .../crypto/qat/qat_common/icp_qat_fw_comp.h | 404 ++++++++++++++++++ drivers/crypto/qat/qat_common/icp_qat_hw.h | 66 +++ .../qat/qat_common/icp_qat_hw_20_comp.h | 164 +++++++ .../qat/qat_common/icp_qat_hw_20_comp_defs.h | 300 +++++++++++++ drivers/crypto/qat/qat_common/qat_algs.c | 208 +-------- drivers/crypto/qat/qat_common/qat_algs_send.h | 16 +- drivers/crypto/qat/qat_common/qat_bl.c | 383 +++++++++++++++++ drivers/crypto/qat/qat_common/qat_bl.h | 67 +++ drivers/crypto/qat/qat_common/qat_comp_algs.c | 344 +++++++++++++++ drivers/crypto/qat/qat_common/qat_comp_req.h | 123 ++++++ .../crypto/qat/qat_common/qat_compression.c | 297 +++++++++++++ .../crypto/qat/qat_common/qat_compression.h | 37 ++ drivers/crypto/qat/qat_common/qat_crypto.c | 120 +----- drivers/crypto/qat/qat_common/qat_crypto.h | 55 +-- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 4 + drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 2 +- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 4 + include/crypto/acompress.h | 1 + 41 files changed, 2848 insertions(+), 384 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.h create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.h create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_comp.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp_defs.h create mode 100644 drivers/crypto/qat/qat_common/qat_bl.c create mode 100644 drivers/crypto/qat/qat_common/qat_bl.h create mode 100644 drivers/crypto/qat/qat_common/qat_comp_algs.c create mode 100644 drivers/crypto/qat/qat_common/qat_comp_req.h create mode 100644 drivers/crypto/qat/qat_common/qat_compression.c create mode 100644 drivers/crypto/qat/qat_common/qat_compression.h
Signature · 1 line
2.38.1
PATCH v3 1/12 crypto: qat - relocate bufferlist logic
Move the logic that maps, unmaps and converts scatterlists into QAT bufferlists from qat_algs.c to a new module, qat_bl.
This is to allow reuse of the logic by the data compression service.
This commit does not implement any functional change.
--- drivers/crypto/qat/qat_common/Makefile | 3 +- drivers/crypto/qat/qat_common/qat_algs.c | 184 +-------------------- drivers/crypto/qat/qat_common/qat_bl.c | 194 +++++++++++++++++++++++ drivers/crypto/qat/qat_common/qat_bl.h | 17 ++ 4 files changed, 214 insertions(+), 184 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/qat_bl.c create mode 100644 drivers/crypto/qat/qat_common/qat_bl.h
drivers/crypto/qat/qat_common/Makefile +2 -1
@@ -19,7 +19,8 @@ intel_qat-objs := adf_cfg.o \ qat_asym_algs.o \ qat_algs_send.o \ qat_uclo.o \ - qat_hal.o + qat_hal.o \ + qat_bl.o intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_vf_isr.o adf_pfvf_utils.o \
drivers/crypto/qat/qat_common/qat_algs.c +1 -183
196 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_bl.c new file +194 -0
194 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_bl.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2014 - 2022 Intel Corporation */ +#ifndef QAT_BL_H +#define QAT_BL_H +#include <linux/scatterlist.h> +#include <linux/types.h> +#include "qat_crypto.h" + +void qat_alg_free_bufl (struct qat_crypto_instance *inst, +struct qat_crypto_request *qat_req); +int qat_alg_sgl_to_bufl (struct qat_crypto_instance *inst, +struct scatterlist *sgl, +struct scatterlist *sglout, +struct qat_crypto_request *qat_req, +gfp_t flags); + +#endif
Signature · 1 line
2.38.1
PATCH v3 2/12 crypto: qat - rename bufferlist functions
In reply to Giovanni CabidduRename the functions qat_alg_sgl_to_bufl() and qat_alg_free_bufl() as qat_bl_sgl_to_bufl() and qat_bl_free_bufl() after their relocation into the qat_bl module.
This commit does not implement any functional change.
--- drivers/crypto/qat/qat_common/qat_algs.c | 20 ++++++++++---------- drivers/crypto/qat/qat_common/qat_bl.c | 14 +++++++------- drivers/crypto/qat/qat_common/qat_bl.h | 14 +++++++------- 3 files changed, 24 insertions(+), 24 deletions(-)
drivers/crypto/qat/qat_common/qat_algs.c +10 -10
@@ -673,7 +673,7 @@ static void qat_aead_alg_callback(struct icp_qat_fw_la_resp *qat_resp,u8 stat_filed = qat_resp->comn_resp.comn_status;int res =0 , qat_res =ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET (stat_filed); -qat_alg_free_bufl (inst, qat_req); +qat_bl_free_bufl (inst, qat_req);if (unlikely (qat_res !=ICP_QAT_FW_COMN_STATUS_FLAG_OK )) res = -EBADMSG ; areq->base.complete (&areq->base, res);
@@ -743,7 +743,7 @@ static void qat_skcipher_alg_callback(struct icp_qat_fw_la_resp *qat_resp,u8 stat_filed = qat_resp->comn_resp.comn_status;int res =0 , qat_res =ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET (stat_filed); -qat_alg_free_bufl (inst, qat_req); +qat_bl_free_bufl (inst, qat_req);if (unlikely (qat_res !=ICP_QAT_FW_COMN_STATUS_FLAG_OK )) res = -EINVAL ;
@@ -799,7 +799,7 @@ static int qat_alg_aead_dec(struct aead_request *areq)if (cipher_len %AES_BLOCK_SIZE !=0 )return -EINVAL ; - ret =qat_alg_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f);if (unlikely (ret))return ret;
@@ -821,7 +821,7 @@ static int qat_alg_aead_dec(struct aead_request *areq) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &areq->base);if (ret == -ENOSPC ) -qat_alg_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst, qat_req);return ret; }
@@ -842,7 +842,7 @@ static int qat_alg_aead_enc(struct aead_request *areq)if (areq->cryptlen %AES_BLOCK_SIZE !=0 )return -EINVAL ; - ret =qat_alg_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f);if (unlikely (ret))return ret;
@@ -866,7 +866,7 @@ static int qat_alg_aead_enc(struct aead_request *areq) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &areq->base);if (ret == -ENOSPC ) -qat_alg_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst, qat_req);return ret; }
@@ -1027,7 +1027,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req)if (req->cryptlen ==0 )return 0 ; - ret =qat_alg_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f);if (unlikely (ret))return ret;
@@ -1048,7 +1048,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &req->base);if (ret == -ENOSPC ) -qat_alg_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst, qat_req);return ret; }
@@ -1093,7 +1093,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req)if (req->cryptlen ==0 )return 0 ; - ret =qat_alg_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f);if (unlikely (ret))return ret;
@@ -1115,7 +1115,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &req->base);if (ret == -ENOSPC ) -qat_alg_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst, qat_req);return ret; }
drivers/crypto/qat/qat_common/qat_bl.c +7 -7
@@ -10,8 +10,8 @@#include "qat_bl.h" #include "qat_crypto.h" -void qat_alg_free_bufl (struct qat_crypto_instance *inst, -struct qat_crypto_request *qat_req) +void qat_bl_free_bufl (struct qat_crypto_instance *inst, +struct qat_crypto_request *qat_req) {struct device *dev = &GET_DEV (inst->accel_dev);struct qat_alg_buf_list *bl = qat_req->buf.bl;
@@ -50,11 +50,11 @@ void qat_alg_free_bufl(struct qat_crypto_instance *inst, } } -int qat_alg_sgl_to_bufl (struct qat_crypto_instance *inst, -struct scatterlist *sgl, -struct scatterlist *sglout, -struct qat_crypto_request *qat_req, -gfp_t flags) +int qat_bl_sgl_to_bufl (struct qat_crypto_instance *inst, +struct scatterlist *sgl, +struct scatterlist *sglout, +struct qat_crypto_request *qat_req, +gfp_t flags) {struct device *dev = &GET_DEV (inst->accel_dev);int i, sg_nctr =0 ;
drivers/crypto/qat/qat_common/qat_bl.h +7 -7
@@ -6,12 +6,12 @@#include <linux/types.h> #include "qat_crypto.h" -void qat_alg_free_bufl (struct qat_crypto_instance *inst, -struct qat_crypto_request *qat_req); -int qat_alg_sgl_to_bufl (struct qat_crypto_instance *inst, -struct scatterlist *sgl, -struct scatterlist *sglout, -struct qat_crypto_request *qat_req, -gfp_t flags); +void qat_bl_free_bufl (struct qat_crypto_instance *inst, +struct qat_crypto_request *qat_req); +int qat_bl_sgl_to_bufl (struct qat_crypto_instance *inst, +struct scatterlist *sgl, +struct scatterlist *sglout, +struct qat_crypto_request *qat_req, +gfp_t flags);#endif
Signature · 1 line
2.38.1
PATCH v3 3/12 crypto: qat - change bufferlist logic interface
In reply to Giovanni CabidduThe functions qat_alg_sgl_to_bufl() and qat_alg_free_bufl() take as argument a qat_crypto_instance and a qat_crypto_request structure. These two structures are used only to get a reference to the adf_accel_dev and qat_crypto_request_buffs.
In order to reuse these functions for the compression service, change the signature so that they take adf_accel_dev and qat_crypto_request_buffs.
--- drivers/crypto/qat/qat_common/qat_algs.c | 24 +++++---- drivers/crypto/qat/qat_common/qat_bl.c | 62 ++++++++++++------------ drivers/crypto/qat/qat_common/qat_bl.h | 8 +-- 3 files changed, 49 insertions(+), 45 deletions(-)
drivers/crypto/qat/qat_common/qat_algs.c +14 -10
@@ -673,7 +673,7 @@ static void qat_aead_alg_callback(struct icp_qat_fw_la_resp *qat_resp,u8 stat_filed = qat_resp->comn_resp.comn_status;int res =0 , qat_res =ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET (stat_filed); -qat_bl_free_bufl (inst, qat_req); +qat_bl_free_bufl (inst->accel_dev, &qat_req->buf);if (unlikely (qat_res !=ICP_QAT_FW_COMN_STATUS_FLAG_OK )) res = -EBADMSG ; areq->base.complete (&areq->base, res);
@@ -743,7 +743,7 @@ static void qat_skcipher_alg_callback(struct icp_qat_fw_la_resp *qat_resp,u8 stat_filed = qat_resp->comn_resp.comn_status;int res =0 , qat_res =ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET (stat_filed); -qat_bl_free_bufl (inst, qat_req); +qat_bl_free_bufl (inst->accel_dev, &qat_req->buf);if (unlikely (qat_res !=ICP_QAT_FW_COMN_STATUS_FLAG_OK )) res = -EINVAL ;
@@ -799,7 +799,8 @@ static int qat_alg_aead_dec(struct aead_request *areq)if (cipher_len %AES_BLOCK_SIZE !=0 )return -EINVAL ; - ret =qat_bl_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, areq->src, areq->dst, + &qat_req->buf, f);if (unlikely (ret))return ret;
@@ -821,7 +822,7 @@ static int qat_alg_aead_dec(struct aead_request *areq) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &areq->base);if (ret == -ENOSPC ) -qat_bl_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst->accel_dev, &qat_req->buf);return ret; }
@@ -842,7 +843,8 @@ static int qat_alg_aead_enc(struct aead_request *areq)if (areq->cryptlen %AES_BLOCK_SIZE !=0 )return -EINVAL ; - ret =qat_bl_sgl_to_bufl (ctx->inst, areq->src, areq->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, areq->src, areq->dst, + &qat_req->buf, f);if (unlikely (ret))return ret;
@@ -866,7 +868,7 @@ static int qat_alg_aead_enc(struct aead_request *areq) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &areq->base);if (ret == -ENOSPC ) -qat_bl_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst->accel_dev, &qat_req->buf);return ret; }
@@ -1027,7 +1029,8 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req)if (req->cryptlen ==0 )return 0 ; - ret =qat_bl_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, req->src, req->dst, + &qat_req->buf, f);if (unlikely (ret))return ret;
@@ -1048,7 +1051,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &req->base);if (ret == -ENOSPC ) -qat_bl_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst->accel_dev, &qat_req->buf);return ret; }
@@ -1093,7 +1096,8 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req)if (req->cryptlen ==0 )return 0 ; - ret =qat_bl_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req, f); + ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, req->src, req->dst, + &qat_req->buf, f);if (unlikely (ret))return ret;
@@ -1115,7 +1119,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req) ret =qat_alg_send_sym_message (qat_req, ctx->inst, &req->base);if (ret == -ENOSPC ) -qat_bl_free_bufl (ctx->inst, qat_req); +qat_bl_free_bufl (ctx->inst->accel_dev, &qat_req->buf);return ret; }
drivers/crypto/qat/qat_common/qat_bl.c +31 -31
140 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_bl.h +4 -4
@@ -6,12 +6,12 @@#include <linux/types.h> #include "qat_crypto.h" -void qat_bl_free_bufl (struct qat_crypto_instance *inst, -struct qat_crypto_request *qat_req); -int qat_bl_sgl_to_bufl (struct qat_crypto_instance *inst, +void qat_bl_free_bufl (struct adf_accel_dev *accel_dev, +struct qat_crypto_request_buffs *buf); +int qat_bl_sgl_to_bufl (struct adf_accel_dev *accel_dev,struct scatterlist *sgl,struct scatterlist *sglout, -struct qat_crypto_request *qat_req, +struct qat_crypto_request_buffs *buf,gfp_t flags);#endif
Signature · 1 line
2.38.1
PATCH v3 4/12 crypto: qat - generalize crypto request buffers
In reply to Giovanni CabidduThe structure qat_crypto_request_buffs which contains the source and destination buffer lists and correspondent sizes and dma addresses is also required for the compression service.
Rename it as qat_request_buffs and move it to qat_bl.h.
--- drivers/crypto/qat/qat_common/qat_bl.c | 4 +-- drivers/crypto/qat/qat_common/qat_bl.h | 38 ++++++++++++++++++++-- drivers/crypto/qat/qat_common/qat_crypto.h | 36 ++------------------ 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/crypto/qat/qat_common/qat_bl.c +2 -2
@@ -11,7 +11,7 @@#include "qat_crypto.h" void qat_bl_free_bufl (struct adf_accel_dev *accel_dev, -struct qat_crypto_request_buffs *buf) +struct qat_request_buffs *buf) {struct device *dev = &GET_DEV (accel_dev);struct qat_alg_buf_list *bl = buf->bl;
@@ -53,7 +53,7 @@ void qat_bl_free_bufl(struct adf_accel_dev *accel_dev,int qat_bl_sgl_to_bufl (struct adf_accel_dev *accel_dev,struct scatterlist *sgl,struct scatterlist *sglout, -struct qat_crypto_request_buffs *buf, +struct qat_request_buffs *buf,gfp_t flags) {struct device *dev = &GET_DEV (accel_dev);
drivers/crypto/qat/qat_common/qat_bl.h +35 -3
@@ -4,14 +4,46 @@#define QAT_BL_H #include <linux/scatterlist.h> #include <linux/types.h> -#include "qat_crypto.h" + +#define QAT_MAX_BUFF_DESC 4 + +struct qat_alg_buf { +u32 len; +u32 resrvd; +u64 addr; +} __packed; + +struct qat_alg_buf_list { +u64 resrvd; +u32 num_bufs; +u32 num_mapped_bufs; +struct qat_alg_buf bufers[]; +} __packed; + +struct qat_alg_fixed_buf_list { +struct qat_alg_buf_list sgl_hdr; +struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC ]; +} __packed__aligned(64) ; + +struct qat_request_buffs { +struct qat_alg_buf_list *bl; +dma_addr_t blp; +struct qat_alg_buf_list *blout; +dma_addr_t bloutp; +size_t sz; +size_t sz_out; +bool sgl_src_valid; +bool sgl_dst_valid; +struct qat_alg_fixed_buf_list sgl_src; +struct qat_alg_fixed_buf_list sgl_dst; +};void qat_bl_free_bufl (struct adf_accel_dev *accel_dev, -struct qat_crypto_request_buffs *buf); +struct qat_request_buffs *buf);int qat_bl_sgl_to_bufl (struct adf_accel_dev *accel_dev,struct scatterlist *sgl,struct scatterlist *sglout, -struct qat_crypto_request_buffs *buf, +struct qat_request_buffs *buf,gfp_t flags);#endif
drivers/crypto/qat/qat_common/qat_crypto.h +2 -34
@@ -8,6 +8,7 @@#include <linux/slab.h> #include "adf_accel_devices.h" #include "icp_qat_fw_la.h" +#include "qat_bl.h" struct qat_instance_backlog {struct list_head list;
@@ -35,39 +36,6 @@ struct qat_crypto_instance {struct qat_instance_backlog backlog; }; -#define QAT_MAX_BUFF_DESC 4 - -struct qat_alg_buf { -u32 len; -u32 resrvd; -u64 addr; -} __packed; - -struct qat_alg_buf_list { -u64 resrvd; -u32 num_bufs; -u32 num_mapped_bufs; -struct qat_alg_buf bufers[]; -} __packed; - -struct qat_alg_fixed_buf_list { -struct qat_alg_buf_list sgl_hdr; -struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC ]; -} __packed__aligned(64) ; - -struct qat_crypto_request_buffs { -struct qat_alg_buf_list *bl; -dma_addr_t blp; -struct qat_alg_buf_list *blout; -dma_addr_t bloutp; -size_t sz; -size_t sz_out; -bool sgl_src_valid; -bool sgl_dst_valid; -struct qat_alg_fixed_buf_list sgl_src; -struct qat_alg_fixed_buf_list sgl_dst; -}; -struct qat_crypto_request ;struct qat_crypto_request {
@@ -80,7 +48,7 @@ struct qat_crypto_request {struct aead_request *aead_req;struct skcipher_request *skcipher_req; }; -struct qat_crypto_request_buffs buf; +struct qat_request_buffs buf;void (*cb)(struct icp_qat_fw_la_resp *resp,struct qat_crypto_request *req);union {
Signature · 1 line
2.38.1
PATCH v3 5/12 crypto: qat - extend buffer list interface
In reply to Giovanni CabidduThe compression service requires an additional pre-allocated buffer for each destination scatter list.
Extend the function qat_alg_sgl_to_bufl() to take an additional structure that contains the dma address and the size of the extra buffer which will be appended in the destination FW SGL.
The logic that unmaps buffers in qat_alg_free_bufl() has been changed to start unmapping from buffer 0 instead of skipping the initial buffers num_buff - num_mapped_bufs as that functionality was not used in the code.
--- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++-- drivers/crypto/qat/qat_common/qat_bl.c | 58 ++++++++++++++++++------ drivers/crypto/qat/qat_common/qat_bl.h | 6 +++ 3 files changed, 54 insertions(+), 18 deletions(-)
drivers/crypto/qat/qat_common/qat_algs.c +4 -4
@@ -800,7 +800,7 @@ static int qat_alg_aead_dec(struct aead_request *areq)return -EINVAL ; ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, areq->src, areq->dst, - &qat_req->buf, f); + &qat_req->buf,NULL , f);if (unlikely (ret))return ret;
@@ -844,7 +844,7 @@ static int qat_alg_aead_enc(struct aead_request *areq)return -EINVAL ; ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, areq->src, areq->dst, - &qat_req->buf, f); + &qat_req->buf,NULL , f);if (unlikely (ret))return ret;
@@ -1030,7 +1030,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req)return 0 ; ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, req->src, req->dst, - &qat_req->buf, f); + &qat_req->buf,NULL , f);if (unlikely (ret))return ret;
@@ -1097,7 +1097,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req)return 0 ; ret =qat_bl_sgl_to_bufl (ctx->inst->accel_dev, req->src, req->dst, - &qat_req->buf, f); + &qat_req->buf,NULL , f);if (unlikely (ret))return ret;
drivers/crypto/qat/qat_common/qat_bl.c +44 -14
111 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_bl.h +6 -0
@@ -38,12 +38,18 @@ struct qat_request_buffs { struct qat_alg_fixed_buf_list sgl_dst; }; +struct qat_sgl_to_bufl_params { +dma_addr_t extra_dst_buff; +size_t sz_extra_dst_buff; +}; +void qat_bl_free_bufl (struct adf_accel_dev *accel_dev,struct qat_request_buffs *buf);int qat_bl_sgl_to_bufl (struct adf_accel_dev *accel_dev,struct scatterlist *sgl,struct scatterlist *sglout,struct qat_request_buffs *buf, +struct qat_sgl_to_bufl_params *params,gfp_t flags);#endif
Signature · 1 line
2.38.1
PATCH v3 6/12 crypto: qat - relocate backlog related structures
In reply to Giovanni CabidduMove the structures qat_instance_backlog and qat_alg_req from qat_crypto.h to qat_algs_send.h since they are not unique to crypto. Both structures will be used by the compression service to support requests with the CRYPTO_TFM_REQ_MAY_BACKLOG flag set.
--- drivers/crypto/qat/qat_common/qat_algs_send.h | 16 +++++++++++++++- drivers/crypto/qat/qat_common/qat_crypto.h | 14 +------------- 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/crypto/qat/qat_common/qat_algs_send.h +15 -1
@@ -3,7 +3,21 @@#ifndef QAT_ALGS_SEND_H #define QAT_ALGS_SEND_H -#include "qat_crypto.h" +#include <linux/list.h> +#include "adf_transport_internal.h" + +struct qat_instance_backlog { +struct list_head list; +spinlock_t lock;/* protects backlog list */ +}; + +struct qat_alg_req { +u32 *fw_req; +struct adf_etr_ring_data *tx_ring; +struct crypto_async_request *base; +struct list_head list; +struct qat_instance_backlog *backlog; +};int qat_alg_send_message (struct qat_alg_req *req);void qat_alg_send_backlog (struct qat_instance_backlog *backlog);
drivers/crypto/qat/qat_common/qat_crypto.h +1 -13
@@ -8,21 +8,9 @@#include <linux/slab.h> #include "adf_accel_devices.h" #include "icp_qat_fw_la.h" +#include "qat_algs_send.h" #include "qat_bl.h" -struct qat_instance_backlog { -struct list_head list; -spinlock_t lock;/* protects backlog list */ -}; - -struct qat_alg_req { -u32 *fw_req; -struct adf_etr_ring_data *tx_ring; -struct crypto_async_request *base; -struct list_head list; -struct qat_instance_backlog *backlog; -}; -struct qat_crypto_instance {struct adf_etr_ring_data *sym_tx;struct adf_etr_ring_data *sym_rx;
Signature · 1 line
2.38.1
PATCH v3 7/12 crypto: qat - relocate qat_algs_alloc_flags()
In reply to Giovanni CabidduMove qat_algs_alloc_flags() from qat_crypto.h to qat_bl.h as this will be used also by the compression logic.
--- drivers/crypto/qat/qat_common/qat_bl.h | 6 ++++++ drivers/crypto/qat/qat_common/qat_crypto.h | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/qat_bl.h +6 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2022 Intel Corporation */ #ifndef QAT_BL_H #define QAT_BL_H +#include <linux/crypto.h> #include <linux/scatterlist.h> #include <linux/types.h>
@@ -52,4 +53,9 @@ int qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev,struct qat_sgl_to_bufl_params *params, gfp_t flags); +static inline gfp_t qat_algs_alloc_flags (struct crypto_async_request *req) +{ +return req->flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC ; +} +#endif
drivers/crypto/qat/qat_common/qat_crypto.h +0 -5
@@ -65,9 +65,4 @@ static inline bool adf_hw_dev_has_crypto(struct adf_accel_dev *accel_dev) return true; } -static inline gfp_t qat_algs_alloc_flags (struct crypto_async_request *req) -{ -return req->flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC ; -} -#endif
Signature · 1 line
2.38.1
PATCH v3 8/12 crypto: qat - rename and relocate GEN2 config function
In reply to Giovanni CabidduRename qat_crypto_dev_config() in adf_gen2_dev_config() and relocate it to the newly created file adf_gen2_config.c.
This function is specific to QAT GEN2 devices and will be used also to configure the compression service.
In addition change the drivers to use the dev_config() in the hardware data structure (which for GEN2 devices now points to adf_gen2_dev_config()), for consistency.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 2 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 2 +- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 2 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 2 + drivers/crypto/qat/qat_c62x/adf_drv.c | 2 +- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 2 + drivers/crypto/qat/qat_common/Makefile | 1 + .../crypto/qat/qat_common/adf_common_drv.h | 1 - .../crypto/qat/qat_common/adf_gen2_config.c | 131 ++++++++++++++++++ .../crypto/qat/qat_common/adf_gen2_config.h | 10 ++ drivers/crypto/qat/qat_common/qat_crypto.c | 120 +--------------- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 + drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 2 +- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 2 + 14 files changed, 158 insertions(+), 123 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.h
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_c3xxx_hw_data.h"
@@ -124,6 +125,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; hw_data->disable_iov = adf_disable_sriov; + hw_data->dev_config = adf_gen2_dev_config;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_c3xxx/adf_drv.c +1 -1
@@ -201,7 +201,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable_aer; } - ret =qat_crypto_dev_config (accel_dev); + ret = hw_data->dev_config (accel_dev);if (ret) goto out_err_disable_aer;
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -86,6 +87,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->dev_class->instances++; + hw_data->dev_config = adf_gen2_dev_config;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_c62x_hw_data.h"
@@ -126,6 +127,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->reset_device = adf_reset_flr; hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer; hw_data->disable_iov = adf_disable_sriov; + hw_data->dev_config = adf_gen2_dev_config;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_c62x/adf_drv.c +1 -1
@@ -201,7 +201,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable_aer; } - ret =qat_crypto_dev_config (accel_dev); + ret = hw_data->dev_config (accel_dev);if (ret) goto out_err_disable_aer;
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -86,6 +87,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->dev_class->instances++; + hw_data->dev_config = adf_gen2_dev_config;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
drivers/crypto/qat/qat_common/Makefile +1 -0
@@ -12,6 +12,7 @@ intel_qat-objs := adf_cfg.o \ adf_hw_arbiter.o \ adf_sysfs.o \ adf_gen2_hw_data.o \ + adf_gen2_config.o \ adf_gen4_hw_data.o \ adf_gen4_pm.o \ qat_crypto.o \
drivers/crypto/qat/qat_common/adf_common_drv.h +0 -1
@@ -110,7 +110,6 @@ int adf_init_etr_data(struct adf_accel_dev *accel_dev);void adf_cleanup_etr_data (struct adf_accel_dev *accel_dev);int qat_crypto_register (void );int qat_crypto_unregister (void ); -int qat_crypto_dev_config (struct adf_accel_dev *accel_dev);int qat_crypto_vf_dev_config (struct adf_accel_dev *accel_dev);struct qat_crypto_instance *qat_crypto_get_instance_node (int node);void qat_crypto_put_instance (struct qat_crypto_instance *inst);
drivers/crypto/qat/qat_common/adf_gen2_config.c new file +131 -0
131 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_config.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2022 Intel Corporation */ +#ifndef ADF_GEN2_CONFIG_H_ +#define ADF_GEN2_CONFIG_H_ + +#include "adf_accel_devices.h" + +int adf_gen2_dev_config (struct adf_accel_dev *accel_dev); + +#endif
drivers/crypto/qat/qat_common/qat_crypto.c +1 -119
134 lines not on this page · raw message
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_dh895xcc_hw_data.h"
@@ -234,6 +235,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->enable_ints = adf_gen2_enable_ints; hw_data->reset_device = adf_reset_sbr; hw_data->disable_iov = adf_disable_sriov; + hw_data->dev_config = adf_gen2_dev_config;adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops); hw_data->pfvf_ops.enable_vf2pf_interrupts = enable_vf2pf_interrupts;
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +1 -1
@@ -201,7 +201,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable_aer; } - ret =qat_crypto_dev_config (accel_dev); + ret = hw_data->dev_config (accel_dev);if (ret) goto out_err_disable_aer;
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +2 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2015 - 2021 Intel Corporation */ #include <adf_accel_devices.h> #include <adf_common_drv.h> +#include <adf_gen2_config.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -86,6 +87,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) hw_data->get_sku = get_sku; hw_data->enable_ints = adf_vf_void_noop; hw_data->dev_class->instances++; + hw_data->dev_config = adf_gen2_dev_config;adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops);
Signature · 1 line
2.38.1
PATCH v3 9/12 crypto: qat - expose deflate through acomp api for QAT GEN2
In reply to Giovanni CabidduAdd infrastructure for implementing the acomp APIs in the QAT driver and expose the deflate algorithm for QAT GEN2 devices.
This adds
(1) the compression service which includes logic to create, allocate and handle compression instances;
(2) logic to create configuration entries at probe time for the compression instances;
(3) updates to the firmware API for allowing the compression service; and;
(4) a back-end for deflate that implements the acomp api for QAT GEN2 devices.
The implementation configures the device to produce data compressed statically, optimized for throughput over compression ratio.
--- drivers/crypto/qat/qat_4xxx/adf_drv.c | 6 + .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 2 + .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 2 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 2 + .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 2 + drivers/crypto/qat/qat_common/Makefile | 3 + .../crypto/qat/qat_common/adf_accel_devices.h | 14 + .../crypto/qat/qat_common/adf_cfg_strings.h | 1 + .../crypto/qat/qat_common/adf_common_drv.h | 8 + drivers/crypto/qat/qat_common/adf_ctl_drv.c | 6 + .../crypto/qat/qat_common/adf_gen2_config.c | 99 ++++- drivers/crypto/qat/qat_common/adf_gen2_dc.c | 70 +++ drivers/crypto/qat/qat_common/adf_gen2_dc.h | 10 + drivers/crypto/qat/qat_common/adf_init.c | 11 + drivers/crypto/qat/qat_common/adf_sriov.c | 4 + drivers/crypto/qat/qat_common/icp_qat_fw.h | 24 ++ .../crypto/qat/qat_common/icp_qat_fw_comp.h | 404 ++++++++++++++++++ drivers/crypto/qat/qat_common/icp_qat_hw.h | 66 +++ drivers/crypto/qat/qat_common/qat_comp_algs.c | 274 ++++++++++++ drivers/crypto/qat/qat_common/qat_comp_req.h | 113 +++++ .../crypto/qat/qat_common/qat_compression.c | 297 +++++++++++++ .../crypto/qat/qat_common/qat_compression.h | 37 ++ .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 + .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 2 + 24 files changed, 1447 insertions(+), 12 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_comp.h create mode 100644 drivers/crypto/qat/qat_common/qat_comp_algs.c create mode 100644 drivers/crypto/qat/qat_common/qat_comp_req.h create mode 100644 drivers/crypto/qat/qat_common/qat_compression.c create mode 100644 drivers/crypto/qat/qat_common/qat_compression.h
drivers/crypto/qat/qat_4xxx/adf_drv.c +6 -0
@@ -155,6 +155,12 @@ int adf_crypto_dev_config(struct adf_accel_dev *accel_dev)if (ret) goto err; + val =0 ; + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC ,ADF_NUM_DC , + &val,ADF_DEC ); +if (ret) + goto err; +set_bit (ADF_STATUS_CONFIGURED , &accel_dev->status);return 0 ; err:
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_c3xxx_hw_data.h"
@@ -129,6 +130,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data)adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_c3xxx (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -91,6 +92,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_c3xxxiov (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_c62x_hw_data.h"
@@ -131,6 +132,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data)adf_gen2_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_c62x (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -91,6 +92,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_c62xiov (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_common/Makefile +3 -0
@@ -15,7 +15,10 @@ intel_qat-objs := adf_cfg.o \ adf_gen2_config.o \ adf_gen4_hw_data.o \ adf_gen4_pm.o \ + adf_gen2_dc.o \ qat_crypto.o \ + qat_compression.o \ + qat_comp_algs.o \ qat_algs.o \ qat_asym_algs.o \ qat_algs_send.o \
drivers/crypto/qat/qat_common/adf_accel_devices.h +14 -0
@@ -163,6 +163,10 @@ struct adf_pfvf_ops { u32 pfvf_offset, u8 compat_ver); }; +struct adf_dc_ops { +void (*build_deflate_ctx)(void *ctx); +}; +struct adf_hw_device_data {struct adf_hw_device_class *dev_class;u32 (*get_accel_mask)(struct adf_hw_device_data *self);
@@ -202,6 +206,7 @@ struct adf_hw_device_data {int (*dev_config)(struct adf_accel_dev *accel_dev);struct adf_pfvf_ops pfvf_ops;struct adf_hw_csr_ops csr_ops; +struct adf_dc_ops dc_ops;const char *fw_name;const char *fw_mmp_name;u32 fuses;
@@ -247,6 +252,7 @@ struct adf_hw_device_data {#define GET_MAX_ACCELENGINES (accel_dev) (GET_HW_DATA(accel_dev)->num_engines)#define GET_CSR_OPS (accel_dev) (&(accel_dev)->hw_device->csr_ops)#define GET_PFVF_OPS (accel_dev) (&(accel_dev)->hw_device->pfvf_ops) +#define GET_DC_OPS (accel_dev) (&(accel_dev)->hw_device->dc_ops)#define accel_to_pci_dev (accel_ptr) accel_ptr->accel_pci_dev.pci_devstruct adf_admin_comms ;
@@ -266,13 +272,21 @@ struct adf_accel_vf_info {u8 vf_compat_ver; }; +struct adf_dc_data { +u8 *ovf_buff; +size_t ovf_buff_sz; +dma_addr_t ovf_buff_p; +}; +struct adf_accel_dev {struct adf_etr_data *transport;struct adf_hw_device_data *hw_device;struct adf_cfg_device_data *cfg;struct adf_fw_loader_data *fw_loader;struct adf_admin_comms *admin; +struct adf_dc_data *dc_data;struct list_head crypto_list; +struct list_head compression_list;unsigned long status;atomic_t ref_count;struct dentry *debugfs_dir;
drivers/crypto/qat/qat_common/adf_cfg_strings.h +1 -0
@@ -20,6 +20,7 @@#define ADF_ETRMGR_BANK "Bank"#define ADF_RING_SYM_BANK_NUM "BankSymNumber"#define ADF_RING_ASYM_BANK_NUM "BankAsymNumber" +#define ADF_RING_DC_BANK_NUM "BankDcNumber"#define ADF_CY "Cy"#define ADF_DC "Dc"#define ADF_CFG_DC "dc"
drivers/crypto/qat/qat_common/adf_common_drv.h +8 -0
@@ -120,6 +120,14 @@ 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); +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 ); +void qat_comp_alg_callback (void *resp); +int adf_isr_resource_alloc (struct adf_accel_dev *accel_dev);void adf_isr_resource_free (struct adf_accel_dev *accel_dev);int adf_vf_isr_resource_alloc (struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_ctl_drv.c +6 -0
@@ -438,8 +438,13 @@ static int __init adf_register_ctl_device_driver(void)if (qat_crypto_register ()) goto err_crypto_register; +if (qat_compression_register ()) + goto err_compression_register; +return 0 ; +err_compression_register: +qat_crypto_unregister (); err_crypto_register:adf_exit_vf_wq (); err_vf_wq:
@@ -463,6 +468,7 @@ static void __exit adf_unregister_ctl_device_driver(void)adf_exit_vf_wq ();adf_exit_pf_wq ();qat_crypto_unregister (); +qat_compression_unregister ();adf_clean_vf_map (false);mutex_destroy (&adf_ctl_lock); }
drivers/crypto/qat/qat_common/adf_gen2_config.c +87 -12
123 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_dc.c new file +70 -0
70 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_dc.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2022 Intel Corporation */ +#ifndef ADF_GEN2_DC_H +#define ADF_GEN2_DC_H + +#include "adf_accel_devices.h" + +void adf_gen2_init_dc_ops (struct adf_dc_ops *dc_ops); + +#endif /* ADF_GEN2_DC_H */
drivers/crypto/qat/qat_common/adf_init.c +11 -0
@@ -209,6 +209,14 @@ int adf_dev_start(struct adf_accel_dev *accel_dev)clear_bit (ADF_STATUS_STARTED , &accel_dev->status);return -EFAULT ; } + +if (!list_empty (&accel_dev->compression_list) &&qat_comp_algs_register ()) { +dev_err (&GET_DEV (accel_dev), +"Failed to register compression algs\n" ); +set_bit (ADF_STATUS_STARTING , &accel_dev->status); +clear_bit (ADF_STATUS_STARTED , &accel_dev->status); +return -EFAULT ; + }return 0 ; }EXPORT_SYMBOL_GPL (adf_dev_start);
@@ -242,6 +250,9 @@ void adf_dev_stop(struct adf_accel_dev *accel_dev)qat_asym_algs_unregister (); } +if (!list_empty (&accel_dev->compression_list)) +qat_comp_algs_unregister (); +list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (!test_bit (accel_dev->accel_id, service->start_status))
drivers/crypto/qat/qat_common/adf_sriov.c +4 -0
@@ -170,6 +170,10 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC ,ADF_NUM_CY , (void *)&val,ADF_DEC ))return -EFAULT ; + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC ,ADF_NUM_DC , + &val,ADF_DEC ); +if (ret) +return ret;set_bit (ADF_STATUS_CONFIGURED , &accel_dev->status);
drivers/crypto/qat/qat_common/icp_qat_fw.h +24 -0
@@ -116,6 +116,10 @@ struct icp_qat_fw_comn_resp {#define ICP_QAT_FW_COMN_VALID_FLAG_BITPOS 7#define ICP_QAT_FW_COMN_VALID_FLAG_MASK 0x1#define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK 0x7F +#define ICP_QAT_FW_COMN_CNV_FLAG_BITPOS 6 +#define ICP_QAT_FW_COMN_CNV_FLAG_MASK 0x1 +#define ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS 5 +#define ICP_QAT_FW_COMN_CNVNR_FLAG_MASK 0x1#define ICP_QAT_FW_COMN_OV_SRV_TYPE_GET (icp_qat_fw_comn_req_hdr_t) \ icp_qat_fw_comn_req_hdr_t.service_type
@@ -132,6 +136,26 @@ struct icp_qat_fw_comn_resp {#define ICP_QAT_FW_COMN_HDR_VALID_FLAG_GET (hdr_t) \ ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_t.hdr_flags) +#define ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET (hdr_flags) \ + QAT_FIELD_GET(hdr_flags, \ + ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS, \ + ICP_QAT_FW_COMN_CNVNR_FLAG_MASK) + +#define ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_SET (hdr_t, val) \ + QAT_FIELD_SET((hdr_t.hdr_flags), (val), \ + ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS, \ + ICP_QAT_FW_COMN_CNVNR_FLAG_MASK) + +#define ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET (hdr_flags) \ + QAT_FIELD_GET(hdr_flags, \ + ICP_QAT_FW_COMN_CNV_FLAG_BITPOS, \ + ICP_QAT_FW_COMN_CNV_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, \ + ICP_QAT_FW_COMN_CNV_FLAG_MASK) +#define ICP_QAT_FW_COMN_HDR_VALID_FLAG_SET (hdr_t, val) \ ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val)
drivers/crypto/qat/qat_common/icp_qat_fw_comp.h new file +404 -0
404 lines not on this page · raw message
drivers/crypto/qat/qat_common/icp_qat_hw.h +66 -0
70 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_comp_algs.c new file +274 -0
274 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_comp_req.h new file +113 -0
113 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_compression.c new file +297 -0
297 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_compression.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2022 Intel Corporation */ +#ifndef _QAT_COMPRESSION_H_ +#define _QAT_COMPRESSION_H_ + +#include <linux/list.h> +#include <linux/types.h> +#include "adf_accel_devices.h" +#include "qat_algs_send.h" + +#define QAT_COMP_MAX_SKID 4096 + +struct qat_compression_instance { +struct adf_etr_ring_data *dc_tx; +struct adf_etr_ring_data *dc_rx; +struct adf_accel_dev *accel_dev; +struct list_head list; +unsigned long state; +int id; +atomic_t refctr; +struct qat_instance_backlog backlog; +struct adf_dc_data *dc_data; +void (*build_deflate_ctx)(void *ctx); +}; + +static inline bool adf_hw_dev_has_compression (struct adf_accel_dev *accel_dev) +{ +struct adf_hw_device_data *hw_device = accel_dev->hw_device; +u32 mask = ~hw_device->accel_capabilities_mask; + +if (mask &ADF_ACCEL_CAPABILITIES_COMPRESSION ) +return false; + +return true; +} + +#endif
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include "adf_dh895xcc_hw_data.h"
@@ -242,6 +243,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->pfvf_ops.disable_all_vf2pf_interrupts = disable_all_vf2pf_interrupts; hw_data->pfvf_ops.disable_pending_vf2pf_interrupts = disable_pending_vf2pf_interrupts;adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_dh895xcc (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +2 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> +#include <adf_gen2_dc.h> #include <adf_gen2_hw_data.h> #include <adf_gen2_pfvf.h> #include <adf_pfvf_vf_msg.h>
@@ -91,6 +92,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)adf_devmgr_update_class_index (hw_data);adf_gen2_init_vf_pfvf_ops (&hw_data->pfvf_ops);adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); +adf_gen2_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_dh895xcciov (struct adf_hw_device_data *hw_data)
Signature · 1 line
2.38.1
PATCH v3 10/12 crypto: qat - enable deflate for QAT GEN4
In reply to Giovanni CabidduEnable deflate for QAT GEN4 devices.
This adds
(1) logic to create configuration entries at probe time for the compression instances for QAT GEN4 devices;
(2) the implementation of QAT GEN4 specific compression operations, required since the creation of the compression request template is different between GEN2 and GEN4; and
(3) updates to the firmware API related to compression for GEN4.
The implementation configures the device to produce data compressed dynamically, optimized for throughput over compression ratio.
--- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 4 +- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.h | 2 +- drivers/crypto/qat/qat_4xxx/adf_drv.c | 139 +++++++- drivers/crypto/qat/qat_common/Makefile | 1 + drivers/crypto/qat/qat_common/adf_gen4_dc.c | 83 +++++ drivers/crypto/qat/qat_common/adf_gen4_dc.h | 10 + .../qat/qat_common/icp_qat_hw_20_comp.h | 164 ++++++++++ .../qat/qat_common/icp_qat_hw_20_comp_defs.h | 300 ++++++++++++++++++ 8 files changed, 689 insertions(+), 14 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp_defs.h
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +3 -1
@@ -4,6 +4,7 @@#include <adf_accel_devices.h> #include <adf_cfg.h> #include <adf_common_drv.h> +#include <adf_gen4_dc.h> #include <adf_gen4_hw_data.h> #include <adf_gen4_pfvf.h> #include <adf_gen4_pm.h>
@@ -357,10 +358,11 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data) hw_data->ring_pair_reset = adf_gen4_ring_pair_reset; hw_data->enable_pm = adf_gen4_enable_pm; hw_data->handle_pm_interrupt = adf_gen4_handle_pm_interrupt; - hw_data->dev_config = adf_crypto_dev_config; + hw_data->dev_config = adf_gen4_dev_config;adf_gen4_init_hw_csr_ops (&hw_data->csr_ops);adf_gen4_init_pf_pfvf_ops (&hw_data->pfvf_ops); +adf_gen4_init_dc_ops (&hw_data->dc_ops); }void adf_clean_hw_data_4xxx (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.h +1 -1
@@ -70,6 +70,6 @@ enum icp_qat_4xxx_slice_mask {void adf_init_hw_data_4xxx (struct adf_hw_device_data *hw_data);void adf_clean_hw_data_4xxx (struct adf_hw_device_data *hw_data); -int adf_crypto_dev_config (struct adf_accel_dev *accel_dev); +int adf_gen4_dev_config (struct adf_accel_dev *accel_dev);#endif
drivers/crypto/qat/qat_4xxx/adf_drv.c +127 -12
177 lines not on this page · raw message
drivers/crypto/qat/qat_common/Makefile +1 -0
@@ -16,6 +16,7 @@ intel_qat-objs := adf_cfg.o \ adf_gen4_hw_data.o \ adf_gen4_pm.o \ adf_gen2_dc.o \ + adf_gen4_dc.o \ qat_crypto.o \ qat_compression.o \ qat_comp_algs.o \
drivers/crypto/qat/qat_common/adf_gen4_dc.c new file +83 -0
83 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen4_dc.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2022 Intel Corporation */ +#ifndef ADF_GEN4_DC_H +#define ADF_GEN4_DC_H + +#include "adf_accel_devices.h" + +void adf_gen4_init_dc_ops (struct adf_dc_ops *dc_ops); + +#endif /* ADF_GEN4_DC_H */
drivers/crypto/qat/qat_common/icp_qat_hw_20_comp.h new file +164 -0
164 lines not on this page · raw message
drivers/crypto/qat/qat_common/icp_qat_hw_20_comp_defs.h new file +300 -0
300 lines not on this page · raw message
Signature · 1 line
2.38.1
PATCH v3 11/12 crypto: acomp - define max size for destination
In reply to Giovanni CabidduThe acomp API allows to send requests with a NULL destination buffer. In this case, the algorithm implementation needs to allocate the destination scatter list, perform the operation and return the buffer to the user. For decompression, data is likely to expand and be bigger than the allocated buffer.
Define the maximum size (128KB) that acomp implementations will allocate for decompression operations as destination buffer when they receive a request with a NULL destination buffer.
--- include/crypto/acompress.h | 1 + 1 file changed, 1 insertion(+)
include/crypto/acompress.h +1 -0
@@ -11,6 +11,7 @@#include <linux/crypto.h> #define CRYPTO_ACOMP_ALLOC_OUTPUT 0x00000001 +#define CRYPTO_ACOMP_DST_MAX 131072/** * struct acomp_req - asynchronous (de)compression request
Signature · 1 line
2.38.1
PATCH v3 12/12 crypto: qat - add resubmit logic for decompression
In reply to Giovanni CabidduThe acomp API allows to send requests with a NULL destination buffer. In this case, the algorithm implementation needs to allocate the destination scatter list, perform the operation and return the buffer to the user. For decompression, data is likely to expand and be bigger than the allocated buffer.
This implements a re-submission mechanism for decompression requests that is triggered if the destination buffer, allocated by the driver, is not sufficiently big to store the output from decompression.
If an overflow is detected when processing the callback for a decompression request with a NULL destination buffer, a workqueue is scheduled. This allocates a new scatter list of size CRYPTO_ACOMP_DST_MAX, now 128KB, creates a new firmware scatter list and resubmits the job to the hardware accelerator.
--- drivers/crypto/qat/qat_common/qat_bl.c | 159 ++++++++++++++++++ drivers/crypto/qat/qat_common/qat_bl.h | 6 + drivers/crypto/qat/qat_common/qat_comp_algs.c | 70 ++++++++ drivers/crypto/qat/qat_common/qat_comp_req.h | 10 ++ 4 files changed, 245 insertions(+)
drivers/crypto/qat/qat_common/qat_bl.c +159 -0
@@ -222,3 +222,162 @@ int qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev, extra_dst_buff, sz_extra_dst_buff, flags); } + +static void qat_bl_sgl_unmap (struct adf_accel_dev *accel_dev, +struct qat_alg_buf_list *bl) +{ +struct device *dev = &GET_DEV (accel_dev); +int n = bl->num_bufs; +int i; + +for (i =0 ; i < n; i++) +if (!dma_mapping_error (dev, bl->bufers[i].addr)) +dma_unmap_single (dev, bl->bufers[i].addr, + bl->bufers[i].len,DMA_FROM_DEVICE ); +} + +static int qat_bl_sgl_map (struct adf_accel_dev *accel_dev, +struct scatterlist *sgl, +struct qat_alg_buf_list **bl) +{ +struct device *dev = &GET_DEV (accel_dev); +struct qat_alg_buf_list *bufl; +int node =dev_to_node (dev); +struct scatterlist *sg; +int n, i, sg_nctr; +size_t sz; + + n =sg_nents (sgl); + sz =struct_size (bufl, bufers, n); + bufl =kzalloc_node (sz,GFP_KERNEL , node); +if (unlikely (!bufl)) +return -ENOMEM ; + +for (i =0 ; i < n; i++) + bufl->bufers[i].addr =DMA_MAPPING_ERROR ; + + sg_nctr =0 ; +for_each_sg (sgl, sg, n, i) { +int y = sg_nctr; + +if (!sg->length) +continue ; + + bufl->bufers[y].addr =dma_map_single (dev,sg_virt (sg), + sg->length, +DMA_FROM_DEVICE ); + bufl->bufers[y].len = sg->length; +if (unlikely (dma_mapping_error (dev, bufl->bufers[y].addr))) + goto err_map; + sg_nctr++; + } + bufl->num_bufs = sg_nctr; + bufl->num_mapped_bufs = sg_nctr; + + *bl = bufl; + +return 0 ; + +err_map: +for (i =0 ; i < n; i++) +if (!dma_mapping_error (dev, bufl->bufers[i].addr)) +dma_unmap_single (dev, bufl->bufers[i].addr, + bufl->bufers[i].len, +DMA_FROM_DEVICE ); +kfree (bufl); + *bl =NULL ; + +return -ENOMEM ; +} + +static void qat_bl_sgl_free_unmap (struct adf_accel_dev *accel_dev, +struct scatterlist *sgl, +struct qat_alg_buf_list *bl, +bool free_bl) +{ +if (bl) { +qat_bl_sgl_unmap (accel_dev, bl); + +if (free_bl) +kfree (bl); + } +if (sgl) +sgl_free (sgl); +} + +static int qat_bl_sgl_alloc_map (struct adf_accel_dev *accel_dev, +struct scatterlist **sgl, +struct qat_alg_buf_list **bl, +unsigned int dlen, +gfp_t gfp) +{ +struct scatterlist *dst; +int ret; + + dst =sgl_alloc (dlen, gfp,NULL ); +if (!dst) { +dev_err (&GET_DEV (accel_dev),"sg_alloc failed\n" ); +return -ENOMEM ; + } + + ret =qat_bl_sgl_map (accel_dev, dst, bl); +if (ret) + goto err; + + *sgl = dst; + +return 0 ; + +err: +sgl_free (dst); + *sgl =NULL ; +return ret; +} + +int qat_bl_realloc_map_new_dst (struct adf_accel_dev *accel_dev, +struct scatterlist **sg, +unsigned int dlen, +struct qat_request_buffs *qat_bufs, +gfp_t gfp) +{ +struct device *dev = &GET_DEV (accel_dev); +dma_addr_t new_blp =DMA_MAPPING_ERROR ; +struct qat_alg_buf_list *new_bl; +struct scatterlist *new_sg; +size_t new_bl_size; +int ret; + + ret =qat_bl_sgl_alloc_map (accel_dev, &new_sg, &new_bl, dlen, gfp); +if (ret) +return ret; + + new_bl_size =struct_size (new_bl, bufers, new_bl->num_bufs); + +/* Map new firmware SGL descriptor */ + new_blp =dma_map_single (dev, new_bl, new_bl_size,DMA_TO_DEVICE ); +if (unlikely (dma_mapping_error (dev, new_blp))) + goto err; + +/* Unmap old firmware SGL descriptor */ +dma_unmap_single (dev, qat_bufs->bloutp, qat_bufs->sz_out,DMA_TO_DEVICE ); + +/* Free and unmap old scatterlist */ +qat_bl_sgl_free_unmap (accel_dev, *sg, qat_bufs->blout, + !qat_bufs->sgl_dst_valid); + + qat_bufs->sgl_dst_valid = false; + qat_bufs->blout = new_bl; + qat_bufs->bloutp = new_blp; + qat_bufs->sz_out = new_bl_size; + + *sg = new_sg; + +return 0 ; +err: +qat_bl_sgl_free_unmap (accel_dev, new_sg, new_bl, true); + +if (!dma_mapping_error (dev, new_blp)) +dma_unmap_single (dev, new_blp, new_bl_size,DMA_TO_DEVICE ); + +return -ENOMEM ; +}
drivers/crypto/qat/qat_common/qat_bl.h +6 -0
@@ -58,4 +58,10 @@ static inline gfp_t qat_algs_alloc_flags(struct crypto_async_request *req) return req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC; } +int qat_bl_realloc_map_new_dst (struct adf_accel_dev *accel_dev, +struct scatterlist **newd, +unsigned int dlen, +struct qat_request_buffs *qat_bufs, +gfp_t gfp); +#endif
drivers/crypto/qat/qat_common/qat_comp_algs.c +70 -0
116 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_comp_req.h +10 -0
@@ -25,6 +25,16 @@ static inline void qat_comp_create_req(void *ctx, void *req, u64 src, u32 slen, req_pars->out_buffer_sz = dlen; } +static inline void qat_comp_override_dst (void *req,u64 dst,u32 dlen) +{ +struct icp_qat_fw_comp_req *fw_req = req; +struct icp_qat_fw_comp_req_params *req_pars = &fw_req->comp_pars; + + fw_req->comn_mid.dest_data_addr = dst; + fw_req->comn_mid.dst_length = dlen; + req_pars->out_buffer_sz = dlen; +} + static inline void qat_comp_create_compression_req(void *ctx, void *req, u64 src, u32 slen, u64 dst, u32 dlen,
Signature · 1 line
2.38.1
Herbert Xu
maintainerQuoted 117 lines · Giovanni Cabiddu
This set enables the offload of the compression deflate algorithm to QAT accelerators through the acomp API.
The first part of the set (patches 1 to 8) reworks and refactors logic that is specific to the crypto service in order to be used by the compression service.
In particular, the first 6 patches rework the buffer list logic, which is used to map, unmap and convert scatterlists into the format that the QAT firmware can understand. These relocate the bufferlist logic to a separate file, change the interfaces so that the logic is service agnostic (not tied to compression or crypto) and extend the interface to allow an additional pre-allocated buffer for each destination scatter list which will be used to avoid premature overflows reported by the compression hardware.
Patch 7 relocates the functionqat_algs_alloc_flags()from a crypto specific header toqat_bl.h.
Patch 8 moves and renames the configuration function for GEN2,qat_crypto_dev_config(), to a new file,adf_gen2_config.h, which contains the configuration logic for both crypto and compression instances for QAT GEN2 devices.The last 2 patches in the set introduce all the infrastructure required to enable the compression service in the QAT driver and expose it through the acomp APIs.
In particular, patch 9 introduces the logic related to the creation and handling of compression instances and their configuration. In addition, it adds the back-end forqat_deflateto plug into acomp, including the logic to build descriptors for the newly added GEN2 compression firmware APIs. This was all kept in a single patch to avoid introducing unused logic in the QAT driver in previous patches.Patch 10, extends the compression logic to support to QAT GEN4 devices.
Patch 11 extends the acomp api by defining the max size for the destination buffer when a request is submitted with NULL destination buffer. This value is then used in the followin patch.
Patch 12 implements the resubmission logic for decompression requests that is triggered if the destination buffer, allocated by the driver, is not sufficiently big to store the output from the operation.
Changes from v1:
- Implemented resubmission logic for decompression triggered when the output buffer allocated by the driver is not sufficiently large to store the result from the operation
- Renamed buffer list functions that are moved to theqat_blmoduleChanges from v2:
- Reworked decompression re-submission logic. For decompression operations submitted specifying NULL as destination buffer, resubmit once with a destination buffer of size 128KB instead of retying multiple times doubling every time the size of the destination buffer.
- Added define in acomp api to specify the destination maximum size.Giovanni Cabiddu (12):
crypto: qat - relocate bufferlist logic
crypto: qat - rename bufferlist functions
crypto: qat - change bufferlist logic interface
crypto: qat - generalize crypto request buffers
crypto: qat - extend buffer list interface
crypto: qat - relocate backlog related structures
crypto: qat - relocateqat_algs_alloc_flags()
crypto: qat - rename and relocate GEN2 config function
crypto: qat - expose deflate through acomp api for QAT GEN2
crypto: qat - enable deflate for QAT GEN4
crypto: acomp - define max size for destination
crypto: qat - add resubmit logic for decompression.../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c | 4 +- .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.h | 2 +- drivers/crypto/qat/qat_4xxx/adf_drv.c | 145 ++++++- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 4 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 2 +- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 4 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 4 + drivers/crypto/qat/qat_c62x/adf_drv.c | 2 +- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 4 + drivers/crypto/qat/qat_common/Makefile | 8 +- .../crypto/qat/qat_common/adf_accel_devices.h | 14 + .../crypto/qat/qat_common/adf_cfg_strings.h | 1 + .../crypto/qat/qat_common/adf_common_drv.h | 9 +- drivers/crypto/qat/qat_common/adf_ctl_drv.c | 6 + .../crypto/qat/qat_common/adf_gen2_config.c | 206 +++++++++ .../crypto/qat/qat_common/adf_gen2_config.h | 10 + drivers/crypto/qat/qat_common/adf_gen2_dc.c | 70 +++ drivers/crypto/qat/qat_common/adf_gen2_dc.h | 10 + drivers/crypto/qat/qat_common/adf_gen4_dc.c | 83 ++++ drivers/crypto/qat/qat_common/adf_gen4_dc.h | 10 + drivers/crypto/qat/qat_common/adf_init.c | 11 + drivers/crypto/qat/qat_common/adf_sriov.c | 4 + drivers/crypto/qat/qat_common/icp_qat_fw.h | 24 ++ .../crypto/qat/qat_common/icp_qat_fw_comp.h | 404 ++++++++++++++++++ drivers/crypto/qat/qat_common/icp_qat_hw.h | 66 +++ .../qat/qat_common/icp_qat_hw_20_comp.h | 164 +++++++ .../qat/qat_common/icp_qat_hw_20_comp_defs.h | 300 +++++++++++++ drivers/crypto/qat/qat_common/qat_algs.c | 208 +-------- drivers/crypto/qat/qat_common/qat_algs_send.h | 16 +- drivers/crypto/qat/qat_common/qat_bl.c | 383 +++++++++++++++++ drivers/crypto/qat/qat_common/qat_bl.h | 67 +++ drivers/crypto/qat/qat_common/qat_comp_algs.c | 344 +++++++++++++++ drivers/crypto/qat/qat_common/qat_comp_req.h | 123 ++++++ .../crypto/qat/qat_common/qat_compression.c | 297 +++++++++++++ .../crypto/qat/qat_common/qat_compression.h | 37 ++ drivers/crypto/qat/qat_common/qat_crypto.c | 120 +----- drivers/crypto/qat/qat_common/qat_crypto.h | 55 +-- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 4 + drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 2 +- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 4 + include/crypto/acompress.h | 1 + 41 files changed, 2848 insertions(+), 384 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_config.h create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_dc.h create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen4_dc.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_comp.h
Quoted 11 lines
create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp.h create mode 100644 drivers/crypto/qat/qat_common/icp_qat_hw_20_comp_defs.h create mode 100644 drivers/crypto/qat/qat_common/qat_bl.c create mode 100644 drivers/crypto/qat/qat_common/qat_bl.h create mode 100644 drivers/crypto/qat/qat_common/qat_comp_algs.c create mode 100644 drivers/crypto/qat/qat_common/qat_comp_req.h create mode 100644 drivers/crypto/qat/qat_common/qat_compression.c create mode 100644 drivers/crypto/qat/qat_common/qat_compression.hSignature · 1 line
2.38.1
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