Skip to content

Commit 0b69c54

Browse files
LGA1150davem330
authored andcommitted
net: dsa: mt7530: enable assisted learning on CPU port
Consider the following bridge configuration, where bond0 is not offloaded: +-- br0 --+ / / | \ / / | \ / | | bond0 / | | / \ swp0 swp1 swp2 swp3 swp4 . . . . . . A B C Address learning is enabled on offloaded ports (swp0~2) and the CPU port, so when client A sends a packet to C, the following will happen: 1. The switch learns that client A can be reached at swp0. 2. The switch probably already knows that client C can be reached at the CPU port, so it forwards the packet to the CPU. 3. The bridge core knows client C can be reached at bond0, so it forwards the packet back to the switch. 4. The switch learns that client A can be reached at the CPU port. 5. The switch forwards the packet to either swp3 or swp4, according to the packet's tag. That makes client A's MAC address flap between swp0 and the CPU port. If client B sends a packet to A, it is possible that the packet is forwarded to the CPU. With offload_fwd_mark = 1, the bridge core won't forward it back to the switch, resulting in packet loss. As we have the assisted_learning_on_cpu_port in DSA core now, enable that and disable hardware learning on the CPU port. Signed-off-by: DENG Qingfang <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8eceea4 commit 0b69c54

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,7 @@ mt7530_setup(struct dsa_switch *ds)
20462046
* as two netdev instances.
20472047
*/
20482048
dn = dsa_to_port(ds, MT7530_CPU_PORT)->master->dev.of_node->parent;
2049+
ds->assisted_learning_on_cpu_port = true;
20492050
ds->mtu_enforcement_ingress = true;
20502051

20512052
if (priv->id == ID_MT7530) {
@@ -2116,15 +2117,15 @@ mt7530_setup(struct dsa_switch *ds)
21162117
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
21172118
PCR_MATRIX_CLR);
21182119

2120+
/* Disable learning by default on all ports */
2121+
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
2122+
21192123
if (dsa_is_cpu_port(ds, i)) {
21202124
ret = mt753x_cpu_port_enable(ds, i);
21212125
if (ret)
21222126
return ret;
21232127
} else {
21242128
mt7530_port_disable(ds, i);
2125-
2126-
/* Disable learning by default on all user ports */
2127-
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
21282129
}
21292130
/* Enable consistent egress tag */
21302131
mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
@@ -2281,6 +2282,9 @@ mt7531_setup(struct dsa_switch *ds)
22812282
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
22822283
PCR_MATRIX_CLR);
22832284

2285+
/* Disable learning by default on all ports */
2286+
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
2287+
22842288
mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
22852289

22862290
if (dsa_is_cpu_port(ds, i)) {
@@ -2289,16 +2293,14 @@ mt7531_setup(struct dsa_switch *ds)
22892293
return ret;
22902294
} else {
22912295
mt7530_port_disable(ds, i);
2292-
2293-
/* Disable learning by default on all user ports */
2294-
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
22952296
}
22962297

22972298
/* Enable consistent egress tag */
22982299
mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
22992300
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
23002301
}
23012302

2303+
ds->assisted_learning_on_cpu_port = true;
23022304
ds->mtu_enforcement_ingress = true;
23032305

23042306
/* Flush the FDB table */

0 commit comments

Comments
 (0)