diff options
| author | Serge Semin <fancer.lancer@gmail.com> | 2025-03-14 00:38:13 +0300 |
|---|---|---|
| committer | Serge Semin <fancer.lancer@gmail.com> | 2026-08-13 20:34:11 +0300 |
| commit | 91f9e9a3b7d78e3ad06ce928f6518cc304991244 (patch) | |
| tree | 901ab11413493b2a3992d989ac6c34d8f07d10c4 | |
| parent | 271532680957849a92548f0fb4a57487a5dc6051 (diff) | |
| download | linux-91f9e9a3b7d78e3ad06ce928f6518cc304991244.tar.gz linux-91f9e9a3b7d78e3ad06ce928f6518cc304991244.zip | |
net: stmmac: dwxgmac2: Fix VLAN packets filtering on promiscuous mode
Currently the promiscuous mode doesn't work for VLAN frames. So if there
is a VLAN interface created on top of an DW XGMAC native interface only
VLAN-frames with the specified VIDs will be received despite of having the
promiscuous mode activated. That's because the stmmac_ops::set_filter()
callback doesn't disable the VLAN-filters when the IFF_PROMISC mode is
detected.
Let's fix the problem the way it has already been done for DW Ether QoS
GMAC in commit Fixes: a7602e7332b9 ("net: stmmac: don't reject VLANs when
IFF_PROMISC is set"). The only thing that needs to be done is moving the
PACKET_FILTER.VTFE flag toggling to the denoted set_filter() callback.
Thus if the IFF_PROMISC flag is set the PACKET_FILTER.VTFE flag will be
cleared and VLAN-filter will be de-activated. Otherwise the flag will be
left set permitting VLAN-filters to work (if any was configured).
Fixes: 3cd1cfcba26e ("net: stmmac: Implement VLAN Hash Filtering in XGMAC")
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c | 27 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h | 1 |
3 files changed, 9 insertions, 25 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index c4458b622de9..ea1252730f6c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -620,6 +620,12 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw, } } + /* VLAN filtering */ + if (dev->flags & IFF_PROMISC) + value &= ~XGMAC_FILTER_VTFE; + else if (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER) + value |= XGMAC_FILTER_VTFE; + writel(value, ioaddr + XGMAC_PACKET_FILTER); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c index e24efe3bfedb..59469805edc2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c @@ -254,18 +254,13 @@ 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); - if (hash) { - u32 value = readl(ioaddr + XGMAC_PACKET_FILTER); - - value |= XGMAC_FILTER_VTFE; - - writel(value, ioaddr + XGMAC_PACKET_FILTER); - - value = readl(ioaddr + VLAN_TAG); + value = readl(ioaddr + VLAN_TAG); + if (hash) { value |= VLAN_VTHM | VLAN_ETV; if (is_double) { value |= VLAN_EDVLP; @@ -280,14 +275,6 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, value &= ~VLAN_VID; writel(value, ioaddr + VLAN_TAG); } else if (perfect_match) { - u32 value = readl(ioaddr + XGMAC_PACKET_FILTER); - - value |= XGMAC_FILTER_VTFE; - - writel(value, ioaddr + XGMAC_PACKET_FILTER); - - value = readl(ioaddr + VLAN_TAG); - value &= ~VLAN_VTHM; value |= VLAN_ETV; if (is_double) { @@ -303,14 +290,6 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, value &= ~VLAN_VID; writel(value | perfect_match, ioaddr + VLAN_TAG); } else { - u32 value = readl(ioaddr + XGMAC_PACKET_FILTER); - - value &= ~XGMAC_FILTER_VTFE; - - writel(value, ioaddr + XGMAC_PACKET_FILTER); - - value = readl(ioaddr + VLAN_TAG); - value &= ~(VLAN_VTHM | VLAN_ETV); value &= ~(VLAN_EDVLP | VLAN_ESVL); value &= ~VLAN_DOVLTC; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h index c24f89a9049b..514f28f246d9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h @@ -8,7 +8,6 @@ #define __STMMAC_VLAN_H__ #include <linux/bitfield.h> -#include "dwxgmac2.h" #define VLAN_TAG 0x00000050 #define VLAN_TAG_DATA 0x00000054 |
