From patchwork Tue Dec 11 19:33:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 10724563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35BDC13BF for ; Tue, 11 Dec 2018 19:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2590D2ADA3 for ; Tue, 11 Dec 2018 19:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 198742B454; Tue, 11 Dec 2018 19:34:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 136012ADA3 for ; Tue, 11 Dec 2018 19:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Sfduwfc43b4iU/K9ywbPUeYN/NJ2TzIfOq4l884Yzkk=; b=SFl7zu9utNxMrmP06zJEeP4Bbf DW2MdrEP358QGGNTTwg0QfdegInKFXrfMHoFdQzAkbZF6cmhLW3jxygEeOib+BT4NoK+qxREnpeOS N7/+5u+GzE07cRxhwJaL+r8sg6msIKnhIjgDcS9pO/X+Oc5udbRN5cf1SEFIINqgNjelzZzDTH5XN QQTKc3wCLnE/EaP78P7ZKihTQGE45ysH6mH7YJcosSiKTRYoRBYNntNODPqN7hg5F0RUtq8AFXrT5 sNI7jptivmCoV9I+KuoLGpBjH4FdXc5VB7a8t/b37w5yR9WNdacjPjEj7fgtm//hkNJ6DNQHEUfNY cOXLyU9Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWnnj-0000x9-6J; Tue, 11 Dec 2018 19:34:39 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWnnH-0000Rc-5J; Tue, 11 Dec 2018 19:34:14 +0000 Received: from localhost.localdomain ([91.14.83.44]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MWBpJ-1gvMxT2drN-00XLBD; Tue, 11 Dec 2018 20:33:34 +0100 From: Frank Wunderlich To: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 2/7] [DSA] add helper functions Date: Tue, 11 Dec 2018 20:33:09 +0100 Message-Id: <20181211193314.10695-2-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181211193314.10695-1-frank-w@public-files.de> References: <20181211193314.10695-1-frank-w@public-files.de> X-Provags-ID: V03:K1:Q/my6UytJVxyZLtJc7lh5FOPR8E+ADY9dIGQJ6QokjLi/F4DiGf 6YXNBT8dwo2tASrHjKJ0CTlhZxNHf+mRzlED69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4F1y wgTZYTied0AufIIdtTGqtZIQ6juAACNJtvI08fzkaOsZ6C/IIM+9a3YCg/7vg5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181211_113411_498688_892089D2 X-CRM114-Status: GOOD ( 10.51 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Wunderlich MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP based on https://github.com/openwrt/openwrt/blob/master/target/linux/mediatek/patches-4.14/0033-dsa-multi-cpu.patch Signed-off-by: Frank Wunderlich --- include/net/dsa.h | 18 ++++++++++++++++++ net/dsa/dsa2.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 3efa81e08993..612942ac56de 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -319,6 +319,12 @@ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, return ds->rtable[device]; } + +static inline bool dsa_is_upstream_port(struct dsa_switch *ds, int p) +{ + return dsa_is_cpu_port(ds, p) || dsa_is_dsa_port(ds, p); +} + /* Return the local port used to reach the dedicated CPU port */ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) { @@ -331,6 +337,18 @@ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); } +static inline u8 dsa_port_upstream_port(struct dsa_switch *ds, int port) +{ + /* + * If this port has a specific upstream cpu port, use it, + * otherwise use the switch default. + */ + if (ds->ports[port].upstream) + return ds->ports[port].upstream; + else + return dsa_upstream_port(ds, port); +} + typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, bool is_static, void *data); struct dsa_switch_ops { diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index a1917025e155..77420675e9ed 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -255,6 +255,24 @@ static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) dst->cpu_dp = NULL; } +static int dsa_user_parse(struct dsa_port *port, u32 index, + struct dsa_switch *ds) +{ + struct device_node *cpu_port; + const unsigned int *cpu_port_reg; + int cpu_port_index; + + cpu_port = of_parse_phandle(port->dn, "cpu", 0); + if (cpu_port) { + cpu_port_reg = of_get_property(cpu_port, "reg", NULL); + if (!cpu_port_reg) + return -EINVAL; + cpu_port_index = be32_to_cpup(cpu_port_reg); + ds->ports[index].upstream = cpu_port_index; + } + return 0; +} + static int dsa_port_setup(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds;