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 | |
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>
-rw-r--r-- | arch/arm/plat-orion/common.c | 2 | ||||
-rw-r--r-- | drivers/net/dsa/bcm_sf2.c | 2 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6060.c | 13 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6123_61_65.c | 6 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6131.c | 6 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 6 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 4 | ||||
-rw-r--r-- | include/linux/netdevice.h | 7 | ||||
-rw-r--r-- | include/net/dsa.h | 19 | ||||
-rw-r--r-- | net/dsa/dsa.c | 56 | ||||
-rw-r--r-- | net/dsa/dsa_priv.h | 11 | ||||
-rw-r--r-- | net/dsa/slave.c | 39 | ||||
-rw-r--r-- | net/dsa/tag_brcm.c | 1 | ||||
-rw-r--r-- | net/dsa/tag_dsa.c | 1 | ||||
-rw-r--r-- | net/dsa/tag_edsa.c | 1 | ||||
-rw-r--r-- | net/dsa/tag_trailer.c | 1 |
16 files changed, 101 insertions, 74 deletions
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c index 3ec6e8e8d368..f5b00f41c4f6 100644 --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c | |||
@@ -499,7 +499,7 @@ void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq) | |||
499 | 499 | ||
500 | d->netdev = &orion_ge00.dev; | 500 | d->netdev = &orion_ge00.dev; |
501 | for (i = 0; i < d->nr_chips; i++) | 501 | for (i = 0; i < d->nr_chips; i++) |
502 | d->chip[i].mii_bus = &orion_ge00_shared.dev; | 502 | d->chip[i].host_dev = &orion_ge00_shared.dev; |
503 | orion_switch_device.dev.platform_data = d; | 503 | orion_switch_device.dev.platform_data = d; |
504 | 504 | ||
505 | platform_device_register(&orion_switch_device); | 505 | platform_device_register(&orion_switch_device); |
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index e9918c7f1792..02d7db320d90 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c | |||
@@ -129,7 +129,7 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds) | |||
129 | return BCM_SF2_STATS_SIZE; | 129 | return BCM_SF2_STATS_SIZE; |
130 | } | 130 | } |
131 | 131 | ||
132 | static char *bcm_sf2_sw_probe(struct mii_bus *bus, int sw_addr) | 132 | static char *bcm_sf2_sw_probe(struct device *host_dev, int sw_addr) |
133 | { | 133 | { |
134 | return "Broadcom Starfighter 2"; | 134 | return "Broadcom Starfighter 2"; |
135 | } | 135 | } |
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c index d8037c1055ac..776e965dc9f4 100644 --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c | |||
@@ -21,7 +21,8 @@ | |||
21 | 21 | ||
22 | static int reg_read(struct dsa_switch *ds, int addr, int reg) | 22 | static int reg_read(struct dsa_switch *ds, int addr, int reg) |
23 | { | 23 | { |
24 | return mdiobus_read(ds->master_mii_bus, ds->pd->sw_addr + addr, reg); | 24 | return mdiobus_read(to_mii_bus(ds->master_dev), |
25 | ds->pd->sw_addr + addr, reg); | ||
25 | } | 26 | } |
26 | 27 | ||
27 | #define REG_READ(addr, reg) \ | 28 | #define REG_READ(addr, reg) \ |
@@ -37,8 +38,8 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) | |||
37 | 38 | ||
38 | static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) | 39 | static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) |
39 | { | 40 | { |
40 | return mdiobus_write(ds->master_mii_bus, ds->pd->sw_addr + addr, | 41 | return mdiobus_write(to_mii_bus(ds->master_dev), |
41 | reg, val); | 42 | ds->pd->sw_addr + addr, reg, val); |
42 | } | 43 | } |
43 | 44 | ||
44 | #define REG_WRITE(addr, reg, val) \ | 45 | #define REG_WRITE(addr, reg, val) \ |
@@ -50,10 +51,14 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) | |||
50 | return __ret; \ | 51 | return __ret; \ |
51 | }) | 52 | }) |
52 | 53 | ||
53 | static char *mv88e6060_probe(struct mii_bus *bus, int sw_addr) | 54 | static char *mv88e6060_probe(struct device *host_dev, int sw_addr) |
54 | { | 55 | { |
56 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); | ||
55 | int ret; | 57 | int ret; |
56 | 58 | ||
59 | if (bus == NULL) | ||
60 | return NULL; | ||
61 | |||
57 | ret = mdiobus_read(bus, sw_addr + REG_PORT(0), 0x03); | 62 | ret = mdiobus_read(bus, sw_addr + REG_PORT(0), 0x03); |
58 | if (ret >= 0) { | 63 | if (ret >= 0) { |
59 | ret &= 0xfff0; | 64 | ret &= 0xfff0; |
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c index 975774f338c2..a332c53ff955 100644 --- a/drivers/net/dsa/mv88e6123_61_65.c +++ b/drivers/net/dsa/mv88e6123_61_65.c | |||
@@ -17,10 +17,14 @@ | |||
17 | #include <net/dsa.h> | 17 | #include <net/dsa.h> |
18 | #include "mv88e6xxx.h" | 18 | #include "mv88e6xxx.h" |
19 | 19 | ||
20 | static char *mv88e6123_61_65_probe(struct mii_bus *bus, int sw_addr) | 20 | static char *mv88e6123_61_65_probe(struct device *host_dev, int sw_addr) |
21 | { | 21 | { |
22 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); | ||
22 | int ret; | 23 | int ret; |
23 | 24 | ||
25 | if (bus == NULL) | ||
26 | return NULL; | ||
27 | |||
24 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); | 28 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); |
25 | if (ret >= 0) { | 29 | if (ret >= 0) { |
26 | if (ret == 0x1212) | 30 | if (ret == 0x1212) |
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index 35541f2ceca3..244c735014fa 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c | |||
@@ -22,10 +22,14 @@ | |||
22 | #define ID_6095 0x0950 | 22 | #define ID_6095 0x0950 |
23 | #define ID_6131 0x1060 | 23 | #define ID_6131 0x1060 |
24 | 24 | ||
25 | static char *mv88e6131_probe(struct mii_bus *bus, int sw_addr) | 25 | static char *mv88e6131_probe(struct device *host_dev, int sw_addr) |
26 | { | 26 | { |
27 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); | ||
27 | int ret; | 28 | int ret; |
28 | 29 | ||
30 | if (bus == NULL) | ||
31 | return NULL; | ||
32 | |||
29 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); | 33 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); |
30 | if (ret >= 0) { | 34 | if (ret >= 0) { |
31 | ret &= 0xfff0; | 35 | ret &= 0xfff0; |
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 03a70069a8c6..6365e30138af 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -17,10 +17,14 @@ | |||
17 | #include <net/dsa.h> | 17 | #include <net/dsa.h> |
18 | #include "mv88e6xxx.h" | 18 | #include "mv88e6xxx.h" |
19 | 19 | ||
20 | static char *mv88e6171_probe(struct mii_bus *bus, int sw_addr) | 20 | static char *mv88e6171_probe(struct device *host_dev, int sw_addr) |
21 | { | 21 | { |
22 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); | ||
22 | int ret; | 23 | int ret; |
23 | 24 | ||
25 | if (bus == NULL) | ||
26 | return NULL; | ||
27 | |||
24 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); | 28 | ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); |
25 | if (ret >= 0) { | 29 | if (ret >= 0) { |
26 | if ((ret & 0xfff0) == 0x1710) | 30 | if ((ret & 0xfff0) == 0x1710) |
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 901d2a9704ef..d6f6428b27dc 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -78,7 +78,7 @@ int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg) | |||
78 | int ret; | 78 | int ret; |
79 | 79 | ||
80 | mutex_lock(&ps->smi_mutex); | 80 | mutex_lock(&ps->smi_mutex); |
81 | ret = __mv88e6xxx_reg_read(ds->master_mii_bus, | 81 | ret = __mv88e6xxx_reg_read(to_mii_bus(ds->master_dev), |
82 | ds->pd->sw_addr, addr, reg); | 82 | ds->pd->sw_addr, addr, reg); |
83 | mutex_unlock(&ps->smi_mutex); | 83 | mutex_unlock(&ps->smi_mutex); |
84 | 84 | ||
@@ -122,7 +122,7 @@ int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) | |||
122 | int ret; | 122 | int ret; |
123 | 123 | ||
124 | mutex_lock(&ps->smi_mutex); | 124 | mutex_lock(&ps->smi_mutex); |
125 | ret = __mv88e6xxx_reg_write(ds->master_mii_bus, | 125 | ret = __mv88e6xxx_reg_write(to_mii_bus(ds->master_dev), |
126 | ds->pd->sw_addr, addr, reg, val); | 126 | ds->pd->sw_addr, addr, reg, val); |
127 | mutex_unlock(&ps->smi_mutex); | 127 | mutex_unlock(&ps->smi_mutex); |
128 | 128 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f9e81d10a3b9..28d4378615e5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1928,13 +1928,6 @@ struct udp_offload { | |||
1928 | struct offload_callbacks callbacks; | 1928 | struct offload_callbacks callbacks; |
1929 | }; | 1929 | }; |
1930 | 1930 | ||
1931 | struct dsa_device_ops { | ||
1932 | netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev); | ||
1933 | int (*rcv)(struct sk_buff *skb, struct net_device *dev, | ||
1934 | struct packet_type *pt, struct net_device *orig_dev); | ||
1935 | }; | ||
1936 | |||
1937 | |||
1938 | /* often modified stats are per cpu, other are shared (netdev->stats) */ | 1931 | /* often modified stats are per cpu, other are shared (netdev->stats) */ |
1939 | struct pcpu_sw_netstats { | 1932 | struct pcpu_sw_netstats { |
1940 | u64 rx_packets; | 1933 | u64 rx_packets; |
diff --git a/include/net/dsa.h b/include/net/dsa.h index 8a8a5d976f97..c779e9bba1b3 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -34,7 +34,7 @@ struct dsa_chip_data { | |||
34 | /* | 34 | /* |
35 | * How to access the switch configuration registers. | 35 | * How to access the switch configuration registers. |
36 | */ | 36 | */ |
37 | struct device *mii_bus; | 37 | struct device *host_dev; |
38 | int sw_addr; | 38 | int sw_addr; |
39 | 39 | ||
40 | /* Device tree node pointer for this specific switch chip | 40 | /* Device tree node pointer for this specific switch chip |
@@ -77,7 +77,7 @@ struct dsa_platform_data { | |||
77 | struct dsa_chip_data *chip; | 77 | struct dsa_chip_data *chip; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | struct dsa_device_ops; | 80 | struct packet_type; |
81 | 81 | ||
82 | struct dsa_switch_tree { | 82 | struct dsa_switch_tree { |
83 | /* | 83 | /* |
@@ -91,7 +91,10 @@ struct dsa_switch_tree { | |||
91 | * protocol to use. | 91 | * protocol to use. |
92 | */ | 92 | */ |
93 | struct net_device *master_netdev; | 93 | struct net_device *master_netdev; |
94 | const struct dsa_device_ops *ops; | 94 | int (*rcv)(struct sk_buff *skb, |
95 | struct net_device *dev, | ||
96 | struct packet_type *pt, | ||
97 | struct net_device *orig_dev); | ||
95 | enum dsa_tag_protocol tag_protocol; | 98 | enum dsa_tag_protocol tag_protocol; |
96 | 99 | ||
97 | /* | 100 | /* |
@@ -131,9 +134,9 @@ struct dsa_switch { | |||
131 | struct dsa_switch_driver *drv; | 134 | struct dsa_switch_driver *drv; |
132 | 135 | ||
133 | /* | 136 | /* |
134 | * Reference to mii bus to use. | 137 | * Reference to host device to use. |
135 | */ | 138 | */ |
136 | struct mii_bus *master_mii_bus; | 139 | struct device *master_dev; |
137 | 140 | ||
138 | /* | 141 | /* |
139 | * Slave mii_bus and devices for the individual ports. | 142 | * Slave mii_bus and devices for the individual ports. |
@@ -175,7 +178,7 @@ struct dsa_switch_driver { | |||
175 | /* | 178 | /* |
176 | * Probing and setup. | 179 | * Probing and setup. |
177 | */ | 180 | */ |
178 | char *(*probe)(struct mii_bus *bus, int sw_addr); | 181 | char *(*probe)(struct device *host_dev, int sw_addr); |
179 | int (*setup)(struct dsa_switch *ds); | 182 | int (*setup)(struct dsa_switch *ds); |
180 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); | 183 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); |
181 | 184 | ||
@@ -210,6 +213,7 @@ struct dsa_switch_driver { | |||
210 | 213 | ||
211 | void register_switch_driver(struct dsa_switch_driver *type); | 214 | void register_switch_driver(struct dsa_switch_driver *type); |
212 | void unregister_switch_driver(struct dsa_switch_driver *type); | 215 | void unregister_switch_driver(struct dsa_switch_driver *type); |
216 | struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); | ||
213 | 217 | ||
214 | static inline void *ds_to_priv(struct dsa_switch *ds) | 218 | static inline void *ds_to_priv(struct dsa_switch *ds) |
215 | { | 219 | { |
@@ -218,7 +222,6 @@ static inline void *ds_to_priv(struct dsa_switch *ds) | |||
218 | 222 | ||
219 | static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) | 223 | static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) |
220 | { | 224 | { |
221 | return dst->tag_protocol != DSA_TAG_PROTO_NONE; | 225 | return dst->rcv != NULL; |
222 | } | 226 | } |
223 | |||
224 | #endif | 227 | #endif |
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 = { |
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 98afed4d92ba..f90899e8ab5a 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h | |||
@@ -12,7 +12,13 @@ | |||
12 | #define __DSA_PRIV_H | 12 | #define __DSA_PRIV_H |
13 | 13 | ||
14 | #include <linux/phy.h> | 14 | #include <linux/phy.h> |
15 | #include <net/dsa.h> | 15 | #include <linux/netdevice.h> |
16 | |||
17 | struct dsa_device_ops { | ||
18 | netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev); | ||
19 | int (*rcv)(struct sk_buff *skb, struct net_device *dev, | ||
20 | struct packet_type *pt, struct net_device *orig_dev); | ||
21 | }; | ||
16 | 22 | ||
17 | struct dsa_slave_priv { | 23 | struct dsa_slave_priv { |
18 | /* | 24 | /* |
@@ -20,6 +26,8 @@ struct dsa_slave_priv { | |||
20 | * switch port. | 26 | * switch port. |
21 | */ | 27 | */ |
22 | struct net_device *dev; | 28 | struct net_device *dev; |
29 | netdev_tx_t (*xmit)(struct sk_buff *skb, | ||
30 | struct net_device *dev); | ||
23 | 31 | ||
24 | /* | 32 | /* |
25 | * Which switch this port is a part of, and the port index | 33 | * Which switch this port is a part of, and the port index |
@@ -43,6 +51,7 @@ struct dsa_slave_priv { | |||
43 | extern char dsa_driver_version[]; | 51 | extern char dsa_driver_version[]; |
44 | 52 | ||
45 | /* slave.c */ | 53 | /* slave.c */ |
54 | extern const struct dsa_device_ops notag_netdev_ops; | ||
46 | void dsa_slave_mii_bus_init(struct dsa_switch *ds); | 55 | void dsa_slave_mii_bus_init(struct dsa_switch *ds); |
47 | struct net_device *dsa_slave_create(struct dsa_switch *ds, | 56 | struct net_device *dsa_slave_create(struct dsa_switch *ds, |
48 | struct device *parent, | 57 | struct device *parent, |
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 809eeb13eb12..90c9689ed362 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
12 | #include <linux/netdevice.h> | ||
13 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
14 | #include <linux/phy.h> | 13 | #include <linux/phy.h> |
15 | #include <linux/of_net.h> | 14 | #include <linux/of_net.h> |
@@ -45,7 +44,7 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds) | |||
45 | ds->slave_mii_bus->write = dsa_slave_phy_write; | 44 | ds->slave_mii_bus->write = dsa_slave_phy_write; |
46 | snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d:%.2x", | 45 | snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d:%.2x", |
47 | ds->index, ds->pd->sw_addr); | 46 | ds->index, ds->pd->sw_addr); |
48 | ds->slave_mii_bus->parent = &ds->master_mii_bus->dev; | 47 | ds->slave_mii_bus->parent = ds->master_dev; |
49 | } | 48 | } |
50 | 49 | ||
51 | 50 | ||
@@ -176,9 +175,8 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
176 | static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev) | 175 | static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev) |
177 | { | 176 | { |
178 | struct dsa_slave_priv *p = netdev_priv(dev); | 177 | struct dsa_slave_priv *p = netdev_priv(dev); |
179 | struct dsa_switch_tree *dst = p->parent->dst; | ||
180 | 178 | ||
181 | return dst->ops->xmit(skb, dev); | 179 | return p->xmit(skb, dev); |
182 | } | 180 | } |
183 | 181 | ||
184 | static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb, | 182 | static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb, |
@@ -325,11 +323,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { | |||
325 | .ndo_do_ioctl = dsa_slave_ioctl, | 323 | .ndo_do_ioctl = dsa_slave_ioctl, |
326 | }; | 324 | }; |
327 | 325 | ||
328 | static const struct dsa_device_ops notag_netdev_ops = { | ||
329 | .xmit = dsa_slave_notag_xmit, | ||
330 | .rcv = NULL, | ||
331 | }; | ||
332 | |||
333 | static void dsa_slave_adjust_link(struct net_device *dev) | 326 | static void dsa_slave_adjust_link(struct net_device *dev) |
334 | { | 327 | { |
335 | struct dsa_slave_priv *p = netdev_priv(dev); | 328 | struct dsa_slave_priv *p = netdev_priv(dev); |
@@ -435,41 +428,41 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, | |||
435 | slave_dev->tx_queue_len = 0; | 428 | slave_dev->tx_queue_len = 0; |
436 | slave_dev->netdev_ops = &dsa_slave_netdev_ops; | 429 | slave_dev->netdev_ops = &dsa_slave_netdev_ops; |
437 | 430 | ||
431 | SET_NETDEV_DEV(slave_dev, parent); | ||
432 | slave_dev->dev.of_node = ds->pd->port_dn[port]; | ||
433 | slave_dev->vlan_features = master->vlan_features; | ||
434 | |||
435 | p = netdev_priv(slave_dev); | ||
436 | p->dev = slave_dev; | ||
437 | p->parent = ds; | ||
438 | p->port = port; | ||
439 | |||
438 | switch (ds->dst->tag_protocol) { | 440 | switch (ds->dst->tag_protocol) { |
439 | #ifdef CONFIG_NET_DSA_TAG_DSA | 441 | #ifdef CONFIG_NET_DSA_TAG_DSA |
440 | case DSA_TAG_PROTO_DSA: | 442 | case DSA_TAG_PROTO_DSA: |
441 | ds->dst->ops = &dsa_netdev_ops; | 443 | p->xmit = dsa_netdev_ops.xmit; |
442 | break; | 444 | break; |
443 | #endif | 445 | #endif |
444 | #ifdef CONFIG_NET_DSA_TAG_EDSA | 446 | #ifdef CONFIG_NET_DSA_TAG_EDSA |
445 | case DSA_TAG_PROTO_EDSA: | 447 | case DSA_TAG_PROTO_EDSA: |
446 | ds->dst->ops = &edsa_netdev_ops; | 448 | p->xmit = edsa_netdev_ops.xmit; |
447 | break; | 449 | break; |
448 | #endif | 450 | #endif |
449 | #ifdef CONFIG_NET_DSA_TAG_TRAILER | 451 | #ifdef CONFIG_NET_DSA_TAG_TRAILER |
450 | case DSA_TAG_PROTO_TRAILER: | 452 | case DSA_TAG_PROTO_TRAILER: |
451 | ds->dst->ops = &trailer_netdev_ops; | 453 | p->xmit = trailer_netdev_ops.xmit; |
452 | break; | 454 | break; |
453 | #endif | 455 | #endif |
454 | #ifdef CONFIG_NET_DSA_TAG_BRCM | 456 | #ifdef CONFIG_NET_DSA_TAG_BRCM |
455 | case DSA_TAG_PROTO_BRCM: | 457 | case DSA_TAG_PROTO_BRCM: |
456 | ds->dst->ops = &brcm_netdev_ops; | 458 | p->xmit = brcm_netdev_ops.xmit; |
457 | break; | 459 | break; |
458 | #endif | 460 | #endif |
459 | default: | 461 | default: |
460 | ds->dst->ops = ¬ag_netdev_ops; | 462 | p->xmit = dsa_slave_notag_xmit; |
461 | break; | 463 | break; |
462 | } | 464 | } |
463 | 465 | ||
464 | SET_NETDEV_DEV(slave_dev, parent); | ||
465 | slave_dev->dev.of_node = ds->pd->port_dn[port]; | ||
466 | slave_dev->vlan_features = master->vlan_features; | ||
467 | |||
468 | p = netdev_priv(slave_dev); | ||
469 | p->dev = slave_dev; | ||
470 | p->parent = ds; | ||
471 | p->port = port; | ||
472 | |||
473 | p->old_pause = -1; | 466 | p->old_pause = -1; |
474 | p->old_link = -1; | 467 | p->old_link = -1; |
475 | p->old_duplex = -1; | 468 | p->old_duplex = -1; |
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index 8fbc21c0de78..83d3572cdb20 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/netdevice.h> | ||
15 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
16 | #include "dsa_priv.h" | 15 | #include "dsa_priv.h" |
17 | 16 | ||
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index d7dbc5bda5c0..ce90c8bdc658 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | #include <linux/etherdevice.h> | 11 | #include <linux/etherdevice.h> |
12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | #include "dsa_priv.h" | 14 | #include "dsa_priv.h" |
16 | 15 | ||
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 6b30abe89183..94fcce778679 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | #include <linux/etherdevice.h> | 11 | #include <linux/etherdevice.h> |
12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | #include "dsa_priv.h" | 14 | #include "dsa_priv.h" |
16 | 15 | ||
diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index 5fe9444842c5..115fdca34077 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | #include <linux/etherdevice.h> | 11 | #include <linux/etherdevice.h> |
12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | #include "dsa_priv.h" | 14 | #include "dsa_priv.h" |
16 | 15 | ||