mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 7/8] net: stmmac: Add Double VLAN handling for VLAN Rx filtering
@ 2023-03-30  7:04 Boon Khai Ng
  2023-03-30 17:25 ` Please ignore this review, send out by accident Boon Khai Ng
  0 siblings, 1 reply; 2+ messages in thread
From: Boon Khai Ng @ 2023-03-30  7:04 UTC (permalink / raw)
  To: David S . Miller; +Cc: linux-kernel, Mun Yew Tham, Tien Sung Ang, Boon Khai Ng

Add double VLAN handling for VLAN Rx Filtering.

Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h   |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h |  3 +++
 .../ethernet/stmicro/stmmac/dwxgmac2_core.c    | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index ec9c130276d8..ca2d4515dd0f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -535,6 +535,7 @@ struct mac_device_info {
 	unsigned int promisc;
 	bool vlan_fail_q_en;
 	u8 vlan_fail_q;
+	unsigned int double_vlan;
 };
 
 struct stmmac_rx_routing {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
index 3f11b2c52324..428f82905273 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
@@ -499,6 +499,9 @@
 #define XGMAC_VLAN_TAG_STRIP_ALL	(0x3 << XGMAC_VLAN_TAG_CTRL_EVLS_SHIFT)
 
 #define XGMAC_VLAN_TAG_DATA		0x00000054
+#define XGMAC_VLAN_TAG_DATA_ERIVLT	BIT(20)
+#define XGMAC_VLAN_TAG_DATA_ERSVLM	BIT(19)
+#define XGMAC_VLAN_TAG_DATA_DOVLTC	BIT(18)
 #define XGMAC_VLAN_TAG_DATA_ETV		BIT(17)
 #define XGMAC_VLAN_TAG_DATA_VEN		BIT(16)
 #define XGMAC_VLAN_TAG_DATA_VID		GENMASK(15, 0)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index 78bad5242562..4dff53dc771f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -438,6 +438,15 @@ static int dwxgmac2_write_vlan_filter(struct net_device *dev,
 	if (index >= hw->num_vlan)
 		return -EINVAL;
 
+	if (hw->double_vlan) {
+		data |= XGMAC_VLAN_TAG_DATA_DOVLTC;
+		data |= XGMAC_VLAN_TAG_DATA_ERIVLT;
+		data &= ~XGMAC_VLAN_TAG_DATA_ERSVLM;
+	} else {
+		data &= ~XGMAC_VLAN_TAG_DATA_DOVLTC;
+		data &= ~XGMAC_VLAN_TAG_DATA_ERIVLT;
+	}
+
 	writel(data, ioaddr + XGMAC_VLAN_TAG_DATA);
 
 	val = readl(ioaddr + XGMAC_VLAN_TAG);
@@ -1855,6 +1864,14 @@ static u32 dwxgmac2_get_num_vlan(void __iomem *ioaddr)
 	return num_vlan;
 }
 
+static u32 dwxgmac2_is_double_vlan(void __iomem *ioaddr)
+{
+	u32 val;
+
+	val = readl(ioaddr + XGMAC_HW_FEATURE3);
+	return (val & XGMAC_HWFEAT_DVLAN);
+}
+
 int dwxgmac2_setup(struct stmmac_priv *priv)
 {
 	struct mac_device_info *mac = priv->hw;
@@ -1889,6 +1906,7 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_shift = 19;
 	mac->mii.clk_csr_mask = GENMASK(21, 19);
 	mac->num_vlan = dwxgmac2_get_num_vlan(priv->ioaddr);
+	mac->double_vlan = dwxgmac2_is_double_vlan(priv->ioaddr);
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Please ignore this review, send out by accident.
  2023-03-30  7:04 [PATCH v1 7/8] net: stmmac: Add Double VLAN handling for VLAN Rx filtering Boon Khai Ng
@ 2023-03-30 17:25 ` Boon Khai Ng
  0 siblings, 0 replies; 2+ messages in thread
From: Boon Khai Ng @ 2023-03-30 17:25 UTC (permalink / raw)
  To: boon.khai.ng; +Cc: davem, linux-kernel, mun.yew.tham, tien.sung.ang

My appologies for sending out this review by accident, this is meant for internal reivew,
kindly ignore and close this thread. Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-30 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30  7:04 [PATCH v1 7/8] net: stmmac: Add Double VLAN handling for VLAN Rx filtering Boon Khai Ng
2023-03-30 17:25 ` Please ignore this review, send out by accident Boon Khai Ng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®