diff options
author | David S. Miller <davem@davemloft.net> | 2014-09-15 17:24:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-15 17:24:29 -0400 |
commit | 0486b60a8c62d3a9470374601dbd2f5f03afb1dd (patch) | |
tree | 348e36396eda758e021a8473b330c19cd571e76f /net/dsa/dsa.c | |
parent | 6cca9adb786184be21f30be0982e3ea0281f75cb (diff) | |
parent | b4d2394d01bc642e95b2cba956d908423c1bef77 (diff) |
Merge branch 'dsa-next'
Alexander Duyck says:
====================
DSA Cleanups
This patch series does two things, first it cleans up the tag_protocol and
protocol ops being configured seperately. Second it addresses the desire
to split DSA away from relying on a MII bus.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 61f145c44555..b34d6978d773 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -10,7 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
15 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -44,7 +43,7 @@ void unregister_switch_driver(struct dsa_switch_driver *drv) | |||
44 | EXPORT_SYMBOL_GPL(unregister_switch_driver); | 43 | EXPORT_SYMBOL_GPL(unregister_switch_driver); |
45 | 44 | ||
46 | static struct dsa_switch_driver * | 45 | static struct dsa_switch_driver * |
47 | dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name) | 46 | dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name) |
48 | { | 47 | { |
49 | struct dsa_switch_driver *ret; | 48 | struct dsa_switch_driver *ret; |
50 | struct list_head *list; | 49 | struct list_head *list; |
@@ -59,7 +58,7 @@ dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name) | |||
59 | 58 | ||
60 | drv = list_entry(list, struct dsa_switch_driver, list); | 59 | drv = list_entry(list, struct dsa_switch_driver, list); |
61 | 60 | ||
62 | name = drv->probe(bus, sw_addr); | 61 | name = drv->probe(host_dev, sw_addr); |
63 | if (name != NULL) { | 62 | if (name != NULL) { |
64 | ret = drv; | 63 | ret = drv; |
65 | break; | 64 | break; |
@@ -76,7 +75,7 @@ dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name) | |||
76 | /* basic switch operations **************************************************/ | 75 | /* basic switch operations **************************************************/ |
77 | static struct dsa_switch * | 76 | static struct dsa_switch * |
78 | dsa_switch_setup(struct dsa_switch_tree *dst, int index, | 77 | dsa_switch_setup(struct dsa_switch_tree *dst, int index, |
79 | struct device *parent, struct mii_bus *bus) | 78 | struct device *parent, struct device *host_dev) |
80 | { | 79 | { |
81 | struct dsa_chip_data *pd = dst->pd->chip + index; | 80 | struct dsa_chip_data *pd = dst->pd->chip + index; |
82 | struct dsa_switch_driver *drv; | 81 | struct dsa_switch_driver *drv; |
@@ -89,7 +88,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
89 | /* | 88 | /* |
90 | * Probe for switch model. | 89 | * Probe for switch model. |
91 | */ | 90 | */ |
92 | drv = dsa_switch_probe(bus, pd->sw_addr, &name); | 91 | drv = dsa_switch_probe(host_dev, pd->sw_addr, &name); |
93 | if (drv == NULL) { | 92 | if (drv == NULL) { |
94 | printk(KERN_ERR "%s[%d]: could not detect attached switch\n", | 93 | printk(KERN_ERR "%s[%d]: could not detect attached switch\n", |
95 | dst->master_netdev->name, index); | 94 | dst->master_netdev->name, index); |
@@ -110,8 +109,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
110 | ds->index = index; | 109 | ds->index = index; |
111 | ds->pd = dst->pd->chip + index; | 110 | ds->pd = dst->pd->chip + index; |
112 | ds->drv = drv; | 111 | ds->drv = drv; |
113 | ds->master_mii_bus = bus; | 112 | ds->master_dev = host_dev; |
114 | |||
115 | 113 | ||
116 | /* | 114 | /* |
117 | * Validate supplied switch configuration. | 115 | * Validate supplied switch configuration. |
@@ -154,9 +152,34 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
154 | * tagging protocol to the preferred tagging format of this | 152 | * tagging protocol to the preferred tagging format of this |
155 | * switch. | 153 | * switch. |
156 | */ | 154 | */ |
157 | if (ds->dst->cpu_switch == index) | 155 | if (dst->cpu_switch == index) { |
158 | ds->dst->tag_protocol = drv->tag_protocol; | 156 | switch (drv->tag_protocol) { |
157 | #ifdef CONFIG_NET_DSA_TAG_DSA | ||
158 | case DSA_TAG_PROTO_DSA: | ||
159 | dst->rcv = dsa_netdev_ops.rcv; | ||
160 | break; | ||
161 | #endif | ||
162 | #ifdef CONFIG_NET_DSA_TAG_EDSA | ||
163 | case DSA_TAG_PROTO_EDSA: | ||
164 | dst->rcv = edsa_netdev_ops.rcv; | ||
165 | break; | ||
166 | #endif | ||
167 | #ifdef CONFIG_NET_DSA_TAG_TRAILER | ||
168 | case DSA_TAG_PROTO_TRAILER: | ||
169 | dst->rcv = trailer_netdev_ops.rcv; | ||
170 | break; | ||
171 | #endif | ||
172 | #ifdef CONFIG_NET_DSA_TAG_BRCM | ||
173 | case DSA_TAG_PROTO_BRCM: | ||
174 | dst->rcv = brcm_netdev_ops.rcv; | ||
175 | break; | ||
176 | #endif | ||
177 | default: | ||
178 | break; | ||
179 | } | ||
159 | 180 | ||
181 | dst->tag_protocol = drv->tag_protocol; | ||
182 | } | ||
160 | 183 | ||
161 | /* | 184 | /* |
162 | * Do basic register setup. | 185 | * Do basic register setup. |
@@ -261,7 +284,7 @@ static struct device *dev_find_class(struct device *parent, char *class) | |||
261 | return device_find_child(parent, class, dev_is_class); | 284 | return device_find_child(parent, class, dev_is_class); |
262 | } | 285 | } |
263 | 286 | ||
264 | static struct mii_bus *dev_to_mii_bus(struct device *dev) | 287 | struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev) |
265 | { | 288 | { |
266 | struct device *d; | 289 | struct device *d; |
267 | 290 | ||
@@ -277,6 +300,7 @@ static struct mii_bus *dev_to_mii_bus(struct device *dev) | |||
277 | 300 | ||
278 | return NULL; | 301 | return NULL; |
279 | } | 302 | } |
303 | EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus); | ||
280 | 304 | ||
281 | static struct net_device *dev_to_net_device(struct device *dev) | 305 | static struct net_device *dev_to_net_device(struct device *dev) |
282 | { | 306 | { |
@@ -542,17 +566,9 @@ static int dsa_probe(struct platform_device *pdev) | |||
542 | dst->cpu_port = -1; | 566 | dst->cpu_port = -1; |
543 | 567 | ||
544 | for (i = 0; i < pd->nr_chips; i++) { | 568 | for (i = 0; i < pd->nr_chips; i++) { |
545 | struct mii_bus *bus; | ||
546 | struct dsa_switch *ds; | 569 | struct dsa_switch *ds; |
547 | 570 | ||
548 | bus = dev_to_mii_bus(pd->chip[i].mii_bus); | 571 | ds = dsa_switch_setup(dst, i, &pdev->dev, pd->chip[i].host_dev); |
549 | if (bus == NULL) { | ||
550 | printk(KERN_ERR "%s[%d]: no mii bus found for " | ||
551 | "dsa switch\n", dev->name, i); | ||
552 | continue; | ||
553 | } | ||
554 | |||
555 | ds = dsa_switch_setup(dst, i, &pdev->dev, bus); | ||
556 | if (IS_ERR(ds)) { | 572 | if (IS_ERR(ds)) { |
557 | printk(KERN_ERR "%s[%d]: couldn't create dsa switch " | 573 | printk(KERN_ERR "%s[%d]: couldn't create dsa switch " |
558 | "instance (error %ld)\n", dev->name, i, | 574 | "instance (error %ld)\n", dev->name, i, |
@@ -626,7 +642,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, | |||
626 | return 0; | 642 | return 0; |
627 | } | 643 | } |
628 | 644 | ||
629 | return dst->ops->rcv(skb, dev, pt, orig_dev); | 645 | return dst->rcv(skb, dev, pt, orig_dev); |
630 | } | 646 | } |
631 | 647 | ||
632 | static struct packet_type dsa_pack_type __read_mostly = { | 648 | static struct packet_type dsa_pack_type __read_mostly = { |