Skip to content

Commit c6d96df

Browse files
nbd168kuba-moo
authored andcommitted
net: ethernet: mtk_eth_soc: drop generic vlan rx offload, only use DSA untagging
Through testing I found out that hardware vlan rx offload support seems to have some hardware issues. At least when using multiple MACs and when receiving tagged packets on the secondary MAC, the hardware can sometimes start to emit wrong tags on the first MAC as well. In order to avoid such issues, drop the feature configuration and use the offload feature only for DSA hardware untagging on MT7621/MT7622 devices where this feature works properly. Fixes: 08666cb ("net: ethernet: mtk_eth_soc: add support for configuring vlan rx offload") Tested-by: Frank Wunderlich <[email protected]> Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Frank Wunderlich <[email protected]> Tested-by: Arınç ÜNAL <[email protected]> Acked-by: Arınç ÜNAL <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fb7cba6 commit c6d96df

File tree

2 files changed

+40
-67
lines changed

2 files changed

+40
-67
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,9 +1918,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
19181918

19191919
while (done < budget) {
19201920
unsigned int pktlen, *rxdcsum;
1921-
bool has_hwaccel_tag = false;
19221921
struct net_device *netdev;
1923-
u16 vlan_proto, vlan_tci;
19241922
dma_addr_t dma_addr;
19251923
u32 hash, reason;
19261924
int mac = 0;
@@ -2055,31 +2053,16 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
20552053
skb_checksum_none_assert(skb);
20562054
skb->protocol = eth_type_trans(skb, netdev);
20572055

2058-
if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
2059-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
2060-
if (trxd.rxd3 & RX_DMA_VTAG_V2) {
2061-
vlan_proto = RX_DMA_VPID(trxd.rxd4);
2062-
vlan_tci = RX_DMA_VID(trxd.rxd4);
2063-
has_hwaccel_tag = true;
2064-
}
2065-
} else if (trxd.rxd2 & RX_DMA_VTAG) {
2066-
vlan_proto = RX_DMA_VPID(trxd.rxd3);
2067-
vlan_tci = RX_DMA_VID(trxd.rxd3);
2068-
has_hwaccel_tag = true;
2069-
}
2070-
}
2071-
20722056
/* When using VLAN untagging in combination with DSA, the
20732057
* hardware treats the MTK special tag as a VLAN and untags it.
20742058
*/
2075-
if (has_hwaccel_tag && netdev_uses_dsa(netdev)) {
2076-
unsigned int port = vlan_proto & GENMASK(2, 0);
2059+
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) &&
2060+
(trxd.rxd2 & RX_DMA_VTAG) && netdev_uses_dsa(netdev)) {
2061+
unsigned int port = RX_DMA_VPID(trxd.rxd3) & GENMASK(2, 0);
20772062

20782063
if (port < ARRAY_SIZE(eth->dsa_meta) &&
20792064
eth->dsa_meta[port])
20802065
skb_dst_set_noref(skb, &eth->dsa_meta[port]->dst);
2081-
} else if (has_hwaccel_tag) {
2082-
__vlan_hwaccel_put_tag(skb, htons(vlan_proto), vlan_tci);
20832066
}
20842067

20852068
if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
@@ -2907,29 +2890,11 @@ static netdev_features_t mtk_fix_features(struct net_device *dev,
29072890

29082891
static int mtk_set_features(struct net_device *dev, netdev_features_t features)
29092892
{
2910-
struct mtk_mac *mac = netdev_priv(dev);
2911-
struct mtk_eth *eth = mac->hw;
29122893
netdev_features_t diff = dev->features ^ features;
2913-
int i;
29142894

29152895
if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO))
29162896
mtk_hwlro_netdev_disable(dev);
29172897

2918-
/* Set RX VLAN offloading */
2919-
if (!(diff & NETIF_F_HW_VLAN_CTAG_RX))
2920-
return 0;
2921-
2922-
mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX),
2923-
MTK_CDMP_EG_CTRL);
2924-
2925-
/* sync features with other MAC */
2926-
for (i = 0; i < MTK_MAC_COUNT; i++) {
2927-
if (!eth->netdev[i] || eth->netdev[i] == dev)
2928-
continue;
2929-
eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
2930-
eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX;
2931-
}
2932-
29332898
return 0;
29342899
}
29352900

