Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2771138rwd; Mon, 22 May 2023 04:14:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TLFU4oEmBqeFvv29ZgpUbMdX45tvCqZE5s+UNlEFBRKE97NESNYxzlqhgj4Hi5ivLbAWg X-Received: by 2002:a17:90b:1e50:b0:252:b14a:55c2 with SMTP id pi16-20020a17090b1e5000b00252b14a55c2mr9456178pjb.9.1684754079506; Mon, 22 May 2023 04:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684754079; cv=none; d=google.com; s=arc-20160816; b=nDDYryWfqYCtBsRyknEpFnY5nyQoVcWTlU1ZT5PuqV3dLt6OxwOKHSuCF0+3xgvapa euPqenCyKnj0b2Odjk3hXKt5hSXj8SAf+2lF8iZKnjW9mzxjoFuuCQmwrVgq355UMZob oAJAFXhpr3bP09uJ9/jlRPWAi7M72qinBtSqF7CrNzHG5Wa+by8EWXTwOMaAYzXrMvAY cdPDUEYYGXs9HEQSrp/lg0/m5ZOX+bJ7FFVq3QCsprokilJK9bvyhAtHeDG26YbZQMES ZQ+0KplZ1b7/OEBoMqlBKWbotQhen8Ss4Q+y0sbF5bh0GaUtU8EWeFowOd47sFKgMLZL b48Q== 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=QbaFtQY4U1SAGZYtnPdu7mZsLG5dGue95mqtDIfDNho=; b=RoEuljXDr2kyBP/GUIVM4wX36TR03Gly3z6qSUuDzYWVRlobNiIaCr/oEN+lSQUNts yyCfaEhyptormROwKJnIxswb7pozT/uM29J1uABw+OqghjAkXPU8ewHGv/3hlbHZxSRa m8gBjgAolCpVeMU+9FR+p4mCM74zd8yEZPFFtW+vpfea13NzNRLEC+fczbdmYIpjXj5S tnznazatIR+K0mcO96zQWfaLOdoBVWdSE9eBbd3cQpzdczXq1EGLu6/njGpK8yh1OqZs TsCfUfCM2lC/9lzrjgsPyNLoFl5qAe/5UFALg1oQgbXKaxJ1Zpg7hjUVHpbRWT9Vczvk LZlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=G3CDtz9b; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a65480b000000b0052c8d7a08a4si4480819pgs.8.2023.05.22.04.14.24; Mon, 22 May 2023 04:14:39 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20221208 header.b=G3CDtz9b; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbjEVLFB (ORCPT + 99 others); Mon, 22 May 2023 07:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232823AbjEVLEa (ORCPT ); Mon, 22 May 2023 07:04:30 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98B12271C; Mon, 22 May 2023 03:59:30 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-510d967249aso9893825a12.1; Mon, 22 May 2023 03:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684753074; x=1687345074; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QbaFtQY4U1SAGZYtnPdu7mZsLG5dGue95mqtDIfDNho=; b=G3CDtz9bnVsVmqFfLRO45IIz1boAbDjKVkdd+zs/OFV4laduBB9Xp3d4pSzc1CjMSb 2mBDqIkjBHBFkNwWyLScLiPLjpaYqO2qeEIc8vMPNBapYffPuMvzMdLA7bJfYtQZN8Kx TvUdZTOO8OSh0c/Vq5aXLnvS23xpmTumKfQ4jl/xZAiqNirLwkbC7ML+lETlHi4UaAPv IxVxr6Emb5UX8YAB2w+k1c1wApD3g6EYJgvyKOAcDC8WzMrYLvT9MufipHtsLvXv9Awi ZoL7sKRihECyB6m7X4VOAF15oQQdwN7hix2PopHfewdLMp45IpYuyMhV+46MWUeuD6BM 2Zgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684753074; x=1687345074; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QbaFtQY4U1SAGZYtnPdu7mZsLG5dGue95mqtDIfDNho=; b=M7mGDXfyVX4oZHVUKipHG9Fp8I7S/IJ4o4M9pYMJam7+2Q3cFn82nPJPVCo9v+upWG S+fcAClBmoIpRcurzvvbQOhjPT3kxWq0S4RIjKPVqvaVWKQPTxF08HvHN6NOpBQR5Vxu C7D4lppzBqGsIjFgvLiZYj32g5svs+wawUDNDUPXGZHBd/zOHEbE9hsEhz1yrwqkeA2a mrKOZO6cw0a/PJ9Vx52vUYkahvZlk5hDpZ1nIuNu8U55RyLi92gGpuOjT4GOviyrsIut /8CywV5LFf88hwE0ssGyAU+nJksGrYOukrZDoVeIB2aGR7ARSbE2yLcVkctGIalHolYa /r7A== X-Gm-Message-State: AC+VfDxeA7uvsUIY+9FZr2mviObMpBlFofsckQhaJmVvCjpmJtcyV614 X90DE1r1g9aby3plLCq7b5c= X-Received: by 2002:aa7:d956:0:b0:50b:c35b:1ef3 with SMTP id l22-20020aa7d956000000b0050bc35b1ef3mr7288765eds.38.1684753073342; Mon, 22 May 2023 03:57:53 -0700 (PDT) Received: from arinc9-PC.. ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id c3-20020a50f603000000b00510d7152dc7sm3020162edn.30.2023.05.22.03.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 03:57:52 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Frank Wunderlich Cc: Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net] net: ethernet: mtk_eth_soc: fix QoS on DSA MAC on non MTK_NETSYS_V2 SoCs Date: Mon, 22 May 2023 13:57:43 +0300 Message-Id: <20230522105744.37227-1-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Arınç ÜNAL The commit c6d96df9fa2c ("net: ethernet: mtk_eth_soc: drop generic vlan rx offload, only use DSA untagging") makes VLAN RX offloading to be only used on the SoCs without the MTK_NETSYS_V2 ability (which are not just MT7621 and MT7622). The commit disables the proper handling of special tagged (DSA) frames, added with commit 87e3df4961f4 ("net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA"), for non MTK_NETSYS_V2 SoCs when it finds a MAC that does not use DSA. So if the other MAC uses DSA, the CDMQ component transmits DSA tagged frames to the CPU improperly. This issue can be observed on frames with TCP, for example, a TCP speed test using iperf3 won't work. The commit disables the proper handling of special tagged (DSA) frames because it assumes that these SoCs don't use more than one MAC, which is wrong. Although I made Frank address this false assumption on the patch log when they sent the patch on behalf of Felix, the code still made changes with this assumption. Therefore, the proper handling of special tagged (DSA) frames must be kept enabled in all circumstances as it doesn't affect non DSA tagged frames. Hardware DSA untagging, introduced with the commit 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging"), and VLAN RX offloading are operations on the two CDM components of the frame engine, CDMP and CDMQ, which connect to Packet DMA (PDMA) and QoS DMA (QDMA) and are between the MACs and the CPU. These operations apply to all MACs of the SoC so if one MAC uses DSA and the other doesn't, the hardware DSA untagging operation will cause the CDMP component to transmit non DSA tagged frames to the CPU improperly. Since the VLAN RX offloading feature configuration was dropped, VLAN RX offloading can only be used along with hardware DSA untagging. So, for the case above, we need to disable both features and leave it to the CPU, therefore software, to untag the DSA and VLAN tags. So the correct way to handle this is: For all SoCs: Enable the proper handling of special tagged (DSA) frames (MTK_CDMQ_IG_CTRL). For non MTK_NETSYS_V2 SoCs: Enable hardware DSA untagging (MTK_CDMP_IG_CTRL). Enable VLAN RX offloading (MTK_CDMP_EG_CTRL). When a non MTK_NETSYS_V2 SoC MAC does not use DSA: Disable hardware DSA untagging (MTK_CDMP_IG_CTRL). Disable VLAN RX offloading (MTK_CDMP_EG_CTRL). Fixes: c6d96df9fa2c ("net: ethernet: mtk_eth_soc: drop generic vlan rx offload, only use DSA untagging") Signed-off-by: Arınç ÜNAL --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index a75fd072082c..834c644b67db 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3269,18 +3269,14 @@ static int mtk_open(struct net_device *dev) eth->dsa_meta[i] = md_dst; } } else { - /* Hardware special tag parsing needs to be disabled if at least - * one MAC does not use DSA. + /* Hardware DSA untagging and VLAN RX offloading need 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); } -- 2.39.2