From patchwork Tue Dec 11 19:33:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 10724567 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 EDB4513BF for ; Tue, 11 Dec 2018 19:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF1792ADA3 for ; Tue, 11 Dec 2018 19:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D33E22B454; Tue, 11 Dec 2018 19:34:45 +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 7398C2ADA3 for ; Tue, 11 Dec 2018 19:34:45 +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=hPEgmU1A+AzhiEAuGzCP2KyQlP92pznPKY66BcwOgFU=; b=jmLoCfDRnWoQAGCL4TcijG0d/s 5PHj3X5DMt2MoBKM6UzD524FJ3eQ9KrxJrE7L5ZP46ZITRxR2behbSgFSvmzqC6SbqLDTAXPYjxjG Fcwb0LMtNxMhGqCQWTgvl7o6j1fshY9ExRY5I3zoUyV9+FvV8BLFdSbeqom0WsEOCD2STsTArU8nm 5+xdh8jYpJ5RxQ5e6AsfHXoaadd9tnJIm2uWk42U2SyRK0K9EViQCqMQSfbz9Rxcmtiuk96wqNr1/ NsKnTWWueIOinl2wTAZLx48FafOK4OX0LAgBCcIha97UIqP7Ns96KgA8EcTUKank8X+ArP7uNWRDb oZHMuWYw==; 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 1gWnnn-00011Z-BG; Tue, 11 Dec 2018 19:34:43 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWnnG-0000RW-9Q; 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 0LsCdj-1hamJM3fcl-013wyj; Tue, 11 Dec 2018 20:33:36 +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 3/7] [DSA] adding handling of second CPU-Port Date: Tue, 11 Dec 2018 20:33:10 +0100 Message-Id: <20181211193314.10695-3-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:uULslvaJwqYnz381Koxpp6SKyzdTC4qeUILpCFIU4cdT8rKSU56 iv/wHJ6crRXZ/tTwcyFwxGkf8fi9X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Qlr6P82Lp0x+uKB3hLdaKu3/5rJWj3as7MTThsmBTU0jMOFK6+S+C5M14F+4/ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181211_113410_687399_B7A48729 X-CRM114-Status: GOOD ( 12.01 ) 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 --- net/dsa/dsa2.c | 18 ++++++++++++++++++ net/dsa/slave.c | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 77420675e9ed..4a6ebfe647f0 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -303,6 +303,8 @@ static int dsa_port_setup(struct dsa_port *dp) ds->index, dp->index); return err; } + if (dp->master) + dp->master->dsa_ptr = dp; break; case DSA_PORT_TYPE_DSA: /* dp->index is used now as port_number. However @@ -323,12 +325,17 @@ static int dsa_port_setup(struct dsa_port *dp) devlink_port_attrs_set(&dp->devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL, dp->index, false, 0); + err = dsa_user_parse(dp, dp->index, ds); + if (err) + return err; + err = dsa_slave_create(dp); if (err) dev_err(ds->dev, "failed to create slave for port %d.%d\n", ds->index, dp->index); else devlink_port_type_eth_set(&dp->devlink_port, dp->slave); + break; } @@ -344,6 +351,14 @@ static void dsa_port_teardown(struct dsa_port *dp) case DSA_PORT_TYPE_UNUSED: break; case DSA_PORT_TYPE_CPU: + dsa_port_link_unregister_of(dp); + if (dp->master) + dp->master->dsa_ptr = NULL; + if (dp->ethernet) { + dev_put(dp->ethernet); + dp->ethernet = NULL; + } + break; case DSA_PORT_TYPE_DSA: dsa_port_link_unregister_of(dp); break; @@ -598,6 +613,9 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master) dp->master = master; dp->dst = dst; + dev_hold(master); + ds->ports[dp->index].ethernet = master; + return 0; } diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 7d0c19e7edcf..f0fdb9e5d05f 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1312,11 +1312,11 @@ static void dsa_slave_notify(struct net_device *dev, unsigned long val) int dsa_slave_create(struct dsa_port *port) { const struct dsa_port *cpu_dp = port->cpu_dp; - struct net_device *master = cpu_dp->master; struct dsa_switch *ds = port->ds; const char *name = port->name; struct net_device *slave_dev; struct dsa_slave_priv *p; + struct net_device *master = ds->ports[port->upstream].ethernet; int ret; if (!ds->num_tx_queues) @@ -1355,6 +1355,7 @@ int dsa_slave_create(struct dsa_port *port) p->dp = port; INIT_LIST_HEAD(&p->mall_tc_list); p->xmit = cpu_dp->tag_ops->xmit; + p->master = master; port->slave = slave_dev; netif_carrier_off(slave_dev);