[][kernel][common][hnat][Add API for WDMA to get tx/rx port in PSE]

[Description]
Add API for WDMA to get tx/rx port in PSE.

For tx port, WDMA 0/1/2 would get PSE port of PPE0.
For rx port, WDMA 0/1/2 would get PSE port of WDMA 0/1/2 respectively.

[Release-log]
N/A


Change-Id: I306c09270e68f548ecf072c841065fc0eabb99bf
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8634126
diff --git a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
index d85117f..a0c22b5 100644
--- a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
+++ b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
@@ -36,6 +36,11 @@
 void (*ra_sw_nat_clear_bind_entries)(void) = NULL;
 EXPORT_SYMBOL(ra_sw_nat_clear_bind_entries);
 
+int (*hnat_get_wdma_tx_port)(int wdma_idx) = NULL;
+EXPORT_SYMBOL(hnat_get_wdma_tx_port);
+int (*hnat_get_wdma_rx_port)(int wdma_idx) = NULL;
+EXPORT_SYMBOL(hnat_get_wdma_rx_port);
+
 int (*ppe_del_entry_by_mac)(unsigned char *mac) = NULL;
 EXPORT_SYMBOL(ppe_del_entry_by_mac);
 
@@ -136,6 +141,26 @@
 	}
 }
 
+static int mtk_get_wdma_tx_port(int wdma_idx)
+{
+	if (wdma_idx == 0 || wdma_idx == 1 || wdma_idx == 2)
+		return NR_PPE0_PORT;
+
+	return -EINVAL;
+}
+
+static int mtk_get_wdma_rx_port(int wdma_idx)
+{
+	if (wdma_idx == 2)
+		return NR_WDMA2_PORT;
+	else if (wdma_idx == 1)
+		return NR_WDMA1_PORT;
+	else if (wdma_idx == 0)
+		return NR_WDMA0_PORT;
+
+	return -EINVAL;
+}
+
 void set_gmac_ppe_fwd(int id, int enable)
 {
 	void __iomem *reg;
@@ -616,6 +641,8 @@
 		ppe_dev_register_hook = mtk_ppe_dev_register_hook;
 		ppe_dev_unregister_hook = mtk_ppe_dev_unregister_hook;
 		ra_sw_nat_clear_bind_entries = foe_clear_all_bind_entries;
+		hnat_get_wdma_tx_port = mtk_get_wdma_tx_port;
+		hnat_get_wdma_rx_port = mtk_get_wdma_rx_port;
 	}
 
 	if (hnat_register_nf_hooks())
@@ -635,6 +662,8 @@
 	ra_sw_nat_hook_tx = NULL;
 	ra_sw_nat_hook_rx = NULL;
 	ra_sw_nat_clear_bind_entries = NULL;
+	hnat_get_wdma_tx_port = NULL;
+	hnat_get_wdma_rx_port = NULL;
 	hnat_unregister_nf_hooks();
 
 	for (i = 0; i < CFG_PPE_NUM; i++) {