summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Semin <fancer.lancer@gmail.com>2026-08-11 12:37:51 +0300
committerSerge Semin <fancer.lancer@gmail.com>2026-08-13 20:34:37 +0300
commit930a50372b6d057ed30ffd622e4f16c94aa21e74 (patch)
tree3bfd6b66748d81045da34cbb3349685593777164
parenta69d2bad1218cae53e09c671a610c7d6c719b61a (diff)
downloadlinux-930a50372b6d057ed30ffd622e4f16c94aa21e74.tar.gz
linux-930a50372b6d057ed30ffd622e4f16c94aa21e74.zip
net: stmmac: vlan: Use single ops desc for GMAC4 and XGMAC
The dwxgmac2_update_vlan_hash() method now completely match to vlan_update_hash(). In the meantime the rest of the callbacks utilized in dwmac_vlan_ops and dwxgmac210_vlan_ops are the same. Thus drop the dwxgmac210_vlan_ops descriptor and use now common dwmac_vlan_ops descriptor instead. Rename it to dwmac4_vlan_ops so not to be accidentally utilized for the older IP-cores which have a bit different VLAN engine and isn't compatible with current VLAN implementation in the driver. Note the current VLAN module can be fully utilized for DW XLGMAC IP-cores too. But leave it be as is for the engineers with the compatible hardware at hand. Don't bother with that right now. Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/hwif.c10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c66
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h3
3 files changed, 8 insertions, 71 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index fa8b0bf5bdad..c8025504e5af 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -158,7 +158,7 @@ static const struct stmmac_hwif_entry {
.desc = &dwmac4_desc_ops,
.dma = &dwmac4_dma_ops,
.mac = &dwmac4_ops,
- .vlan = &dwmac_vlan_ops,
+ .vlan = &dwmac4_vlan_ops,
.hwtimestamp = &stmmac_ptp,
.ptp = &stmmac_ptp_clock_ops,
.tc = &dwmac4_tc_ops,
@@ -177,7 +177,7 @@ static const struct stmmac_hwif_entry {
.desc = &dwmac4_desc_ops,
.dma = &dwmac4_dma_ops,
.mac = &dwmac410_ops,
- .vlan = &dwmac_vlan_ops,
+ .vlan = &dwmac4_vlan_ops,
.hwtimestamp = &stmmac_ptp,
.ptp = &stmmac_ptp_clock_ops,
.tc = &dwmac510_tc_ops,
@@ -197,7 +197,7 @@ static const struct stmmac_hwif_entry {
.desc = &dwmac4_desc_ops,
.dma = &dwmac410_dma_ops,
.mac = &dwmac410_ops,
- .vlan = &dwmac_vlan_ops,
+ .vlan = &dwmac4_vlan_ops,
.hwtimestamp = &stmmac_ptp,
.ptp = &stmmac_ptp_clock_ops,
.tc = &dwmac510_tc_ops,
@@ -217,7 +217,7 @@ static const struct stmmac_hwif_entry {
.desc = &dwmac4_desc_ops,
.dma = &dwmac410_dma_ops,
.mac = &dwmac510_ops,
- .vlan = &dwmac_vlan_ops,
+ .vlan = &dwmac4_vlan_ops,
.hwtimestamp = &stmmac_ptp,
.ptp = &stmmac_ptp_clock_ops,
.tc = &dwmac510_tc_ops,
@@ -238,7 +238,7 @@ static const struct stmmac_hwif_entry {
.desc = &dwxgmac210_desc_ops,
.dma = &dwxgmac210_dma_ops,
.mac = &dwxgmac210_ops,
- .vlan = &dwxgmac210_vlan_ops,
+ .vlan = &dwmac4_vlan_ops,
.hwtimestamp = &stmmac_ptp,
.ptp = &stmmac_ptp_clock_ops,
.tc = &dwmac510_tc_ops,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
index c553cf6b772e..2dcdbf78dd44 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
@@ -283,59 +283,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw)
writel(value, ioaddr + VLAN_TAG);
}
-static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
- u16 perfect_match, bool is_double)
-{
- void __iomem *ioaddr = hw->pcsr;
- u32 value;
-
- writel(hash, ioaddr + VLAN_HASH_TABLE);
-
- value = readl(ioaddr + VLAN_TAG);
-
- if (hash) {
- value |= VLAN_VTHM | VLAN_ETV;
- if (is_double) {
- value |= VLAN_EDVLP;
- value |= VLAN_ESVL;
- value |= VLAN_DOVLTC;
- } else {
- value &= ~VLAN_EDVLP;
- value &= ~VLAN_ESVL;
- value &= ~VLAN_DOVLTC;
- }
-
- if (!hw->vlan_filter[0])
- value |= VLAN_VID;
-
- writel(value, ioaddr + VLAN_TAG);
- } else if (perfect_match) {
- value &= ~VLAN_VTHM;
- value |= VLAN_ETV;
- if (is_double) {
- value |= VLAN_EDVLP;
- value |= VLAN_ESVL;
- value |= VLAN_DOVLTC;
- } else {
- value &= ~VLAN_EDVLP;
- value &= ~VLAN_ESVL;
- value &= ~VLAN_DOVLTC;
- }
-
- value &= ~VLAN_VID;
- writel(value | perfect_match, ioaddr + VLAN_TAG);
- } else {
- value &= ~(VLAN_VTHM | VLAN_ETV);
- value &= ~(VLAN_EDVLP | VLAN_ESVL);
- value &= ~VLAN_DOVLTC;
- if (!hw->vlan_filter[0])
- value |= VLAN_VID;
-
- writel(value, ioaddr + VLAN_TAG);
- }
-}
-
-const struct stmmac_vlan_ops dwmac_vlan_ops = {
+const struct stmmac_vlan_ops dwmac4_vlan_ops = {
.update_vlan_hash = vlan_update_hash,
.enable_vlan = vlan_enable,
.add_hw_vlan_rx_fltr = vlan_add_hw_rx_fltr,
@@ -346,18 +294,8 @@ const struct stmmac_vlan_ops dwmac_vlan_ops = {
};
const struct stmmac_vlan_ops dwxlgmac2_vlan_ops = {
- .update_vlan_hash = dwxgmac2_update_vlan_hash,
- .enable_vlan = vlan_enable,
-};
-
-const struct stmmac_vlan_ops dwxgmac210_vlan_ops = {
- .update_vlan_hash = dwxgmac2_update_vlan_hash,
+ .update_vlan_hash = vlan_update_hash,
.enable_vlan = vlan_enable,
- .add_hw_vlan_rx_fltr = vlan_add_hw_rx_fltr,
- .del_hw_vlan_rx_fltr = vlan_del_hw_rx_fltr,
- .restore_hw_vlan_rx_fltr = vlan_restore_hw_rx_fltr,
- .rx_hw_vlan = vlan_rx_hw,
- .set_hw_vlan_mode = vlan_set_hw_mode,
};
u32 stmmac_get_num_vlan(void __iomem *ioaddr)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h
index a138f4fdc4d8..3ee0022282f1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h
@@ -57,8 +57,7 @@
#define HW_FEATURE3 0x00000128
#define VLAN_HW_FEAT_NRVF GENMASK(2, 0)
-extern const struct stmmac_vlan_ops dwmac_vlan_ops;
-extern const struct stmmac_vlan_ops dwxgmac210_vlan_ops;
+extern const struct stmmac_vlan_ops dwmac4_vlan_ops;
extern const struct stmmac_vlan_ops dwxlgmac2_vlan_ops;
u32 stmmac_get_num_vlan(void __iomem *ioaddr);