Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808389/?format=api
{ "id": 808389, "url": "http://patchwork.ozlabs.org/api/patches/808389/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170831183746.2109-2-vivien.didelot@savoirfairelinux.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170831183746.2109-2-vivien.didelot@savoirfairelinux.com>", "list_archive_url": null, "date": "2017-08-31T18:37:43", "name": "[net-next,1/4] net: dsa: introduce dsa_master", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "c68f8fa34c394e9a2270f9c3fc087e69c945e90f", "submitter": { "id": 15889, "url": "http://patchwork.ozlabs.org/api/people/15889/?format=api", "name": "Vivien Didelot", "email": "vivien.didelot@savoirfairelinux.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170831183746.2109-2-vivien.didelot@savoirfairelinux.com/mbox/", "series": [ { "id": 892, "url": "http://patchwork.ozlabs.org/api/series/892/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=892", "date": "2017-08-31T18:37:46", "name": "net: dsa: add master interface", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/892/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808389/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808389/checks/", "tags": {}, "related": [], "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 3xjrqy3CCvz9s7g\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 1 Sep 2017 04:43:58 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751811AbdHaSnW (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 14:43:22 -0400", "from mail.savoirfairelinux.com ([208.88.110.44]:36920 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751612AbdHaSm0 (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 40C589C1A35;\n\tThu, 31 Aug 2017 14:42:26 -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 3m15DfLcCh2p; 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 EF7D59C1AA6;\n\tThu, 31 Aug 2017 14:42:24 -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 wM3wmigawwgZ; Thu, 31 Aug 2017 14:42:24 -0400 (EDT)", "from weeman.mtl.sfl (unknown [192.168.49.192])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id B69D49C19B8;\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 1/4] net: dsa: introduce dsa_master", "Date": "Thu, 31 Aug 2017 14:37:43 -0400", "Message-Id": "<20170831183746.2109-2-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": "Add a new dsa_master structure to represent the DSA switch port\nphysically linked to the CPU master Ethernet device.\n\nThis device, a.k.a. a CPU port, is responsible to receive/send frames\nfrom/to the DSA slave ports, a.k.a. user ports.\n\nFor the moment, this structure only contains a pointer to a dsa_port\n(i.e. the switch device side) and a pointer to the master interface\n(i.e. the SoC CPU side).\n\nThe structure will be extended with master-specific data such as the\ntagging operations or the master ethtool_ops copies.\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n---\n drivers/net/dsa/b53/b53_common.c | 4 ++--\n drivers/net/dsa/bcm_sf2.c | 8 ++++----\n drivers/net/dsa/mt7530.c | 4 ++--\n drivers/net/dsa/mv88e6060.c | 2 +-\n drivers/net/dsa/qca8k.c | 2 +-\n include/net/dsa.h | 12 ++++++++----\n net/dsa/Makefile | 2 +-\n net/dsa/dsa2.c | 27 ++++++++++++++-------------\n net/dsa/dsa_priv.h | 8 ++++++--\n net/dsa/legacy.c | 21 ++++++++++++---------\n net/dsa/master.c | 30 ++++++++++++++++++++++++++++++\n net/dsa/slave.c | 6 +-----\n 12 files changed, 82 insertions(+), 44 deletions(-)\n create mode 100644 net/dsa/master.c", "diff": "diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c\nindex 274f3679f33d..798045939281 100644\n--- a/drivers/net/dsa/b53/b53_common.c\n+++ b/drivers/net/dsa/b53/b53_common.c\n@@ -1280,7 +1280,7 @@ EXPORT_SYMBOL(b53_fdb_dump);\n int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br)\n {\n \tstruct b53_device *dev = ds->priv;\n-\ts8 cpu_port = ds->dst->cpu_dp->index;\n+\ts8 cpu_port = ds->dst->master->port->index;\n \tu16 pvlan, reg;\n \tunsigned int i;\n \n@@ -1326,7 +1326,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)\n {\n \tstruct b53_device *dev = ds->priv;\n \tstruct b53_vlan *vl = &dev->vlans[0];\n-\ts8 cpu_port = ds->dst->cpu_dp->index;\n+\ts8 cpu_port = ds->dst->master->port->index;\n \tunsigned int i;\n \tu16 pvlan, reg, pvid;\n \ndiff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c\nindex 8492c9d64004..39468a0c1cee 100644\n--- a/drivers/net/dsa/bcm_sf2.c\n+++ b/drivers/net/dsa/bcm_sf2.c\n@@ -227,7 +227,7 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,\n \t\t\t struct phy_device *phy)\n {\n \tstruct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);\n-\ts8 cpu_port = ds->dst->cpu_dp->index;\n+\ts8 cpu_port = ds->dst->master->port->index;\n \tunsigned int i;\n \tu32 reg;\n \n@@ -788,7 +788,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)\n static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,\n \t\t\t struct ethtool_wolinfo *wol)\n {\n-\tstruct net_device *p = ds->dst->cpu_dp->netdev;\n+\tstruct net_device *p = ds->dst->master->netdev;\n \tstruct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);\n \tstruct ethtool_wolinfo pwol;\n \n@@ -811,9 +811,9 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,\n static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,\n \t\t\t struct ethtool_wolinfo *wol)\n {\n-\tstruct net_device *p = ds->dst->cpu_dp->netdev;\n+\tstruct net_device *p = ds->dst->master->netdev;\n \tstruct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);\n-\ts8 cpu_port = ds->dst->cpu_dp->index;\n+\ts8 cpu_port = ds->dst->master->port->index;\n \tstruct ethtool_wolinfo pwol;\n \n \tp->ethtool_ops->get_wol(p, &pwol);\ndiff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c\nindex c142b97add2c..4998c05dba1b 100644\n--- a/drivers/net/dsa/mt7530.c\n+++ b/drivers/net/dsa/mt7530.c\n@@ -928,11 +928,11 @@ mt7530_setup(struct dsa_switch *ds)\n \tstruct device_node *dn;\n \tstruct mt7530_dummy_poll p;\n \n-\t/* The parent node of cpu_dp->netdev which holds the common system\n+\t/* The parent node of master->netdev which holds the common system\n \t * controller also is the container for two GMACs nodes representing\n \t * as two netdev instances.\n \t */\n-\tdn = ds->dst->cpu_dp->netdev->dev.of_node->parent;\n+\tdn = ds->dst->master->netdev->dev.of_node->parent;\n \tpriv->ethernet = syscon_node_to_regmap(dn);\n \tif (IS_ERR(priv->ethernet))\n \t\treturn PTR_ERR(priv->ethernet);\ndiff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c\nindex dce7fa57eb55..6a30e15b9c01 100644\n--- a/drivers/net/dsa/mv88e6060.c\n+++ b/drivers/net/dsa/mv88e6060.c\n@@ -176,7 +176,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)\n \t\t ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) |\n \t\t (dsa_is_cpu_port(ds, p) ?\n \t\t\tds->enabled_port_mask :\n-\t\t\tBIT(ds->dst->cpu_dp->index)));\n+\t\t\tBIT(ds->dst->master->port->index)));\n \n \t/* Port Association Vector: when learning source addresses\n \t * of packets, add the address to the address database using\ndiff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c\nindex 5ada7a41449c..c34d6c82efb3 100644\n--- a/drivers/net/dsa/qca8k.c\n+++ b/drivers/net/dsa/qca8k.c\n@@ -506,7 +506,7 @@ qca8k_setup(struct dsa_switch *ds)\n \t\tpr_warn(\"regmap initialization failed\");\n \n \t/* Initialize CPU port pad mode (xMII type, delays...) */\n-\tphy_mode = of_get_phy_mode(ds->dst->cpu_dp->dn);\n+\tphy_mode = of_get_phy_mode(ds->dst->master->port->dn);\n \tif (phy_mode < 0) {\n \t\tpr_err(\"Can't find phy-mode for master device\\n\");\n \t\treturn phy_mode;\ndiff --git a/include/net/dsa.h b/include/net/dsa.h\nindex 398ca8d70ccd..217e36cfc69f 100644\n--- a/include/net/dsa.h\n+++ b/include/net/dsa.h\n@@ -138,7 +138,7 @@ struct dsa_switch_tree {\n \t/*\n \t * The switch port to which the CPU is attached.\n \t */\n-\tstruct dsa_port\t\t*cpu_dp;\n+\tstruct dsa_master\t*master;\n \n \t/*\n \t * Data for the individual switch chips.\n@@ -173,6 +173,10 @@ struct dsa_mall_tc_entry {\n \t};\n };\n \n+struct dsa_master {\n+\tstruct dsa_port *port;\n+\tstruct net_device *netdev;\n+};\n \n struct dsa_port {\n \tstruct dsa_switch\t*ds;\n@@ -273,10 +277,10 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)\n \t * Else return the (DSA) port number that connects to the\n \t * switch that is one hop closer to the cpu.\n \t */\n-\tif (dst->cpu_dp->ds == ds)\n-\t\treturn dst->cpu_dp->index;\n+\tif (dst->master->port->ds == ds)\n+\t\treturn dst->master->port->index;\n \telse\n-\t\treturn ds->rtable[dst->cpu_dp->ds->index];\n+\t\treturn ds->rtable[dst->master->port->ds->index];\n }\n \n typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,\ndiff --git a/net/dsa/Makefile b/net/dsa/Makefile\nindex fcce25da937c..2e7ac8bab19d 100644\n--- a/net/dsa/Makefile\n+++ b/net/dsa/Makefile\n@@ -1,6 +1,6 @@\n # the core\n obj-$(CONFIG_NET_DSA) += dsa_core.o\n-dsa_core-y += dsa.o dsa2.o legacy.o port.o slave.o switch.o\n+dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o\n \n # tagging formats\n dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o\ndiff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c\nindex cceaa4dd9f53..4c4381b7aafb 100644\n--- a/net/dsa/dsa2.c\n+++ b/net/dsa/dsa2.c\n@@ -337,7 +337,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)\n \t\treturn err;\n \n \tif (ds->ops->set_addr) {\n-\t\terr = ds->ops->set_addr(ds, dst->cpu_dp->netdev->dev_addr);\n+\t\terr = ds->ops->set_addr(ds, dst->master->netdev->dev_addr);\n \t\tif (err < 0)\n \t\t\treturn err;\n \t}\n@@ -433,8 +433,8 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)\n \t\t\treturn err;\n \t}\n \n-\tif (dst->cpu_dp) {\n-\t\terr = dsa_cpu_port_ethtool_setup(dst->cpu_dp);\n+\tif (dst->master) {\n+\t\terr = dsa_cpu_port_ethtool_setup(dst->master->port);\n \t\tif (err)\n \t\t\treturn err;\n \t}\n@@ -444,7 +444,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)\n \t * sent to the tag format's receive function.\n \t */\n \twmb();\n-\tdst->cpu_dp->netdev->dsa_ptr = dst;\n+\tdst->master->netdev->dsa_ptr = dst;\n \tdst->applied = true;\n \n \treturn 0;\n@@ -458,7 +458,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)\n \tif (!dst->applied)\n \t\treturn;\n \n-\tdst->cpu_dp->netdev->dsa_ptr = NULL;\n+\tdst->master->netdev->dsa_ptr = NULL;\n \n \t/* If we used a tagging format that doesn't have an ethertype\n \t * field, make sure that all packets from this point get sent\n@@ -474,9 +474,9 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)\n \t\tdsa_ds_unapply(dst, ds);\n \t}\n \n-\tif (dst->cpu_dp) {\n-\t\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n-\t\tdst->cpu_dp = NULL;\n+\tif (dst->master) {\n+\t\tdsa_cpu_port_ethtool_restore(dst->master->port);\n+\t\tdst->master = NULL;\n \t}\n \n \tpr_info(\"DSA: tree %d unapplied\\n\", dst->tree);\n@@ -504,9 +504,10 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,\n \tif (!ethernet_dev)\n \t\treturn -EPROBE_DEFER;\n \n-\tif (!dst->cpu_dp) {\n-\t\tdst->cpu_dp = port;\n-\t\tdst->cpu_dp->netdev = ethernet_dev;\n+\tif (!dst->master) {\n+\t\tdst->master = dsa_master_create(port, ethernet_dev);\n+\t\tif (!dst->master)\n+\t\t\treturn -ENOMEM;\n \t}\n \n \t/* Initialize cpu_port_mask now for drv->setup()\n@@ -577,7 +578,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)\n \t\t\treturn err;\n \t}\n \n-\tif (!dst->cpu_dp->netdev) {\n+\tif (!dst->master) {\n \t\tpr_warn(\"Tree has no master device\\n\");\n \t\treturn -EINVAL;\n \t}\n@@ -595,7 +596,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)\n \t\t\t dsa_port_is_cpu(dp))\n \t\t\t\tcontinue;\n \n-\t\t\tdp->cpu_dp = dst->cpu_dp;\n+\t\t\tdp->cpu_dp = dst->master->port;\n \t\t}\n \t}\n \ndiff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h\nindex 9c3eeb72462d..70f576b3d6fb 100644\n--- a/net/dsa/dsa_priv.h\n+++ b/net/dsa/dsa_priv.h\n@@ -112,6 +112,10 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],\n \t\t struct net_device *dev,\n \t\t const unsigned char *addr, u16 vid);\n \n+/* master.c */\n+struct dsa_master *dsa_master_create(struct dsa_port *port,\n+\t\t\t\t struct net_device *netdev);\n+\n /* port.c */\n int dsa_port_set_state(struct dsa_port *dp, u8 state,\n \t\t struct switchdev_trans *trans);\n@@ -177,12 +181,12 @@ 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->cpu_dp->netdev;\n+\treturn p->dp->ds->dst->master->netdev;\n }\n \n static inline struct dsa_port *dsa_get_cpu_port(struct dsa_switch_tree *dst)\n {\n-\treturn dst->cpu_dp;\n+\treturn dst->master->port;\n }\n \n #endif\ndiff --git a/net/dsa/legacy.c b/net/dsa/legacy.c\nindex 91e6f7981d39..7a21415d2a81 100644\n--- a/net/dsa/legacy.c\n+++ b/net/dsa/legacy.c\n@@ -114,13 +114,16 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,\n \t\t\tcontinue;\n \n \t\tif (!strcmp(name, \"cpu\")) {\n-\t\t\tif (dst->cpu_dp) {\n+\t\t\tif (dst->master) {\n \t\t\t\tnetdev_err(master,\n \t\t\t\t\t \"multiple cpu ports?!\\n\");\n \t\t\t\treturn -EINVAL;\n \t\t\t}\n-\t\t\tdst->cpu_dp = &ds->ports[i];\n-\t\t\tdst->cpu_dp->netdev = master;\n+\n+\t\t\tdst->master = dsa_master_create(&ds->ports[i], master);\n+\t\t\tif (!dst->master)\n+\t\t\t\treturn -ENOMEM;\n+\n \t\t\tds->cpu_port_mask |= 1 << i;\n \t\t} else if (!strcmp(name, \"dsa\")) {\n \t\t\tds->dsa_port_mask |= 1 << i;\n@@ -143,7 +146,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,\n \t * tagging protocol to the preferred tagging format of this\n \t * switch.\n \t */\n-\tif (dst->cpu_dp->ds == ds) {\n+\tif (dst->master->port->ds == ds) {\n \t\tenum dsa_tag_protocol tag_protocol;\n \n \t\ttag_protocol = ops->get_tag_protocol(ds);\n@@ -189,7 +192,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,\n \t */\n \tfor (i = 0; i < ds->num_ports; i++) {\n \t\tds->ports[i].dn = cd->port_dn[i];\n-\t\tds->ports[i].cpu_dp = dst->cpu_dp;\n+\t\tds->ports[i].cpu_dp = dst->master->port;\n \n \t\tif (!(ds->enabled_port_mask & (1 << i)))\n \t\t\tcontinue;\n@@ -206,7 +209,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,\n \t\tnetdev_err(master, \"[%d] : can't configure CPU and DSA ports\\n\",\n \t\t\t index);\n \n-\tret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);\n+\tret = dsa_cpu_port_ethtool_setup(ds->dst->master->port);\n \tif (ret)\n \t\treturn ret;\n \n@@ -671,7 +674,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)\n {\n \tint i;\n \n-\tdst->cpu_dp->netdev->dsa_ptr = NULL;\n+\tdst->master->netdev->dsa_ptr = NULL;\n \n \t/* If we used a tagging format that doesn't have an ethertype\n \t * field, make sure that all packets from this point get sent\n@@ -686,9 +689,9 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)\n \t\t\tdsa_switch_destroy(ds);\n \t}\n \n-\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n+\tdsa_cpu_port_ethtool_restore(dst->master->port);\n \n-\tdev_put(dst->cpu_dp->netdev);\n+\tdev_put(dst->master->netdev);\n }\n \n static int dsa_remove(struct platform_device *pdev)\ndiff --git a/net/dsa/master.c b/net/dsa/master.c\nnew file mode 100644\nindex 000000000000..294b82b9c114\n--- /dev/null\n+++ b/net/dsa/master.c\n@@ -0,0 +1,30 @@\n+/*\n+ * Handling of a master port, receiving/sending frames from/to slave ports\n+ *\n+ * Copyright (c) 2017 Savoir-faire Linux Inc.\n+ *\tVivien Didelot <vivien.didelot@savoirfairelinux.com>\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ */\n+\n+#include \"dsa_priv.h\"\n+\n+struct dsa_master *dsa_master_create(struct dsa_port *port,\n+\t\t\t\t struct net_device *netdev)\n+{\n+\tstruct device *dev = port->ds->dev;\n+\tstruct dsa_master *master;\n+\n+\tmaster = devm_kzalloc(dev, sizeof(struct dsa_master), GFP_KERNEL);\n+\tif (!master)\n+\t\treturn NULL;\n+\n+\tmaster->port = port;\n+\tmaster->netdev = netdev;\n+\tmaster->port->netdev = netdev;\n+\n+\treturn master;\n+}\ndiff --git a/net/dsa/slave.c b/net/dsa/slave.c\nindex 78e78a6e6833..6d47eca47a0c 100644\n--- a/net/dsa/slave.c\n+++ b/net/dsa/slave.c\n@@ -1250,15 +1250,11 @@ 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;\n+\tstruct net_device *master = dst->master->netdev;\n \tstruct net_device *slave_dev;\n \tstruct dsa_slave_priv *p;\n-\tstruct dsa_port *cpu_dp;\n \tint ret;\n \n-\tcpu_dp = ds->dst->cpu_dp;\n-\tmaster = cpu_dp->netdev;\n-\n \tslave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,\n \t\t\t\t NET_NAME_UNKNOWN, ether_setup);\n \tif (slave_dev == NULL)\n", "prefixes": [ "net-next", "1/4" ] }