[][openwrt][mt7988][crypto][Add look-aside mode]

[Description]
Add look-aside mode. Similar to the upstream driver, register the
algorithm with the Linux crypto subsystem to provide encryption and
decryption algorithms for use by other modules.

The construction of transform records, command descriptors,
tokens, and packets is implemented through the APIs provided by the DDK.

All suportted algorithms can check src/init.c, there is a list for all
supported algo. However, the IPSec throught put is only 300 Mbps for
AES-CBC-HMAC-SHA1 while the upstream driver is 1000 Mbps. Still need to
enhance performance.

[Release-log]
N/A


Change-Id: I15d2550cb3190c47a79da82c8654dea6647bd101
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8838386
diff --git a/feed/kernel/crypto-eip/src/lookaside.c b/feed/kernel/crypto-eip/src/lookaside.c
new file mode 100644
index 0000000..7eae63d
--- /dev/null
+++ b/feed/kernel/crypto-eip/src/lookaside.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2023 MediaTek Inc.
+ *
+ * Author: Chris.Chou <chris.chou@mediatek.com>
+ *         Ren-Ting Wang <ren-ting.wang@mediatek.com>
+ */
+
+#include <linux/bitops.h>
+#include <crypto/aes.h>
+#include <crypto/internal/skcipher.h>
+
+#include "crypto-eip/crypto-eip.h"
+#include "crypto-eip/ddk-wrapper.h"
+#include "crypto-eip/lookaside.h"
+#include "crypto-eip/internal.h"
+
+void mtk_crypto_dequeue(struct mtk_crypto_priv *priv)
+{
+	struct crypto_async_request *req;
+	struct crypto_async_request *backlog;
+	struct mtk_crypto_context *ctx;
+	int ret;
+
+	while (true) {
+		spin_lock_bh(&priv->mtk_eip_queue.queue_lock);
+		backlog = crypto_get_backlog(&priv->mtk_eip_queue.queue);
+		req = crypto_dequeue_request(&priv->mtk_eip_queue.queue);
+		spin_unlock_bh(&priv->mtk_eip_queue.queue_lock);
+
+		if (!req)
+			goto finalize;
+
+		ctx = crypto_tfm_ctx(req->tfm);
+		ret = ctx->send(req);
+		if (ret)
+			goto finalize;
+
+		if (backlog)
+			backlog->complete(backlog, -EINPROGRESS);
+	}
+
+finalize:
+	return;
+}
+
+void mtk_crypto_dequeue_work(struct work_struct *work)
+{
+	struct mtk_crypto_work_data *data =
+			container_of(work, struct mtk_crypto_work_data, work);
+	mtk_crypto_dequeue(data->priv);
+}