[][openwrt][mt7988][crypto][Fix 3 PPE issue for IPSec]

[Description]
Fix 3 PPE issue for IPSec. In previous version, we'll use CLS rule to
set fport = PPE0 for ESP packets. However, in 3 PPE situation, it expect
the packet from GDM1 fport should be PPE0, GDM2 should use PPE1, GDM3
should use PPE2.
In this commit, we add parsing dts for PPE numbers to decide which PPE
should be set to CLS rule.

[Release-log]
N/A


Change-Id: I02c0e0b94f7214964a56bf56fb1f30ef9f67bd8a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8713736
diff --git a/feed/kernel/crypto-eip/src/init.c b/feed/kernel/crypto-eip/src/init.c
index cc53a39..075ca69 100644
--- a/feed/kernel/crypto-eip/src/init.c
+++ b/feed/kernel/crypto-eip/src/init.c
@@ -64,6 +64,11 @@
 	return true;
 }
 
+u32 mtk_crypto_ppe_get_num(void)
+{
+	return mcrypto.ppe_num;
+}
+
 static const struct xfrmdev_ops mtk_xfrmdev_ops = {
 	.xdo_dev_state_add = mtk_xfrm_offload_state_add,
 	.xdo_dev_state_delete = mtk_xfrm_offload_state_delete,
@@ -151,6 +156,29 @@
 	return ret;
 }
 
+static int __init mtk_crypto_ppe_num_dts_init(struct platform_device *pdev)
+{
+	struct device_node *hnat = NULL;
+	u32 val = 0;
+	int ret = 0;
+
+	hnat = of_parse_phandle(pdev->dev.of_node, "hnat", 0);
+	if (!hnat) {
+		CRYPTO_ERR("can not find hnat node\n");
+		return -ENODEV;
+	}
+
+	ret = of_property_read_u32(hnat, "mtketh-ppe-num", &val);
+	if (ret)
+		mcrypto.ppe_num = 1;
+	else
+		mcrypto.ppe_num = val;
+
+	of_node_put(hnat);
+
+	return 0;
+}
+
 static int __init mtk_crypto_eip_dts_init(void)
 {
 	struct platform_device *crypto_pdev;
@@ -190,6 +218,10 @@
 	if (ret)
 		goto out;
 
+	ret = mtk_crypto_ppe_num_dts_init(crypto_pdev);
+	if (ret)
+		goto out;
+
 	crypto_dev = &crypto_pdev->dev;
 
 out: