From nobody Fri Sep 20 20:36:06 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51769C7619A for ; Sun, 16 Apr 2023 09:13:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjDPJNd (ORCPT ); Sun, 16 Apr 2023 05:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbjDPJN3 (ORCPT ); Sun, 16 Apr 2023 05:13:29 -0400 Received: from mxout4.routing.net (mxout4.routing.net [134.0.28.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765AD1BD9 for ; Sun, 16 Apr 2023 02:13:27 -0700 (PDT) Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout4.routing.net (Postfix) with ESMTP id 09A601012C4; Sun, 16 Apr 2023 09:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1681636403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KSatJAZyCfwpD4TZPKhwQdPlv6+YyvJv4XQLuenDj2A=; b=A9mOekSEXDx7Zp1E9gy+f6GvqZskvOPcfTOwPI/YSnYoclR6u1WyETS6vXTKSRG3NGgVZJ G1mxhuD/5tZ1l2w8a85Lqgj+OeucODT3B1r50jasNfVJAOVSt/QXQUQw46I9KYp46Bymex tsjZOt7NFjxOR9VmelXciagSNvikFbQ= Received: from frank-G5.. (fttx-pool-217.61.152.230.bambit.de [217.61.152.230]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 9AD651013A7; Sun, 16 Apr 2023 09:11:35 +0000 (UTC) From: Frank Wunderlich To: Felix Fietkau , Vladimir Oltean , Daniel Golle , =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= Cc: John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Frank Wunderlich Subject: [RFC/RFT v1] net: ethernet: mtk_eth_soc: drop generic vlan rx offload, only use DSA untagging Date: Sun, 16 Apr 2023 11:10:38 +0200 Message-Id: <20230416091038.54479-1-linux@fw-web.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mail-ID: 33c41008-f1e3-46f3-802e-ecce294b5d3c Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Felix Fietkau 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 recei= ving tagged packets on the secondary MAC, the hardware can sometimes start to em= it 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 wh= ich only use one MAC. Tested-by: Frank Wunderlich Signed-off-by: Felix Fietkau Signed-off-by: Frank Wunderlich Tested-by: Ar=C4=B1n=C3=A7 =C3=9CNAL --- used felix Patch as base and ported up to 6.3-rc6 which seems to get lost and the original bug is not handled again. it reverts changes from vladimirs patch 1a3245fe0cf8 net: ethernet: mtk_eth_soc: fix DSA TX tag hwaccel for switch = port 0 tested this on bananapi-r3 on non-dsa gmac1 and dsa aware eth0 (wan). on both vlan is working, but maybe it breaks HW-vlan-untagging --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 105 ++++++++------------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 39 insertions(+), 67 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethe= rnet/mediatek/mtk_eth_soc.c index e14050e17862..20c60cee6aa7 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1921,9 +1921,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int = budget, =20 while (done < budget) { unsigned int pktlen, *rxdcsum; - bool has_hwaccel_tag =3D false; struct net_device *netdev; - u16 vlan_proto, vlan_tci; dma_addr_t dma_addr; u32 hash, reason; int mac =3D 0; @@ -2058,31 +2056,16 @@ static int mtk_poll_rx(struct napi_struct *napi, in= t budget, skb_checksum_none_assert(skb); skb->protocol =3D eth_type_trans(skb, netdev); =20 - if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { - if (trxd.rxd3 & RX_DMA_VTAG_V2) { - vlan_proto =3D RX_DMA_VPID(trxd.rxd4); - vlan_tci =3D RX_DMA_VID(trxd.rxd4); - has_hwaccel_tag =3D true; - } - } else if (trxd.rxd2 & RX_DMA_VTAG) { - vlan_proto =3D RX_DMA_VPID(trxd.rxd3); - vlan_tci =3D RX_DMA_VID(trxd.rxd3); - has_hwaccel_tag =3D true; - } - } - /* When using VLAN untagging in combination with DSA, the * hardware treats the MTK special tag as a VLAN and untags it. */ - if (has_hwaccel_tag && netdev_uses_dsa(netdev)) { - unsigned int port =3D vlan_proto & GENMASK(2, 0); + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) && + (trxd.rxd2 & RX_DMA_VTAG) && netdev_uses_dsa(netdev)) { + unsigned int port =3D RX_DMA_VPID(trxd.rxd3) & GENMASK(2, 0); =20 if (port < ARRAY_SIZE(eth->dsa_meta) && eth->dsa_meta[port]) skb_dst_set_noref(skb, ð->dsa_meta[port]->dst); - } else if (has_hwaccel_tag) { - __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vlan_tci); } =20 if (reason =3D=3D MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED) @@ -2910,29 +2893,11 @@ static netdev_features_t mtk_fix_features(struct ne= t_device *dev, =20 static int mtk_set_features(struct net_device *dev, netdev_features_t feat= ures) { - struct mtk_mac *mac =3D netdev_priv(dev); - struct mtk_eth *eth =3D mac->hw; netdev_features_t diff =3D dev->features ^ features; - int i; =20 if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) mtk_hwlro_netdev_disable(dev); =20 - /* Set RX VLAN offloading */ - if (!(diff & NETIF_F_HW_VLAN_CTAG_RX)) - return 0; - - mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX), - MTK_CDMP_EG_CTRL); - - /* sync features with other MAC */ - for (i =3D 0; i < MTK_MAC_COUNT; i++) { - if (!eth->netdev[i] || eth->netdev[i] =3D=3D dev) - continue; - eth->netdev[i]->features &=3D ~NETIF_F_HW_VLAN_CTAG_RX; - eth->netdev[i]->features |=3D features & NETIF_F_HW_VLAN_CTAG_RX; - } - return 0; } =20 @@ -3250,30 +3215,6 @@ static int mtk_open(struct net_device *dev) struct mtk_eth *eth =3D mac->hw; int i, err; =20 - if (mtk_uses_dsa(dev) && !eth->prog) { - for (i =3D 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { - struct metadata_dst *md_dst =3D eth->dsa_meta[i]; - - if (md_dst) - continue; - - md_dst =3D metadata_dst_alloc(0, METADATA_HW_PORT_MUX, - GFP_KERNEL); - if (!md_dst) - return -ENOMEM; - - md_dst->u.port_info.port_id =3D i; - eth->dsa_meta[i] =3D md_dst; - } - } else { - /* Hardware special tag parsing needs to be disabled if at least - * one MAC does not use DSA. - */ - u32 val =3D mtk_r32(eth, MTK_CDMP_IG_CTRL); - val &=3D ~MTK_CDMP_STAG_EN; - mtk_w32(eth, val, MTK_CDMP_IG_CTRL); - } - err =3D phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { netdev_err(dev, "%s: could not attach PHY: %d\n", __func__, @@ -3312,6 +3253,39 @@ static int mtk_open(struct net_device *dev) phylink_start(mac->phylink); netif_tx_start_all_queues(dev); =20 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + return 0; + + if (mtk_uses_dsa(dev) && !eth->prog) { + for (i =3D 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { + struct metadata_dst *md_dst =3D eth->dsa_meta[i]; + + if (md_dst) + continue; + + md_dst =3D metadata_dst_alloc(0, METADATA_HW_PORT_MUX, + GFP_KERNEL); + if (!md_dst) + return -ENOMEM; + + md_dst->u.port_info.port_id =3D i; + eth->dsa_meta[i] =3D md_dst; + } + } else { + /* Hardware special tag parsing needs to be disabled if at least + * one MAC does not use DSA. + */ + u32 val =3D mtk_r32(eth, MTK_CDMP_IG_CTRL); + val &=3D ~MTK_CDMP_STAG_EN; + mtk_w32(eth, val, MTK_CDMP_IG_CTRL); + + val =3D mtk_r32(eth, MTK_CDMQ_IG_CTRL); + val &=3D ~MTK_CDMQ_STAG_EN; + mtk_w32(eth, val, MTK_CDMQ_IG_CTRL); + + mtk_w32(eth, 0, MTK_CDMP_EG_CTRL); + } + return 0; } =20 @@ -3796,10 +3770,9 @@ static int mtk_hw_init(struct mtk_eth *eth, bool res= et) if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { val =3D mtk_r32(eth, MTK_CDMP_IG_CTRL); mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); - } =20 - /* Enable RX VLan Offloading */ - mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); + mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); + } =20 /* set interrupt delays based on current Net DIM sample */ mtk_dim_rx(ð->rx_dim.work); @@ -4437,7 +4410,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct de= vice_node *np) eth->netdev[id]->hw_features |=3D NETIF_F_LRO; =20 eth->netdev[id]->vlan_features =3D eth->soc->hw_features & - ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); + ~NETIF_F_HW_VLAN_CTAG_TX; eth->netdev[id]->features |=3D eth->soc->hw_features; eth->netdev[id]->ethtool_ops =3D &mtk_ethtool_ops; =20 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethe= rnet/mediatek/mtk_eth_soc.h index 084a6badef6d..ac57dc87c59a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -48,7 +48,6 @@ #define MTK_HW_FEATURES (NETIF_F_IP_CSUM | \ NETIF_F_RXCSUM | \ NETIF_F_HW_VLAN_CTAG_TX | \ - NETIF_F_HW_VLAN_CTAG_RX | \ NETIF_F_SG | NETIF_F_TSO | \ NETIF_F_TSO6 | \ NETIF_F_IPV6_CSUM |\ --=20 2.34.1