Skip to content

Commit ec52b69

Browse files
clementlegerdavem330
authored andcommitted
net: dsa: rzn1-a5psw: disable learning for standalone ports
When ports are in standalone mode, they should have learning disabled to avoid adding new entries in the MAC lookup table which might be used by other bridge ports to forward packets. While adding that, also make sure learning is enabled for CPU port. Fixes: 888cdb8 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver") Signed-off-by: Clément Léger <[email protected]> Signed-off-by: Alexis Lothoré <[email protected]> Reviewed-by: Piotr Raczynski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ebe9bc5 commit ec52b69

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/net/dsa/rzn1_a5psw.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port,
340340
a5psw_reg_writel(a5psw, offsets[i], a5psw->bridged_ports);
341341
}
342342

343+
static void a5psw_port_set_standalone(struct a5psw *a5psw, int port,
344+
bool standalone)
345+
{
346+
a5psw_port_learning_set(a5psw, port, !standalone);
347+
a5psw_flooding_set_resolution(a5psw, port, !standalone);
348+
a5psw_port_mgmtfwd_set(a5psw, port, standalone);
349+
}
350+
343351
static int a5psw_port_bridge_join(struct dsa_switch *ds, int port,
344352
struct dsa_bridge bridge,
345353
bool *tx_fwd_offload,
@@ -355,8 +363,7 @@ static int a5psw_port_bridge_join(struct dsa_switch *ds, int port,
355363
}
356364

357365
a5psw->br_dev = bridge.dev;
358-
a5psw_flooding_set_resolution(a5psw, port, true);
359-
a5psw_port_mgmtfwd_set(a5psw, port, false);
366+
a5psw_port_set_standalone(a5psw, port, false);
360367

361368
return 0;
362369
}
@@ -366,8 +373,7 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port,
366373
{
367374
struct a5psw *a5psw = ds->priv;
368375

369-
a5psw_flooding_set_resolution(a5psw, port, false);
370-
a5psw_port_mgmtfwd_set(a5psw, port, true);
376+
a5psw_port_set_standalone(a5psw, port, true);
371377

372378
/* No more ports bridged */
373379
if (a5psw->bridged_ports == BIT(A5PSW_CPU_PORT))
@@ -761,13 +767,15 @@ static int a5psw_setup(struct dsa_switch *ds)
761767
if (dsa_port_is_unused(dp))
762768
continue;
763769

764-
/* Enable egress flooding for CPU port */
765-
if (dsa_port_is_cpu(dp))
770+
/* Enable egress flooding and learning for CPU port */
771+
if (dsa_port_is_cpu(dp)) {
766772
a5psw_flooding_set_resolution(a5psw, port, true);
773+
a5psw_port_learning_set(a5psw, port, true);
774+
}
767775

768-
/* Enable management forward only for user ports */
776+
/* Enable standalone mode for user ports */
769777
if (dsa_port_is_user(dp))
770-
a5psw_port_mgmtfwd_set(a5psw, port, true);
778+
a5psw_port_set_standalone(a5psw, port, true);
771779
}
772780

773781
return 0;

0 commit comments

Comments
 (0)