提交 e5887a2a 编写于 作者: V Vivien Didelot 提交者: David S. Miller

net: dsa: mv88e6xxx: rework in-chip bridging

All ports -- internal and external, for chips featuring a PVT -- have a
mask restricting to which internal ports a frame is allowed to egress.

Now that DSA exposes the number of ports and their bridge devices, it is
possible to extract the code generating the VLAN map and make it generic
so that it can be shared later with the cross-chip bridging code.
Signed-off-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 73b1204d
...@@ -1123,27 +1123,42 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1123,27 +1123,42 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
return err; return err;
} }
static int _mv88e6xxx_port_based_vlan_map(struct mv88e6xxx_chip *chip, int port) static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
{ {
struct dsa_switch *ds = chip->ds; struct dsa_switch *ds = NULL;
struct net_device *bridge = ds->ports[port].bridge_dev; struct net_device *br;
u16 output_ports = 0; u16 pvlan;
int i; int i;
/* allow CPU port or DSA link(s) to send frames to every port */ if (dev < DSA_MAX_SWITCHES)
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { ds = chip->ds->dst->ds[dev];
output_ports = ~0;
} else {
for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
/* allow sending frames to every group member */
if (bridge && ds->ports[i].bridge_dev == bridge)
output_ports |= BIT(i);
/* allow sending frames to CPU port and DSA link(s) */ /* Prevent frames from unknown switch or port */
if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)) if (!ds || port >= ds->num_ports)
output_ports |= BIT(i); return 0;
}
} /* Frames from DSA links and CPU ports can egress any local port */
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
return mv88e6xxx_port_mask(chip);
br = ds->ports[port].bridge_dev;
pvlan = 0;
/* Frames from user ports can egress any local DSA links and CPU ports,
* as well as any local member of their bridge group.
*/
for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
if (dsa_is_cpu_port(chip->ds, i) ||
dsa_is_dsa_port(chip->ds, i) ||
(br && chip->ds->ports[i].bridge_dev == br))
pvlan |= BIT(i);
return pvlan;
}
static int _mv88e6xxx_port_based_vlan_map(struct mv88e6xxx_chip *chip, int port)
{
u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
/* prevent frames from going back out of the port they came in on */ /* prevent frames from going back out of the port they came in on */
output_ports &= ~BIT(port); output_ports &= ~BIT(port);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册