Commit 65144067 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Jakub Kicinski

net: dsa: mv88e6xxx: compute port vlan membership based on dp->bridge_dev comparison

The goal of this change is to reduce mv88e6xxx_port_vlan() to a form
where dsa_port_bridge_same() can be used, since the dp->bridge_dev
pointer will be hidden in a future change.

To do that, we observe that the "br" pointer is deduced from a
dp->bridge_dev in both cases (of a physical switch port as well as a
virtual bridge). So instead of keeping the "br" pointer, we can just
keep the "dp" pointer from which "br" gets derived.

In the last iteration over switch ports, we must use another iterator
variable, "other_dp"since now we use the "dp" variable to keep an
indirect reference to the bridge. While at it, the old code used to
filter only the ports which were part of the same switch as "ds".
There exists a dedicated DSA port iterator for that:
dsa_switch_for_each_port (which skips the ports in the tree that belong
to non-local switches), so we can just use that.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0493fa79
...@@ -1228,8 +1228,7 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) ...@@ -1228,8 +1228,7 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
{ {
struct dsa_switch *ds = chip->ds; struct dsa_switch *ds = chip->ds;
struct dsa_switch_tree *dst = ds->dst; struct dsa_switch_tree *dst = ds->dst;
struct net_device *br; struct dsa_port *dp, *other_dp;
struct dsa_port *dp;
bool found = false; bool found = false;
u16 pvlan; u16 pvlan;
...@@ -1238,11 +1237,9 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) ...@@ -1238,11 +1237,9 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
list_for_each_entry(dp, &dst->ports, list) { list_for_each_entry(dp, &dst->ports, list) {
if (dp->ds->index == dev && dp->index == port) { if (dp->ds->index == dev && dp->index == port) {
/* dp might be a DSA link or a user port, so it /* dp might be a DSA link or a user port, so it
* might or might not have a bridge_dev * might or might not have a bridge.
* pointer. Use the "found" variable for both * Use the "found" variable for both cases.
* cases.
*/ */
br = dp->bridge_dev;
found = true; found = true;
break; break;
} }
...@@ -1256,7 +1253,6 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) ...@@ -1256,7 +1253,6 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
if (dp->bridge_num + dst->last_switch != dev) if (dp->bridge_num + dst->last_switch != dev)
continue; continue;
br = dp->bridge_dev;
found = true; found = true;
break; break;
} }
...@@ -1275,12 +1271,11 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) ...@@ -1275,12 +1271,11 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
/* Frames from user ports can egress any local DSA links and CPU ports, /* Frames from user ports can egress any local DSA links and CPU ports,
* as well as any local member of their bridge group. * as well as any local member of their bridge group.
*/ */
list_for_each_entry(dp, &dst->ports, list) dsa_switch_for_each_port(other_dp, ds)
if (dp->ds == ds && if (other_dp->type == DSA_PORT_TYPE_CPU ||
(dp->type == DSA_PORT_TYPE_CPU || other_dp->type == DSA_PORT_TYPE_DSA ||
dp->type == DSA_PORT_TYPE_DSA || (dp->bridge_dev && dp->bridge_dev == other_dp->bridge_dev))
(br && dp->bridge_dev == br))) pvlan |= BIT(other_dp->index);
pvlan |= BIT(dp->index);
return pvlan; return pvlan;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment