{"id":808385,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808385/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170831183746.2109-5-vivien.didelot@savoirfairelinux.com>","date":"2017-08-31T18:37:46","name":"[net-next,4/4] net: dsa: assign a master to slave ports","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"cd4f61bf9ba7e76e264bd21d63adb62dd06aa094","submitter":{"id":15889,"url":"http://patchwork.ozlabs.org/api/1.0/people/15889/?format=json","name":"Vivien Didelot","email":"vivien.didelot@savoirfairelinux.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.0/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170831183746.2109-5-vivien.didelot@savoirfairelinux.com/mbox/","series":[{"id":892,"url":"http://patchwork.ozlabs.org/api/1.0/series/892/?format=json","date":"2017-08-31T18:37:46","name":"net: dsa: add master interface","version":1,"mbox":"http://patchwork.ozlabs.org/series/892/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808385/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjrpG4fkWz9s7g\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 04:42:30 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751686AbdHaSm2 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 14:42:28 -0400","from mail.savoirfairelinux.com ([208.88.110.44]:36890 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751602AbdHaSm0 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 31 Aug 2017 14:42:26 -0400","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id E450D9C1A81;\n\tThu, 31 Aug 2017 14:42:25 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10032)\n\twith ESMTP id zeEv5PJxaeUJ; Thu, 31 Aug 2017 14:42:25 -0400 (EDT)","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id 2FF0A9C1A9D;\n\tThu, 31 Aug 2017 14:42:25 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10026)\n\twith ESMTP id 6SIQZkuN3gtt; Thu, 31 Aug 2017 14:42:25 -0400 (EDT)","from weeman.mtl.sfl (unknown [192.168.49.192])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id E56119C1A96;\n\tThu, 31 Aug 2017 14:42:24 -0400 (EDT)"],"X-Virus-Scanned":"amavisd-new at mail.savoirfairelinux.com","From":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>","To":"netdev@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tFlorian Fainelli <f.fainelli@gmail.com>, Andrew Lunn <andrew@lunn.ch>,\n\tVivien Didelot <vivien.didelot@savoirfairelinux.com>","Subject":"[PATCH net-next 4/4] net: dsa: assign a master to slave ports","Date":"Thu, 31 Aug 2017 14:37:46 -0400","Message-Id":"<20170831183746.2109-5-vivien.didelot@savoirfairelinux.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170831183746.2109-1-vivien.didelot@savoirfairelinux.com>","References":"<20170831183746.2109-1-vivien.didelot@savoirfairelinux.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Because each DSA slave port may use a different DSA master port, add a\npointer to a master in the slave structure. This is a preparatory patch\nfor multiple CPU ports.\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n---\n net/dsa/dsa_priv.h |  7 ++-----\n net/dsa/slave.c    | 33 ++++++++++++++++++---------------\n 2 files changed, 20 insertions(+), 20 deletions(-)","diff":"diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h\nindex 59f155cbbe87..a8cd6cbe4061 100644\n--- a/net/dsa/dsa_priv.h\n+++ b/net/dsa/dsa_priv.h\n@@ -66,6 +66,8 @@ struct dsa_notifier_vlan_info {\n };\n \n struct dsa_slave_priv {\n+\tstruct dsa_master *master;\n+\n \t/* Copy of the master xmit tagging op for faster access in hot path */\n \tstruct sk_buff *\t(*xmit)(struct sk_buff *skb,\n \t\t\t\t\tstruct net_device *dev);\n@@ -179,9 +181,4 @@ extern const struct dsa_device_ops qca_netdev_ops;\n /* tag_trailer.c */\n extern const struct dsa_device_ops trailer_netdev_ops;\n \n-static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)\n-{\n-\treturn p->dp->ds->dst->master->netdev;\n-}\n-\n #endif\ndiff --git a/net/dsa/slave.c b/net/dsa/slave.c\nindex d5a03ef8d0e0..107ed0c4a850 100644\n--- a/net/dsa/slave.c\n+++ b/net/dsa/slave.c\n@@ -66,7 +66,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n \n-\treturn dsa_master_netdev(p)->ifindex;\n+\treturn p->master->netdev->ifindex;\n }\n \n static int dsa_slave_open(struct net_device *dev)\n@@ -74,7 +74,7 @@ static int dsa_slave_open(struct net_device *dev)\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n \tstruct dsa_port *dp = p->dp;\n \tstruct dsa_switch *ds = dp->ds;\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \tu8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;\n \tint err;\n \n@@ -127,7 +127,7 @@ static int dsa_slave_open(struct net_device *dev)\n static int dsa_slave_close(struct net_device *dev)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \tstruct dsa_switch *ds = p->dp->ds;\n \n \tif (p->phy)\n@@ -154,7 +154,7 @@ static int dsa_slave_close(struct net_device *dev)\n static void dsa_slave_change_rx_flags(struct net_device *dev, int change)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \n \tif (change & IFF_ALLMULTI)\n \t\tdev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);\n@@ -165,7 +165,7 @@ static void dsa_slave_change_rx_flags(struct net_device *dev, int change)\n static void dsa_slave_set_rx_mode(struct net_device *dev)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \n \tdev_mc_sync(master, dev);\n \tdev_uc_sync(master, dev);\n@@ -174,7 +174,7 @@ static void dsa_slave_set_rx_mode(struct net_device *dev)\n static int dsa_slave_set_mac_address(struct net_device *dev, void *a)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \tstruct sockaddr *addr = a;\n \tint err;\n \n@@ -427,7 +427,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)\n \t/* Queue the SKB for transmission on the parent interface, but\n \t * do not modify its EtherType\n \t */\n-\tnskb->dev = dsa_master_netdev(p);\n+\tnskb->dev = p->master->netdev;\n \tdev_queue_xmit(nskb);\n \n \treturn NETDEV_TX_OK;\n@@ -687,7 +687,7 @@ static int dsa_slave_netpoll_setup(struct net_device *dev,\n \t\t\t\t   struct netpoll_info *ni)\n {\n \tstruct dsa_slave_priv *p = netdev_priv(dev);\n-\tstruct net_device *master = dsa_master_netdev(p);\n+\tstruct net_device *master = p->master->netdev;\n \tstruct netpoll *netpoll;\n \tint err = 0;\n \n@@ -1170,7 +1170,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n {\n \tstruct dsa_switch *ds = port->ds;\n \tstruct dsa_switch_tree *dst = ds->dst;\n-\tstruct net_device *master = dst->master->netdev;\n+\tstruct dsa_master *master = dst->master;\n \tstruct net_device *slave_dev;\n \tstruct dsa_slave_priv *p;\n \tint ret;\n@@ -1180,10 +1180,10 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n \tif (slave_dev == NULL)\n \t\treturn -ENOMEM;\n \n-\tslave_dev->features = master->vlan_features | NETIF_F_HW_TC;\n+\tslave_dev->features = master->netdev->vlan_features | NETIF_F_HW_TC;\n \tslave_dev->hw_features |= NETIF_F_HW_TC;\n \tslave_dev->ethtool_ops = &dsa_slave_ethtool_ops;\n-\teth_hw_addr_inherit(slave_dev, master);\n+\teth_hw_addr_inherit(slave_dev, master->netdev);\n \tslave_dev->priv_flags |= IFF_NO_QUEUE;\n \tslave_dev->netdev_ops = &dsa_slave_netdev_ops;\n \tslave_dev->switchdev_ops = &dsa_slave_switchdev_ops;\n@@ -1196,7 +1196,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n \n \tSET_NETDEV_DEV(slave_dev, port->ds->dev);\n \tslave_dev->dev.of_node = port->dn;\n-\tslave_dev->vlan_features = master->vlan_features;\n+\tslave_dev->vlan_features = master->netdev->vlan_features;\n \n \tp = netdev_priv(slave_dev);\n \tp->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);\n@@ -1206,7 +1206,8 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n \t}\n \tp->dp = port;\n \tINIT_LIST_HEAD(&p->mall_tc_list);\n-\tp->xmit = dst->master->tag_ops->xmit;\n+\tp->master = master;\n+\tp->xmit = master->tag_ops->xmit;\n \n \tp->old_pause = -1;\n \tp->old_link = -1;\n@@ -1215,7 +1216,8 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n \tport->netdev = slave_dev;\n \tret = register_netdev(slave_dev);\n \tif (ret) {\n-\t\tnetdev_err(master, \"error %d registering interface %s\\n\",\n+\t\tnetdev_err(master->netdev,\n+\t\t\t   \"error %d registering interface %s\\n\",\n \t\t\t   ret, slave_dev->name);\n \t\tport->netdev = NULL;\n \t\tfree_percpu(p->stats64);\n@@ -1227,7 +1229,8 @@ int dsa_slave_create(struct dsa_port *port, const char *name)\n \n \tret = dsa_slave_phy_setup(p, slave_dev);\n \tif (ret) {\n-\t\tnetdev_err(master, \"error %d setting up slave phy\\n\", ret);\n+\t\tnetdev_err(master->netdev,\n+\t\t\t   \"error %d setting up slave phy\\n\", ret);\n \t\tunregister_netdev(slave_dev);\n \t\tfree_percpu(p->stats64);\n \t\tfree_netdev(slave_dev);\n","prefixes":["net-next","4/4"]}