From nobody Fri Sep 20 18:40:19 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 5C3B3EB64D9 for ; Sat, 17 Jun 2023 06:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbjFQG1L (ORCPT ); Sat, 17 Jun 2023 02:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjFQG1F (ORCPT ); Sat, 17 Jun 2023 02:27:05 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C896E5E; Fri, 16 Jun 2023 23:27:04 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-519c0ad1223so1933048a12.0; Fri, 16 Jun 2023 23:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686983222; x=1689575222; 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=5ETqwYFXP5yK+TdJrVYXjdQ9fA9ImE5ftxIHWarTd9o=; b=nHqrT9Mlkid+cur0QneFzCexGoIZbmibWBPkqs3PdPFkCbHzEGDi6tS3rW9MeMp7kA 6xj70Fb6CgxwR48B1T1mDcmIy/JyPiYywgIlFblOxFBGXAMhk5bMU6JG2tXv9npBCfCW UvAlPILreEnqyS/vzi8/O7fEfhIIZIy7uy6cW5FaB+ySGofd61lLaXTnacpYa4OgQQuN c7rr0LtUsM+J0HeVb1W7uLk2CnUSZgV2crmL7b7MXZ2jpUAYRkCcX96NByV4jQQWOdu7 HMw5meASQYoX/eebQ9I+wu0cApbRln6lktClpaz5G6ntgN/BbV6HTXS8uQ7dWqng+bcQ fI9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686983222; x=1689575222; 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=5ETqwYFXP5yK+TdJrVYXjdQ9fA9ImE5ftxIHWarTd9o=; b=auNaCyZfN+qL5L5pLpDtbFg9Fb6OvS70iIRxiXcsFTe+iaBO2TRVyztfdkMBH6eZyI LwQUaW/SjjWXRJQvKn+olSaXGG81jfUxKJ9Fef5kLNJn6ZxeuTDFDDYeSjNEFXcc2k7L RT+YVu5oBM1f13CGI1rbjyeQgk47ajplw4wVoYq9g7KMPPBU//jS+A7OkM8vzdmeZ6JM Hpe0PGGLt2f+d6dMSenRgvMt5LMUcXbjGcZN2+Gn/2HurSZrU/oX04GM5ca2tB/wyh6M s8Qt9JVEId1WVCUPqCLONOtS0EQqKQON3mbBQDwAUrTNhEwOkqm5MWi8x8TnBodZFnsX +e9Q== X-Gm-Message-State: AC+VfDwC+1PQgayrZCVH3uK7xmsRDwhc3BT2ZParG/bx0+4omYA0XmtB 5fCcOhWZiPHJY1W2LBqd7As= X-Google-Smtp-Source: ACHHUZ64/5pmb6uBvnL4fx+4nHvtRhpIfWy208CSYFEWvOTketFEdZ8wF29wkOF2XVlGxgs0tAvpAA== X-Received: by 2002:a05:6402:1496:b0:504:8929:71ca with SMTP id e22-20020a056402149600b00504892971camr2580162edv.6.1686983222257; Fri, 16 Jun 2023 23:27:02 -0700 (PDT) Received: from arinc9-PC.. ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id n6-20020a056402514600b0051a313a66e8sm1799638edd.45.2023.06.16.23.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 23:27:01 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: Russell King , Landen Chao , Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net v6 1/6] net: dsa: mt7530: set all CPU ports in MT7531_CPU_PMAP Date: Sat, 17 Jun 2023 09:26:44 +0300 Message-Id: <20230617062649.28444-2-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230617062649.28444-1-arinc.unal@arinc9.com> References: <20230617062649.28444-1-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ar=C4=B1n=C3=A7 =C3=9CNAL MT7531_CPU_PMAP represents the destination port mask for trapped-to-CPU frames (further restricted by PCR_MATRIX). Currently the driver sets the first CPU port as the single port in this bit mask, which works fine regardless of whether the device tree defines port 5, 6 or 5+6 as CPU ports. This is because the logic coincides with DSA's logic of picking the first CPU port as the CPU port that all user ports are affine to, by default. An upcoming change would like to influence DSA's selection of the default CPU port to no longer be the first one, and in that case, this logic needs adaptation. Since there is no observed leakage or duplication of frames if all CPU ports are defined in this bit mask, simply include them all. Suggested-by: Russell King (Oracle) Suggested-by: Vladimir Oltean Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Reviewed-by: Vladimir Oltean Reviewed-by: Russell King (Oracle) Reviewed-by: Florian Fainelli --- drivers/net/dsa/mt7530.c | 15 ++++++++------- drivers/net/dsa/mt7530.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 9bc54e1348cb..f8503155f179 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1010,6 +1010,13 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int po= rt) if (priv->id =3D=3D ID_MT7621) mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port)); =20 + /* Add the CPU port to the CPU port bitmap for MT7531 and the switch on + * the MT7988 SoC. Trapped frames will be forwarded to the CPU port that + * is affine to the inbound user port. + */ + if (priv->id =3D=3D ID_MT7531 || priv->id =3D=3D ID_MT7988) + mt7530_set(priv, MT7531_CFC, MT7531_CPU_PMAP(BIT(port))); + /* CPU port gets connected to all user ports of * the switch. */ @@ -2352,15 +2359,9 @@ static int mt7531_setup_common(struct dsa_switch *ds) { struct mt7530_priv *priv =3D ds->priv; - struct dsa_port *cpu_dp; int ret, i; =20 - /* BPDU to CPU port */ - dsa_switch_for_each_cpu_port(cpu_dp, ds) { - mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK, - BIT(cpu_dp->index)); - break; - } + /* Trap BPDUs to the CPU port(s) */ mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, MT753X_BPDU_CPU_ONLY); =20 diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 5084f48a8869..e590cf43f3ae 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -54,6 +54,7 @@ enum mt753x_id { #define MT7531_MIRROR_PORT_GET(x) (((x) >> 16) & MIRROR_MASK) #define MT7531_MIRROR_PORT_SET(x) (((x) & MIRROR_MASK) << 16) #define MT7531_CPU_PMAP_MASK GENMASK(7, 0) +#define MT7531_CPU_PMAP(x) FIELD_PREP(MT7531_CPU_PMAP_MASK, x) =20 #define MT753X_MIRROR_REG(id) ((((id) =3D=3D ID_MT7531) || ((id) =3D=3D I= D_MT7988)) ? \ MT7531_CFC : MT7530_MFC) --=20 2.39.2