blob: 7eae63d8d264c9214676c875442a721c5c85bc11 [file] [log] [blame]
developer2df22aa2024-03-22 14:36:06 +08001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2023 MediaTek Inc.
4 *
5 * Author: Chris.Chou <chris.chou@mediatek.com>
6 * Ren-Ting Wang <ren-ting.wang@mediatek.com>
7 */
8
9#include <linux/bitops.h>
10#include <crypto/aes.h>
11#include <crypto/internal/skcipher.h>
12
13#include "crypto-eip/crypto-eip.h"
14#include "crypto-eip/ddk-wrapper.h"
15#include "crypto-eip/lookaside.h"
16#include "crypto-eip/internal.h"
17
18void mtk_crypto_dequeue(struct mtk_crypto_priv *priv)
19{
20 struct crypto_async_request *req;
21 struct crypto_async_request *backlog;
22 struct mtk_crypto_context *ctx;
23 int ret;
24
25 while (true) {
26 spin_lock_bh(&priv->mtk_eip_queue.queue_lock);
27 backlog = crypto_get_backlog(&priv->mtk_eip_queue.queue);
28 req = crypto_dequeue_request(&priv->mtk_eip_queue.queue);
29 spin_unlock_bh(&priv->mtk_eip_queue.queue_lock);
30
31 if (!req)
32 goto finalize;
33
34 ctx = crypto_tfm_ctx(req->tfm);
35 ret = ctx->send(req);
36 if (ret)
37 goto finalize;
38
39 if (backlog)
40 backlog->complete(backlog, -EINPROGRESS);
41 }
42
43finalize:
44 return;
45}
46
47void mtk_crypto_dequeue_work(struct work_struct *work)
48{
49 struct mtk_crypto_work_data *data =
50 container_of(work, struct mtk_crypto_work_data, work);
51 mtk_crypto_dequeue(data->priv);
52}