From patchwork Fri Dec 30 07:31:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 37602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2772324wrt; Thu, 29 Dec 2022 23:33:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyIVN4Vg6Iv/QhvwiOZq0ikQcNJSTAml+AdfRv/SK8BHqKwzVO1zUAoDaG3unHf7lsXj2A X-Received: by 2002:a05:6402:538d:b0:487:2ce6:2b80 with SMTP id ew13-20020a056402538d00b004872ce62b80mr10066139edb.8.1672385639520; Thu, 29 Dec 2022 23:33:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672385639; cv=none; d=google.com; s=arc-20160816; b=LE/GsNSXAv9BFXMBKgD9Tjh+tZQfx94XzVjncE/XKcAvqpXckFLc5dZbxoCfe90Fug FTlb35G+m8tlSUDjuciMJ+bz4ZxTWSjEpWEXe0HsFrS0QIcvSjh/RJn73yyevEBZNVBM so6VeNLgcprl+kv55hs8Lo4VnRG0TRKhYe0CuHZhKpoDRzvAzbN4vK8Q5iNtAvPe97yc jhBFTB5Y7DhN+YHxkOgy8ABjUkLQcC4gAMzyVmKiKDm1XzXQ0fNtKGq7IGyAv0ugiGHQ tbIwNh/U3tww2qsf2+lXk+Lv/RFqnELiDjH4aTXQ69xPxe/IuXS7oKp7ll2OuXLWSp2g H1vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=P13fC0gIy9H1wpJFlbhQImrQkU7AmQuWDjdNHiwtHhE=; b=Wsv3mA4sK7CfumlVqpBZkOd5fncOuv8jA35SvW9jbcNKeFUvAYgI56SysXYbXe1TAD KA0BUoSjvCY268bzdnmH60t65jH63XIfI3tuAyiPDs9NjGbZ8b87MK26DOLMIU0DC1Xn UGF24LDmsMTYTnuHFxzmrPJ5hcZuzYYQd+dmBBMzFp+LCgzVpRk/OTLbb38BwldcXy4g cB2Ym7ulMo/n1CVxdiMoAMwuErtWCqcIrgRfbWIUM+QbtdKJjyTgAbWknuWEh763Yubt QDDPpZex6M42TkyAOUotgaPehIgu8Qv/t5Tu38E3j35T7St15HjpDqLjAOXsQatXvd8W u5dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=AinItdjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a056402064d00b00458ab55ccc9si16437329edx.168.2022.12.29.23.33.34; Thu, 29 Dec 2022 23:33:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=AinItdjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234706AbiL3HcR (ORCPT + 99 others); Fri, 30 Dec 2022 02:32:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbiL3HcG (ORCPT ); Fri, 30 Dec 2022 02:32:06 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14112DF8; Thu, 29 Dec 2022 23:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=P13fC0gIy9H1wpJFlbhQImrQkU7AmQuWDjdNHiwtHhE=; b=AinItdjyBiZbYhA1gF9YGn4UVW VxjwKYu0OviTHqSGApDH7OL35y6COZAeGsAEw6fl1Qnf3E/HCElLzHSBqVC693O6GP01Y5PtUJqAs osEYDCU6D/rk171ZGsWzM1M1TzPUZeSMdO91Vz1nsTDwVXMWzvgYPMTgC90xhmobBKAM=; Received: from p200300daa720fc00fd7bb9014adaf597.dip0.t-ipconnect.de ([2003:da:a720:fc00:fd7b:b901:4ada:f597] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pB9rm-00CcyM-An; Fri, 30 Dec 2022 08:31:46 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: Vladimir Oltean , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 1/5] net: ethernet: mtk_eth_soc: account for vlan in rx header length Date: Fri, 30 Dec 2022 08:31:41 +0100 Message-Id: <20221230073145.53386-1-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753623444519909435?= X-GMAIL-MSGID: =?utf-8?q?1753623444519909435?= The network stack assumes that devices can handle an extra VLAN tag without increasing the MTU Reviewed-by: Vladimir Oltean Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 18a50529ce7b..877cee9bcc66 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -34,7 +34,7 @@ #define MTK_QDMA_RING_SIZE 2048 #define MTK_DMA_SIZE 512 #define MTK_MAC_COUNT 2 -#define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN) +#define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + ETH_FCS_LEN) #define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN) #define MTK_DMA_DUMMY_DESC 0xffffffff #define MTK_DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | \ From patchwork Fri Dec 30 07:31:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 37605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2772654wrt; Thu, 29 Dec 2022 23:35:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFABzgG+QtY85jqVqVJm2GaGW8Ul8vm5ISN/Yk60NL0m0aX9YXOF5pBHs2EJ8TyhBVwmOX X-Received: by 2002:aa7:c505:0:b0:47f:2419:336c with SMTP id o5-20020aa7c505000000b0047f2419336cmr25656083edq.25.1672385702827; Thu, 29 Dec 2022 23:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672385702; cv=none; d=google.com; s=arc-20160816; b=eTBF/WMC1HZm+pewzdkZTBOPO7OxBImpOozETx1QK/iIESBQ3OlY9tXFsSS7FKxF4o +9Sd7/y48mATAVYxWS+aZt307jglO5lu5+Uax3FoYIfl6oqoPHQ8WXx40l9tQXrtUCS3 ScCEvxqhXdaDKPJq4kktI6NJKsZCQP/QgdXa3yES2uq4tOiF12cMnqt36MnHxPbSOOe8 yq0mqlvBJ2G42yJsvi1q+oyWHCOanjezy+AvBPdweNhhCMAOHqhIShJTgtXNZJzQrhZc Nb7ZRCGXm0dlWq2TURc3S0TCAKKHY0/XXj4ShuzlHKBNHV2OgC5Xe5cymdExYh5xynin JDxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BvOC66n7pZ2pEcN9qIrVWxECjhBPJGMGgZTSuErZAzs=; b=UPkYSCFqfQ8BN6JygNAQOe6UqiW1C9gsciB5rDbBlFgU2bKUHSHtw+tcM137EBzmLE ojB3TM+z72gOrpHrbYiNT+993oLWe+HfgCuKzgbw/ok/9RWe9hnpTrkiVFQ8BcU9WY1X VrR9Et7qr01KqegyA8rfRTEu9FU0Avp5lVTlfroljUn7cXlXfwhZmQUgKOdhy0pXHriE McZsX0NPogvawD6yDTKds48B0U8XqKCX7XOqhxAYTl/XeeFlvLow5t5ZxoghSvADIDwH FnjnswAR4LL9pHqLL28IUMk8TpaWG6hsR0HZFtu/qmgaOJy9Ell/uWOqnYTou0xvuPB3 ukEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ftSUJwEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a056402036c00b004697dff9638si15804973edw.87.2022.12.29.23.34.39; Thu, 29 Dec 2022 23:35:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ftSUJwEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbiL3HcW (ORCPT + 99 others); Fri, 30 Dec 2022 02:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbiL3HcH (ORCPT ); Fri, 30 Dec 2022 02:32:07 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379D6DE8D; Thu, 29 Dec 2022 23:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BvOC66n7pZ2pEcN9qIrVWxECjhBPJGMGgZTSuErZAzs=; b=ftSUJwElGo3Wc9UoKBU0nRZ+db 0CaCTeNwJN80mG+3lMtznUWbViysyQSQUkbcjNt+c3RgzliAxJETVMwV/p2lMFGCfDcErMOfFz9T9 lerBxsxsfWhMTZfAB84jxEq0WIEshZu5ywgF+oEOdf8qmKdDtX5W1quRA1oJUY/hti2Y=; Received: from p200300daa720fc00fd7bb9014adaf597.dip0.t-ipconnect.de ([2003:da:a720:fc00:fd7b:b901:4ada:f597] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pB9rn-00CcyM-4V; Fri, 30 Dec 2022 08:31:47 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 2/5] net: ethernet: mtk_eth_soc: work around issue with sending small fragments Date: Fri, 30 Dec 2022 08:31:42 +0100 Message-Id: <20221230073145.53386-2-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221230073145.53386-1-nbd@nbd.name> References: <20221230073145.53386-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753623510547070681?= X-GMAIL-MSGID: =?utf-8?q?1753623510547070681?= When lots of frames are sent with a number of very small fragments, an internal FIFO can overflow, causing the DMA engine to lock up lock up and transmit attempts time out. Fix this on MT7986 by increasing the reserved FIFO space. Fix this on older chips by detecting the presence of small fragments and use skb_gso_segment + skb_linearize to deal with them. Signed-off-by: Felix Fietkau --- v2: add proper fix for MT7986, limit workaround to NETSYS v1 v3: fix a regression on mt7986 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 38 +++++++++++++++++++-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index e3de9a53b2d9..04b75c7ad5b0 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1441,12 +1441,28 @@ static void mtk_wake_queue(struct mtk_eth *eth) } } +static bool mtk_skb_has_small_frag(struct sk_buff *skb) +{ + int min_size = 16; + int i; + + if (skb_headlen(skb) < min_size) + return true; + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) + if (skb_frag_size(&skb_shinfo(skb)->frags[i]) < min_size) + return true; + + return false; +} + static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; struct mtk_tx_ring *ring = ð->tx_ring; struct net_device_stats *stats = &dev->stats; + struct sk_buff *segs, *next; bool gso = false; int tx_num; @@ -1468,6 +1484,18 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_BUSY; } + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) && + skb_is_gso(skb) && mtk_skb_has_small_frag(skb)) { + segs = skb_gso_segment(skb, dev->features & ~NETIF_F_ALL_TSO); + if (IS_ERR(segs)) + goto drop; + + if (segs) { + consume_skb(skb); + skb = segs; + } + } + /* TSO: fill MSS info in tcp checksum field */ if (skb_is_gso(skb)) { if (skb_cow_head(skb, 0)) { @@ -1483,8 +1511,14 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) } } - if (mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) - goto drop; + skb_list_walk_safe(skb, skb, next) { + if ((!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) && + mtk_skb_has_small_frag(skb) && skb_linearize(skb)) || + mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) { + stats->tx_dropped++; + dev_kfree_skb_any(skb); + } + } if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) netif_tx_stop_all_queues(dev); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 877cee9bcc66..420a7d412f24 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -247,7 +247,7 @@ #define MTK_CHK_DDONE_EN BIT(28) #define MTK_DMAD_WR_WDONE BIT(26) #define MTK_WCOMP_EN BIT(24) -#define MTK_RESV_BUF (0x40 << 16) +#define MTK_RESV_BUF (0x80 << 16) #define MTK_MUTLI_CNT (0x4 << 12) #define MTK_LEAKY_BUCKET_EN BIT(11) From patchwork Fri Dec 30 07:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 37601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2772045wrt; Thu, 29 Dec 2022 23:32:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXtkg53CQBYyTXY64hj90PO5tjNKFqqneVHhutAYFKaEGjx8yhEjtw4eD5+HJuwDO4FNhTD0 X-Received: by 2002:a17:906:34db:b0:842:3920:df75 with SMTP id h27-20020a17090634db00b008423920df75mr27089947ejb.33.1672385574143; Thu, 29 Dec 2022 23:32:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672385574; cv=none; d=google.com; s=arc-20160816; b=mjFeJyP+//ifJZaez30SRZSyQRnUEkipW6tu0FQW/sEtXKJKBhnI62DpleQsyIOV14 nNh4b1J9XsXdO1SOKXHh1gIsR0PXESvJISaRICK0ejSvF0md3jH4Ec37Iy2EThUaX/sq GH8p6KcDIMN2y7V6fccxReJbG7GNOWyXQ8/lIkUl4i5YA4p8LACDfvoiH8vxgLv0g5iF 2ukxCJkxKh20J2goctaeyang50jEZmGaPS2nTHn/YV3/8IDvhIZOGJc1RkpMGTYoMHW8 U5NElyfjOf1l0z7cmVSgnGzgZ91277j2QbxDl167RhTm9O0V5vBB2Y4KCq2z6SuT0sZ8 KaBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/eX4/CTCtjyiWC4V7OvOX6dzNZbFQNR2QZZFW5KPupw=; b=yCeRfTwhahiwmK99hciyULbT5lU9Tlb8L9wn+dbHYrAsal2XMf7+PHPqlkQ8H9B1eP 48crkF4OCou771yQ1x5yZhzFk/vyYpkZ2YQ2h6lkGg90bCmXhntSe64IZsUy9RMW23DM 4FUg9HA05nLVQQ/qDrLswpZApLEJpetahXN3PT9iV/VQ2GHF2SVT9F7ongVCGQCXtjUR PQ6AVUJyeiiROsOX22FUuEd3dbEhB/B6js6jEbz6AsU6tdgXNg4SXdsbJTYtgm6HlHOA ycX3R6G5EZgU6ddVul/z9VS7AUeAxh/BaOQVaQC9RzUCau5E4Us6irPOsyLyPsPnpQ6p hxZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=imvlYXXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a1709063e5200b007add0c2ee2csi13507609eji.924.2022.12.29.23.32.30; Thu, 29 Dec 2022 23:32:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=imvlYXXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbiL3HcL (ORCPT + 99 others); Fri, 30 Dec 2022 02:32:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbiL3HcG (ORCPT ); Fri, 30 Dec 2022 02:32:06 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A9B2BD9; Thu, 29 Dec 2022 23:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/eX4/CTCtjyiWC4V7OvOX6dzNZbFQNR2QZZFW5KPupw=; b=imvlYXXLQzkhx3C9WX7lII+acM ixTx1f6ndSof5qCXODx7uSKtLWVAarD7z6YBuQVrZv1DOGx3pKP3polA2qD6VwyZ6uixGTBZx/xhU jrd1yuzyJqQxUBqabRCr2U/9MvyZMcxmyh3NluE5k1hN/UlyZ0RXpBT5lA9p/uYtuoM8=; Received: from p200300daa720fc00fd7bb9014adaf597.dip0.t-ipconnect.de ([2003:da:a720:fc00:fd7b:b901:4ada:f597] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pB9rn-00CcyM-UX; Fri, 30 Dec 2022 08:31:48 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Pablo Neira Ayuso Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 3/5] net: ethernet: mtk_eth_soc: fix flow_offload related refcount bug Date: Fri, 30 Dec 2022 08:31:43 +0100 Message-Id: <20221230073145.53386-3-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221230073145.53386-1-nbd@nbd.name> References: <20221230073145.53386-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753623375632652683?= X-GMAIL-MSGID: =?utf-8?q?1753623375632652683?= Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we need to call flow_block_cb_incref unconditionally, even for a newly allocated cb. Fixes a use-after-free bug Fixes: 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support") Signed-off-by: Felix Fietkau --- .../net/ethernet/mediatek/mtk_ppe_offload.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c index 81afd5ee3fbf..412d215b9571 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c @@ -554,6 +554,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f) struct mtk_eth *eth = mac->hw; static LIST_HEAD(block_cb_list); struct flow_block_cb *block_cb; + bool register_block = false; flow_setup_cb_t *cb; if (!eth->soc->offload_version) @@ -568,16 +569,20 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f) switch (f->command) { case FLOW_BLOCK_BIND: block_cb = flow_block_cb_lookup(f->block, cb, dev); - if (block_cb) { - flow_block_cb_incref(block_cb); - return 0; + if (!block_cb) { + block_cb = flow_block_cb_alloc(cb, dev, dev, NULL); + if (IS_ERR(block_cb)) + return PTR_ERR(block_cb); + + register_block = true; } - block_cb = flow_block_cb_alloc(cb, dev, dev, NULL); - if (IS_ERR(block_cb)) - return PTR_ERR(block_cb); - flow_block_cb_add(block_cb, f); - list_add_tail(&block_cb->driver_list, &block_cb_list); + flow_block_cb_incref(block_cb); + + if (register_block) { + flow_block_cb_add(block_cb, f); + list_add_tail(&block_cb->driver_list, &block_cb_list); + } return 0; case FLOW_BLOCK_UNBIND: block_cb = flow_block_cb_lookup(f->block, cb, dev); From patchwork Fri Dec 30 07:31:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 37603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2772468wrt; Thu, 29 Dec 2022 23:34:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLO1ifug9amoIKXlDs8fcdsgfv2O27kvao5x+nJP+eUR1bHB5GEzendQ0RgRXkqSm3zRuT X-Received: by 2002:a17:906:8e91:b0:7c1:5248:4f3a with SMTP id ru17-20020a1709068e9100b007c152484f3amr24552476ejc.56.1672385662016; Thu, 29 Dec 2022 23:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672385661; cv=none; d=google.com; s=arc-20160816; b=v3uxQx9CA3Gfm5HPTc6XNeq082CxyLRAzD5kLaQzGpAXS5AxebXJZFYsU5uhPNVYKX /i7nDKA9OgJ1Q9QQPPePNfwxJlGxwgoz4xG+ccRHgW01kI6cbGkgfG5lTTB6qmmaOrjy 3ZWs1id6ANOTvTcb5rLone4o6KrmgAcZo1trY/6JThM88guO6AeumGDL9DiLPVQvDT9D ZEID9CMwsDTrv1Ex2LjvQEgzfysGqVQICbW5o0IGm8rQPRdBJSJDJoYS7jrl8XoWSbLa rGA2VjCjEjH8M6HknRQOT8RaxXTwy83avBsnry23gBD4JoUJan5MM0Xew2ReEamLwaw5 Zp2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QJQDjuF3r6zEq7hcTaeVjEXZUzPPpjXcmQnnLZNDmdA=; b=a5P8TXh3KvgqHr1r6Z6qN/8mCEc1LY4ynjIXmOlc6K2L/lQOVsCtFrIxtpAUk9ll1i 0rJvAXe+nqUTL1Xe3QrL64VEMkTnkYuX5h3NooFPiEACptwZDxQAdXzQsIQq/uuGLTF1 zSUVd/I9bqH7AuAlcpU5SUrppvMxeMjR1sB6ozchOJPoL/3p2jnog6aNaBYZROuMDmu+ ZeD54LJ+0inpxO749WJjKHujOOLwI2F8VYE+lDQ6c3yKhXTG7vtsUiEbOGwAPBrsw/zQ Qka35tqQ4LRRi8k3l8TKVNt5XnJdw+OuqMIag2RCboPlpP8Aa0FP8/n4jRKSZ+6+tF5W Agzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=lHtFlgle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp26-20020a1709071b1a00b0084ca32731dcsi834174ejc.675.2022.12.29.23.33.58; Thu, 29 Dec 2022 23:34:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=lHtFlgle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234740AbiL3HcY (ORCPT + 99 others); Fri, 30 Dec 2022 02:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234654AbiL3HcI (ORCPT ); Fri, 30 Dec 2022 02:32:08 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA822BD9; Thu, 29 Dec 2022 23:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QJQDjuF3r6zEq7hcTaeVjEXZUzPPpjXcmQnnLZNDmdA=; b=lHtFlgleNENzTCYf483HXQ6I3A +/nn0r2WJoi56C5ai53UEZt7Wp/m9aWcOvHR/co7N9aBFge3GNjWuNngkkspjyFy1FA/ZcqtOEv04 JhUk0yWjr0DsB4rcoIdEh12wh1I+0m2zCmsm9rMwmVe8C+BrtvW1XzH4jPT75DMsloZo=; Received: from p200300daa720fc00fd7bb9014adaf597.dip0.t-ipconnect.de ([2003:da:a720:fc00:fd7b:b901:4ada:f597] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pB9ro-00CcyM-QG; Fri, 30 Dec 2022 08:31:48 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King Cc: Frank Wunderlich , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 4/5] net: ethernet: mtk_eth_soc: drop generic vlan rx offload, only use DSA untagging Date: Fri, 30 Dec 2022 08:31:44 +0100 Message-Id: <20221230073145.53386-4-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221230073145.53386-1-nbd@nbd.name> References: <20221230073145.53386-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753623468126072021?= X-GMAIL-MSGID: =?utf-8?q?1753623468126072021?= 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 which only use one MAC. Tested-By: Frank Wunderlich Signed-off-by: Felix Fietkau Tested-by: Arınç ÜNAL --- v3: rebase drivers/net/ethernet/mediatek/mtk_eth_soc.c | 101 ++++++++------------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 39 insertions(+), 63 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 04b75c7ad5b0..ab6c571a39ae 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2042,29 +2042,16 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED) mtk_ppe_check_skb(eth->ppe[0], skb, hash); - 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_hwaccel_put_tag(skb, - htons(RX_DMA_VPID(trxd.rxd4)), - RX_DMA_VID(trxd.rxd4)); - } else if (trxd.rxd2 & RX_DMA_VTAG) { - __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)), - RX_DMA_VID(trxd.rxd3)); - } - } - /* When using VLAN untagging in combination with DSA, the * hardware treats the MTK special tag as a VLAN and untags it. */ - if (skb_vlan_tag_present(skb) && netdev_uses_dsa(netdev)) { - unsigned int port = ntohs(skb->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 = RX_DMA_VPID(trxd.rxd3) & GENMASK(2, 0); if (port < ARRAY_SIZE(eth->dsa_meta) && eth->dsa_meta[port]) skb_dst_set_noref(skb, ð->dsa_meta[port]->dst); - - __vlan_hwaccel_clear_tag(skb); } skb_record_rx_queue(skb, 0); @@ -2889,29 +2876,11 @@ static netdev_features_t mtk_fix_features(struct net_device *dev, static int mtk_set_features(struct net_device *dev, netdev_features_t features) { - struct mtk_mac *mac = netdev_priv(dev); - struct mtk_eth *eth = mac->hw; netdev_features_t diff = dev->features ^ features; - int i; if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) mtk_hwlro_netdev_disable(dev); - /* 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 = 0; i < MTK_MAC_COUNT; i++) { - if (!eth->netdev[i] || eth->netdev[i] == dev) - continue; - eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX; - eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX; - } - return 0; } @@ -3211,30 +3180,6 @@ static int mtk_open(struct net_device *dev) struct mtk_eth *eth = mac->hw; int i, err; - if (mtk_uses_dsa(dev) && !eth->prog) { - for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { - struct metadata_dst *md_dst = eth->dsa_meta[i]; - - if (md_dst) - continue; - - md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, - GFP_KERNEL); - if (!md_dst) - return -ENOMEM; - - md_dst->u.port_info.port_id = i; - eth->dsa_meta[i] = md_dst; - } - } else { - /* Hardware special tag parsing needs to be disabled if at least - * one MAC does not use DSA. - */ - u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL); - val &= ~MTK_CDMP_STAG_EN; - mtk_w32(eth, val, MTK_CDMP_IG_CTRL); - } - err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { netdev_err(dev, "%s: could not attach PHY: %d\n", __func__, @@ -3273,6 +3218,39 @@ static int mtk_open(struct net_device *dev) phylink_start(mac->phylink); netif_tx_start_all_queues(dev); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + return 0; + + if (mtk_uses_dsa(dev) && !eth->prog) { + for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { + struct metadata_dst *md_dst = eth->dsa_meta[i]; + + if (md_dst) + continue; + + md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, + GFP_KERNEL); + if (!md_dst) + return -ENOMEM; + + md_dst->u.port_info.port_id = i; + eth->dsa_meta[i] = md_dst; + } + } else { + /* Hardware special tag parsing needs to be disabled if at least + * one MAC does not use DSA. + */ + u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL); + val &= ~MTK_CDMP_STAG_EN; + mtk_w32(eth, val, MTK_CDMP_IG_CTRL); + + val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); + val &= ~MTK_CDMQ_STAG_EN; + mtk_w32(eth, val, MTK_CDMQ_IG_CTRL); + + mtk_w32(eth, 0, MTK_CDMP_EG_CTRL); + } + return 0; } @@ -3599,10 +3577,9 @@ static int mtk_hw_init(struct mtk_eth *eth) if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { val = mtk_r32(eth, MTK_CDMP_IG_CTRL); mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); - } - /* Enable RX VLan Offloading */ - mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); + mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); + } /* set interrupt delays based on current Net DIM sample */ mtk_dim_rx(ð->rx_dim.work); @@ -4203,7 +4180,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) eth->netdev[id]->hw_features |= NETIF_F_LRO; eth->netdev[id]->vlan_features = 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 |= eth->soc->hw_features; eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 420a7d412f24..e8bb8b511f06 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 |\ From patchwork Fri Dec 30 07:31:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 37604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2772570wrt; Thu, 29 Dec 2022 23:34:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBOUuQVy4WOOA/9TuxInG83ku9l8YzOTTu+ukAN2xeu4FpQoYJ4XJryBLjekRUo66KjFO8 X-Received: by 2002:a17:906:13d6:b0:7c1:99a7:e10b with SMTP id g22-20020a17090613d600b007c199a7e10bmr25698732ejc.49.1672385683465; Thu, 29 Dec 2022 23:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672385683; cv=none; d=google.com; s=arc-20160816; b=JQzytjYDrJshlDLqnnVXaFiW2NXwNk62F7LtrCh3qSOvwQf7lGR4TGGa3fgJbdfItE jpjnD19MZh8xbulxtyedQdq3eX9lsGRqGOO+VrkRRmElligOK9ah/vCYr3Eu0CHb0rej sWarD2xb7yhJQcvhV2psdWSD9VJyzE2BIYlujwp8JJjtoFSj4IpYjLmAVDQeXGICnMCV noCYMZbrhUFp3Yj4J63YR2H2AcgnS1yfPRLEpe4x4zwAfdskFogQ+1cp0lG4dOnG9js+ tW1hyA64kb6bcX7UxLI8tv7rbMeuvU6u9CrkZCnItbHGgcJayuvE0BBHkgreaS/Iw360 //qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QkQJAkmCP+Nuor28oAQ7xUGQ6VarGmNl8TUneHFaCpI=; b=jjZYrejHaOKcecN/ZZ32RJBbCdS2vPEkQGjJCtPzpT2wQiUV1F0lv2AoU6qZr8b5vr 49wymTAlDkXPiMRmYlStoOz1urFuIpNaBEVd2pAxAtACUOW8a/mmfU0UQ1f86CtHjsH/ 4WgjUL6b0h2NsKAYCOPBB7K8Gy1xty9gbI7wxazW5QEklije4PMtg28SDkOG3ouSvM9c WfXFEk5YTceLD0wub+0ySHGTIQ7QHGpZWV7Wwfnq7AOM6aYdCT5kSngllmouRLuZt40A 9NuJXk0oLD3O87MdZTYFr1omMByyndMXK4azZrQLiq9iY3hqq1nsJkPbjmZyZ3DDXtOK I3jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=W5dlGu8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wu8-20020a170906eec800b007a1d4f0e7fcsi1684084ejb.655.2022.12.29.23.34.16; Thu, 29 Dec 2022 23:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=W5dlGu8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234712AbiL3HcT (ORCPT + 99 others); Fri, 30 Dec 2022 02:32:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234646AbiL3HcG (ORCPT ); Fri, 30 Dec 2022 02:32:06 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52FBA65B0; Thu, 29 Dec 2022 23:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QkQJAkmCP+Nuor28oAQ7xUGQ6VarGmNl8TUneHFaCpI=; b=W5dlGu8PC6yganKCBF8FGA+SjX XiqTrLOvVu3t6wuzB0NGf+302TDzqUOqklTX5ypScG+5JJsg8Kk32zJMHJmmeYv9YjPyAhHyoAjWR ZQbZoxVhA491TbQKcMPTyeVONkrXBHatKh816IW9KRE72QPw5gptHygsDTTs3Wgtb2VU=; Received: from p200300daa720fc00fd7bb9014adaf597.dip0.t-ipconnect.de ([2003:da:a720:fc00:fd7b:b901:4ada:f597] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pB9rp-00CcyM-L4; Fri, 30 Dec 2022 08:31:49 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 5/5] net: ethernet: mtk_eth_soc: ppe: fix L2 offloading with DSA untagging offload enabled Date: Fri, 30 Dec 2022 08:31:45 +0100 Message-Id: <20221230073145.53386-5-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221230073145.53386-1-nbd@nbd.name> References: <20221230073145.53386-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753623490091354359?= X-GMAIL-MSGID: =?utf-8?q?1753623490091354359?= Check for skb metadata in order to detect the case where the DSA header is not present. Fixes: 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging") Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++--- drivers/net/ethernet/mediatek/mtk_ppe.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index ab6c571a39ae..cec2fcab3dfa 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2039,9 +2039,6 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, netdev); - if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED) - mtk_ppe_check_skb(eth->ppe[0], skb, hash); - /* When using VLAN untagging in combination with DSA, the * hardware treats the MTK special tag as a VLAN and untags it. */ @@ -2054,6 +2051,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb_dst_set_noref(skb, ð->dsa_meta[port]->dst); } + if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED) + mtk_ppe_check_skb(eth->ppe[0], skb, hash); + skb_record_rx_queue(skb, 0); napi_gro_receive(napi, skb); diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 269208a841c7..e366a83cf516 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "mtk_eth_soc.h" #include "mtk_ppe.h" @@ -700,7 +701,9 @@ void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash) skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK) goto out; - tag += 4; + if (!skb_metadata_dst(skb)) + tag += 4; + if (get_unaligned_be16(tag) != ETH_P_8021Q) break;