Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5798556rwr; Mon, 1 May 2023 10:55:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6i30y+4GMas3QB26m9GiZQzpRe1Qzbuw8DCVonJBs6urhimM9/szIjWxREWpfPgHN9vBAD X-Received: by 2002:a17:90b:1892:b0:24d:ebfe:be93 with SMTP id mn18-20020a17090b189200b0024debfebe93mr7379343pjb.37.1682963726742; Mon, 01 May 2023 10:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682963726; cv=none; d=google.com; s=arc-20160816; b=vIJK8EJqfoQlm7JyUDHpyzIGSmW0BB+JZdgBdKM4TvzJ5uKypyXHnaQ7tPPC44/rq4 uMbL+wRL173EeyzuayNxCH+pQ1LQbddkt5CnU2erNUzW/TQ2kwGgLpAeef3FKiCS14p5 e16jmLcw7I4M3CbCpWRVol8laJ1XhHuDUmCfKI0uaCnXB0cHodY/WYjE2N61jzTfSO8T 4MaF81gOvYOwyiCEh+XNoNPxfewSRhE2qB5YPlBOiWmgs3kSmb8lPro/wdYvK83WVGpW yNictI3kg25J9vxvi/E76J0R0go5rbxSKlbmAQJ47CwHV71450odZAJxrNjjzvIayR3S CKiQ== 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=7zn2qiz0PMcDlMBZ9iY+p8RStjdYbRZl/cnGOAd2Vqg=; b=XSXCYMxt6qxjay6ANdiTp3Mwbd3o6krNlXjhhushu4OlYDAbMx+D1fEcm9A0KlJkZl OVHzcyVxL6Zt0dX53NBi7iS9CWglSK5pHe8z1T4e0YR3BugUOwfs1r3Bzh/trfwmArrc ZOcfSXY5dERgD+9UWcYHNkukxL1kxU3XJCEqeGZQyFa0T4UJvAqKWSEdF7cLWAErQZHj Lps445pOY9nUCVVbFjNq6q/cGxP8aZeBEhhHLfN39gUg6mfq01LzBEdFfYrZlnbaG79V BmxJqXxkMrawiMmaVHOdPodb4xhB2550XxPlVLPS+nqRdayPeoD9+UGcsZh+lgNMFzWb w5Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=E909MYKQ; 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 pg8-20020a17090b1e0800b0024be8553ec8si16353653pjb.183.2023.05.01.10.55.14; Mon, 01 May 2023 10:55:26 -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=E909MYKQ; 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 S232523AbjEARsP (ORCPT + 99 others); Mon, 1 May 2023 13:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232513AbjEARsN (ORCPT ); Mon, 1 May 2023 13:48:13 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A08610C6; Mon, 1 May 2023 10:48:12 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-94f7a7a3351so556226166b.2; Mon, 01 May 2023 10:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682963290; x=1685555290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7zn2qiz0PMcDlMBZ9iY+p8RStjdYbRZl/cnGOAd2Vqg=; b=E909MYKQQE2H2eABVhK2NB2EqRseF2MVkG26I7NnkE2LTNq3iiK3sZ81J8yuInxdGL eW3sEbuz5qp4p2RIgknB0EVVXKRnynjZiH0thBBrmil/LtpvY1/bIcpCofrxAHux7e80 SKTbBF3OiYADM3Bb7nxbhGkOyIaP7WmZnHe8BAu8bwPfTLGaudGxhDcyPSl3ewstPzVA lyHqfgjtqYI2UdaRwTle2opR6/x81jeMs6AgrChQM3B2DBFxUL9p2Pu/seAWY/ZTVsww DKEjP4ZsIt5FDfuV+zUnwRLcA+6Xwkhd6k/ny3ZePUqP9Mbcx3xgTRFP1IciGEaoW1B5 0PQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682963290; x=1685555290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7zn2qiz0PMcDlMBZ9iY+p8RStjdYbRZl/cnGOAd2Vqg=; b=FmRsxoCyoMyUoPFdHlKWdetvazxt/OXpobUJlOjVQJSprXyz+KQcA6FlfaWEuxcJ5N OfTKgmR/ItkpyQPwTUIMm9i+v7nMNlogsD79NZhCCLG8SbB6aeHVSu4GyUQj1wOcbVa4 ZdEXp5UJPc34a5N42zixt/sgY8KwDpMts+xi1bKMMjFixFCbxYYXXP6at4bmkeLS/rYo 6VjlHeyDKeNJokBcm/TyIY1gTK/9eiYkFeeuzQwV0itFX0J+qmamvI0bhXeNGLiMtvyO z52WCxRPDoK6L/k/AtlPxGwBusPQOfIO0hFSIknzbQZdxYCVyuJ38Aa4Ai4zpyTC0FP2 UHNQ== X-Gm-Message-State: AC+VfDwf3LpjycDwyRIgehf1p6z83nw4NYohJvKldCK+Qh1AjS2JyJ1O edh4USu4Hz5+HlUVCrUIPOE= X-Received: by 2002:a17:907:a4c:b0:94e:bc04:1e19 with SMTP id be12-20020a1709070a4c00b0094ebc041e19mr12339374ejc.71.1682963290375; Mon, 01 May 2023 10:48:10 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id se20-20020a170907a39400b0095ef737dbd7sm7745282ejc.93.2023.05.01.10.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 10:48:10 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= Cc: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , 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 v2 net 2/2] net: dsa: mt7530: fix network connectivity with multiple CPU ports Date: Mon, 1 May 2023 20:47:43 +0300 Message-Id: <20230501174743.95897-2-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501174743.95897-1-arinc.unal@arinc9.com> References: <20230501174743.95897-1-arinc.unal@arinc9.com> 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 On mt753x_cpu_port_enable() there's code that enables flooding for the CPU port only. Since mt753x_cpu_port_enable() runs twice when both CPU ports are enabled, port 6 becomes the only port to forward the frames to. But port 5 is the active port, so no frames received from the user ports will be forwarded to port 5 which breaks network connectivity. Every bit of the BC_FFP, UNM_FFP, and UNU_FFP bits represents a port. Fix this issue by setting the bit that corresponds to the CPU port without overwriting the other bits. Clear the bits beforehand only for the MT7531 switch. According to the documents MT7621 Giga Switch Programming Guide v0.3 and MT7531 Reference Manual for Development Board v1.0, after reset, the BC_FFP, UNM_FFP, and UNU_FFP bits are set to 1 for MT7531, 0 for MT7530. The commit 5e5502e012b8 ("net: dsa: mt7530: fix roaming from DSA user ports") silently changed the method to set the bits on the MT7530_MFC. Instead of clearing the relevant bits before mt7530_cpu_port_enable() which runs under a for loop, the commit started doing it on mt7530_cpu_port_enable(). Back then, this didn't really matter as only a single CPU port could be used since the CPU port number was hardcoded. The driver was later changed with commit 1f9a6abecf53 ("net: dsa: mt7530: get cpu-port via dp->cpu_dp instead of constant") to retrieve the CPU port via dp->cpu_dp. With that, this silent change became an issue for when using multiple CPU ports. Fixes: 5e5502e012b8 ("net: dsa: mt7530: fix roaming from DSA user ports") Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- v2: Add the fixes tag and information about the commit that caused this issue. --- drivers/net/dsa/mt7530.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 7d9f9563dbda..9bc54e1348cb 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1002,9 +1002,9 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port) mt7530_write(priv, MT7530_PVC_P(port), PORT_SPEC_TAG); - /* Disable flooding by default */ - mt7530_rmw(priv, MT7530_MFC, BC_FFP_MASK | UNM_FFP_MASK | UNU_FFP_MASK, - BC_FFP(BIT(port)) | UNM_FFP(BIT(port)) | UNU_FFP(BIT(port))); + /* Enable flooding on the CPU port */ + mt7530_set(priv, MT7530_MFC, BC_FFP(BIT(port)) | UNM_FFP(BIT(port)) | + UNU_FFP(BIT(port))); /* Set CPU port number */ if (priv->id == ID_MT7621) @@ -2367,6 +2367,10 @@ mt7531_setup_common(struct dsa_switch *ds) /* Enable and reset MIB counters */ mt7530_mib_reset(ds); + /* Disable flooding on all ports */ + mt7530_clear(priv, MT7530_MFC, BC_FFP_MASK | UNM_FFP_MASK | + UNU_FFP_MASK); + for (i = 0; i < MT7530_NUM_PORTS; i++) { /* Disable forwarding by default on all ports */ mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, -- 2.39.2