[PATCH] net: dsa: lan9303: add VLAN IDs to master device

From: Mans Rullgard
Date: Wed Feb 16 2022 - 10:11:18 EST


If the master device does VLAN filtering, the IDs used by the switch
must be added for any frames to be received. Do this in the
port_enable() function, and remove them in port_disable().

Signed-off-by: Mans Rullgard <mans@xxxxxxxxx>
---
drivers/net/dsa/lan9303-core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 873a5588171b..f3bf642fbf92 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -1084,20 +1084,32 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phy)
{
struct lan9303 *chip = ds->priv;
+ struct dsa_port *cpu_dp;

if (!dsa_is_user_port(ds, port))
return 0;

+ dsa_switch_for_each_cpu_port(cpu_dp, ds)
+ break;
+
+ vlan_vid_add(cpu_dp->master, htons(ETH_P_8021Q), port);
+
return lan9303_enable_processing_port(chip, port);
}

static void lan9303_port_disable(struct dsa_switch *ds, int port)
{
struct lan9303 *chip = ds->priv;
+ struct dsa_port *cpu_dp;

if (!dsa_is_user_port(ds, port))
return;

+ dsa_switch_for_each_cpu_port(cpu_dp, ds)
+ break;
+
+ vlan_vid_del(cpu_dp->master, htons(ETH_P_8021Q), port);
+
lan9303_disable_processing_port(chip, port);
lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN);
}
--
2.35.1