Skip to content

Commit 9dc8b13

Browse files
vivienJakub Kicinski
authored andcommitted
net: dsa: mv88e6xxx: use ports list to map port VLAN
Instead of digging into the other dsa_switch structures of the fabric and relying too much on the dsa_to_port helper, use the new list of switch fabric ports to define the mask of the local ports allowed to receive frames from another port of the fabric. Signed-off-by: Vivien Didelot <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d14939b commit 9dc8b13

File tree

1 file changed

+20
-12
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+20
-12
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,35 +1057,43 @@ static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
10571057
return 0;
10581058
}
10591059

1060+
/* Mask of the local ports allowed to receive frames from a given fabric port */
10601061
static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
10611062
{
1062-
struct dsa_switch *ds = NULL;
1063+
struct dsa_switch *ds = chip->ds;
1064+
struct dsa_switch_tree *dst = ds->dst;
10631065
struct net_device *br;
1066+
struct dsa_port *dp;
1067+
bool found = false;
10641068
u16 pvlan;
1065-
int i;
10661069

1067-
if (dev < DSA_MAX_SWITCHES)
1068-
ds = chip->ds->dst->ds[dev];
1070+
list_for_each_entry(dp, &dst->ports, list) {
1071+
if (dp->ds->index == dev && dp->index == port) {
1072+
found = true;
1073+
break;
1074+
}
1075+
}
10691076

10701077
/* Prevent frames from unknown switch or port */
1071-
if (!ds || port >= ds->num_ports)
1078+
if (!found)
10721079
return 0;
10731080

10741081
/* Frames from DSA links and CPU ports can egress any local port */
1075-
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1082+
if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
10761083
return mv88e6xxx_port_mask(chip);
10771084

1078-
br = dsa_to_port(ds, port)->bridge_dev;
1085+
br = dp->bridge_dev;
10791086
pvlan = 0;
10801087

10811088
/* Frames from user ports can egress any local DSA links and CPU ports,
10821089
* as well as any local member of their bridge group.
10831090
*/
1084-
for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1085-
if (dsa_is_cpu_port(chip->ds, i) ||
1086-
dsa_is_dsa_port(chip->ds, i) ||
1087-
(br && dsa_to_port(chip->ds, i)->bridge_dev == br))
1088-
pvlan |= BIT(i);
1091+
list_for_each_entry(dp, &dst->ports, list)
1092+
if (dp->ds == ds &&
1093+
(dp->type == DSA_PORT_TYPE_CPU ||
1094+
dp->type == DSA_PORT_TYPE_DSA ||
1095+
(br && dp->bridge_dev == br)))
1096+
pvlan |= BIT(dp->index);
10891097

10901098
return pvlan;
10911099
}

0 commit comments

Comments
 (0)