Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4826250iob; Mon, 9 May 2022 02:32:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy42+xc2vAFsMSsNN5UHags/8nDweGKr+YSnlQW8EaCosn5ofHxn9KnAnoR51gkINzpgPiX X-Received: by 2002:a17:902:8698:b0:158:99d4:6256 with SMTP id g24-20020a170902869800b0015899d46256mr15636371plo.104.1652088721357; Mon, 09 May 2022 02:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652088721; cv=none; d=google.com; s=arc-20160816; b=fzxB8s2BaEPyPNAJ+uXlRqMvNTveESeii9Vc46SWSl1EVObmKhg0jI/MIPIxFSDlpC o0OutVCPBAPQMJlD7ymUfQzeOa96MXLKrkGSNzdVP9G3rbpTcWNHweovjfe/I4Jy1hhB ICoBU+VCVbmQ9Ix0iR+z6aczjyRj47lqc/3eLwJVA9x9Xyoxfi8cvtcodafxu12mu/T2 mi9SW/y0sotZomn95xy4pxg/hDQGZieGVbBvYoVKuhk2ke1UnGs+rKPS0yd0q4F+DCgF 8r2DV6eNx7gmrcE9zCxt7aJl7I0f+ltUA4wih3S1M7owjDfKqRzPPopXNkHklzlvFph6 cQrA== 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=LOzOxFYxSbpxrsLpx0+hJ9+AnJmKyemfOaXKQkmyk/I=; b=cYDevUzCm5CQbONni+kMz17KIsPRBp/dx3+yprhkdOTTaJRb5VLZqyKkhGqKhecEZj vX39CeDBjre8BjlrwKUmcf+rbcF+FPj45iWOWgprt5yItJ+iKCWCI4Zi97bAoo7eNUQh +lQRRGPlCjMgI0SDAK9LavrzH55rqAcV59wVwyJW+jmfGa2RC0FE93YyULde4chqsqt2 UUf2lYsgUxPm3tnD0OpF7k3fzYkxpOs1ayA/YbO3tKTFzM9uY/ok247bqX8mIQb3jyf9 Eus7Vq0XqjgDn6jwor2OOl0eCA4VsDCELX1fBme5gzunznoC6wjQgwJihdn+PBOVDYVR sm8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=i2W2S4MM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n6-20020a056a0007c600b004fae70007c5si12615906pfu.78.2022.05.09.02.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=i2W2S4MM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDDCB20822D; Mon, 9 May 2022 02:19:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446721AbiEGRKC (ORCPT + 99 others); Sat, 7 May 2022 13:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446664AbiEGRIn (ORCPT ); Sat, 7 May 2022 13:08:43 -0400 Received: from mxout1.routing.net (mxout1.routing.net [IPv6:2a03:2900:1:a::a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 996911B781; Sat, 7 May 2022 10:04:56 -0700 (PDT) Received: from mxbox4.masterlogin.de (unknown [192.168.10.79]) by mxout1.routing.net (Postfix) with ESMTP id 6F2893FEC0; Sat, 7 May 2022 17:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1651943094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LOzOxFYxSbpxrsLpx0+hJ9+AnJmKyemfOaXKQkmyk/I=; b=i2W2S4MMMQPNEnQZNnMIeQ7YLVeMPnlYXnCeEZFEarRsdV70cyDvObxpCg4yUmCJR4uLO7 EyTXX1BkNv7OAfdS2x9tlxD34f+tvriRArzBqSZhclUb+sL6zPJhpHsZyrHIUa6KJvrmSl bD50buNofJmdK9QjrctJAC834DTBdHg= Received: from localhost.localdomain (fttx-pool-80.245.74.2.bambit.de [80.245.74.2]) by mxbox4.masterlogin.de (Postfix) with ESMTPSA id 5A958800AB; Sat, 7 May 2022 17:04:53 +0000 (UTC) From: Frank Wunderlich To: linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Heiko Stuebner , Sean Wang , Landen Chao , DENG Qingfang , Peter Geis , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Greg Ungerer , =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= , "Mauro Carvalho Chehab" Subject: [PATCH v3 4/6] net: dsa: mt7530: get cpu-port via dp->cpu_dp instead of constant Date: Sat, 7 May 2022 19:04:38 +0200 Message-Id: <20220507170440.64005-5-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507170440.64005-1-linux@fw-web.de> References: <20220507170440.64005-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mail-ID: d012d05b-052b-4fe5-96f1-fb2d2962997e X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Frank Wunderlich Replace last occurences of hardcoded cpu-port by cpu_dp member of dsa_port struct. Now the constant can be dropped. Suggested-by: Vladimir Oltean Signed-off-by: Frank Wunderlich Reviewed-by: Vladimir Oltean --- drivers/net/dsa/mt7530.c | 27 ++++++++++++++++++++------- drivers/net/dsa/mt7530.h | 1 - 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 144c29f8fefc..8bf27937e577 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1033,6 +1033,7 @@ static int mt7530_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) { + struct dsa_port *dp = dsa_to_port(ds, port); struct mt7530_priv *priv = ds->priv; mutex_lock(&priv->reg_mutex); @@ -1041,7 +1042,11 @@ mt7530_port_enable(struct dsa_switch *ds, int port, * restore the port matrix if the port is the member of a certain * bridge. */ - priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT)); + if (dsa_port_is_user(dp)) { + struct dsa_port *cpu_dp = dp->cpu_dp; + + priv->ports[port].pm |= PCR_MATRIX(BIT(cpu_dp->index)); + } priv->ports[port].enable = true; mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, priv->ports[port].pm); @@ -1190,7 +1195,8 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; - u32 port_bitmap = BIT(MT7530_CPU_PORT); + struct dsa_port *cpu_dp = dp->cpu_dp; + u32 port_bitmap = BIT(cpu_dp->index); struct mt7530_priv *priv = ds->priv; mutex_lock(&priv->reg_mutex); @@ -1267,9 +1273,12 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port) * the CPU port get out of VLAN filtering mode. */ if (all_user_ports_removed) { - mt7530_write(priv, MT7530_PCR_P(MT7530_CPU_PORT), + struct dsa_port *dp = dsa_to_port(ds, port); + struct dsa_port *cpu_dp = dp->cpu_dp; + + mt7530_write(priv, MT7530_PCR_P(cpu_dp->index), PCR_MATRIX(dsa_user_ports(priv->ds))); - mt7530_write(priv, MT7530_PVC_P(MT7530_CPU_PORT), PORT_SPEC_TAG + mt7530_write(priv, MT7530_PVC_P(cpu_dp->index), PORT_SPEC_TAG | PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT)); } } @@ -1307,6 +1316,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge) { struct dsa_port *dp = dsa_to_port(ds, port), *other_dp; + struct dsa_port *cpu_dp = dp->cpu_dp; struct mt7530_priv *priv = ds->priv; mutex_lock(&priv->reg_mutex); @@ -1335,8 +1345,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, */ if (priv->ports[port].enable) mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, - PCR_MATRIX(BIT(MT7530_CPU_PORT))); - priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT)); + PCR_MATRIX(BIT(cpu_dp->index))); + priv->ports[port].pm = PCR_MATRIX(BIT(cpu_dp->index)); /* When a port is removed from the bridge, the port would be set up * back to the default as is at initial boot which is a VLAN-unaware @@ -1503,6 +1513,9 @@ static int mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, struct netlink_ext_ack *extack) { + struct dsa_port *dp = dsa_to_port(ds, port); + struct dsa_port *cpu_dp = dp->cpu_dp; + if (vlan_filtering) { /* The port is being kept as VLAN-unaware port when bridge is * set up with vlan_filtering not being set, Otherwise, the @@ -1510,7 +1523,7 @@ mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering, * for becoming a VLAN-aware port. */ mt7530_port_set_vlan_aware(ds, port); - mt7530_port_set_vlan_aware(ds, MT7530_CPU_PORT); + mt7530_port_set_vlan_aware(ds, cpu_dp->index); } else { mt7530_port_set_vlan_unaware(ds, port); } diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 91508e2feef9..5895bcfc0f7d 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -8,7 +8,6 @@ #define MT7530_NUM_PORTS 7 #define MT7530_NUM_PHYS 5 -#define MT7530_CPU_PORT 6 #define MT7530_NUM_FDB_RECORDS 2048 #define MT7530_ALL_MEMBERS 0xff -- 2.25.1