crypto: qat - rework in preparation for qat_4xxx driver
cover crypto: qat - rework in preparation for qat_4xxx driver
This set is an initial rework of the QAT driver in preparation for the inclusion of the qat_4xxx driver (QAT GEN4).
Summary of changes:
* IV update logic moved to software to remove allocation of the IV buffer in the data-path and allow for devices that are not capable of updating it when performing AES-CBC or AES-CTR.
* Added logic to detect the presence of engines and accelerators via soft-straps and fuse registers.
* Added infrastructure to support devices with an arbitrary number of rings per bank.
* Introduced adf_gen2_hw_data.[c|h] that contain logic that is common between QAT GEN2 devices (c62x, c3xxx and dh895xcc).
* Abstracted logic that configures iov threads.
* Abstracted access to transport CSRs.
* Abstracted, refactored and updated admin interface logic.
* Abstracted and refactored arbiter logic.
* Changed sequence on how arbitration is enabled on rings.
* Added support for device capability detection.
* Replaced hardcoded masks.
* Changed logic in adf_sriov.c to allow for drivers that do not implement some of the functions of that module.
* Refactored logic related to device configuration and instance creation.
* Changed logic to allow for instances in different banks.
* Extended accelerator mask.
Ahsan Atta (1):
crypto: qat - num_rings_per_bank is device dependent
Giovanni Cabiddu (28):
crypto: qat - mask device capabilities with soft straps
crypto: qat - fix configuration of iov threads
crypto: qat - split transport CSR access logic
crypto: qat - relocate GEN2 CSR access code
crypto: qat - abstract admin interface
crypto: qat - add packed to init admin structures
crypto: qat - rename ME in AE
crypto: qat - change admin sequence
crypto: qat - use admin mask to send fw constants
crypto: qat - update constants table
crypto: qat - remove writes into WQCFG
crypto: qat - remove unused macros in arbiter module
crypto: qat - abstract arbiter access
crypto: qat - register crypto instances based on capability
crypto: qat - enable ring after pair is programmed
crypto: qat - abstract build ring base
crypto: qat - replace constant masks with GENMASK
crypto: qat - use BIT_ULL() - 1 pattern for masks
crypto: qat - abstract writes to arbiter enable
crypto: qat - remove hardcoded bank irq clear flag mask
crypto: qat - call functions in adf_sriov if available
crypto: qat - remove unnecessary void* casts
crypto: qat - change return value in adf_cfg_add_key_value_param()
crypto: qat - change return value in adf_cfg_key_val_get()
crypto: qat - refactor qat_crypto_create_instances()
crypto: qat - refactor qat_crypto_dev_config()
crypto: qat - allow for instances in different banks
crypto: qat - extend ae_mask
Marco Chiappero (2):
crypto: qat - update IV in software
crypto: qat - add support for capability detection
.../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 49 ++++- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h | 5 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 11 +- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 7 +- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 +- .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 49 ++++- .../crypto/qat/qat_c62x/adf_c62x_hw_data.h | 5 + drivers/crypto/qat/qat_c62x/adf_drv.c | 11 +- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 7 +- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 +- drivers/crypto/qat/qat_common/Makefile | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 58 +++++- drivers/crypto/qat/qat_common/adf_admin.c | 77 ++++---- drivers/crypto/qat/qat_common/adf_cfg.c | 4 +- .../crypto/qat/qat_common/adf_cfg_strings.h | 3 +- .../crypto/qat/qat_common/adf_gen2_hw_data.c | 181 ++++++++++++++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 123 ++++++++++++ .../crypto/qat/qat_common/adf_hw_arbiter.c | 94 ++++----- drivers/crypto/qat/qat_common/adf_isr.c | 4 +- drivers/crypto/qat/qat_common/adf_sriov.c | 74 ++----- drivers/crypto/qat/qat_common/adf_transport.c | 130 +++++++++---- .../qat_common/adf_transport_access_macros.h | 67 ------- .../qat/qat_common/adf_transport_debug.c | 32 ++-- .../qat/qat_common/adf_transport_internal.h | 2 +- drivers/crypto/qat/qat_common/adf_vf_isr.c | 5 +- .../qat/qat_common/icp_qat_fw_init_admin.h | 6 +- drivers/crypto/qat/qat_common/icp_qat_hw.h | 23 +++ drivers/crypto/qat/qat_common/qat_algs.c | 136 +++++++------ drivers/crypto/qat/qat_common/qat_crypto.c | 162 ++++++++++------ drivers/crypto/qat/qat_common/qat_crypto.h | 26 ++- drivers/crypto/qat/qat_common/qat_hal.c | 27 +-- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 60 +++++- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 5 + drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 9 +- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 7 +- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 +- 36 files changed, 1024 insertions(+), 448 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
Signature · 1 line
2.26.2
PATCH 1/31 crypto: qat - update IV in software
From: Marco Chiappero <[email protected]>
Do IV update calculations in software for AES-CBC and AES-CTR.
This allows to embed the IV on the request descriptor and removes the allocation of the IV buffer in the data path.
In addition, this change allows the support of QAT devices that are not capable of updating the IV buffer when performing an AES-CBC or AES-CTR operation.
--- drivers/crypto/qat/qat_common/qat_algs.c | 136 ++++++++++++--------- drivers/crypto/qat/qat_common/qat_crypto.h | 11 +- 2 files changed, 89 insertions(+), 58 deletions(-)
drivers/crypto/qat/qat_common/qat_algs.c +80 -56
@@ -11,6 +11,7 @@#include <crypto/hmac.h> #include <crypto/algapi.h> #include <crypto/authenc.h> +#include <crypto/scatterwalk.h> #include <crypto/xts.h> #include <linux/dma-mapping.h> #include "adf_accel_devices.h"
@@ -90,6 +91,7 @@ struct qat_alg_skcipher_ctx {struct qat_crypto_instance *inst;struct crypto_skcipher *ftfm;bool fallback; +int mode; };static int qat_get_inter_state_size (enum icp_qat_hw_auth_algo qat_hash_alg)
@@ -214,24 +216,7 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash,return 0 ; } -static void qat_alg_init_hdr_iv_updt (struct icp_qat_fw_comn_req_hdr *header) -{ -ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET (header->serv_specif_flags, -ICP_QAT_FW_CIPH_IV_64BIT_PTR ); -ICP_QAT_FW_LA_UPDATE_STATE_SET (header->serv_specif_flags, -ICP_QAT_FW_LA_UPDATE_STATE ); -} - -static void qat_alg_init_hdr_no_iv_updt (struct icp_qat_fw_comn_req_hdr *header) -{ -ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET (header->serv_specif_flags, -ICP_QAT_FW_CIPH_IV_16BYTE_DATA ); -ICP_QAT_FW_LA_UPDATE_STATE_SET (header->serv_specif_flags, -ICP_QAT_FW_LA_NO_UPDATE_STATE ); -} - -static void qat_alg_init_common_hdr (struct icp_qat_fw_comn_req_hdr *header, -int aead) +static void qat_alg_init_common_hdr (struct icp_qat_fw_comn_req_hdr *header) { header->hdr_flags =ICP_QAT_FW_COMN_HDR_FLAGS_BUILD (ICP_QAT_FW_COMN_REQ_FLAG_SET );
@@ -241,12 +226,12 @@ static void qat_alg_init_common_hdr(struct icp_qat_fw_comn_req_hdr *header, QAT_COMN_PTR_TYPE_SGL);ICP_QAT_FW_LA_PARTIAL_SET (header->serv_specif_flags,ICP_QAT_FW_LA_PARTIAL_NONE ); -if (aead) -qat_alg_init_hdr_no_iv_updt (header); -else -qat_alg_init_hdr_iv_updt (header); +ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET (header->serv_specif_flags, +ICP_QAT_FW_CIPH_IV_16BYTE_DATA );ICP_QAT_FW_LA_PROTO_SET (header->serv_specif_flags,ICP_QAT_FW_LA_NO_PROTO ); +ICP_QAT_FW_LA_UPDATE_STATE_SET (header->serv_specif_flags, +ICP_QAT_FW_LA_NO_UPDATE_STATE ); } static int qat_alg_aead_init_enc_session(struct crypto_aead *aead_tfm,
@@ -281,7 +266,7 @@ static int qat_alg_aead_init_enc_session(struct crypto_aead *aead_tfm,return -EFAULT ;/* Request setup */ -qat_alg_init_common_hdr (header,1 ); +qat_alg_init_common_hdr (header); header->service_cmd_id =ICP_QAT_FW_LA_CMD_CIPHER_HASH ;ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET (header->serv_specif_flags,ICP_QAT_FW_LA_DIGEST_IN_BUFFER );
@@ -368,7 +353,7 @@ static int qat_alg_aead_init_dec_session(struct crypto_aead *aead_tfm,return -EFAULT ;/* Request setup */ -qat_alg_init_common_hdr (header,1 ); +qat_alg_init_common_hdr (header); header->service_cmd_id =ICP_QAT_FW_LA_CMD_HASH_CIPHER ;ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET (header->serv_specif_flags,ICP_QAT_FW_LA_DIGEST_IN_BUFFER );
@@ -432,7 +417,7 @@ static void qat_alg_skcipher_init_com(struct qat_alg_skcipher_ctx *ctx,struct icp_qat_fw_cipher_cd_ctrl_hdr *cd_ctrl = (void *)&req->cd_ctrl;memcpy (cd->aes.key, key, keylen); -qat_alg_init_common_hdr (header,0 ); +qat_alg_init_common_hdr (header); header->service_cmd_id =ICP_QAT_FW_LA_CMD_CIPHER ; cd_pars->u.s.content_desc_params_sz =sizeof (struct icp_qat_hw_cipher_algo_blk ) >>3 ;
@@ -787,6 +772,61 @@ static void qat_aead_alg_callback(struct icp_qat_fw_la_resp *qat_resp, areq->base.complete (&areq->base, res); } +static void qat_alg_update_iv_ctr_mode (struct qat_crypto_request *qat_req) +{ +struct skcipher_request *sreq = qat_req->skcipher_req; +u64 iv_lo_prev; +u64 iv_lo; +u64 iv_hi; + +memcpy (qat_req->iv, sreq->iv,AES_BLOCK_SIZE ); + + iv_lo =be64_to_cpu (qat_req->iv_lo); + iv_hi =be64_to_cpu (qat_req->iv_hi); + + iv_lo_prev = iv_lo; + iv_lo +=DIV_ROUND_UP (sreq->cryptlen,AES_BLOCK_SIZE ); +if (iv_lo < iv_lo_prev) + iv_hi++; + + qat_req->iv_lo =cpu_to_be64 (iv_lo); + qat_req->iv_hi =cpu_to_be64 (iv_hi); +} + +static void qat_alg_update_iv_cbc_mode (struct qat_crypto_request *qat_req) +{ +struct skcipher_request *sreq = qat_req->skcipher_req; +int offset = sreq->cryptlen -AES_BLOCK_SIZE ; +struct scatterlist *sgl; + +if (qat_req->encryption) + sgl = sreq->dst; +else + sgl = sreq->src; + +scatterwalk_map_and_copy (qat_req->iv, sgl, offset,AES_BLOCK_SIZE ,0 ); +} + +static void qat_alg_update_iv (struct qat_crypto_request *qat_req) +{ +struct qat_alg_skcipher_ctx *ctx = qat_req->skcipher_ctx; +struct device *dev = &GET_DEV (ctx->inst->accel_dev); + +switch (ctx->mode) { +case ICP_QAT_HW_CIPHER_CTR_MODE : +qat_alg_update_iv_ctr_mode (qat_req); +break ; +case ICP_QAT_HW_CIPHER_CBC_MODE : +qat_alg_update_iv_cbc_mode (qat_req); +break ; +case ICP_QAT_HW_CIPHER_XTS_MODE : +break ; +default : +dev_warn (dev,"Unsupported IV update for cipher mode %d\n" , + ctx->mode); + } +} +static void qat_skcipher_alg_callback (struct icp_qat_fw_la_resp *qat_resp,struct qat_crypto_request *qat_req) {
@@ -794,16 +834,16 @@ static void qat_skcipher_alg_callback(struct icp_qat_fw_la_resp *qat_resp,struct qat_crypto_instance *inst = ctx->inst;struct skcipher_request *sreq = qat_req->skcipher_req;u8 stat_filed = qat_resp->comn_resp.comn_status; -struct device *dev = &GET_DEV (ctx->inst->accel_dev);int res =0 , qat_res =ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET (stat_filed);qat_alg_free_bufl (inst, qat_req);if (unlikely (qat_res !=ICP_QAT_FW_COMN_STATUS_FLAG_OK )) res = -EINVAL ; +if (qat_req->encryption) +qat_alg_update_iv (qat_req); +memcpy (sreq->iv, qat_req->iv,AES_BLOCK_SIZE ); -dma_free_coherent (dev,AES_BLOCK_SIZE , qat_req->iv, - qat_req->iv_paddr); sreq->base.complete (&sreq->base, res); }
@@ -981,6 +1021,8 @@ static int qat_alg_skcipher_setkey(struct crypto_skcipher *tfm, {struct qat_alg_skcipher_ctx *ctx =crypto_skcipher_ctx (tfm); + ctx->mode = mode; +if (ctx->enc_cd)return qat_alg_skcipher_rekey (ctx, key, keylen, mode);else
@@ -1035,23 +1077,14 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req)struct qat_crypto_request *qat_req =skcipher_request_ctx (req);struct icp_qat_fw_la_cipher_req_params *cipher_param;struct icp_qat_fw_la_bulk_req *msg; -struct device *dev = &GET_DEV (ctx->inst->accel_dev);int ret, ctr =0 ;if (req->cryptlen ==0 )return 0 ; - qat_req->iv =dma_alloc_coherent (dev,AES_BLOCK_SIZE , - &qat_req->iv_paddr,GFP_ATOMIC ); -if (!qat_req->iv) -return -ENOMEM ; - ret =qat_alg_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req); -if (unlikely (ret)) { -dma_free_coherent (dev,AES_BLOCK_SIZE , qat_req->iv, - qat_req->iv_paddr); +if (unlikely (ret))return ret; - } msg = &qat_req->req; *msg = ctx->enc_fw_req;
@@ -1061,19 +1094,18 @@ static int qat_alg_skcipher_encrypt(struct skcipher_request *req) qat_req->req.comn_mid.opaque_data = (u64 )(__force long )qat_req; qat_req->req.comn_mid.src_data_addr = qat_req->buf.blp; qat_req->req.comn_mid.dest_data_addr = qat_req->buf.bloutp; + qat_req->encryption = true; cipher_param = (void *)&qat_req->req.serv_specif_rqpars; cipher_param->cipher_length = req->cryptlen; cipher_param->cipher_offset =0 ; - cipher_param->u.s.cipher_IV_ptr = qat_req->iv_paddr; -memcpy (qat_req->iv, req->iv,AES_BLOCK_SIZE ); +memcpy (cipher_param->u.cipher_IV_array, req->iv,AES_BLOCK_SIZE ); +do { ret =adf_send_message (ctx->inst->sym_tx, (u32 *)msg); }while (ret == -EAGAIN && ctr++ <10 );if (ret == -EAGAIN ) {qat_alg_free_bufl (ctx->inst, qat_req); -dma_free_coherent (dev,AES_BLOCK_SIZE , qat_req->iv, - qat_req->iv_paddr);return -EBUSY ; }return -EINPROGRESS ;
@@ -1113,23 +1145,14 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req)struct qat_crypto_request *qat_req =skcipher_request_ctx (req);struct icp_qat_fw_la_cipher_req_params *cipher_param;struct icp_qat_fw_la_bulk_req *msg; -struct device *dev = &GET_DEV (ctx->inst->accel_dev);int ret, ctr =0 ;if (req->cryptlen ==0 )return 0 ; - qat_req->iv =dma_alloc_coherent (dev,AES_BLOCK_SIZE , - &qat_req->iv_paddr,GFP_ATOMIC ); -if (!qat_req->iv) -return -ENOMEM ; - ret =qat_alg_sgl_to_bufl (ctx->inst, req->src, req->dst, qat_req); -if (unlikely (ret)) { -dma_free_coherent (dev,AES_BLOCK_SIZE , qat_req->iv, - qat_req->iv_paddr); +if (unlikely (ret))return ret; - } msg = &qat_req->req; *msg = ctx->dec_fw_req;
@@ -1139,19 +1162,20 @@ static int qat_alg_skcipher_decrypt(struct skcipher_request *req) qat_req->req.comn_mid.opaque_data = (u64 )(__force long )qat_req; qat_req->req.comn_mid.src_data_addr = qat_req->buf.blp; qat_req->req.comn_mid.dest_data_addr = qat_req->buf.bloutp; + qat_req->encryption = false; cipher_param = (void *)&qat_req->req.serv_specif_rqpars; cipher_param->cipher_length = req->cryptlen; cipher_param->cipher_offset =0 ; - cipher_param->u.s.cipher_IV_ptr = qat_req->iv_paddr; -memcpy (qat_req->iv, req->iv,AES_BLOCK_SIZE ); +memcpy (cipher_param->u.cipher_IV_array, req->iv,AES_BLOCK_SIZE ); + +qat_alg_update_iv (qat_req); +do { ret =adf_send_message (ctx->inst->sym_tx, (u32 *)msg); }while (ret == -EAGAIN && ctr++ <10 );if (ret == -EAGAIN ) {qat_alg_free_bufl (ctx->inst, qat_req); -dma_free_coherent (dev,AES_BLOCK_SIZE , qat_req->iv, - qat_req->iv_paddr);return -EBUSY ; }return -EINPROGRESS ;
drivers/crypto/qat/qat_common/qat_crypto.h +9 -2
@@ -3,6 +3,7 @@#ifndef _QAT_CRYPTO_INSTANCE_H_#define _QAT_CRYPTO_INSTANCE_H_ +#include <crypto/aes.h> #include <linux/list.h> #include <linux/slab.h> #include "adf_accel_devices.h"
@@ -44,8 +45,14 @@ struct qat_crypto_request {struct qat_crypto_request_buffs buf;void (*cb)(struct icp_qat_fw_la_resp *resp,struct qat_crypto_request *req); -void *iv; - dma_addr_t iv_paddr; +union { +struct { +__be64 iv_hi; +__be64 iv_lo; + }; +u8 iv[AES_BLOCK_SIZE ]; + }; + bool encryption; };#endif
Signature · 1 line
2.26.2
PATCH 2/31 crypto: qat - mask device capabilities with soft straps
In reply to Giovanni CabidduEnable acceleration engines (AEs) and accelerators based on soft straps and fuses. When looping with a number of AEs or accelerators, ignore the ones that are disabled.
This patch is based on earlier work done by Conor McLoughlin.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 34 +++++++++++++++---- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h | 1 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 6 ++-- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 4 +-- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 +-- .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 34 +++++++++++++++---- .../crypto/qat/qat_c62x/adf_c62x_hw_data.h | 1 + drivers/crypto/qat/qat_c62x/adf_drv.c | 6 ++-- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 4 +-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 +-- .../crypto/qat/qat_common/adf_accel_devices.h | 5 +-- drivers/crypto/qat/qat_common/qat_hal.c | 27 ++++++++------- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 20 +++++++---- drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 4 +-- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 4 +-- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 +-- 16 files changed, 109 insertions(+), 53 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +27 -7
@@ -17,15 +17,33 @@ static struct adf_hw_device_class c3xxx_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) { -return (~fuse) >>ADF_C3XXX_ACCELERATORS_REG_OFFSET & -ADF_C3XXX_ACCELERATORS_MASK ; +u32 straps = self->straps; +u32 fuses = self->fuses; +u32 accel; + + accel = ~(fuses | straps) >>ADF_C3XXX_ACCELERATORS_REG_OFFSET ; + accel &=ADF_C3XXX_ACCELERATORS_MASK ; + +return accel; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) { -return (~fuse) &ADF_C3XXX_ACCELENGINES_MASK ; +u32 straps = self->straps; +u32 fuses = self->fuses; +unsigned long disabled; +u32 ae_disable; +int accel; + +/* If an accel is disabled, then disable the corresponding two AEs */ + disabled = ~get_accel_mask (self) &ADF_C3XXX_ACCELERATORS_MASK ; + ae_disable =BIT (1 ) |BIT (0 ); +for_each_set_bit (accel, &disabled,ADF_C3XXX_MAX_ACCELERATORS ) + straps |= ae_disable << (accel <<1 ); + +return ~(fuses | straps) &ADF_C3XXX_ACCELENGINES_MASK ; }static u32 get_num_accels (struct adf_hw_device_data *self)
@@ -109,11 +127,13 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_device = accel_dev->hw_device;struct adf_bar *misc_bar = &GET_BARS (accel_dev)[ADF_C3XXX_PMISC_BAR ]; +unsigned long accel_mask = hw_device->accel_mask; +unsigned long ae_mask = hw_device->ae_mask;void __iomem *csr = misc_bar->virt_addr;unsigned int val, i;/* Enable Accel Engine error detection & correction */ -for (i =0 ; i < hw_device->get_num_aes (hw_device); i++) { +for_each_set_bit (i, &ae_mask,GET_MAX_ACCELENGINES (accel_dev)) { val =ADF_CSR_RD (csr,ADF_C3XXX_AE_CTX_ENABLES (i)); val |=ADF_C3XXX_ENABLE_AE_ECC_ERR ;ADF_CSR_WR (csr,ADF_C3XXX_AE_CTX_ENABLES (i), val);
@@ -123,7 +143,7 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) }/* Enable shared memory error detection & correction */ -for (i =0 ; i < hw_device->get_num_accels (hw_device); i++) { +for_each_set_bit (i, &accel_mask,ADF_C3XXX_MAX_ACCELERATORS ) { val =ADF_CSR_RD (csr,ADF_C3XXX_UERRSSMSH (i)); val |=ADF_C3XXX_ERRSSMSH_EN ;ADF_CSR_WR (csr,ADF_C3XXX_UERRSSMSH (i), val);
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h +1 -0
@@ -18,6 +18,7 @@#define ADF_C3XXX_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)#define ADF_C3XXX_SMIA0_MASK 0xFFFF#define ADF_C3XXX_SMIA1_MASK 0x1 +#define ADF_C3XXX_SOFTSTRAP_CSR_OFFSET 0x2EC/* Error detection and correction */ #define ADF_C3XXX_AE_CTX_ENABLES (i) (i * 0x1000 + 0x20818)#define ADF_C3XXX_AE_MISC_CONTROL (i) (i * 0x1000 + 0x20960)
drivers/crypto/qat/qat_c3xxx/adf_drv.c +4 -2
@@ -126,10 +126,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_read_config_byte (pdev,PCI_REVISION_ID , &accel_pci_dev->revid);pci_read_config_dword (pdev,ADF_DEVICE_FUSECTL_OFFSET , &hw_data->fuses); +pci_read_config_dword (pdev,ADF_C3XXX_SOFTSTRAP_CSR_OFFSET , + &hw_data->straps);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* If the device has no acceleration engines then ignore it. */ if (!hw_data->accel_mask || !hw_data->ae_mask ||
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +2 -2
@@ -11,12 +11,12 @@ static struct adf_hw_device_class c3xxxiov_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) {return ADF_C3XXXIOV_ACCELERATORS_MASK ; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) {return ADF_C3XXXIOV_ACCELENGINES_MASK ; }
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2 -2
@@ -119,8 +119,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)adf_init_hw_data_c3xxxiov (accel_dev->hw_device);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* Create dev top level debugfs entry */
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +27 -7
@@ -22,15 +22,33 @@ static struct adf_hw_device_class c62x_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) { -return (~fuse) >>ADF_C62X_ACCELERATORS_REG_OFFSET & -ADF_C62X_ACCELERATORS_MASK ; +u32 straps = self->straps; +u32 fuses = self->fuses; +u32 accel; + + accel = ~(fuses | straps) >>ADF_C62X_ACCELERATORS_REG_OFFSET ; + accel &=ADF_C62X_ACCELERATORS_MASK ; + +return accel; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) { -return (~fuse) &ADF_C62X_ACCELENGINES_MASK ; +u32 straps = self->straps; +u32 fuses = self->fuses; +unsigned long disabled; +u32 ae_disable; +int accel; + +/* If an accel is disabled, then disable the corresponding two AEs */ + disabled = ~get_accel_mask (self) &ADF_C62X_ACCELERATORS_MASK ; + ae_disable =BIT (1 ) |BIT (0 ); +for_each_set_bit (accel, &disabled,ADF_C62X_MAX_ACCELERATORS ) + straps |= ae_disable << (accel <<1 ); + +return ~(fuses | straps) &ADF_C62X_ACCELENGINES_MASK ; }static u32 get_num_accels (struct adf_hw_device_data *self)
@@ -119,11 +137,13 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_device = accel_dev->hw_device;struct adf_bar *misc_bar = &GET_BARS (accel_dev)[ADF_C62X_PMISC_BAR ]; +unsigned long accel_mask = hw_device->accel_mask; +unsigned long ae_mask = hw_device->ae_mask;void __iomem *csr = misc_bar->virt_addr;unsigned int val, i;/* Enable Accel Engine error detection & correction */ -for (i =0 ; i < hw_device->get_num_aes (hw_device); i++) { +for_each_set_bit (i, &ae_mask,GET_MAX_ACCELENGINES (accel_dev)) { val =ADF_CSR_RD (csr,ADF_C62X_AE_CTX_ENABLES (i)); val |=ADF_C62X_ENABLE_AE_ECC_ERR ;ADF_CSR_WR (csr,ADF_C62X_AE_CTX_ENABLES (i), val);
@@ -133,7 +153,7 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) }/* Enable shared memory error detection & correction */ -for (i =0 ; i < hw_device->get_num_accels (hw_device); i++) { +for_each_set_bit (i, &accel_mask,ADF_C62X_MAX_ACCELERATORS ) { val =ADF_CSR_RD (csr,ADF_C62X_UERRSSMSH (i)); val |=ADF_C62X_ERRSSMSH_EN ;ADF_CSR_WR (csr,ADF_C62X_UERRSSMSH (i), val);
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.h +1 -0
@@ -19,6 +19,7 @@#define ADF_C62X_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)#define ADF_C62X_SMIA0_MASK 0xFFFF#define ADF_C62X_SMIA1_MASK 0x1 +#define ADF_C62X_SOFTSTRAP_CSR_OFFSET 0x2EC/* Error detection and correction */ #define ADF_C62X_AE_CTX_ENABLES (i) (i * 0x1000 + 0x20818)#define ADF_C62X_AE_MISC_CONTROL (i) (i * 0x1000 + 0x20960)
drivers/crypto/qat/qat_c62x/adf_drv.c +4 -2
@@ -126,10 +126,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_read_config_byte (pdev,PCI_REVISION_ID , &accel_pci_dev->revid);pci_read_config_dword (pdev,ADF_DEVICE_FUSECTL_OFFSET , &hw_data->fuses); +pci_read_config_dword (pdev,ADF_C62X_SOFTSTRAP_CSR_OFFSET , + &hw_data->straps);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* If the device has no acceleration engines then ignore it. */ if (!hw_data->accel_mask || !hw_data->ae_mask ||
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +2 -2
@@ -11,12 +11,12 @@ static struct adf_hw_device_class c62xiov_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) {return ADF_C62XIOV_ACCELERATORS_MASK ; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) {return ADF_C62XIOV_ACCELENGINES_MASK ; }
drivers/crypto/qat/qat_c62xvf/adf_drv.c +2 -2
@@ -119,8 +119,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)adf_init_hw_data_c62xiov (accel_dev->hw_device);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* Create dev top level debugfs entry */
drivers/crypto/qat/qat_common/adf_accel_devices.h +3 -2
@@ -104,8 +104,8 @@ struct adf_etr_ring_data;struct adf_hw_device_data {struct adf_hw_device_class *dev_class; -u32 (*get_accel_mask)(u32 fuse); -u32 (*get_ae_mask)(u32 fuse); +u32 (*get_accel_mask)(struct adf_hw_device_data *self); +u32 (*get_ae_mask)(struct adf_hw_device_data *self);u32 (*get_sram_bar_id)(struct adf_hw_device_data *self);u32 (*get_misc_bar_id)(struct adf_hw_device_data *self);u32 (*get_etr_bar_id)(struct adf_hw_device_data *self);
@@ -131,6 +131,7 @@ struct adf_hw_device_data {const char *fw_name;const char *fw_mmp_name;u32 fuses; +u32 straps;u32 accel_capabilities_mask;u32 instance_id;u16 accel_mask;
drivers/crypto/qat/qat_common/qat_hal.c +15 -12
@@ -346,11 +346,12 @@ static void qat_hal_put_wakeup_event(struct icp_qat_fw_loader_handle *handle,static int qat_hal_check_ae_alive (struct icp_qat_fw_loader_handle *handle) { +unsigned long ae_mask = handle->hal_handle->ae_mask;unsigned int base_cnt, cur_cnt;unsigned char ae;int times =MAX_RETRY_TIMES ; -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) { base_cnt =qat_hal_rd_ae_csr (handle, ae,PROFILE_COUNT ); base_cnt &=0xffff ;
@@ -384,6 +385,7 @@ int qat_hal_check_ae_active(struct icp_qat_fw_loader_handle *handle,static void qat_hal_reset_timestamp (struct icp_qat_fw_loader_handle *handle) { +unsigned long ae_mask = handle->hal_handle->ae_mask;unsigned int misc_ctl;unsigned char ae;
@@ -393,7 +395,7 @@ static void qat_hal_reset_timestamp(struct icp_qat_fw_loader_handle *handle)SET_GLB_CSR (handle,MISC_CONTROL , misc_ctl & (~MC_TIMESTAMP_ENABLE )); -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) {qat_hal_wr_ae_csr (handle, ae,TIMESTAMP_LOW ,0 );qat_hal_wr_ae_csr (handle, ae,TIMESTAMP_HIGH ,0 ); }
@@ -438,6 +440,7 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)#define SHRAM_INIT_CYCLES 2060int qat_hal_clr_reset (struct icp_qat_fw_loader_handle *handle) { +unsigned long ae_mask = handle->hal_handle->ae_mask;unsigned int ae_reset_csr;unsigned char ae;unsigned int clk_csr;
@@ -464,7 +467,7 @@ int qat_hal_clr_reset(struct icp_qat_fw_loader_handle *handle) goto out_err;/* Set undefined power-up/reset states to reasonable default values */ -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) {qat_hal_wr_ae_csr (handle, ae,CTX_ENABLES ,INIT_CTX_ENABLE_VALUE ); qat_hal_wr_indr_csr(handle, ae, ICP_QAT_UCLO_AE_ALL_CTX,
@@ -570,10 +573,11 @@ static void qat_hal_enable_ctx(struct icp_qat_fw_loader_handle *handle,static void qat_hal_clear_xfer (struct icp_qat_fw_loader_handle *handle) { +unsigned long ae_mask = handle->hal_handle->ae_mask;unsigned char ae;unsigned short reg; -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) {for (reg =0 ; reg <ICP_QAT_UCLO_MAX_GPR_REG ; reg++) {qat_hal_init_rd_xfer (handle, ae,0 ,ICP_SR_RD_ABS , reg,0 );
@@ -585,6 +589,7 @@ static void qat_hal_clear_xfer(struct icp_qat_fw_loader_handle *handle)static int qat_hal_clear_gpr (struct icp_qat_fw_loader_handle *handle) { +unsigned long ae_mask = handle->hal_handle->ae_mask;unsigned char ae;unsigned int ctx_mask =ICP_QAT_UCLO_AE_ALL_CTX ;int times =MAX_RETRY_TIMES ;
@@ -592,7 +597,7 @@ static int qat_hal_clear_gpr(struct icp_qat_fw_loader_handle *handle)unsigned int savctx =0 ;int ret =0 ; -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) { csr_val =qat_hal_rd_ae_csr (handle, ae,AE_MISC_CONTROL ); csr_val &= ~(1 <<MMC_SHARE_CS_BITPOS );qat_hal_wr_ae_csr (handle, ae,AE_MISC_CONTROL , csr_val);
@@ -613,7 +618,7 @@ static int qat_hal_clear_gpr(struct icp_qat_fw_loader_handle *handle)qat_hal_wr_ae_csr (handle, ae,CTX_SIG_EVENTS_ACTIVE ,0 );qat_hal_enable_ctx (handle, ae, ctx_mask); } -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) {/* wait for AE to finish */ do { ret = qat_hal_wait_cycles(handle, ae, 20, 1);
@@ -654,6 +659,8 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)struct adf_hw_device_data *hw_data = accel_dev->hw_device;struct adf_bar *misc_bar = &pci_info->pci_bars[hw_data->get_misc_bar_id (hw_data)]; +unsigned long ae_mask = hw_data->ae_mask; +unsigned int csr_val =0 ;struct adf_bar *sram_bar; handle =kzalloc (sizeof (*handle),GFP_KERNEL );
@@ -689,9 +696,7 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)/* create AE objects */ handle->hal_handle->upc_mask =0x1ffff ; handle->hal_handle->max_ustore =0x4000 ; -for (ae =0 ; ae <ICP_QAT_UCLO_MAX_AE ; ae++) { -if (!(hw_data->ae_mask & (1 << ae))) -continue ; +for_each_set_bit (ae, &ae_mask,ICP_QAT_UCLO_MAX_AE ) { handle->hal_handle->aes[ae].free_addr =0 ; handle->hal_handle->aes[ae].free_size = handle->hal_handle->max_ustore;
@@ -714,9 +719,7 @@ int qat_hal_init(struct adf_accel_dev *accel_dev) }/* Set SIGNATURE_ENABLE[0] to 0x1 in order to enable ALU_OUT csr */ -for (ae =0 ; ae < handle->hal_handle->ae_max_num; ae++) { -unsigned int csr_val =0 ; - +for_each_set_bit (ae, &ae_mask, handle->hal_handle->ae_max_num) { csr_val =qat_hal_rd_ae_csr (handle, ae,SIGNATURE_ENABLE ); csr_val |=0x1 ;qat_hal_wr_ae_csr (handle, ae,SIGNATURE_ENABLE , csr_val);
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +13 -7
@@ -24,15 +24,19 @@ static struct adf_hw_device_class dh895xcc_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) { -return (~fuse) >>ADF_DH895XCC_ACCELERATORS_REG_OFFSET & -ADF_DH895XCC_ACCELERATORS_MASK ; +u32 fuses = self->fuses; + +return ~fuses >>ADF_DH895XCC_ACCELERATORS_REG_OFFSET & +ADF_DH895XCC_ACCELERATORS_MASK ; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) { -return (~fuse) &ADF_DH895XCC_ACCELENGINES_MASK ; +u32 fuses = self->fuses; + +return ~fuses &ADF_DH895XCC_ACCELENGINES_MASK ; }static u32 get_num_accels (struct adf_hw_device_data *self)
@@ -131,11 +135,13 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_device = accel_dev->hw_device;struct adf_bar *misc_bar = &GET_BARS (accel_dev)[ADF_DH895XCC_PMISC_BAR ]; +unsigned long accel_mask = hw_device->accel_mask; +unsigned long ae_mask = hw_device->ae_mask;void __iomem *csr = misc_bar->virt_addr;unsigned int val, i;/* Enable Accel Engine error detection & correction */ -for (i =0 ; i < hw_device->get_num_aes (hw_device); i++) { +for_each_set_bit (i, &ae_mask,GET_MAX_ACCELENGINES (accel_dev)) { val =ADF_CSR_RD (csr,ADF_DH895XCC_AE_CTX_ENABLES (i)); val |=ADF_DH895XCC_ENABLE_AE_ECC_ERR ;ADF_CSR_WR (csr,ADF_DH895XCC_AE_CTX_ENABLES (i), val);
@@ -145,7 +151,7 @@ static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) }/* Enable shared memory error detection & correction */ -for (i =0 ; i < hw_device->get_num_accels (hw_device); i++) { +for_each_set_bit (i, &accel_mask,ADF_DH895XCC_MAX_ACCELERATORS ) { val =ADF_CSR_RD (csr,ADF_DH895XCC_UERRSSMSH (i)); val |=ADF_DH895XCC_ERRSSMSH_EN ;ADF_CSR_WR (csr,ADF_DH895XCC_UERRSSMSH (i), val);
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +2 -2
@@ -128,8 +128,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) &hw_data->fuses);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* If the device has no acceleration engines then ignore it. */ if (!hw_data->accel_mask || !hw_data->ae_mask ||
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +2 -2
@@ -11,12 +11,12 @@ static struct adf_hw_device_class dh895xcciov_class = { .instances = 0 }; -static u32 get_accel_mask (u32 fuse) +static u32 get_accel_mask (struct adf_hw_device_data *self) {return ADF_DH895XCCIOV_ACCELERATORS_MASK ; } -static u32 get_ae_mask (u32 fuse) +static u32 get_ae_mask (struct adf_hw_device_data *self) {return ADF_DH895XCCIOV_ACCELENGINES_MASK ; }
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2 -2
@@ -119,8 +119,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)adf_init_hw_data_dh895xcciov (accel_dev->hw_device);/* Get Accelerators and Accelerators Engines masks */ - hw_data->accel_mask = hw_data->get_accel_mask (hw_data->fuses); - hw_data->ae_mask = hw_data->get_ae_mask (hw_data->fuses); + hw_data->accel_mask = hw_data->get_accel_mask (hw_data); + hw_data->ae_mask = hw_data->get_ae_mask (hw_data); accel_pci_dev->sku = hw_data->get_sku (hw_data);/* Create dev top level debugfs entry */
Signature · 1 line
2.26.2
PATCH 3/31 crypto: qat - num_rings_per_bank is device dependent
In reply to Giovanni CabidduFrom: Ahsan Atta <[email protected]>
This change is to allow support for QAT devices that may not have 16 rings per bank.
The rings structure in bank is allocated dynamically based on the number of banks supported by a device.
Note that in the error path in adf_init_bank(), ring->inflights is set to NULL after the free to silence a false positive double free reported by clang scan-build.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 1 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 3 ++ drivers/crypto/qat/qat_common/adf_transport.c | 42 +++++++++++++------ .../qat/qat_common/adf_transport_debug.c | 10 ++++- .../qat/qat_common/adf_transport_internal.h | 2 +- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 1 + 10 files changed, 47 insertions(+), 16 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -176,6 +176,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->dev_class = &c3xxx_class; hw_data->instance_id = c3xxx_class.instances++; hw_data->num_banks =ADF_C3XXX_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_C3XXX_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_C3XXX_MAX_ACCELENGINES ;
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +1 -0
@@ -69,6 +69,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) { hw_data->dev_class = &c3xxxiov_class; hw_data->num_banks =ADF_C3XXXIOV_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_C3XXXIOV_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_C3XXXIOV_MAX_ACCELENGINES ;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -186,6 +186,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->dev_class = &c62x_class; hw_data->instance_id = c62x_class.instances++; hw_data->num_banks =ADF_C62X_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_C62X_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_C62X_MAX_ACCELENGINES ;
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +1 -0
@@ -69,6 +69,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) { hw_data->dev_class = &c62xiov_class; hw_data->num_banks =ADF_C62XIOV_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_C62XIOV_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_C62XIOV_MAX_ACCELENGINES ;
drivers/crypto/qat/qat_common/adf_accel_devices.h +3 -0
@@ -139,6 +139,7 @@ struct adf_hw_device_data {u16 tx_rings_mask;u8 tx_rx_gap;u8 num_banks; +u8 num_rings_per_bank;u8 num_accel;u8 num_logical_accel;u8 num_engines;
@@ -156,6 +157,8 @@ struct adf_hw_device_data {#define GET_BARS (accel_dev) ((accel_dev)->accel_pci_dev.pci_bars)#define GET_HW_DATA (accel_dev) (accel_dev->hw_device)#define GET_MAX_BANKS (accel_dev) (GET_HW_DATA(accel_dev)->num_banks) +#define GET_NUM_RINGS_PER_BANK (accel_dev) \ + GET_HW_DATA(accel_dev)->num_rings_per_bank#define GET_MAX_ACCELENGINES (accel_dev) (GET_HW_DATA(accel_dev)->num_engines)#define accel_to_pci_dev (accel_ptr) accel_ptr->accel_pci_dev.pci_dev
drivers/crypto/qat/qat_common/adf_transport.c +29 -13
113 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_transport_debug.c +8 -2
@@ -117,11 +117,14 @@ void adf_ring_debugfs_rm(struct adf_etr_ring_data *ring)static void *adf_bank_start (struct seq_file *sfile,loff_t *pos) { +struct adf_etr_bank_data *bank = sfile->private; +u8 num_rings_per_bank =GET_NUM_RINGS_PER_BANK (bank->accel_dev); +mutex_lock (&bank_read_lock);if (*pos ==0 )return SEQ_START_TOKEN ; -if (*pos >=ADF_ETR_MAX_RINGS_PER_BANK ) +if (*pos >= num_rings_per_bank)return NULL ;return pos;
@@ -129,7 +132,10 @@ static void *adf_bank_start(struct seq_file *sfile, loff_t *pos)static void *adf_bank_next (struct seq_file *sfile,void *v,loff_t *pos) { -if (++(*pos) >=ADF_ETR_MAX_RINGS_PER_BANK ) +struct adf_etr_bank_data *bank = sfile->private; +u8 num_rings_per_bank =GET_NUM_RINGS_PER_BANK (bank->accel_dev); + +if (++(*pos) >= num_rings_per_bank)return NULL ;return pos;
drivers/crypto/qat/qat_common/adf_transport_internal.h +1 -1
@@ -28,7 +28,7 @@ struct adf_etr_ring_data { };struct adf_etr_bank_data { -struct adf_etr_ring_data rings[ADF_ETR_MAX_RINGS_PER_BANK ]; +struct adf_etr_ring_data *rings;struct tasklet_struct resp_handler;void __iomem *csr_addr;u32 irq_coalesc_timer;
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -185,6 +185,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->dev_class = &dh895xcc_class; hw_data->instance_id = dh895xcc_class.instances++; hw_data->num_banks =ADF_DH895XCC_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_DH895XCC_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_DH895XCC_MAX_ACCELENGINES ;
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +1 -0
@@ -69,6 +69,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) { hw_data->dev_class = &dh895xcciov_class; hw_data->num_banks =ADF_DH895XCCIOV_ETR_MAX_BANKS ; + hw_data->num_rings_per_bank =ADF_ETR_MAX_RINGS_PER_BANK ; hw_data->num_accel =ADF_DH895XCCIOV_MAX_ACCELERATORS ; hw_data->num_logical_accel =1 ; hw_data->num_engines =ADF_DH895XCCIOV_MAX_ACCELENGINES ;
Signature · 1 line
2.26.2
PATCH 4/31 crypto: qat - fix configuration of iov threads
In reply to Giovanni CabidduThe number of AE2FUNC_MAP registers is different in every QAT device (c62x, c3xxx and dh895xcc) although the logic and the register offsets are the same across devices.
This patch separates the logic that configures the iov threads in a common function that takes as input the number of AE2FUNC_MAP registers supported by a device. The function is then added to the adf_hw_device_data structure of each device, and called with the appropriate parameters.
The configure iov thread logic is added to a new file, adf_gen2_hw_data.c, that is going to contain code that is shared across QAT GEN2 devices.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 9 +++ .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h | 4 ++ .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 9 +++ .../crypto/qat/qat_c62x/adf_c62x_hw_data.h | 4 ++ drivers/crypto/qat/qat_common/Makefile | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 2 + .../crypto/qat/qat_common/adf_gen2_hw_data.c | 38 +++++++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 30 +++++++++ drivers/crypto/qat/qat_common/adf_sriov.c | 63 ++----------------- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 9 +++ .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 5 ++ 11 files changed, 115 insertions(+), 59 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +9 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_pf2vf_msg.h> +#include <adf_gen2_hw_data.h> #include "adf_c3xxx_hw_data.h" /* Worker thread to service arbiter mappings based on dev SKUs */
@@ -171,6 +172,13 @@ static int adf_pf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev)return 0 ; } +static void configure_iov_threads (struct adf_accel_dev *accel_dev,bool enable) +{ +adf_gen2_cfg_iov_thds (accel_dev, enable, +ADF_C3XXX_AE2FUNC_MAP_GRP_A_NUM_REGS , +ADF_C3XXX_AE2FUNC_MAP_GRP_B_NUM_REGS ); +} +void adf_init_hw_data_c3xxx (struct adf_hw_device_data *hw_data) { hw_data->dev_class = &c3xxx_class;
@@ -199,6 +207,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->fw_mmp_name =ADF_C3XXX_MMP ; hw_data->init_admin_comms = adf_init_admin_comms; hw_data->exit_admin_comms = adf_exit_admin_comms; + hw_data->configure_iov_threads = configure_iov_threads; hw_data->disable_iov = adf_disable_sriov; hw_data->send_admin_init = adf_send_admin_init; hw_data->init_arb = adf_init_arb;
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h +4 -0
@@ -31,6 +31,10 @@#define ADF_C3XXX_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04))#define ADF_C3XXX_VINTMSK_OFFSET (i) (0x3A000 + 0x200 + ((i) * 0x04)) +/* AE to function mapping */ +#define ADF_C3XXX_AE2FUNC_MAP_GRP_A_NUM_REGS 48 +#define ADF_C3XXX_AE2FUNC_MAP_GRP_B_NUM_REGS 6 +/* Firmware Binary */ #define ADF_C3XXX_FW "qat_c3xxx.bin"#define ADF_C3XXX_MMP "qat_c3xxx_mmp.bin"
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +9 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_common_drv.h> #include <adf_pf2vf_msg.h> +#include <adf_gen2_hw_data.h> #include "adf_c62x_hw_data.h" /* Worker thread to service arbiter mappings based on dev SKUs */
@@ -181,6 +182,13 @@ static int adf_pf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev)return 0 ; } +static void configure_iov_threads (struct adf_accel_dev *accel_dev,bool enable) +{ +adf_gen2_cfg_iov_thds (accel_dev, enable, +ADF_C62X_AE2FUNC_MAP_GRP_A_NUM_REGS , +ADF_C62X_AE2FUNC_MAP_GRP_B_NUM_REGS ); +} +void adf_init_hw_data_c62x (struct adf_hw_device_data *hw_data) { hw_data->dev_class = &c62x_class;
@@ -209,6 +217,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->fw_mmp_name =ADF_C62X_MMP ; hw_data->init_admin_comms = adf_init_admin_comms; hw_data->exit_admin_comms = adf_exit_admin_comms; + hw_data->configure_iov_threads = configure_iov_threads; hw_data->disable_iov = adf_disable_sriov; hw_data->send_admin_init = adf_send_admin_init; hw_data->init_arb = adf_init_arb;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.h +4 -0
@@ -32,6 +32,10 @@#define ADF_C62X_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04))#define ADF_C62X_VINTMSK_OFFSET (i) (0x3A000 + 0x200 + ((i) * 0x04)) +/* AE to function mapping */ +#define ADF_C62X_AE2FUNC_MAP_GRP_A_NUM_REGS 80 +#define ADF_C62X_AE2FUNC_MAP_GRP_B_NUM_REGS 10 +/* Firmware Binary */ #define ADF_C62X_FW "qat_c62x.bin"#define ADF_C62X_MMP "qat_c62x_mmp.bin"
drivers/crypto/qat/qat_common/Makefile +1 -0
@@ -10,6 +10,7 @@ intel_qat-objs := adf_cfg.o \ adf_transport.o \ adf_admin.o \ adf_hw_arbiter.o \ + adf_gen2_hw_data.o \ qat_crypto.o \ qat_algs.o \ qat_asym_algs.o \
drivers/crypto/qat/qat_common/adf_accel_devices.h +2 -0
@@ -125,6 +125,8 @@ struct adf_hw_device_data {void (*get_arb_mapping)(struct adf_accel_dev *accel_dev,const u32 **cfg);void (*disable_iov)(struct adf_accel_dev *accel_dev); +void (*configure_iov_threads)(struct adf_accel_dev *accel_dev, +bool enable);void (*enable_ints)(struct adf_accel_dev *accel_dev);int (*enable_vf2pf_comms)(struct adf_accel_dev *accel_dev);void (*reset_device)(struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) +/* Copyright(c) 2020 Intel Corporation */ +#include "adf_gen2_hw_data.h" + +void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable, +int num_a_regs,int num_b_regs) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +void __iomem *pmisc_addr; +struct adf_bar *pmisc; +int pmisc_id, i; +u32 reg; + + pmisc_id = hw_data->get_misc_bar_id (hw_data); + pmisc = &GET_BARS (accel_dev)[pmisc_id]; + pmisc_addr = pmisc->virt_addr; + +/* Set/Unset Valid bit in AE Thread to PCIe Function Mapping Group A */ +for (i =0 ; i < num_a_regs; i++) { + reg =READ_CSR_AE2FUNCTION_MAP_A (pmisc_addr, i); +if (enable) + reg |=AE2FUNCTION_MAP_VALID ; +else + reg &= ~AE2FUNCTION_MAP_VALID ; +WRITE_CSR_AE2FUNCTION_MAP_A (pmisc_addr, i, reg); + } + +/* Set/Unset Valid bit in AE Thread to PCIe Function Mapping Group B */ +for (i =0 ; i < num_b_regs; i++) { + reg =READ_CSR_AE2FUNCTION_MAP_B (pmisc_addr, i); +if (enable) + reg |=AE2FUNCTION_MAP_VALID ; +else + reg &= ~AE2FUNCTION_MAP_VALID ; +WRITE_CSR_AE2FUNCTION_MAP_B (pmisc_addr, i, reg); + } +} +EXPORT_SYMBOL_GPL (adf_gen2_cfg_iov_thds);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2020 Intel Corporation */ +#ifndef ADF_GEN2_HW_DATA_H_ +#define ADF_GEN2_HW_DATA_H_ + +#include "adf_accel_devices.h" + +/* AE to function map */ +#define AE2FUNCTION_MAP_A_OFFSET (0x3A400 + 0x190) +#define AE2FUNCTION_MAP_B_OFFSET (0x3A400 + 0x310) +#define AE2FUNCTION_MAP_REG_SIZE 4 +#define AE2FUNCTION_MAP_VALID BIT(7) + +#define READ_CSR_AE2FUNCTION_MAP_A (pmisc_bar_addr, index) \ + ADF_CSR_RD(pmisc_bar_addr, AE2FUNCTION_MAP_A_OFFSET + \ + AE2FUNCTION_MAP_REG_SIZE * (index)) +#define WRITE_CSR_AE2FUNCTION_MAP_A (pmisc_bar_addr, index, value) \ + ADF_CSR_WR(pmisc_bar_addr, AE2FUNCTION_MAP_A_OFFSET + \ + AE2FUNCTION_MAP_REG_SIZE * (index), value) +#define READ_CSR_AE2FUNCTION_MAP_B (pmisc_bar_addr, index) \ + ADF_CSR_RD(pmisc_bar_addr, AE2FUNCTION_MAP_B_OFFSET + \ + AE2FUNCTION_MAP_REG_SIZE * (index)) +#define WRITE_CSR_AE2FUNCTION_MAP_B (pmisc_bar_addr, index, value) \ + ADF_CSR_WR(pmisc_bar_addr, AE2FUNCTION_MAP_B_OFFSET + \ + AE2FUNCTION_MAP_REG_SIZE * (index), value) + +void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable, +int num_a_regs,int num_b_regs); + +#endif
drivers/crypto/qat/qat_common/adf_sriov.c +4 -59
97 lines not on this page · raw message
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +9 -0
@@ -3,6 +3,7 @@#include <adf_accel_devices.h> #include <adf_pf2vf_msg.h> #include <adf_common_drv.h> +#include <adf_gen2_hw_data.h> #include "adf_dh895xcc_hw_data.h" /* Worker thread to service arbiter mappings based on dev SKUs */
@@ -180,6 +181,13 @@ static int adf_pf_enable_vf2pf_comms(struct adf_accel_dev *accel_dev)return 0 ; } +static void configure_iov_threads (struct adf_accel_dev *accel_dev,bool enable) +{ +adf_gen2_cfg_iov_thds (accel_dev, enable, +ADF_DH895XCC_AE2FUNC_MAP_GRP_A_NUM_REGS , +ADF_DH895XCC_AE2FUNC_MAP_GRP_B_NUM_REGS ); +} +void adf_init_hw_data_dh895xcc (struct adf_hw_device_data *hw_data) { hw_data->dev_class = &dh895xcc_class;
@@ -208,6 +216,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->fw_mmp_name =ADF_DH895XCC_MMP ; hw_data->init_admin_comms = adf_init_admin_comms; hw_data->exit_admin_comms = adf_exit_admin_comms; + hw_data->configure_iov_threads = configure_iov_threads; hw_data->disable_iov = adf_disable_sriov; hw_data->send_admin_init = adf_send_admin_init; hw_data->init_arb = adf_init_arb;
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h +5 -0
@@ -36,6 +36,11 @@#define ADF_DH895XCC_PF2VF_OFFSET (i) (0x3A000 + 0x280 + ((i) * 0x04))#define ADF_DH895XCC_VINTMSK_OFFSET (i) (0x3A000 + 0x200 + ((i) * 0x04)) + +/* AE to function mapping */ +#define ADF_DH895XCC_AE2FUNC_MAP_GRP_A_NUM_REGS 96 +#define ADF_DH895XCC_AE2FUNC_MAP_GRP_B_NUM_REGS 12 +/* FW names */ #define ADF_DH895XCC_FW "qat_895xcc.bin"#define ADF_DH895XCC_MMP "qat_895xcc_mmp.bin"
Signature · 1 line
2.26.2
PATCH 5/31 crypto: qat - split transport CSR access logic
In reply to Giovanni CabidduAbstract access to transport CSRs and move generation specific code into adf_gen2_hw_data.c in preparation for the introduction of the qat_4xxx driver.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 2 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 2 + .../crypto/qat/qat_common/adf_accel_devices.h | 27 ++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.c | 85 ++++++++++++++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 1 + drivers/crypto/qat/qat_common/adf_isr.c | 4 +- drivers/crypto/qat/qat_common/adf_transport.c | 86 +++++++++++++------ .../qat/qat_common/adf_transport_debug.c | 22 ++--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 5 +- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 2 + 13 files changed, 198 insertions(+), 41 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -217,6 +217,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms; hw_data->reset_device = adf_reset_flr; hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; +adf_gen2_init_hw_csr_ops (&hw_data->csr_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_pf2vf_msg.h> #include <adf_common_drv.h> +#include <adf_gen2_hw_data.h> #include "adf_c3xxxvf_hw_data.h" static struct adf_hw_device_class c3xxxiov_class = {
@@ -98,6 +99,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }void adf_clean_hw_data_c3xxxiov (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -227,6 +227,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms; hw_data->reset_device = adf_reset_flr; hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; +adf_gen2_init_hw_csr_ops (&hw_data->csr_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_pf2vf_msg.h> #include <adf_common_drv.h> +#include <adf_gen2_hw_data.h> #include "adf_c62xvf_hw_data.h" static struct adf_hw_device_class c62xiov_class = {
@@ -98,6 +99,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }void adf_clean_hw_data_c62xiov (struct adf_hw_device_data *hw_data)
drivers/crypto/qat/qat_common/adf_accel_devices.h +27 -0
@@ -97,6 +97,31 @@ struct adf_hw_device_class {u32 instances; } __packed; +struct adf_hw_csr_ops { +u32 (*read_csr_ring_head)(void __iomem *csr_base_addr,u32 bank, +u32 ring); +void (*write_csr_ring_head)(void __iomem *csr_base_addr,u32 bank, +u32 ring,u32 value); +u32 (*read_csr_ring_tail)(void __iomem *csr_base_addr,u32 bank, +u32 ring); +void (*write_csr_ring_tail)(void __iomem *csr_base_addr,u32 bank, +u32 ring,u32 value); +u32 (*read_csr_e_stat)(void __iomem *csr_base_addr,u32 bank); +void (*write_csr_ring_config)(void __iomem *csr_base_addr,u32 bank, +u32 ring,u32 value); +void (*write_csr_ring_base)(void __iomem *csr_base_addr,u32 bank, +u32 ring,dma_addr_t addr); +void (*write_csr_int_flag)(void __iomem *csr_base_addr,u32 bank, +u32 value); +void (*write_csr_int_srcsel)(void __iomem *csr_base_addr,u32 bank); +void (*write_csr_int_col_en)(void __iomem *csr_base_addr,u32 bank, +u32 value); +void (*write_csr_int_col_ctl)(void __iomem *csr_base_addr,u32 bank, +u32 value); +void (*write_csr_int_flag_and_col)(void __iomem *csr_base_addr, +u32 bank,u32 value); +}; +struct adf_cfg_device_data ;struct adf_accel_dev ;struct adf_etr_data ;
@@ -130,6 +155,7 @@ struct adf_hw_device_data {void (*enable_ints)(struct adf_accel_dev *accel_dev);int (*enable_vf2pf_comms)(struct adf_accel_dev *accel_dev);void (*reset_device)(struct adf_accel_dev *accel_dev); +struct adf_hw_csr_ops csr_ops;const char *fw_name;const char *fw_mmp_name;u32 fuses;
@@ -162,6 +188,7 @@ struct adf_hw_device_data {#define GET_NUM_RINGS_PER_BANK (accel_dev) \ GET_HW_DATA(accel_dev)->num_rings_per_bank#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 accel_to_pci_dev (accel_ptr) accel_ptr->accel_pci_dev.pci_devstruct adf_admin_comms ;
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +85 -0
94 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +1 -0
@@ -26,5 +26,6 @@void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs); +void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops);#endif
drivers/crypto/qat/qat_common/adf_isr.c +3 -1
@@ -50,8 +50,10 @@ static void adf_disable_msix(struct adf_accel_pci *pci_dev_info)static irqreturn_t adf_msix_isr_bundle (int irq,void *bank_ptr) {struct adf_etr_bank_data *bank = bank_ptr; +struct adf_hw_csr_ops *csr_ops =GET_CSR_OPS (bank->accel_dev); -WRITE_CSR_INT_FLAG_AND_COL (bank->csr_addr, bank->bank_number,0 ); + csr_ops->write_csr_int_flag_and_col (bank->csr_addr, bank->bank_number, +0 );tasklet_hi_schedule (&bank->resp_handler);return IRQ_HANDLED ; }
drivers/crypto/qat/qat_common/adf_transport.c +58 -28
199 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_transport_debug.c +12 -10
@@ -42,16 +42,17 @@ static int adf_ring_show(struct seq_file *sfile, void *v) {struct adf_etr_ring_data *ring = sfile->private;struct adf_etr_bank_data *bank = ring->bank; +struct adf_hw_csr_ops *csr_ops =GET_CSR_OPS (bank->accel_dev);void __iomem *csr = ring->bank->csr_addr;if (v ==SEQ_START_TOKEN ) {int head, tail, empty; - head =READ_CSR_RING_HEAD (csr, bank->bank_number, - ring->ring_number); - tail =READ_CSR_RING_TAIL (csr, bank->bank_number, - ring->ring_number); - empty =READ_CSR_E_STAT (csr, bank->bank_number); + head = csr_ops->read_csr_ring_head (csr, bank->bank_number, + ring->ring_number); + tail = csr_ops->read_csr_ring_tail (csr, bank->bank_number, + ring->ring_number); + empty = csr_ops->read_csr_e_stat (csr, bank->bank_number);seq_puts (sfile,"------- Ring configuration -------\n" ); seq_printf(sfile, "ring name: %s\n",
@@ -144,6 +145,7 @@ static void *adf_bank_next(struct seq_file *sfile, void *v, loff_t *pos)static int adf_bank_show (struct seq_file *sfile,void *v) {struct adf_etr_bank_data *bank = sfile->private; +struct adf_hw_csr_ops *csr_ops =GET_CSR_OPS (bank->accel_dev);if (v ==SEQ_START_TOKEN ) { seq_printf(sfile, "------- Bank %d configuration -------\n",
@@ -157,11 +159,11 @@ static int adf_bank_show(struct seq_file *sfile, void *v)if (!(bank->ring_mask &1 << ring_id))return 0 ; - head =READ_CSR_RING_HEAD (csr, bank->bank_number, - ring->ring_number); - tail =READ_CSR_RING_TAIL (csr, bank->bank_number, - ring->ring_number); - empty =READ_CSR_E_STAT (csr, bank->bank_number); + head = csr_ops->read_csr_ring_head (csr, bank->bank_number, + ring->ring_number); + tail = csr_ops->read_csr_ring_tail (csr, bank->bank_number, + ring->ring_number); + empty = csr_ops->read_csr_e_stat (csr, bank->bank_number); seq_printf(sfile, "ring num %02d, head %04x, tail %04x, empty: %d\n",
drivers/crypto/qat/qat_common/adf_vf_isr.c +3 -2
@@ -156,6 +156,7 @@ static irqreturn_t adf_isr(int irq, void *privdata) {struct adf_accel_dev *accel_dev = privdata;struct adf_hw_device_data *hw_data = accel_dev->hw_device; +struct adf_hw_csr_ops *csr_ops = &hw_data->csr_ops;struct adf_bar *pmisc = &GET_BARS (accel_dev)[hw_data->get_misc_bar_id (hw_data)];void __iomem *pmisc_bar_addr = pmisc->virt_addr;
@@ -180,8 +181,8 @@ static irqreturn_t adf_isr(int irq, void *privdata)struct adf_etr_bank_data *bank = &etr_data->banks[0 ];/* Disable Flag and Coalesce Ring Interrupts */ -WRITE_CSR_INT_FLAG_AND_COL (bank->csr_addr, bank->bank_number, -0 ); + csr_ops->write_csr_int_flag_and_col (bank->csr_addr, + bank->bank_number,0 );tasklet_hi_schedule (&bank->resp_handler);return IRQ_HANDLED ; }
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -226,6 +226,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms; hw_data->reset_device = adf_reset_sbr; hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; +adf_gen2_init_hw_csr_ops (&hw_data->csr_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_pf2vf_msg.h> #include <adf_common_drv.h> +#include <adf_gen2_hw_data.h> #include "adf_dh895xccvf_hw_data.h" static struct adf_hw_device_class dh895xcciov_class = {
@@ -98,6 +99,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) hw_data->min_iov_compat_ver =ADF_PFVF_COMPATIBILITY_VERSION ; hw_data->dev_class->instances++;adf_devmgr_update_class_index (hw_data); +adf_gen2_init_hw_csr_ops (&hw_data->csr_ops); }void adf_clean_hw_data_dh895xcciov (struct adf_hw_device_data *hw_data)
Signature · 1 line
2.26.2
PATCH 6/31 crypto: qat - relocate GEN2 CSR access code
In reply to Giovanni CabidduMove gen2 specific transport macros to adf_gen2_hw_data.c.
--- .../crypto/qat/qat_common/adf_gen2_hw_data.c | 1 - .../crypto/qat/qat_common/adf_gen2_hw_data.h | 68 +++++++++++++++++++ .../qat_common/adf_transport_access_macros.h | 64 ----------------- 3 files changed, 68 insertions(+), 65 deletions(-)
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2020 Intel Corporation */ #include "adf_gen2_hw_data.h" -#include "adf_transport_access_macros.h" void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs)
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +68 -0
74 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_transport_access_macros.h +0 -64
75 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 7/31 crypto: qat - abstract admin interface
In reply to Giovanni CabidduAbstract access to admin interface and move generation specific code into adf_gen2_hw_data.c in preparation for the introduction of the qat_4xxx driver.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 7 ++++++ drivers/crypto/qat/qat_common/adf_admin.c | 25 +++++++++++-------- .../crypto/qat/qat_common/adf_gen2_hw_data.c | 8 ++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 6 +++++ .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + 7 files changed, 39 insertions(+), 10 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -202,6 +202,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; + hw_data->get_admin_info = adf_gen2_get_admin_info; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_C3XXX_FW ; hw_data->fw_mmp_name =ADF_C3XXX_MMP ;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -212,6 +212,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; + hw_data->get_admin_info = adf_gen2_get_admin_info; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_C62X_FW ; hw_data->fw_mmp_name =ADF_C62X_MMP ;
drivers/crypto/qat/qat_common/adf_accel_devices.h +7 -0
@@ -97,6 +97,12 @@ struct adf_hw_device_class {u32 instances; } __packed; +struct admin_info { +u32 admin_msg_ur; +u32 admin_msg_lr; +u32 mailbox_offset; +}; +struct adf_hw_csr_ops {u32 (*read_csr_ring_head)(void __iomem *csr_base_addr,u32 bank,u32 ring);
@@ -138,6 +144,7 @@ struct adf_hw_device_data {u32 (*get_num_accels)(struct adf_hw_device_data *self);u32 (*get_pf2vf_offset)(u32 i);u32 (*get_vintmsk_offset)(u32 i); +void (*get_admin_info)(struct admin_info *admin_csrs_info);enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self);int (*alloc_irq)(struct adf_accel_dev *accel_dev);void (*free_irq)(struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_admin.c +15 -10
@@ -10,11 +10,7 @@#include "adf_common_drv.h" #include "icp_qat_fw_init_admin.h" -/* Admin Messages Registers */ -#define ADF_DH895XCC_ADMINMSGUR_OFFSET (0x3A000 + 0x574) -#define ADF_DH895XCC_ADMINMSGLR_OFFSET (0x3A000 + 0x578) -#define ADF_DH895XCC_MAILBOX_BASE_OFFSET 0x20970 -#define ADF_DH895XCC_MAILBOX_STRIDE 0x1000 +#define ADF_ADMIN_MAILBOX_STRIDE 0x1000#define ADF_ADMINMSG_LEN 32#define ADF_CONST_TABLE_SIZE 1024#define ADF_ADMIN_POLL_DELAY_US 20
@@ -118,7 +114,7 @@ static int adf_put_admin_msg_sync(struct adf_accel_dev *accel_dev, u32 ae,struct adf_admin_comms *admin = accel_dev->admin;int offset = ae *ADF_ADMINMSG_LEN *2 ;void __iomem *mailbox = admin->mailbox_addr; -int mb_offset = ae *ADF_DH895XCC_MAILBOX_STRIDE ; +int mb_offset = ae *ADF_ADMIN_MAILBOX_STRIDE ;struct icp_qat_fw_init_admin_req *request = in;mutex_lock (&admin->lock);
@@ -225,8 +221,9 @@ int adf_init_admin_comms(struct adf_accel_dev *accel_dev)struct adf_bar *pmisc = &GET_BARS (accel_dev)[hw_data->get_misc_bar_id (hw_data)];void __iomem *csr = pmisc->virt_addr; -void __iomem *mailbox = (void __iomem *)((uintptr_t )csr + -ADF_DH895XCC_MAILBOX_BASE_OFFSET ); +struct admin_info admin_csrs_info; +u32 mailbox_offset, adminmsg_u, adminmsg_l; +void __iomem *mailbox;u64 reg_val; admin = kzalloc_node(sizeof(*accel_dev->admin), GFP_KERNEL,
@@ -254,9 +251,17 @@ int adf_init_admin_comms(struct adf_accel_dev *accel_dev) }memcpy (admin->virt_tbl_addr, const_tab,sizeof (const_tab)); + hw_data->get_admin_info (&admin_csrs_info); + + mailbox_offset = admin_csrs_info.mailbox_offset; + mailbox = (void __iomem *)((uintptr_t )csr + mailbox_offset); + adminmsg_u = admin_csrs_info.admin_msg_ur; + adminmsg_l = admin_csrs_info.admin_msg_lr; + reg_val = (u64 )admin->phy_addr; -ADF_CSR_WR (csr,ADF_DH895XCC_ADMINMSGUR_OFFSET , reg_val >>32 ); -ADF_CSR_WR (csr,ADF_DH895XCC_ADMINMSGLR_OFFSET , reg_val); +ADF_CSR_WR (csr, adminmsg_u,upper_32_bits (reg_val)); +ADF_CSR_WR (csr, adminmsg_l,lower_32_bits (reg_val)); +mutex_init (&admin->lock); admin->mailbox_addr = mailbox; accel_dev->admin = admin;
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +8 -0
@@ -37,6 +37,14 @@ void adf_gen2_cfg_iov_thds(struct adf_accel_dev *accel_dev, bool enable, }EXPORT_SYMBOL_GPL (adf_gen2_cfg_iov_thds); +void adf_gen2_get_admin_info (struct admin_info *admin_csrs_info) +{ + admin_csrs_info->mailbox_offset =ADF_MAILBOX_BASE_OFFSET ; + admin_csrs_info->admin_msg_ur =ADF_ADMINMSGUR_OFFSET ; + admin_csrs_info->admin_msg_lr =ADF_ADMINMSGLR_OFFSET ; +} +EXPORT_SYMBOL_GPL (adf_gen2_get_admin_info); +static u32 read_csr_ring_head (void __iomem *csr_base_addr,u32 bank,u32 ring) {return READ_CSR_RING_HEAD (csr_base_addr, bank, ring);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +6 -0
@@ -92,8 +92,14 @@ do { \ADF_CSR_WR (pmisc_bar_addr,AE2FUNCTION_MAP_B_OFFSET + \AE2FUNCTION_MAP_REG_SIZE * (index), value) +/* Admin Interface Offsets */ +#define ADF_ADMINMSGUR_OFFSET (0x3A000 + 0x574) +#define ADF_ADMINMSGLR_OFFSET (0x3A000 + 0x578) +#define ADF_MAILBOX_BASE_OFFSET 0x20970 +void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs);void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops); +void adf_gen2_get_admin_info (struct admin_info *admin_csrs_info);#endif
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -210,6 +210,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_misc_bar_id = get_misc_bar_id; hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; + hw_data->get_admin_info = adf_gen2_get_admin_info; hw_data->get_sram_bar_id = get_sram_bar_id; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_DH895XCC_FW ;
Signature · 1 line
2.26.2
PATCH 8/31 crypto: qat - add packed to init admin structures
In reply to Giovanni CabidduAdd packed attribute to the structures icp_qat_fw_init_admin_req and icp_qat_fw_init_admin_resp as they are accessed by firmware.
--- drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h +2 -2
@@ -39,7 +39,7 @@ struct icp_qat_fw_init_admin_req { };__u32 resrvd4; -}; +} __packed;struct icp_qat_fw_init_admin_resp {__u8 flags;
@@ -92,7 +92,7 @@ struct icp_qat_fw_init_admin_resp {__u64 resrvd8; }; }; -}; +} __packed;#define ICP_QAT_FW_COMN_HEARTBEAT_OK 0#define ICP_QAT_FW_COMN_HEARTBEAT_BLOCKED 1
Signature · 1 line
2.26.2
PATCH 9/31 crypto: qat - rename ME in AE
In reply to Giovanni CabidduRename occurrences of ME in the admin module with the acronym AE (Acceleration Engine) as the two are equivalent.
This is to keep a single acronym for engined in the codebase and follow the documentation in https://01.org/intel-quickassist-technology.
--- drivers/crypto/qat/qat_common/adf_admin.c | 6 +++--- drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/adf_admin.c +3 -3
@@ -163,7 +163,7 @@ static int adf_send_admin(struct adf_accel_dev *accel_dev,return 0 ; } -static int adf_init_me (struct adf_accel_dev *accel_dev) +static int adf_init_ae (struct adf_accel_dev *accel_dev) {struct icp_qat_fw_init_admin_req req;struct icp_qat_fw_init_admin_resp resp;
@@ -172,7 +172,7 @@ static int adf_init_me(struct adf_accel_dev *accel_dev)memset (&req,0 ,sizeof (req));memset (&resp,0 ,sizeof (resp)); - req.cmd_id =ICP_QAT_FW_INIT_ME ; + req.cmd_id =ICP_QAT_FW_INIT_AE ;return adf_send_admin (accel_dev, &req, &resp, ae_mask); }
@@ -206,7 +206,7 @@ int adf_send_admin_init(struct adf_accel_dev *accel_dev) {int ret; - ret =adf_init_me (accel_dev); + ret =adf_init_ae (accel_dev);if (ret)return ret;
drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h +1 -1
@@ -6,7 +6,7 @@#include "icp_qat_fw.h" enum icp_qat_fw_init_admin_cmd_id { -ICP_QAT_FW_INIT_ME =0 , +ICP_QAT_FW_INIT_AE =0 ,ICP_QAT_FW_TRNG_ENABLE =1 ,ICP_QAT_FW_TRNG_DISABLE =2 ,ICP_QAT_FW_CONSTANTS_CFG =3 ,
Signature · 1 line
2.26.2
PATCH 10/31 crypto: qat - change admin sequence
In reply to Giovanni CabidduCall adf_set_fw_constants() before adf_init_ae().
This is required by QAT GEN4 devices, which expect that the FW_CONSTANTS_CFG command is sent to the admin AEs before the FW_INIT_AE command.
Swapping the order of the two commands (FW_INIT_AE and FW_CONSTANTS_CFG) is allowed in QAT GEN2 devices as the firmware can handle those in any order.
--- drivers/crypto/qat/qat_common/adf_admin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_admin.c +2 -2
@@ -206,11 +206,11 @@ int adf_send_admin_init(struct adf_accel_dev *accel_dev) {int ret; - ret =adf_init_ae (accel_dev); + ret =adf_set_fw_constants (accel_dev);if (ret)return ret; -return adf_set_fw_constants (accel_dev); +return adf_init_ae (accel_dev); }EXPORT_SYMBOL_GPL (adf_send_admin_init);
Signature · 1 line
2.26.2
PATCH 11/31 crypto: qat - use admin mask to send fw constants
In reply to Giovanni CabidduIntroduce admin AE mask. If this mask set, the fw constant message is sent only to engines that belong to that set, otherwise it is sent to all engines.
This is in preparation for the qat_4xxx driver where the constant message should be sent only to admin engines.
In GEN2 devices (c62x, c3xxx and dh895xcc), the admin AE mask is 0 and the fw constants message is sent to all AEs.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_admin.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -171,6 +171,7 @@ struct adf_hw_device_data {u32 instance_id;u16 accel_mask;u16 ae_mask; +u32 admin_ae_mask;u16 tx_rings_mask;u8 tx_rx_gap;u8 num_banks;
drivers/crypto/qat/qat_common/adf_admin.c +1 -1
@@ -182,7 +182,7 @@ static int adf_set_fw_constants(struct adf_accel_dev *accel_dev)struct icp_qat_fw_init_admin_req req;struct icp_qat_fw_init_admin_resp resp;struct adf_hw_device_data *hw_device = accel_dev->hw_device; -u32 ae_mask = hw_device->ae_mask; +u32 ae_mask = hw_device->admin_ae_mask ?: hw_device->ae_mask;memset (&req,0 ,sizeof (req));memset (&resp,0 ,sizeof (resp));
Signature · 1 line
2.26.2
PATCH 12/31 crypto: qat - update constants table
In reply to Giovanni CabidduExtend admin contansts table to support QAT GEN4 devices.
This change does not affect QAT GEN2 devices (c62x, c3xxx and dh895xcc) as the table was extended in an unused area which is not referenced by any of those drivers and devices.
--- drivers/crypto/qat/qat_common/adf_admin.c | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/crypto/qat/qat_common/adf_admin.c +22 -22
@@ -66,28 +66,28 @@ static const u8 const_tab[1024] __aligned(1024) = {0xf8 ,0x2b ,0xa5 ,0x4f ,0xf5 ,0x3a ,0x5f ,0x1d ,0x36 ,0xf1 ,0x51 ,0x0e ,0x52 ,0x7f ,0xad ,0xe6 ,0x82 ,0xd1 ,0x9b ,0x05 ,0x68 ,0x8c ,0x2b ,0x3e ,0x6c ,0x1f ,0x1f ,0x83 ,0xd9 ,0xab ,0xfb ,0x41 ,0xbd ,0x6b ,0x5b ,0xe0 ,0xcd ,0x19 ,0x13 , -0x7e ,0x21 ,0x79 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x7e ,0x21 ,0x79 ,0x14 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x40 ,0x00 ,0x00 ,0x00 ,0x00 ,0x16 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x80 ,0x00 ,0x00 ,0x00 ,0x00 ,0x12 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x40 ,0x00 ,0x00 ,0x00 ,0x00 ,0x18 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x14 ,0x01 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x15 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x14 ,0x02 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x14 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x15 ,0x02 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x15 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x24 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x25 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x24 ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x25 , +0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x12 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x12 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x43 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x43 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x45 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x45 ,0x01 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x44 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x44 ,0x01 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x2B ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x2B ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x20 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x80 ,0x00 ,0x00 ,0x00 ,0x00 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x10 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Signature · 1 line
2.26.2
PATCH 13/31 crypto: qat - remove writes into WQCFG
In reply to Giovanni CabidduWQCFG registers contain the correct values after reset in all generations of QAT. No need to write into them.
--- drivers/crypto/qat/qat_common/adf_hw_arbiter.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/crypto/qat/qat_common/adf_hw_arbiter.c +0 -13
@@ -11,7 +11,6 @@#define ADF_ARB_REG_SLOT 0x1000#define ADF_ARB_WTR_OFFSET 0x010#define ADF_ARB_RO_EN_OFFSET 0x090 -#define ADF_ARB_WQCFG_OFFSET 0x100#define ADF_ARB_WRK_2_SER_MAP_OFFSET 0x180#define ADF_ARB_RINGSRVARBEN_OFFSET 0x19C
@@ -28,10 +27,6 @@ ADF_ARB_WRK_2_SER_MAP_OFFSET) + \ (ADF_ARB_REG_SIZE * index), value) -#define WRITE_CSR_ARB_WQCFG (csr_addr, index, value) \ - ADF_CSR_WR(csr_addr, (ADF_ARB_OFFSET + \ - ADF_ARB_WQCFG_OFFSET) + (ADF_ARB_REG_SIZE * index), value) -int adf_init_arb (struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_data = accel_dev->hw_device;
@@ -45,10 +40,6 @@ int adf_init_arb(struct adf_accel_dev *accel_dev)for (arb =0 ; arb <ADF_ARB_NUM ; arb++)WRITE_CSR_ARB_SARCONFIG (csr, arb, arb_cfg); -/* Setup worker queue registers */ -for (i =0 ; i < hw_data->num_engines; i++) -WRITE_CSR_ARB_WQCFG (csr, i, i); -/* Map worker threads to service arbiters */ hw_data->get_arb_mapping (accel_dev, &thd_2_arb_cfg);
@@ -84,10 +75,6 @@ void adf_exit_arb(struct adf_accel_dev *accel_dev)for (i =0 ; i <ADF_ARB_NUM ; i++)WRITE_CSR_ARB_SARCONFIG (csr, i,0 ); -/* Shutdown work queue */ -for (i =0 ; i < hw_data->num_engines; i++) -WRITE_CSR_ARB_WQCFG (csr, i,0 ); -/* Unmap worker threads to service arbiters */ for (i =0 ; i < hw_data->num_engines; i++)WRITE_CSR_ARB_WRK_2_SER_MAP (csr, i,0 );
Signature · 1 line
2.26.2
PATCH 14/31 crypto: qat - remove unused macros in arbiter module
In reply to Giovanni CabidduRemove the unused macros ADF_ARB_WTR_SIZE, ADF_ARB_WTR_OFFSET and ADF_ARB_RO_EN_OFFSET.
These macros were left in commit 34074205bb9f ("crypto: qat - remove redundant arbiter configuration") that removed the logic that used those defines.
--- drivers/crypto/qat/qat_common/adf_hw_arbiter.c | 3 --- 1 file changed, 3 deletions(-)
drivers/crypto/qat/qat_common/adf_hw_arbiter.c +0 -3
@@ -6,11 +6,8 @@#define ADF_ARB_NUM 4#define ADF_ARB_REG_SIZE 0x4 -#define ADF_ARB_WTR_SIZE 0x20#define ADF_ARB_OFFSET 0x30000#define ADF_ARB_REG_SLOT 0x1000 -#define ADF_ARB_WTR_OFFSET 0x010 -#define ADF_ARB_RO_EN_OFFSET 0x090#define ADF_ARB_WRK_2_SER_MAP_OFFSET 0x180#define ADF_ARB_RINGSRVARBEN_OFFSET 0x19C
Signature · 1 line
2.26.2
PATCH 15/31 crypto: qat - abstract arbiter access
In reply to Giovanni CabidduThe arbiter configuration, the offset to the arbiter config CSR and the offset to the worker thread to service arbiter CSR are going to be different in QAT GEN4 devices although the logic that uses them is the same across all QAT generations.
This patch reworks the gen-specific parts of the arbiter access code by introducing the arb_info structure, that contains the values that are generation specific, and a function in the structure adf_hw_device_data, get_arb_info(), that allows to get them.
Since the arbiter values for QAT GEN2 devices (c62x, c3xxx and dh895xcc) are the same, a single function, adf_gen2_get_arb_info() is provided in adf_gen2_hw_data.c and referenced by each QAT GEN2 driver.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 7 ++++ .../crypto/qat/qat_common/adf_gen2_hw_data.c | 8 ++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 6 +++ .../crypto/qat/qat_common/adf_hw_arbiter.c | 41 ++++++++++++------- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + 7 files changed, 50 insertions(+), 15 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -203,6 +203,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; hw_data->get_admin_info = adf_gen2_get_admin_info; + hw_data->get_arb_info = adf_gen2_get_arb_info; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_C3XXX_FW ; hw_data->fw_mmp_name =ADF_C3XXX_MMP ;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -213,6 +213,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; hw_data->get_admin_info = adf_gen2_get_admin_info; + hw_data->get_arb_info = adf_gen2_get_arb_info; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_C62X_FW ; hw_data->fw_mmp_name =ADF_C62X_MMP ;
drivers/crypto/qat/qat_common/adf_accel_devices.h +7 -0
@@ -97,6 +97,12 @@ struct adf_hw_device_class {u32 instances; } __packed; +struct arb_info { +u32 arb_cfg; +u32 arb_offset; +u32 wt2sam_offset; +}; +struct admin_info {u32 admin_msg_ur;u32 admin_msg_lr;
@@ -144,6 +150,7 @@ struct adf_hw_device_data {u32 (*get_num_accels)(struct adf_hw_device_data *self);u32 (*get_pf2vf_offset)(u32 i);u32 (*get_vintmsk_offset)(u32 i); +void (*get_arb_info)(struct arb_info *arb_csrs_info);void (*get_admin_info)(struct admin_info *admin_csrs_info);enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self);int (*alloc_irq)(struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +8 -0
@@ -45,6 +45,14 @@ void adf_gen2_get_admin_info(struct admin_info *admin_csrs_info) }EXPORT_SYMBOL_GPL (adf_gen2_get_admin_info); +void adf_gen2_get_arb_info (struct arb_info *arb_info) +{ + arb_info->arb_cfg =ADF_ARB_CONFIG ; + arb_info->arb_offset =ADF_ARB_OFFSET ; + arb_info->wt2sam_offset =ADF_ARB_WRK_2_SER_MAP_OFFSET ; +} +EXPORT_SYMBOL_GPL (adf_gen2_get_arb_info); +static u32 read_csr_ring_head (void __iomem *csr_base_addr,u32 bank,u32 ring) {return READ_CSR_RING_HEAD (csr_base_addr, bank, ring);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +6 -0
@@ -97,9 +97,15 @@ do { \#define ADF_ADMINMSGLR_OFFSET (0x3A000 + 0x578)#define ADF_MAILBOX_BASE_OFFSET 0x20970 +/* Arbiter configuration */ +#define ADF_ARB_OFFSET 0x30000 +#define ADF_ARB_WRK_2_SER_MAP_OFFSET 0x180 +#define ADF_ARB_CONFIG (BIT(31) | BIT(6) | BIT(0)) +void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs);void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops);void adf_gen2_get_admin_info (struct admin_info *admin_csrs_info); +void adf_gen2_get_arb_info (struct arb_info *arb_info);#endif
drivers/crypto/qat/qat_common/adf_hw_arbiter.c +26 -15
90 lines not on this page · raw message
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -211,6 +211,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_pf2vf_offset = get_pf2vf_offset; hw_data->get_vintmsk_offset = get_vintmsk_offset; hw_data->get_admin_info = adf_gen2_get_admin_info; + hw_data->get_arb_info = adf_gen2_get_arb_info; hw_data->get_sram_bar_id = get_sram_bar_id; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_DH895XCC_FW ;
Signature · 1 line
2.26.2
PATCH 16/31 crypto: qat - add support for capability detection
In reply to Giovanni CabidduFrom: Marco Chiappero <[email protected]>
Add logic to detect device capabilities for c62x, c3xxx and dh895xcc.
Read fuses, straps and legfuses CSRs and build the device capabilities mask. This will be used to understand if a certain service is supported by a device.
This patch is based on earlier work done by Conor McLoughlin.
--- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 2 ++ drivers/crypto/qat/qat_c3xxx/adf_drv.c | 5 ++-- .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 2 ++ drivers/crypto/qat/qat_c62x/adf_drv.c | 5 ++-- .../crypto/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/qat/qat_common/adf_gen2_hw_data.c | 30 +++++++++++++++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 4 +++ drivers/crypto/qat/qat_common/icp_qat_hw.h | 23 ++++++++++++++ .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 25 ++++++++++++++++ drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 5 ++-- 10 files changed, 93 insertions(+), 9 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +2 -0
@@ -5,6 +5,7 @@#include <adf_pf2vf_msg.h> #include <adf_gen2_hw_data.h> #include "adf_c3xxx_hw_data.h" +#include "icp_qat_hw.h" /* Worker thread to service arbiter mappings based on dev SKUs */ static const u32 thrd_to_arb_map_6_me_sku[] = {
@@ -195,6 +196,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data) hw_data->enable_error_correction = adf_enable_error_correction; hw_data->get_accel_mask = get_accel_mask; hw_data->get_ae_mask = get_ae_mask; + hw_data->get_accel_cap = adf_gen2_get_accel_cap; hw_data->get_num_accels = get_num_accels; hw_data->get_num_aes = get_num_aes; hw_data->get_sram_bar_id = get_sram_bar_id;
drivers/crypto/qat/qat_c3xxx/adf_drv.c +2 -3
@@ -177,9 +177,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable; } -/* Read accelerator capabilities mask */ -pci_read_config_dword (pdev,ADF_DEVICE_LEGFUSE_OFFSET , - &hw_data->accel_capabilities_mask); +/* Get accelerator capabilities mask */ + hw_data->accel_capabilities_mask = hw_data->get_accel_cap (accel_dev);/* Find and map all the device's BARS */ i =0 ;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +2 -0
@@ -5,6 +5,7 @@#include <adf_pf2vf_msg.h> #include <adf_gen2_hw_data.h> #include "adf_c62x_hw_data.h" +#include "icp_qat_hw.h" /* Worker thread to service arbiter mappings based on dev SKUs */ static const u32 thrd_to_arb_map_8_me_sku[] = {
@@ -205,6 +206,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data) hw_data->enable_error_correction = adf_enable_error_correction; hw_data->get_accel_mask = get_accel_mask; hw_data->get_ae_mask = get_ae_mask; + hw_data->get_accel_cap = adf_gen2_get_accel_cap; hw_data->get_num_accels = get_num_accels; hw_data->get_num_aes = get_num_aes; hw_data->get_sram_bar_id = get_sram_bar_id;
drivers/crypto/qat/qat_c62x/adf_drv.c +2 -3
@@ -177,9 +177,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable; } -/* Read accelerator capabilities mask */ -pci_read_config_dword (pdev,ADF_DEVICE_LEGFUSE_OFFSET , - &hw_data->accel_capabilities_mask); +/* Get accelerator capabilities mask */ + hw_data->accel_capabilities_mask = hw_data->get_accel_cap (accel_dev);/* Find and map all the device's BARS */ i = (hw_data->fuses &ADF_DEVICE_FUSECTL_MASK ) ?1 :0 ;
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -143,6 +143,7 @@ struct adf_hw_device_data {struct adf_hw_device_class *dev_class;u32 (*get_accel_mask)(struct adf_hw_device_data *self);u32 (*get_ae_mask)(struct adf_hw_device_data *self); +u32 (*get_accel_cap)(struct adf_accel_dev *accel_dev);u32 (*get_sram_bar_id)(struct adf_hw_device_data *self);u32 (*get_misc_bar_id)(struct adf_hw_device_data *self);u32 (*get_etr_bar_id)(struct adf_hw_device_data *self);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +30 -0
@@ -1,6 +1,8 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2020 Intel Corporation */ #include "adf_gen2_hw_data.h" +#include "icp_qat_hw.h" +#include <linux/pci.h> void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs)
@@ -136,3 +138,31 @@ void adf_gen2_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops) csr_ops->write_csr_int_flag_and_col = write_csr_int_flag_and_col; }EXPORT_SYMBOL_GPL (adf_gen2_init_hw_csr_ops); + +u32 adf_gen2_get_accel_cap (struct adf_accel_dev *accel_dev) +{ +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +struct pci_dev *pdev = accel_dev->accel_pci_dev.pci_dev; +u32 straps = hw_data->straps; +u32 fuses = hw_data->fuses; +u32 legfuses; +u32 capabilities =ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC | +ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | +ICP_ACCEL_CAPABILITIES_AUTHENTICATION ; + +/* Read accelerator capabilities mask */ +pci_read_config_dword (pdev,ADF_DEVICE_LEGFUSE_OFFSET , &legfuses); + +if (legfuses &ICP_ACCEL_MASK_CIPHER_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC ; +if (legfuses &ICP_ACCEL_MASK_PKE_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC ; +if (legfuses &ICP_ACCEL_MASK_AUTH_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_AUTHENTICATION ; + +if ((straps | fuses) &ADF_POWERGATE_PKE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC ; + +return capabilities; +} +EXPORT_SYMBOL_GPL (adf_gen2_get_accel_cap);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +4 -0
@@ -102,10 +102,14 @@ do { \#define ADF_ARB_WRK_2_SER_MAP_OFFSET 0x180#define ADF_ARB_CONFIG (BIT(31) | BIT(6) | BIT(0)) +/* Power gating */ +#define ADF_POWERGATE_PKE BIT(24) +void adf_gen2_cfg_iov_thds (struct adf_accel_dev *accel_dev,bool enable,int num_a_regs,int num_b_regs);void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops);void adf_gen2_get_admin_info (struct admin_info *admin_csrs_info);void adf_gen2_get_arb_info (struct arb_info *arb_info); +u32 adf_gen2_get_accel_cap (struct adf_accel_dev *accel_dev);#endif
drivers/crypto/qat/qat_common/icp_qat_hw.h +23 -0
@@ -65,6 +65,29 @@ struct icp_qat_hw_auth_config {__u32 reserved; }; +enum icp_qat_slice_mask { +ICP_ACCEL_MASK_CIPHER_SLICE =BIT (0 ), +ICP_ACCEL_MASK_AUTH_SLICE =BIT (1 ), +ICP_ACCEL_MASK_PKE_SLICE =BIT (2 ), +ICP_ACCEL_MASK_COMPRESS_SLICE =BIT (3 ), +ICP_ACCEL_MASK_LZS_SLICE =BIT (4 ), +ICP_ACCEL_MASK_EIA3_SLICE =BIT (5 ), +ICP_ACCEL_MASK_SHA3_SLICE =BIT (6 ), +}; + +enum icp_qat_capabilities_mask { +ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC =BIT (0 ), +ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC =BIT (1 ), +ICP_ACCEL_CAPABILITIES_CIPHER =BIT (2 ), +ICP_ACCEL_CAPABILITIES_AUTHENTICATION =BIT (3 ), +ICP_ACCEL_CAPABILITIES_RESERVED_1 =BIT (4 ), +ICP_ACCEL_CAPABILITIES_COMPRESSION =BIT (5 ), +ICP_ACCEL_CAPABILITIES_LZS_COMPRESSION =BIT (6 ), +ICP_ACCEL_CAPABILITIES_RAND =BIT (7 ), +ICP_ACCEL_CAPABILITIES_ZUC =BIT (8 ), +ICP_ACCEL_CAPABILITIES_SHA3 =BIT (9 ), +}; +#define QAT_AUTH_MODE_BITPOS 4#define QAT_AUTH_MODE_MASK 0xF#define QAT_AUTH_ALGO_BITPOS 0
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +25 -0
@@ -5,6 +5,7 @@#include <adf_common_drv.h> #include <adf_gen2_hw_data.h> #include "adf_dh895xcc_hw_data.h" +#include "icp_qat_hw.h" /* Worker thread to service arbiter mappings based on dev SKUs */ static const u32 thrd_to_arb_map_sku4[] = {
@@ -83,6 +84,29 @@ static u32 get_sram_bar_id(struct adf_hw_device_data *self)return ADF_DH895XCC_SRAM_BAR ; } +static u32 get_accel_cap (struct adf_accel_dev *accel_dev) +{ +struct pci_dev *pdev = accel_dev->accel_pci_dev.pci_dev; +u32 capabilities; +u32 legfuses; + + capabilities =ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC | +ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | +ICP_ACCEL_CAPABILITIES_AUTHENTICATION ; + +/* Read accelerator capabilities mask */ +pci_read_config_dword (pdev,ADF_DEVICE_LEGFUSE_OFFSET , &legfuses); + +if (legfuses &ICP_ACCEL_MASK_CIPHER_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC ; +if (legfuses &ICP_ACCEL_MASK_PKE_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC ; +if (legfuses &ICP_ACCEL_MASK_AUTH_SLICE ) + capabilities &= ~ICP_ACCEL_CAPABILITIES_AUTHENTICATION ; + +return capabilities; +} +static enum dev_sku_info get_sku (struct adf_hw_device_data *self) {int sku = (self->fuses &ADF_DH895XCC_FUSECTL_SKU_MASK )
@@ -204,6 +228,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->enable_error_correction = adf_enable_error_correction; hw_data->get_accel_mask = get_accel_mask; hw_data->get_ae_mask = get_ae_mask; + hw_data->get_accel_cap = get_accel_cap; hw_data->get_num_accels = get_num_accels; hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id;
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +2 -3
@@ -177,9 +177,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_err_disable; } -/* Read accelerator capabilities mask */ -pci_read_config_dword (pdev,ADF_DEVICE_LEGFUSE_OFFSET , - &hw_data->accel_capabilities_mask); +/* Get accelerator capabilities mask */ + hw_data->accel_capabilities_mask = hw_data->get_accel_cap (accel_dev);/* Find and map all the device's BARS */ i =0 ;
Signature · 1 line
2.26.2
PATCH 17/31 crypto: qat - register crypto instances based on capability
In reply to Giovanni CabidduIntroduce the function adf_hw_dev_has_crypto() that returns true if a device supports symmetric crypto, asymmetric crypto and authentication services.
If a device has crypto capabilities, add crypto instances to the configuration.
This is done since the function that allows to retrieve crypto instances, qat_crypto_get_instance_node(), return instances that support all crypto services.
--- drivers/crypto/qat/qat_common/qat_crypto.c | 7 ++++++- drivers/crypto/qat/qat_common/qat_crypto.h | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/qat_crypto.c +6 -1
@@ -117,10 +117,15 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_dev) {int cpus =num_online_cpus ();int banks =GET_MAX_BANKS (accel_dev); -int instances =min (cpus, banks);char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES ];int i;unsigned long val; +int instances; + +if (adf_hw_dev_has_crypto (accel_dev)) + instances =min (cpus, banks); +else + instances =0 ;if (adf_cfg_section_add (accel_dev,ADF_KERNEL_SEC )) goto err;
drivers/crypto/qat/qat_common/qat_crypto.h +15 -0
@@ -55,4 +55,19 @@ struct qat_crypto_request { bool encryption; }; +static inline bool adf_hw_dev_has_crypto (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_CRYPTO_SYMMETRIC ) +return false; +if (mask &ADF_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC ) +return false; +if (mask &ADF_ACCEL_CAPABILITIES_AUTHENTICATION ) +return false; + +return true; +} +#endif
Signature · 1 line
2.26.2
PATCH 18/31 crypto: qat - enable ring after pair is programmed
In reply to Giovanni CabidduEnable arbitration on the TX ring only after the RX ring is programmed.
Before this change, arbitration was enabled on the TX ring before the RX ring was programmed allowing the HW to process a request before having the ring pair configured.
With this change, the arbitration logic is programmed only if the TX half of the ring mask matches the RX half.
This change does not affect QAT GEN2 devices (c62x, c3xxx and dh895xcc), but it is a must for QAT GEN4 devices since the CSRs of the ring pair are locked after arbitration is enabled on the TX ring.
--- .../crypto/qat/qat_common/adf_hw_arbiter.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_hw_arbiter.c +19 -1
@@ -55,9 +55,27 @@ EXPORT_SYMBOL_GPL(adf_init_arb);void adf_update_ring_arb (struct adf_etr_ring_data *ring) { +struct adf_accel_dev *accel_dev = ring->bank->accel_dev; +struct adf_hw_device_data *hw_data = accel_dev->hw_device; +u32 tx_ring_mask = hw_data->tx_rings_mask; +u32 shift = hw_data->tx_rx_gap; +u32 arben, arben_tx, arben_rx; +u32 rx_ring_mask; + +/* +* Enable arbitration on a ring only if the TX half of the ring mask +* matches the RX part. This results in writes to CSR on both TX and +* RX update - only one is necessary, but both are done for +* simplicity. +*/ + rx_ring_mask = tx_ring_mask << shift; + arben_tx = (ring->bank->ring_mask & tx_ring_mask) >>0 ; + arben_rx = (ring->bank->ring_mask & rx_ring_mask) >> shift; + arben = arben_tx & arben_rx; +WRITE_CSR_ARB_RINGSRVARBEN (ring->bank->csr_addr, ring->bank->bank_number, - ring->bank->ring_mask &0xFF ); + arben); }void adf_exit_arb (struct adf_accel_dev *accel_dev)
Signature · 1 line
2.26.2
PATCH 19/31 crypto: qat - abstract build ring base
In reply to Giovanni CabidduAbstract the implementation of BUILD_RING_BASE_ADDR.
This is in preparation for the introduction of the qat_4xxx driver since the value of the ring base differs between QAT GEN2 and QAT GEN4 devices.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_gen2_hw_data.c | 6 ++++++ drivers/crypto/qat/qat_common/adf_gen2_hw_data.h | 2 ++ drivers/crypto/qat/qat_common/adf_transport.c | 4 +++- drivers/crypto/qat/qat_common/adf_transport_access_macros.h | 2 -- 5 files changed, 12 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -110,6 +110,7 @@ struct admin_info { };struct adf_hw_csr_ops { +u64 (*build_csr_ring_base_addr)(dma_addr_t addr,u32 size);u32 (*read_csr_ring_head)(void __iomem *csr_base_addr,u32 bank,u32 ring); void (*write_csr_ring_head)(void __iomem *csr_base_addr, u32 bank,
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +6 -0
@@ -55,6 +55,11 @@ void adf_gen2_get_arb_info(struct arb_info *arb_info) }EXPORT_SYMBOL_GPL (adf_gen2_get_arb_info); +static u64 build_csr_ring_base_addr (dma_addr_t addr,u32 size) +{ +return BUILD_RING_BASE_ADDR (addr, size); +} +static u32 read_csr_ring_head (void __iomem *csr_base_addr,u32 bank,u32 ring) {return READ_CSR_RING_HEAD (csr_base_addr, bank, ring);
@@ -124,6 +129,7 @@ static void write_csr_int_flag_and_col(void __iomem *csr_base_addr, u32 bank,void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops) { + csr_ops->build_csr_ring_base_addr = build_csr_ring_base_addr; csr_ops->read_csr_ring_head = read_csr_ring_head; csr_ops->write_csr_ring_head = write_csr_ring_head; csr_ops->read_csr_ring_tail = read_csr_ring_tail;
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +2 -0
@@ -23,6 +23,8 @@#define ADF_RING_CSR_INT_COL_CTL_ENABLE 0x80000000#define ADF_RING_BUNDLE_SIZE 0x1000 +#define BUILD_RING_BASE_ADDR (addr, size) \ + (((addr) >> 6) & (0xFFFFFFFFFFFFFFFFULL << (size)))#define READ_CSR_RING_HEAD (csr_base_addr, bank, ring) \ ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * (bank)) + \ ADF_RING_CSR_RING_HEAD + ((ring) << 2))
drivers/crypto/qat/qat_common/adf_transport.c +3 -1
@@ -180,7 +180,9 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)else adf_configure_rx_ring (ring); - ring_base =BUILD_RING_BASE_ADDR (ring->dma_addr, ring->ring_size); + ring_base = csr_ops->build_csr_ring_base_addr (ring->dma_addr, + ring->ring_size); + csr_ops->write_csr_ring_base (ring->bank->csr_addr, ring->bank->bank_number, ring->ring_number, ring_base);
drivers/crypto/qat/qat_common/adf_transport_access_macros.h +0 -2
@@ -56,6 +56,4 @@ ((watermark_nf <<ADF_RING_CONFIG_NEAR_FULL_WM ) \ | (watermark_ne <<ADF_RING_CONFIG_NEAR_EMPTY_WM ) \ | size) -#define BUILD_RING_BASE_ADDR (addr, size) \ - ((addr >> 6) & (0xFFFFFFFFFFFFFFFFULL << size))#endif
Signature · 1 line
2.26.2
PATCH 20/31 crypto: qat - replace constant masks with GENMASK
In reply to Giovanni CabidduReplace constant 0xFFFFFFFFFFFFFFFFULL with GENMASK_ULL(63, 0) and 0xFFFFFFFF with GENMASK(31, 0) as they are masks.
This makes code less error prone.
--- drivers/crypto/qat/qat_common/adf_gen2_hw_data.h | 2 +- drivers/crypto/qat/qat_common/adf_sriov.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +1 -1
@@ -24,7 +24,7 @@#define ADF_RING_BUNDLE_SIZE 0x1000#define BUILD_RING_BASE_ADDR (addr, size) \ - (((addr) >> 6) & (0xFFFFFFFFFFFFFFFFULL << (size))) + (((addr) >> 6) & (GENMASK_ULL(63, 0) << (size)))#define READ_CSR_RING_HEAD (csr_base_addr, bank, ring) \ ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * (bank)) + \ ADF_RING_CSR_RING_HEAD + ((ring) << 2))
drivers/crypto/qat/qat_common/adf_sriov.c +1 -1
@@ -99,7 +99,7 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)pci_disable_sriov (accel_to_pci_dev (accel_dev));/* Disable VF to PF interrupts */ -adf_disable_vf2pf_interrupts (accel_dev,0xFFFFFFFF ); +adf_disable_vf2pf_interrupts (accel_dev,GENMASK (31 ,0 ));/* Clear Valid bits in AE Thread to PCIe Function Mapping */ hw_data->configure_iov_threads (accel_dev, false);
Signature · 1 line
2.26.2
PATCH 21/31 crypto: qat - use BIT_ULL() - 1 pattern for masks
In reply to Giovanni CabidduReplace occurrences of the pattern GENMASK_ULL(var - 1, 0)) with BIT_ULL(var) - 1 since it produces better code and it is easier to read.
--- drivers/crypto/qat/qat_common/adf_sriov.c | 2 +- drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_sriov.c +1 -1
@@ -65,7 +65,7 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev) hw_data->configure_iov_threads (accel_dev, true);/* Enable VF to PF interrupts for all VFs */ -adf_enable_vf2pf_interrupts (accel_dev,GENMASK_ULL (totalvfs -1 ,0 )); +adf_enable_vf2pf_interrupts (accel_dev,BIT_ULL (totalvfs) -1 );/* * Due to the hardware design, when SR-IOV and the ring arbiter
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -1
@@ -195,7 +195,7 @@ static void adf_enable_ints(struct adf_accel_dev *accel_dev)/* Enable bundle and misc interrupts */ ADF_CSR_WR (addr,ADF_DH895XCC_SMIAPF0_MASK_OFFSET , accel_dev->pf.vf_info ?0 : -GENMASK_ULL (GET_MAX_BANKS (accel_dev) -1 ,0 )); +BIT_ULL (GET_MAX_BANKS (accel_dev)) -1 );ADF_CSR_WR (addr,ADF_DH895XCC_SMIAPF1_MASK_OFFSET ,ADF_DH895XCC_SMIA1_MASK ); }
Signature · 1 line
2.26.2
PATCH 22/31 crypto: qat - abstract writes to arbiter enable
In reply to Giovanni CabidduAbstract writes to the service arbiter enable register.
This is in preparation for the introduction of the qat_4xxx driver since the arbitration enable register differes between QAT GEN2 and QAT GEN4 devices.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 2 ++ drivers/crypto/qat/qat_common/adf_gen2_hw_data.c | 7 +++++++ drivers/crypto/qat/qat_common/adf_gen2_hw_data.h | 6 ++++++ drivers/crypto/qat/qat_common/adf_hw_arbiter.c | 15 +++++---------- 4 files changed, 20 insertions(+), 10 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +2 -0
@@ -133,6 +133,8 @@ struct adf_hw_csr_ops { u32 value);void (*write_csr_int_flag_and_col)(void __iomem *csr_base_addr,u32 bank,u32 value); +void (*write_csr_ring_srv_arb_en)(void __iomem *csr_base_addr,u32 bank, +u32 value); };struct adf_cfg_device_data ;
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +7 -0
@@ -127,6 +127,12 @@ static void write_csr_int_flag_and_col(void __iomem *csr_base_addr, u32 bank,WRITE_CSR_INT_FLAG_AND_COL (csr_base_addr, bank, value); } +static void write_csr_ring_srv_arb_en (void __iomem *csr_base_addr,u32 bank, +u32 value) +{ +WRITE_CSR_RING_SRV_ARB_EN (csr_base_addr, bank, value); +} +void adf_gen2_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops) { csr_ops->build_csr_ring_base_addr = build_csr_ring_base_addr;
@@ -142,6 +148,7 @@ void adf_gen2_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops) csr_ops->write_csr_int_col_en = write_csr_int_col_en; csr_ops->write_csr_int_col_ctl = write_csr_int_col_ctl; csr_ops->write_csr_int_flag_and_col = write_csr_int_flag_and_col; + csr_ops->write_csr_ring_srv_arb_en = write_csr_ring_srv_arb_en; }EXPORT_SYMBOL_GPL (adf_gen2_init_hw_csr_ops);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +6 -0
@@ -103,6 +103,12 @@ do { \#define ADF_ARB_OFFSET 0x30000#define ADF_ARB_WRK_2_SER_MAP_OFFSET 0x180#define ADF_ARB_CONFIG (BIT(31) | BIT(6) | BIT(0)) +#define ADF_ARB_REG_SLOT 0x1000 +#define ADF_ARB_RINGSRVARBEN_OFFSET 0x19C + +#define WRITE_CSR_RING_SRV_ARB_EN (csr_addr, index, value) \ + ADF_CSR_WR(csr_addr, ADF_ARB_RINGSRVARBEN_OFFSET + \ + (ADF_ARB_REG_SLOT * (index)), value)/* Power gating */ #define ADF_POWERGATE_PKE BIT(24)
drivers/crypto/qat/qat_common/adf_hw_arbiter.c +5 -10
@@ -6,12 +6,6 @@#define ADF_ARB_NUM 4#define ADF_ARB_REG_SIZE 0x4 -#define ADF_ARB_REG_SLOT 0x1000 -#define ADF_ARB_RINGSRVARBEN_OFFSET 0x19C - -#define WRITE_CSR_ARB_RINGSRVARBEN (csr_addr, index, value) \ - ADF_CSR_WR(csr_addr, ADF_ARB_RINGSRVARBEN_OFFSET + \ - (ADF_ARB_REG_SLOT * index), value)#define WRITE_CSR_ARB_SARCONFIG (csr_addr, arb_offset, index, value) \ ADF_CSR_WR(csr_addr, (arb_offset) + \
@@ -57,6 +51,7 @@ void adf_update_ring_arb(struct adf_etr_ring_data *ring) {struct adf_accel_dev *accel_dev = ring->bank->accel_dev;struct adf_hw_device_data *hw_data = accel_dev->hw_device; +struct adf_hw_csr_ops *csr_ops =GET_CSR_OPS (accel_dev);u32 tx_ring_mask = hw_data->tx_rings_mask;u32 shift = hw_data->tx_rx_gap;u32 arben, arben_tx, arben_rx;
@@ -73,14 +68,14 @@ void adf_update_ring_arb(struct adf_etr_ring_data *ring) arben_rx = (ring->bank->ring_mask & rx_ring_mask) >> shift; arben = arben_tx & arben_rx; -WRITE_CSR_ARB_RINGSRVARBEN (ring->bank->csr_addr, - ring->bank->bank_number, - arben); + csr_ops->write_csr_ring_srv_arb_en (ring->bank->csr_addr, + ring->bank->bank_number, arben); }void adf_exit_arb (struct adf_accel_dev *accel_dev) {struct adf_hw_device_data *hw_data = accel_dev->hw_device; +struct adf_hw_csr_ops *csr_ops =GET_CSR_OPS (accel_dev);u32 arb_off, wt_off;struct arb_info info;void __iomem *csr;
@@ -107,6 +102,6 @@ void adf_exit_arb(struct adf_accel_dev *accel_dev)/* Disable arbitration on all rings */ for (i =0 ; i <GET_MAX_BANKS (accel_dev); i++) -WRITE_CSR_ARB_RINGSRVARBEN (csr, i,0 ); + csr_ops->write_csr_ring_srv_arb_en (csr, i,0 ); }EXPORT_SYMBOL_GPL (adf_exit_arb);
Signature · 1 line
2.26.2
PATCH 23/31 crypto: qat - remove hardcoded bank irq clear flag mask
In reply to Giovanni CabidduReplace hardcoded value of the bank interrupt clear flag mask with a value calculated on the fly which is based on the number of rings present in a bank. This is to support devices that have a number of rings per bank different than 16.
--- drivers/crypto/qat/qat_common/adf_transport.c | 4 ++-- drivers/crypto/qat/qat_common/adf_transport_access_macros.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_transport.c +2 -2
@@ -374,6 +374,7 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev,struct adf_hw_device_data *hw_data = accel_dev->hw_device;u8 num_rings_per_bank = hw_data->num_rings_per_bank;struct adf_hw_csr_ops *csr_ops = &hw_data->csr_ops; +u32 irq_mask =BIT (num_rings_per_bank) -1 ;struct adf_etr_ring_data *ring;struct adf_etr_ring_data *tx_ring;u32 i, coalesc_enabled =0 ;
@@ -431,8 +432,7 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev, goto err; } - csr_ops->write_csr_int_flag (csr_addr, bank_num, -ADF_BANK_INT_FLAG_CLEAR_MASK ); + csr_ops->write_csr_int_flag (csr_addr, bank_num, irq_mask); csr_ops->write_csr_int_srcsel (csr_addr, bank_num);return 0 ;
drivers/crypto/qat/qat_common/adf_transport_access_macros.h +0 -1
@@ -4,7 +4,6 @@#define ADF_TRANSPORT_ACCESS_MACROS_H #include "adf_accel_devices.h" -#define ADF_BANK_INT_FLAG_CLEAR_MASK 0xFFFF#define ADF_RING_CONFIG_NEAR_FULL_WM 0x0A#define ADF_RING_CONFIG_NEAR_EMPTY_WM 0x05#define ADF_COALESCING_MIN_TIME 0x1FF
Signature · 1 line
2.26.2
PATCH 24/31 crypto: qat - call functions in adf_sriov if available
In reply to Giovanni CabidduCall the function configure_iov_threads(), adf_enable_vf2pf_interrupts() and adf_pf2vf_notify_restarting() only if present in the struct adf_hw_device_data of the device.
This is to allow for QAT drivers that do not implement those functions.
--- drivers/crypto/qat/qat_common/adf_sriov.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/adf_sriov.c +10 -5
@@ -62,10 +62,12 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev) }/* Set Valid bits in AE Thread to PCIe Function Mapping */ - hw_data->configure_iov_threads (accel_dev, true); +if (hw_data->configure_iov_threads) + hw_data->configure_iov_threads (accel_dev, true);/* Enable VF to PF interrupts for all VFs */ -adf_enable_vf2pf_interrupts (accel_dev,BIT_ULL (totalvfs) -1 ); +if (hw_data->get_pf2vf_offset) +adf_enable_vf2pf_interrupts (accel_dev,BIT_ULL (totalvfs) -1 );/* * Due to the hardware design, when SR-IOV and the ring arbiter
@@ -94,15 +96,18 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)if (!accel_dev->pf.vf_info)return ; -adf_pf2vf_notify_restarting (accel_dev); +if (hw_data->get_pf2vf_offset) +adf_pf2vf_notify_restarting (accel_dev);pci_disable_sriov (accel_to_pci_dev (accel_dev));/* Disable VF to PF interrupts */ -adf_disable_vf2pf_interrupts (accel_dev,GENMASK (31 ,0 )); +if (hw_data->get_pf2vf_offset) +adf_disable_vf2pf_interrupts (accel_dev,GENMASK (31 ,0 ));/* Clear Valid bits in AE Thread to PCIe Function Mapping */ - hw_data->configure_iov_threads (accel_dev, false); +if (hw_data->configure_iov_threads) + hw_data->configure_iov_threads (accel_dev, false);for (i =0 , vf = accel_dev->pf.vf_info; i < totalvfs; i++, vf++) {tasklet_disable (&vf->vf2pf_bh_tasklet);
Signature · 1 line
2.26.2
PATCH 25/31 crypto: qat - remove unnecessary void* casts
In reply to Giovanni CabidduRemove superfluous casts to void* in function qat_crypto_dev_config().
--- drivers/crypto/qat/qat_common/qat_crypto.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/crypto/qat/qat_common/qat_crypto.c +10 -10
@@ -135,61 +135,61 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_dev) val = i;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_BANK_NUM , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_SIZE , i); val =128 ;if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =512 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_SIZE , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =0 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_TX , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =2 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_TX , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =8 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =10 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_RX , i);if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; val =ADF_COALESCING_DEF_TIME ;snprintf (key,sizeof (key),ADF_ETRMGR_COALESCE_TIMER_FORMAT , i);if (adf_cfg_add_key_value_param (accel_dev,"Accelerator0" , - key, (void *)&val,ADF_DEC )) + key, &val,ADF_DEC )) goto err; } val = i;if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , -ADF_NUM_CY , (void *)&val,ADF_DEC )) +ADF_NUM_CY , &val,ADF_DEC )) goto err;set_bit (ADF_STATUS_CONFIGURED , &accel_dev->status);
Signature · 1 line
2.26.2
PATCH 26/31 crypto: qat - change return value in adf_cfg_add_key_value_param()
In reply to Giovanni CabidduIf the parameter type provided to adf_cfg_add_key_value_param() is invalid, return -EINVAL instead of -1 that is treated as -EPERM and may confuse.
--- drivers/crypto/qat/qat_common/adf_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_cfg.c +1 -1
@@ -243,7 +243,7 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev, }else {dev_err (&GET_DEV (accel_dev),"Unknown type given.\n" );kfree (key_val); -return -1 ; +return -EINVAL ; } key_val->type = type;down_write (&cfg->lock);
Signature · 1 line
2.26.2
PATCH 27/31 crypto: qat - change return value in adf_cfg_key_val_get()
In reply to Giovanni CabidduIf a key is not found in the internal key value storage, return -ENODATA instead of -1 that is treated as -EPERM and may confuse.
--- drivers/crypto/qat/qat_common/adf_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_cfg.c +1 -1
@@ -196,7 +196,7 @@ static int adf_cfg_key_val_get(struct adf_accel_dev *accel_dev,memcpy (val, keyval->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES );return 0 ; } -return -1 ; +return -ENODATA ; }/**
Signature · 1 line
2.26.2
PATCH 28/31 crypto: qat - refactor qat_crypto_create_instances()
In reply to Giovanni CabidduRefactor function qat_crypto_create_instances() to propagate errors to the caller.
--- drivers/crypto/qat/qat_common/qat_crypto.c | 68 +++++++++++++--------- 1 file changed, 41 insertions(+), 27 deletions(-)
drivers/crypto/qat/qat_common/qat_crypto.c +41 -27
@@ -202,83 +202,97 @@ EXPORT_SYMBOL_GPL(qat_crypto_dev_config);static int qat_crypto_create_instances (struct adf_accel_dev *accel_dev) { -int i; -unsigned long bank; -unsigned long num_inst, num_msg_sym, num_msg_asym; -int msg_size; -struct qat_crypto_instance *inst; +unsigned long bank, num_inst, num_msg_sym, num_msg_asym;char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES ];char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES ]; +struct qat_crypto_instance *inst; +int msg_size; +int ret; +int i;INIT_LIST_HEAD (&accel_dev->crypto_list); -if (adf_cfg_get_param_value (accel_dev,SEC ,ADF_NUM_CY , val)) -return -EFAULT ; + ret =adf_cfg_get_param_value (accel_dev,SEC ,ADF_NUM_CY , val); +if (ret) +return ret; -if (kstrtoul (val,0 , &num_inst)) -return -EFAULT ; + ret =kstrtoul (val,0 , &num_inst); +if (ret) +return ret;for (i =0 ; i < num_inst; i++) { inst =kzalloc_node (sizeof (*inst),GFP_KERNEL ,dev_to_node (&GET_DEV (accel_dev))); -if (!inst) +if (!inst) { + ret = -ENOMEM ; goto err; + }list_add_tail (&inst->list, &accel_dev->crypto_list); inst->id = i;atomic_set (&inst->refctr,0 ); inst->accel_dev = accel_dev;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_BANK_NUM , i); -if (adf_cfg_get_param_value (accel_dev,SEC , key, val)) + ret =adf_cfg_get_param_value (accel_dev,SEC , key, val); +if (ret) goto err; -if (kstrtoul (val,10 , &bank)) + ret =kstrtoul (val,10 , &bank); +if (ret) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_SIZE , i); -if (adf_cfg_get_param_value (accel_dev,SEC , key, val)) + ret =adf_cfg_get_param_value (accel_dev,SEC , key, val); +if (ret) goto err; -if (kstrtoul (val,10 , &num_msg_sym)) + ret =kstrtoul (val,10 , &num_msg_sym); +if (ret) goto err; num_msg_sym = num_msg_sym >>1 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_SIZE , i); -if (adf_cfg_get_param_value (accel_dev,SEC , key, val)) + ret =adf_cfg_get_param_value (accel_dev,SEC , key, val); +if (ret) goto err; -if (kstrtoul (val,10 , &num_msg_asym)) + ret =kstrtoul (val,10 , &num_msg_asym); +if (ret) goto err; num_msg_asym = num_msg_asym >>1 ; msg_size =ICP_QAT_FW_REQ_DEFAULT_SZ ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_TX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_sym, - msg_size, key,NULL ,0 , &inst->sym_tx)) + ret =adf_create_ring (accel_dev,SEC , bank, num_msg_sym, + msg_size, key,NULL ,0 , &inst->sym_tx); +if (ret) goto err; msg_size = msg_size >>1 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_TX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_asym, - msg_size, key,NULL ,0 , &inst->pke_tx)) + ret =adf_create_ring (accel_dev,SEC , bank, num_msg_asym, + msg_size, key,NULL ,0 , &inst->pke_tx); +if (ret) goto err; msg_size =ICP_QAT_FW_RESP_DEFAULT_SZ ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_RX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_sym, - msg_size, key, qat_alg_callback,0 , - &inst->sym_rx)) + ret =adf_create_ring (accel_dev,SEC , bank, num_msg_sym, + msg_size, key, qat_alg_callback,0 , + &inst->sym_rx); +if (ret) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_asym, - msg_size, key, qat_alg_asym_callback,0 , - &inst->pke_rx)) + ret =adf_create_ring (accel_dev,SEC , bank, num_msg_asym, + msg_size, key, qat_alg_asym_callback,0 , + &inst->pke_rx); +if (ret) goto err; }return 0 ; err:qat_crypto_free_instances (accel_dev); -return -ENOMEM ; +return ret; }static int qat_crypto_init (struct adf_accel_dev *accel_dev)
Signature · 1 line
2.26.2
PATCH 29/31 crypto: qat - refactor qat_crypto_dev_config()
In reply to Giovanni CabidduRefactor function qat_crypto_dev_config() to propagate errors to the caller.
--- drivers/crypto/qat/qat_common/qat_crypto.c | 67 +++++++++++++--------- 1 file changed, 41 insertions(+), 26 deletions(-)
drivers/crypto/qat/qat_common/qat_crypto.c +41 -26
@@ -115,88 +115,103 @@ struct qat_crypto_instance *qat_crypto_get_instance_node(int node)*/ int qat_crypto_dev_config (struct adf_accel_dev *accel_dev) { -int cpus =num_online_cpus (); -int banks =GET_MAX_BANKS (accel_dev);char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES ]; -int i; +int banks =GET_MAX_BANKS (accel_dev); +int cpus =num_online_cpus ();unsigned long val;int instances; +int ret; +int i;if (adf_hw_dev_has_crypto (accel_dev)) instances =min (cpus, banks);else instances =0 ; -if (adf_cfg_section_add (accel_dev,ADF_KERNEL_SEC )) + ret =adf_cfg_section_add (accel_dev,ADF_KERNEL_SEC ); +if (ret) goto err; -if (adf_cfg_section_add (accel_dev,"Accelerator0" )) + + ret =adf_cfg_section_add (accel_dev,"Accelerator0" ); +if (ret) goto err; +for (i =0 ; i < instances; i++) { val = i;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_BANK_NUM , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_SIZE , i); val =128 ; -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =512 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_SIZE , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =0 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_TX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =2 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_TX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =8 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =10 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_RX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) goto err; val =ADF_COALESCING_DEF_TIME ;snprintf (key,sizeof (key),ADF_ETRMGR_COALESCE_TIMER_FORMAT , i); -if (adf_cfg_add_key_value_param (accel_dev,"Accelerator0" , - key, &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,"Accelerator0" , + key, &val,ADF_DEC ); +if (ret) goto err; } val = i; -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , -ADF_NUM_CY , &val,ADF_DEC )) + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC ,ADF_NUM_CY , + &val,ADF_DEC ); +if (ret) goto err;set_bit (ADF_STATUS_CONFIGURED , &accel_dev->status);return 0 ; err:dev_err (&GET_DEV (accel_dev),"Failed to start QAT accel dev\n" ); -return -EINVAL ; +return ret; }EXPORT_SYMBOL_GPL (qat_crypto_dev_config);
Signature · 1 line
2.26.2
PATCH 30/31 crypto: qat - allow for instances in different banks
In reply to Giovanni CabidduAllow for crypto instances to be configured with symmetric crypto rings that belong to a bank that is different from the one where asymmetric crypto rings are located.
This is to allow for devices with banks made of a single ring pair. In these, crypto instances will be composed of two separate banks.
Changed string literals are not exposed to the user space.
--- .../crypto/qat/qat_common/adf_cfg_strings.h | 3 +- drivers/crypto/qat/qat_common/qat_crypto.c | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-)
drivers/crypto/qat/qat_common/adf_cfg_strings.h +2 -1
@@ -18,7 +18,8 @@#define ADF_RING_DC_TX "RingTx"#define ADF_RING_DC_RX "RingRx"#define ADF_ETRMGR_BANK "Bank" -#define ADF_RING_BANK_NUM "BankNumber" +#define ADF_RING_SYM_BANK_NUM "BankSymNumber" +#define ADF_RING_ASYM_BANK_NUM "BankAsymNumber"#define ADF_CY "Cy"#define ADF_DC "Dc"#define ADF_ETRMGR_COALESCING_ENABLED "InterruptCoalescingEnabled"
drivers/crypto/qat/qat_common/qat_crypto.c +26 -8
@@ -138,7 +138,13 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_dev)for (i =0 ; i < instances; i++) { val = i; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_BANK_NUM , i); +snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_BANK_NUM , i); + ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , + key, &val,ADF_DEC ); +if (ret) + goto err; + +snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_BANK_NUM , i); ret =adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , key, &val,ADF_DEC );if (ret)
@@ -217,9 +223,10 @@ EXPORT_SYMBOL_GPL(qat_crypto_dev_config);static int qat_crypto_create_instances (struct adf_accel_dev *accel_dev) { -unsigned long bank, num_inst, num_msg_sym, num_msg_asym; +unsigned long num_inst, num_msg_sym, num_msg_asym;char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES ];char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES ]; +unsigned long sym_bank, asym_bank;struct qat_crypto_instance *inst;int msg_size;int ret;
@@ -246,14 +253,25 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) inst->id = i;atomic_set (&inst->refctr,0 ); inst->accel_dev = accel_dev; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_BANK_NUM , i); + +snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_BANK_NUM , i); + ret =adf_cfg_get_param_value (accel_dev,SEC , key, val); +if (ret) + goto err; + + ret =kstrtoul (val,10 , &sym_bank); +if (ret) + goto err; + +snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_BANK_NUM , i); ret =adf_cfg_get_param_value (accel_dev,SEC , key, val);if (ret) goto err; - ret =kstrtoul (val,10 , &bank); + ret =kstrtoul (val,10 , &asym_bank);if (ret) goto err; +snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_SIZE , i); ret =adf_cfg_get_param_value (accel_dev,SEC , key, val);if (ret)
@@ -277,28 +295,28 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) msg_size =ICP_QAT_FW_REQ_DEFAULT_SZ ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_TX , i); - ret =adf_create_ring (accel_dev,SEC , bank, num_msg_sym, + ret =adf_create_ring (accel_dev,SEC , sym_bank, num_msg_sym, msg_size, key,NULL ,0 , &inst->sym_tx);if (ret) goto err; msg_size = msg_size >>1 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_TX , i); - ret =adf_create_ring (accel_dev,SEC , bank, num_msg_asym, + ret =adf_create_ring (accel_dev,SEC , asym_bank, num_msg_asym, msg_size, key,NULL ,0 , &inst->pke_tx);if (ret) goto err; msg_size =ICP_QAT_FW_RESP_DEFAULT_SZ ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_SYM_RX , i); - ret =adf_create_ring (accel_dev,SEC , bank, num_msg_sym, + ret =adf_create_ring (accel_dev,SEC , sym_bank, num_msg_sym, msg_size, key, qat_alg_callback,0 , &inst->sym_rx);if (ret) goto err;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i); - ret =adf_create_ring (accel_dev,SEC , bank, num_msg_asym, + ret =adf_create_ring (accel_dev,SEC , asym_bank, num_msg_asym, msg_size, key, qat_alg_asym_callback,0 , &inst->pke_rx);if (ret)
Signature · 1 line
2.26.2
PATCH 31/31 crypto: qat - extend ae_mask
In reply to Giovanni CabidduChange type of ae_mask in adf_hw_device_data to allow for devices with more than 16 Acceleration Engines (AEs).
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -1
@@ -181,7 +181,7 @@ struct adf_hw_device_data {u32 accel_capabilities_mask;u32 instance_id;u16 accel_mask; -u16 ae_mask; +u32 ae_mask;u32 admin_ae_mask;u16 tx_rings_mask;u8 tx_rx_gap;
Signature · 1 line
2.26.2
Herbert Xu
maintainerQuoted 95 lines · Giovanni Cabiddu
This set is an initial rework of the QAT driver in preparation for the inclusion of the
qat_4xxxdriver (QAT GEN4).Summary of changes:
* IV update logic moved to software to remove allocation of the IV buffer in the data-path and allow for devices that are not capable of updating it when performing AES-CBC or AES-CTR.
* Added logic to detect the presence of engines and accelerators via soft-straps and fuse registers.
* Added infrastructure to support devices with an arbitrary number of rings per bank.
* Introduced adf_gen2_hw_data.[c|h] that contain logic that is common between QAT GEN2 devices (c62x, c3xxx and dh895xcc).
* Abstracted logic that configures iov threads.
* Abstracted access to transport CSRs.
* Abstracted, refactored and updated admin interface logic.
* Abstracted and refactored arbiter logic.
* Changed sequence on how arbitration is enabled on rings.
* Added support for device capability detection.
* Replaced hardcoded masks.
* Changed logic inadf_sriov.cto allow for drivers that do not implement some of the functions of that module.
* Refactored logic related to device configuration and instance creation.
* Changed logic to allow for instances in different banks.
* Extended accelerator mask.Ahsan Atta (1):
crypto: qat -num_rings_per_bankis device dependentGiovanni Cabiddu (28):
crypto: qat - mask device capabilities with soft straps
crypto: qat - fix configuration of iov threads
crypto: qat - split transport CSR access logic
crypto: qat - relocate GEN2 CSR access code
crypto: qat - abstract admin interface
crypto: qat - add packed to init admin structures
crypto: qat - rename ME in AE
crypto: qat - change admin sequence
crypto: qat - use admin mask to send fw constants
crypto: qat - update constants table
crypto: qat - remove writes into WQCFG
crypto: qat - remove unused macros in arbiter module
crypto: qat - abstract arbiter access
crypto: qat - register crypto instances based on capability
crypto: qat - enable ring after pair is programmed
crypto: qat - abstract build ring base
crypto: qat - replace constant masks with GENMASK
crypto: qat - useBIT_ULL()- 1 pattern for masks
crypto: qat - abstract writes to arbiter enable
crypto: qat - remove hardcoded bank irq clear flag mask
crypto: qat - call functions inadf_sriovif available
crypto: qat - remove unnecessary void* casts
crypto: qat - change return value inadf_cfg_add_key_value_param()
crypto: qat - change return value inadf_cfg_key_val_get()
crypto: qat - refactorqat_crypto_create_instances()
crypto: qat - refactorqat_crypto_dev_config()
crypto: qat - allow for instances in different banks
crypto: qat - extendae_maskMarco Chiappero (2):
crypto: qat - update IV in software
crypto: qat - add support for capability detection.../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 49 ++++- .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h | 5 + drivers/crypto/qat/qat_c3xxx/adf_drv.c | 11 +- .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c | 7 +- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 +- .../crypto/qat/qat_c62x/adf_c62x_hw_data.c | 49 ++++- .../crypto/qat/qat_c62x/adf_c62x_hw_data.h | 5 + drivers/crypto/qat/qat_c62x/adf_drv.c | 11 +- .../qat/qat_c62xvf/adf_c62xvf_hw_data.c | 7 +- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 +- drivers/crypto/qat/qat_common/Makefile | 1 + .../crypto/qat/qat_common/adf_accel_devices.h | 58 +++++- drivers/crypto/qat/qat_common/adf_admin.c | 77 ++++---- drivers/crypto/qat/qat_common/adf_cfg.c | 4 +- .../crypto/qat/qat_common/adf_cfg_strings.h | 3 +- .../crypto/qat/qat_common/adf_gen2_hw_data.c | 181 ++++++++++++++++++ .../crypto/qat/qat_common/adf_gen2_hw_data.h | 123 ++++++++++++ .../crypto/qat/qat_common/adf_hw_arbiter.c | 94 ++++----- drivers/crypto/qat/qat_common/adf_isr.c | 4 +- drivers/crypto/qat/qat_common/adf_sriov.c | 74 ++----- drivers/crypto/qat/qat_common/adf_transport.c | 130 +++++++++---- .../qat_common/adf_transport_access_macros.h | 67 ------- .../qat/qat_common/adf_transport_debug.c | 32 ++-- .../qat/qat_common/adf_transport_internal.h | 2 +- drivers/crypto/qat/qat_common/adf_vf_isr.c | 5 +- .../qat/qat_common/icp_qat_fw_init_admin.h | 6 +- drivers/crypto/qat/qat_common/icp_qat_hw.h | 23 +++ drivers/crypto/qat/qat_common/qat_algs.c | 136 +++++++------ drivers/crypto/qat/qat_common/qat_crypto.c | 162 ++++++++++------ drivers/crypto/qat/qat_common/qat_crypto.h | 26 ++- drivers/crypto/qat/qat_common/qat_hal.c | 27 +--
Quoted 8 lines
.../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 60 +++++- .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 5 + drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 9 +- .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c | 7 +- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 +- 36 files changed, 1024 insertions(+), 448 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.c create mode 100644 drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
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