crypto: hisilicon - add fallback function for hisilicon accelerater driver
Subsystems (5)
Chenghai Huang
maintainerv4 cover crypto: hisilicon - add fallback function for hisilicon accelerater driver
1.Supports multiple tfms sharing the same device queue to avoid tfm creation failure.
2.Support fallback for zip/sec2/hpre when queue allocation fails or when processing unsupported specifications.
When pf_q_num is less than the number of tfms, queues will be obtained from devices with fewer references and closer NUMA distances(priority: ref counts -> NUMA distances).
We can test by zswap:
modprobe hisi_zip uacce_mode=1 pf_q_num=2
cat /sys/class/uacce/hisi_zip-?/available_instances echo hisi-deflate-acomp > /sys/module/zswap/parameters/compressor
---
V3: https://lore.kernel.org/all/[email protected]/
Updates:
- In patch 7, fix the issue of skipping qp enablement due to incorrect reference count judgment.
- In patch 6, Supplement the device power wake-up operation before applying for the qp.
V2: https://lore.kernel.org/all/[email protected]/
Updates:
- According to crypto framework, support shared queues to address
the hardware resource limitation on tfm.
- Remove the fallback modification for x25519.
V1: https://lore.kernel.org/all/[email protected]/
Updates:
- Remove unnecessary callback completions.
- Add CRYPTO_ALG_NEED_FALLBACK to hisi_zip's cra_flags.
---
Chenghai Huang (8):
crypto: hisilicon/zip - adjust the way to obtain the req in the
callback function
crypto: hisilicon/sec - move backlog management to qp and store sqe in
qp for callback
crypto: hisilicon/qm - enhance the configuration of req_type in queue
attributes
crypto: hisilicon/qm - centralize the sending locks of each module
into qm
crypto: hisilicon - consolidate qp creation and start in
hisi_qm_alloc_qps_node
crypto: hisilicon/qm - add reference counting to queues for tfm kernel
reuse
crypto: hisilicon/qm - optimize device selection priority based on
queue ref count and NUMA distance
crypto: hisilicon/zip - support fallback for zip
Qi Tao (1):
crypto: hisilicon/sec2 - support skcipher/aead fallback for hardware
queue unavailable
Weili Qian (1):
crypto: hisilicon/hpre - support the hpre algorithm fallback
lizhi (1):
crypto: hisilicon/hpre: extend tag field to 64 bits for better
performance
drivers/crypto/hisilicon/Kconfig | 1 + drivers/crypto/hisilicon/hpre/hpre.h | 5 +- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 416 +++++++++++--------- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- drivers/crypto/hisilicon/qm.c | 206 +++++++--- drivers/crypto/hisilicon/sec2/sec.h | 7 - drivers/crypto/hisilicon/sec2/sec_crypto.c | 159 ++++---- drivers/crypto/hisilicon/sec2/sec_main.c | 21 +- drivers/crypto/hisilicon/zip/zip.h | 2 +- drivers/crypto/hisilicon/zip/zip_crypto.c | 133 ++++--- drivers/crypto/hisilicon/zip/zip_main.c | 4 +- include/linux/hisi_acc_qm.h | 14 +- 12 files changed, 574 insertions(+), 396 deletions(-)
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 1/11 crypto: hisilicon/zip - adjust the way to obtain the req in the callback function
In the shared queue design, multiple tfms use same qp, and one qp need to corresponds to multiple qp_ctx. So use tag to obtain the req virtual address. Build a one-to-one relationship between tfm and qp_ctx. finaly remove the old get_tag operation.
--- drivers/crypto/hisilicon/zip/zip_crypto.c | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/crypto/hisilicon/zip/zip_crypto.c +9 -15
@@ -39,6 +39,7 @@ enum { HZIP_CTX_Q_NUM }; +#define GET_REQ_FROM_SQE (sqe) ((u64)(sqe)->dw26 | (u64)(sqe)->dw27 << 32)#define COMP_NAME_TO_TYPE (alg_name) \ (!strcmp((alg_name), "deflate") ? HZIP_ALG_TYPE_DEFLATE : 0)
@@ -48,6 +49,7 @@ struct hisi_zip_req {struct hisi_acc_hw_sgl *hw_dst;dma_addr_t dma_src;dma_addr_t dma_dst; +struct hisi_zip_qp_ctx *qp_ctx;u16 req_id; };
@@ -74,7 +76,6 @@ struct hisi_zip_sqe_ops {void (*fill_req_type)(struct hisi_zip_sqe *sqe,u8 req_type);void (*fill_tag)(struct hisi_zip_sqe *sqe,struct hisi_zip_req *req);void (*fill_sqe_type)(struct hisi_zip_sqe *sqe,u8 sqe_type); -u32 (*get_tag)(struct hisi_zip_sqe *sqe);u32 (*get_status)(struct hisi_zip_sqe *sqe);u32 (*get_dstlen)(struct hisi_zip_sqe *sqe); };
@@ -131,6 +132,7 @@ static struct hisi_zip_req *hisi_zip_create_req(struct hisi_zip_qp_ctx *qp_ctx, req_cache = q + req_id; req_cache->req_id = req_id; req_cache->req = req; + req_cache->qp_ctx = qp_ctx;return req_cache; }
@@ -181,7 +183,8 @@ static void hisi_zip_fill_req_type(struct hisi_zip_sqe *sqe, u8 req_type)static void hisi_zip_fill_tag (struct hisi_zip_sqe *sqe,struct hisi_zip_req *req) { - sqe->dw26 = req->req_id; + sqe->dw26 =lower_32_bits ((u64 )req); + sqe->dw27 =upper_32_bits ((u64 )req); }static void hisi_zip_fill_sqe_type (struct hisi_zip_sqe *sqe,u8 sqe_type)
@@ -237,7 +240,7 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx, &req->dma_dst, DMA_FROM_DEVICE);if (IS_ERR (req->hw_dst)) { ret =PTR_ERR (req->hw_dst); -dev_err (dev,"failed to map the dst buffer to hw slg (%d)!\n" , +dev_err (dev,"failed to map the dst buffer to hw sgl (%d)!\n" , ret); goto err_unmap_input; }
@@ -265,11 +268,6 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx,return ret; } -static u32 hisi_zip_get_tag (struct hisi_zip_sqe *sqe) -{ -return sqe->dw26; -} -static u32 hisi_zip_get_status (struct hisi_zip_sqe *sqe) {return sqe->dw3 &HZIP_BD_STATUS_M ;
@@ -282,14 +280,12 @@ static u32 hisi_zip_get_dstlen(struct hisi_zip_sqe *sqe)static void hisi_zip_acomp_cb (struct hisi_qp *qp,void *data) { -struct hisi_zip_qp_ctx *qp_ctx = qp->qp_ctx; +struct hisi_zip_sqe *sqe = data; +struct hisi_zip_req *req = (struct hisi_zip_req *)GET_REQ_FROM_SQE (sqe); +struct hisi_zip_qp_ctx *qp_ctx = req->qp_ctx;const struct hisi_zip_sqe_ops *ops = qp_ctx->ctx->ops;struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx; -struct hisi_zip_req_q *req_q = &qp_ctx->req_q;struct device *dev = &qp->qm->pdev->dev; -struct hisi_zip_sqe *sqe = data; -u32 tag = ops->get_tag (sqe); -struct hisi_zip_req *req = req_q->q + tag;struct acomp_req *acomp_req = req->req;int err =0 ;u32 status;
@@ -393,7 +389,6 @@ static const struct hisi_zip_sqe_ops hisi_zip_ops = { .fill_req_type = hisi_zip_fill_req_type, .fill_tag = hisi_zip_fill_tag, .fill_sqe_type = hisi_zip_fill_sqe_type, - .get_tag = hisi_zip_get_tag, .get_status = hisi_zip_get_status, .get_dstlen = hisi_zip_get_dstlen, };
@@ -581,7 +576,6 @@ static void hisi_zip_acomp_exit(struct crypto_acomp *tfm) {struct hisi_zip_ctx *ctx =crypto_tfm_ctx (&tfm->base); -hisi_zip_set_acomp_cb (ctx,NULL );hisi_zip_release_sgl_pool (ctx);hisi_zip_release_req_q (ctx);hisi_zip_ctx_exit (ctx);
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 2/11 crypto: hisilicon/sec - move backlog management to qp and store sqe in qp for callback
In reply to Chenghai HuangWhen multiple tfm use a same qp, the backlog data should be managed centrally by the qp, rather than in the qp_ctx of each req.
Additionally, since SEC_BD_TYPE1 and SEC_BD_TYPE2 cannot use the tag of the sqe to carry the virtual address of the req, the sent sqe is stored in the qp. This allows the callback function to get the req address. To handle the differences between hardware types, the callback functions are split into two separate implementations.
--- drivers/crypto/hisilicon/qm.c | 20 ++++- drivers/crypto/hisilicon/sec2/sec.h | 7 -- drivers/crypto/hisilicon/sec2/sec_crypto.c | 88 +++++++++++----------- include/linux/hisi_acc_qm.h | 8 ++ 4 files changed, 69 insertions(+), 54 deletions(-)
drivers/crypto/hisilicon/qm.c +16 -4
@@ -2219,6 +2219,7 @@ static void qp_stop_fail_cb(struct hisi_qp *qp)for (i =0 ; i < qp_used; i++) { pos = (i + cur_head) % sq_depth; qp->req_cb (qp, qp->sqe + (u32)(qm->sqe_size * pos)); +qm_cq_head_update (qp);atomic_dec (&qp->qp_status.used); } }
@@ -2383,6 +2384,7 @@ int hisi_qp_send(struct hisi_qp *qp, const void *msg)return -EBUSY ;memcpy (sqe, msg, qp->qm->sqe_size); + qp->msg[sq_tail] = msg;qm_db (qp->qm, qp->qp_id,QM_DOORBELL_CMD_SQ , sq_tail_next,0 );atomic_inc (&qp->qp_status.used);
@@ -2919,12 +2921,13 @@ EXPORT_SYMBOL_GPL(hisi_qm_wait_task_finish);static void hisi_qp_memory_uninit (struct hisi_qm *qm,int num) {struct device *dev = &qm->pdev->dev; -struct qm_dma *qdma; +struct hisi_qp *qp;int i;for (i = num -1 ; i >=0 ; i--) { - qdma = &qm->qp_array[i].qdma; -dma_free_coherent (dev, qdma->size, qdma->va, qdma->dma); + qp = &qm->qp_array[i]; +dma_free_coherent (dev, qp->qdma.size, qp->qdma.va, qp->qdma.dma); +kfree (qp->msg);kfree (qm->poll_data[i].qp_finish_id); }
@@ -2946,10 +2949,14 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id,return -ENOMEM ; qp = &qm->qp_array[id]; + qp->msg =kmalloc_array (sq_depth,sizeof (void *),GFP_KERNEL ); +if (!qp->msg) + goto err_free_qp_finish_id; + qp->qdma.va =dma_alloc_coherent (dev, dma_size, &qp->qdma.dma,GFP_KERNEL );if (!qp->qdma.va) - goto err_free_qp_finish_id; + goto err_free_qp_msg; qp->sqe = qp->qdma.va; qp->sqe_dma = qp->qdma.dma;
@@ -2961,8 +2968,13 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id, qp->qm = qm; qp->qp_id = id; +spin_lock_init (&qp->backlog.lock); +INIT_LIST_HEAD (&qp->backlog.list); +return 0 ; +err_free_qp_msg: +kfree (qp->msg); err_free_qp_finish_id:kfree (qm->poll_data[id].qp_finish_id);return ret;
drivers/crypto/hisilicon/sec2/sec.h +0 -7
@@ -82,11 +82,6 @@ struct sec_aead_req {__u8 out_mac_buf[SEC_MAX_MAC_LEN ]; }; -struct sec_instance_backlog { -struct list_head list; -spinlock_t lock; -}; -/* SEC request of Crypto */ struct sec_req { union {
@@ -112,7 +107,6 @@ struct sec_req {bool use_pbuf;struct list_head list; -struct sec_instance_backlog *backlog;struct sec_request_buf buf; };
@@ -172,7 +166,6 @@ struct sec_qp_ctx {spinlock_t id_lock;struct hisi_acc_sgl_pool *c_in_pool;struct hisi_acc_sgl_pool *c_out_pool; -struct sec_instance_backlog backlog;u16 send_head; };
drivers/crypto/hisilicon/sec2/sec_crypto.c +45 -43
190 lines not on this page · raw message
include/linux/hisi_acc_qm.h +8 -0
@@ -444,6 +444,11 @@ struct hisi_qp_ops {int (*fill_sqe)(void *sqe,void *q_parm,void *d_parm); }; +struct instance_backlog { +struct list_head list; +spinlock_t lock; +}; +struct hisi_qp {u32 qp_id;u16 sq_depth;
@@ -468,6 +473,9 @@ struct hisi_qp {bool is_in_kernel;u16 pasid;struct uacce_queue *uacce_q; + +struct instance_backlog backlog; +const void **msg; };static inline int vfs_num_set (const char *val,const struct kernel_param *kp)
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 3/11 crypto: hisilicon/hpre: extend tag field to 64 bits for better performance
In reply to Chenghai HuangFrom: lizhi <[email protected]>
This commit expands the tag field in hpre_sqe structure from 16-bit to 64-bit. The change enables storing request addresses directly in the tag field, allowing callback functions to access request messages without the previous indirection mechanism.
By eliminating the need for lookup tables, this modification reduces lock contention and associated overhead, leading to improved efficiency and simplified code.
--- drivers/crypto/hisilicon/hpre/hpre.h | 5 +- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 142 ++++---------------- 2 files changed, 25 insertions(+), 122 deletions(-)
drivers/crypto/hisilicon/hpre/hpre.h +2 -3
@@ -94,9 +94,8 @@ struct hpre_sqe {__le64 key;__le64 in;__le64 out; -__le16 tag; -__le16 resv2; -#define _HPRE_SQE_ALIGN_EXT 7 +__le64 tag; +#define _HPRE_SQE_ALIGN_EXT 6__le32 rsvd1[_HPRE_SQE_ALIGN_EXT]; };
drivers/crypto/hisilicon/hpre/hpre_crypto.c +23 -119
272 lines not on this page · raw message
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 4/11 crypto: hisilicon/qm - enhance the configuration of req_type in queue attributes
In reply to Chenghai HuangOriginally, when a queue was requested, it could only be configured with the default algorithm type of 0. Now, when multiple tfms use the same queue, the queue must be selected based on its attributes to meet the requirements of tfm tasks. So the algorithm type attribute of queue need to be distinguished. Just like a queue used for compression in ZIP cannot be used for decompression tasks.
--- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- drivers/crypto/hisilicon/qm.c | 8 ++++---- drivers/crypto/hisilicon/sec2/sec_crypto.c | 1 - drivers/crypto/hisilicon/sec2/sec_main.c | 21 ++++++++++++++++----- drivers/crypto/hisilicon/zip/zip.h | 2 +- drivers/crypto/hisilicon/zip/zip_crypto.c | 13 +++++++++---- drivers/crypto/hisilicon/zip/zip_main.c | 4 ++-- include/linux/hisi_acc_qm.h | 3 +-- 8 files changed, 34 insertions(+), 20 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +1 -1
@@ -465,7 +465,7 @@ struct hisi_qp *hpre_create_qp(u8 type)* type: 0 - RSA/DH. algorithm supported in V2, * 1 - ECC algorithm in V3. */ - ret =hisi_qm_alloc_qps_node (&hpre_devices,1 , type, node, &qp); + ret =hisi_qm_alloc_qps_node (&hpre_devices,1 , &type, node, &qp);if (!ret)return qp;
drivers/crypto/hisilicon/qm.c +4 -4
@@ -3595,7 +3595,7 @@ static int hisi_qm_sort_devices(int node, struct list_head *head,* not meet the requirements will return error. */ int hisi_qm_alloc_qps_node (struct hisi_qm_list *qm_list,int qp_num, -u8 alg_type,int node,struct hisi_qp **qps) +u8 *alg_type,int node,struct hisi_qp **qps) {struct hisi_qm_resource *tmp;int ret = -ENODEV ;
@@ -3613,7 +3613,7 @@ int hisi_qm_alloc_qps_node(struct hisi_qm_list *qm_list, int qp_num,list_for_each_entry (tmp, &head, list) {for (i =0 ; i < qp_num; i++) { - qps[i] =hisi_qm_create_qp (tmp->qm, alg_type); + qps[i] =hisi_qm_create_qp (tmp->qm, alg_type[i]);if (IS_ERR (qps[i])) {hisi_qm_free_qps (qps, i);break ;
@@ -3628,8 +3628,8 @@ int hisi_qm_alloc_qps_node(struct hisi_qm_list *qm_list, int qp_num,mutex_unlock (&qm_list->lock);if (ret) -pr_info ("Failed to create qps, node[%d], alg[%u], qp[%d]!\n" , - node, alg_type, qp_num); +pr_info ("Failed to create qps, node[%d], qp[%d]!\n" , + node, qp_num); err:free_list (&head);
drivers/crypto/hisilicon/sec2/sec_crypto.c +0 -1
@@ -626,7 +626,6 @@ static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id) qp_ctx = &ctx->qp_ctx[qp_ctx_id]; qp = ctx->qps[qp_ctx_id]; - qp->req_type =0 ; qp->qp_ctx = qp_ctx; qp_ctx->qp = qp; qp_ctx->ctx = ctx;
drivers/crypto/hisilicon/sec2/sec_main.c +16 -5
@@ -417,18 +417,29 @@ struct hisi_qp **sec_create_qps(void)int node =cpu_to_node (raw_smp_processor_id ());u32 ctx_num = ctx_q_num;struct hisi_qp **qps; +u8 *type;int ret; qps =kcalloc (ctx_num,sizeof (struct hisi_qp *),GFP_KERNEL );if (!qps)return NULL ; - ret =hisi_qm_alloc_qps_node (&sec_devices, ctx_num,0 , node, qps); -if (!ret) -return qps; +/* The type of SEC is all 0, so just allocated by kcalloc */ + type =kcalloc (ctx_num,sizeof (u8),GFP_KERNEL ); +if (!type) { +kfree (qps); +return NULL ; + } -kfree (qps); -return NULL ; + ret =hisi_qm_alloc_qps_node (&sec_devices, ctx_num, type, node, qps); +if (ret) { +kfree (type); +kfree (qps); +return NULL ; + } + +kfree (type); +return qps; }u64 sec_get_alg_bitmap (struct hisi_qm *qm,u32 high,u32 low)
drivers/crypto/hisilicon/zip/zip.h +1 -1
@@ -99,7 +99,7 @@ enum zip_cap_table_type { ZIP_CORE5_BITMAP, }; -int zip_create_qps (struct hisi_qp **qps,int qp_num,int node); +int zip_create_qps (struct hisi_qp **qps,int qp_num,int node,u8 *alg_type);int hisi_zip_register_to_crypto (struct hisi_qm *qm);void hisi_zip_unregister_from_crypto (struct hisi_qm *qm);bool hisi_zip_alg_support (struct hisi_qm *qm,u32 alg);
drivers/crypto/hisilicon/zip/zip_crypto.c +9 -4
@@ -66,6 +66,7 @@ struct hisi_zip_qp_ctx {struct hisi_acc_sgl_pool *sgl_pool;struct hisi_zip *zip_dev;struct hisi_zip_ctx *ctx; +u8 req_type; };struct hisi_zip_sqe_ops {
@@ -245,7 +246,7 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx, goto err_unmap_input; } -hisi_zip_fill_sqe (qp_ctx->ctx, &zip_sqe, qp->req_type, req); +hisi_zip_fill_sqe (qp_ctx->ctx, &zip_sqe, qp_ctx->req_type, req);/* send command to start a task */ atomic64_inc (&dfx->send_cnt);
@@ -360,7 +361,6 @@ static int hisi_zip_start_qp(struct hisi_qp *qp, struct hisi_zip_qp_ctx *qp_ctx,struct device *dev = &qp->qm->pdev->dev;int ret; - qp->req_type = req_type; qp->alg_type = alg_type; qp->qp_ctx = qp_ctx;
@@ -397,10 +397,15 @@ static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type, int {struct hisi_qp *qps[HZIP_CTX_Q_NUM ] = {NULL };struct hisi_zip_qp_ctx *qp_ctx; +u8 alg_type[HZIP_CTX_Q_NUM ];struct hisi_zip *hisi_zip;int ret, i, j; - ret =zip_create_qps (qps,HZIP_CTX_Q_NUM , node); +/* alg_type = 0 for compress, 1 for decompress in hw sqe */ +for (i =0 ; i <HZIP_CTX_Q_NUM ; i++) + alg_type[i] = i; + + ret =zip_create_qps (qps,HZIP_CTX_Q_NUM , node, alg_type);if (ret) {pr_err ("failed to create zip qps (%d)!\n" , ret);return -ENODEV ;
@@ -409,7 +414,6 @@ static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type, int hisi_zip = container_of(qps[0]->qm, struct hisi_zip, qm);for (i =0 ; i <HZIP_CTX_Q_NUM ; i++) { -/* alg_type = 0 for compress, 1 for decompress in hw sqe */ qp_ctx = &hisi_zip_ctx->qp_ctx[i]; qp_ctx->ctx = hisi_zip_ctx; ret =hisi_zip_start_qp (qps[i], qp_ctx, i, req_type);
@@ -422,6 +426,7 @@ static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type, int } qp_ctx->zip_dev = hisi_zip; + qp_ctx->req_type = req_type; } hisi_zip_ctx->ops = &hisi_zip_ops;
drivers/crypto/hisilicon/zip/zip_main.c +2 -2
@@ -446,12 +446,12 @@ static const struct pci_device_id hisi_zip_dev_ids[] = { };MODULE_DEVICE_TABLE (pci, hisi_zip_dev_ids); -int zip_create_qps (struct hisi_qp **qps,int qp_num,int node) +int zip_create_qps (struct hisi_qp **qps,int qp_num,int node,u8 *alg_type) {if (node ==NUMA_NO_NODE ) node =cpu_to_node (raw_smp_processor_id ()); -return hisi_qm_alloc_qps_node (&zip_devices, qp_num,0 , node, qps); +return hisi_qm_alloc_qps_node (&zip_devices, qp_num, alg_type, node, qps); }bool hisi_zip_alg_support (struct hisi_qm *qm,u32 alg)
include/linux/hisi_acc_qm.h +1 -2
@@ -454,7 +454,6 @@ struct hisi_qp {u16 sq_depth;u16 cq_depth;u8 alg_type; -u8 req_type;struct qm_dma qdma;void *sqe;
@@ -580,7 +579,7 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,void hisi_acc_free_sgl_pool (struct device *dev,struct hisi_acc_sgl_pool *pool);int hisi_qm_alloc_qps_node (struct hisi_qm_list *qm_list,int qp_num, -u8 alg_type,int node,struct hisi_qp **qps); +u8 *alg_type,int node,struct hisi_qp **qps);void hisi_qm_free_qps (struct hisi_qp **qps,int qp_num);void hisi_qm_dev_shutdown (struct pci_dev *pdev);void hisi_qm_wait_task_finish (struct hisi_qm *qm,struct hisi_qm_list *qm_list);
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 5/11 crypto: hisilicon/qm - centralize the sending locks of each module into qm
In reply to Chenghai HuangWhen a single queue used by multiple tfms, the protection of shared resources by individual module driver programs is no longer sufficient. The hisi_qp_send needs to be ensured by the lock in qp.
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 4 ---- drivers/crypto/hisilicon/qm.c | 16 ++++++++++++---- drivers/crypto/hisilicon/zip/zip_crypto.c | 3 --- include/linux/hisi_acc_qm.h | 1 + 4 files changed, 13 insertions(+), 11 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +0 -4
@@ -109,7 +109,6 @@ struct hpre_ctx {struct hisi_qp *qp;struct device *dev;struct hpre *hpre; -spinlock_t req_lock;unsigned int key_sz;bool crt_g2_mode;union {
@@ -410,7 +409,6 @@ static int hpre_ctx_init(struct hpre_ctx *ctx, u8 type) qp->qp_ctx = ctx; qp->req_cb = hpre_alg_cb; -spin_lock_init (&ctx->req_lock); ctx->qp = qp; ctx->dev = &qp->qm->pdev->dev; hpre = container_of(ctx->qp->qm, struct hpre, qm);
@@ -478,9 +476,7 @@ static int hpre_send(struct hpre_ctx *ctx, struct hpre_sqe *msg) do { atomic64_inc(&dfx[HPRE_SEND_CNT].value); - spin_lock_bh(&ctx->req_lock); ret = hisi_qp_send(ctx->qp, msg); - spin_unlock_bh(&ctx->req_lock); if (ret != -EBUSY) break; atomic64_inc(&dfx[HPRE_SEND_BUSY_CNT].value);
drivers/crypto/hisilicon/qm.c +12 -4
@@ -2369,26 +2369,33 @@ EXPORT_SYMBOL_GPL(hisi_qm_stop_qp);int hisi_qp_send (struct hisi_qp *qp,const void *msg) {struct hisi_qp_status *qp_status = &qp->qp_status; -u16 sq_tail = qp_status->sq_tail; -u16 sq_tail_next = (sq_tail +1 ) % qp->sq_depth; -void *sqe =qm_get_avail_sqe (qp); +u16 sq_tail, sq_tail_next; +void *sqe; +spin_lock_bh (&qp->qp_lock);if (unlikely (atomic_read (&qp->qp_status.flags) ==QP_STOP ||atomic_read (&qp->qm->status.flags) ==QM_STOP || qp->is_resetting)) { +spin_unlock_bh (&qp->qp_lock);dev_info_ratelimited (&qp->qm->pdev->dev,"QP is stopped or resetting\n" );return -EAGAIN ; } -if (!sqe) + sqe =qm_get_avail_sqe (qp); +if (!sqe) { +spin_unlock_bh (&qp->qp_lock);return -EBUSY ; + } + sq_tail = qp_status->sq_tail; + sq_tail_next = (sq_tail +1 ) % qp->sq_depth;memcpy (sqe, msg, qp->qm->sqe_size); qp->msg[sq_tail] = msg;qm_db (qp->qm, qp->qp_id,QM_DOORBELL_CMD_SQ , sq_tail_next,0 );atomic_inc (&qp->qp_status.used); qp_status->sq_tail = sq_tail_next; +spin_unlock_bh (&qp->qp_lock);return 0 ; }
@@ -2968,6 +2975,7 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id, qp->qm = qm; qp->qp_id = id; +spin_lock_init (&qp->qp_lock);spin_lock_init (&qp->backlog.lock);INIT_LIST_HEAD (&qp->backlog.list);
drivers/crypto/hisilicon/zip/zip_crypto.c +0 -3
@@ -217,7 +217,6 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx, {struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool;struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx; -struct hisi_zip_req_q *req_q = &qp_ctx->req_q;struct acomp_req *a_req = req->req;struct hisi_qp *qp = qp_ctx->qp;struct device *dev = &qp->qm->pdev->dev;
@@ -250,9 +249,7 @@ static int hisi_zip_do_work(struct hisi_zip_qp_ctx *qp_ctx,/* send command to start a task */ atomic64_inc (&dfx->send_cnt); -spin_lock_bh (&req_q->req_lock); ret =hisi_qp_send (qp, &zip_sqe); -spin_unlock_bh (&req_q->req_lock);if (unlikely (ret <0 )) {atomic64_inc (&dfx->send_busy_cnt); ret = -EAGAIN ;
include/linux/hisi_acc_qm.h +1 -0
@@ -473,6 +473,7 @@ struct hisi_qp {u16 pasid;struct uacce_queue *uacce_q; +spinlock_t qp_lock;struct instance_backlog backlog;const void **msg; };
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 6/11 crypto: hisilicon - consolidate qp creation and start in hisi_qm_alloc_qps_node
In reply to Chenghai HuangConsolidate the creation and start of qp into the function hisi_qm_alloc_qps_node. This change eliminates the need for each module to perform these steps in two separate phases (creation and start).
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 40 ++---------- drivers/crypto/hisilicon/qm.c | 70 ++++++++++++++++----- drivers/crypto/hisilicon/sec2/sec_crypto.c | 8 --- drivers/crypto/hisilicon/zip/zip_crypto.c | 43 ++----------- include/linux/hisi_acc_qm.h | 1 - 5 files changed, 66 insertions(+), 96 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +4 -36
@@ -156,27 +156,6 @@ static void hpre_dfx_add_req_time(struct hpre_asym_request *hpre_req)ktime_get_ts64 (&hpre_req->req_time); } -static struct hisi_qp *hpre_get_qp_and_start (u8 type) -{ -struct hisi_qp *qp; -int ret; - - qp =hpre_create_qp (type); -if (!qp) { -pr_err ("Can not create hpre qp!\n" ); -return ERR_PTR (-ENODEV ); - } - - ret =hisi_qm_start_qp (qp,0 ); -if (ret <0 ) { -hisi_qm_free_qps (&qp,1 ); -pci_err (qp->qm->pdev,"Can not start qp!\n" ); -return ERR_PTR (-EINVAL ); - } - -return qp; -} -static int hpre_get_data_dma_addr (struct hpre_asym_request *hpre_req,struct scatterlist *data,unsigned int len,int is_src,dma_addr_t *tmp)
@@ -316,9 +295,8 @@ static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe,static void hpre_ctx_clear (struct hpre_ctx *ctx,bool is_clear_all) { -if (is_clear_all) { +if (is_clear_all)hisi_qm_free_qps (&ctx->qp,1 ); - } ctx->crt_g2_mode = false; ctx->key_sz =0 ;
@@ -403,11 +381,10 @@ static int hpre_ctx_init(struct hpre_ctx *ctx, u8 type)struct hisi_qp *qp;struct hpre *hpre; - qp =hpre_get_qp_and_start (type); -if (IS_ERR (qp)) -return PTR_ERR (qp); + qp =hpre_create_qp (type); +if (!qp) +return -ENODEV ; - qp->qp_ctx = ctx; qp->req_cb = hpre_alg_cb; ctx->qp = qp; ctx->dev = &qp->qm->pdev->dev;
@@ -597,9 +574,6 @@ static void hpre_dh_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)struct device *dev = ctx->dev;unsigned int sz = ctx->key_sz; -if (is_clear_all) -hisi_qm_stop_qp (ctx->qp); -if (ctx->dh.g) {dma_free_coherent (dev, sz, ctx->dh.g, ctx->dh.dma_g); ctx->dh.g =NULL ;
@@ -940,9 +914,6 @@ static void hpre_rsa_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)unsigned int half_key_sz = ctx->key_sz >>1 ;struct device *dev = ctx->dev; -if (is_clear_all) -hisi_qm_stop_qp (ctx->qp); -if (ctx->rsa.pubkey) {dma_free_coherent (dev, ctx->key_sz <<1 , ctx->rsa.pubkey, ctx->rsa.dma_pubkey);
@@ -1112,9 +1083,6 @@ static void hpre_ecc_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)unsigned int sz = ctx->key_sz;unsigned int shift = sz <<1 ; -if (is_clear_all) -hisi_qm_stop_qp (ctx->qp); -if (ctx->ecdh.p) {/* ecdh: p->a->k->b */ memzero_explicit (ctx->ecdh.p + shift, sz);
drivers/crypto/hisilicon/qm.c +56 -14
101 lines not on this page · raw message
drivers/crypto/hisilicon/sec2/sec_crypto.c +0 -8
@@ -626,7 +626,6 @@ static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id) qp_ctx = &ctx->qp_ctx[qp_ctx_id]; qp = ctx->qps[qp_ctx_id]; - qp->qp_ctx = qp_ctx; qp_ctx->qp = qp; qp_ctx->ctx = ctx;
@@ -644,14 +643,8 @@ static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id)if (ret) goto err_destroy_idr; - ret =hisi_qm_start_qp (qp,0 ); -if (ret <0 ) - goto err_resource_free; -return 0 ; -err_resource_free: -sec_free_qp_ctx_resource (ctx, qp_ctx); err_destroy_idr:idr_destroy (&qp_ctx->req_idr);return ret;
@@ -660,7 +653,6 @@ static int sec_create_qp_ctx(struct sec_ctx *ctx, int qp_ctx_id)static void sec_release_qp_ctx (struct sec_ctx *ctx,struct sec_qp_ctx *qp_ctx) { -hisi_qm_stop_qp (qp_ctx->qp);sec_free_qp_ctx_resource (ctx, qp_ctx);idr_destroy (&qp_ctx->req_idr); }
drivers/crypto/hisilicon/zip/zip_crypto.c +6 -37
72 lines not on this page · raw message
include/linux/hisi_acc_qm.h +0 -1
@@ -463,7 +463,6 @@ struct hisi_qp {struct hisi_qp_status qp_status;struct hisi_qp_ops *hw_ops; -void *qp_ctx;void (*req_cb)(struct hisi_qp *qp,void *data);void (*event_cb)(struct hisi_qp *qp);
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 7/11 crypto: hisilicon/qm - add reference counting to queues for tfm kernel reuse
In reply to Chenghai HuangAdd reference counting to queues. When all queues are occupied, tfm will reuse queues with the same algorithm type that have already been allocated in the kernel. The corresponding queue will be released when the reference count reaches 1.
--- drivers/crypto/hisilicon/qm.c | 65 +++++++++++++++++++++++++++-------- include/linux/hisi_acc_qm.h | 1 + 2 files changed, 52 insertions(+), 14 deletions(-)
drivers/crypto/hisilicon/qm.c +51 -14
@@ -2002,7 +2002,38 @@ static void hisi_qm_unset_hw_reset(struct hisi_qp *qp) *addr =0 ; } -static struct hisi_qp *qm_create_qp_nolock (struct hisi_qm *qm,u8 alg_type) +static struct hisi_qp *find_shareable_qp (struct hisi_qm *qm,u8 alg_type,bool is_in_kernel) +{ +struct device *dev = &qm->pdev->dev; +struct hisi_qp *share_qp =NULL ; +struct hisi_qp *qp; +u32 ref_count = ~0 ; +int i; + +if (!is_in_kernel) + goto queues_busy; + +for (i =0 ; i < qm->qp_num; i++) { + qp = &qm->qp_array[i]; +if (qp->is_in_kernel && qp->alg_type == alg_type && qp->ref_count < ref_count) { + ref_count = qp->ref_count; + share_qp = qp; + } + } + +if (share_qp) { + share_qp->ref_count++; +return share_qp; + } + +queues_busy: +dev_info_ratelimited (dev,"All %u queues of QM are busy and no shareable queue\n" , + qm->qp_num); +atomic64_inc (&qm->debug.dfx.create_qp_err_cnt); +return ERR_PTR (-EBUSY ); +} + +static struct hisi_qp *qm_create_qp_nolock (struct hisi_qm *qm,u8 alg_type,bool is_in_kernel) {struct device *dev = &qm->pdev->dev;struct hisi_qp *qp;
@@ -2013,12 +2044,9 @@ static struct hisi_qp *qm_create_qp_nolock(struct hisi_qm *qm, u8 alg_type)return ERR_PTR (-EPERM ); } -if (qm->qp_in_used == qm->qp_num) { -dev_info_ratelimited (dev,"All %u queues of QM are busy!\n" , - qm->qp_num); -atomic64_inc (&qm->debug.dfx.create_qp_err_cnt); -return ERR_PTR (-EBUSY ); - } +/* Try to find a shareable queue when all queues are busy */ +if (qm->qp_in_used == qm->qp_num) +return find_shareable_qp (qm, alg_type, is_in_kernel); qp_id =idr_alloc_cyclic (&qm->qp_idr,NULL ,0 , qm->qp_num,GFP_ATOMIC );if (qp_id <0 ) {
@@ -2034,10 +2062,10 @@ static struct hisi_qp *qm_create_qp_nolock(struct hisi_qm *qm, u8 alg_type) qp->event_cb =NULL ; qp->req_cb =NULL ; - qp->qp_id = qp_id; qp->alg_type = alg_type; - qp->is_in_kernel = true; + qp->is_in_kernel = is_in_kernel; qm->qp_in_used++; + qp->ref_count =1 ;return qp; }
@@ -2059,7 +2087,7 @@ static struct hisi_qp *hisi_qm_create_qp(struct hisi_qm *qm, u8 alg_type)return ERR_PTR (ret);down_write (&qm->qps_lock); - qp =qm_create_qp_nolock (qm, alg_type); + qp =qm_create_qp_nolock (qm, alg_type, false);up_write (&qm->qps_lock);if (IS_ERR (qp))
@@ -2458,7 +2486,6 @@ static int hisi_qm_uacce_get_queue(struct uacce_device *uacce, qp->uacce_q = q; qp->event_cb = qm_qp_event_notifier; qp->pasid = arg; - qp->is_in_kernel = false;return 0 ; }
@@ -3532,6 +3559,9 @@ static void qm_release_qp_nolock(struct hisi_qp *qp) {struct hisi_qm *qm = qp->qm; +if (--qp->ref_count) +return ; + qm->qp_in_used--;idr_remove (&qm->qp_idr, qp->qp_id); }
@@ -3551,7 +3581,9 @@ void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num)down_write (&qps[0 ]->qm->qps_lock);for (i = qp_num -1 ; i >=0 ; i--) { -qm_stop_qp_nolock (qps[i]); +if (qps[i]->ref_count ==1 ) +qm_stop_qp_nolock (qps[i]); +qm_release_qp_nolock (qps[i]); }
@@ -3580,12 +3612,15 @@ static int qm_get_and_start_qp(struct hisi_qm *qm, int qp_num, struct hisi_qp **down_write (&qm->qps_lock);for (i =0 ; i < qp_num; i++) { - qps[i] =qm_create_qp_nolock (qm, alg_type[i]); + qps[i] =qm_create_qp_nolock (qm, alg_type[i], true);if (IS_ERR (qps[i])) { ret = -ENODEV ; goto stop_and_free; } +if (qps[i]->ref_count !=1 ) +continue ; + ret =qm_start_qp_nolock (qps[i],0 );if (ret) {qm_release_qp_nolock (qps[i]);
@@ -3598,7 +3633,9 @@ static int qm_get_and_start_qp(struct hisi_qm *qm, int qp_num, struct hisi_qp ** stop_and_free:for (i--; i >=0 ; i--) { -qm_stop_qp_nolock (qps[i]); +if (qps[i]->ref_count ==1 ) +qm_stop_qp_nolock (qps[i]); +qm_release_qp_nolock (qps[i]); }up_write (&qm->qps_lock);
include/linux/hisi_acc_qm.h +1 -0
@@ -472,6 +472,7 @@ struct hisi_qp {u16 pasid;struct uacce_queue *uacce_q; +u32 ref_count;spinlock_t qp_lock;struct instance_backlog backlog;const void **msg;
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 8/11 crypto: hisilicon/qm - optimize device selection priority based on queue ref count and NUMA distance
In reply to Chenghai HuangAdd device sorting criteria to prioritize devices with fewer references and closer NUMA distances. Devices that are fully occupied will not be prioritized for use.
--- drivers/crypto/hisilicon/qm.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/crypto/hisilicon/qm.c +25 -10
@@ -3592,6 +3592,20 @@ void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num) }EXPORT_SYMBOL_GPL (hisi_qm_free_qps); +static void qm_insert_sorted (struct list_head *head,struct hisi_qm_resource *res) +{ +struct hisi_qm_resource *tmp; +struct list_head *n = head; + +list_for_each_entry (tmp, head, list) { +if (res->distance < tmp->distance) { + n = &tmp->list; +break ; + } + } +list_add_tail (&res->list, n); +} +static void free_list (struct list_head *head) {struct hisi_qm_resource *res, *tmp;
@@ -3647,11 +3661,12 @@ static int qm_get_and_start_qp(struct hisi_qm *qm, int qp_num, struct hisi_qp **static int hisi_qm_sort_devices (int node,struct list_head *head,struct hisi_qm_list *qm_list) { -struct hisi_qm_resource *res, *tmp; +struct hisi_qm_resource *res;struct hisi_qm *qm; -struct list_head *n;struct device *dev;int dev_node; +LIST_HEAD (non_full_list); +LIST_HEAD (full_list);list_for_each_entry (qm, &qm_list->list, list) { dev = &qm->pdev->dev;
@@ -3666,16 +3681,16 @@ static int hisi_qm_sort_devices(int node, struct list_head *head, res->qm = qm; res->distance =node_distance (dev_node, node); - n = head; -list_for_each_entry (tmp, head, list) { -if (res->distance < tmp->distance) { - n = &tmp->list; -break ; - } - } -list_add_tail (&res->list, n); + +if (qm->qp_in_used == qm->qp_num) +qm_insert_sorted (&full_list, res); +else +qm_insert_sorted (&non_full_list, res); } +list_splice_tail (&non_full_list, head); +list_splice_tail (&full_list, head); +return 0 ; }
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 9/11 crypto: hisilicon/zip - support fallback for zip
In reply to Chenghai HuangWhen the hardware queue resource busy(no shareable queue) or memery alloc fail in initialization of acomp_alg, use soft algorithm to complete the work.
--- drivers/crypto/hisilicon/Kconfig | 1 + drivers/crypto/hisilicon/zip/zip_crypto.c | 50 +++++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-)
drivers/crypto/hisilicon/Kconfig +1 -0
@@ -57,6 +57,7 @@ config CRYPTO_DEV_HISI_ZIP depends on UACCE || UACCE=n depends on ACPI select CRYPTO_DEV_HISI_QM + select CRYPTO_DEFLATE help Support for HiSilicon ZIP Driver
drivers/crypto/hisilicon/zip/zip_crypto.c +42 -8
104 lines not on this page · raw message
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 10/11 crypto: hisilicon/hpre - support the hpre algorithm fallback
In reply to Chenghai HuangFrom: Weili Qian <[email protected]>
When all hardware queues are busy and no shareable queue, new processes fail to apply for queues. To avoid affecting tasks, support fallback mechanism when hardware queues are unavailable.
HPRE driver supports DH algorithm, limited to prime numbers up to 4K. It supports prime numbers larger than 4K via fallback mechanism.
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 238 ++++++++++++++++---- 1 file changed, 199 insertions(+), 39 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +199 -39
@@ -93,6 +93,7 @@ struct hpre_dh_ctx {char *g;/* m */ dma_addr_t dma_g; +struct crypto_kpp *soft_tfm; };struct hpre_ecdh_ctx {
@@ -103,6 +104,7 @@ struct hpre_ecdh_ctx {/* low address: x->y */ unsigned char *g;dma_addr_t dma_g; +struct crypto_kpp *soft_tfm; };struct hpre_ctx {
@@ -120,6 +122,7 @@ struct hpre_ctx {unsigned int curve_id;/* for high performance core */ u8 enable_hpcore; +bool fallback; };struct hpre_asym_request {
@@ -382,8 +385,10 @@ static int hpre_ctx_init(struct hpre_ctx *ctx, u8 type)struct hpre *hpre; qp =hpre_create_qp (type); -if (!qp) +if (!qp) { + ctx->qp =NULL ;return -ENODEV ; + } qp->req_cb = hpre_alg_cb; ctx->qp = qp;
@@ -509,6 +514,48 @@ static int hpre_dh_compute_value(struct kpp_request *req)return ret; } +static struct kpp_request *hpre_dh_prepare_fb_req (struct kpp_request *req) +{ +struct kpp_request *fb_req =kpp_request_ctx (req); +struct crypto_kpp *tfm =crypto_kpp_reqtfm (req); +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); + +kpp_request_set_tfm (fb_req, ctx->dh.soft_tfm); +kpp_request_set_callback (fb_req, req->base.flags, req->base.complete, req->base.data); +kpp_request_set_input (fb_req, req->src, req->src_len); +kpp_request_set_output (fb_req, req->dst, req->dst_len); + +return fb_req; +} + +static int hpre_dh_generate_public_key (struct kpp_request *req) +{ +struct crypto_kpp *tfm =crypto_kpp_reqtfm (req); +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +struct kpp_request *fb_req; + +if (ctx->fallback) { + fb_req =hpre_dh_prepare_fb_req (req); +return crypto_kpp_generate_public_key (fb_req); + } + +return hpre_dh_compute_value (req); +} + +static int hpre_dh_compute_shared_secret (struct kpp_request *req) +{ +struct crypto_kpp *tfm =crypto_kpp_reqtfm (req); +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +struct kpp_request *fb_req; + +if (ctx->fallback) { + fb_req =hpre_dh_prepare_fb_req (req); +return crypto_kpp_compute_shared_secret (fb_req); + } + +return hpre_dh_compute_value (req); +} +static int hpre_is_dh_params_length_valid (unsigned int key_sz) {#define _HPRE_DH_GRP1 768
@@ -535,13 +582,6 @@ static int hpre_dh_set_params(struct hpre_ctx *ctx, struct dh *params)struct device *dev = ctx->dev;unsigned int sz; -if (params->p_size >HPRE_DH_MAX_P_SZ ) -return -EINVAL ; - -if (hpre_is_dh_params_length_valid (params->p_size << -HPRE_BITS_2_BYTES_SHIFT )) -return -EINVAL ; - sz = ctx->key_sz = params->p_size; ctx->dh.xa_p =dma_alloc_coherent (dev, sz <<1 , &ctx->dh.dma_xa_p,GFP_KERNEL );
@@ -574,6 +614,9 @@ static void hpre_dh_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)struct device *dev = ctx->dev;unsigned int sz = ctx->key_sz; +if (!ctx->qp) +return ; +if (ctx->dh.g) {dma_free_coherent (dev, sz, ctx->dh.g, ctx->dh.dma_g); ctx->dh.g =NULL ;
@@ -599,6 +642,13 @@ static int hpre_dh_set_secret(struct crypto_kpp *tfm, const void *buf,if (crypto_dh_decode_key (buf, len, ¶ms) <0 )return -EINVAL ; +if (!ctx->qp) + goto set_soft_secret; + +if (hpre_is_dh_params_length_valid (params.p_size << +HPRE_BITS_2_BYTES_SHIFT )) + goto set_soft_secret; +/* Free old secret if any */ hpre_dh_clear_ctx (ctx, false);
@@ -609,27 +659,55 @@ static int hpre_dh_set_secret(struct crypto_kpp *tfm, const void *buf,memcpy (ctx->dh.xa_p + (ctx->key_sz - params.key_size), params.key, params.key_size); + ctx->fallback = false;return 0 ; err_clear_ctx:hpre_dh_clear_ctx (ctx, false);return ret; +set_soft_secret: + ctx->fallback = true; +return crypto_kpp_set_secret (ctx->dh.soft_tfm, buf, len); }static unsigned int hpre_dh_max_size (struct crypto_kpp *tfm) {struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +if (ctx->fallback) +return crypto_kpp_maxsize (ctx->dh.soft_tfm); +return ctx->key_sz; }static int hpre_dh_init_tfm (struct crypto_kpp *tfm) {struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +const char *alg =kpp_alg_name (tfm); +unsigned int reqsize; +int ret; + + ctx->dh.soft_tfm =crypto_alloc_kpp (alg,0 ,CRYPTO_ALG_NEED_FALLBACK ); +if (IS_ERR (ctx->dh.soft_tfm)) { +pr_err ("Failed to alloc dh tfm!\n" ); +return PTR_ERR (ctx->dh.soft_tfm); + } + +crypto_kpp_set_flags (ctx->dh.soft_tfm,crypto_kpp_get_flags (tfm)); + + reqsize =max (sizeof (struct hpre_asym_request ) +hpre_align_pd (), +sizeof (struct kpp_request ) +crypto_kpp_reqsize (ctx->dh.soft_tfm)); +kpp_set_reqsize (tfm, reqsize); -kpp_set_reqsize (tfm,sizeof (struct hpre_asym_request ) +hpre_align_pd ()); + ret =hpre_ctx_init (ctx,HPRE_V2_ALG_TYPE ); +if (ret && ret != -ENODEV ) { +crypto_free_kpp (ctx->dh.soft_tfm); +return ret; + }else if (ret == -ENODEV ) { + ctx->fallback = true; + } -return hpre_ctx_init (ctx,HPRE_V2_ALG_TYPE ); +return 0 ; }static void hpre_dh_exit_tfm (struct crypto_kpp *tfm)
@@ -637,6 +715,7 @@ static void hpre_dh_exit_tfm(struct crypto_kpp *tfm)struct hpre_ctx *ctx =kpp_tfm_ctx (tfm);hpre_dh_clear_ctx (ctx, true); +crypto_free_kpp (ctx->dh.soft_tfm); }static void hpre_rsa_drop_leading_zeros (const char **ptr,size_t *len)
@@ -676,9 +755,8 @@ static int hpre_rsa_enc(struct akcipher_request *req)struct hpre_sqe *msg = &hpre_req->req;int ret; -/* For 512 and 1536 bits key size, use soft tfm instead */ -if (ctx->key_sz ==HPRE_RSA_512BITS_KSZ || - ctx->key_sz ==HPRE_RSA_1536BITS_KSZ ) { +/* For unsupported key size and unavailable devices, use soft tfm instead */ +if (ctx->fallback) {akcipher_request_set_tfm (req, ctx->rsa.soft_tfm); ret =crypto_akcipher_encrypt (req);akcipher_request_set_tfm (req, tfm);
@@ -723,9 +801,8 @@ static int hpre_rsa_dec(struct akcipher_request *req)struct hpre_sqe *msg = &hpre_req->req;int ret; -/* For 512 and 1536 bits key size, use soft tfm instead */ -if (ctx->key_sz ==HPRE_RSA_512BITS_KSZ || - ctx->key_sz ==HPRE_RSA_1536BITS_KSZ ) { +/* For unsupported key size and unavailable devices, use soft tfm instead */ +if (ctx->fallback) {akcipher_request_set_tfm (req, ctx->rsa.soft_tfm); ret =crypto_akcipher_decrypt (req);akcipher_request_set_tfm (req, tfm);
@@ -778,8 +855,10 @@ static int hpre_rsa_set_n(struct hpre_ctx *ctx, const char *value, ctx->key_sz = vlen;/* if invalid key size provided, we use software tfm */ -if (!hpre_rsa_key_size_is_support (ctx->key_sz)) +if (!hpre_rsa_key_size_is_support (ctx->key_sz)) { + ctx->fallback = true;return 0 ; + } ctx->rsa.pubkey = dma_alloc_coherent(ctx->dev, vlen << 1, &ctx->rsa.dma_pubkey,
@@ -914,6 +993,9 @@ static void hpre_rsa_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)unsigned int half_key_sz = ctx->key_sz >>1 ;struct device *dev = ctx->dev; +if (!ctx->qp) +return ; +if (ctx->rsa.pubkey) {dma_free_coherent (dev, ctx->key_sz <<1 , ctx->rsa.pubkey, ctx->rsa.dma_pubkey);
@@ -993,6 +1075,7 @@ static int hpre_rsa_setkey(struct hpre_ctx *ctx, const void *key, goto free; } + ctx->fallback = false;return 0 ; free:
@@ -1010,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key,if (ret)return ret; +if (!ctx->qp) +return 0 ; +return hpre_rsa_setkey (ctx, key, keylen, false); }
@@ -1023,6 +1109,9 @@ static int hpre_rsa_setprivkey(struct crypto_akcipher *tfm, const void *key,if (ret)return ret; +if (!ctx->qp) +return 0 ; +return hpre_rsa_setkey (ctx, key, keylen, true); }
@@ -1030,9 +1119,8 @@ static unsigned int hpre_rsa_max_size(struct crypto_akcipher *tfm) {struct hpre_ctx *ctx =akcipher_tfm_ctx (tfm); -/* For 512 and 1536 bits key size, use soft tfm instead */ -if (ctx->key_sz ==HPRE_RSA_512BITS_KSZ || - ctx->key_sz ==HPRE_RSA_1536BITS_KSZ ) +/* For unsupported key size and unavailable devices, use soft tfm instead */ +if (ctx->fallback)return crypto_akcipher_maxsize (ctx->rsa.soft_tfm);return ctx->key_sz;
@@ -1053,10 +1141,14 @@ static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm) hpre_align_pd()); ret =hpre_ctx_init (ctx,HPRE_V2_ALG_TYPE ); -if (ret) +if (ret && ret != -ENODEV ) {crypto_free_akcipher (ctx->rsa.soft_tfm); +return ret; + }else if (ret == -ENODEV ) { + ctx->fallback = true; + } -return ret; +return 0 ; }static void hpre_rsa_exit_tfm (struct crypto_akcipher *tfm)
@@ -1260,6 +1352,9 @@ static int hpre_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,struct ecdh params;int ret; +if (ctx->fallback) +return crypto_kpp_set_secret (ctx->ecdh.soft_tfm, buf, len); +if (crypto_ecdh_decode_key (buf, len, ¶ms) <0 ) {dev_err (dev,"failed to decode ecdh key!\n" );return -EINVAL ;
@@ -1485,23 +1580,82 @@ static int hpre_ecdh_compute_value(struct kpp_request *req)return ret; } +static int hpre_ecdh_generate_public_key (struct kpp_request *req) +{ +struct crypto_kpp *tfm =crypto_kpp_reqtfm (req); +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +int ret; + +if (ctx->fallback) { +kpp_request_set_tfm (req, ctx->ecdh.soft_tfm); + ret =crypto_kpp_generate_public_key (req); +kpp_request_set_tfm (req, tfm); +return ret; + } + +return hpre_ecdh_compute_value (req); +} + +static int hpre_ecdh_compute_shared_secret (struct kpp_request *req) +{ +struct crypto_kpp *tfm =crypto_kpp_reqtfm (req); +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +int ret; + +if (ctx->fallback) { +kpp_request_set_tfm (req, ctx->ecdh.soft_tfm); + ret =crypto_kpp_compute_shared_secret (req); +kpp_request_set_tfm (req, tfm); +return ret; + } + +return hpre_ecdh_compute_value (req); +} +static unsigned int hpre_ecdh_max_size (struct crypto_kpp *tfm) {struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +if (ctx->fallback) +return crypto_kpp_maxsize (ctx->ecdh.soft_tfm); +/* max size is the pub_key_size, include x and y */ return ctx->key_sz <<1 ; } +static int hpre_ecdh_init_tfm (struct crypto_kpp *tfm) +{ +struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +const char *alg =kpp_alg_name (tfm); +int ret; + + ret =hpre_ctx_init (ctx,HPRE_V3_ECC_ALG_TYPE ); +if (!ret) { +kpp_set_reqsize (tfm,sizeof (struct hpre_asym_request ) +hpre_align_pd ()); +return 0 ; + }else if (ret && ret != -ENODEV ) { +return ret; + } + + ctx->ecdh.soft_tfm =crypto_alloc_kpp (alg,0 ,CRYPTO_ALG_NEED_FALLBACK ); +if (IS_ERR (ctx->ecdh.soft_tfm)) { +pr_err ("Failed to alloc %s tfm!\n" , alg); +return PTR_ERR (ctx->ecdh.soft_tfm); + } + +crypto_kpp_set_flags (ctx->ecdh.soft_tfm,crypto_kpp_get_flags (tfm)); + ctx->fallback = true; + +return 0 ; +} +static int hpre_ecdh_nist_p192_init_tfm (struct crypto_kpp *tfm) {struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); ctx->curve_id =ECC_CURVE_NIST_P192 ; -kpp_set_reqsize (tfm,sizeof (struct hpre_asym_request ) +hpre_align_pd ()); - -return hpre_ctx_init (ctx,HPRE_V3_ECC_ALG_TYPE ); +return hpre_ecdh_init_tfm (tfm); }static int hpre_ecdh_nist_p256_init_tfm (struct crypto_kpp *tfm)
@@ -1511,9 +1665,7 @@ static int hpre_ecdh_nist_p256_init_tfm(struct crypto_kpp *tfm) ctx->curve_id =ECC_CURVE_NIST_P256 ; ctx->enable_hpcore =1 ; -kpp_set_reqsize (tfm,sizeof (struct hpre_asym_request ) +hpre_align_pd ()); - -return hpre_ctx_init (ctx,HPRE_V3_ECC_ALG_TYPE ); +return hpre_ecdh_init_tfm (tfm); }static int hpre_ecdh_nist_p384_init_tfm (struct crypto_kpp *tfm)
@@ -1522,15 +1674,18 @@ static int hpre_ecdh_nist_p384_init_tfm(struct crypto_kpp *tfm) ctx->curve_id =ECC_CURVE_NIST_P384 ; -kpp_set_reqsize (tfm,sizeof (struct hpre_asym_request ) +hpre_align_pd ()); - -return hpre_ctx_init (ctx,HPRE_V3_ECC_ALG_TYPE ); +return hpre_ecdh_init_tfm (tfm); }static void hpre_ecdh_exit_tfm (struct crypto_kpp *tfm) {struct hpre_ctx *ctx =kpp_tfm_ctx (tfm); +if (ctx->fallback) { +crypto_free_kpp (ctx->ecdh.soft_tfm); +return ; + } +hpre_ecc_clear_ctx (ctx, true); }
@@ -1548,13 +1703,14 @@ static struct akcipher_alg rsa = { .cra_name = "rsa", .cra_driver_name = "hpre-rsa", .cra_module = THIS_MODULE, + .cra_flags = CRYPTO_ALG_NEED_FALLBACK, }, };static struct kpp_alg dh = { .set_secret = hpre_dh_set_secret, - .generate_public_key = hpre_dh_compute_value, - .compute_shared_secret = hpre_dh_compute_value, + .generate_public_key = hpre_dh_generate_public_key, + .compute_shared_secret = hpre_dh_compute_shared_secret, .max_size = hpre_dh_max_size, .init = hpre_dh_init_tfm, .exit = hpre_dh_exit_tfm,
@@ -1564,14 +1720,15 @@ static struct kpp_alg dh = { .cra_name = "dh", .cra_driver_name = "hpre-dh", .cra_module = THIS_MODULE, + .cra_flags = CRYPTO_ALG_NEED_FALLBACK, }, };static struct kpp_alg ecdh_curves[] = { { .set_secret = hpre_ecdh_set_secret, - .generate_public_key = hpre_ecdh_compute_value, - .compute_shared_secret = hpre_ecdh_compute_value, + .generate_public_key = hpre_ecdh_generate_public_key, + .compute_shared_secret = hpre_ecdh_compute_shared_secret, .max_size = hpre_ecdh_max_size, .init = hpre_ecdh_nist_p192_init_tfm, .exit = hpre_ecdh_exit_tfm,
@@ -1581,11 +1738,12 @@ static struct kpp_alg ecdh_curves[] = { .cra_name = "ecdh-nist-p192", .cra_driver_name = "hpre-ecdh-nist-p192", .cra_module = THIS_MODULE, + .cra_flags = CRYPTO_ALG_NEED_FALLBACK, }, }, { .set_secret = hpre_ecdh_set_secret, - .generate_public_key = hpre_ecdh_compute_value, - .compute_shared_secret = hpre_ecdh_compute_value, + .generate_public_key = hpre_ecdh_generate_public_key, + .compute_shared_secret = hpre_ecdh_compute_shared_secret, .max_size = hpre_ecdh_max_size, .init = hpre_ecdh_nist_p256_init_tfm, .exit = hpre_ecdh_exit_tfm,
@@ -1595,11 +1753,12 @@ static struct kpp_alg ecdh_curves[] = { .cra_name = "ecdh-nist-p256", .cra_driver_name = "hpre-ecdh-nist-p256", .cra_module = THIS_MODULE, + .cra_flags = CRYPTO_ALG_NEED_FALLBACK, }, }, { .set_secret = hpre_ecdh_set_secret, - .generate_public_key = hpre_ecdh_compute_value, - .compute_shared_secret = hpre_ecdh_compute_value, + .generate_public_key = hpre_ecdh_generate_public_key, + .compute_shared_secret = hpre_ecdh_compute_shared_secret, .max_size = hpre_ecdh_max_size, .init = hpre_ecdh_nist_p384_init_tfm, .exit = hpre_ecdh_exit_tfm,
@@ -1609,6 +1768,7 @@ static struct kpp_alg ecdh_curves[] = { .cra_name = "ecdh-nist-p384", .cra_driver_name = "hpre-ecdh-nist-p384", .cra_module = THIS_MODULE, + .cra_flags = CRYPTO_ALG_NEED_FALLBACK, }, } };
Signature · 1 line
2.33.0
Chenghai Huang
maintainerPATCH v4 11/11 crypto: hisilicon/sec2 - support skcipher/aead fallback for hardware queue unavailable
In reply to Chenghai HuangFrom: Qi Tao <[email protected]>
When all hardware queues are busy and no shareable queue, new processes fail to apply for queues. To avoid affecting tasks, support fallback mechanism when hardware queues are unavailable.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 62 ++++++++++++++++------ 1 file changed, 47 insertions(+), 15 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +47 -15
@@ -663,10 +663,8 @@ static int sec_ctx_base_init(struct sec_ctx *ctx)int i, ret; ctx->qps =sec_create_qps (); -if (!ctx->qps) { -pr_err ("Can not create sec qps!\n" ); +if (!ctx->qps)return -ENODEV ; - } sec = container_of(ctx->qps[0]->qm, struct sec_dev, qm); ctx->sec = sec;
@@ -702,6 +700,9 @@ static void sec_ctx_base_uninit(struct sec_ctx *ctx) {int i; +if (!ctx->qps) +return ; +for (i =0 ; i < ctx->sec->ctx_q_num; i++)sec_release_qp_ctx (ctx, &ctx->qp_ctx[i]);
@@ -713,6 +714,9 @@ static int sec_cipher_init(struct sec_ctx *ctx) {struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; +if (!ctx->qps) +return 0 ; + c_ctx->c_key =dma_alloc_coherent (ctx->dev,SEC_MAX_KEY_SIZE , &c_ctx->c_key_dma,GFP_KERNEL );if (!c_ctx->c_key)
@@ -725,6 +729,9 @@ static void sec_cipher_uninit(struct sec_ctx *ctx) {struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; +if (!ctx->qps) +return ; +memzero_explicit (c_ctx->c_key,SEC_MAX_KEY_SIZE );dma_free_coherent (ctx->dev,SEC_MAX_KEY_SIZE , c_ctx->c_key, c_ctx->c_key_dma);
@@ -746,6 +753,9 @@ static void sec_auth_uninit(struct sec_ctx *ctx) {struct sec_auth_ctx *a_ctx = &ctx->a_ctx; +if (!ctx->qps) +return ; +memzero_explicit (a_ctx->a_key,SEC_MAX_AKEY_SIZE );dma_free_coherent (ctx->dev,SEC_MAX_AKEY_SIZE , a_ctx->a_key, a_ctx->a_key_dma);
@@ -783,7 +793,7 @@ static int sec_skcipher_init(struct crypto_skcipher *tfm) } ret =sec_ctx_base_init (ctx); -if (ret) +if (ret && ret != -ENODEV )return ret; ret =sec_cipher_init (ctx);
@@ -892,6 +902,9 @@ static int sec_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,struct device *dev = ctx->dev;int ret; +if (!ctx->qps) + goto set_soft_key; +if (c_mode ==SEC_CMODE_XTS ) { ret =xts_verify_key (tfm, key, keylen);if (ret) {
@@ -922,13 +935,14 @@ static int sec_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, }memcpy (c_ctx->c_key, key, keylen); -if (c_ctx->fbtfm) { - ret =crypto_sync_skcipher_setkey (c_ctx->fbtfm, key, keylen); -if (ret) { -dev_err (dev,"failed to set fallback skcipher key!\n" ); -return ret; - } + +set_soft_key: + ret =crypto_sync_skcipher_setkey (c_ctx->fbtfm, key, keylen); +if (ret) { +dev_err (dev,"failed to set fallback skcipher key!\n" ); +return ret; } +return 0 ; }
@@ -1392,6 +1406,9 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,struct crypto_authenc_keys keys;int ret; +if (!ctx->qps) +return sec_aead_fallback_setkey (a_ctx, tfm, key, keylen); + ctx->a_ctx.a_alg = a_alg; ctx->c_ctx.c_alg = c_alg; c_ctx->c_mode = c_mode;
@@ -2048,6 +2065,9 @@ static int sec_skcipher_ctx_init(struct crypto_skcipher *tfm)if (ret)return ret; +if (!ctx->qps) +return 0 ; +if (ctx->sec->qm.ver <QM_HW_V3 ) { ctx->type_supported =SEC_BD_TYPE2 ; ctx->req_op = &sec_skcipher_req_ops;
@@ -2056,7 +2076,7 @@ static int sec_skcipher_ctx_init(struct crypto_skcipher *tfm) ctx->req_op = &sec_skcipher_req_ops_v3; } -return ret; +return 0 ; }static void sec_skcipher_ctx_exit (struct crypto_skcipher *tfm)
@@ -2124,7 +2144,7 @@ static int sec_aead_ctx_init(struct crypto_aead *tfm, const char *hash_name)int ret; ret =sec_aead_init (tfm); -if (ret) { +if (ret && ret != -ENODEV ) {pr_err ("hisi_sec2: aead init error!\n" );return ret; }
@@ -2166,7 +2186,7 @@ static int sec_aead_xcm_ctx_init(struct crypto_aead *tfm)int ret; ret =sec_aead_init (tfm); -if (ret) { +if (ret && ret != -ENODEV ) {dev_err (ctx->dev,"hisi_sec2: aead xcm init error!\n" );return ret; }
@@ -2311,6 +2331,9 @@ static int sec_skcipher_crypto(struct skcipher_request *sk_req, bool encrypt)bool need_fallback = false;int ret; +if (!ctx->qps) + goto soft_crypto; +if (!sk_req->cryptlen) {if (ctx->c_ctx.c_mode ==SEC_CMODE_XTS )return -EINVAL ;
@@ -2328,9 +2351,12 @@ static int sec_skcipher_crypto(struct skcipher_request *sk_req, bool encrypt)return -EINVAL ;if (unlikely (ctx->c_ctx.fallback || need_fallback)) -return sec_skcipher_soft_crypto (ctx, sk_req, encrypt); + goto soft_crypto;return ctx->req_op->process (ctx, req); + +soft_crypto: +return sec_skcipher_soft_crypto (ctx, sk_req, encrypt); }static int sec_skcipher_encrypt (struct skcipher_request *sk_req)
@@ -2538,6 +2564,9 @@ static int sec_aead_crypto(struct aead_request *a_req, bool encrypt)bool need_fallback = false;int ret; +if (!ctx->qps) + goto soft_crypto; + req->flag = a_req->base.flags; req->aead_req.aead_req = a_req; req->c_req.encrypt = encrypt;
@@ -2548,11 +2577,14 @@ static int sec_aead_crypto(struct aead_request *a_req, bool encrypt) ret =sec_aead_param_check (ctx, req, &need_fallback);if (unlikely (ret)) {if (need_fallback) -return sec_aead_soft_crypto (ctx, a_req, encrypt); + goto soft_crypto;return -EINVAL ; }return ctx->req_op->process (ctx, req); + +soft_crypto: +return sec_aead_soft_crypto (ctx, a_req, encrypt); }static int sec_aead_encrypt (struct aead_request *a_req)
Signature · 1 line
2.33.0
Herbert Xu
maintainerQuoted 62 lines · Chenghai Huang
1.Supports multiple tfms sharing the same device queue to avoid tfm creation failure.
2.Support fallback for zip/sec2/hpre when queue allocation fails or when processing unsupported specifications.When
pf_q_numis less than the number of tfms, queues will be obtained from devices with fewer references and closer NUMAdistances(priority: ref counts -> NUMA distances).We can test by zswap:
modprobehisi_zipuacce_mode=1 pf_q_num=2
cat /sys/class/uacce/hisi_zip-?/available_instances echo hisi-deflate-acomp >/sys/module/zswap/parameters/compressor---
V3: https://lore.kernel.org/all/[email protected]/
Updates:
- In patch 7, fix the issue of skipping qp enablement due to incorrect reference count judgment.
- In patch 6, Supplement the device power wake-up operation before applying for the qp.V2: https://lore.kernel.org/all/[email protected]/
Updates:
- According to crypto framework, support shared queues to address
the hardware resource limitation on tfm.
- Remove the fallback modification for x25519.V1: https://lore.kernel.org/all/[email protected]/
Updates:
- Remove unnecessary callback completions.
- AddCRYPTO_ALG_NEED_FALLBACKto hisi_zip'scra_flags.---
Chenghai Huang (8):
crypto: hisilicon/zip - adjust the way to obtain the req in the
callback function
crypto: hisilicon/sec - move backlog management to qp and store sqe in
qp for callback
crypto: hisilicon/qm - enhance the configuration ofreq_typein queue
attributes
crypto: hisilicon/qm - centralize the sending locks of each module
into qm
crypto: hisilicon - consolidate qp creation and start in
hisi_qm_alloc_qps_node
crypto: hisilicon/qm - add reference counting to queues for tfm kernel
reuse
crypto: hisilicon/qm - optimize device selection priority based on
queue ref count and NUMA distance
crypto: hisilicon/zip - support fallback for zipQi Tao (1):
crypto: hisilicon/sec2 - support skcipher/aead fallback for hardware
queue unavailableWeili Qian (1):
crypto: hisilicon/hpre - support the hpre algorithm fallbacklizhi (1):
crypto: hisilicon/hpre: extend tag field to 64 bits for better
performance
Quoted 16 lines
drivers/crypto/hisilicon/Kconfig | 1 + drivers/crypto/hisilicon/hpre/hpre.h | 5 +- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 416 +++++++++++--------- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- drivers/crypto/hisilicon/qm.c | 206 +++++++--- drivers/crypto/hisilicon/sec2/sec.h | 7 - drivers/crypto/hisilicon/sec2/sec_crypto.c | 159 ++++---- drivers/crypto/hisilicon/sec2/sec_main.c | 21 +- drivers/crypto/hisilicon/zip/zip.h | 2 +- drivers/crypto/hisilicon/zip/zip_crypto.c | 133 ++++--- drivers/crypto/hisilicon/zip/zip_main.c | 4 +- include/linux/hisi_acc_qm.h | 14 +- 12 files changed, 574 insertions(+), 396 deletions(-)Signature · 1 line
2.33.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt