From 32230f9e59438899c949a4bab178a8f10f17b903 Mon Sep 17 00:00:00 2001
From: jensen <jensenhuang@friendlyarm.com>
Date: Thu, 17 Nov 2022 18:35:43 +0800
Subject: [PATCH] ethernet: stmmac: Add property to disable VLAN hw filter

Since adding VLAN in promisc mode not supported, which makes unable to
setup bridge, add a configurable option to disable it.

Signed-off-by: jensen <jensenhuang@friendlyarm.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +++
 include/linux/stmmac.h                                | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

--- a/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-base.dtsi
@@ -1808,6 +1808,7 @@
 		snps,mixed-burst;
 		snps,mtl-rx-config = <&gmac1_mtl_rx_setup>;
 		snps,mtl-tx-config = <&gmac1_mtl_tx_setup>;
+		snps,no-vlhash;
 		snps,tso;
 		status = "disabled";
 
--- a/arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi
@@ -462,6 +462,7 @@
 		snps,mixed-burst;
 		snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
 		snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
+		snps,no-vlhash;
 		snps,tso;
 		status = "disabled";
 
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7707,7 +7707,7 @@ int stmmac_dvr_probe(struct device *devi
 		ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
 		priv->hw->hw_vlan_en = true;
 	}
-	if (priv->dma_cap.vlhash) {
+	if (priv->plat->vlhash_en && priv->dma_cap.vlhash) {
 		ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 		ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
 	}
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -596,6 +596,9 @@ stmmac_probe_config_dt(struct platform_d
 			 "force_sf_dma_mode is ignored if force_thresh_dma_mode is set.\n");
 	}
 
+	/* To disable VLAN tag filter */
+	plat->vlhash_en = !of_property_read_bool(np, "snps,no-vlhash");
+
 	of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed);
 
 	plat->axi = stmmac_axi_setup(pdev);
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -262,6 +262,7 @@ struct plat_stmmacenet_data {
 	int rss_en;
 	int mac_port_sel_speed;
 	int has_xgmac;
+	bool vlhash_en;
 	u8 vlan_fail_q;
 	unsigned int eee_usecs_rate;
 	struct pci_dev *pdev;
