Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2008661rwd; Thu, 15 Jun 2023 20:13:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rzGyHXky60UIZEYCGKShXSdgrXwPex8u9QYo4CmZYeoFTAX97klu8QwznCdEGGi5IlzCT X-Received: by 2002:a05:6a00:174d:b0:64c:c5f9:1533 with SMTP id j13-20020a056a00174d00b0064cc5f91533mr943371pfc.33.1686885207483; Thu, 15 Jun 2023 20:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686885207; cv=none; d=google.com; s=arc-20160816; b=F1mCj9JIZuU7qMCx6jLPOYU59hv7f0AK3ME98p4hVvHKEM72uz9y7gNleUiNgnP4Dk 7VqdtvQnOtSO6iWZZ9YUuzd1zorh/pnebMvEON+mNYpRIF387tTbJlUHGmL1wRQ3z6y2 JhPdlAMdBwe4GSSE1sTPEJUkEA9Go3hyuQerXEz5gDmyfTwVMwNLwFVRxZLtZutjc75i rSW250sxJGFEHioptzkupFN4gpCe1gJGZdBTRDYsS5tUUX//nWiq+QJYx0gEDfE8vHfG qqpP3cdYgkZL9SXmHTAXEPi0M6T9jrkmEM82Wdk+Ekj15irh0tgPSa0UNaP1wbUQKALq AXww== 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=5teyYXVySChYV/2XSD9vMPokSMgSc3gjTsNzsa7EAFM=; b=U9OpHpmm14ZAGowAadzl+9vTZ/3K9L3Nz5ae6ZttL70U7RF/5YDw/NToEHHuvnsAgD x78EFmLVUZwghuJpwvENvJlJJR1ZhF+7tEQcj7xPDzrXCX/Fyhvjx72zd6pNKLDzqr2/ kWMzJCtkoePtAEtnSRAulHG8PoZcEm4eQDNvwURlmIu7SdcGXmFzCbs2XemUdwpGQqM0 jCiR/b/djmG0OtNQTYFfcV2s7pP4DS74RlWul7snbeAdHxvF6l/nRU7zXzxwZ5r4ZJlU oYDnDfGbkPl6vsZVz+wgFneKvgtJ8Bz79dK6BqTm2w6viy0thcKVEpsu12Z0JeK3YpXj yVyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=GNGMlYrD; 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 p37-20020a635b25000000b00550e8b3614asi1981459pgb.901.2023.06.15.20.13.15; Thu, 15 Jun 2023 20:13:27 -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=GNGMlYrD; 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 S240000AbjFPCxi (ORCPT + 99 others); Thu, 15 Jun 2023 22:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237804AbjFPCxg (ORCPT ); Thu, 15 Jun 2023 22:53:36 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB3A2953; Thu, 15 Jun 2023 19:53:35 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2b448cf5d83so1787481fa.1; Thu, 15 Jun 2023 19:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686884013; x=1689476013; 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=5teyYXVySChYV/2XSD9vMPokSMgSc3gjTsNzsa7EAFM=; b=GNGMlYrDetZ6ICqbhwc+puCCyE0c6rBFCkQ8b2eeddMC1qIzcXriAtlIDfPp1ocvIQ Y85D0wSVo17OGLjrALMWSfJ7CC84T3mXIEpEOqin4Ce6pvn+sj9Eh6aXApRESdK5nO1T M0Uzch3MQyKSoV0y+PuLiq1vvpZlmwV3RInYVeJX7xu0kHE6bJkcBm4EIAGUfLE4fcl+ Azz9yUjzTf4HOjqUJoF+0yCu17FhRfHghSHqbLXk+htf8e022ymnlP+PCDnDwI5kiqow uHsr0hCZ56YmvWc1UwNKGktZcBsdqep4u3a1dzgu4FndnRaYK6Vql5XOwRj5p1j2G+62 AURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686884013; x=1689476013; 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=5teyYXVySChYV/2XSD9vMPokSMgSc3gjTsNzsa7EAFM=; b=Bjn7/jt/sue6spbkYfBj24PrJXhPjv5tb1UXeNn9SBLvzkmexwVybop/2ZEhsEzIih yf9Rk53ya4yDADstexC8XjJFsToarBGeieFnPa0mWmCIiYBkILCm0GHyJmR+zkC7zdPz oGoMV1kO0W9SP5Jw3WJC9m+1W/OBTnDPyAj7IHZI+Bc2JmVm7usyU3MgLCd0GBxZy1lE HEFWUaiI3ts+VAUqcPjylduzu7y6uCJv5dqFaufaafilTrQhKTWazUQ4V4N3/dX8Bb+x 73i9sKQzRNfYlGsaNT4/Kw4hbiC30nKLZvch3tn6BoX9IHQ00i2gcuM0CLTygKqN+6n6 6Wcw== X-Gm-Message-State: AC+VfDzOYiI7urAXztARuQv1bU3FfW86IoOQHPpAaLeM4J7KswYt9+IN vH5Kgf8kiVM1HLbSM4xMg4U= X-Received: by 2002:a2e:98d6:0:b0:2af:3141:a52b with SMTP id s22-20020a2e98d6000000b002af3141a52bmr710339ljj.22.1686884013304; Thu, 15 Jun 2023 19:53:33 -0700 (PDT) Received: from arinc9-Xeront.. (athedsl-404045.home.otenet.gr. [79.131.130.75]) by smtp.gmail.com with ESMTPSA id v15-20020a1cf70f000000b003f8d770e935sm890328wmh.0.2023.06.15.19.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 19:53:32 -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: 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 v5 1/6] net: dsa: mt7530: set all CPU ports in MT7531_CPU_PMAP Date: Fri, 16 Jun 2023 05:53:22 +0300 Message-Id: <20230616025327.12652-2-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616025327.12652-1-arinc.unal@arinc9.com> References: <20230616025327.12652-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 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ınç ÜNAL --- 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..0a5237793209 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 port) if (priv->id == ID_MT7621) mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port)); + /* Add the CPU port to the CPU port bitmap for MT7531 and the switch on + * the MT7988 SoC. Trapped frames will be trapped to the CPU port that + * is affine to the inbound user port. + */ + if (priv->id == ID_MT7531 || priv->id == 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 = ds->priv; - struct dsa_port *cpu_dp; int ret, i; - /* 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); 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) #define MT753X_MIRROR_REG(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \ MT7531_CFC : MT7530_MFC) -- 2.39.2