2023-03-30 07:12:56

by Ng, Boon Khai

[permalink] [raw]
Subject: [PATCH v1 7/8] net: stmmac: Add Double VLAN handling for VLAN Rx filtering

Add double VLAN handling for VLAN Rx Filtering.

Signed-off-by: Boon Khai Ng <[email protected]>
---
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


2023-03-30 17:30:51

by Ng, Boon Khai

[permalink] [raw]
Subject: Please ignore this review, send out by accident.

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