]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: lan9303: add VLAN IDs to master device
authorMans Rullgard <mans@mansr.com>
Wed, 16 Feb 2022 20:48:18 +0000 (20:48 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Feb 2022 17:32:13 +0000 (09:32 -0800)
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().

Fixes: 3bbb5663f4fc ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")
Signed-off-by: Mans Rullgard <mans@mansr.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20220216204818.28746-1-mans@mansr.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/Kconfig
drivers/net/dsa/lan9303-core.c

index c0c91440340ae67d0e313a012b8d5c70d2ec9a3e..0029d279616fd673389c3fc277d4bb39e6061226 100644 (file)
@@ -82,6 +82,7 @@ config NET_DSA_REALTEK_SMI
 
 config NET_DSA_SMSC_LAN9303
        tristate
+       depends on VLAN_8021Q || VLAN_8021Q=n
        select NET_DSA_TAG_LAN9303
        select REGMAP
        help
index 873a5588171bf32eb3de16439d0ab44700cf99cc..3969d89fa4db0bf19476283f83f3c217e3a8ac2e 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mii.h>
 #include <linux/phy.h>
 #include <linux/if_bridge.h>
+#include <linux/if_vlan.h>
 #include <linux/etherdevice.h>
 
 #include "lan9303.h"
@@ -1083,21 +1084,27 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
 static int lan9303_port_enable(struct dsa_switch *ds, int port,
                               struct phy_device *phy)
 {
+       struct dsa_port *dp = dsa_to_port(ds, port);
        struct lan9303 *chip = ds->priv;
 
-       if (!dsa_is_user_port(ds, port))
+       if (!dsa_port_is_user(dp))
                return 0;
 
+       vlan_vid_add(dp->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 dsa_port *dp = dsa_to_port(ds, port);
        struct lan9303 *chip = ds->priv;
 
-       if (!dsa_is_user_port(ds, port))
+       if (!dsa_port_is_user(dp))
                return;
 
+       vlan_vid_del(dp->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);
 }