From 1903e366f228ac6ee9dfb826b75b9d698bb180d8 Mon Sep 17 00:00:00 2001
From: Kai Ye <yekai13@huawei.com>
Date: Wed, 22 Dec 2021 14:38:03 +0800
Subject: [PATCH 07/28] qm/v1: fixup the incorrect configuration of the type

1. SEC should setting the sqc type is 0. it doesn't depend on
encryption or decryption direction.
2. Modify the HPRE sqc type configuration.

Signed-off-by: Kai Ye <yekai13@huawei.com>
---
 v1/drv/hisi_qm_udrv.c | 5 +++++
 v1/wd.h               | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/v1/drv/hisi_qm_udrv.c b/v1/drv/hisi_qm_udrv.c
index 7fb6599..02aaf81 100644
--- a/v1/drv/hisi_qm_udrv.c
+++ b/v1/drv/hisi_qm_udrv.c
@@ -277,16 +277,19 @@ static bool hpre_alg_info_init(struct wd_queue *q, const char *alg)
 	struct qm_queue_info *info = qinfo->priv;
 	bool is_found = true;
 
+	/* DH/RSA: qm sqc_type = 0, ECC: qm sqc_type = 1 */
 	if (!strcmp(alg, "rsa")) {
 		qinfo->atype = WCRYPTO_RSA;
 		info->sqe_size = QM_HPRE_BD_SIZE;
 		info->sqe_fill[WCRYPTO_RSA] = qm_fill_rsa_sqe;
 		info->sqe_parse[WCRYPTO_RSA] = qm_parse_rsa_sqe;
+		priv->direction = 0;
 	} else if (!strcmp(alg, "dh")) {
 		qinfo->atype = WCRYPTO_DH;
 		info->sqe_size = QM_HPRE_BD_SIZE;
 		info->sqe_fill[WCRYPTO_DH] = qm_fill_dh_sqe;
 		info->sqe_parse[WCRYPTO_DH] = qm_parse_dh_sqe;
+		priv->direction = 0;
 	} else if (!strcmp(alg, "ecdh")) {
 		qinfo->atype = WCRYPTO_ECDH;
 		info->sqe_size = QM_HPRE_BD_SIZE;
@@ -414,6 +417,8 @@ static int qm_set_queue_alg_info(struct wd_queue *q)
 	} else if (zip_alg_info_init(qinfo, alg)) {
 		ret = WD_SUCCESS;
 	} else if (sec_alg_info_init(qinfo, alg)) {
+		/* setting the type is 0 for sqc_type */
+		priv->direction = 0;
 		ret = WD_SUCCESS;
 	} else if (!strcmp(alg, "xts(aes)") ||
 		!strcmp(alg, "xts(sm4)")) {
diff --git a/v1/wd.h b/v1/wd.h
index 30fbf89..3dd69eb 100644
--- a/v1/wd.h
+++ b/v1/wd.h
@@ -73,7 +73,10 @@ struct wcrypto_cb_tag {
 };
 
 struct wcrypto_paras {
-	 /* 0--encipher/compress .etc, 1 ---decipher/decomp .etc */
+	/*
+	 * 0--encipher/compress .etc, 1 ---decipher/decomp .etc
+	 * it not been used for HiSilicon SEC currently.
+	 */
 	__u8 direction;
 	__u8 is_poll;
 
-- 
2.31.1

