Skip to content

Commit ff22102

Browse files
arinc9davem330
authored andcommitted
net: dsa: mt7530: set all CPU ports in MT7531_CPU_PMAP
MT7531_CPU_PMAP represents the destination port mask for trapped-to-CPU frames (further restricted by PCR_MATRIX). Currently the driver sets the first CPU port as the single port in this bit mask, which works fine regardless of whether the device tree defines port 5, 6 or 5+6 as CPU ports. This is because the logic coincides with DSA's logic of picking the first CPU port as the CPU port that all user ports are affine to, by default. An upcoming change would like to influence DSA's selection of the default CPU port to no longer be the first one, and in that case, this logic needs adaptation. Since there is no observed leakage or duplication of frames if all CPU ports are defined in this bit mask, simply include them all. Suggested-by: Russell King (Oracle) <[email protected]> Suggested-by: Vladimir Oltean <[email protected]> Signed-off-by: Arınç ÜNAL <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9a43827 commit ff22102

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,13 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
10101010
if (priv->id == ID_MT7621)
10111011
mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port));
10121012

1013+
/* Add the CPU port to the CPU port bitmap for MT7531 and the switch on
1014+
* the MT7988 SoC. Trapped frames will be forwarded to the CPU port that
1015+
* is affine to the inbound user port.
1016+
*/
1017+
if (priv->id == ID_MT7531 || priv->id == ID_MT7988)
1018+
mt7530_set(priv, MT7531_CFC, MT7531_CPU_PMAP(BIT(port)));
1019+
10131020
/* CPU port gets connected to all user ports of
10141021
* the switch.
10151022
*/
@@ -2352,15 +2359,9 @@ static int
23522359
mt7531_setup_common(struct dsa_switch *ds)
23532360
{
23542361
struct mt7530_priv *priv = ds->priv;
2355-
struct dsa_port *cpu_dp;
23562362
int ret, i;
23572363

2358-
/* BPDU to CPU port */
2359-
dsa_switch_for_each_cpu_port(cpu_dp, ds) {
2360-
mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
2361-
BIT(cpu_dp->index));
2362-
break;
2363-
}
2364+
/* Trap BPDUs to the CPU port(s) */
23642365
mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
23652366
MT753X_BPDU_CPU_ONLY);
23662367

drivers/net/dsa/mt7530.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum mt753x_id {
5454
#define MT7531_MIRROR_PORT_GET(x) (((x) >> 16) & MIRROR_MASK)
5555
#define MT7531_MIRROR_PORT_SET(x) (((x) & MIRROR_MASK) << 16)
5656
#define MT7531_CPU_PMAP_MASK GENMASK(7, 0)
57+
#define MT7531_CPU_PMAP(x) FIELD_PREP(MT7531_CPU_PMAP_MASK, x)
5758

5859
#define MT753X_MIRROR_REG(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
5960
MT7531_CFC : MT7530_MFC)

0 commit comments

Comments
 (0)