diff options
Diffstat (limited to 'net/dsa/slave.c')
-rw-r--r-- | net/dsa/slave.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a68fd79e9eca..ed131181215d 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * net/dsa/slave.c - Slave device handling | 2 | * net/dsa/slave.c - Slave device handling |
3 | * Copyright (c) 2008 Marvell Semiconductor | 3 | * Copyright (c) 2008-2009 Marvell Semiconductor |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -19,7 +19,7 @@ static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg) | |||
19 | { | 19 | { |
20 | struct dsa_switch *ds = bus->priv; | 20 | struct dsa_switch *ds = bus->priv; |
21 | 21 | ||
22 | if (ds->valid_port_mask & (1 << addr)) | 22 | if (ds->phys_port_mask & (1 << addr)) |
23 | return ds->drv->phy_read(ds, addr, reg); | 23 | return ds->drv->phy_read(ds, addr, reg); |
24 | 24 | ||
25 | return 0xffff; | 25 | return 0xffff; |
@@ -29,7 +29,7 @@ static int dsa_slave_phy_write(struct mii_bus *bus, int addr, int reg, u16 val) | |||
29 | { | 29 | { |
30 | struct dsa_switch *ds = bus->priv; | 30 | struct dsa_switch *ds = bus->priv; |
31 | 31 | ||
32 | if (ds->valid_port_mask & (1 << addr)) | 32 | if (ds->phys_port_mask & (1 << addr)) |
33 | return ds->drv->phy_write(ds, addr, reg, val); | 33 | return ds->drv->phy_write(ds, addr, reg, val); |
34 | 34 | ||
35 | return 0; | 35 | return 0; |
@@ -43,15 +43,24 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds) | |||
43 | ds->slave_mii_bus->write = dsa_slave_phy_write; | 43 | ds->slave_mii_bus->write = dsa_slave_phy_write; |
44 | snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s:%.2x", | 44 | snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s:%.2x", |
45 | ds->master_mii_bus->id, ds->pd->sw_addr); | 45 | ds->master_mii_bus->id, ds->pd->sw_addr); |
46 | ds->slave_mii_bus->parent = &(ds->master_mii_bus->dev); | 46 | ds->slave_mii_bus->parent = &ds->master_mii_bus->dev; |
47 | } | 47 | } |
48 | 48 | ||
49 | 49 | ||
50 | /* slave device handling ****************************************************/ | 50 | /* slave device handling ****************************************************/ |
51 | static int dsa_slave_init(struct net_device *dev) | ||
52 | { | ||
53 | struct dsa_slave_priv *p = netdev_priv(dev); | ||
54 | |||
55 | dev->iflink = p->parent->dst->master_netdev->ifindex; | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
51 | static int dsa_slave_open(struct net_device *dev) | 60 | static int dsa_slave_open(struct net_device *dev) |
52 | { | 61 | { |
53 | struct dsa_slave_priv *p = netdev_priv(dev); | 62 | struct dsa_slave_priv *p = netdev_priv(dev); |
54 | struct net_device *master = p->parent->master_netdev; | 63 | struct net_device *master = p->parent->dst->master_netdev; |
55 | int err; | 64 | int err; |
56 | 65 | ||
57 | if (!(master->flags & IFF_UP)) | 66 | if (!(master->flags & IFF_UP)) |
@@ -89,7 +98,7 @@ out: | |||
89 | static int dsa_slave_close(struct net_device *dev) | 98 | static int dsa_slave_close(struct net_device *dev) |
90 | { | 99 | { |
91 | struct dsa_slave_priv *p = netdev_priv(dev); | 100 | struct dsa_slave_priv *p = netdev_priv(dev); |
92 | struct net_device *master = p->parent->master_netdev; | 101 | struct net_device *master = p->parent->dst->master_netdev; |
93 | 102 | ||
94 | dev_mc_unsync(master, dev); | 103 | dev_mc_unsync(master, dev); |
95 | dev_unicast_unsync(master, dev); | 104 | dev_unicast_unsync(master, dev); |
@@ -107,7 +116,7 @@ static int dsa_slave_close(struct net_device *dev) | |||
107 | static void dsa_slave_change_rx_flags(struct net_device *dev, int change) | 116 | static void dsa_slave_change_rx_flags(struct net_device *dev, int change) |
108 | { | 117 | { |
109 | struct dsa_slave_priv *p = netdev_priv(dev); | 118 | struct dsa_slave_priv *p = netdev_priv(dev); |
110 | struct net_device *master = p->parent->master_netdev; | 119 | struct net_device *master = p->parent->dst->master_netdev; |
111 | 120 | ||
112 | if (change & IFF_ALLMULTI) | 121 | if (change & IFF_ALLMULTI) |
113 | dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1); | 122 | dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1); |
@@ -118,7 +127,7 @@ static void dsa_slave_change_rx_flags(struct net_device *dev, int change) | |||
118 | static void dsa_slave_set_rx_mode(struct net_device *dev) | 127 | static void dsa_slave_set_rx_mode(struct net_device *dev) |
119 | { | 128 | { |
120 | struct dsa_slave_priv *p = netdev_priv(dev); | 129 | struct dsa_slave_priv *p = netdev_priv(dev); |
121 | struct net_device *master = p->parent->master_netdev; | 130 | struct net_device *master = p->parent->dst->master_netdev; |
122 | 131 | ||
123 | dev_mc_sync(master, dev); | 132 | dev_mc_sync(master, dev); |
124 | dev_unicast_sync(master, dev); | 133 | dev_unicast_sync(master, dev); |
@@ -127,7 +136,7 @@ static void dsa_slave_set_rx_mode(struct net_device *dev) | |||
127 | static int dsa_slave_set_mac_address(struct net_device *dev, void *a) | 136 | static int dsa_slave_set_mac_address(struct net_device *dev, void *a) |
128 | { | 137 | { |
129 | struct dsa_slave_priv *p = netdev_priv(dev); | 138 | struct dsa_slave_priv *p = netdev_priv(dev); |
130 | struct net_device *master = p->parent->master_netdev; | 139 | struct net_device *master = p->parent->dst->master_netdev; |
131 | struct sockaddr *addr = a; | 140 | struct sockaddr *addr = a; |
132 | int err; | 141 | int err; |
133 | 142 | ||
@@ -288,6 +297,7 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { | |||
288 | 297 | ||
289 | #ifdef CONFIG_NET_DSA_TAG_DSA | 298 | #ifdef CONFIG_NET_DSA_TAG_DSA |
290 | static const struct net_device_ops dsa_netdev_ops = { | 299 | static const struct net_device_ops dsa_netdev_ops = { |
300 | .ndo_init = dsa_slave_init, | ||
291 | .ndo_open = dsa_slave_open, | 301 | .ndo_open = dsa_slave_open, |
292 | .ndo_stop = dsa_slave_close, | 302 | .ndo_stop = dsa_slave_close, |
293 | .ndo_start_xmit = dsa_xmit, | 303 | .ndo_start_xmit = dsa_xmit, |
@@ -300,6 +310,7 @@ static const struct net_device_ops dsa_netdev_ops = { | |||
300 | #endif | 310 | #endif |
301 | #ifdef CONFIG_NET_DSA_TAG_EDSA | 311 | #ifdef CONFIG_NET_DSA_TAG_EDSA |
302 | static const struct net_device_ops edsa_netdev_ops = { | 312 | static const struct net_device_ops edsa_netdev_ops = { |
313 | .ndo_init = dsa_slave_init, | ||
303 | .ndo_open = dsa_slave_open, | 314 | .ndo_open = dsa_slave_open, |
304 | .ndo_stop = dsa_slave_close, | 315 | .ndo_stop = dsa_slave_close, |
305 | .ndo_start_xmit = edsa_xmit, | 316 | .ndo_start_xmit = edsa_xmit, |
@@ -312,6 +323,7 @@ static const struct net_device_ops edsa_netdev_ops = { | |||
312 | #endif | 323 | #endif |
313 | #ifdef CONFIG_NET_DSA_TAG_TRAILER | 324 | #ifdef CONFIG_NET_DSA_TAG_TRAILER |
314 | static const struct net_device_ops trailer_netdev_ops = { | 325 | static const struct net_device_ops trailer_netdev_ops = { |
326 | .ndo_init = dsa_slave_init, | ||
315 | .ndo_open = dsa_slave_open, | 327 | .ndo_open = dsa_slave_open, |
316 | .ndo_stop = dsa_slave_close, | 328 | .ndo_stop = dsa_slave_close, |
317 | .ndo_start_xmit = trailer_xmit, | 329 | .ndo_start_xmit = trailer_xmit, |
@@ -328,7 +340,7 @@ struct net_device * | |||
328 | dsa_slave_create(struct dsa_switch *ds, struct device *parent, | 340 | dsa_slave_create(struct dsa_switch *ds, struct device *parent, |
329 | int port, char *name) | 341 | int port, char *name) |
330 | { | 342 | { |
331 | struct net_device *master = ds->master_netdev; | 343 | struct net_device *master = ds->dst->master_netdev; |
332 | struct net_device *slave_dev; | 344 | struct net_device *slave_dev; |
333 | struct dsa_slave_priv *p; | 345 | struct dsa_slave_priv *p; |
334 | int ret; | 346 | int ret; |
@@ -343,7 +355,7 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, | |||
343 | memcpy(slave_dev->dev_addr, master->dev_addr, ETH_ALEN); | 355 | memcpy(slave_dev->dev_addr, master->dev_addr, ETH_ALEN); |
344 | slave_dev->tx_queue_len = 0; | 356 | slave_dev->tx_queue_len = 0; |
345 | 357 | ||
346 | switch (ds->tag_protocol) { | 358 | switch (ds->dst->tag_protocol) { |
347 | #ifdef CONFIG_NET_DSA_TAG_DSA | 359 | #ifdef CONFIG_NET_DSA_TAG_DSA |
348 | case htons(ETH_P_DSA): | 360 | case htons(ETH_P_DSA): |
349 | slave_dev->netdev_ops = &dsa_netdev_ops; | 361 | slave_dev->netdev_ops = &dsa_netdev_ops; |