net: dsa: pass bridge down to drivers

Some DSA drivers may or may not support multiple software bridges on top
of an hardware switch.

It is more convenient for them to access the bridge's net_device for
finer configuration.

Removing the need to craft and access a bitmask also simplifies the
code.

This patch changes the signature of bridge related functions, update DSA
drivers, and removes dsa_slave_br_port_mask.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vivien Didelot
2016-02-12 12:09:39 -05:00
committed by David S. Miller
parent d715fa6431
commit a6692754d6
7 changed files with 30 additions and 46 deletions

View File

@@ -385,31 +385,6 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return -EOPNOTSUPP;
}
/* Return a bitmask of all ports being currently bridged within a given bridge
* device. Note that on leave, the mask will still return the bitmask of ports
* currently bridged, prior to port removal, and this is exactly what we want.
*/
static u32 dsa_slave_br_port_mask(struct dsa_switch *ds,
struct net_device *bridge)
{
struct dsa_slave_priv *p;
unsigned int port;
u32 mask = 0;
for (port = 0; port < DSA_MAX_PORTS; port++) {
if (!dsa_is_port_initialized(ds, port))
continue;
p = netdev_priv(ds->ports[port]);
if (ds->ports[port]->priv_flags & IFF_BRIDGE_PORT &&
p->bridge_dev == bridge)
mask |= 1 << port;
}
return mask;
}
static int dsa_slave_stp_update(struct net_device *dev, u8 state)
{
struct dsa_slave_priv *p = netdev_priv(dev);
@@ -533,8 +508,7 @@ static int dsa_slave_bridge_port_join(struct net_device *dev,
p->bridge_dev = br;
if (ds->drv->port_join_bridge)
ret = ds->drv->port_join_bridge(ds, p->port,
dsa_slave_br_port_mask(ds, br));
ret = ds->drv->port_join_bridge(ds, p->port, br);
return ret;
}
@@ -547,8 +521,7 @@ static int dsa_slave_bridge_port_leave(struct net_device *dev)
if (ds->drv->port_leave_bridge)
ret = ds->drv->port_leave_bridge(ds, p->port,
dsa_slave_br_port_mask(ds, p->bridge_dev));
ret = ds->drv->port_leave_bridge(ds, p->port);
p->bridge_dev = NULL;