@@ -3247,30 +3212,6 @@ static int mtk_open(struct net_device *dev)
32473212
struct mtk_eth *eth = mac->hw;
32483213
int i, err;
32493214

3250-
if (mtk_uses_dsa(dev) && !eth->prog) {
3251-
for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) {
3252-
struct metadata_dst *md_dst = eth->dsa_meta[i];
3253-
3254-
if (md_dst)
3255-
continue;
3256-
3257-
md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
3258-
GFP_KERNEL);
3259-
if (!md_dst)
3260-
return -ENOMEM;
3261-
3262-
md_dst->u.port_info.port_id = i;
3263-
eth->dsa_meta[i] = md_dst;
3264-
}
3265-
} else {
3266-
/* Hardware special tag parsing needs to be disabled if at least
3267-
* one MAC does not use DSA.
3268-
*/
3269-
u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
3270-
val &= ~MTK_CDMP_STAG_EN;
3271-
mtk_w32(eth, val, MTK_CDMP_IG_CTRL);
3272-
}
3273-
32743215
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
32753216
if (err) {
32763217
netdev_err(dev, "%s: could not attach PHY: %d\n", __func__,
@@ -3309,6 +3250,40 @@ static int mtk_open(struct net_device *dev)
33093250
phylink_start(mac->phylink);
33103251
netif_tx_start_all_queues(dev);
33113252

3253+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
3254+
return 0;
3255+
3256+
if (mtk_uses_dsa(dev) && !eth->prog) {
3257+
for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) {
3258+
struct metadata_dst *md_dst = eth->dsa_meta[i];
3259+
3260+
if (md_dst)
3261+
continue;
3262+
3263+
md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
3264+
GFP_KERNEL);
3265+
if (!md_dst)
3266+
return -ENOMEM;
3267+
3268+
md_dst->u.port_info.port_id = i;
3269+
eth->dsa_meta[i] = md_dst;
3270+
}
3271+
} else {
3272+
/* Hardware special tag parsing needs to be disabled if at least
3273+
* one MAC does not use DSA.
3274+
*/
3275+
u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
3276+
3277+
val &= ~MTK_CDMP_STAG_EN;
3278+
mtk_w32(eth, val, MTK_CDMP_IG_CTRL);
3279+
3280+
val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
3281+
val &= ~MTK_CDMQ_STAG_EN;
3282+
mtk_w32(eth, val, MTK_CDMQ_IG_CTRL);
3283+
3284+
mtk_w32(eth, 0, MTK_CDMP_EG_CTRL);
3285+
}
3286+
33123287
return 0;
33133288
}
33143289

@@ -3793,10 +3768,9 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
37933768
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
37943769
val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
37953770
mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);
3796-
}
37973771

3798-
/* Enable RX VLan Offloading */
3799-
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
3772+
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
3773+
}
38003774

38013775
/* set interrupt delays based on current Net DIM sample */
38023776
mtk_dim_rx(&eth->rx_dim.work);
@@ -4453,7 +4427,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
44534427
eth->netdev[id]->hw_features |= NETIF_F_LRO;
44544428

44554429
eth->netdev[id]->vlan_features = eth->soc->hw_features &
4456-
~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX);
4430+
~NETIF_F_HW_VLAN_CTAG_TX;
44574431
eth->netdev[id]->features |= eth->soc->hw_features;
44584432
eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops;
44594433

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#define MTK_HW_FEATURES (NETIF_F_IP_CSUM | \
4949
NETIF_F_RXCSUM | \
5050
NETIF_F_HW_VLAN_CTAG_TX | \
51-
NETIF_F_HW_VLAN_CTAG_RX | \
5251
NETIF_F_SG | NETIF_F_TSO | \
5352
NETIF_F_TSO6 | \
5453
NETIF_F_IPV6_CSUM |\

0 commit comments

Comments
 (0)