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:
parent
d715fa6431
commit
a6692754d6
|
@ -524,17 +524,14 @@ Bridge layer
|
|||
- port_join_bridge: bridge layer function invoked when a given switch port is
|
||||
added to a bridge, this function should be doing the necessary at the switch
|
||||
level to permit the joining port from being added to the relevant logical
|
||||
domain for it to ingress/egress traffic with other members of the bridge. DSA
|
||||
does nothing but calculate a bitmask of switch ports currently members of the
|
||||
specified bridge being requested the join
|
||||
domain for it to ingress/egress traffic with other members of the bridge.
|
||||
|
||||
- port_leave_bridge: bridge layer function invoked when a given switch port is
|
||||
removed from a bridge, this function should be doing the necessary at the
|
||||
switch level to deny the leaving port from ingress/egress traffic from the
|
||||
remaining bridge members. When the port leaves the bridge, it should be aged
|
||||
out at the switch hardware for the switch to (re) learn MAC addresses behind
|
||||
this port. DSA calculates the bitmask of ports still members of the bridge
|
||||
being left
|
||||
this port.
|
||||
|
||||
- port_stp_update: bridge layer function invoked when a given switch port STP
|
||||
state is computed by the bridge layer and should be propagated to switch
|
||||
|
|
|
@ -483,16 +483,17 @@ static int bcm_sf2_sw_fast_age_port(struct dsa_switch *ds, int port)
|
|||
}
|
||||
|
||||
static int bcm_sf2_sw_br_join(struct dsa_switch *ds, int port,
|
||||
u32 br_port_mask)
|
||||
struct net_device *bridge)
|
||||
{
|
||||
struct bcm_sf2_priv *priv = ds_to_priv(ds);
|
||||
unsigned int i;
|
||||
u32 reg, p_ctl;
|
||||
|
||||
priv->port_sts[port].bridge_dev = bridge;
|
||||
p_ctl = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(port));
|
||||
|
||||
for (i = 0; i < priv->hw_params.num_ports; i++) {
|
||||
if (!((1 << i) & br_port_mask))
|
||||
if (priv->port_sts[i].bridge_dev != bridge)
|
||||
continue;
|
||||
|
||||
/* Add this local port to the remote port VLAN control
|
||||
|
@ -515,10 +516,10 @@ static int bcm_sf2_sw_br_join(struct dsa_switch *ds, int port,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port,
|
||||
u32 br_port_mask)
|
||||
static int bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct bcm_sf2_priv *priv = ds_to_priv(ds);
|
||||
struct net_device *bridge = priv->port_sts[port].bridge_dev;
|
||||
unsigned int i;
|
||||
u32 reg, p_ctl;
|
||||
|
||||
|
@ -526,7 +527,7 @@ static int bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port,
|
|||
|
||||
for (i = 0; i < priv->hw_params.num_ports; i++) {
|
||||
/* Don't touch the remaining ports */
|
||||
if (!((1 << i) & br_port_mask))
|
||||
if (priv->port_sts[i].bridge_dev != bridge)
|
||||
continue;
|
||||
|
||||
reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(i));
|
||||
|
@ -541,6 +542,7 @@ static int bcm_sf2_sw_br_leave(struct dsa_switch *ds, int port,
|
|||
|
||||
core_writel(priv, p_ctl, CORE_PORT_VLAN_CTL_PORT(port));
|
||||
priv->port_sts[port].vlan_ctl_mask = p_ctl;
|
||||
priv->port_sts[port].bridge_dev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ struct bcm_sf2_port_status {
|
|||
struct ethtool_eee eee;
|
||||
|
||||
u32 vlan_ctl_mask;
|
||||
|
||||
struct net_device *bridge_dev;
|
||||
};
|
||||
|
||||
struct bcm_sf2_arl_entry {
|
||||
|
|
|
@ -1889,13 +1889,22 @@ unlock:
|
|||
return err;
|
||||
}
|
||||
|
||||
int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, u32 members)
|
||||
int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
|
||||
struct net_device *bridge)
|
||||
{
|
||||
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
||||
|
||||
ps->ports[port].bridge_dev = bridge;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, u32 members)
|
||||
int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
||||
|
||||
ps->ports[port].bridge_dev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,6 +380,7 @@ struct mv88e6xxx_vtu_stu_entry {
|
|||
};
|
||||
|
||||
struct mv88e6xxx_priv_port {
|
||||
struct net_device *bridge_dev;
|
||||
u8 state;
|
||||
};
|
||||
|
||||
|
@ -481,8 +482,9 @@ int mv88e6xxx_phy_write_indirect(struct dsa_switch *ds, int addr, int regnum,
|
|||
int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
|
||||
int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
|
||||
struct phy_device *phydev, struct ethtool_eee *e);
|
||||
int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, u32 members);
|
||||
int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, u32 members);
|
||||
int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
|
||||
struct net_device *bridge);
|
||||
int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port);
|
||||
int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state);
|
||||
int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
|
||||
const struct switchdev_obj_port_vlan *vlan,
|
||||
|
|
|
@ -297,9 +297,8 @@ struct dsa_switch_driver {
|
|||
* Bridge integration
|
||||
*/
|
||||
int (*port_join_bridge)(struct dsa_switch *ds, int port,
|
||||
u32 br_port_mask);
|
||||
int (*port_leave_bridge)(struct dsa_switch *ds, int port,
|
||||
u32 br_port_mask);
|
||||
struct net_device *bridge);
|
||||
int (*port_leave_bridge)(struct dsa_switch *ds, int port);
|
||||
int (*port_stp_update)(struct dsa_switch *ds, int port,
|
||||
u8 state);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue